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.
62 lines
1.5 KiB
62 lines
1.5 KiB
package allhelp
|
|
|
|
import (
|
|
"yunyan/comm"
|
|
"yunyan/pb"
|
|
)
|
|
|
|
// CompleteTask 完成任务(用户确认提醒)
|
|
// @Summary 完成任务
|
|
// @Description 用户确认完成任务
|
|
// @Tags Allhelp
|
|
// @Accept json
|
|
// @Produce json
|
|
// @Security BearerAuth
|
|
// @Param user body pb.AllhelpCompleteTaskReq true "请求数据"
|
|
// @Success 200 {object} comm.HttpResult{data=pb.AllhelpCompleteTaskResp} "响应数据"
|
|
// @Router /api/home/allhelp_completetask [post]
|
|
func (this *apiComp) CompleteTask(session comm.IUserSession, req *pb.AllhelpCompleteTaskReq) (resp *pb.AllhelpCompleteTaskResp, errdata *pb.ErrorData) {
|
|
uid := session.GetUserId()
|
|
if uid == "" {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "用户未登录",
|
|
}
|
|
return
|
|
}
|
|
if req.TaskId == 0 {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "任务ID无效",
|
|
}
|
|
return
|
|
}
|
|
|
|
task, err := this.module.model.getTaskById(req.TaskId)
|
|
if err != nil {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: "任务不存在",
|
|
}
|
|
return
|
|
}
|
|
if task.Uid != uid {
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_ReqParameterError,
|
|
Message: "无权操作该任务",
|
|
}
|
|
return
|
|
}
|
|
|
|
if err := this.module.model.updateTaskStatus(req.TaskId, pb.TaskStatus_TaskStatus_Completed); err != nil {
|
|
this.module.Errorln("CompleteTask error:", err)
|
|
errdata = &pb.ErrorData{
|
|
Code: pb.ErrorCode_DBError,
|
|
Message: "完成任务失败",
|
|
}
|
|
return
|
|
}
|
|
|
|
resp = &pb.AllhelpCompleteTaskResp{}
|
|
return
|
|
}
|
|
|