| | |
| | | // @Summary 获取任务 |
| | | // @Produce application/json |
| | | // @Param object query request.TaskList true "查询参数" |
| | | // @Success 200 {object} contextx.Response{data=response.TaskData} "成功" |
| | | // @Success 200 {object} contextx.Response{data=response.TaskResponse} "成功" |
| | | // @Router /v1/task/get [get] |
| | | func (slf *TaskApi) TaskGet(c *gin.Context) { |
| | | var params request.TaskList |
| | |
| | | if !ok { |
| | | return |
| | | } |
| | | |
| | | channelAmount, err := service.NewDevicePlcService().GetDeviceChannelAmount() |
| | | if err != nil { |
| | | ctx.FailWithMsg(ecode.NeedConfirmedErr, err.Error()) |
| | | return |
| | | } |
| | | |
| | | if params.Page <= 0 { |
| | | params.Page = 1 |
| | | } |
| | | if params.PageSize <= 0 { |
| | | params.PageSize = 1 |
| | | } |
| | | |
| | | params.PageSize = channelAmount |
| | | |
| | | taskResponse, code := service.NewTaskService().GetTask(params.Page, params.PageSize, service.TaskModeCurrent) //取进行中的或未开始的 |
| | | if code != ecode.OK { |
| | |
| | | } |
| | | |
| | | taskResponse.Prompt = conf.Conf.Prompt |
| | | taskResponse.ChannelAmount = channelAmount |
| | | |
| | | ctx.OkWithDetailed(taskResponse) |
| | | } |