|
|
@@ -31,11 +31,14 @@ import com.ydtech.utils.excel.ExcelUtils2;
|
|
|
import com.ydtech.utils.idgen.IdGenerate;
|
|
|
import io.swagger.annotations.*;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
@@ -368,6 +371,14 @@ public class SysUserController extends BaseController {
|
|
|
// return HttpResult.ok(sysUserService.selectByDeptId(deptId));
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 根据部门id查询该部门的推荐人信息
|
|
|
+ */
|
|
|
+ @GetMapping("/selectfindByreferrerId")
|
|
|
+ public HttpResult findByreferrerId(@Valid String deptId) {
|
|
|
+ return HttpResult.ok(sysUserService.findByreferrerId(deptId));
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// /**
|
|
|
// * 审批
|
|
|
@@ -404,8 +415,13 @@ public class SysUserController extends BaseController {
|
|
|
@Transactional
|
|
|
public HttpResult saveOrUpdate(@RequestBody SysUser sysUser) {
|
|
|
|
|
|
- if (StringUtils.isNullOrEmpty(sysUser.getMobile())) return HttpResult.error("手机不能为空");
|
|
|
- if (StringUtils.isNullOrEmpty(sysUser.getDeptId())) return HttpResult.error("机构ID不能为空");
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser.getMobile())) {
|
|
|
+ return HttpResult.error("手机不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNullOrEmpty(sysUser.getDeptId())) {
|
|
|
+ return HttpResult.error("机构ID不能为空");
|
|
|
+ }
|
|
|
|
|
|
//处理密码
|
|
|
if (StringUtils.isNotEmpty(sysUser.getPassword())) {
|
|
|
@@ -414,6 +430,7 @@ public class SysUserController extends BaseController {
|
|
|
sysUser.setPassword(pwd);
|
|
|
sysUser.setSalt(salt);
|
|
|
}
|
|
|
+
|
|
|
sysUserService.saveUser(sysUser);
|
|
|
|
|
|
return HttpResult.ok(sysUser);
|
|
|
@@ -482,9 +499,20 @@ public class SysUserController extends BaseController {
|
|
|
})
|
|
|
@GetMapping(value = "/{userId}")
|
|
|
public HttpResult findUserById(@PathVariable String userId) {
|
|
|
+ // 查询用户
|
|
|
SysUser sysUser = sysUserService.getById(userId);
|
|
|
+ // 查询角色
|
|
|
SysUserRole sysUserRole = sysUserRoleService.selectByUserId(userId);
|
|
|
sysUser.setRoleId(StringUtils.toString(sysUserRole.getRoleId()));
|
|
|
+ // 查询推荐人
|
|
|
+ EsmUserReferrer referrer = esmUserReferrerService.getById(userId);
|
|
|
+ if (ObjectUtils.isEmpty(referrer)) {
|
|
|
+ sysUser.setReferrerId(null);
|
|
|
+ sysUser.setReferrerName(null);
|
|
|
+ } else {
|
|
|
+ sysUser.setReferrerId(referrer.getReferrerId());
|
|
|
+ sysUser.setReferrerName(referrer.getReferrerName());
|
|
|
+ }
|
|
|
return HttpResult.ok(sysUser);
|
|
|
|
|
|
}
|
|
|
@@ -509,7 +537,6 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 个代注册
|
|
|
*
|
|
|
@@ -549,7 +576,7 @@ public class SysUserController extends BaseController {
|
|
|
SysUser sysUser = sysUserService.findByPhone(dto.getMobile());
|
|
|
if (sysUser != null) {
|
|
|
return HttpResult.error("手机号已存在");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
sysUser = new SysUser();
|
|
|
}
|
|
|
String nextPK = "001";
|
|
|
@@ -591,7 +618,7 @@ public class SysUserController extends BaseController {
|
|
|
eur.setReferrerId(dto.getReferrerId());
|
|
|
if (null != referrer) {
|
|
|
eur.setLevel(referrer.getLevel() + 1);
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
eur.setLevel(1);
|
|
|
}
|
|
|
esmUserReferrerService.save(eur);
|
|
|
@@ -600,25 +627,23 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
@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")
|
|
|
+ @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("机构部门不存在");
|
|
|
+ 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 ->{
|
|
|
+ userList.stream().forEach(a -> {
|
|
|
|
|
|
if (StringUtils.isNullOrEmpty(a.getMobile())) throw new SystemException("手机不能为空");
|
|
|
//处理密码
|
|
|
@@ -633,27 +658,27 @@ public class SysUserController extends BaseController {
|
|
|
|
|
|
//获取角色
|
|
|
LambdaQueryWrapper<SysRole> lqwRole = new LambdaQueryWrapper<>();
|
|
|
- lqwRole.like(SysRole::getName,a.getRoleName());
|
|
|
+ lqwRole.like(SysRole::getName, a.getRoleName());
|
|
|
SysRole sr = sysRoleService.getOne(lqwRole);
|
|
|
a.setRoleId(sr.getId().toString());
|
|
|
a.setRoleName(sr.getName());
|
|
|
|
|
|
//状态
|
|
|
- if(a.getExcelStatus().equals("正常")){
|
|
|
+ if (a.getExcelStatus().equals("正常")) {
|
|
|
a.setStatus(1);
|
|
|
}
|
|
|
- if(a.getExcelStatus().equals("新注册")){
|
|
|
+ if (a.getExcelStatus().equals("新注册")) {
|
|
|
a.setStatus(2);
|
|
|
}
|
|
|
|
|
|
//性别
|
|
|
- if(a.getSex().equals("未知")){
|
|
|
+ if (a.getSex().equals("未知")) {
|
|
|
a.setSex("U");
|
|
|
}
|
|
|
- if(a.getSex().equals("男")){
|
|
|
+ if (a.getSex().equals("男")) {
|
|
|
a.setSex("M");
|
|
|
}
|
|
|
- if(a.getSex().equals("女")){
|
|
|
+ if (a.getSex().equals("女")) {
|
|
|
a.setSex("W");
|
|
|
}
|
|
|
|
|
|
@@ -669,14 +694,10 @@ public class SysUserController extends BaseController {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
return HttpResult.ok("导入成功");
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* ==================用户详情=================
|
|
|
*/
|