|
@@ -4,11 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageHelper;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.github.pagehelper.PageInfo;
|
|
import com.hssx.cloudmodel.constant.Constant;
|
|
import com.hssx.cloudmodel.constant.Constant;
|
|
-import com.hssx.cloudmodel.entity.Company;
|
|
|
|
-import com.hssx.cloudmodel.entity.User;
|
|
|
|
|
|
+import com.hssx.cloudmodel.entity.*;
|
|
import com.hssx.cloudmodel.entity.vo.UserVO;
|
|
import com.hssx.cloudmodel.entity.vo.UserVO;
|
|
-import com.hssx.cloudmodel.mapper.CompanyMapper;
|
|
|
|
-import com.hssx.cloudmodel.mapper.UserMapper;
|
|
|
|
|
|
+import com.hssx.cloudmodel.mapper.*;
|
|
import com.hssx.cloudmodel.service.UserService;
|
|
import com.hssx.cloudmodel.service.UserService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
@@ -35,6 +33,12 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
UserMapper userMapper;
|
|
UserMapper userMapper;
|
|
@Autowired
|
|
@Autowired
|
|
CompanyMapper companyMapper;
|
|
CompanyMapper companyMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ UserCompanyMapper userCompanyMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ ProjectUserMapper projectUserMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ ProjectMapper projectMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg login(User user, HttpServletRequest request) {
|
|
public HttpRespMsg login(User user, HttpServletRequest request) {
|
|
@@ -64,14 +68,42 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
public HttpRespMsg pageList(PageUtil page, Integer companyId, Integer flag, String keyName, User user, Integer roleType) {
|
|
public HttpRespMsg pageList(PageUtil page, Integer companyId, Integer flag, String keyName, User user, Integer roleType) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
PageHelper.startPage(page.getPageNum(), page.getPageSize());
|
|
- List<UserVO> users = userMapper.selectListByCondition(roleType,companyId,flag, user, keyName);
|
|
|
|
|
|
+ List<UserVO> users = userMapper.selectListByCondition(roleType, companyId, flag, user, keyName);
|
|
PageInfo<UserVO> pageInfos = new PageInfo<>(users);
|
|
PageInfo<UserVO> pageInfos = new PageInfo<>(users);
|
|
msg.data = pageInfos;
|
|
msg.data = pageInfos;
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg deleteUser(User user) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ QueryWrapper<ProjectUser> qw = new QueryWrapper<>();
|
|
|
|
+ qw.eq("user_id", user.getId());
|
|
|
|
+ //普通用户应用到项目不能删除
|
|
|
|
+ Integer count = projectUserMapper.selectCount(qw);
|
|
|
|
+ if (count > 0) {
|
|
|
|
+ msg.setError("该用户已被应用到项目,暂不提供删除操作");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ //是项目经理不能删除
|
|
|
|
+ Integer countProject = projectMapper.selectCount(new QueryWrapper<Project>().eq("manager_id", user.getId()));
|
|
|
|
+ if(countProject>0){
|
|
|
|
+ msg.setError("该用户已被应用到项目,暂不提供删除操作");
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+ //删除用户
|
|
|
|
+ userMapper.deleteById(user.getId());
|
|
|
|
+ //删除合作的公司
|
|
|
|
+ userCompanyMapper.delete(new QueryWrapper<UserCompany>().eq("user_id",user.getId()));
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public HttpRespMsg addAndUpdateUser(User user, Integer flag) {
|
|
public HttpRespMsg addAndUpdateUser(User user, Integer flag) {
|
|
|
|
+ //获取该账号的创建者
|
|
|
|
+ User parentUser = userMapper.selectById(user.getParentId());
|
|
|
|
+ //获取admin的用户信息
|
|
|
|
+ User proParentUser = userMapper.selectById(parentUser.getParentId());
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
if (flag == 0) {
|
|
if (flag == 0) {
|
|
//添加角色
|
|
//添加角色
|
|
@@ -79,21 +111,40 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
|
|
qw.eq("account", user.getAccount());
|
|
qw.eq("account", user.getAccount());
|
|
int count = userMapper.selectCount(qw);
|
|
int count = userMapper.selectCount(qw);
|
|
if (count > 0) {
|
|
if (count > 0) {
|
|
- msg.setError("账号已存在,请输入其他账号");
|
|
|
|
|
|
+ User existingUser = userMapper.selectOne(qw);
|
|
|
|
+ //此时用户已经有了,则建立一条合作公司的关系
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(existingUser.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(existingUser.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(proParentUser.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
//创建账号默认密码"000000"
|
|
//创建账号默认密码"000000"
|
|
user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
user.setPassword(MD5Util.getPassword(Constant.DEFAULT_PWD));
|
|
user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
user.setHeadImgurl(UUID.randomUUID().toString().replaceAll("-", ""));
|
|
//获取角色所属的团体
|
|
//获取角色所属的团体
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
Company company = companyMapper.selectById(user.getCompanyId());
|
|
- if(Constant.ASSETS_COMPANY == company.getCompanyType()){
|
|
|
|
- user.setSubordinateType(Constant.ASSETS_COMPANY );
|
|
|
|
|
|
+ if (Constant.ASSETS_COMPANY == company.getCompanyType()) {
|
|
|
|
+ user.setSubordinateType(Constant.ASSETS_COMPANY);
|
|
user.setTeamName("资产方");
|
|
user.setTeamName("资产方");
|
|
- }else if(Constant.PRODUCER_COMPANY == company.getCompanyType()){
|
|
|
|
|
|
+ } else if (Constant.PRODUCER_COMPANY == company.getCompanyType()) {
|
|
user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
user.setSubordinateType(Constant.PRODUCER_COMPANY);
|
|
user.setTeamName("生产方");
|
|
user.setTeamName("生产方");
|
|
}
|
|
}
|
|
userMapper.insert(user);
|
|
userMapper.insert(user);
|
|
|
|
+ UserCompany userCompany = new UserCompany();
|
|
|
|
+ userCompany.setUserId(user.getId());
|
|
|
|
+ userCompany.setBelongCompanyId(user.getCompanyId());
|
|
|
|
+ userCompany.setCooperationCompanyId(proParentUser.getCompanyId());
|
|
|
|
+ QueryWrapper<UserCompany> qWra = new QueryWrapper<>(userCompany);
|
|
|
|
+ int userCompanyCount = userCompanyMapper.selectCount(qWra);
|
|
|
|
+ if (count == 0) {
|
|
|
|
+ userCompanyMapper.insert(userCompany);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else if (flag == 1) {
|
|
} else if (flag == 1) {
|
|
//更新角色信息
|
|
//更新角色信息
|