diff --git a/app/hdl/member_center/hdl_user_management.go b/app/hdl/member_center/hdl_user_management.go index 9bbd334..d2c9e7c 100644 --- a/app/hdl/member_center/hdl_user_management.go +++ b/app/hdl/member_center/hdl_user_management.go @@ -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 diff --git a/app/md/md_mq.go b/app/md/md_mq.go index 9b84649..ccf9bd7 100644 --- a/app/md/md_mq.go +++ b/app/md/md_mq.go @@ -11,5 +11,6 @@ type JpushRecordFundData struct { Id string `json:"id"` } type CommUserId struct { - Uid string `json:"uid"` + Uid string `json:"uid"` + ParentUid string `json:"parent_uid"` } diff --git a/app/md/member_center/md_user_management.go b/app/md/member_center/md_user_management.go index ff1ec0b..f1d2e8e 100644 --- a/app/md/member_center/md_user_management.go +++ b/app/md/member_center/md_user_management.go @@ -94,7 +94,11 @@ type UserManagementUpdateUserInfoReq struct { Password string `json:"password"` // 登录密码 } type UserManagementUserInfoReq struct { - UID string `json:"uid"` + UID string `json:"uid" example:"多个逗号隔开"` + ParentUid string `json:"parent_uid" example:"参考下智莺 保留关系时候的选择用户"` +} +type UserManagementUserInfoCancelReq struct { + UID string `json:"uid" example:"多个逗号隔开"` } type TagNode struct { TagID int `json:"tag_id"` // 标签 ID diff --git a/go.mod b/go.mod index 4b828a4..32911af 100644 --- a/go.mod +++ b/go.mod @@ -33,7 +33,7 @@ require ( ) require ( - code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211131723-5b61ee87000b + code.fnuoos.com/EggPlanet/egg_models.git v0.2.1-0.20241211152610-0c5e1e903c99 code.fnuoos.com/EggPlanet/egg_system_rules.git v0.0.4-0.20241205075006-9c0bf995c788 code.fnuoos.com/go_rely_warehouse/zyos_go_es.git v1.0.1-0.20241118083738-0f22da9ba0be code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git v0.0.5