Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ jobs:
run: |
sudo apt-get update && sudo apt-get install -y sqlite3
sqlite3 test.db "CREATE TABLE item (id INTEGER PRIMARY KEY, barcode TEXT, name TEXT, price INTEGER);
CREATE TABLE sale (id INTEGER PRIMARY KEY, storeId INTEGER, staffId INTEGER, quantity INTEGER, amount INTEGER, deposit INTEGER, createdAt TEXT);
CREATE TABLE sale (id INTEGER PRIMARY KEY, storeId INTEGER, quantity INTEGER, amount INTEGER, deposit INTEGER, createdAt TEXT);
CREATE TABLE sale_detail (id INTEGER PRIMARY KEY, saleId INTEGER, itemId INTEGER, price INTEGER, quantity INTEGER);
INSERT INTO item VALUES (1, 'test-barcode', 'Test Item', 100);
INSERT INTO item VALUES (2, 'test-barcode-2', 'Test Item 2', 200);"
Expand Down
205 changes: 1 addition & 204 deletions api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ tags:
description: 商品管理
- name: Sales
description: 売上管理
- name: Staff
description: スタッフ管理
- name: Stores
description: 店舗管理
- name: Settings
description: 設定管理
- name: Users
description: ユーザー管理

paths:
# Items
Expand Down Expand Up @@ -269,9 +265,6 @@ paths:
change:
type: integer
description: おつり
staffId:
type: integer
description: スタッフID
storeId:
type: integer
description: 店舗ID
Expand Down Expand Up @@ -335,113 +328,6 @@ paths:
isValid:
type: boolean

# Staff
/api/staff:
get:
tags:
- Staff
summary: スタッフ一覧取得
description: 全スタッフを取得します
operationId: getAllStaff
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/StaffEntity'

post:
tags:
- Staff
summary: スタッフ登録
description: 新しいスタッフを登録します
operationId: createStaff
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateStaffRequest'
responses:
'201':
description: Created
content:
application/json:
schema:
$ref: '#/components/schemas/StaffEntity'

/api/staff/{barcode}:
get:
tags:
- Staff
summary: スタッフ取得
description: バーコードからスタッフを取得します
operationId: getStaffByBarcode
parameters:
- name: barcode
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/StaffEntity'
'404':
description: Staff not found

put:
tags:
- Staff
summary: スタッフ更新
description: スタッフ情報を更新します
operationId: updateStaff
parameters:
- name: barcode
in: path
required: true
schema:
type: string
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateStaffRequest'
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/StaffEntity'
'404':
description: Staff not found

delete:
tags:
- Staff
summary: スタッフ削除
description: スタッフを削除します
operationId: deleteStaff
parameters:
- name: barcode
in: path
required: true
schema:
type: string
responses:
'204':
description: No Content
'404':
description: Staff not found

# Stores
/api/stores:
get:
Expand Down Expand Up @@ -797,46 +683,6 @@ paths:
message:
type: string

# Users
/api/users:
get:
tags:
- Users
summary: ユーザー一覧取得
description: 全ユーザーを取得します
operationId: getAllUsers
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/StaffEntity'

/api/users/{barcode}:
get:
tags:
- Users
summary: ユーザー取得
description: バーコードからユーザーを取得します
operationId: getUserByBarcode
parameters:
- name: barcode
in: path
required: true
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/StaffEntity'
'404':
description: User not found

components:
schemas:
Expand Down Expand Up @@ -896,12 +742,6 @@ components:
storeName:
type: string
description: 店舗名
staffId:
type: string
description: スタッフID
staffName:
type: string
description: スタッフ名
totalAmount:
type: integer
description: 合計金額(リバー)
Expand All @@ -924,8 +764,6 @@ components:
- id
- storeId
- storeName
- staffId
- staffName
- totalAmount
- deposit
- change
Expand Down Expand Up @@ -966,10 +804,6 @@ components:
storeId:
type: integer
description: 店舗ID
staffBarcode:
type: string
nullable: true
description: スタッフバーコード(オプショナル)
itemIds:
type: string
description: 商品IDのカンマ区切り文字列(例:"1,2,3")
Expand All @@ -983,43 +817,6 @@ components:
- itemIds
- deposit

StaffEntity:
type: object
properties:
barcode:
type: string
example: "STAFF001"
name:
type: string
example: "田中太郎"
required:
- barcode
- name

CreateStaffRequest:
type: object
properties:
barcode:
type: string
minLength: 1
maxLength: 50
name:
type: string
minLength: 1
maxLength: 100
required:
- barcode
- name

UpdateStaffRequest:
type: object
properties:
name:
type: string
minLength: 1
maxLength: 100
required:
- name

StoreEntity:
type: object
Expand Down Expand Up @@ -1093,4 +890,4 @@ components:

# セキュリティは現在未実装のため、コメントアウト
# security:
# - bearerAuth: []
# - bearerAuth: []
17 changes: 16 additions & 1 deletion src/main/kotlin/info/nukoneko/kidspos/common/Constants.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,17 @@ object Constants {
object Barcode {
const val SUFFIX_LENGTH = 3
const val MIN_LENGTH = 4
const val TOTAL_LENGTH = 10
const val ID_LENGTH = 6

// バーコード種別コード
const val TYPE_STAFF = "00"
const val TYPE_ITEM = "01"
const val TYPE_SALE = "02"

// バーコードの開始・終了記号
const val PREFIX = "A"
const val SUFFIX = "A"
}

/**
Expand All @@ -25,7 +36,11 @@ object Constants {
*/
object Validation {
const val NAME_MAX_LENGTH = 255
const val BARCODE_PATTERN = "^[0-9]{4,}$"

// 独自バーコードフォーマット: A + 種別(2桁) + ID(6桁) + A
// 種別: 00(STAFF), 01(ITEM), 02(SALE)
// 例: A01000001A (商品ID:1)
const val BARCODE_PATTERN = "^A(00|01|02)\\d{6}A$"
const val MAX_PRICE = 1000000
const val MAX_QUANTITY = 9999
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import java.util.*
data class ReceiptDetail(
val items: List<ItemEntity>,
val storeName: String?,
val staffName: String?,
val deposit: Int,
val transactionId: String?,
val createdAt: Date,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@ class ReceiptPrinter(
command.writeTextLine(dateFormat.format(detail.createdAt))
command.newLine()

// 店舗名・担当者
// 店舗名
command.setGravity(PrintCommand.Direction.LEFT)
if (!detail.storeName.isNullOrEmpty()) {
command.writeTextLine("店舗名:${detail.storeName.toAllEm()}")
}
if (!detail.staffName.isNullOrEmpty()) {
command.writeTextLine("担 当:${detail.staffName.toAllEm()}")
}
command.drawLine()

command.setGravity(PrintCommand.Direction.CENTER)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class ItemApiController {
val headers =
HttpHeaders().apply {
contentType = MediaType.APPLICATION_PDF
setContentDispositionFormData("inline", "barcodes.pdf")
setContentDispositionFormData("attachment", "barcodes.pdf")
}

logger.info("Barcode PDF generated successfully with {} items", items.size)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,15 @@ class SaleApiController(
val saleBean =
SaleBean(
storeId = request.storeId,
staffBarcode = request.staffBarcode,
itemIds = request.itemIds,
deposit = request.deposit,
)
when (val result = saleProcessingService.processSaleWithValidation(saleBean, items)) {
is SaleResult.Success -> {
// Print receipt (staffBarcode is now nullable)
// Print receipt
receiptService.printReceipt(
request.storeId,
items,
request.staffBarcode ?: "",
request.deposit,
)

Expand All @@ -67,7 +65,6 @@ class SaleApiController(
"quantity" to sale.quantity,
"deposit" to request.deposit,
"change" to (request.deposit - sale.amount),
"staffId" to sale.staffId,
"storeId" to sale.storeId,
)
logger.info("Sale created successfully: ID={}", sale.id)
Expand Down Expand Up @@ -108,11 +105,10 @@ class SaleApiController(
// Process the sale
when (val result = saleProcessingService.processSaleWithValidation(saleBean, items)) {
is SaleResult.Success -> {
// Print receipt (staffBarcode is now nullable)
// Print receipt
receiptService.printReceipt(
saleBean.storeId,
items,
saleBean.staffBarcode ?: "",
saleBean.deposit,
)

Expand Down
Loading