Merge branch 'dev' of http://gitlab.fjmaimaimai.com/mmm-go/oppmg into dev
正在显示
5 个修改的文件
包含
42 行增加
和
2 行删除
| @@ -103,3 +103,12 @@ func GetAuditTemplateByTypeId(chanceTypeId int) (v []*AuditTemplate, err error) | @@ -103,3 +103,12 @@ func GetAuditTemplateByTypeId(chanceTypeId int) (v []*AuditTemplate, err error) | ||
| 103 | } | 103 | } |
| 104 | return | 104 | return |
| 105 | } | 105 | } |
| 106 | + | ||
| 107 | +func GetAuditTemplateByCode(companyId int64, code string) (v *ChanceType, err error) { | ||
| 108 | + o := orm.NewOrm() | ||
| 109 | + sql := "select * from audit_template where code=? and company_id=?" | ||
| 110 | + if err = o.Raw(sql, code, companyId).QueryRow(&v); err == nil { | ||
| 111 | + return | ||
| 112 | + } | ||
| 113 | + return | ||
| 114 | +} |
| @@ -92,3 +92,12 @@ func GetChanceTypeByCompany(companyId int) (v []*ChanceType, err error) { | @@ -92,3 +92,12 @@ func GetChanceTypeByCompany(companyId int) (v []*ChanceType, err error) { | ||
| 92 | } | 92 | } |
| 93 | return | 93 | return |
| 94 | } | 94 | } |
| 95 | + | ||
| 96 | +func GetChanceTypeByCode(companyId int64, code string) (v *ChanceType, err error) { | ||
| 97 | + o := orm.NewOrm() | ||
| 98 | + sql := "select * from chance_type where code=? and company_id=?" | ||
| 99 | + if err = o.Raw(sql, code, companyId).QueryRow(&v); err == nil { | ||
| 100 | + return | ||
| 101 | + } | ||
| 102 | + return | ||
| 103 | +} |
| @@ -115,6 +115,7 @@ type TemplateList struct { | @@ -115,6 +115,7 @@ type TemplateList struct { | ||
| 115 | Id int `json:"id"` | 115 | Id int `json:"id"` |
| 116 | Name string `json:"name"` | 116 | Name string `json:"name"` |
| 117 | Icon string `json:"icon"` | 117 | Icon string `json:"icon"` |
| 118 | + Code string `json:"code"` | ||
| 118 | Templates []*TemplateItem `json:"templates"` | 119 | Templates []*TemplateItem `json:"templates"` |
| 119 | } | 120 | } |
| 120 | 121 | ||
| @@ -123,6 +124,7 @@ type TemplateItem struct { | @@ -123,6 +124,7 @@ type TemplateItem struct { | ||
| 123 | Name string `json:"name"` | 124 | Name string `json:"name"` |
| 124 | Doc string `json:"doc"` | 125 | Doc string `json:"doc"` |
| 125 | Icon string `json:"icon"` | 126 | Icon string `json:"icon"` |
| 127 | + Code string `json:"code"` //编码 | ||
| 126 | EnableStatus int8 `json:"enableStatus"` //禁用状态 | 128 | EnableStatus int8 `json:"enableStatus"` //禁用状态 |
| 127 | Sort int `json:"sort"` //序号 | 129 | Sort int `json:"sort"` //序号 |
| 128 | VisibleType int8 `json:"visibleType"` | 130 | VisibleType int8 `json:"visibleType"` |
| @@ -146,8 +148,8 @@ type TemplateEditVisibleResponse struct { | @@ -146,8 +148,8 @@ type TemplateEditVisibleResponse struct { | ||
| 146 | /*TemplateAddCategory */ | 148 | /*TemplateAddCategory */ |
| 147 | type TemplateOperateCategoryRequest struct { | 149 | type TemplateOperateCategoryRequest struct { |
| 148 | Id int `json:"id"` | 150 | Id int `json:"id"` |
| 149 | - Name string `json:"name"` | ||
| 150 | - Code string `json:"code"` | 151 | + Name string `json:"name" valid:"Required"` |
| 152 | + Code string `json:"code" valid:"Required"` | ||
| 151 | Icon string `json:"icon"` | 153 | Icon string `json:"icon"` |
| 152 | } | 154 | } |
| 153 | type TemplateOperateCategoryResponse struct { | 155 | type TemplateOperateCategoryResponse struct { |
| @@ -42,6 +42,8 @@ var errmessge ErrorMap = map[string]string{ | @@ -42,6 +42,8 @@ var errmessge ErrorMap = map[string]string{ | ||
| 42 | "10061": "请先删除该分类下的二级分类", | 42 | "10061": "请先删除该分类下的二级分类", |
| 43 | "10062": "该分类已被使用无法删除", | 43 | "10062": "该分类已被使用无法删除", |
| 44 | "10063": "该分类已被使用无法禁用", | 44 | "10063": "该分类已被使用无法禁用", |
| 45 | + "10064": "编码已存在", | ||
| 46 | + "10065": "编码长度为6个字符", | ||
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | //错误码转换 ,兼容需要 | 49 | //错误码转换 ,兼容需要 |
| @@ -26,6 +26,14 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | @@ -26,6 +26,14 @@ func TemplateAdd(uid, companyId int64, request *protocol.TemplateAddRequest) (rs | ||
| 26 | log.Error("chance_type_id:%v 不存在 ,err:%v", request.Template.ChanceTypeId, err.Error()) | 26 | log.Error("chance_type_id:%v 不存在 ,err:%v", request.Template.ChanceTypeId, err.Error()) |
| 27 | return | 27 | return |
| 28 | } | 28 | } |
| 29 | + if len([]rune(request.Template.Code)) != 6 { | ||
| 30 | + err = protocol.NewErrWithMessage("10065") | ||
| 31 | + return | ||
| 32 | + } | ||
| 33 | + if _, err = models.GetAuditTemplateByCode(companyId, request.Template.Code); err == nil { | ||
| 34 | + err = protocol.NewErrWithMessage("10064") | ||
| 35 | + return | ||
| 36 | + } | ||
| 29 | orm := orm2.NewOrm() | 37 | orm := orm2.NewOrm() |
| 30 | //模板 | 38 | //模板 |
| 31 | { | 39 | { |
| @@ -199,6 +207,7 @@ func TemplateList(uid, companyId int64, request *protocol.TemplateListRequest) ( | @@ -199,6 +207,7 @@ func TemplateList(uid, companyId int64, request *protocol.TemplateListRequest) ( | ||
| 199 | Id: t.Id, | 207 | Id: t.Id, |
| 200 | Name: t.Name, | 208 | Name: t.Name, |
| 201 | Icon: t.Icon, | 209 | Icon: t.Icon, |
| 210 | + Code: t.Code, | ||
| 202 | } | 211 | } |
| 203 | rsp.List = append(rsp.List, item) | 212 | rsp.List = append(rsp.List, item) |
| 204 | if templates, err = models.GetAuditTemplateByTypeId(t.Id); err != nil { | 213 | if templates, err = models.GetAuditTemplateByTypeId(t.Id); err != nil { |
| @@ -222,6 +231,7 @@ func TemplateList(uid, companyId int64, request *protocol.TemplateListRequest) ( | @@ -222,6 +231,7 @@ func TemplateList(uid, companyId int64, request *protocol.TemplateListRequest) ( | ||
| 222 | Id: temp.Id, | 231 | Id: temp.Id, |
| 223 | Name: temp.Name, | 232 | Name: temp.Name, |
| 224 | Doc: temp.Doc, | 233 | Doc: temp.Doc, |
| 234 | + Code: temp.Code, | ||
| 225 | Icon: temp.Icon, | 235 | Icon: temp.Icon, |
| 226 | EnableStatus: temp.EnableStatus, | 236 | EnableStatus: temp.EnableStatus, |
| 227 | Sort: temp.SortNum, | 237 | Sort: temp.SortNum, |
| @@ -423,6 +433,10 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | @@ -423,6 +433,10 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | ||
| 423 | } | 433 | } |
| 424 | return | 434 | return |
| 425 | } | 435 | } |
| 436 | + if len([]rune(request.Code)) != 6 { | ||
| 437 | + err = protocol.NewErrWithMessage("10065") | ||
| 438 | + return | ||
| 439 | + } | ||
| 426 | chanceType = &models.ChanceType{ | 440 | chanceType = &models.ChanceType{ |
| 427 | Name: request.Name, | 441 | Name: request.Name, |
| 428 | Icon: request.Icon, | 442 | Icon: request.Icon, |
| @@ -431,6 +445,10 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | @@ -431,6 +445,10 @@ func TemplateOperateCategory(uid, companyId int64, request *protocol.TemplateOpe | ||
| 431 | CreateAt: time.Now(), | 445 | CreateAt: time.Now(), |
| 432 | UpdateAt: time.Now(), | 446 | UpdateAt: time.Now(), |
| 433 | } | 447 | } |
| 448 | + if _, err = models.GetChanceTypeByCode(companyId, chanceType.Code); err == nil { | ||
| 449 | + err = protocol.NewErrWithMessage("10064") | ||
| 450 | + return | ||
| 451 | + } | ||
| 434 | if _, err = models.AddChanceType(chanceType); err != nil { | 452 | if _, err = models.AddChanceType(chanceType); err != nil { |
| 435 | log.Error(err.Error()) | 453 | log.Error(err.Error()) |
| 436 | } | 454 | } |
-
请 注册 或 登录 后发表评论