@@ -2,6 +2,7 @@ package logic
2
2
3
3
import (
4
4
"fmt"
5
+ "strings"
5
6
6
7
"github.com/eryajf/go-ldap-admin/config"
7
8
"github.com/eryajf/go-ldap-admin/model"
@@ -216,6 +217,24 @@ func (l UserLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
216
217
return nil , tools .NewMySqlError (err )
217
218
}
218
219
220
+ var (
221
+ depts string
222
+ deptids []uint
223
+ )
224
+ if strings .Contains (r .Departments , "请选择部门信息" ) {
225
+ for _ , v := range strings .Split (r .Departments , "," ) {
226
+ if v != "请选择部门信息" {
227
+ depts += v + ","
228
+ }
229
+ }
230
+ for _ , j := range r .DepartmentId {
231
+ if j != 0 {
232
+ deptids = append (deptids , j )
233
+ }
234
+ }
235
+ }
236
+ // fmt.Println(depts, deptids)
237
+
219
238
// 拼装新的用户信息
220
239
user := model.User {
221
240
Model : oldData .Model ,
@@ -227,11 +246,11 @@ func (l UserLogic) Update(c *gin.Context, req interface{}) (data interface{}, rs
227
246
Mobile : r .Mobile ,
228
247
Avatar : r .Avatar ,
229
248
PostalAddress : r .PostalAddress ,
230
- Departments : r . Departments ,
249
+ Departments : depts ,
231
250
Position : r .Position ,
232
251
Introduction : r .Introduction ,
233
252
Creator : ctxUser .Username ,
234
- DepartmentId : tools .SliceToString (r . DepartmentId , "," ),
253
+ DepartmentId : tools .SliceToString (deptids , "," ),
235
254
Source : oldData .Source ,
236
255
Roles : roles ,
237
256
UserDN : oldData .UserDN ,
0 commit comments