作者 tangxvhui

bug 修复

... ... @@ -293,6 +293,11 @@ func (c RankController) RankRangeAdd() {
msg = protocol.BadRequestParam("10107")
return
}
ok := serverank.RankRangeNameOnlyOne(param.RankTypeId, 0, param.Name)
if !ok {
msg = protocol.BadRequestParam("10125")
return
}
switch param.RangeType {
case 1:
param.RangeType = models.RANK_RANGE_TYPE_EMPLAYEE
... ...
... ... @@ -122,6 +122,7 @@ var errmessge ErrorMap = map[string]string{
"10122": "分配的总分不可大于把握分",
"10123": "排行榜评比项最多4项",
"10124": "公司未启用该模块",
"10125": "参与范围名称不能重复",
}
//错误码转换 ,兼容需要
... ...
... ... @@ -319,6 +319,22 @@ func getRangeDataRelationLsit(rankRangeId int64, rangeType int8) []protocol.Rank
return datalist
}
func RankRangeNameOnlyOne(rankTypeId int64, rankRangeId int64, name string) bool {
sql := `SELECT 1 FROM rank_range WHERE rank_type_id=? AND name=? AND id<>? LIMIT 1`
var (
err error
cnt int
)
err = utils.ExecuteQueryOne(&cnt, sql, rankTypeId, name, rankRangeId)
if err != nil {
return false
}
if cnt == 0 {
return true
}
return false
}
func AddRankRange(rankTypeId int64, name string, rangetype int8, relationId []int64, companyid int64) error {
var (
rankRangeDatas []models.RankRangeData
... ... @@ -430,6 +446,10 @@ func EditRankRange(id int64, name string, rangetype int8, relationId []int64, co
log.Error("公司不匹配")
return protocol.NewErrWithMessage("1")
}
ok := RankRangeNameOnlyOne(rankRange.RankTypeId, rankRange.Id, name)
if !ok {
return protocol.NewErrWithMessage("10125")
}
rankRangeDatas, err = models.GetRankRangeDataByRangeId(rankRange.Id)
if err != nil {
log.Error("获取rank_range_data数据失败;%s", err)
... ...