Browse Source

optimize add ab from peer #84

lejianwen 1 year ago
parent
commit
034ec6ca1b
1 changed files with 15 additions and 4 deletions
  1. 15 4
      http/controller/admin/addressBook.go

+ 15 - 4
http/controller/admin/addressBook.go

@@ -4,7 +4,6 @@ import (
4 4
 	"Gwen/global"
5 5
 	"Gwen/http/request/admin"
6 6
 	"Gwen/http/response"
7
-	"Gwen/model"
8 7
 	"Gwen/service"
9 8
 	"encoding/json"
10 9
 	_ "encoding/json"
@@ -107,9 +106,21 @@ func (ct *AddressBook) BatchCreate(c *gin.Context) {
107 106
 		response.Fail(c, 101, errList[0])
108 107
 		return
109 108
 	}
109
+	ul := len(f.UserIds)
110
+
111
+	if ul == 0 {
112
+		response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
113
+		return
114
+	}
115
+	if ul > 1 {
116
+		//多用户置空标签
117
+		f.Tags = []string{}
118
+		//多用户只能创建到默认地址簿
119
+		f.CollectionId = 0
120
+	}
110 121
 
111 122
 	//创建标签
112
-	for _, fu := range f.UserIds {
123
+	/*for _, fu := range f.UserIds {
113 124
 		if fu == 0 {
114 125
 			continue
115 126
 		}
@@ -122,13 +133,13 @@ func (ct *AddressBook) BatchCreate(c *gin.Context) {
122 133
 				})
123 134
 			}
124 135
 		}
125
-	}
136
+	}*/
126 137
 	ts := f.ToAddressBooks()
127 138
 	for _, t := range ts {
128 139
 		if t.UserId == 0 {
129 140
 			continue
130 141
 		}
131
-		ex := service.AllService.AddressBookService.InfoByUserIdAndId(t.UserId, t.Id)
142
+		ex := service.AllService.AddressBookService.InfoByUserIdAndIdAndCid(t.UserId, t.Id, t.CollectionId)
132 143
 		if ex.RowId == 0 {
133 144
 			service.AllService.AddressBookService.Create(t)
134 145
 		}