|
|
@@ -150,17 +150,13 @@ public class SysUserController extends BaseController {
|
|
|
@Transactional
|
|
|
public HttpResult saveUserRole(@RequestParam String userId, @RequestParam String roleId) {
|
|
|
SysUserRole userRole = new SysUserRole();
|
|
|
-// List<SysUserRole> list = sysUserRoleService.selectList(" where user_id=?", new Object[]{userId});
|
|
|
-
|
|
|
sysUserRoleService.deleteByUserId(userId);
|
|
|
-
|
|
|
userRole = new SysUserRole();
|
|
|
userRole.setUserId(userId);
|
|
|
userRole.setRoleId(Long.parseLong(roleId));
|
|
|
userRole.setCreateBy(getUserName());
|
|
|
userRole.setCreateTime(new Date());
|
|
|
sysUserRoleService.save(userRole);
|
|
|
-
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -184,12 +180,9 @@ public class SysUserController extends BaseController {
|
|
|
@PostMapping(value = "/findPageUsed")
|
|
|
@Deprecated
|
|
|
public HttpResult findPageUsed(@RequestBody PageRequest pageRequest) {
|
|
|
- //return HttpResult.ok(sysUserService.findPage(pageRequest));
|
|
|
-
|
|
|
int pageNum = pageRequest.getPageNum();
|
|
|
int pageSize = pageRequest.getPageSize();
|
|
|
String name = pageRequest.getColumnFilterValue(pageRequest, "name");
|
|
|
-// String email = pageRequest.getColumnFilterValue(pageRequest, "email");
|
|
|
//需要处理传入的部门
|
|
|
PageResult pageResult = sysUserService.selectPagingCustom(pageNum, pageSize, name, "");
|
|
|
sysUserService.findSysUseresmUserInternalVORoles(pageResult);
|
|
|
@@ -213,7 +206,6 @@ public class SysUserController extends BaseController {
|
|
|
return HttpResult.error("ID不存在");
|
|
|
}
|
|
|
//密码加密
|
|
|
- String salt = PasswordUtils.getSalt();
|
|
|
String pwd = PasswordUtils.encode(password, sysUser.getSalt());
|
|
|
sysUser.setPassword(pwd);
|
|
|
sysUserService.updateById(sysUser);
|
|
|
@@ -242,8 +234,7 @@ public class SysUserController extends BaseController {
|
|
|
lqw.eq(SysUser::getMobile, mobile);
|
|
|
|
|
|
List<SysUser> users = sysUserService.list(lqw);
|
|
|
-// List<SysUser> users = sysUserService.selectList(" where id != ? and mobile=?", new Object[]{id, mobile});
|
|
|
- if (users != null && users.size() > 0) {
|
|
|
+ if (users != null && !users.isEmpty()) {
|
|
|
return HttpResult.error("手机号已存在");
|
|
|
}
|
|
|
|
|
|
@@ -260,11 +251,7 @@ public class SysUserController extends BaseController {
|
|
|
*/
|
|
|
@GetMapping(value = "/findById")
|
|
|
public HttpResult findByUserId(@RequestParam String id) {
|
|
|
- SysUser sysUser = sysUserService.getById(id);
|
|
|
- SysUserVO sysUserVO = new SysUserVO();
|
|
|
-
|
|
|
- sysUserVO = sysUserService.gainUserInternal(id);
|
|
|
-// SysUserVO sysUserVO = sysUserService.selectById(id);
|
|
|
+ SysUserVO sysUserVO = sysUserService.gainUserInternal(id);
|
|
|
if (sysUserVO != null) {
|
|
|
return HttpResult.ok(sysUserVO);
|
|
|
}
|
|
|
@@ -280,7 +267,6 @@ public class SysUserController extends BaseController {
|
|
|
@GetMapping(value = "/selectByDeptId")
|
|
|
public HttpResult selectByDeptId(String deptId) {
|
|
|
return HttpResult.ok(sysUserService.gainUserInternalByDeptId(deptId));
|
|
|
-// return HttpResult.ok(sysUserService.selectByDeptId(deptId));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -292,31 +278,6 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-// /**
|
|
|
-// * 审批
|
|
|
-// *
|
|
|
-// * @param userId
|
|
|
-// * @param status 审批
|
|
|
-// * @return
|
|
|
-// */
|
|
|
-// @ApiOperation(value = "审批")
|
|
|
-// @ApiImplicitParams({
|
|
|
-// @ApiImplicitParam(name = "userId", value = "用户ID")
|
|
|
-// , @ApiImplicitParam(name = "status", value = "审批状态")
|
|
|
-// })
|
|
|
-// @GetMapping(value = "/approval")
|
|
|
-// public HttpResult approval(@RequestParam String userId, @RequestParam String status) {
|
|
|
-//
|
|
|
-// LambdaUpdateWrapper<SysUser> luw = new LambdaUpdateWrapper();
|
|
|
-// luw.eq(SysUser::getId, userId);
|
|
|
-// luw.set(SysUser::getApprovalStatus, status);
|
|
|
-//
|
|
|
-// return HttpResult.ok(sysUserService.update(luw));
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- //======================== 重构新接口
|
|
|
|
|
|
/**
|
|
|
* @author: lig
|
|
|
@@ -344,16 +305,14 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
sysUserService.saveUser(sysUser);
|
|
|
-
|
|
|
return HttpResult.ok(sysUser);
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@ApiOperation(value = "(重构)逻辑删除")
|
|
|
@PostMapping(value = "/logicDeleteBatch")
|
|
|
public HttpResult logicDeleteBatch(@RequestBody List<String> userIds) {
|
|
|
- if (null != userIds && userIds.size() > 0) {
|
|
|
+ if (null != userIds && !userIds.isEmpty()) {
|
|
|
LambdaUpdateWrapper<SysUser> luw = new LambdaUpdateWrapper<>();
|
|
|
luw.set(SysUser::getStatus, "0");
|
|
|
luw.in(SysUser::getId, userIds);
|
|
|
@@ -362,7 +321,6 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
return HttpResult.error("请正确选择参数");
|
|
|
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -627,114 +585,6 @@ public class SysUserController extends BaseController {
|
|
|
return HttpResult.ok("保存成功", sysUser.getId());
|
|
|
}
|
|
|
|
|
|
- @PostMapping(value = "/newUserImport")
|
|
|
- @ApiOperation(value = "新用户导入")
|
|
|
- @ApiImplicitParams({
|
|
|
- @ApiImplicitParam(name = "file", value = "excel文件", required = true, dataType = "__file"),
|
|
|
- @ApiImplicitParam(name = "deptId", value = "机构部门ID", required = true, dataType = "String", paramType = "formData")
|
|
|
- })
|
|
|
- @Transactional
|
|
|
- public HttpResult newUserImport(@RequestPart MultipartFile file, @RequestParam String deptId) {
|
|
|
-
|
|
|
- SysDept sd = sysDeptService.getById(deptId);
|
|
|
- if (null == sd) return HttpResult.error("机构部门不存在");
|
|
|
-
|
|
|
- try {
|
|
|
- List<SysUser> userList = ExcelEasypoiUtils.importExcel(file, SysUser.class, 0, 1, 1);
|
|
|
- userList = userList.stream().filter(l -> StringUtils.isNotEmpty(l.getMobile())).collect(Collectors.toList());
|
|
|
-
|
|
|
- userList.stream().forEach(a -> {
|
|
|
-
|
|
|
- if (StringUtils.isNullOrEmpty(a.getMobile())) throw new SystemException("手机不能为空");
|
|
|
- //处理密码
|
|
|
- if (StringUtils.isNotEmpty(a.getPassword())) {
|
|
|
- String salt = PasswordUtils.getSalt();
|
|
|
- String pwd = PasswordUtils.encode(a.getPassword(), salt);
|
|
|
- a.setPassword(pwd);
|
|
|
- a.setSalt(salt);
|
|
|
- }
|
|
|
- a.setDeptId(sd.getId());
|
|
|
- a.setDeptName(sd.getName());
|
|
|
-
|
|
|
- //获取角色
|
|
|
- LambdaQueryWrapper<SysRole> lqwRole = new LambdaQueryWrapper<>();
|
|
|
- lqwRole.like(SysRole::getName, a.getRoleName());
|
|
|
- SysRole sr = sysRoleService.getOne(lqwRole);
|
|
|
- a.setRoleId(sr.getId().toString());
|
|
|
- a.setRoleName(sr.getName());
|
|
|
-
|
|
|
- //状态
|
|
|
- if (a.getExcelStatus().equals("正常")) {
|
|
|
- a.setStatus(1);
|
|
|
- }
|
|
|
- if (a.getExcelStatus().equals("新注册")) {
|
|
|
- a.setStatus(2);
|
|
|
- }
|
|
|
-
|
|
|
-// //性别
|
|
|
-// if (a.getSex().equals("未知")) {
|
|
|
-// a.setSex("U");
|
|
|
-// }
|
|
|
-// if (a.getSex().equals("男")) {
|
|
|
-// a.setSex("M");
|
|
|
-// }
|
|
|
-// if (a.getSex().equals("女")) {
|
|
|
-// a.setSex("W");
|
|
|
-// }
|
|
|
-
|
|
|
-
|
|
|
- if (StringUtils.isNullOrEmpty(a.getDeptId())) throw new SystemException("机构ID不能为空");
|
|
|
- //by gws 21 团队长 20 代理人 必须归属团队
|
|
|
- // 22 后线人员 必须归属部门
|
|
|
- if (StringUtils.isNullOrEmpty(a.getRoleId())) throw new SystemException("角色ID不能为空");
|
|
|
- if ("21".equals(a.getRoleId()) || "20".equals(a.getRoleId())) {//21 团队长 20 代理人
|
|
|
- boolean teamflag = false;
|
|
|
- char[] deptids = a.getDeptId().toCharArray();
|
|
|
- char ch1 = 'D';
|
|
|
- char ch2 = 'M';
|
|
|
- if (deptids.length > 6) {
|
|
|
- teamflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] == ch2;
|
|
|
- }
|
|
|
- if (!teamflag) {
|
|
|
- throw new SystemException("团队长和代理人只能归属团队中");
|
|
|
- }
|
|
|
- } else if ("22".equals(a.getRoleId())) {//22 后线人员
|
|
|
- boolean deptflag = false;
|
|
|
- char[] deptids = a.getDeptId().toCharArray();
|
|
|
- char ch1 = 'D';
|
|
|
- char ch2 = 'M';
|
|
|
- if (deptids.length > 6) {
|
|
|
- deptflag = deptids[deptids.length - 3] == ch1 && deptids[deptids.length - 6] != ch2;
|
|
|
- } else if (deptids.length <= 6 && deptids.length > 3) {
|
|
|
- deptflag = deptids[deptids.length - 3] == ch1;
|
|
|
- }
|
|
|
- if (!deptflag) {
|
|
|
- throw new SystemException("后线人员只能归属业务部门中");
|
|
|
- }
|
|
|
- } else {
|
|
|
- throw new SystemException("角色id有误");
|
|
|
- }
|
|
|
- sysUserService.saveUser(a);
|
|
|
-
|
|
|
- });
|
|
|
-
|
|
|
- } catch (IOException e) {
|
|
|
- throw new SystemException(e.getMessage());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- return HttpResult.ok("导入成功");
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-// @ApiOperation(value = "保存或更新用户信息")
|
|
|
-// @PostMapping(value = "/saveOrUpdateInfo")
|
|
|
-// public HttpResult saveOrUpdateInfo(@RequestBody SysUserInfo sysUserInfo) {
|
|
|
-// if (StringUtils.isNullOrEmpty(sysUserInfo.getId())) return HttpResult.error("用户ID不能为空");
|
|
|
-// return HttpResult.ok(sysUserInfoService.saveOrUpdate(sysUserInfo));
|
|
|
-//
|
|
|
-// }
|
|
|
-
|
|
|
|
|
|
@GetMapping(value = "/findUserInfo/{userId}")
|
|
|
@ApiOperation(value = "获取用户信息")
|
|
|
@@ -771,12 +621,7 @@ public class SysUserController extends BaseController {
|
|
|
if (deptLevel != 6) {
|
|
|
throw new SystemException("团队长、代理人、出单员只能归属团队中");
|
|
|
}
|
|
|
- } else if (RoleConstants.R22.getCode().equals(sysUser.getRoleId())) {//22 后线人员
|
|
|
-
|
|
|
- if (deptLevel != 5) {
|
|
|
- throw new SystemException("后线人员只能归属业务部门中");
|
|
|
- }
|
|
|
- } else if (RoleConstants.R18.getCode().equals(sysUser.getRoleId())) { // 42 门店长
|
|
|
+ }else if (RoleConstants.R18.getCode().equals(sysUser.getRoleId())) { // 42 门店长
|
|
|
if (deptLevel != 5) {
|
|
|
throw new SystemException("机构管理员只能归属机构中");
|
|
|
}
|