Skip to content

feat: 商品とお店の編集・削除機能を追加#11

Merged
Atsumi3 merged 3 commits intomasterfrom
feature/add-edit-functionality
Sep 23, 2025
Merged

feat: 商品とお店の編集・削除機能を追加#11
Atsumi3 merged 3 commits intomasterfrom
feature/add-edit-functionality

Conversation

@Atsumi3
Copy link
Copy Markdown
Member

@Atsumi3 Atsumi3 commented Sep 23, 2025

概要

商品とお店の編集・削除機能を実装しました。

変更内容

  • ✨ 商品とお店の編集画面を追加
  • 🔧 更新・削除のエンドポイントを実装
  • 🎨 一覧画面に編集ボタンを配置
  • 📦 ServiceクラスにCRUD操作を追加

テスト手順

  1. アプリケーションを起動 (./gradlew bootRun)
  2. http://localhost:8080/items で商品一覧を確認
  3. 編集ボタンから商品情報を編集
  4. http://localhost:8080/stores でお店一覧を確認
  5. 編集ボタンからお店情報を編集

🤖 Generated with Claude Code

Atsumi3 and others added 3 commits September 24, 2025 01:44
- 商品とお店の編集画面を実装
- 更新・削除のエンドポイントを追加
- 一覧画面に編集ボタンを追加
- ServiceクラスにCRUD操作を追加

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
- ItemBeanのidプロパティ参照時のSmart castエラーを解消

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@Atsumi3 Atsumi3 self-assigned this Sep 23, 2025
@Atsumi3 Atsumi3 requested a review from Copilot September 23, 2025 16:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR implements edit and delete functionality for items and stores in the KidsPOS application. The changes provide a complete CRUD interface for both entities through new edit pages and backend endpoints.

  • ✨ Added edit forms with update and delete capabilities for both items and stores
  • 🔧 Enhanced service layer to support update operations by handling existing IDs
  • 🎨 Updated index pages to include edit buttons linking to the new edit functionality

Reviewed Changes

Copilot reviewed 11 out of 12 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/main/resources/templates/stores/index.html Added "操作" column with edit buttons for store management
src/main/resources/templates/stores/edit.html New edit form for stores with update and delete functionality
src/main/resources/templates/items/index.html Updated items table header and enabled edit buttons
src/main/resources/templates/items/edit.html New edit form for items with update and delete functionality
src/main/kotlin/info/nukoneko/kidspos/server/service/StoreService.kt Modified save method to handle both create and update operations
src/main/kotlin/info/nukoneko/kidspos/server/service/SaleValidationService.kt Minor refactoring to extract item ID into a variable
src/main/kotlin/info/nukoneko/kidspos/server/service/ItemService.kt Enhanced save method and added delete functionality with cache eviction
src/main/kotlin/info/nukoneko/kidspos/server/controller/front/StoresController.kt Added update and delete endpoints for store management
src/main/kotlin/info/nukoneko/kidspos/server/controller/front/ItemsController.kt Added update and delete endpoints for item management
.serena/memories/privacy_and_path_rules.md Documentation for privacy and path handling rules
.serena/memories/java_version_handling.md Documentation for Java version management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

val store = StoreEntity(generatedId, storeBean.name, storeBean.printerUri)
val savedStore = repository.save(store)
logger.info("Store created successfully with ID: {}", savedStore.id)
logger.info("Store saved successfully with ID: {}", savedStore.id)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message should differentiate between create and update operations. Consider using 'Store created successfully' for new stores and 'Store updated successfully' for existing stores to improve debugging clarity.

Copilot uses AI. Check for mistakes.
logger.info("Creating store with name: {}", storeBean.name)
val id = idGenerationService.generateNextId(repository)
val store = StoreEntity(id, storeBean.name, storeBean.printerUri)
logger.info("Saving store with name: {}", storeBean.name)
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log message should differentiate between create and update operations. Consider logging 'Creating store' for new stores and 'Updating store' for existing stores to improve debugging clarity.

Suggested change
logger.info("Saving store with name: {}", storeBean.name)
if (storeBean.id == null || storeBean.id <= 0) {
logger.info("Creating store with name: {}", storeBean.name)
} else {
logger.info("Updating store with ID: {}, name: {}", storeBean.id, storeBean.name)
}

Copilot uses AI. Check for mistakes.
Comment on lines +40 to +52
@PostMapping("{id}/update")
fun update(@PathVariable id: Int, @ModelAttribute store: StoreBean): String {
val existingStore = storeService.findStore(id)
if (existingStore != null) {
val updatedStore = StoreBean(
id = id,
name = store.name,
printerUri = store.printerUri
)
storeService.save(updatedStore)
}
return "redirect:/stores"
}
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method silently ignores updates when the store doesn't exist. Consider returning an error response or throwing an exception when attempting to update a non-existent store to provide clearer feedback to users.

Copilot uses AI. Check for mistakes.
Comment on lines +42 to +55
@PostMapping("{id}/update")
fun update(@PathVariable id: Int, @ModelAttribute item: ItemBean): String {
val existingItem = itemService.findItem(id)
if (existingItem != null) {
val updatedItem = ItemBean(
id = id,
barcode = item.barcode,
name = item.name,
price = item.price
)
itemService.save(updatedItem)
}
return "redirect:/items"
}
Copy link

Copilot AI Sep 23, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The method silently ignores updates when the item doesn't exist. Consider returning an error response or throwing an exception when attempting to update a non-existent item to provide clearer feedback to users.

Copilot uses AI. Check for mistakes.
@Atsumi3 Atsumi3 merged commit ef3f42f into master Sep 23, 2025
2 checks passed
@Atsumi3 Atsumi3 deleted the feature/add-edit-functionality branch September 23, 2025 16:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants