parent
108d0570fa
commit
da25463bf9
|
|
@ -1,6 +1,7 @@
|
|||
package com.zcloud.basic.info.facade;
|
||||
|
||||
import com.alibaba.cola.dto.MultiResponse;
|
||||
import com.alibaba.cola.dto.Response;
|
||||
import com.jjb.saas.framework.auth.model.SSOUser;
|
||||
import com.jjb.saas.framework.auth.utils.AuthContext;
|
||||
import com.zcloud.basic.info.api.ImgFilesServiceI;
|
||||
|
|
@ -21,8 +22,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|||
import javax.annotation.Resource;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.InputStream;
|
||||
import java.util.Base64;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author zhangyue
|
||||
|
|
@ -84,6 +84,47 @@ public class ZcloudImgFilesFacadeImpl implements ZcloudImgFilesFacade {
|
|||
return resultFilePath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteFiles(String foreignKey, String type) {
|
||||
if (ObjectUtils.isEmpty(foreignKey)){
|
||||
return Response.buildFailure("文件foreignKey不能为空");
|
||||
}
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("eqForeignKey", foreignKey);
|
||||
if (!ObjectUtils.isEmpty(type)){
|
||||
params.put("eqType", type);
|
||||
}
|
||||
params.put("eqDeleteEnum", "FALSE");
|
||||
imgFilesService.removeBatch(params);
|
||||
return Response.buildSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteFiles(List<String> foreignKeyList, String type) {
|
||||
if (foreignKeyList == null || foreignKeyList.size() == 0){
|
||||
return Response.buildFailure("文件foreignKey不能为空");
|
||||
}
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("inForeignKey", foreignKeyList);
|
||||
if (!ObjectUtils.isEmpty(type)){
|
||||
params.put("eqType", type);
|
||||
}
|
||||
params.put("eqDeleteEnum", "FALSE");
|
||||
imgFilesService.removeBatch(params);
|
||||
return Response.buildSuccess();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Response deleteFileList(List<String> filePathList) {
|
||||
if (filePathList == null || filePathList.size() == 0){
|
||||
return Response.buildFailure("文件路径不能为空");
|
||||
}
|
||||
filePathList.forEach(filePath -> {
|
||||
imgFilesService.removeFile(filePath);
|
||||
});
|
||||
return Response.buildSuccess();
|
||||
}
|
||||
|
||||
|
||||
public static InputStream base64ToInputStream(String base64String) {
|
||||
if (base64String == null || base64String.isEmpty()) {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class DepartmentAddExe {
|
|||
departmentQry.setEqParentId(cmd.getParentId());
|
||||
List<DepartmentTreeInfoCO> departmentTreeInfoCOList = departmentQueryExe.listTree(departmentQry);*/
|
||||
//名字校验重复
|
||||
if (departmentRepository.existsByName(cmd.getName())) {
|
||||
if (departmentRepository.existsByName(cmd.getParentId(), cmd.getName(), null)) {
|
||||
throw new BizException("部门名称已存在");
|
||||
}
|
||||
BeanUtils.copyProperties(cmd, examTypeE);
|
||||
|
|
|
|||
|
|
@ -51,6 +51,10 @@ public class DepartmentUpdateExe {
|
|||
if(departmentDO == null){
|
||||
throw new BizException("部门信息不存在");
|
||||
}
|
||||
//名字校验重复
|
||||
if (departmentRepository.existsByName(departmentUpdateCmd.getParentId(), departmentUpdateCmd.getName(), departmentUpdateCmd.getId())) {
|
||||
throw new BizException("部门名称已存在");
|
||||
}
|
||||
DepartmentE departmentE = new DepartmentE();
|
||||
BeanUtils.copyProperties(departmentUpdateCmd, departmentE);
|
||||
boolean res = departmentGateway.update(departmentE);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -51,5 +53,20 @@ public class ImgFilesRemoveExe {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean execute(Map<String, Object> params) {
|
||||
List<ImgFilesDO> imgFilesDOList = imgFilesRepository.listAll(params);
|
||||
List<ImgFilesE> imgFilesEList = imgFilesCoConvertor.converDOsToEs(imgFilesDOList);
|
||||
ImgFilesE imgFilesE = new ImgFilesE();
|
||||
try {
|
||||
imgFilesE.deleteFileList(imgFilesEList);
|
||||
Long[] ids = imgFilesEList.stream().map(ImgFilesE::getId).toArray(Long[]::new);
|
||||
imgFilesRepository.deleteList(ids);
|
||||
} catch (Exception e) {
|
||||
throw new BizException("删除失败");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@ import com.zcloud.basic.info.dto.clientobject.ImgFilesInfoCO;
|
|||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web-app
|
||||
*
|
||||
|
|
@ -62,6 +64,11 @@ public class ImgFilesServiceImpl implements ImgFilesServiceI {
|
|||
imgFilesRemoveExe.execute(ids);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeBatch(Map<String, Object> params) {
|
||||
imgFilesRemoveExe.execute(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public MultiResponse<ImgFilesCO> listAll(ImgFilesQryCmd imgFilesQryCmd) {
|
||||
return imgFilesQueryExe.executeList(imgFilesQryCmd);
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import com.zcloud.basic.info.dto.ImgFilesUpdateCmd;
|
|||
import com.zcloud.basic.info.dto.clientobject.ImgFilesCO;
|
||||
import com.zcloud.basic.info.dto.clientobject.ImgFilesInfoCO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* web-client
|
||||
* @Author zhangyue
|
||||
|
|
@ -27,6 +29,8 @@ public interface ImgFilesServiceI {
|
|||
|
||||
void removeBatch(Long[] ids);
|
||||
|
||||
void removeBatch(Map<String, Object> params);
|
||||
|
||||
MultiResponse<ImgFilesCO> listAll(ImgFilesQryCmd imgFilesQryCmd);
|
||||
|
||||
String getImagePath();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.zcloud.basic.info.persistence.dataobject.CorpInfoDO;
|
|||
import com.zcloud.basic.info.persistence.dataobject.DepartmentDO;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ public interface DepartmentRepository extends BaseRepository<DepartmentDO> {
|
|||
|
||||
List<DepartmentDO> listAllTree();
|
||||
|
||||
boolean existsByName(@NotEmpty(message = "名称不能为空") String name);
|
||||
boolean existsByName(@NotNull(message = "父级id") Long parentId, @NotEmpty(message = "名称不能为空") String name, Long id);
|
||||
|
||||
List<DepartmentDO> listAllTreeByCorpType(Map<String, Object> parmas);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,10 +136,14 @@ public class DepartmentRepositoryImpl extends BaseRepositoryImpl<DepartmentMappe
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean existsByName(String name) {
|
||||
public boolean existsByName(Long parentId,String name, Long id) {
|
||||
QueryWrapper<DepartmentDO> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("name", name);
|
||||
queryWrapper.eq("corpinfo_id", AuthContext.getTenantId());
|
||||
queryWrapper.eq("parent_id", parentId);
|
||||
queryWrapper.eq("delete_enum", "FALSE");
|
||||
if (!ObjectUtils.isEmpty(id)){
|
||||
queryWrapper.ne("id", id);
|
||||
}
|
||||
return departmentMapper.selectCount(queryWrapper) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue