|
@@ -10,15 +10,13 @@ import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
import com.sckw.system.api.model.dto.req.RegisterReqDto;
|
|
|
import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
|
|
import com.sckw.system.api.model.dto.req.UpdatePasswordReqDto;
|
|
|
import com.sckw.system.api.model.dto.res.RegisterResDto;
|
|
import com.sckw.system.api.model.dto.res.RegisterResDto;
|
|
|
-import com.sckw.system.dao.KwsEntCheckTrackDao;
|
|
|
|
|
-import com.sckw.system.dao.KwsEnterpriseDao;
|
|
|
|
|
-import com.sckw.system.dao.KwsUserDao;
|
|
|
|
|
-import com.sckw.system.dao.KwsUserDeptDao;
|
|
|
|
|
|
|
+import com.sckw.system.dao.*;
|
|
|
import com.sckw.system.model.*;
|
|
import com.sckw.system.model.*;
|
|
|
import com.sckw.system.model.pojo.FindEntListPojo;
|
|
import com.sckw.system.model.pojo.FindEntListPojo;
|
|
|
import com.sckw.system.model.vo.req.*;
|
|
import com.sckw.system.model.vo.req.*;
|
|
|
import com.sckw.system.model.vo.res.KwsUserResVo;
|
|
import com.sckw.system.model.vo.res.KwsUserResVo;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.checkerframework.checker.units.qual.K;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -47,6 +45,9 @@ public class KwsUserService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsRoleService kwsRoleService;
|
|
KwsRoleService kwsRoleService;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ KwsUserRoleDao kwsUserRoleDao;
|
|
|
|
|
+
|
|
|
@Autowired
|
|
@Autowired
|
|
|
KwsDeptService kwsDeptService;
|
|
KwsDeptService kwsDeptService;
|
|
|
|
|
|
|
@@ -66,6 +67,9 @@ public class KwsUserService {
|
|
|
public void add(UserAddReqVo reqVo) {
|
|
public void add(UserAddReqVo reqVo) {
|
|
|
KwsUser kwsUser = new KwsUser();
|
|
KwsUser kwsUser = new KwsUser();
|
|
|
BeanUtils.copyProperties(reqVo, kwsUser);
|
|
BeanUtils.copyProperties(reqVo, kwsUser);
|
|
|
|
|
+ kwsUser.setPhone(kwsUser.getAccount());
|
|
|
|
|
+ kwsUser.setIsMain(Global.NO);
|
|
|
|
|
+ kwsUser.setSystemType(SystemTypeEnum.COMPANY.getCode());
|
|
|
|
|
|
|
|
/*1、数据校验*/
|
|
/*1、数据校验*/
|
|
|
checkAccountValid(kwsUser.getAccount(), kwsUser.getSystemType());
|
|
checkAccountValid(kwsUser.getAccount(), kwsUser.getSystemType());
|
|
@@ -99,7 +103,7 @@ public class KwsUserService {
|
|
|
public RegisterResDto register(RegisterReqDto reqDto) throws SystemException {
|
|
public RegisterResDto register(RegisterReqDto reqDto) throws SystemException {
|
|
|
EntFindPageReqVo entFindPageReqVo = new EntFindPageReqVo();
|
|
EntFindPageReqVo entFindPageReqVo = new EntFindPageReqVo();
|
|
|
entFindPageReqVo.setFirmName(reqDto.getEntName());
|
|
entFindPageReqVo.setFirmName(reqDto.getEntName());
|
|
|
- List<KwsEnterprise > list = kwsEnterpriseDao.findList(entFindPageReqVo);
|
|
|
|
|
|
|
+ List<KwsEnterprise> list = kwsEnterpriseDao.findList(entFindPageReqVo);
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
if (!CollectionUtils.isEmpty(list)) {
|
|
|
throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ENT_EXISTS);
|
|
throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ENT_EXISTS);
|
|
|
}
|
|
}
|
|
@@ -256,7 +260,12 @@ public class KwsUserService {
|
|
|
*
|
|
*
|
|
|
* @param params KwsUser
|
|
* @param params KwsUser
|
|
|
*/
|
|
*/
|
|
|
- public void update(KwsUser params) throws SystemException {
|
|
|
|
|
|
|
+ @Transactional(rollbackFor = {})
|
|
|
|
|
+ public void update(UserAddReqVo params) throws SystemException {
|
|
|
|
|
+ KwsUser kwsUser = kwsUserDao.selectByKey(params.getId());
|
|
|
|
|
+ if (Objects.isNull(kwsUser)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ACCOUNT_NOT_EXISTS);
|
|
|
|
|
+ }
|
|
|
//更换账号后账号唯一性校验
|
|
//更换账号后账号唯一性校验
|
|
|
if (StringUtils.isNotBlank(params.getAccount())) {
|
|
if (StringUtils.isNotBlank(params.getAccount())) {
|
|
|
//用户信息
|
|
//用户信息
|
|
@@ -265,10 +274,36 @@ public class KwsUserService {
|
|
|
throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_EXISTS);
|
|
throw new SystemException(HttpStatus.PARAMETERS_MISSING_CODE, HttpStatus.ACCOUNT_EXISTS);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
- //更新用户信息
|
|
|
|
|
- if (kwsUserDao.update(params) <= 0) {
|
|
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //以前的关联数据先删除再新增
|
|
|
|
|
+ List<KwsUserDept> kwsUserDepts = kwsUserDeptDao.findAllByUserId(params.getId());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(kwsUserDepts)) {
|
|
|
|
|
+ for (KwsUserDept kwsUserDept : kwsUserDepts) {
|
|
|
|
|
+ kwsUserDept.setDelFlag(Global.YES);
|
|
|
|
|
+ if (kwsUserDeptDao.update(kwsUserDept) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ List<KwsUserRole> kwsUserRoles = kwsUserRoleDao.findAllByUserId(params.getId());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(kwsUserRoles)) {
|
|
|
|
|
+ for (KwsUserRole kwsUserRole : kwsUserRoles) {
|
|
|
|
|
+ kwsUserRole.setDelFlag(Global.YES);
|
|
|
|
|
+ if (kwsUserRoleDao.update(kwsUserRole) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ kwsUser.setName(params.getName());
|
|
|
|
|
+ kwsUserDao.update(kwsUser);
|
|
|
|
|
+
|
|
|
|
|
+ /*填充用户角色*/
|
|
|
|
|
+ fillUserRole(params.getRoleIds(), kwsUser.getId(), kwsUser.getSystemType());
|
|
|
|
|
+
|
|
|
|
|
+ /*用户机构关系*/
|
|
|
|
|
+ fillUserDept(kwsUser.getId(), params.getDeptId());
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -465,4 +500,55 @@ public class KwsUserService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param ids 主键
|
|
|
|
|
+ * @desc: 冻结
|
|
|
|
|
+ * @author: czh
|
|
|
|
|
+ * @date: 2023/7/12
|
|
|
|
|
+ */
|
|
|
|
|
+ public void freeze(String ids) {
|
|
|
|
|
+ if (StringUtils.isBlank(ids)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ID_MISSING);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] split = ids.split(Global.COMMA);
|
|
|
|
|
+ for (String id : split) {
|
|
|
|
|
+ KwsUser kwsUser = kwsUserDao.selectByKey(Long.parseLong(id));
|
|
|
|
|
+ if (Objects.isNull(kwsUser) || !kwsUser.getStatus().equals(Global.NO)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ACCOUNT_FREEZE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ kwsUser.setStatus(Global.YES);
|
|
|
|
|
+ if (kwsUserDao.update(kwsUser) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @param ids 主键
|
|
|
|
|
+ * @desc: 解冻
|
|
|
|
|
+ * @author: czh
|
|
|
|
|
+ * @date: 2023/7/12
|
|
|
|
|
+ */
|
|
|
|
|
+ public void unFreeze(String ids) {
|
|
|
|
|
+ if (StringUtils.isBlank(ids)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ID_MISSING);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ String[] split = ids.split(Global.COMMA);
|
|
|
|
|
+ for (String id : split) {
|
|
|
|
|
+ KwsUser kwsUser = kwsUserDao.selectByKey(Long.parseLong(id));
|
|
|
|
|
+ if (Objects.isNull(kwsUser) || !kwsUser.getStatus().equals(Global.YES)) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.QUERY_FAIL_CODE, HttpStatus.ACCOUNT_UNFREEZE);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ kwsUser.setStatus(Global.NO);
|
|
|
|
|
+ if (kwsUserDao.update(kwsUser) <= 0) {
|
|
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|