Commit 446fdf5a authored by hujiebin's avatar hujiebin

Merge branch 'feature/3.5' of...

Merge branch 'feature/3.5' of http://47.107.153.111:8081/gitlab/hujiebin/hilo-group into feature/3.5
parents 2cf1e6c3 36d4fb9b
...@@ -113,22 +113,30 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara ...@@ -113,22 +113,30 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara
if familyId == 0 || (name == "" && nameplate == "" && declaration == "" && icon == "") { if familyId == 0 || (name == "" && nameplate == "" && declaration == "" && icon == "") {
return nil return nil
} }
// 修改铭牌
if nameplate != "" {
sql := "UPDATE `group_power` a left join (SELECT ? `id` FROM group_power WHERE nameplate = ?) b on a.id = b.id SET a.`nameplate`=? where a.id=? and b.id is null;"
result := model.Db.Exec(sql, familyId, nameplate, nameplate, familyId)
if result.Error != nil {
return myerr.WrapErr(result.Error)
}
if result.RowsAffected <= 0 {
return myerr.WrapErr(bizerr.GroupPowerHaveChangeInfo)
}
return nil
}
db := model.Db.Model(GroupPower{}) db := model.Db.Model(GroupPower{})
updateMap := make(map[string]interface{}) updateMap := make(map[string]interface{})
if name != "" { if name != "" {
updateMap["name"] = name updateMap["name"] = name
} }
if nameplate != "" {
updateMap["nameplate"] = nameplate
db = db.Where("not exists (select id from group_power where nameplate = ?)", nameplate)
}
if declaration != "" { if declaration != "" {
updateMap["declaration"] = declaration updateMap["declaration"] = declaration
} }
if icon != "" { if icon != "" {
updateMap["icon"] = icon updateMap["icon"] = icon
} }
result := db.Where("id = ?", familyId).Updates(updateMap).Limit(1) result := db.Where("group_power.id = ?", familyId).Updates(updateMap).Limit(1)
if result.Error != nil { if result.Error != nil {
return myerr.WrapErr(result.Error) return myerr.WrapErr(result.Error)
} }
......
...@@ -768,6 +768,9 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -768,6 +768,9 @@ func GroupPowerInfo(c *gin.Context) (*mycontext.MyContext, error) {
} }
if groupInfo != nil { if groupInfo != nil {
info.Nameplate = groupInfo.Name info.Nameplate = groupInfo.Name
if len(info.Nameplate) > 6 {
info.Nameplate = info.Nameplate[:6]
}
} }
} }
// 家族月排名 // 家族月排名
...@@ -1420,7 +1423,7 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) { ...@@ -1420,7 +1423,7 @@ func GroupPowerSetInfo(c *gin.Context) (*mycontext.MyContext, error) {
return myContext, bizerr.GroupPowerChangeNameplate return myContext, bizerr.GroupPowerChangeNameplate
} }
// 检查铭牌长度和唯一性 // 检查铭牌长度和唯一性
if len(para.Nameplate) > 10 { if len(para.Nameplate) > 6 {
return myContext, bizerr.GroupPowerHaveTooLong return myContext, bizerr.GroupPowerHaveTooLong
} }
if groupPower_m.IsExistsNameplate(model, para.Nameplate) { if groupPower_m.IsExistsNameplate(model, para.Nameplate) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment