|
@@ -7,7 +7,7 @@ import (
|
7
|
7
|
"XT_Admin_Api/service"
|
8
|
8
|
"XT_Admin_Api/utils"
|
9
|
9
|
"encoding/json"
|
10
|
|
- "github.com/jinzhu/gorm"
|
|
10
|
+ "fmt"
|
11
|
11
|
"reflect"
|
12
|
12
|
"time"
|
13
|
13
|
)
|
|
@@ -111,6 +111,9 @@ func (this *SystemApiController) GetFollowOrg() {
|
111
|
111
|
FollowOrgs, err := service.FindFollowOrg(id)
|
112
|
112
|
unFollow, _ := service.FindUnFollowOrgByIds(id)
|
113
|
113
|
|
|
114
|
+ fmt.Println(FollowOrgs)
|
|
115
|
+ fmt.Println(unFollow)
|
|
116
|
+
|
114
|
117
|
if err == nil {
|
115
|
118
|
this.ServeSuccessJSON(map[string]interface{}{
|
116
|
119
|
"follows": FollowOrgs,
|
|
@@ -281,15 +284,18 @@ func (this *SystemApiController) PostUnFollow() {
|
281
|
284
|
OrgId: org_id,
|
282
|
285
|
AdminUserId: info.AdminUserId,
|
283
|
286
|
}
|
284
|
|
- service.UpdateFollow(follow)
|
|
287
|
+ err := service.UpdateFollow(follow)
|
|
288
|
+ if err == nil {
|
|
289
|
+ this.ServeSuccessJSON(map[string]interface{}{
|
|
290
|
+ "msg": "删除成功",
|
|
291
|
+ })
|
|
292
|
+ }
|
|
293
|
+
|
285
|
294
|
}
|
286
|
295
|
|
287
|
296
|
func (this *SystemApiController) ModifyFollowInfo() {
|
288
|
|
- org_id, _ := this.GetInt64("org_id")
|
289
|
297
|
time := time.Now().Unix()
|
290
|
|
-
|
291
|
298
|
var orgFollow []*models.OrgFollow
|
292
|
|
-
|
293
|
299
|
dataBody := make(map[string]interface{}, 0)
|
294
|
300
|
err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
|
295
|
301
|
if err != nil {
|
|
@@ -309,33 +315,55 @@ func (this *SystemApiController) ModifyFollowInfo() {
|
309
|
315
|
return
|
310
|
316
|
}
|
311
|
317
|
admin_user_id := int64(items["admin_user_id"].(float64))
|
312
|
|
- follow := &models.OrgFollow{
|
313
|
|
- Mtime: time,
|
314
|
|
- Status: 1,
|
315
|
|
- Ctime: time,
|
316
|
|
- OrgId: org_id,
|
317
|
|
- AdminUserId: admin_user_id,
|
|
318
|
+
|
|
319
|
+ if items["org_id"] == nil || reflect.TypeOf(items["org_id"]).String() != "float64" {
|
|
320
|
+ utils.ErrorLog("org_id")
|
|
321
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
322
|
+ return
|
|
323
|
+ }
|
|
324
|
+ org_id := int64(items["org_id"].(float64))
|
|
325
|
+
|
|
326
|
+ if items["id"] == nil || reflect.TypeOf(items["id"]).String() != "float64" {
|
|
327
|
+ utils.ErrorLog("id")
|
|
328
|
+ this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
|
|
329
|
+ return
|
|
330
|
+ }
|
|
331
|
+ id := int64(items["id"].(float64))
|
|
332
|
+
|
|
333
|
+ if id == 0 {
|
|
334
|
+ follow := &models.OrgFollow{
|
|
335
|
+ Mtime: time,
|
|
336
|
+ Status: 1,
|
|
337
|
+ Ctime: time,
|
|
338
|
+ OrgId: org_id,
|
|
339
|
+ AdminUserId: admin_user_id,
|
|
340
|
+ }
|
|
341
|
+ orgFollow = append(orgFollow, follow)
|
318
|
342
|
}
|
319
|
|
- orgFollow = append(orgFollow, follow)
|
320
|
343
|
}
|
321
|
344
|
}
|
322
|
345
|
}
|
323
|
346
|
|
|
347
|
+ fmt.Println(orgFollow)
|
|
348
|
+
|
324
|
349
|
//防止数据冗余,先查出之前被删的数据是否存在,存在则直接改变删除状态,不插入新数据
|
325
|
350
|
for index, follow := range orgFollow {
|
326
|
351
|
info, err := service.FindFollowRecordByID(follow)
|
327
|
|
- if err == gorm.ErrRecordNotFound { //不存在,过滤掉该数据
|
|
352
|
+
|
|
353
|
+ if err == nil { //存在,则修改删除状态
|
328
|
354
|
orgFollow = append(orgFollow[:index], orgFollow[index+1:]...)
|
329
|
|
- } else if err == nil { //存在,则修改删除状态
|
330
|
|
- follow := &models.OrgFollow{
|
331
|
|
- ID: info.ID,
|
332
|
|
- Mtime: info.Mtime,
|
333
|
|
- Status: 1,
|
334
|
|
- Ctime: info.Ctime,
|
335
|
|
- OrgId: info.OrgId,
|
336
|
|
- AdminUserId: info.AdminUserId,
|
|
355
|
+ if info.Status == 0 {
|
|
356
|
+ follow := &models.OrgFollow{
|
|
357
|
+ ID: info.ID,
|
|
358
|
+ Mtime: info.Mtime,
|
|
359
|
+ Status: 1,
|
|
360
|
+ Ctime: info.Ctime,
|
|
361
|
+ OrgId: info.OrgId,
|
|
362
|
+ AdminUserId: info.AdminUserId,
|
|
363
|
+ }
|
|
364
|
+ service.UpdateFollow(follow)
|
337
|
365
|
}
|
338
|
|
- service.UpdateFollow(follow)
|
|
366
|
+
|
339
|
367
|
}
|
340
|
368
|
}
|
341
|
369
|
|