diff --git a/api/reward/reward.go b/api/reward/reward.go index 57a55a4..907c53f 100644 --- a/api/reward/reward.go +++ b/api/reward/reward.go @@ -20,4 +20,5 @@ type IRewardV1 interface { GetGoodsList(ctx context.Context, req *v1.GetGoodsListReq) (res *v1.GetGoodsListRes, err error) GetGoods(ctx context.Context, req *v1.GetGoodsReq) (res *v1.GetGoodsRes, err error) GetGoodsDetails(ctx context.Context, req *v1.GetGoodsDetailsReq) (res *v1.GetGoodsDetailsRes, err error) + OperateTaskReward(ctx context.Context, req *v1.OperateTaskRewardReq) (res *v1.OperateTaskRewardRes, err error) } diff --git a/api/reward/v1/reward.go b/api/reward/v1/reward.go index 13a3de7..4d84430 100644 --- a/api/reward/v1/reward.go +++ b/api/reward/v1/reward.go @@ -267,3 +267,13 @@ type GetGoodsDetailsReq struct { type GetGoodsDetailsRes struct { Water interface{} `json:"water" dc:"流水信息"` } + +type OperateTaskRewardReq struct { + g.Meta `path:"/reward/addTaskReward" method:"post" tags:"Reward" summary:"添加任务奖励"` + Type int `json:"type" v:"required#操作类型只能为1或2,1是添加、2是删除" dc:"操作类型"` + TaskId int64 `json:"taskId" v:"required#任务id不能为空" dc:"任务Id"` + RewardId int64 `json:"rewardId" v:"required#奖励id不能为空" dc:"奖励Id"` +} +type OperateTaskRewardRes struct { + Success bool `json:"success" dc:"是否成功"` +} diff --git a/internal/controller/reward/reward_v1_operate_task_reward.go b/internal/controller/reward/reward_v1_operate_task_reward.go new file mode 100644 index 0000000..c12790a --- /dev/null +++ b/internal/controller/reward/reward_v1_operate_task_reward.go @@ -0,0 +1,13 @@ +package reward + +import ( + "context" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + + "server/api/reward/v1" +) + +func (c *ControllerV1) OperateTaskReward(ctx context.Context, req *v1.OperateTaskRewardReq) (res *v1.OperateTaskRewardRes, err error) { + return nil, gerror.NewCode(gcode.CodeNotImplemented) +} diff --git a/internal/dao/internal/task_rewards.go b/internal/dao/internal/task_rewards.go new file mode 100644 index 0000000..ea0ec0a --- /dev/null +++ b/internal/dao/internal/task_rewards.go @@ -0,0 +1,75 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +package internal + +import ( + "context" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" +) + +// TaskRewardsDao is the data access object for the table task_rewards. +type TaskRewardsDao struct { + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TaskRewardsColumns // columns contains all the column names of Table for convenient usage. +} + +// TaskRewardsColumns defines and stores column names for the table task_rewards. +type TaskRewardsColumns struct { + TaskId string // 任务ID + RewardId string // 奖励ID +} + +// taskRewardsColumns holds the columns for the table task_rewards. +var taskRewardsColumns = TaskRewardsColumns{ + TaskId: "task_id", + RewardId: "reward_id", +} + +// NewTaskRewardsDao creates and returns a new DAO object for table data access. +func NewTaskRewardsDao() *TaskRewardsDao { + return &TaskRewardsDao{ + group: "default", + table: "task_rewards", + columns: taskRewardsColumns, + } +} + +// DB retrieves and returns the underlying raw database management object of the current DAO. +func (dao *TaskRewardsDao) DB() gdb.DB { + return g.DB(dao.group) +} + +// Table returns the table name of the current DAO. +func (dao *TaskRewardsDao) Table() string { + return dao.table +} + +// Columns returns all column names of the current DAO. +func (dao *TaskRewardsDao) Columns() TaskRewardsColumns { + return dao.columns +} + +// Group returns the database configuration group name of the current DAO. +func (dao *TaskRewardsDao) Group() string { + return dao.group +} + +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. +func (dao *TaskRewardsDao) Ctx(ctx context.Context) *gdb.Model { + return dao.DB().Model(dao.table).Safe().Ctx(ctx) +} + +// Transaction wraps the transaction logic using function f. +// It rolls back the transaction and returns the error if function f returns a non-nil error. +// It commits the transaction and returns nil if function f returns nil. +// +// Note: Do not commit or roll back the transaction in function f, +// as it is automatically handled by this function. +func (dao *TaskRewardsDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { + return dao.Ctx(ctx).Transaction(ctx, f) +} diff --git a/internal/dao/task_rewards.go b/internal/dao/task_rewards.go new file mode 100644 index 0000000..613e23b --- /dev/null +++ b/internal/dao/task_rewards.go @@ -0,0 +1,27 @@ +// ================================================================================= +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. +// ================================================================================= + +package dao + +import ( + "server/internal/dao/internal" +) + +// internalTaskRewardsDao is an internal type for wrapping the internal DAO implementation. +type internalTaskRewardsDao = *internal.TaskRewardsDao + +// taskRewardsDao is the data access object for the table task_rewards. +// You can define custom methods on it to extend its functionality as needed. +type taskRewardsDao struct { + internalTaskRewardsDao +} + +var ( + // TaskRewards is a globally accessible object for table task_rewards operations. + TaskRewards = taskRewardsDao{ + internal.NewTaskRewardsDao(), + } +) + +// Add your custom methods and functionality below. diff --git a/internal/model/do/task_rewards.go b/internal/model/do/task_rewards.go new file mode 100644 index 0000000..5be04b1 --- /dev/null +++ b/internal/model/do/task_rewards.go @@ -0,0 +1,16 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package do + +import ( + "github.com/gogf/gf/v2/frame/g" +) + +// TaskRewards is the golang structure of table task_rewards for DAO operations like Where/Data. +type TaskRewards struct { + g.Meta `orm:"table:task_rewards, do:true"` + TaskId interface{} // 任务ID + RewardId interface{} // 奖励ID +} diff --git a/internal/model/entity/task_rewards.go b/internal/model/entity/task_rewards.go new file mode 100644 index 0000000..334fe86 --- /dev/null +++ b/internal/model/entity/task_rewards.go @@ -0,0 +1,11 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package entity + +// TaskRewards is the golang structure for table task_rewards. +type TaskRewards struct { + TaskId int64 `json:"taskId" orm:"task_id" description:"任务ID"` // 任务ID + RewardId int64 `json:"rewardId" orm:"reward_id" description:"奖励ID"` // 奖励ID +} diff --git a/internal/service/reward.go b/internal/service/reward.go index 1361304..76d8523 100644 --- a/internal/service/reward.go +++ b/internal/service/reward.go @@ -27,6 +27,7 @@ type ( GetGoods(ctx context.Context, in *model.GetGoodsGetIn) (out *model.GoodsGetOut, err error) // GetGoodsDetails 物品详情 GetGoodsDetails(ctx context.Context, in *model.GetGoodsDetailsIn) (out *model.QueryUserGoodsDetailResponse, err error) + OperateTaskReward(ctx context.Context, in *model.OperateTaskRewardIn) (out *model.OperateTaskRewardOut, err error) } ) diff --git a/internal/service/reward_type.go b/internal/service/reward_type.go index 58c8ea9..3fa9ad3 100644 --- a/internal/service/reward_type.go +++ b/internal/service/reward_type.go @@ -16,9 +16,9 @@ type ( Create(ctx context.Context, in *model.RewardTypeCreateIn) (out *model.RewardTypeCreateOut, err error) // Update 更新奖励类型 Update(ctx context.Context, in *model.RewardTypeUpdateIn) (out *model.RewardTypeUpdateOut, err error) - // Delete 删除奖励类型 + // Delete 删除奖励类型(逻辑删除) Delete(ctx context.Context, in *model.RewardTypeDeleteIn) (out *model.RewardTypeDeleteOut, err error) - // List 获取奖励类型列表 + // List 获取奖励类型列表(支持分页、过滤) List(ctx context.Context, in *model.RewardTypeListIn) (out *model.RewardTypeListOut, err error) } )