|
@@ -110,56 +110,140 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
//获取该账号的创建者
|
|
//获取该账号的创建者
|
|
User parentUser = userMapper.selectById(user.getParentId());
|
|
User parentUser = userMapper.selectById(user.getParentId());
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
-// if(Constant.SYS_PARENT_ID == parentUser.getParentId()){
|
|
|
|
-// //此时是创建admind,当前创建人是超级管理员
|
|
|
|
-// }else if(){
|
|
|
|
-//
|
|
|
|
-// }
|
|
|
|
- if (flag == 0) {
|
|
|
|
- //添加角色
|
|
|
|
- QueryWrapper<User> qw = new QueryWrapper<>();
|
|
|
|
- qw.eq("account", user.getAccount());
|
|
|
|
- int count = userMapper.selectCount(qw);
|
|
|
|
- if (count > 0) {
|
|
|
|
- User existingUser = userMapper.selectOne(qw);
|
|
|
|
- //此时用户已经有了,则建立一条合作公司的关系
|
|
|
|
- UserCompany userCompany = new UserCompany();
|
|
|
|
- userCompany.setUserId(existingUser.getId());
|
|
|
|
- userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
- userCompany.setCooperationCompanyId(parentUser.getCompanyId());
|
|
|
|
- QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
- int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
- if (count == 0) {
|
|
|
|
- userCompanyMapper.insert(userCompany);
|
|
|
|
|
|
+ if(Constant.SYS_PARENT_ID == parentUser.getParentId()) {
|
|
|
|
+ //此时是创建admind,当前创建人是超级管理员
|
|
|
|
+ int count = userMapper.selectCount(new QueryWrapper<User>().eq("company_id", user.getCompanyId()).eq("parent_id", parentUser.getId()));
|
|
|
|
+ if (flag == 0) {
|
|
|
|
+ if(count>0){
|
|
|
|
+ //所选公司下的admin已存在
|
|
|
|
+ msg.setError("该公司下的管理员已存在");
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
- //创建账号默认密码"000000"
|
|
|
|
- user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
|
|
- user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
- //获取角色所属的团体
|
|
|
|
- Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
|
- if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
|
|
|
|
- user.setSubordinateType(Constant.ASSETS_COMPANY);
|
|
|
|
- user.setTeamName("资产方");
|
|
|
|
- } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
|
|
|
|
- user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
|
|
- user.setTeamName("生产方");
|
|
|
|
|
|
+ //添加用户
|
|
|
|
+ QueryWrapper<User> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("account", user.getAccount());
|
|
|
|
+ count = userMapper.selectCount(qw);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ User existingUser = userMapper.selectOne(qw);
|
|
|
|
+ msg.setError("当前账号已存在");
|
|
|
|
+ return msg;
|
|
|
|
+ } else {
|
|
|
|
+ //创建账号默认密码"000000"
|
|
|
|
+ user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
|
|
+ user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
+ //获取角色所属的团体
|
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
|
+ if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.ASSETS_COMPANY);
|
|
|
|
+ user.setTeamName("资产方");
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
|
|
+ user.setTeamName("生产方");
|
|
|
|
+ }
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ }
|
|
|
|
+ } else if (flag == 1) {
|
|
|
|
+ //更新角色信息
|
|
|
|
+ userMapper.updateById(user);
|
|
|
|
+ }
|
|
|
|
+ }else if(Constant.SYS_ID == parentUser.getParentId()){
|
|
|
|
+ //admin创建用户
|
|
|
|
+ if (flag == 0) {
|
|
|
|
+ //添加用户
|
|
|
|
+ QueryWrapper<User> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("account", user.getAccount());
|
|
|
|
+ int count = userMapper.selectCount(qw);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ User existingUser = userMapper.selectOne(qw);
|
|
|
|
+ //此时用户已经有了,则建立一条合作公司的关系
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(existingUser.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(parentUser.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (userCompanyCount == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //创建账号默认密码"000000"
|
|
|
|
+ user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
|
|
+ user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
+ //获取角色所属的团体
|
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
|
+ if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.ASSETS_COMPANY);
|
|
|
|
+ user.setTeamName("资产方");
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
|
|
+ user.setTeamName("生产方");
|
|
|
|
+ }
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(user.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(user.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(parentUser.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (userCompanyCount == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- userMapper.insert(user);
|
|
|
|
- UserCompany userCompany = new UserCompany();
|
|
|
|
- userCompany.setUserId(user.getId());
|
|
|
|
- userCompany.setBelongCompanyId(user.getCompanyId());
|
|
|
|
- userCompany.setCooperationCompanyId(parentUser.getCompanyId());
|
|
|
|
- QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
- int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
- if (count == 0) {
|
|
|
|
- userCompanyMapper.insert(userCompany);
|
|
|
|
|
|
+ } else if (flag == 1) {
|
|
|
|
+ //更新角色信息
|
|
|
|
+ userMapper.updateById(user);
|
|
|
|
+ }
|
|
|
|
+ }else {
|
|
|
|
+ //此时是项目经理创建人员
|
|
|
|
+ //查询创建该项目经理的人
|
|
|
|
+ User managerParent = userMapper.selectOne(new QueryWrapper<User>().eq("id",parentUser.getParentId()));
|
|
|
|
+ if (flag == 0) {
|
|
|
|
+ //添加用户
|
|
|
|
+ QueryWrapper<User> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("account", user.getAccount());
|
|
|
|
+ int count = userMapper.selectCount(qw);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ User existingUser = userMapper.selectOne(qw);
|
|
|
|
+ //此时用户已经有了,则建立一条合作公司的关系
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(existingUser.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(managerParent.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (userCompanyCount == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //创建账号默认密码"000000"
|
|
|
|
+ user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
|
|
+ user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
|
|
+ //获取角色所属的团体
|
|
|
|
+ Company company = companyMapper.selectById(user.getCompanyId());
|
|
|
|
+ if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.ASSETS_COMPANY);
|
|
|
|
+ user.setTeamName("资产方");
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
|
|
+ user.setTeamName("生产方");
|
|
|
|
+ }
|
|
|
|
+ userMapper.insert(user);
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(user.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(user.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(managerParent.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (userCompanyCount == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ } else if (flag == 1) {
|
|
|
|
+ //更新角色信息
|
|
|
|
+ userMapper.updateById(user);
|
|
}
|
|
}
|
|
- } else if (flag == 1) {
|
|
|
|
- //更新角色信息
|
|
|
|
- userMapper.updateById(user);
|
|
|
|
}
|
|
}
|
|
|
|
+
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|