zhangqian
2024-07-30 9bb979dbfb2c4edc31018a83970567f8734c0b61
单位字典保存前进行重复校验
2个文件已修改
14 ■■■■ 已修改文件
controllers/product_controller.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/material.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/product_controller.go
@@ -1028,6 +1028,16 @@
        v.Sort = i + 1
    }
    //校验重复
    m := make(map[string]struct{})
    for _, v := range params {
        if _, ok := m[v.Name]; ok {
            util.ResponseFormat(c, code.RequestParamError, "单位重复:"+v.Name)
            return
        }
        m[v.Name] = struct{}{}
    }
    err := models.WithTransaction(func(tx *gorm.DB) error {
        err := models.NewUnitDictSearch().SetOrm(tx).Delete()
        if err != nil {
@@ -1041,7 +1051,7 @@
        return nil
    })
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "删除失败")
        util.ResponseFormat(c, code.RequestParamError, "保存失败")
        return
    }
models/material.go
@@ -120,7 +120,7 @@
    }
    UnitItems struct {
        Amount   decimal.Decimal `json:"amount"`
        Amount   decimal.Decimal `json:"amount"` //在物料中为换算率(1辅单位=换算率*主单位),在明细或库存中为具体值
        Unit     string          `json:"unit"`
        Floating bool            `json:"floating"` //是否浮动利率
    }