|
|
@@ -17,6 +17,7 @@ import org.springblade.core.boot.ctrl.BladeController;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.utils.DigestUtil;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
+import org.springblade.modules.baseinfo.user.dto.OpenUserDTO;
|
|
|
import org.springblade.modules.baseinfo.user.entity.OpenUserEntity;
|
|
|
import org.springblade.modules.baseinfo.user.service.IOpenUserService;
|
|
|
import org.springblade.modules.system.entity.Dept;
|
|
|
@@ -47,42 +48,41 @@ import java.util.List;
|
|
|
@AllArgsConstructor
|
|
|
@Api(value = "开放用户人员接口", tags = "开放用户人员模块管理")
|
|
|
public class OpenUserController extends BladeController {
|
|
|
- private final IUserService userService;
|
|
|
- private final IDeptService deptService;
|
|
|
- private final IUserDeptService userDeptService;
|
|
|
- private final IRegionService regionService;
|
|
|
- private final IOpenUserService openUserService;
|
|
|
-
|
|
|
- /**
|
|
|
- * 注册
|
|
|
- */
|
|
|
- @PostMapping("/reg")
|
|
|
- @ApiOperationSupport(order = 4)
|
|
|
- @ApiOperation(value = "注册", notes = "传入 OpenUserEntity")
|
|
|
- @Transactional
|
|
|
- public R openUserReg(@RequestBody OpenUserEntity openUserEntity) {
|
|
|
- try {
|
|
|
- if (openUserEntity.getCompanyName()==null){
|
|
|
- return R.fail("公司名称不能为空");
|
|
|
- }
|
|
|
- if (openUserEntity.getPersonName()==null){
|
|
|
- return R.fail("性名不能为空");
|
|
|
- }
|
|
|
- if (openUserEntity.getMail()==null){
|
|
|
- return R.fail("邮箱不能为空");
|
|
|
- }
|
|
|
- if (openUserEntity.getContactPhone()==null){
|
|
|
- return R.fail("联系手机不能为空");
|
|
|
- }
|
|
|
- LambdaQueryWrapper<OpenUserEntity> openUserWrapper = Wrappers.<OpenUserEntity>query().lambda();
|
|
|
- openUserWrapper.eq(OpenUserEntity::getContactPhone, openUserEntity.getContactPhone());
|
|
|
- openUserWrapper.eq(OpenUserEntity::getIsDeleted, 0);
|
|
|
- openUserWrapper.eq(OpenUserEntity::getApproveStatus,0).or().eq(OpenUserEntity::getApproveStatus,1);
|
|
|
-
|
|
|
- List<OpenUserEntity> openUserEntityList = openUserService.list(openUserWrapper);
|
|
|
- if (openUserEntityList != null && openUserEntityList.size()>0){
|
|
|
- return R.fail("请勿重复进行申请");
|
|
|
- }
|
|
|
+ private final IUserService userService;
|
|
|
+ private final IDeptService deptService;
|
|
|
+ private final IUserDeptService userDeptService;
|
|
|
+ private final IRegionService regionService;
|
|
|
+ private final IOpenUserService openUserService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 注册
|
|
|
+ */
|
|
|
+ @PostMapping("/reg")
|
|
|
+ @ApiOperationSupport(order = 4)
|
|
|
+ @ApiOperation(value = "注册", notes = "传入 OpenUserEntity")
|
|
|
+ @Transactional
|
|
|
+ public R openUserReg(OpenUserDTO openUserEntity) {
|
|
|
+ try {
|
|
|
+ if (openUserEntity.getTenantId() == null) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (openUserEntity.getUsername() == null) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+ if (openUserEntity.getPassword() == null) {
|
|
|
+ return R.fail("参数错误");
|
|
|
+ }
|
|
|
+
|
|
|
+// LambdaQueryWrapper<OpenUserEntity> openUserWrapper = Wrappers.<OpenUserEntity>query().lambda();
|
|
|
+// openUserWrapper.eq(OpenUserEntity::getAccount, openUserEntity.getUsername());
|
|
|
+// openUserWrapper.eq(OpenUserEntity::getIsDeleted, 0);
|
|
|
+// openUserWrapper.last("limit 1");
|
|
|
+// openUserWrapper.eq(OpenUserEntity::getApproveStatus,0).or().eq(OpenUserEntity::getApproveStatus,1);
|
|
|
+
|
|
|
+// OpenUserEntity detail = openUserService.getOne(openUserWrapper);
|
|
|
+// if (Func.notNull(detail)) {
|
|
|
+// return R.fail("帐号已存在");
|
|
|
+// }
|
|
|
|
|
|
// String account;
|
|
|
// if (openUserEntity.getUserAccount()!=null){
|
|
|
@@ -90,52 +90,53 @@ public class OpenUserController extends BladeController {
|
|
|
// }else{
|
|
|
// account=openUserEntity.getContactPhone();
|
|
|
// }
|
|
|
- LambdaQueryWrapper<User> wrapper = Wrappers.<User>query().lambda();
|
|
|
- wrapper.eq(User::getAccount, openUserEntity.getContactPhone());
|
|
|
- wrapper.eq(User::getIsDeleted, 0);
|
|
|
- List<User> userList = userService.list(wrapper);
|
|
|
- if (null != userList && userList.size() > 0) {
|
|
|
- return R.fail("帐号已经存在,请更换一个手机号进行申请");
|
|
|
- }
|
|
|
-
|
|
|
- openUserEntity.setApproveStatus(0);
|
|
|
-
|
|
|
- openUserService.save(openUserEntity);
|
|
|
-
|
|
|
-
|
|
|
+ LambdaQueryWrapper<User> wrapper = Wrappers.<User>query().lambda();
|
|
|
+ wrapper.eq(User::getTenantId, openUserEntity.getTenantId());
|
|
|
+ wrapper.eq(User::getAccount, openUserEntity.getUsername());
|
|
|
+ wrapper.eq(User::getIsDeleted, 0);
|
|
|
+ wrapper.last("limit 1");
|
|
|
+ User user = userService.getOne(wrapper);
|
|
|
+ if (Func.notNull(user)) {
|
|
|
+ return R.fail("帐号已存在");
|
|
|
+ }
|
|
|
+ openUserEntity.setApproveStatus(1);
|
|
|
+ openUserService.save(openUserEntity);
|
|
|
|
|
|
|
|
|
// if (null == openUserEntity.getRegionCode()){
|
|
|
// return R.fail("所在区划参数不能为空");
|
|
|
// }
|
|
|
- //创建组织机构
|
|
|
- Dept parentDept = deptService.getById(BusinessConstant.DEPT_DH_ID);
|
|
|
- Dept dept = new Dept();
|
|
|
- dept.setParentId(BusinessConstant.DEPT_DH_ID);
|
|
|
- dept.setDeptCategory(1);
|
|
|
- dept.setDeptName(openUserEntity.getCompanyName());
|
|
|
- dept.setFullName(openUserEntity.getCompanyName());
|
|
|
- dept.setAncestors(parentDept.getAncestors()+","+parentDept.getId());
|
|
|
- dept.setSort(1);
|
|
|
- deptService.save(dept);
|
|
|
+ //创建组织机构
|
|
|
+ Dept parentDept = deptService.getById(BusinessConstant.DEPT_DH_ID);
|
|
|
+ Dept dept = new Dept();
|
|
|
+ dept.setTenantId(openUserEntity.getTenantId());
|
|
|
+ dept.setParentId(BusinessConstant.DEPT_DH_ID);
|
|
|
+ dept.setDeptCategory(1);
|
|
|
+// dept.setDeptName(openUserEntity.getCompanyName());
|
|
|
+// dept.setFullName(openUserEntity.getCompanyName());
|
|
|
+ dept.setAncestors(parentDept.getAncestors() + "," + parentDept.getId());
|
|
|
+ dept.setSort(1);
|
|
|
+ deptService.save(dept);
|
|
|
//创建用户
|
|
|
- User u = new User();
|
|
|
- u.setAccount(openUserEntity.getContactPhone());
|
|
|
- u.setPhone(openUserEntity.getContactPhone());
|
|
|
- u.setEmail(openUserEntity.getMail());
|
|
|
- u.setName(openUserEntity.getPersonName());
|
|
|
- u.setRealName(openUserEntity.getPersonName());
|
|
|
- u.setPassword(DigestUtil.encrypt(openUserEntity.getContactPhone() + BusinessConstant.ACCOUNT_PW_SUFFIX));
|
|
|
- u.setDeptId(Func.toStr(dept.getId()));
|
|
|
- u.setRoleId(BusinessConstant.ROLE_ORG_ADMIN_ID);
|
|
|
- u.setPostId(BusinessConstant.POST_ORG_ADMIN_ID);
|
|
|
- u.setUserType(1);
|
|
|
- userService.save(u);
|
|
|
+ User u = new User();
|
|
|
+ u.setTenantId(openUserEntity.getTenantId());
|
|
|
+ u.setAccount(openUserEntity.getUsername());
|
|
|
+ u.setPhone(openUserEntity.getUsername());
|
|
|
+// u.setEmail(openUserEntity.getMail());
|
|
|
+ u.setName(openUserEntity.getUsername());
|
|
|
+ u.setRealName(openUserEntity.getUsername());
|
|
|
+// u.setPassword(DigestUtil.encrypt(openUserEntity.getContactPhone() + BusinessConstant.ACCOUNT_PW_SUFFIX));
|
|
|
+ u.setPassword(DigestUtil.hex(openUserEntity.getPassword()));
|
|
|
+ u.setDeptId(Func.toStr(dept.getId()));
|
|
|
+ u.setRoleId(BusinessConstant.ROLE_ORG_ADMIN_ID);
|
|
|
+ u.setPostId(BusinessConstant.POST_ORG_ADMIN_ID);
|
|
|
+ u.setUserType(2);
|
|
|
+ userService.save(u);
|
|
|
//创建关联关系
|
|
|
- UserDept userDept=new UserDept();
|
|
|
- userDept.setUserId(u.getId());
|
|
|
- userDept.setDeptId(dept.getId());
|
|
|
- userDeptService.save(userDept);
|
|
|
+ UserDept userDept = new UserDept();
|
|
|
+ userDept.setUserId(u.getId());
|
|
|
+ userDept.setDeptId(dept.getId());
|
|
|
+ userDeptService.save(userDept);
|
|
|
// //创建组织机构
|
|
|
// LambdaQueryWrapper<Region> regionQueryWrapper = Wrappers.<Region>query().lambda();
|
|
|
// regionQueryWrapper.eq(Region::getCode,openUserEntity.getRegionCode());
|
|
|
@@ -201,12 +202,12 @@ public class OpenUserController extends BladeController {
|
|
|
// mailText += "</div>";
|
|
|
// MailHelp.sendMail(toMail, title, mailText);
|
|
|
|
|
|
- return R.success("帐号申请已注册成功");
|
|
|
+ return R.success("已注册成功");
|
|
|
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- throw new RuntimeException("注册失败");
|
|
|
- }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ throw new RuntimeException("注册失败");
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
}
|