```
feat(config): 更新商品配置模型和任务服务查询功能 - 将商品描述字段从 Description 改为 Desc,优化字段命名 - 将价格字段类型从 uint32 改为 int32,支持负数价格表示 - 更新价格信息注释说明,明确 -1 代表不允许购买的含义 - 移除商品分类字段,简化商品配置结构 - 移除备注信息字段,精简数据模型 - 为任务服务添加关键词
This commit is contained in:
22
modules/config/controller/admin/shop.go
Normal file
22
modules/config/controller/admin/shop.go
Normal file
@@ -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(),
|
||||
},
|
||||
})
|
||||
}
|
||||
@@ -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:"备注信息"`
|
||||
}
|
||||
|
||||
// -------------------------- 核心配套方法(遵循项目规范)--------------------------
|
||||
|
||||
21
modules/config/service/shop.go
Normal file
21
modules/config/service/shop.go
Normal file
@@ -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"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -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": "索引不能重复"},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user