|
|
@@ -342,16 +342,24 @@ func UserManagementUserRecycle(c *gin.Context) { |
|
|
|
e.OutErr(c, e.ERR_INVALID_ARGS, err.Error()) |
|
|
|
return |
|
|
|
} |
|
|
|
ex := strings.Split(req.UID, ",") |
|
|
|
NewUserDb := implement.NewUserDb(db.Db) |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
for _, v := range ex { |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(v)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
} |
|
|
|
user.State = 4 |
|
|
|
user.RecycleParentUid = utils.StrToInt(req.ParentUid) |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state,recycle_parent_uid").Update(user) |
|
|
|
// 清掉token |
|
|
|
cacheKey := fmt.Sprintf("egg_app_jwt_token:%d", user.Id) |
|
|
|
cache.SetEx(cacheKey, "", 1) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户回收", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 删除到回收站", "") |
|
|
|
} |
|
|
|
user.State = 4 |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state").Update(user) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户回收", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 删除到回收站", utils.SerializeStr(user)) |
|
|
|
|
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
} |
|
|
|
|
|
|
@@ -362,7 +370,7 @@ func UserManagementUserRecycle(c *gin.Context) { |
|
|
|
// @Accept json |
|
|
|
// @Produce json |
|
|
|
// @param Authorization header string true "验证参数Bearer和token空格拼接" |
|
|
|
// @Param req body md.UserManagementUserInfoReq true "用户ID 必传" |
|
|
|
// @Param req body md.UserManagementUserInfoCancelReq true "用户ID 必传" |
|
|
|
// @Success 200 {int} "修改数据行数" |
|
|
|
// @Failure 400 {object} md.Response "具体错误" |
|
|
|
// @Router /api/memberCenter/userManagement/userRecycleCancel [post] |
|
|
@@ -373,15 +381,19 @@ func UserManagementUserRecycleCancel(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
NewUserDb := implement.NewUserDb(db.Db) |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
ex := strings.Split(req.UID, ",") |
|
|
|
for _, v := range ex { |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(v)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
} |
|
|
|
user.State = 1 |
|
|
|
user.RecycleParentUid = 0 |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state,recycle_parent_uid").Update(user) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户恢复", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 恢复到会员列表", "") |
|
|
|
} |
|
|
|
user.State = 1 |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state").Update(user) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户恢复", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 恢复到会员列表", utils.SerializeStr(user)) |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
} |
|
|
|
|
|
|
@@ -403,41 +415,48 @@ func UserManagementUserDelete(c *gin.Context) { |
|
|
|
return |
|
|
|
} |
|
|
|
NewUserDb := implement.NewUserDb(db.Db) |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(req.UID)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
} |
|
|
|
if user.State != 4 { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "不能删除")) |
|
|
|
return |
|
|
|
} |
|
|
|
user.State = 3 |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state").Update(user) |
|
|
|
tmp := model.UserDeleteInfo{ |
|
|
|
Uid: int(user.Id), |
|
|
|
Phone: user.Phone, |
|
|
|
CreateAt: time.Now(), |
|
|
|
} |
|
|
|
db.Db.Insert(&tmp) |
|
|
|
ex := strings.Split(req.UID, ",") |
|
|
|
ch, err := rabbit.Cfg.Pool.GetChannel() |
|
|
|
if err == nil { |
|
|
|
defer ch.Release() |
|
|
|
} |
|
|
|
|
|
|
|
for _, v := range ex { |
|
|
|
user, _ := NewUserDb.GetUser(utils.StrToInt64(v)) |
|
|
|
if user == nil { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "用户不存在")) |
|
|
|
return |
|
|
|
} |
|
|
|
if user.State != 4 { |
|
|
|
e.OutErr(c, 400, e.NewErr(400, "不能删除")) |
|
|
|
return |
|
|
|
} |
|
|
|
user.State = 3 |
|
|
|
db.Db.Where("id=?", user.Id).Cols("state").Update(user) |
|
|
|
tmp := model.UserDeleteInfo{ |
|
|
|
Uid: int(user.Id), |
|
|
|
Phone: user.Phone, |
|
|
|
CreateAt: time.Now(), |
|
|
|
} |
|
|
|
db.Db.Insert(&tmp) |
|
|
|
err = ch.PublishV2(md2.EggUserExchange, md2.CommUserId{ |
|
|
|
Uid: utils.Int64ToStr(user.Id), |
|
|
|
Uid: utils.Int64ToStr(user.Id), |
|
|
|
ParentUid: utils.IntToStr(user.RecycleParentUid), |
|
|
|
}, md2.EggUserDelete) |
|
|
|
if err != nil { |
|
|
|
ch.PublishV2(md2.EggUserExchange, md2.CommUserId{ |
|
|
|
Uid: utils.Int64ToStr(user.Id), |
|
|
|
Uid: utils.Int64ToStr(user.Id), |
|
|
|
ParentUid: utils.IntToStr(user.RecycleParentUid), |
|
|
|
}, md2.EggUserDelete) |
|
|
|
} |
|
|
|
// 清掉token |
|
|
|
cacheKey := fmt.Sprintf("egg_app_jwt_token:%d", user.Id) |
|
|
|
_, err = cache.SetEx(cacheKey, "", 1) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户永久删除", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 永久删除", "") |
|
|
|
} |
|
|
|
// 清掉token |
|
|
|
cacheKey := fmt.Sprintf("egg_app_jwt_token:%d", user.Id) |
|
|
|
_, err = cache.SetEx(cacheKey, "", 1) |
|
|
|
admin := svc2.GetUser(c) |
|
|
|
svc2.AddAdminLog(c, admin.AdmId, "用户永久删除", "用户id:"+utils.Int64ToStr(user.Id)+",用户手机号:"+user.Phone+" 永久删除", utils.SerializeStr(user)) |
|
|
|
e.OutSuc(c, "success", nil) |
|
|
|
return |
|
|
|
} |
|
|
|
|
|
|
|
// UserManagementGetOneBasic |
|
|
|