初始化项目
This commit is contained in:
53
internal/logic/task/get_task_list_logic.go
Normal file
53
internal/logic/task/get_task_list_logic.go
Normal file
@@ -0,0 +1,53 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
"nova_task/internal/pkg/errs"
|
||||
"time"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetTaskListLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// NewGetTaskListLogic 获取任务列表
|
||||
func NewGetTaskListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTaskListLogic {
|
||||
return &GetTaskListLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetTaskListLogic) GetTaskList(req *types.GetTaskListReq) (*types.GetTaskListResp, error) {
|
||||
tasks, err := l.svcCtx.TaskModel.FindTasksByCommunity(l.ctx, req.CommunityId)
|
||||
if err != nil {
|
||||
l.Errorw("get task list failed", logx.Field("err", err), logx.Field("communityId", req.CommunityId))
|
||||
return nil, errs.InternalServer(errs.ErrDatabaseOperate, err)
|
||||
}
|
||||
|
||||
resp := &types.GetTaskListResp{}
|
||||
for _, t := range tasks {
|
||||
resp.Tasks = append(resp.Tasks, types.Task{
|
||||
Id: t.Id,
|
||||
Title: t.Title,
|
||||
SubTitle: t.SubTitle,
|
||||
Description: t.Description,
|
||||
Points: t.Points,
|
||||
ButtonText: t.ButtonText,
|
||||
Type: t.Type,
|
||||
StartAt: t.StartAt.Time.Format(time.DateTime),
|
||||
EndAt: t.EndAt.Time.Format(time.DateTime),
|
||||
Status: t.Status,
|
||||
})
|
||||
}
|
||||
|
||||
return resp, nil
|
||||
}
|
||||
31
internal/logic/task/get_task_reward_logic.go
Normal file
31
internal/logic/task/get_task_reward_logic.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"nova_task/internal/svc"
|
||||
"nova_task/internal/types"
|
||||
|
||||
"github.com/zeromicro/go-zero/core/logx"
|
||||
)
|
||||
|
||||
type GetTaskRewardLogic struct {
|
||||
logx.Logger
|
||||
ctx context.Context
|
||||
svcCtx *svc.ServiceContext
|
||||
}
|
||||
|
||||
// 领取任务奖励
|
||||
func NewGetTaskRewardLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetTaskRewardLogic {
|
||||
return &GetTaskRewardLogic{
|
||||
Logger: logx.WithContext(ctx),
|
||||
ctx: ctx,
|
||||
svcCtx: svcCtx,
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetTaskRewardLogic) GetTaskReward(req *types.GetTaskRewardReq) (resp *types.GetTaskRewardResp, err error) {
|
||||
// todo: add your logic here and delete this line
|
||||
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user