add
wangpengfei
2023-07-20 a63566fef15a499c82a5198578d5cb99fca299d4
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
package v1
 
import (
    "aps_crm/model"
    "aps_crm/model/request"
    "aps_crm/pkg/contextx"
    "aps_crm/pkg/ecode"
    "github.com/gin-gonic/gin"
)
 
type VettingApi struct{}
 
// Add
//
//    @Tags        Vetting
//    @Summary    添加审批
//    @Produce    application/json
//    @Param        object    body        request.AddVetting    true    "查询参数"
//    @Success    200        {object}    contextx.Response{}
//    @Router        /api/vetting/add [post]
func (vet *VettingApi) Add(c *gin.Context) {
    var params request.AddVetting
    ctx, ok := contextx.NewContext(c, &params)
    if !ok {
        return
    }
 
    errCode, vetting := checkVettingParams(&params)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
 
    // check member exist
 
    errCode = vettingService.AddVetting(vetting)
    if errCode != ecode.OK {
        ctx.Fail(errCode)
        return
    }
 
    ctx.Ok()
}
 
func checkVettingParams(vetting *request.AddVetting) (int, *model.Vetting) {
 
    v := &model.Vetting{
        Opinion:   vetting.Opinion,
        Status:    vetting.Status,
        UserId:    vetting.UserId,
        VettingId: vetting.VettingId,
    }
 
    return ecode.OK, v
}