zhangqian
2023-12-20 1960a054785d1f81e69abe84b43073ed9df638e0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package v1
 
import (
    "apsClient/model/request"
    _ "apsClient/model/response"
    "apsClient/pkg/contextx"
    "apsClient/pkg/ecode"
    "apsClient/pkg/logx"
    "apsClient/service"
    "github.com/gin-gonic/gin"
)
 
type ReportWorkApi struct{}
 
// Report
// @Tags      报工
// @Summary   上报
// @Produce   application/json
// @Param     object  body    request.ReportWork true  "查询参数"
// @Success   200   {object}  contextx.Response{}  "成功"
// @Router    /v1/reportWork/report [post]
func (slf *ReportWorkApi) Report(c *gin.Context) {
    var params request.ReportWork
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    err := service.AddReportWork(params)
    if err != nil {
        logx.Errorf("ReportWork err:%v", err)
        ctx.FailWithMsg(ecode.ParamsErr, err.Error())
        return
    }
    ctx.Ok()
}
 
// ReportList
// @Tags      报工
// @Summary   报工列表
// @Produce   application/json
// @Param     object  query    request.ReportWorkList true  "查询参数"
// @Success   200   {object}  contextx.ResponseList{data=[]model.ReportWork}  "成功"
// @Router    /v1/reportWork/list [get]
func (slf *ReportWorkApi) ReportList(c *gin.Context) {
    var params request.ReportWorkList
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
    list, total, err := service.ReportWorkList(params.ProcedureId, params.Page, params.PageSize)
    if err != nil {
        ctx.Fail(ecode.DBErr)
        return
    }
    ctx.ResultList(list, total)
}