修复删除元素的问题

This commit is contained in:
wh_zcy 2022-12-22 23:56:40 +08:00
parent 9a17f539bf
commit 6a553f11e8
2 changed files with 13 additions and 9 deletions

View File

@ -352,9 +352,10 @@ func (this *ModelSociaty) updateSociaty(sociatyId string, update map[string]inte
// 退出公会
func (this *ModelSociaty) quit(uid string, sociaty *pb.DBSociaty) error {
for i, m := range sociaty.Members {
if m.Uid == uid {
for i:=0;i<len(sociaty.Members);i++{
if sociaty.Members[i].Uid == uid {
sociaty.Members = append(sociaty.Members[:i], sociaty.Members[i+1:]...)
i--
}
}
update := map[string]interface{}{
@ -385,9 +386,10 @@ func (this *ModelSociaty) dismiss(sociaty *pb.DBSociaty) error {
//删除请求记录
func (this *ModelSociaty) delFromApplyRecord(uid string, sociaty *pb.DBSociaty) error {
for i, ar := range sociaty.ApplyRecord {
if ar.Uid == uid {
for i:=0;i<len(sociaty.ApplyRecord);i++{
if sociaty.ApplyRecord[i].Uid == uid {
sociaty.ApplyRecord = append(sociaty.ApplyRecord[:i], sociaty.ApplyRecord[i+1:]...)
i--
}
}
update := map[string]interface{}{
@ -511,12 +513,13 @@ func (this *ModelSociaty) assign(srcId, targetId string, sociaty *pb.DBSociaty)
// targetId 踢出目标
// 不允许踢出会长
func (this *ModelSociaty) discharge(targetId string, sociaty *pb.DBSociaty) error {
for i, m := range sociaty.Members {
if m.Uid == targetId {
if m.Job == pb.SociatyJob_PRESIDENT {
for i:=0;i<len(sociaty.Members);i++ {
if sociaty.Members[i].Uid == targetId {
if sociaty.Members[i].Job == pb.SociatyJob_PRESIDENT {
return comm.NewCustomError(pb.ErrorCode_SociatyMasterNoDiss)
}
sociaty.Members = append(sociaty.Members[:i], sociaty.Members[i+1:]...)
i--
}
}
update := map[string]interface{}{

View File

@ -130,9 +130,10 @@ func (this *ModelTaskActive) clearTask(uid string, taskTag ...comm.TaskTag) {
return
}
data := this.getActiveListByTag(uid, taskTag[0])
for i, v := range data {
if v.Tag == int32(taskTag[0]) {
for i:=0; i<len(data); i++ {
if data[i].Tag == int32(taskTag[0]) {
data = append(data[:i], data[i+1:]...)
i--
}
}
update := map[string]interface{}{