重构多公司代码
This commit is contained in:
parent
302721fd57
commit
84f1113c21
|
|
@ -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<SysDept> list = new ArrayList<>();
|
||||
list.add(sysDept);
|
||||
if (!deptService.checkCompaniesNameUnique(list)) {
|
||||
return error("新增公司失败,公司名称已存在");
|
||||
}
|
||||
return toAjax(deptService.insertCompany(sysDept));
|
||||
return toAjax(deptService.insertCompanies(list));
|
||||
}
|
||||
/**
|
||||
* 新增部门
|
||||
|
|
|
|||
|
|
@ -133,6 +133,4 @@ public interface SysDeptMapper
|
|||
int getMaxDeptId();
|
||||
|
||||
int checkCompanyNameUnique(SysDept list);
|
||||
|
||||
int insertCompany(SysDept list);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归列表
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -143,15 +143,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
<insert id="insertCompany" parameterType="com.bonus.sgzb.system.api.domain.SysDept">
|
||||
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}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<update id="updateDept" parameterType="com.bonus.sgzb.system.api.domain.SysDept">
|
||||
update sys_dept
|
||||
|
|
|
|||
Loading…
Reference in New Issue