|
@@ -16,6 +16,7 @@
|
|
|
package me.zhengjie.modules.dm.company.service.impl;
|
|
|
|
|
|
import me.zhengjie.modules.dm.company.domain.DmCompany;
|
|
|
+import me.zhengjie.modules.system.repository.UserRepository;
|
|
|
import me.zhengjie.utils.ValidationUtil;
|
|
|
import me.zhengjie.utils.FileUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
@@ -24,6 +25,7 @@ import me.zhengjie.modules.dm.company.service.DmCompanyService;
|
|
|
import me.zhengjie.modules.dm.company.service.dto.DmCompanyDto;
|
|
|
import me.zhengjie.modules.dm.company.service.dto.DmCompanyQueryCriteria;
|
|
|
import me.zhengjie.modules.dm.company.service.mapstruct.DmCompanyMapper;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import cn.hutool.core.lang.Snowflake;
|
|
@@ -32,12 +34,10 @@ import org.springframework.data.domain.Page;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import me.zhengjie.utils.PageUtil;
|
|
|
import me.zhengjie.utils.QueryHelp;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+
|
|
|
+import java.util.*;
|
|
|
import java.io.IOException;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.LinkedHashMap;
|
|
|
|
|
|
/**
|
|
|
* @website https://el-admin.vip
|
|
@@ -51,6 +51,8 @@ public class DmCompanyServiceImpl implements DmCompanyService {
|
|
|
|
|
|
private final DmCompanyRepository dmCompanyRepository;
|
|
|
private final DmCompanyMapper dmCompanyMapper;
|
|
|
+ @Autowired
|
|
|
+ private final UserRepository userRepository;
|
|
|
|
|
|
@Override
|
|
|
public Map<String,Object> queryAll(DmCompanyQueryCriteria criteria, Pageable pageable){
|
|
@@ -89,10 +91,19 @@ public class DmCompanyServiceImpl implements DmCompanyService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteAll(Long[] ids) {
|
|
|
+ public Map<String,Object> deleteAll(Long[] ids) {
|
|
|
+ Map<String,Object> map= new HashMap<>();
|
|
|
+ List name=userRepository.selectCompanyName(ids);
|
|
|
for (Long companyId : ids) {
|
|
|
- dmCompanyRepository.deleteById(companyId);
|
|
|
+ Integer count = userRepository.selecIsNotCompany(companyId);
|
|
|
+ if(count<=0){
|
|
|
+ dmCompanyRepository.deleteById(companyId);
|
|
|
+ }else {
|
|
|
+ map.put("lose",name+"已绑定用户,不能删除");
|
|
|
+ map.put("type", "company");
|
|
|
+ }
|
|
|
}
|
|
|
+ return map;
|
|
|
}
|
|
|
|
|
|
@Override
|