From e218d4602f5b59944dfb7926b8023564fb08d62a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Fri, 9 Jan 2026 21:12:39 +0800 Subject: [PATCH] =?UTF-8?q?```=20feat(config):=20=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=95=86=E5=93=81=E9=85=8D=E7=BD=AE=E6=A8=A1=E5=9E=8B=E5=92=8C?= =?UTF-8?q?=E4=BB=BB=E5=8A=A1=E6=9C=8D=E5=8A=A1=E6=9F=A5=E8=AF=A2=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将商品描述字段从 Description 改为 Desc,优化字段命名 - 将价格字段类型从 uint32 改为 int32,支持负数价格表示 - 更新价格信息注释说明,明确 -1 代表不允许购买的含义 - 移除商品分类字段,简化商品配置结构 - 移除备注信息字段,精简数据模型 - 为任务服务添加关键词 --- modules/config/controller/admin/shop.go | 22 ++++++++++++++++++++++ modules/config/model/shop.go | 15 +++++---------- modules/config/service/shop.go | 21 +++++++++++++++++++++ modules/config/service/task.go | 3 ++- 4 files changed, 50 insertions(+), 11 deletions(-) create mode 100644 modules/config/controller/admin/shop.go create mode 100644 modules/config/service/shop.go diff --git a/modules/config/controller/admin/shop.go b/modules/config/controller/admin/shop.go new file mode 100644 index 000000000..361a85bcb --- /dev/null +++ b/modules/config/controller/admin/shop.go @@ -0,0 +1,22 @@ +package admin + +import ( + "blazing/cool" + "blazing/modules/config/service" +) + +type ShopController struct { + *cool.Controller +} + +func init() { + + // 注册路由 + cool.RegisterController(&ShopController{ + &cool.Controller{ + Prefix: "/admin/game/shop", + Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"}, + Service: service.NewShopService(), + }, + }) +} diff --git a/modules/config/model/shop.go b/modules/config/model/shop.go index c0a729c2f..9beef52c3 100644 --- a/modules/config/model/shop.go +++ b/modules/config/model/shop.go @@ -16,27 +16,22 @@ type ShopConfig struct { // 核心字段 ProductName string `gorm:"not null;size:128;comment:'商品名称'" json:"product_name" description:"商品名称"` //商品ID - ProductID uint32 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"` - Description string `gorm:"not null;size:512;comment:'商品描述'" json:"description" description:"商品描述"` + ProductID uint32 `gorm:"not null;uniqueIndex;comment:'商品ID'" json:"product_id" description:"商品ID"` + Desc string `gorm:"not null;size:512;comment:'商品描述'" json:"desc" description:"商品描述"` - // 价格信息 -1代表不允许购买,0免费赠送 - SeerdouPrice uint32 `gorm:"not null;default:0;comment:'骄阳豆价格'" json:"seerdou_price" description:"骄阳豆价格"` - JindouPrice uint32 `gorm:"not null;default:0;comment:'价格'" json:"jindou_price" description:"金豆价格"` + // 价格信息 -1代表不允许购买,0表示不支持购买 + SeerdouPrice int32 `gorm:"not null;default:0;comment:'骄阳豆价格'" json:"seerdou_price" description:"骄阳豆价格"` + JindouPrice int32 `gorm:"not null;default:0;comment:'金豆价格'" json:"jindou_price" description:"金豆价格"` // 库存信息 Stock uint32 `gorm:"not null;default:0;comment:'商品库存数量(0表示无限库存)'" json:"stock" description:"库存数量"` - Category uint32 `gorm:"not null;size:64;comment:'商品分类名称'" json:"category" description:"分类名称"` - // 状态信息 IsOnSale uint32 `gorm:"not null;default:1;comment:'是否上架(0-下架 1-上架)'" json:"is_on_sale" description:"是否上架"` // 限购信息 QuotaLimit uint32 `gorm:"not null;default:0;comment:'单位时间内的限购数量(0表示不限购)'" json:"quota_limit" description:"限购数量"` QuotaCycle uint32 `gorm:"not null;default:0;comment:'限购周期(单位:小时,0表示不限购)'" json:"quota_cycle" description:"限购周期(小时)"` - - // 备注信息 - Remark string `gorm:"size:512;default:'';comment:'商品备注'" json:"remark" description:"备注信息"` } // -------------------------- 核心配套方法(遵循项目规范)-------------------------- diff --git a/modules/config/service/shop.go b/modules/config/service/shop.go new file mode 100644 index 000000000..dab856955 --- /dev/null +++ b/modules/config/service/shop.go @@ -0,0 +1,21 @@ +package service + +import ( + "blazing/cool" + "blazing/modules/config/model" +) + +type ShopService struct { + *cool.Service +} + +func NewShopService() *ShopService { + return &ShopService{ + &cool.Service{ + Model: model.NewShopConfig(), + PageQueryOp: &cool.QueryOp{ + KeyWordField: []string{"desc"}, + }, + }, + } +} diff --git a/modules/config/service/task.go b/modules/config/service/task.go index 81b07e974..260266229 100644 --- a/modules/config/service/task.go +++ b/modules/config/service/task.go @@ -16,7 +16,8 @@ func NewTaskService() *TaskService { &cool.Service{ Model: model.NewTaskConfig(), PageQueryOp: &cool.QueryOp{ - FieldEQ: []string{"task_type"}, + FieldEQ: []string{"task_type"}, + KeyWordField: []string{"remark"}, }, //UniqueKey: map[string]string{"task_id": "索引不能重复"}, },