diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java index f340414..4b09b47 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/controller/SysDeptController.java @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import java.util.ArrayList; import java.util.List; /** @@ -88,11 +89,12 @@ public class SysDeptController extends BaseController { @Log(title = "公司管理", businessType = BusinessType.INSERT) @PostMapping(value = "/addFirm") public AjaxResult addFirm(@RequestBody SysDept sysDept) { - logger.info("新增公司"); - if (!deptService.checkCompanyNameUnique(sysDept)) { + List list = new ArrayList<>(); + list.add(sysDept); + if (!deptService.checkCompaniesNameUnique(list)) { return error("新增公司失败,公司名称已存在"); } - return toAjax(deptService.insertCompany(sysDept)); + return toAjax(deptService.insertCompanies(list)); } /** * 新增部门 diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysDeptMapper.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysDeptMapper.java index 05d1d84..b3e8324 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysDeptMapper.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/mapper/SysDeptMapper.java @@ -133,6 +133,4 @@ public interface SysDeptMapper int getMaxDeptId(); int checkCompanyNameUnique(SysDept list); - - int insertCompany(SysDept list); } diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysDeptService.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysDeptService.java index 345e430..877ebf5 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysDeptService.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/ISysDeptService.java @@ -127,11 +127,4 @@ public interface ISysDeptService public int deleteDeptById(Long deptId); String getCompanyByAncestors(String ancestors); - - /* - * 新增公司 - * */ - public boolean checkCompanyNameUnique(SysDept list); - - int insertCompany(SysDept list); } diff --git a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysDeptServiceImpl.java b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysDeptServiceImpl.java index 4f47607..d1b3983 100644 --- a/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysDeptServiceImpl.java +++ b/sgzb-modules/sgzb-system/src/main/java/com/bonus/sgzb/system/service/impl/SysDeptServiceImpl.java @@ -315,32 +315,6 @@ public class SysDeptServiceImpl implements ISysDeptService { } - @Override - public boolean checkCompanyNameUnique(SysDept list) { - int count = deptMapper.checkCompanyNameUnique(list); - return count == 0; - } - - @Override - public int insertCompany(SysDept list) { -// long num = deptMapper.getMaxDeptId()+1; - SysDept dept = new SysDept(); - String deptName = list.getDeptName(); - dept.setDeptName(deptName); - dept.setSocialCreditCode(list.getSocialCreditCode()); - dept.setEnterpriseOwnershipCode(list.getEnterpriseOwnershipCode()); - dept.setCreateBy(SecurityUtils.getUsername()); - dept.setParentId(0L); - dept.setAncestors("0"); - dept.setOrderNum(999); - dept.setStatus("0"); -// long nextMultiple = (int) Math.ceil((double) num / 100) * 100; -// num = nextMultiple + 1; -// dept.setDeptId(nextMultiple); -// dept.setCompanyId(nextMultiple); - return deptMapper.insertCompany(dept); - } - /** * 递归列表 */ diff --git a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml index 7f37e6c..f1c9b23 100644 --- a/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml +++ b/sgzb-modules/sgzb-system/src/main/resources/mapper/system/SysDeptMapper.xml @@ -143,15 +143,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" sysdate() ) - - insert into sys_dept( - dept_id,parent_id,dept_name,ancestors,order_num,leader,phone,email,status,create_by,company_id,create_time,social_credit_code,enterprise_ownership_code) - values( - #{deptId},#{parentId},#{deptName},#{ancestors},#{orderNum},#{leader}, - #{phone},#{email},#{status},#{createBy},#{companyId}, - sysdate(),#{socialCreditCode},#{enterpriseOwnershipCode} - ) - update sys_dept