Skip to content

Commit

Permalink
fix(admin):修改更改个人状态为批量更改
Browse files Browse the repository at this point in the history
Signed-off-by: Penryn <15158052130@163.com>
  • Loading branch information
Penryn committed Oct 17, 2024
1 parent 0f0a64e commit 5b4a764
Showing 1 changed file with 32 additions and 24 deletions.
56 changes: 32 additions & 24 deletions controller/admin/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,44 +16,52 @@ type UserStatusForm struct {
Status int `json:"status" binding:"required,oneof=1 2"`
}

type UserStatusList struct {
List []UserStatusForm `json:"list" binding:"required"`
}

// UserSU 输入userID
func UserStatus(c *gin.Context) {
var postForm UserStatusForm
var postForm UserStatusList
err := c.ShouldBindJSON(&postForm)
if err != nil {
utility.ResponseError(c, "参数错误")
return
}

user, _ := adminService.GetAdminByJWT(c)
for _, form := range postForm.List {
// 获取个人信息
person, err := model.GetPerson(form.UserID)
if err != nil {
utility.ResponseError(c, "扫码错误,查找用户失败,请再次核对")
return
}

// 获取个人信息
person, err := model.GetPerson(postForm.UserID)
if err != nil {
utility.ResponseError(c, "扫码错误,查找用户失败,请再次核对")
return
}
var team model.Team
if err := global.DB.Where("id = ?", person.TeamId).Take(&team).Error; err != nil {
utility.ResponseError(c, "队伍信息获取失败")
return
}

var team model.Team
global.DB.Where("id = ?", person.TeamId).Take(&team)
// 管理员只能管理自己所在的校区
b := middleware.CheckRoute(user, &team)
if !b {
utility.ResponseError(c, "该队伍为其他路线")
return
}
// 管理员只能管理自己所在的校区
if !middleware.CheckRoute(user, &team) {
utility.ResponseError(c, "该队伍为其他路线")
return
}

if person.WalkStatus == 5 {
utility.ResponseError(c, "成员已结束毅行")
return
}
if person.WalkStatus == 5 {
utility.ResponseError(c, "成员已结束毅行")
return
}

if postForm.Status == 1 {
person.WalkStatus = 3
} else {
person.WalkStatus = 4
if form.Status == 1 {
person.WalkStatus = 3
} else {
person.WalkStatus = 4
}
userService.Update(*person)
}
userService.Update(*person)

utility.ResponseSuccess(c, nil)
}

0 comments on commit 5b4a764

Please sign in to comment.