lejianwen месяцев назад: 9
Родитель
Сommit
0dedaf6824

+ 2 - 2
http/controller/admin/addressBookCollectionRule.go

@@ -120,7 +120,7 @@ func (abcr *AddressBookCollectionRule) CheckForm(t *model.AddressBookCollectionR
120 120
 	//check to_id
121 121
 	if t.Type == model.ShareAddressBookRuleTypePersonal {
122 122
 		if t.ToId == t.UserId {
123
-			return "ParamsError", false
123
+			return "CannotShareToSelf", false
124 124
 		}
125 125
 		tou := service.AllService.UserService.InfoById(t.ToId)
126 126
 		if tou.Id == 0 {
@@ -135,7 +135,7 @@ func (abcr *AddressBookCollectionRule) CheckForm(t *model.AddressBookCollectionR
135 135
 		return "ParamsError", false
136 136
 	}
137 137
 	// 重复检查
138
-	ex := service.AllService.AddressBookService.RulePersonalInfoByToIdAndCid(t.ToId, t.CollectionId)
138
+	ex := service.AllService.AddressBookService.RuleInfoByToIdAndCid(t.Type, t.ToId, t.CollectionId)
139 139
 	if t.Id == 0 && ex.Id > 0 {
140 140
 		return "ItemExists", false
141 141
 	}

+ 8 - 8
http/controller/admin/my/addressBookCollectionRule.go

@@ -100,21 +100,21 @@ func (abcr *AddressBookCollectionRule) CheckForm(u *model.User, t *model.Address
100 100
 	//check to_id
101 101
 	if t.Type == model.ShareAddressBookRuleTypePersonal {
102 102
 		if t.ToId == t.UserId {
103
-			return "ParamsError", false
103
+			return "CannotShareToSelf", false
104 104
 		}
105 105
 		tou := service.AllService.UserService.InfoById(t.ToId)
106 106
 		if tou.Id == 0 {
107 107
 			return "ItemNotFound", false
108 108
 		}
109 109
 		//非管理员不能分享给非本组织用户
110
-		if tou.GroupId != u.GroupId {
111
-			return "NoAccess", false
112
-		}
110
+		//if tou.GroupId != u.GroupId {
111
+		//	return "NoAccess", false
112
+		//}
113 113
 	} else if t.Type == model.ShareAddressBookRuleTypeGroup {
114 114
 		//非管理员不能分享给其他组
115
-		if t.ToId != u.GroupId {
116
-			return "NoAccess", false
117
-		}
115
+		//if t.ToId != u.GroupId {
116
+		//	return "NoAccess", false
117
+		//}
118 118
 
119 119
 		tog := service.AllService.GroupService.InfoById(t.ToId)
120 120
 		if tog.Id == 0 {
@@ -124,7 +124,7 @@ func (abcr *AddressBookCollectionRule) CheckForm(u *model.User, t *model.Address
124 124
 		return "ParamsError", false
125 125
 	}
126 126
 	// 重复检查
127
-	ex := service.AllService.AddressBookService.RulePersonalInfoByToIdAndCid(t.ToId, t.CollectionId)
127
+	ex := service.AllService.AddressBookService.RuleInfoByToIdAndCid(t.Type, t.ToId, t.CollectionId)
128 128
 	if t.Id == 0 && ex.Id > 0 {
129 129
 		return "ItemExists", false
130 130
 	}

+ 5 - 25
http/controller/admin/user.go

@@ -296,32 +296,12 @@ func (ct *User) MyOauth(c *gin.Context) {
296 296
 
297 297
 // groupUsers
298 298
 func (ct *User) GroupUsers(c *gin.Context) {
299
-	q := &admin.GroupUsersQuery{}
300
-	if err := c.ShouldBindJSON(q); err != nil {
301
-		response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
302
-		return
303
-	}
304
-	u := service.AllService.UserService.CurUser(c)
305
-	gid := u.GroupId
306
-	uid := u.Id
307
-	if service.AllService.UserService.IsAdmin(u) && q.UserId > 0 {
308
-		nu := service.AllService.UserService.InfoById(q.UserId)
309
-		gid = nu.GroupId
310
-		uid = q.UserId
311
-	}
312
-	res := service.AllService.UserService.List(1, 999, func(tx *gorm.DB) {
313
-		tx.Where("group_id = ?", gid)
299
+	aG := service.AllService.GroupService.List(1, 999, nil)
300
+	aU := service.AllService.UserService.List(1, 9999, nil)
301
+	response.Success(c, gin.H{
302
+		"groups": aG.Groups,
303
+		"users":  aU.Users,
314 304
 	})
315
-	var data []*adResp.GroupUsersPayload
316
-	for _, _u := range res.Users {
317
-		gup := &adResp.GroupUsersPayload{}
318
-		gup.FromUser(_u)
319
-		if _u.Id == uid {
320
-			gup.Status = 0
321
-		}
322
-		data = append(data, gup)
323
-	}
324
-	response.Success(c, data)
325 305
 }
326 306
 
327 307
 // Register

+ 0 - 12
http/response/admin/user.go

@@ -22,15 +22,3 @@ type UserOauthItem struct {
22 22
 	Op     string `json:"op"`
23 23
 	Status int    `json:"status"`
24 24
 }
25
-
26
-type GroupUsersPayload struct {
27
-	Id       uint   `json:"id"`
28
-	Username string `json:"username"`
29
-	Status   int    `json:"status"`
30
-}
31
-
32
-func (g *GroupUsersPayload) FromUser(user *model.User) {
33
-	g.Id = user.Id
34
-	g.Username = user.Username
35
-	g.Status = 1
36
-}

+ 6 - 1
resources/i18n/en.toml

@@ -137,4 +137,9 @@ other = "Captcha error."
137 137
 [PwdLoginDisabled]
138 138
 description = "Password login disabled."
139 139
 one = "Password login disabled."
140
-other = "Password login disabled."
140
+other = "Password login disabled."
141
+
142
+[CannotShareToSelf]
143
+description = "Cannot share to self."
144
+one = "Cannot share to self."
145
+other = "Cannot share to self."

+ 6 - 1
resources/i18n/es.toml

@@ -146,4 +146,9 @@ other = "Error de captcha."
146 146
 [PwdLoginDisabled]
147 147
 description = "Password login disabled."
148 148
 one = "Inicio de sesión con contraseña deshabilitado."
149
-other = "Inicio de sesión con contraseña deshabilitado."
149
+other = "Inicio de sesión con contraseña deshabilitado."
150
+
151
+[CannotShareToSelf]
152
+description = "Cannot share to self."
153
+one = "No se puede compartir con uno mismo."
154
+other = "No se puede compartir con uno mismo."

+ 6 - 1
resources/i18n/fr.toml

@@ -146,4 +146,9 @@ other = "Erreur de captcha."
146 146
 [PwdLoginDisabled]
147 147
 description = "Password login disabled."
148 148
 one = "Connexion par mot de passe désactivée."
149
-other = "Connexion par mot de passe désactivée."
149
+other = "Connexion par mot de passe désactivée."
150
+
151
+[CannotShareToSelf]
152
+description = "Cannot share to self."
153
+one = "Impossible de partager avec soi-même."
154
+other = "Impossible de partager avec soi-même."

+ 5 - 0
resources/i18n/ko.toml

@@ -141,3 +141,8 @@ other = "Captcha 오류."
141 141
 description = "Password login disabled."
142 142
 one = "비밀번호 로그인이 비활성화되었습니다."
143 143
 other = "비밀번호 로그인이 비활성화되었습니다."
144
+
145
+[CannotShareToSelf]
146
+description = "Cannot share to self."
147
+one = "자기 자신에게 공유할 수 없습니다."
148
+other = "자기 자신에게 공유할 수 없습니다."

+ 6 - 1
resources/i18n/ru.toml

@@ -146,4 +146,9 @@ other = "Ошибка капчи."
146 146
 [PwdLoginDisabled]
147 147
 description = "Password login disabled."
148 148
 one = "Вход по паролю отключен."
149
-other = "Вход по паролю отключен."
149
+other = "Вход по паролю отключен."
150
+
151
+[CannotShareToSelf]
152
+description = "Cannot share to self."
153
+one = "Нельзя поделиться с собой."
154
+other = "Нельзя поделиться с собой."

+ 6 - 1
resources/i18n/zh_CN.toml

@@ -139,4 +139,9 @@ other = "验证码错误。"
139 139
 [PwdLoginDisabled]
140 140
 description = "Password login disabled."
141 141
 one = "密码登录已禁用。"
142
-other = "密码登录已禁用。"
142
+other = "密码登录已禁用。"
143
+
144
+[CannotShareToSelf]
145
+description = "Cannot share to self."
146
+one = "不能共享给自己。"
147
+other = "不能共享给自己。"

+ 5 - 0
resources/i18n/zh_TW.toml

@@ -140,3 +140,8 @@ other = "驗證碼錯誤。"
140 140
 description = "Password login disabled."
141 141
 one = "密碼登錄已禁用。"
142 142
 other = "密碼登錄已禁用。"
143
+
144
+[CannotShareToSelf]
145
+description = "Cannot share to self."
146
+one = "無法共享給自己。"
147
+other = "無法共享給自己。"

+ 4 - 1
service/addressBook.go

@@ -293,8 +293,11 @@ func (s *AddressBookService) RuleInfoById(u uint) *model.AddressBookCollectionRu
293 293
 	return p
294 294
 }
295 295
 func (s *AddressBookService) RulePersonalInfoByToIdAndCid(toid, cid uint) *model.AddressBookCollectionRule {
296
+	return s.RuleInfoByToIdAndCid(model.ShareAddressBookRuleTypePersonal, toid, cid)
297
+}
298
+func (s *AddressBookService) RuleInfoByToIdAndCid(t int, toid, cid uint) *model.AddressBookCollectionRule {
296 299
 	p := &model.AddressBookCollectionRule{}
297
-	DB.Where("type = ? and to_id = ? and collection_id = ?", model.ShareAddressBookRuleTypePersonal, toid, cid).First(p)
300
+	DB.Where("type = ? and to_id = ? and collection_id = ?", t, toid, cid).First(p)
298 301
 	return p
299 302
 }
300 303
 func (s *AddressBookService) CreateRule(t *model.AddressBookCollectionRule) error {