You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.2 KiB
52 lines
1.2 KiB
package allhelp
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// GetTasks 获取用户任务列表
|
|
// @Summary 获取任务列表
|
|
// @Description 分页获取用户的任务列表
|
|
// @Tags Allhelp
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param user body pb.AllhelpGetTasksReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.AllhelpGetTasksResp} "响应数据"
|
|
// @Router /api/home/allhelp_gettasks [post]
|
|
func (this *apiComp) GetTasks(session comm.IUserSession, req *pb.AllhelpGetTasksReq) (resp *pb.AllhelpGetTasksResp, errdata *pb.ErrorData) {
|
|
uid := session.GetUserId()
|
|
if uid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "用户未登录",
|
|
}
|
|
return
|
|
}
|
|
|
|
page := req.Page
|
|
if page <= 0 {
|
|
page = 1
|
|
}
|
|
size := req.Size
|
|
if size <= 0 {
|
|
size = 20
|
|
}
|
|
|
|
tasks, total, err := this.module.model.getTasksByUid(uid, req.Status, page, size)
|
|
if err != nil {
|
|
this.module.Errorln("GetTasks error:", err)
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: "查询任务失败",
|
|
}
|
|
return
|
|
}
|
|
|
|
resp = &pb.AllhelpGetTasksResp{
|
|
Tasks: tasks,
|
|
Total: total,
|
|
}
|
|
return
|
|
}
|
|
|