Compare commits

...

2 Commits

Author SHA1 Message Date
031026 6cf79591f7 Merge remote-tracking branch 'origin/master' 2024-05-28 22:36:39 +08:00
031026 b7975ee9dd fix(重新搭建表,重构代码) 2024-05-28 22:36:24 +08:00
15 changed files with 259 additions and 601 deletions

View File

@ -0,0 +1,48 @@
package com.muyu.company.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName Authentication
* @Author AnNan.Wang
* @Date 2024/5/28 21:12
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("authentication")
@EqualsAndHashCode(callSuper = true)
public class Authentication extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
*
*/
private String auditor;
/**
* ,,
*/
private String stat;
/**
*
*/
private String auditReason;
}

View File

@ -1,20 +1,15 @@
package com.muyu.company.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.company.domain.vo.CompanyVo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.io.Serial;
import java.util.Date;
/**
@ -27,71 +22,67 @@ import java.util.Date;
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("company")
@EqualsAndHashCode(callSuper = true)
public class Company extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 主键 */
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/** 企业名称 */
@Excel(name = "企业名称")
/**
*
*/
private String companyName;
/** 法定代表人 */
@Excel(name = "法定代表人")
/**
*
*/
private String legalRepresentative;
/** 企业成立时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "企业成立时间", width = 30, dateFormat = "yyyy-MM-dd")
/**
*
*/
private String businessLicenseNumber;
/**
*
*/
private Date companyTime;
/** 业务范围 */
@Excel(name = "业务范围")
/**
*
*/
private String sphereOfBusiness;
/** 注册地址 */
@Excel(name = "注册地址")
/**
*
*/
private String registeredAddress;
/** 企业联系电话 */
@Excel(name = "企业联系电话")
/**
*
*/
private String companyPhone;
/** 公司邮箱 */
@Excel(name = "公司邮箱")
/**
*
*/
private String companyMailbox;
/** 公司营业执照 */
@Excel(name = "公司营业执照")
private String businessLicense;
/** 税务登记证 */
@Excel(name = "税务登记证")
private String taxRegistrationCertificate;
/** 企业状态 */
@Excel(name = "企业状态")
/**
* ,,,
*/
private String companyStatus;
/** 企业入驻时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "企业入驻时间", width = 30, dateFormat = "yyyy-MM-dd")
/**
*
*/
private Date enterTime;
/** 是否认证 */
@Excel(name = "是否认证")
private String isAuthentication;
/** 认证时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "认证时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date authenticationTime;
/** 服务等级 */
@Excel(name = "服务等级")
private Long serviceLevel;
/**
*
*/
private Long authenticationId;
/**
*
*/
private Long liberalServiceId;
/**
*
*/
private Long appreciationServiceId;
}

View File

@ -0,0 +1,41 @@
package com.muyu.company.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName Liberal
* @Author AnNan.Wang
* @Date 2024/5/28 21:31
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("liberal")
@EqualsAndHashCode(callSuper = true)
public class Liberal extends BaseEntity {
private static final long serialVersionUID =1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
* 1 2
*/
private String activateTheService;
}

View File

@ -0,0 +1,48 @@
package com.muyu.company.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName Pay
* @Author AnNan.Wang
* @Date 2024/5/28 21:33
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("pay")
@EqualsAndHashCode(callSuper = true)
public class Pay extends BaseEntity {
private static final long serialVersionUID =1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
*
*/
private Long companyId;
/**
*
*/
private Long paymentId;
/**
*
*/
private Double appreciationDecimal;
}

View File

@ -0,0 +1,39 @@
package com.muyu.company.domain;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
/**
*
*
* @ClassName Payment
* @Author AnNan.Wang
* @Date 2024/5/28 21:51
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("payment")
@EqualsAndHashCode(callSuper = true)
public class Payment extends BaseEntity {
private static final long serialVersionUID =1L;
/**
*
*/
@TableId(value = "id",type = IdType.AUTO)
private Long id;
/**
*
*/
private String payment;
}

View File

@ -1,30 +0,0 @@
package com.muyu.company.domain.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
/**
* company company
*
* @author wan
* @date 2024-05-26
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
public class CompanyVo
{
private String deptName;
private String roleKey;
}

View File

@ -12,6 +12,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
* @author muyu
*/
@EnableCustomConfig
@EnableCustomSwagger2
@EnableMyFeignClients
@SpringBootApplication
public class MuYuCompanyApplication {

View File

@ -1,86 +0,0 @@
package com.muyu.company.controller;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.core.web.page.TableDataInfo;
import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.company.domain.Company;
import com.muyu.company.domain.vo.CompanyVo;
import com.muyu.company.service.ICompanyService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* companyController
*
* @author wan
* @date 2024-05-26
*/
@RestController
@RequestMapping("/company")
public class CompanyController extends BaseController
{
@Autowired
private ICompanyService companyService;
/**
* company
*/
@ApiOperation("获取企业列表")
@RequiresPermissions("company:company:list")
@GetMapping("/list")
public Result<TableDataInfo<Company>> list(CompanyVo company){
startPage();
System.out.println(company);
List<Company> list = companyService.selectCompanyList(company);
return getDataTable(list);
}
/**
* company
*/
@RequiresPermissions("company:company:query")
@GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id)
{
return success(companyService.selectCompanyById(id));
}
/**
* company
*/
@RequiresPermissions("company:company:add")
@Log(title = "company", businessType = BusinessType.INSERT)
@PostMapping
public Result add(@RequestBody Company company)
{
return toAjax(companyService.insertCompany(company));
}
/**
* company
*/
@RequiresPermissions("company:company:edit")
@Log(title = "company", businessType = BusinessType.UPDATE)
@PutMapping
public Result edit(@RequestBody Company company)
{
return toAjax(companyService.updateCompany(company));
}
/**
* company
*/
@RequiresPermissions("company:company:remove")
@Log(title = "company", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids)
{
return toAjax(companyService.deleteCompanyByIds(ids));
}
}

View File

@ -1,63 +0,0 @@
package com.muyu.company.mapper;
import com.muyu.company.domain.Company;
import com.muyu.company.domain.vo.CompanyVo;
import java.util.List;
/**
* companyMapper
*
* @author wan
* @date 2024-05-26
*/
public interface CompanyMapper
{
/**
* company
*
* @param id company
* @return company
*/
public Company selectCompanyById(Long id);
/**
* company
*
* @param company company
* @return company
*/
public List<Company> selectCompanyList(CompanyVo company);
/**
* company
*
* @param company company
* @return
*/
public int insertCompany(Company company);
/**
* company
*
* @param company company
* @return
*/
public int updateCompany(Company company);
/**
* company
*
* @param id company
* @return
*/
public int deleteCompanyById(Long id);
/**
* company
*
* @param ids
* @return
*/
public int deleteCompanyByIds(Long[] ids);
}

View File

@ -1,63 +0,0 @@
package com.muyu.company.service;
import com.muyu.company.domain.Company;
import com.muyu.company.domain.vo.CompanyVo;
import java.util.List;
/**
* companyService
*
* @author wan
* @date 2024-05-26
*/
public interface ICompanyService
{
/**
* company
*
* @param id company
* @return company
*/
public Company selectCompanyById(Long id);
/**
* company
*
* @param company company
* @return company
*/
public List<Company> selectCompanyList(CompanyVo company);
/**
* company
*
* @param company company
* @return
*/
public int insertCompany(Company company);
/**
* company
*
* @param company company
* @return
*/
public int updateCompany(Company company);
/**
* company
*
* @param ids company
* @return
*/
public int deleteCompanyByIds(Long[] ids);
/**
* company
*
* @param id company
* @return
*/
public int deleteCompanyById(Long id);
}

View File

@ -1,98 +0,0 @@
package com.muyu.company.service.impl;
import com.muyu.common.core.utils.DateUtils;
import com.muyu.company.domain.Company;
import com.muyu.company.domain.vo.CompanyVo;
import com.muyu.company.mapper.CompanyMapper;
import com.muyu.company.service.ICompanyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.List;
/**
* companyService
*
* @author wan
* @date 2024-05-26
*/
@Service
public class CompanyServiceImpl implements ICompanyService
{
@Autowired
private CompanyMapper companyMapper;
/**
* company
*
* @param id company
* @return company
*/
@Override
public Company selectCompanyById(Long id)
{
return companyMapper.selectCompanyById(id);
}
/**
* company
*
* @param company company
* @return company
*/
@Override
public List<Company> selectCompanyList(CompanyVo company)
{
return companyMapper.selectCompanyList(company);
}
/**
* company
*
* @param company company
* @return
*/
@Override
public int insertCompany(Company company)
{
return companyMapper.insertCompany(company);
}
/**
* company
*
* @param company company
* @return
*/
@Override
public int updateCompany(Company company)
{
company.setUpdateTime(DateUtils.getNowDate());
return companyMapper.updateCompany(company);
}
/**
* company
*
* @param ids company
* @return
*/
@Override
public int deleteCompanyByIds(Long[] ids)
{
return companyMapper.deleteCompanyByIds(ids);
}
/**
* company
*
* @param id company
* @return
*/
@Override
public int deleteCompanyById(Long id)
{
return companyMapper.deleteCompanyById(id);
}
}

View File

@ -1,115 +0,0 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.muyu.company.mapper.CompanyMapper">
<resultMap type="com.muyu.company.domain.Company" id="CompanyResult">
<result property="id" column="id" />
<result property="companyName" column="company_name" />
<result property="legalRepresentative" column="legal_representative" />
<result property="companyTime" column="company_time" />
<result property="sphereOfBusiness" column="sphere_of_business" />
<result property="registeredAddress" column="registered_address" />
<result property="companyPhone" column="company_phone" />
<result property="companyMailbox" column="company_mailbox" />
<result property="businessLicense" column="business_license" />
<result property="taxRegistrationCertificate" column="tax_registration_certificate" />
<result property="companyStatus" column="company_status" />
<result property="enterTime" column="enter_time" />
<result property="isAuthentication" column="is_authentication" />
<result property="authenticationTime" column="authentication_time" />
<result property="serviceLevel" column="service_level" />
<result property="remark" column="remark"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
</resultMap>
<sql id="selectCompanyVo">
select id, company_name, legal_representative, company_time, sphere_of_business, registered_address, company_phone, company_mailbox, business_license, tax_registration_certificate, company_status, enter_time, is_authentication, authentication_time, service_level, remark, create_by, create_time, update_by, update_time from company
</sql>
<select id="selectCompanyList" parameterType="com.muyu.company.domain.Company" resultMap="CompanyResult">
<include refid="selectCompanyVo"/>
<where>
<if test="roleKey != null and roleKey != '' and roleKey == 'common' || roleKey == 'employee'">
and company_name = #{deptName}
</if>
</where>
</select>
<select id="selectCompanyById" parameterType="Long" resultMap="CompanyResult">
<include refid="selectCompanyVo"/>
where id = #{id}
</select>
<insert id="insertCompany" parameterType="com.muyu.company.domain.Company" useGeneratedKeys="true" keyProperty="id">
insert into company
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="companyName != null">company_name,</if>
<if test="legalRepresentative != null">legal_representative,</if>
<if test="companyTime != null">company_time,</if>
<if test="sphereOfBusiness != null">sphere_of_business,</if>
<if test="registeredAddress != null">registered_address,</if>
<if test="companyPhone != null">company_phone,</if>
<if test="companyMailbox != null">company_mailbox,</if>
<if test="businessLicense != null">business_license,</if>
<if test="taxRegistrationCertificate != null">tax_registration_certificate,</if>
<if test="companyStatus != null">company_status,</if>
<if test="enterTime != null">enter_time,</if>
<if test="isAuthentication != null">is_authentication,</if>
<if test="authenticationTime != null">authentication_time,</if>
<if test="serviceLevel != null">service_level,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="companyName != null">#{companyName},</if>
<if test="legalRepresentative != null">#{legalRepresentative},</if>
<if test="companyTime != null">#{companyTime},</if>
<if test="sphereOfBusiness != null">#{sphereOfBusiness},</if>
<if test="registeredAddress != null">#{registeredAddress},</if>
<if test="companyPhone != null">#{companyPhone},</if>
<if test="companyMailbox != null">#{companyMailbox},</if>
<if test="businessLicense != null">#{businessLicense},</if>
<if test="taxRegistrationCertificate != null">#{taxRegistrationCertificate},</if>
<if test="companyStatus != null">#{companyStatus},</if>
<if test="enterTime != null">#{enterTime},</if>
<if test="isAuthentication != null">#{isAuthentication},</if>
<if test="authenticationTime != null">#{authenticationTime},</if>
<if test="serviceLevel != null">#{serviceLevel},</if>
</trim>
</insert>
<update id="updateCompany" parameterType="com.muyu.company.domain.Company">
update company
<trim prefix="SET" suffixOverrides=",">
<if test="companyName != null">company_name = #{companyName},</if>
<if test="legalRepresentative != null">legal_representative = #{legalRepresentative},</if>
<if test="companyTime != null">company_time = #{companyTime},</if>
<if test="sphereOfBusiness != null">sphere_of_business = #{sphereOfBusiness},</if>
<if test="registeredAddress != null">registered_address = #{registeredAddress},</if>
<if test="companyPhone != null">company_phone = #{companyPhone},</if>
<if test="companyMailbox != null">company_mailbox = #{companyMailbox},</if>
<if test="businessLicense != null">business_license = #{businessLicense},</if>
<if test="taxRegistrationCertificate != null">tax_registration_certificate = #{taxRegistrationCertificate},</if>
<if test="companyStatus != null">company_status = #{companyStatus},</if>
<if test="enterTime != null">enter_time = #{enterTime},</if>
<if test="isAuthentication != null">is_authentication = #{isAuthentication},</if>
<if test="authenticationTime != null">authentication_time = #{authenticationTime},</if>
<if test="serviceLevel != null">service_level = #{serviceLevel},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCompanyById" parameterType="Long">
delete from company where id = #{id}
</delete>
<delete id="deleteCompanyByIds" parameterType="String">
delete from company where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -82,25 +82,16 @@ public class SysDeptController extends BaseController {
@PutMapping
public Result edit (@Validated @RequestBody SysDept dept) {
if (dept.getParentId()==null) {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
}else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
return error("该部门包含未停用的子部门!");
}
}else {
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} else if (dept.getParentId().equals(deptId)) {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
return error("该部门包含未停用的子部门!");
}
Long deptId = dept.getDeptId();
deptService.checkDeptDataScope(deptId);
if (!deptService.checkDeptNameUnique(dept)) {
return error("修改部门'" + dept.getDeptName() + "'失败,部门名称已存在");
} else if (dept.getParentId().equals(deptId)) {
return error("修改部门'" + dept.getDeptName() + "'失败,上级部门不能是自己");
} else if (StringUtils.equals(UserConstants.DEPT_DISABLE, dept.getStatus()) && deptService.selectNormalChildrenDeptById(deptId) > 0) {
return error("该部门包含未停用的子部门!");
}
dept.setUpdateBy(SecurityUtils.getUsername());
return toAjax(deptService.updateDept(dept));
}

View File

@ -205,35 +205,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
*/
@Override
public int insertDept (SysDept dept) {
Long id = null;
if (dept.getParentId()==null) {
id =0L;
return deptMapper.insertDept(
SysDept.builder()
.deptId(null)
.parentId(id)
.ancestors(String.valueOf(id))
.deptName(dept.getDeptName())
.orderNum(dept.getOrderNum())
.leader(dept.getLeader())
.phone(dept.getPhone())
.email(dept.getEmail())
.status(dept.getStatus())
.delFlag(dept.getDelFlag())
.parentName(dept.getParentName())
.createBy(dept.getCreateBy())
.build()
);
}else {
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
SysDept info = deptMapper.selectDeptById(dept.getParentId());
// 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
throw new ServiceException("部门停用,不允许新增");
}
dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
return deptMapper.insertDept(dept);
}
/**
@ -245,45 +223,21 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
*/
@Override
public int updateDept (SysDept dept) {
Long id = null;
if (dept.getParentId() == null) {
id =0L;
dept.setUpdateBy(SecurityUtils.getUsername());
int result = deptMapper.updateDept(
SysDept.builder()
.deptId(dept.getDeptId())
.parentId(id)
.ancestors(String.valueOf(id))
.deptName(dept.getDeptName())
.orderNum(dept.getOrderNum())
.leader(dept.getLeader())
.phone(dept.getPhone())
.email(dept.getEmail())
.status(dept.getStatus())
.delFlag(dept.getDelFlag())
.parentName(dept.getParentName())
.updateBy(dept.getUpdateBy())
.build()
);
return result;
}else {
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
return result;
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors);
updateDeptChildren(dept.getDeptId(), newAncestors, oldAncestors);
}
int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) {
// 如果该部门是启用状态,则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept);
}
return result;
}
/**

View File

@ -112,7 +112,7 @@
<insert id="insertDept" parameterType="com.muyu.common.system.domain.SysDept">
insert into sys_dept(
<if test="deptId != null and deptId != 0">dept_id,</if>
<if test="parentId != null">parent_id,</if>
<if test="parentId != null and parentId != 0">parent_id,</if>
<if test="deptName != null and deptName != ''">dept_name,</if>
<if test="ancestors != null and ancestors != ''">ancestors,</if>
<if test="orderNum != null">order_num,</if>
@ -124,7 +124,7 @@
create_time
)values(
<if test="deptId != null and deptId != 0">#{deptId},</if>
<if test="parentId != null">#{parentId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="deptName != null and deptName != ''">#{deptName},</if>
<if test="ancestors != null and ancestors != ''">#{ancestors},</if>
<if test="orderNum != null">#{orderNum},</if>
@ -140,7 +140,7 @@
<update id="updateDept" parameterType="com.muyu.common.system.domain.SysDept">
update sys_dept
<set>
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="parentId != null and parentId != 0">parent_id = #{parentId},</if>
<if test="deptName != null and deptName != ''">dept_name = #{deptName},</if>
<if test="ancestors != null and ancestors != ''">ancestors = #{ancestors},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>