This commit is contained in:
yinjinlu-pc\尹金路 2025-02-06 11:43:34 +08:00
commit cb3f288512
7 changed files with 50 additions and 4 deletions

View File

@ -116,8 +116,9 @@ public class SysDeptController extends BaseController
{ {
return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return AjaxResult.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} }
String s = autoCodeUtil.genSerialCode("DEPT_CODE", null); if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptCodeUnique(dept))) {
dept.setDeptCode(s); return AjaxResult.error("新增部门'" + dept.getDeptCode() + "'失败,部门编码已存在");
}
dept.setCreateBy(getUsername()); dept.setCreateBy(getUsername());
return toAjax(deptService.insertDept(dept)); return toAjax(deptService.insertDept(dept));
} }
@ -132,6 +133,9 @@ public class SysDeptController extends BaseController
{ {
Long deptId = dept.getDeptId(); Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId); deptService.checkDeptDataScope(deptId);
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptCodeUnique(dept))) {
return AjaxResult.error("新增部门'" + dept.getDeptCode() + "'失败,部门编码已存在");
}
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept)))
{ {
return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在"); return AjaxResult.error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");

View File

@ -35,6 +35,9 @@ public class MdWorkshop extends BaseEntity
@Excel(name = "负责人") @Excel(name = "负责人")
private String charge; private String charge;
/** 负责人id */
private Long chargeId;
/** 是否启用 */ /** 是否启用 */
@Excel(name = "是否启用") @Excel(name = "是否启用")
private String enableFlag; private String enableFlag;
@ -51,6 +54,14 @@ public class MdWorkshop extends BaseEntity
/** 预留字段4 */ /** 预留字段4 */
private Long attr4; private Long attr4;
public Long getChargeId() {
return chargeId;
}
public void setChargeId(Long chargeId) {
this.chargeId = chargeId;
}
public void setWorkshopId(Long workshopId) public void setWorkshopId(Long workshopId)
{ {
this.workshopId = workshopId; this.workshopId = workshopId;
@ -150,6 +161,7 @@ public class MdWorkshop extends BaseEntity
.append("workshopName", getWorkshopName()) .append("workshopName", getWorkshopName())
.append("area", getArea()) .append("area", getArea())
.append("charge", getCharge()) .append("charge", getCharge())
.append("chargeId", getChargeId())
.append("enableFlag", getEnableFlag()) .append("enableFlag", getEnableFlag())
.append("remark", getRemark()) .append("remark", getRemark())
.append("attr1", getAttr1()) .append("attr1", getAttr1())

View File

@ -23,7 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectMdWorkshopVo"> <sql id="selectMdWorkshopVo">
select workshop_id, workshop_code, workshop_name, area, charge, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from md_workshop select workshop_id, workshop_code, workshop_name, area, charge, charge_id, enable_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from md_workshop
</sql> </sql>
<select id="selectMdWorkshopList" parameterType="MdWorkshop" resultMap="MdWorkshopResult"> <select id="selectMdWorkshopList" parameterType="MdWorkshop" resultMap="MdWorkshopResult">

View File

@ -121,4 +121,11 @@ public interface SysDeptMapper
* @return * @return
*/ */
List<SysDept> selectAllDeptList(); List<SysDept> selectAllDeptList();
/**
* 校验部门编码是否唯一
* @param deptCode
* @return
*/
SysDept checkDeptCodeUnique(@Param("deptCode") String deptCode);
} }

View File

@ -119,4 +119,11 @@ public interface ISysDeptService
* @return * @return
*/ */
List<SysDept> selectAllDeptList(); List<SysDept> selectAllDeptList();
/**
* 校验部门编码是否唯一
* @param dept
* @return
*/
String checkDeptCodeUnique(SysDept dept);
} }

View File

@ -289,6 +289,17 @@ public class SysDeptServiceImpl implements ISysDeptService
return deptMapper.selectAllDeptList(); return deptMapper.selectAllDeptList();
} }
@Override
public String checkDeptCodeUnique(SysDept dept) {
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptCodeUnique(dept.getDeptCode());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue())
{
return UserConstants.NOT_UNIQUE;
}
return UserConstants.UNIQUE;
}
/** /**
* 递归列表 * 递归列表
*/ */

View File

@ -88,6 +88,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectAllDeptList" resultType="com.ktg.common.core.domain.entity.SysDept" resultMap="SysDeptResult"> <select id="selectAllDeptList" resultType="com.ktg.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/> <include refid="selectDeptVo"/>
</select> </select>
<select id="checkDeptCodeUnique" resultType="com.ktg.common.core.domain.entity.SysDept" resultMap="SysDeptResult">
<include refid="selectDeptVo"/>
where dept_code = #{deptCode}
limit 1
</select>
<insert id="insertDept" parameterType="SysDept"> <insert id="insertDept" parameterType="SysDept">
insert into sys_dept( insert into sys_dept(