添加企业及其下级数据删除功能
parent
97d23b58eb
commit
9dd1fb1e4c
|
|
@ -18,6 +18,8 @@ import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-adapter
|
* web-adapter
|
||||||
*
|
*
|
||||||
|
|
@ -37,6 +39,13 @@ public class CorpInfoController {
|
||||||
return corpInfoService.add(cmd);
|
return corpInfoService.add(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ApiOperation("新增")
|
||||||
|
@GetMapping("/deleteCorpAndDown/{ids}")
|
||||||
|
public void deleteCorpAndDown(@PathVariable("ids") List<Long> ids) {
|
||||||
|
corpInfoService.deleteCorpAndDown(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation("判断统一社会信用代码是否重复, true:没重复, false:有重复")
|
@ApiOperation("判断统一社会信用代码是否重复, true:没重复, false:有重复")
|
||||||
@PostMapping("/checkCorpCode")
|
@PostMapping("/checkCorpCode")
|
||||||
public SingleResponse<Object> checkCorpCode(@Validated @RequestBody CorpInfoCheckCodeQry qry) {
|
public SingleResponse<Object> checkCorpCode(@Validated @RequestBody CorpInfoCheckCodeQry qry) {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,29 @@
|
||||||
package com.zcloud.basic.info.command;
|
package com.zcloud.basic.info.command;
|
||||||
|
|
||||||
|
import com.alibaba.cola.dto.Response;
|
||||||
import com.alibaba.cola.exception.BizException;
|
import com.alibaba.cola.exception.BizException;
|
||||||
|
import com.jjb.saas.system.client.unit.facade.UnitFacade;
|
||||||
|
import com.jjb.saas.system.client.user.facade.UserFacade;
|
||||||
|
import com.jjb.saas.system.client.user.request.UserUpdateQuitCmd;
|
||||||
import com.zcloud.basic.info.domain.gateway.CorpInfoGateway;
|
import com.zcloud.basic.info.domain.gateway.CorpInfoGateway;
|
||||||
|
import com.zcloud.basic.info.persistence.dataobject.CorpInfoDO;
|
||||||
|
import com.zcloud.basic.info.persistence.dataobject.UserDO;
|
||||||
|
import com.zcloud.basic.info.persistence.repository.CorpInfoRepository;
|
||||||
|
import com.zcloud.basic.info.persistence.repository.DepartmentRepository;
|
||||||
|
import com.zcloud.basic.info.persistence.repository.PostRepository;
|
||||||
|
import com.zcloud.basic.info.persistence.repository.UserRepository;
|
||||||
import com.zcloud.gbscommon.utils.Const;
|
import com.zcloud.gbscommon.utils.Const;
|
||||||
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
|
import com.zcloud.gbscommon.utils.ZcloudRedisUtil;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.dubbo.config.annotation.DubboReference;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.core.parameters.P;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* web-app
|
* web-app
|
||||||
|
|
@ -18,8 +33,17 @@ import org.springframework.transaction.annotation.Transactional;
|
||||||
*/
|
*/
|
||||||
@Component
|
@Component
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Slf4j
|
||||||
public class CorpInfoRemoveExe {
|
public class CorpInfoRemoveExe {
|
||||||
private final CorpInfoGateway corpInfoGateway;
|
private final CorpInfoGateway corpInfoGateway;
|
||||||
|
private final UserRepository userRepository;
|
||||||
|
private final PostRepository postRepository;
|
||||||
|
private final DepartmentRepository departmentRepository;
|
||||||
|
private final CorpInfoRepository corpInfoRepository;
|
||||||
|
@DubboReference
|
||||||
|
private UserFacade userFacade;
|
||||||
|
@DubboReference
|
||||||
|
private UnitFacade unitFacade;
|
||||||
// @Autowired
|
// @Autowired
|
||||||
// private ZcloudRedisUtil zcloudRedisUtil;
|
// private ZcloudRedisUtil zcloudRedisUtil;
|
||||||
|
|
||||||
|
|
@ -45,5 +69,54 @@ public class CorpInfoRemoveExe {
|
||||||
// }
|
// }
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void deleteCorpAndDown(List<Long> ids) {
|
||||||
|
List<CorpInfoDO> corpList = corpInfoRepository.listByIds(ids);
|
||||||
|
if (corpList != null && !corpList.isEmpty()){
|
||||||
|
for (CorpInfoDO corp : corpList){
|
||||||
|
log.info("开始清理企业数据:"+corp.getCorpName()+"____"+corp.getId()+"------------------");
|
||||||
|
List<UserDO> userList = userRepository.listByCorpInfoId(corp.getId());
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 1. 先调用远程服务删除底座数据,确保底座数据删除成功
|
||||||
|
log.info("底座---开始删除租户数据----------------------------------------");
|
||||||
|
unitFacade.delete(corp.getId());
|
||||||
|
log.info("底座---删除租户数据完成----------------------------------------");
|
||||||
|
|
||||||
|
log.info("开始清理用户数据数据----------------------------------------");
|
||||||
|
for (UserDO user : userList){
|
||||||
|
log.info("底座---开始清理用户数据:"+user.getName()+"____"+user.getId());
|
||||||
|
|
||||||
|
// Response quit = userFacade.quit(quitCmd);
|
||||||
|
if (!user.getId().equals(user.getCorpinfoId())){
|
||||||
|
|
||||||
|
log.info(user.getId()+"-------"+ corp.getId());
|
||||||
|
if (corp.getBroadType() == 2){ // 企业
|
||||||
|
userFacade.delete(user.getId());
|
||||||
|
} else if (corp.getBroadType() == 3){ // 相关方
|
||||||
|
UserUpdateQuitCmd quitCmd = new UserUpdateQuitCmd();
|
||||||
|
quitCmd.setId(user.getId());
|
||||||
|
userFacade.quit(quitCmd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
log.info("底座---清理用户数据完成:"+user.getName()+"____"+user.getId());
|
||||||
|
}
|
||||||
|
log.info("清理用户数据完成----------------------------------------");
|
||||||
|
|
||||||
|
// 2. 远程服务删除成功后,再执行本地软删除
|
||||||
|
userRepository.deleteByCorpInfoId(corp.getId());
|
||||||
|
postRepository.deleteByCorpInfoId(corp.getId());
|
||||||
|
departmentRepository.deleteByCorpInfoId(corp.getId());
|
||||||
|
corpInfoRepository.deleteById(corp.getId());
|
||||||
|
log.info("清理企业数据完成:"+corp.getCorpName()+"____"+corp.getId()+"------------------");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("清理企业{}数据异常:", corp.getCorpName(), e);
|
||||||
|
// 抛出异常,触发事务回滚
|
||||||
|
throw new BizException("清理企业" + corp.getCorpName() + "数据异常:" + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -299,16 +299,12 @@ public class CorpInfoQueryExe {
|
||||||
if (!enterpriseType.contains(corpInfoDO.getType())) {
|
if (!enterpriseType.contains(corpInfoDO.getType())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
//corpName,省份编码,单位经营地址,企业规模,法定代表人姓名,主要负责人电话,成立日期,职工人数,资产总额,营业执照开始时间,只要有一个不为空
|
//corpName,单位经营地址,法定代表人姓名,主要负责人电话,职工人数,只要有一个不为空
|
||||||
if (StringUtils.isEmpty(corpInfoDO.getCorpName())
|
if (StringUtils.isEmpty(corpInfoDO.getCorpName())
|
||||||
|| StringUtils.isEmpty(corpInfoDO.getProvince())
|
|
||||||
|| StringUtils.isEmpty(corpInfoDO.getAddressBusiness())
|
|| StringUtils.isEmpty(corpInfoDO.getAddressBusiness())
|
||||||
|| StringUtils.isEmpty(corpInfoDO.getLrName())
|
|| StringUtils.isEmpty(corpInfoDO.getLrName())
|
||||||
|| StringUtils.isEmpty(corpInfoDO.getContactsPhone())
|
|| StringUtils.isEmpty(corpInfoDO.getContactsPhone())
|
||||||
|| corpInfoDO.getCreateDate() == null
|
|| corpInfoDO.getEmployees()==null) {
|
||||||
|| corpInfoDO.getEmployees()==null
|
|
||||||
|| corpInfoDO.getTotalAssets()==null
|
|
||||||
|| corpInfoDO.getLicenseStart()==null) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -99,6 +99,11 @@ public class CorpInfoServiceImpl implements CorpInfoServiceI {
|
||||||
return corpInfoQueryExe.CorpInfoEncryCO(userCheckPassWordCmd);
|
return corpInfoQueryExe.CorpInfoEncryCO(userCheckPassWordCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteCorpAndDown(List<Long> ids) {
|
||||||
|
corpInfoRemoveExe.deleteCorpAndDown(ids);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResponse<CorpDepartmentCO> corpDepartlist(CorpDepartmentQry qry) {
|
public PageResponse<CorpDepartmentCO> corpDepartlist(CorpDepartmentQry qry) {
|
||||||
return corpInfoQueryExe.corpDepartlist(qry);
|
return corpInfoQueryExe.corpDepartlist(qry);
|
||||||
|
|
|
||||||
|
|
@ -53,5 +53,7 @@ public interface CorpInfoServiceI {
|
||||||
Boolean verifyCorpInfo();
|
Boolean verifyCorpInfo();
|
||||||
|
|
||||||
DecryptCmd getEncryInfo(UserCheckPassWordCmd userCheckPassWordCmd);
|
DecryptCmd getEncryInfo(UserCheckPassWordCmd userCheckPassWordCmd);
|
||||||
|
|
||||||
|
void deleteCorpAndDown(List<Long> ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,8 @@ public class CorpInfoDO extends BaseDO {
|
||||||
@ApiModelProperty(value = "所属区域")
|
@ApiModelProperty(value = "所属区域")
|
||||||
private String companyArea;
|
private String companyArea;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "企业类型 1:监管 2:企业 3:相关方")
|
||||||
|
private Integer broadType;
|
||||||
//规模
|
//规模
|
||||||
@ApiModelProperty(value = "规模")
|
@ApiModelProperty(value = "规模")
|
||||||
private String scale;
|
private String scale;
|
||||||
|
|
|
||||||
|
|
@ -42,5 +42,7 @@ public interface CorpInfoRepository extends BaseRepository<CorpInfoDO> {
|
||||||
List<CorpInfoDO> getByIdList(List<Long> corpinfoIds);
|
List<CorpInfoDO> getByIdList(List<Long> corpinfoIds);
|
||||||
|
|
||||||
Boolean isSupper();
|
Boolean isSupper();
|
||||||
|
|
||||||
|
void deleteById(Long id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -39,5 +39,7 @@ public interface DepartmentRepository extends BaseRepository<DepartmentDO> {
|
||||||
boolean existsByName(@NotNull(message = "父级id") Long parentId, @NotEmpty(message = "名称不能为空") String name, Long id);
|
boolean existsByName(@NotNull(message = "父级id") Long parentId, @NotEmpty(message = "名称不能为空") String name, Long id);
|
||||||
|
|
||||||
List<DepartmentDO> listAllTreeByCorpType(Map<String, Object> parmas);
|
List<DepartmentDO> listAllTreeByCorpType(Map<String, Object> parmas);
|
||||||
|
|
||||||
|
void deleteByCorpInfoId(Long corpInfoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -28,5 +28,7 @@ public interface PostRepository extends BaseRepository<PostDO> {
|
||||||
List<PostDO> listByCorpInfoId(Long corpInfoId);
|
List<PostDO> listByCorpInfoId(Long corpInfoId);
|
||||||
|
|
||||||
Boolean checkPostDepartment(Long id);
|
Boolean checkPostDepartment(Long id);
|
||||||
|
|
||||||
|
void deleteByCorpInfoId(Long corpInfoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -100,5 +100,8 @@ public interface UserRepository extends BaseRepository<UserDO> {
|
||||||
PageResponse<UserDO> pageByNopermission(Map<String, Object> params);
|
PageResponse<UserDO> pageByNopermission(Map<String, Object> params);
|
||||||
|
|
||||||
void updateFaceByPhone(@NotEmpty(message = "人脸头像url不能为空") String userAvatarUrl, String phone);
|
void updateFaceByPhone(@NotEmpty(message = "人脸头像url不能为空") String userAvatarUrl, String phone);
|
||||||
|
|
||||||
|
|
||||||
|
void deleteByCorpInfoId(Long corpInfoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -308,5 +308,13 @@ public class CorpInfoRepositoryImpl extends BaseRepositoryImpl<CorpInfoMapper, C
|
||||||
return true;
|
return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
UpdateWrapper updateWrapper = new UpdateWrapper<CorpInfoDO>();
|
||||||
|
updateWrapper.eq("id", id);
|
||||||
|
updateWrapper.set("delete_enum", "TRUE");
|
||||||
|
update(updateWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ package com.zcloud.basic.info.persistence.repository.impl;
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import com.alibaba.cola.dto.PageResponse;
|
import com.alibaba.cola.dto.PageResponse;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
|
|
@ -145,6 +146,14 @@ public class DepartmentRepositoryImpl extends BaseRepositoryImpl<DepartmentMappe
|
||||||
queryWrapper.ne("id", id);
|
queryWrapper.ne("id", id);
|
||||||
}
|
}
|
||||||
return departmentMapper.selectCount(queryWrapper) > 0;
|
return departmentMapper.selectCount(queryWrapper) > 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public void deleteByCorpInfoId(Long corpInfoId) {
|
||||||
|
UpdateWrapper updateWrapper = new UpdateWrapper();
|
||||||
|
updateWrapper.eq("corpinfo_id", corpInfoId);
|
||||||
|
updateWrapper.set("delete_enum", "TRUE");
|
||||||
|
update(updateWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.zcloud.basic.info.persistence.repository.impl;
|
package com.zcloud.basic.info.persistence.repository.impl;
|
||||||
|
|
||||||
import com.alibaba.cola.dto.MultiResponse;
|
import com.alibaba.cola.dto.MultiResponse;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||||
import com.jjb.saas.framework.repository.common.PageHelper;
|
import com.jjb.saas.framework.repository.common.PageHelper;
|
||||||
|
|
@ -111,5 +112,13 @@ public class PostRepositoryImpl extends BaseRepositoryImpl<PostMapper, PostDO> i
|
||||||
queryWrapper.eq("delete_enum", "FALSE");
|
queryWrapper.eq("delete_enum", "FALSE");
|
||||||
return postMapper.selectCount(queryWrapper) > 0;
|
return postMapper.selectCount(queryWrapper) > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByCorpInfoId(Long corpInfoId) {
|
||||||
|
UpdateWrapper updateWrapper = new UpdateWrapper();
|
||||||
|
updateWrapper.eq("corpinfo_id", corpInfoId);
|
||||||
|
updateWrapper.set("delete_enum", "TRUE");
|
||||||
|
update(updateWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -318,6 +318,7 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
UserAddCmd userAddCmd = new UserAddCmd();
|
UserAddCmd userAddCmd = new UserAddCmd();
|
||||||
userAddCmd.setAccount(userDO.getUsername());
|
userAddCmd.setAccount(userDO.getUsername());
|
||||||
userAddCmd.setName(userDO.getName());
|
userAddCmd.setName(userDO.getName());
|
||||||
|
userAddCmd.setPassword(userDO.getPassword());
|
||||||
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
RoleDeptAddCmd roleDeptAddCmd = new RoleDeptAddCmd();
|
||||||
roleDeptAddCmd.setRoleId(userDO.getRoleId());
|
roleDeptAddCmd.setRoleId(userDO.getRoleId());
|
||||||
roleDeptAddCmd.setDeptId(userDO.getDepartmentId());
|
roleDeptAddCmd.setDeptId(userDO.getDepartmentId());
|
||||||
|
|
@ -707,5 +708,13 @@ public class UserRepositoryImpl extends BaseRepositoryImpl<UserMapper, UserDO> i
|
||||||
|
|
||||||
userMapper.updateFaceByPhone(userAvatarUrl, phone);
|
userMapper.updateFaceByPhone(userAvatarUrl, phone);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteByCorpInfoId(Long corpInfoId) {
|
||||||
|
UpdateWrapper updateWrapper = new UpdateWrapper();
|
||||||
|
updateWrapper.eq("corpinfo_id", corpInfoId);
|
||||||
|
updateWrapper.set("delete_enum", "TRUE");
|
||||||
|
update(updateWrapper);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue