|
@@ -0,0 +1,533 @@
|
|
|
+package cn.aiyangniu.api.controller.system;
|
|
|
+
|
|
|
+import cn.aiyangniu.api.common.entity.system.*;
|
|
|
+import cn.aiyangniu.api.common.util.*;
|
|
|
+import cn.aiyangniu.api.service.system.SysUserService;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 用户业务接口类
|
|
|
+ *
|
|
|
+ * @author Henry Hall
|
|
|
+ * @since 2020-08-08
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@Api(tags="系统管理员接口")
|
|
|
+@RequestMapping("/sysUser")
|
|
|
+public class SysUserController {
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private SysUserService usrService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RandomUtil randomUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AuthUtil authUtil;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RedisUtil redisUtil;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * saveUsr 新增/修改用户
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "新增/修改角色信息")
|
|
|
+ @RequestMapping(value="/save", method= RequestMethod.POST)
|
|
|
+ @ApiImplicitParam(name = "usrEntity", value = "用户实体对象", paramType = "body", dataType="SysUserEntity", dataTypeClass = SysUserEntity.class, required = true)
|
|
|
+ public Map<String, Object> saveUser(@RequestBody SysUserEntity usrEntity, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, sysRandom, token, reqRandom, userId, nickName, mobile, usname, passwd, orgId, dutyId, roleId;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ AuthEntity auth = authUtil.getUserId(token);
|
|
|
+ if(auth == null || !auth.isSuccess()) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ sysRandom = randomUtil.getSysRandom(auth.getUserId());
|
|
|
+ userId = usrEntity.getUserId();
|
|
|
+ nickName = usrEntity.getNickName();
|
|
|
+ mobile = usrEntity.getMobile();
|
|
|
+ usname = usrEntity.getUsname();
|
|
|
+ passwd = usrEntity.getPasswd();
|
|
|
+ orgId = usrEntity.getOrgId();
|
|
|
+ dutyId = usrEntity.getDutyId();
|
|
|
+ roleId = usrEntity.getRoleId();
|
|
|
+ reqRandom = usrEntity.getReqRandom();
|
|
|
+ userId = CharacterFiltUtil.inputFilter(userId, true);
|
|
|
+ nickName = CharacterFiltUtil.inputFilter(nickName, true);
|
|
|
+ mobile = CharacterFiltUtil.inputFilter(mobile, true);
|
|
|
+ usname = CharacterFiltUtil.inputFilter(usname, true);
|
|
|
+ passwd = CharacterFiltUtil.inputFilter(passwd, true);
|
|
|
+ orgId = CharacterFiltUtil.inputFilter(orgId, true);
|
|
|
+ dutyId = CharacterFiltUtil.inputFilter(dutyId, true);
|
|
|
+ roleId = CharacterFiltUtil.inputFilter(roleId, true);
|
|
|
+ reqRandom = CharacterFiltUtil.inputFilter(reqRandom, true);
|
|
|
+ SysUserVo usrVo = new SysUserVo();
|
|
|
+ usrVo.setUserId(userId);
|
|
|
+ usrVo.setUsname(usname);
|
|
|
+ boolean exists = usrService.extUser(usrVo)>0;
|
|
|
+ if("".equals(nickName) || "".equals(mobile) || "".equals(usname) || ("".equals(userId) && "".equals(passwd)) || "".equals(orgId) || "".equals(dutyId) || "".equals(roleId) || "".equals(reqRandom)) {
|
|
|
+ retCode = "100110050101";
|
|
|
+ retMsg = "对不起,您输入的信息有为空的必填项,请检查!";
|
|
|
+ } else if(nickName.length() > 30 || mobile.length() != 11 || usname.length() > 30 || passwd.length() > 30 || orgId.length() != 36 || dutyId.length() != 36 || roleId.length() != 36) {
|
|
|
+ retCode = "100110050102";
|
|
|
+ retMsg = "对不起,您输入的信息有超出字数限制的项,请检查!";
|
|
|
+ } else if(RandomUtil.verifySysRandom(reqRandom, sysRandom)) {
|
|
|
+ retCode = "100110050103";
|
|
|
+ retMsg = "对不起,您已经提交过了,请不要重复提交!";
|
|
|
+ } else if(exists) {
|
|
|
+ retCode = "100110050106";
|
|
|
+ retMsg = "对不起,您输入的登录账号已经存在,请更换!";
|
|
|
+ } else {
|
|
|
+ randomUtil.setSysRandom(auth.getUserId());
|
|
|
+ if(!"".equals(passwd) && !"********".equals(passwd)) {
|
|
|
+ passwd = Md5Util.strMd5(passwd);
|
|
|
+ }
|
|
|
+ usrEntity.setNickName(nickName);
|
|
|
+ usrEntity.setMobile(mobile);
|
|
|
+ usrEntity.setUsname(usname);
|
|
|
+ usrEntity.setPasswd(passwd);
|
|
|
+ usrEntity.setOrgId(orgId);
|
|
|
+ usrEntity.setDutyId(dutyId);
|
|
|
+ usrEntity.setRoleId(roleId);
|
|
|
+ usrEntity.setOptUser(auth.getUserId());
|
|
|
+ int r;
|
|
|
+ if("".equals(userId)) {
|
|
|
+ usrEntity.setUserId(UUIDUtil.create36UUID());
|
|
|
+ r = usrService.addUser(usrEntity);
|
|
|
+ } else {
|
|
|
+ usrEntity.setUserId(userId);
|
|
|
+ r = usrService.edtUser(usrEntity);
|
|
|
+ }
|
|
|
+ if(r != 0) {
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "恭喜您,用户保存成功!";
|
|
|
+ } else {
|
|
|
+ retCode = "100110050104";
|
|
|
+ retMsg = "对不起,系统错误,请联系系统管理员!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * proUsrs 删除用户
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "删除角色信息")
|
|
|
+ @RequestMapping(value="/process", method= RequestMethod.POST)
|
|
|
+ @ApiImplicitParam(name = "roleEntity", value = "角色实体对象", paramType = "body", dataType="SysRoleEntity", dataTypeClass = SysRoleEntity.class, required = true)
|
|
|
+ public Map<String, Object> proUsers(HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token, ids, dataStatus;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ AuthEntity auth = authUtil.getUserId(token);
|
|
|
+ if(auth == null || !auth.isSuccess()) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ ids = req.getParameter("ids");
|
|
|
+ dataStatus = req.getParameter("dataStatus");
|
|
|
+ ids = CharacterFiltUtil.inputFilter(ids, true);
|
|
|
+ dataStatus = CharacterFiltUtil.inputFilter(dataStatus, true);
|
|
|
+ int iStatus = CharacterFiltUtil.isInt(dataStatus) ? Integer.parseInt(dataStatus) : 0;
|
|
|
+ if("".equals(ids) || iStatus == 0) {
|
|
|
+ retCode = "100110050201";
|
|
|
+ retMsg = "对不起,您提交的信息有为空的必填项,请检查!";
|
|
|
+ } else {
|
|
|
+ List<String> userIds = Arrays.asList(ids.split(","));
|
|
|
+ SysUserVo usrVo = new SysUserVo();
|
|
|
+ usrVo.setDataStatus(iStatus);
|
|
|
+ usrVo.setOptUser(auth.getUserId());
|
|
|
+ usrVo.setUserIds(userIds);
|
|
|
+ int r = usrService.proUsers(usrVo);
|
|
|
+ if(r != 0) {
|
|
|
+ retCode = "1001";
|
|
|
+ switch(iStatus) {
|
|
|
+ case 1:
|
|
|
+ retMsg = "恭喜您,用户审核成功!";
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ retMsg = "恭喜您,用户取消审核成功!";
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ retMsg = "恭喜您,用户删除成功!";
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ retMsg = "恭喜您,用户处理成功!";
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ retCode = "100110050204";
|
|
|
+ retMsg = "对不起,系统错误,请联系系统管理员!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * getUser 获取单一用户
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户详情信息")
|
|
|
+ @RequestMapping(value="/getById", method= RequestMethod.GET)
|
|
|
+ @ApiImplicitParam(name = "userId", value = "用户编号", paramType = "query", dataType="string", dataTypeClass = String.class, required = true)
|
|
|
+ public Map<String, Object> getUser(String userId, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token;
|
|
|
+ SysUserEntity usrEntity;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ boolean auth = authUtil.hasLogin(token);
|
|
|
+ if(!auth) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ userId = CharacterFiltUtil.inputFilter(userId, true);
|
|
|
+ if("".equals(userId) || userId.length() != 36) {
|
|
|
+ retCode = "100110050301";
|
|
|
+ retMsg = "对不起,您请求的参数非法,请重试!";
|
|
|
+ } else {
|
|
|
+ usrEntity = usrService.getUser(userId);
|
|
|
+ if(usrEntity != null) {
|
|
|
+ result.put("data", usrEntity);
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "查询成功。";
|
|
|
+ } else {
|
|
|
+ retCode = "100110050305";
|
|
|
+ retMsg = "暂无内容";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * listUsrs 列表显示用户
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户分页列表")
|
|
|
+ @RequestMapping(value="/page", method= RequestMethod.GET)
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "schName", value = "关键字", paramType = "query", dataType="string", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "orgId", value = "组织编号", paramType = "query", dataType="int", dataTypeClass = Integer.class),
|
|
|
+ @ApiImplicitParam(name = "dutyId", value = "职务编号", paramType = "query", dataType="int", dataTypeClass = Integer.class),
|
|
|
+ @ApiImplicitParam(name = "roleId", value = "角色编号", paramType = "query", dataType="int", dataTypeClass = Integer.class),
|
|
|
+ @ApiImplicitParam(name = "states", value = "用户状态", paramType = "query", dataType="int", dataTypeClass = Integer.class),
|
|
|
+ @ApiImplicitParam(name = "offset", value = "开始数据", paramType = "query", dataType="int", dataTypeClass = Integer.class, required = true),
|
|
|
+ @ApiImplicitParam(name = "limit", value = "每页数量", paramType = "query", dataType="int", dataTypeClass = Integer.class, required = true)
|
|
|
+ })
|
|
|
+ public Map<String, Object> listUsers(String schName, String orgId, String dutyId, String roleId, Integer states, Integer offset, Integer limit, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token;
|
|
|
+ int kind, pageNo;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ AuthEntity auth = authUtil.getUserId(token);
|
|
|
+ if(auth == null || !auth.isSuccess()) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ schName = CharacterFiltUtil.inputFilter(schName, true);
|
|
|
+ orgId = CharacterFiltUtil.inputFilter(orgId, true);
|
|
|
+ dutyId = CharacterFiltUtil.inputFilter(dutyId, true);
|
|
|
+ roleId = CharacterFiltUtil.inputFilter(roleId, true);
|
|
|
+ kind = (auth.getUserId().contains("glyhv") ? 1 : 2);
|
|
|
+ SysUserVo usrVo = new SysUserVo();
|
|
|
+ usrVo.setName(schName);
|
|
|
+ usrVo.setOrgId(orgId);
|
|
|
+ usrVo.setDutyId(dutyId);
|
|
|
+ usrVo.setRoleId(roleId);
|
|
|
+ usrVo.setDataStatus(states);
|
|
|
+ usrVo.setKind(kind);
|
|
|
+ pageNo = offset / limit + 1;
|
|
|
+ IPage<SysUserDto> iPage = usrService.listUsers(usrVo, pageNo, limit);
|
|
|
+ if(iPage != null && iPage.getRecords() != null && iPage.getRecords().size() > 0) {
|
|
|
+ result.put("data", iPage.getRecords());
|
|
|
+ result.put("total", iPage.getTotal());
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "查询成功。";
|
|
|
+ } else {
|
|
|
+ retCode = "100110050405";
|
|
|
+ retMsg = "暂无内容";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * selUsrs 下拉选择用户列表
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户下拉列表")
|
|
|
+ @RequestMapping(value="/select", method= RequestMethod.GET)
|
|
|
+ @ApiImplicitParam(name = "schName", value = "关键字", paramType = "query", dataType="string", dataTypeClass = String.class)
|
|
|
+ public Map<String, Object> selUsers(String schName, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ AuthEntity auth = authUtil.getUserId(token);
|
|
|
+ if(auth == null || !auth.isSuccess()) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ schName = CharacterFiltUtil.inputFilter(schName, true);
|
|
|
+ int kind = (auth.getUserId().contains("glyhv") ? 1 : 2);
|
|
|
+ SysUserVo usrVo = new SysUserVo();
|
|
|
+ usrVo.setName(schName);
|
|
|
+ usrVo.setKind(kind);
|
|
|
+ List<SysUserDto> usrDtoList = usrService.selUsers(usrVo);
|
|
|
+ if(usrDtoList != null && usrDtoList.size() > 0) {
|
|
|
+ result.put("data", usrDtoList);
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "查询成功。";
|
|
|
+ } else {
|
|
|
+ retCode = "100110050505";
|
|
|
+ retMsg = "暂无内容";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * loginUsr 用户登录
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户下拉列表")
|
|
|
+ @RequestMapping(value="/login", method= RequestMethod.POST)
|
|
|
+ @ApiImplicitParam(name = "usrVo", value = "用户登录的对象", paramType = "query", dataType="SysUserVo", dataTypeClass = SysUserVo.class)
|
|
|
+ public Map<String, Object> loginUser(@RequestBody SysUserVo usrVo, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, username, password, ipAddr, key;
|
|
|
+ int times = 0;
|
|
|
+ ipAddr = ClientIpUtil.getIPAddr(req);
|
|
|
+ key = "ip_" + ipAddr;
|
|
|
+ if(redisUtil.exists(key)) {
|
|
|
+ times = redisUtil.get(key);
|
|
|
+ times++;
|
|
|
+ }
|
|
|
+ redisUtil.add(key, times, 1800);
|
|
|
+ result.put("show", (times>10 ? 1 : 2));
|
|
|
+ username = usrVo.getUsname();
|
|
|
+ password = usrVo.getPasswd();
|
|
|
+ username = CharacterFiltUtil.inputFilter(username, true);
|
|
|
+ password = CharacterFiltUtil.inputFilter(password, true);
|
|
|
+ password = Md5Util.strMd5(password);
|
|
|
+ usrVo.setPasswd(password);
|
|
|
+ if("".equals(username) || "".equals(password)) {
|
|
|
+ retCode = "100110050601";
|
|
|
+ retMsg = "对不起,您输入的信息有为空的必填项,请检查!";
|
|
|
+ } else {
|
|
|
+ SysUserDto usrDto = usrService.loginUser(usrVo);
|
|
|
+ if(usrDto == null) {
|
|
|
+ retCode = "100110050607";
|
|
|
+ retMsg = "对不起,您的用户名或密码不正确,请重试!";
|
|
|
+ } else {
|
|
|
+ int flag = usrDto.getDataStatus();
|
|
|
+ if(flag == 2) {
|
|
|
+ retCode = "100110050608";
|
|
|
+ retMsg = "对不起,您的账号未被审核,请联系系统管理员!";
|
|
|
+ } else {
|
|
|
+ String xAuthKey = UUIDUtil.create32UUID();
|
|
|
+ authUtil.setUserSession(usrDto, xAuthKey);
|
|
|
+ result.put("data", xAuthKey);
|
|
|
+ redisUtil.delete(key);
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "恭喜您,登录成功!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * userSession 获取用户Session
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "获取用户Session")
|
|
|
+ @RequestMapping(value="/session", method= RequestMethod.GET)
|
|
|
+ public Map<String, Object> userSession(HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ JSONObject session = authUtil.getUserSession(token);
|
|
|
+ if(session == null) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ result.put("data", session);
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "查询成功。";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * exitUser 退出登录
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "退出登录")
|
|
|
+ @RequestMapping(value="/exit", method= RequestMethod.POST)
|
|
|
+ public Map<String, Object> exitUser(HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ authUtil.delUserSession(token);
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "退出成功。";
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * edtUsr 修改个人资料
|
|
|
+ *
|
|
|
+ * @param req 请求对象
|
|
|
+ * @return 返回结果Json串
|
|
|
+ */
|
|
|
+ @ApiOperation(value = "修改个人资料")
|
|
|
+ @RequestMapping(value="/edit", method= RequestMethod.POST)
|
|
|
+ @ApiImplicitParam(name = "usrEntity", value = "用户登录的对象", paramType = "query", dataType="SysUserEntity", dataTypeClass = SysUserEntity.class)
|
|
|
+ public Map<String, Object> edtUser(@RequestBody SysUserEntity usrEntity, HttpServletRequest req) {
|
|
|
+ Map<String, Object> result = new HashMap<>();
|
|
|
+ String retCode, retMsg, token, userId, nickName, mobile, usname, passwd;
|
|
|
+ token = req.getHeader("Authorization");
|
|
|
+ if(token == null || "null".equals(token)) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您的操作非法,请登录!";
|
|
|
+ } else {
|
|
|
+ boolean auth = authUtil.hasLogin(token);
|
|
|
+ if(!auth) {
|
|
|
+ retCode = "1002";
|
|
|
+ retMsg = "对不起,您没有登录或会话超时,请重新登录!";
|
|
|
+ } else {
|
|
|
+ userId = usrEntity.getUserId();
|
|
|
+ nickName = usrEntity.getNickName();
|
|
|
+ usname = usrEntity.getUsname();
|
|
|
+ passwd = usrEntity.getPasswd();
|
|
|
+ mobile = usrEntity.getMobile();
|
|
|
+ userId = CharacterFiltUtil.inputFilter(userId, true);
|
|
|
+ nickName = CharacterFiltUtil.inputFilter(nickName, true);
|
|
|
+ usname = CharacterFiltUtil.inputFilter(usname, true);
|
|
|
+ passwd = CharacterFiltUtil.inputFilter(passwd, true);
|
|
|
+ mobile = CharacterFiltUtil.inputFilter(mobile, true);
|
|
|
+ SysUserVo usrVo = new SysUserVo();
|
|
|
+ usrVo.setUserId(userId);
|
|
|
+ usrVo.setUsname(usname);
|
|
|
+ boolean exists = usrService.extUser(usrVo)>0;
|
|
|
+ if("".equals(userId) || "".equals(nickName) || "".equals(mobile) || "".equals(usname)) {
|
|
|
+ retCode = "100110050901";
|
|
|
+ retMsg = "对不起,您输入的信息有为空的必填项,请检查!";
|
|
|
+ } else if(userId.length() != 36 || nickName.length() > 30 || usname.length() > 30 || passwd.length() > 30 || mobile.length() != 11) {
|
|
|
+ retCode = "100110050902";
|
|
|
+ retMsg = "对不起,您输入的信息有超出字数限制的项,请检查!";
|
|
|
+ } else if(exists) {
|
|
|
+ retCode = "100110050906";
|
|
|
+ retMsg = "对不起,您输入的登录账号已经存在,请更换!";
|
|
|
+ } else {
|
|
|
+ if(!"".equals(passwd) && !"********".equals(passwd)) {
|
|
|
+ passwd = Md5Util.strMd5(passwd);
|
|
|
+ }
|
|
|
+ usrEntity.setUserId(userId);
|
|
|
+ usrEntity.setNickName(nickName);
|
|
|
+ usrEntity.setMobile(mobile);
|
|
|
+ usrEntity.setUsname(usname);
|
|
|
+ usrEntity.setPasswd(passwd);
|
|
|
+ usrEntity.setOptUser(userId);
|
|
|
+ int r = usrService.updUser(usrEntity);
|
|
|
+ if(r != 0) {
|
|
|
+ retCode = "1001";
|
|
|
+ retMsg = "恭喜您,个人资料修改成功,请重新登录以便生效!";
|
|
|
+ } else {
|
|
|
+ retCode = "100110050904";
|
|
|
+ retMsg = "对不起,系统错误,请联系系统管理员!";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ result.put("code", retCode);
|
|
|
+ result.put("msg", retMsg);
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+}
|