Commit 36d4fb9b authored by chenweijian's avatar chenweijian

家族修改铭牌

parent 1efa1434
...@@ -113,16 +113,23 @@ func UpdateFamily(model *domain.Model, familyId uint64, name, nameplate, declara ...@@ -113,16 +113,23 @@ 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.Joins("left join (SELECT ? `id` FROM group_power WHERE nameplate=?) b on a.id = b.id", familyId, nameplate).
Where("b.id is null")
}
if declaration != "" { if declaration != "" {
updateMap["declaration"] = declaration updateMap["declaration"] = declaration
} }
......
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