parent
93f6c66bb6
commit
fcbd00ad14
@ -0,0 +1,114 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hfkj.common.exception.ErrorCode; |
||||
import com.hfkj.common.exception.ErrorHelp; |
||||
import com.hfkj.common.exception.SysCode; |
||||
import com.hfkj.common.utils.ResponseMsgUtil; |
||||
import com.hfkj.entity.BsUser; |
||||
import com.hfkj.model.ResponseData; |
||||
import com.hfkj.service.user.BsUserService; |
||||
import com.hfkj.service.user.impl.BsUserServiceImpl; |
||||
import com.hfkj.sysenum.SecUserStatusEnum; |
||||
import com.hfkj.sysenum.UserStatusEnum; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* @className: BsUserController |
||||
* @author: HuRui |
||||
* @date: 2024/5/6 |
||||
**/ |
||||
@Controller |
||||
@RequestMapping(value="/user") |
||||
@Api(value="系统菜单管理") |
||||
public class BsUserController { |
||||
private static Logger log = LoggerFactory.getLogger(BsUserController.class); |
||||
@Resource |
||||
private BsUserService userService; |
||||
|
||||
@RequestMapping(value="/restore",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "恢复") |
||||
public ResponseData restore(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("userId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
|
||||
// 查询用户详情
|
||||
BsUser user = userService.getUser(body.getLong("userId")); |
||||
if (user == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
user.setStatus(UserStatusEnum.status1.getCode()); |
||||
userService.editData(user); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/disable",method = RequestMethod.POST) |
||||
@ResponseBody |
||||
@ApiOperation(value = "禁用") |
||||
public ResponseData disable(@RequestBody JSONObject body) { |
||||
try { |
||||
if (body == null || body.getLong("userId") == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
// 查询用户详情
|
||||
BsUser user = userService.getUser(body.getLong("userId")); |
||||
if (user == null) { |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); |
||||
} |
||||
user.setStatus(SecUserStatusEnum.status2.getCode()); |
||||
userService.editData(user); |
||||
|
||||
// 退出当前登录信息
|
||||
userService.loginOut(new BsUserServiceImpl().token(user)); |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value="/queryUserList",method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "查询用户列表") |
||||
public ResponseData queryUserList(@RequestParam(value = "name" , required = false) String name, |
||||
@RequestParam(value = "phone" , required = false) String phone, |
||||
@RequestParam(value = "status" , required = false) Integer status, |
||||
@RequestParam(value = "pageNum" , required = true) Integer pageNum, |
||||
@RequestParam(value = "pageSize" , required = true) Integer pageSize) { |
||||
try { |
||||
Map<String,Object> param = new HashMap<>(); |
||||
param.put("name", name); |
||||
param.put("phone", phone); |
||||
param.put("status", status); |
||||
|
||||
PageHelper.startPage(pageNum, pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(userService.getList(param))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("error!",e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue