更新用户状态.
()
| 219 | |
| 220 | // 更新用户状态. |
| 221 | func (this *ManagerController) UpdateMemberStatus() { |
| 222 | |
| 223 | memberId, _ := this.GetInt("member_id", 0) |
| 224 | status, _ := this.GetInt("status", 0) |
| 225 | |
| 226 | if memberId <= 0 { |
| 227 | this.JsonResult(6001, "参数错误") |
| 228 | } |
| 229 | if status != 0 && status != 1 { |
| 230 | status = 0 |
| 231 | } |
| 232 | member := models.NewMember() |
| 233 | |
| 234 | if _, err := member.Find(memberId); err != nil { |
| 235 | this.JsonResult(6002, "用户不存在") |
| 236 | } |
| 237 | if member.MemberId == this.Member.MemberId { |
| 238 | this.JsonResult(6004, "不能变更自己的状态") |
| 239 | } |
| 240 | if member.Role == conf.MemberSuperRole { |
| 241 | this.JsonResult(6005, "不能变更超级管理员的状态") |
| 242 | } |
| 243 | member.Status = status |
| 244 | |
| 245 | if err := member.Update(); err != nil { |
| 246 | logs.Error("", err) |
| 247 | this.JsonResult(6003, "用户状态设置失败") |
| 248 | } |
| 249 | this.JsonResult(0, "ok", member) |
| 250 | } |
| 251 | |
| 252 | // 变更用户权限. |
| 253 | func (this *ManagerController) ChangeMemberRole() { |
nothing calls this directly
no test coverage detected