liujiandao
2024-02-29 1e7ef4a6705d59f7f3308638d44cc3b0cf340211
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
57
58
59
60
61
62
package controllers
 
import (
    "github.com/gin-gonic/gin"
    "silkserver/controllers/request"
    "silkserver/extend/code"
    "silkserver/extend/util"
    "silkserver/models"
)
 
type RawSilkStandardController struct {
}
 
// SavePriceStandard
//
//    @Tags        系统设置/生丝定价标准
//    @Summary    保存生丝定价标准
//    @Produce    application/json
//    @Param        object    body        models.RawSilkPriceStandard    true    "参数"
//    @Success    200        {object}    util.Response        "成功"
//    @Router        /api-jl/v1/system/savePriceStandard [post]
func (slf RawSilkStandardController) SavePriceStandard(c *gin.Context) {
    var priceStandard models.RawSilkPriceStandard
    err := c.BindJSON(&priceStandard)
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    if priceStandard.ID > 0 {
        err = models.NewRawSilkPriceStandardSearch().Save(&priceStandard)
    } else {
        err = models.NewRawSilkPriceStandardSearch().Create(&priceStandard)
    }
    if err != nil {
        util.ResponseFormat(c, code.SaveFail, "保存失败")
        return
    }
    util.ResponseFormat(c, code.Success, "保存成功")
}
 
// GetPriceStandardList
//
//    @Tags        系统设置/生丝定价标准
//    @Summary    获取生丝定价标准
//    @Produce    application/json
//    @Param        object    body        models.RawSilkPriceStandard    true    "参数"
//    @Success    200        {object}    util.Response        "成功"
//    @Router        /api-jl/v1/system/getPriceStandardList [get]
func (slf RawSilkStandardController) GetPriceStandardList(c *gin.Context) {
    var param request.GetPriceStandard
    err := c.BindJSON(&param)
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    list, total, err := models.NewRawSilkPriceStandardSearch().SetPage(param.Page, param.PageSize).Find()
    if err != nil {
        util.ResponseFormat(c, code.SelectError, "查询失败")
        return
    }
    util.ResponseFormatList(c, code.Success, list, int(total))
}