diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java index 6d2482c..30fd78a 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/system/api/domain/SysDept.java @@ -1,20 +1,20 @@ package com.bonus.sgzb.system.api.domain; -import java.util.ArrayList; -import java.util.List; +import com.bonus.sgzb.common.core.web.domain.BaseEntity; +import io.swagger.annotations.ApiModelProperty; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + import javax.validation.constraints.Email; import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotNull; import javax.validation.constraints.Size; - -import io.swagger.annotations.ApiModelProperty; -import org.apache.commons.lang3.builder.ToStringBuilder; -import org.apache.commons.lang3.builder.ToStringStyle; -import com.bonus.sgzb.common.core.web.domain.BaseEntity; +import java.util.ArrayList; +import java.util.List; /** * 部门表 sys_dept - * + * * @author ruoyi */ public class SysDept extends BaseEntity @@ -64,7 +64,7 @@ public class SysDept extends BaseEntity /** 父部门名称 */ @ApiModelProperty(value = "父部门名称") private String parentName; - + /** 子部门 */ @ApiModelProperty(value = "子部门") private List children = new ArrayList<>(); 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 df3f901..f340414 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 @@ -1,18 +1,5 @@ package com.bonus.sgzb.system.controller; -import java.util.List; - -import org.apache.commons.lang3.ArrayUtils; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.PutMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; import com.bonus.sgzb.common.core.constant.UserConstants; import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.web.controller.BaseController; @@ -23,6 +10,12 @@ import com.bonus.sgzb.common.security.annotation.RequiresPermissions; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.system.api.domain.SysDept; import com.bonus.sgzb.system.service.ISysDeptService; +import org.apache.commons.lang3.ArrayUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; /** * 部门信息 @@ -91,7 +84,16 @@ public class SysDeptController extends BaseController { return toAjax(deptService.insertCompanies(list)); } - +// @RequiresPermissions("system:dept:add") + @Log(title = "公司管理", businessType = BusinessType.INSERT) + @PostMapping(value = "/addFirm") + public AjaxResult addFirm(@RequestBody SysDept sysDept) { + logger.info("新增公司"); + if (!deptService.checkCompanyNameUnique(sysDept)) { + return error("新增公司失败,公司名称已存在"); + } + return toAjax(deptService.insertCompany(sysDept)); + } /** * 新增部门 */ 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 e310500..05d1d84 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 @@ -1,19 +1,20 @@ package com.bonus.sgzb.system.mapper; -import java.util.List; -import org.apache.ibatis.annotations.Param; import com.bonus.sgzb.system.api.domain.SysDept; +import org.apache.ibatis.annotations.Param; + +import java.util.List; /** * 部门管理 数据层 - * + * * @author ruoyi */ public interface SysDeptMapper { /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -21,7 +22,7 @@ public interface SysDeptMapper /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @param deptCheckStrictly 部门树选择项是否关联显示 * @return 选中部门列表 @@ -30,7 +31,7 @@ public interface SysDeptMapper /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -38,7 +39,7 @@ public interface SysDeptMapper /** * 根据ID查询所有子部门 - * + * * @param deptId 部门ID * @return 部门列表 */ @@ -46,7 +47,7 @@ public interface SysDeptMapper /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -54,7 +55,7 @@ public interface SysDeptMapper /** * 是否存在子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -62,7 +63,7 @@ public interface SysDeptMapper /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 */ @@ -72,7 +73,7 @@ public interface SysDeptMapper /** * 校验部门名称是否唯一 - * + * * @param deptName 部门名称 * @param parentId 父部门ID * @return 结果 @@ -83,7 +84,7 @@ public interface SysDeptMapper /** * 新增部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -91,7 +92,7 @@ public interface SysDeptMapper /** * 修改部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -99,14 +100,14 @@ public interface SysDeptMapper /** * 修改所在部门正常状态 - * + * * @param deptIds 部门ID组 */ public void updateDeptStatusNormal(Long[] deptIds); /** * 修改子元素关系 - * + * * @param depts 子元素 * @return 结果 */ @@ -114,7 +115,7 @@ public interface SysDeptMapper /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ @@ -130,4 +131,8 @@ public interface SysDeptMapper String getCompanyByAncestors(String split); 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 f0a8e54..345e430 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 @@ -1,19 +1,20 @@ package com.bonus.sgzb.system.service; -import java.util.List; import com.bonus.sgzb.system.api.domain.SysDept; import com.bonus.sgzb.system.domain.vo.TreeSelect; +import java.util.List; + /** * 部门管理 服务层 - * + * * @author ruoyi */ public interface ISysDeptService { /** * 查询部门管理数据 - * + * * @param dept 部门信息 * @return 部门信息集合 */ @@ -21,7 +22,7 @@ public interface ISysDeptService /** * 查询部门树结构信息 - * + * * @param dept 部门信息 * @return 部门树信息集合 */ @@ -29,7 +30,7 @@ public interface ISysDeptService /** * 构建前端所需要树结构 - * + * * @param depts 部门列表 * @return 树结构列表 */ @@ -37,7 +38,7 @@ public interface ISysDeptService /** * 构建前端所需要下拉树结构 - * + * * @param depts 部门列表 * @return 下拉树结构列表 */ @@ -45,7 +46,7 @@ public interface ISysDeptService /** * 根据角色ID查询部门树信息 - * + * * @param roleId 角色ID * @return 选中部门列表 */ @@ -53,7 +54,7 @@ public interface ISysDeptService /** * 根据部门ID查询信息 - * + * * @param deptId 部门ID * @return 部门信息 */ @@ -61,7 +62,7 @@ public interface ISysDeptService /** * 根据ID查询所有子部门(正常状态) - * + * * @param deptId 部门ID * @return 子部门数 */ @@ -69,7 +70,7 @@ public interface ISysDeptService /** * 是否存在部门子节点 - * + * * @param deptId 部门ID * @return 结果 */ @@ -77,7 +78,7 @@ public interface ISysDeptService /** * 查询部门是否存在用户 - * + * * @param deptId 部门ID * @return 结果 true 存在 false 不存在 */ @@ -86,7 +87,7 @@ public interface ISysDeptService public boolean checkCompaniesNameUnique(List list); /** * 校验部门名称是否唯一 - * + * * @param dept 部门信息 * @return 结果 */ @@ -94,7 +95,7 @@ public interface ISysDeptService /** * 校验部门是否有数据权限 - * + * * @param deptId 部门id */ public void checkDeptDataScope(Long deptId); @@ -103,7 +104,7 @@ public interface ISysDeptService /** * 新增保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -111,7 +112,7 @@ public interface ISysDeptService /** * 修改保存部门信息 - * + * * @param dept 部门信息 * @return 结果 */ @@ -119,11 +120,18 @@ public interface ISysDeptService /** * 删除部门管理信息 - * + * * @param deptId 部门ID * @return 结果 */ 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 e19a302..4f47607 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 @@ -16,7 +16,6 @@ import com.bonus.sgzb.system.mapper.SysDeptMapper; import com.bonus.sgzb.system.mapper.SysRoleMapper; import com.bonus.sgzb.system.mapper.SysUserMapper; import com.bonus.sgzb.system.service.ISysDeptService; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -316,6 +315,32 @@ 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 ed5c19a..7f37e6c 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 @@ -25,13 +25,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + select d.dept_id, d.parent_id, d.ancestors, d.dept_name, d.order_num, d.leader, d.phone, d.email, d.status, d.del_flag, d.create_by, d.create_time, d.remark,d.company_id,d.social_credit_code,d.enterprise_ownership_code from sys_dept d - + - + - + - + - + - + - + @@ -96,7 +96,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{item.deptName} - + - \ No newline at end of file + +