|
@@ -27,6 +27,7 @@ import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
import org.apache.dubbo.config.annotation.DubboService;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
import org.springframework.cache.annotation.CacheEvict;
|
|
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
|
@@ -61,6 +62,7 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
private MinioDataProviderService minioDataProviderService;
|
|
private MinioDataProviderService minioDataProviderService;
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @CacheEvict(value = "msr:department:name", allEntries = true)
|
|
|
public Response addDepartment(String userId , SmsbDepartmentAdd smsbDepartmentAdd) {
|
|
public Response addDepartment(String userId , SmsbDepartmentAdd smsbDepartmentAdd) {
|
|
|
List<SmsbDepartmentDO> departments = this.list(new LambdaQueryWrapper<>(SmsbDepartmentDO.class)
|
|
List<SmsbDepartmentDO> departments = this.list(new LambdaQueryWrapper<>(SmsbDepartmentDO.class)
|
|
|
.eq(SmsbDepartmentDO::getTenant, smsbDepartmentAdd.getTenant())
|
|
.eq(SmsbDepartmentDO::getTenant, smsbDepartmentAdd.getTenant())
|
|
@@ -78,6 +80,7 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
+ @CacheEvict(value = "msr:department:name", allEntries = true)
|
|
|
public void deleteDepartment(String userId, Long id) {
|
|
public void deleteDepartment(String userId, Long id) {
|
|
|
SmsbDepartmentDO department = super.getById(id);
|
|
SmsbDepartmentDO department = super.getById(id);
|
|
|
// 1、删除用户
|
|
// 1、删除用户
|
|
@@ -104,6 +107,7 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @CacheEvict(value = "msr:department:name", allEntries = true)
|
|
|
public Response updateDepartment(String userId, SmsbDepartmentUpdate departmentUpdate) {
|
|
public Response updateDepartment(String userId, SmsbDepartmentUpdate departmentUpdate) {
|
|
|
boolean flag = super.update(new LambdaUpdateWrapper<>(SmsbDepartmentDO.class)
|
|
boolean flag = super.update(new LambdaUpdateWrapper<>(SmsbDepartmentDO.class)
|
|
|
.set(StringUtils.isNotBlank(departmentUpdate.getName()), SmsbDepartmentDO::getName, departmentUpdate.getName())
|
|
.set(StringUtils.isNotBlank(departmentUpdate.getName()), SmsbDepartmentDO::getName, departmentUpdate.getName())
|
|
@@ -356,6 +360,7 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
|
|
+ @Cacheable(value = "msr:list:net:dept:device")
|
|
|
public DeviceDepartmentSimpleDto listDepartmentDeviceSimple(DeviceDepartmentCmd departmentCmd) {
|
|
public DeviceDepartmentSimpleDto listDepartmentDeviceSimple(DeviceDepartmentCmd departmentCmd) {
|
|
|
// 1. 获取对应部门树
|
|
// 1. 获取对应部门树
|
|
|
SmsbDepartmentCO department = this.queryDepartment(departmentCmd.getTenant() , departmentCmd.getOrg());
|
|
SmsbDepartmentCO department = this.queryDepartment(departmentCmd.getTenant() , departmentCmd.getOrg());
|
|
@@ -575,6 +580,36 @@ public class SmsbDepartmentServiceImpl extends ServiceImpl<SmsbDepartmentMapper
|
|
|
return BeanCopyUtils.copyList(doList, SmsbDepartmentCO.class);
|
|
return BeanCopyUtils.copyList(doList, SmsbDepartmentCO.class);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
|
+ @Cacheable(value = "msr:department:name", key = "#path")
|
|
|
|
|
+ public String getDeptNameByPath(String path){
|
|
|
|
|
+ if (StringUtils.isEmpty(path)) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ SmsbDepartmentDO departmentDO = lambdaQuery().eq(SmsbDepartmentDO::getPath, path).one();
|
|
|
|
|
+ if (Objects.isNull(departmentDO)) {
|
|
|
|
|
+ return "";
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Objects.isNull(departmentDO.getParentId())) {
|
|
|
|
|
+ return departmentDO.getName();
|
|
|
|
|
+ }
|
|
|
|
|
+ departmentDO = lambdaQuery().eq(SmsbDepartmentDO::getId, departmentDO.getParentId()).one();
|
|
|
|
|
+ return getDeptNameByPath(departmentDO.getPath());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public List<String> getSubPathByCityName(String cityName) {
|
|
|
|
|
+ Long cityId = lambdaQuery().eq(SmsbDepartmentDO::getName, cityName).one().getId();
|
|
|
|
|
+ return lambdaQuery()
|
|
|
|
|
+ .eq(SmsbDepartmentDO::getId, cityId)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .eq(SmsbDepartmentDO::getParentId, cityId)
|
|
|
|
|
+ .list()
|
|
|
|
|
+ .stream()
|
|
|
|
|
+ .map(SmsbDepartmentDO::getPath)
|
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 获取present部门的所有父部门
|
|
* 获取present部门的所有父部门
|
|
|
*/
|
|
*/
|