|
|
@@ -90,7 +90,8 @@ public class KwsEnterpriseService {
|
|
|
* @author: czh
|
|
|
* @date: 2023/6/19
|
|
|
*/
|
|
|
- public void deleteByKey(String ids) throws Exception {
|
|
|
+ @Transactional(rollbackFor = {})
|
|
|
+ public void deleteByKey(String ids) throws SystemException {
|
|
|
//校验,有员工还在企业下则不能删除
|
|
|
List<Long> list = Arrays.stream(ids.split(",")).map(Long::parseLong).toList();
|
|
|
List<KwsEnterprise> kwsEnterprises = kwsEnterpriseDao.selectByKeys(list);
|
|
|
@@ -100,14 +101,14 @@ public class KwsEnterpriseService {
|
|
|
|
|
|
List<FindEntUserPojo> findEntUserPojos = kwsEnterpriseDao.findUserByEntIds(list);
|
|
|
if (!CollectionUtils.isEmpty(findEntUserPojos)) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.MSG_011);
|
|
|
}
|
|
|
|
|
|
/*1、删除企业*/
|
|
|
for (KwsEnterprise kwsEnterprise : kwsEnterprises) {
|
|
|
kwsEnterprise.setDelFlag(Global.YES);
|
|
|
if (kwsEnterpriseDao.update(kwsEnterprise) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
+ throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.DELETE_FAIL);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -134,76 +135,74 @@ public class KwsEnterpriseService {
|
|
|
throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
}
|
|
|
|
|
|
- /*2、更新企业类型*/
|
|
|
- List<KwsEntType> kwsEntTypes = kwsEntTypeDao.findListByEntId(entId);
|
|
|
- List<String> typeReqList = new ArrayList<>();
|
|
|
- String entTypes = reqVo.getEntTypes();
|
|
|
- if (StringUtils.isNotBlank(entTypes)) {
|
|
|
- typeReqList = Arrays.stream(entTypes.split(",")).toList();
|
|
|
- }
|
|
|
-
|
|
|
- //若入参传来的type在表里面本来就有则不管,没有就新增
|
|
|
- typeReqList.forEach(item -> {
|
|
|
- if (CollectionUtils.isEmpty(kwsEntTypes) || kwsEntTypes.stream().anyMatch(x -> x.getType() == Integer.parseInt(item))) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- KwsEntType kwsEntType = new KwsEntType();
|
|
|
- kwsEntType.setEntId(entId);
|
|
|
- kwsEntType.setType(Integer.parseInt(item));
|
|
|
- if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //若表里的type没有在入参传来的type里则做逻辑删除,有就不管
|
|
|
- if (CollectionUtils.isNotEmpty(kwsEntTypes)) {
|
|
|
- List<String> finalTypeReqList = typeReqList;
|
|
|
- kwsEntTypes.forEach(item -> {
|
|
|
- if (finalTypeReqList.contains(String.valueOf(item.getType()))) {
|
|
|
- item.setDelFlag(Global.YES);
|
|
|
- if (kwsEntTypeDao.update(item) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- /*更新证书信息*/
|
|
|
- //1、没有传则全部删除
|
|
|
- List<BusinessLicense> certificates = reqVo.getCertificates();
|
|
|
- if (CollectionUtils.isEmpty(certificates)) {
|
|
|
- List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
|
|
|
- if (!CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
- kwsEntCertificates.forEach(item -> {
|
|
|
- item.setDelFlag(Global.YES);
|
|
|
- if (kwsEntCertificateDao.update(item) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- certificates.forEach(item -> {
|
|
|
- long id = item.getId();
|
|
|
- if (Objects.isNull(id)) {
|
|
|
- KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
|
- kwsEntCertificate.setEntId(entId);
|
|
|
- BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
- if (kwsEntCertificateDao.insert(kwsEntCertificate) <= 0) {
|
|
|
- throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- KwsEntCertificate kwsEntCertificate = checkEntCertificate(id);
|
|
|
- BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
- //不做更新条数校验
|
|
|
- kwsEntCertificateDao.update(kwsEntCertificate);
|
|
|
- });
|
|
|
-
|
|
|
-
|
|
|
+// /*2、更新企业类型*/
|
|
|
+// List<KwsEntType> kwsEntTypes = kwsEntTypeDao.findListByEntId(entId);
|
|
|
+// List<String> typeReqList = new ArrayList<>();
|
|
|
+// String entTypes = reqVo.getEntTypes();
|
|
|
+// if (StringUtils.isNotBlank(entTypes)) {
|
|
|
+// typeReqList = Arrays.stream(entTypes.split(",")).toList();
|
|
|
+// }
|
|
|
+//
|
|
|
+// //若入参传来的type在表里面本来就有则不管,没有就新增
|
|
|
+// typeReqList.forEach(item -> {
|
|
|
+// if (CollectionUtils.isEmpty(kwsEntTypes) || kwsEntTypes.stream().anyMatch(x -> x.getType() == Integer.parseInt(item))) {
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// KwsEntType kwsEntType = new KwsEntType();
|
|
|
+// kwsEntType.setEntId(entId);
|
|
|
+// kwsEntType.setType(Integer.parseInt(item));
|
|
|
+// if (kwsEntTypeDao.insert(kwsEntType) <= 0) {
|
|
|
+// throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// //若表里的type没有在入参传来的type里则做逻辑删除,有就不管
|
|
|
+// if (CollectionUtils.isNotEmpty(kwsEntTypes)) {
|
|
|
+// List<String> finalTypeReqList = typeReqList;
|
|
|
+// kwsEntTypes.forEach(item -> {
|
|
|
+// if (finalTypeReqList.contains(String.valueOf(item.getType()))) {
|
|
|
+// item.setDelFlag(Global.YES);
|
|
|
+// if (kwsEntTypeDao.update(item) <= 0) {
|
|
|
+// throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+//
|
|
|
+// /*更新证书信息*/
|
|
|
+// //1、没有传则全部删除
|
|
|
+// List<BusinessLicense> certificates = reqVo.getCertificates();
|
|
|
+// if (CollectionUtils.isEmpty(certificates)) {
|
|
|
+// List<KwsEntCertificate> kwsEntCertificates = kwsEntCertificateDao.selectByEntId(entId);
|
|
|
+// if (!CollectionUtils.isEmpty(kwsEntCertificates)) {
|
|
|
+// kwsEntCertificates.forEach(item -> {
|
|
|
+// item.setDelFlag(Global.YES);
|
|
|
+// if (kwsEntCertificateDao.update(item) <= 0) {
|
|
|
+// throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.UPDATE_FAIL);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// certificates.forEach(item -> {
|
|
|
+// long id = item.getId();
|
|
|
+// if (Objects.isNull(id)) {
|
|
|
+// KwsEntCertificate kwsEntCertificate = new KwsEntCertificate();
|
|
|
+// kwsEntCertificate.setEntId(entId);
|
|
|
+// BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
+// if (kwsEntCertificateDao.insert(kwsEntCertificate) <= 0) {
|
|
|
+// throw new SystemException(HttpStatus.CRUD_FAIL_CODE, HttpStatus.INSERT_FAIL);
|
|
|
+// }
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// KwsEntCertificate kwsEntCertificate = checkEntCertificate(id);
|
|
|
+// BeanUtils.copyProperties(item, kwsEntCertificate);
|
|
|
+// //不做更新条数校验
|
|
|
+// kwsEntCertificateDao.update(kwsEntCertificate);
|
|
|
+// });
|
|
|
}
|
|
|
|
|
|
public KwsEntCertificate checkEntCertificate(long id) throws SystemException {
|
|
|
@@ -234,7 +233,7 @@ public class KwsEnterpriseService {
|
|
|
* @author: czh
|
|
|
* @date: 2023/6/9
|
|
|
*/
|
|
|
- public PageResult findPage(EntFindPageReqVo reqVo) throws Exception {
|
|
|
+ public PageResult findPage(EntFindPageReqVo reqVo) throws SystemException {
|
|
|
PageHelper.startPage(reqVo.getPageNum(), reqVo.getPageSize());
|
|
|
List<KwsEnterprise> list = findList(reqVo);
|
|
|
return PageHelperUtil.getPageResult(new PageInfo<>(list));
|