机构删除修改

This commit is contained in:
zhangheng 2024-02-27 15:29:54 +08:00
parent df838d2b3b
commit ff2adb4396
5 changed files with 26 additions and 4 deletions

View File

@ -90,7 +90,7 @@ public class AgencyController extends BaseController {
@Log(title = "机构信息", businessType = BusinessType.DELETE) @Log(title = "机构信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids) { public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(agencyService.deleteAgencyByIds(ids)); return agencyService.deleteAgencyByIds(ids);
} }
/** /**

View File

@ -22,6 +22,14 @@ public interface AgencyMapper {
*/ */
Agency selectAgencyById(Long id); Agency selectAgencyById(Long id);
/**
* 查询下级机构信息
*
* @param id 机构信息主键
* @return 机构信息
*/
List<Agency> selectSubordinateAgencyById(Long[] id);
/** /**
* 查询机构信息 * 查询机构信息
* *

View File

@ -53,7 +53,7 @@ public interface IAgencyService {
* @param ids 需要删除的机构信息主键集合 * @param ids 需要删除的机构信息主键集合
* @return 结果 * @return 结果
*/ */
int deleteAgencyByIds(Long[] ids); AjaxResult deleteAgencyByIds(Long[] ids);
/** /**
* 删除机构信息信息 * 删除机构信息信息

View File

@ -73,6 +73,7 @@ public class AgencyServiceImpl implements IAgencyService {
@Override @Override
public int insertAgency(Agency agency) { public int insertAgency(Agency agency) {
agency.setCreateTime(DateUtils.getNowDate()); agency.setCreateTime(DateUtils.getNowDate());
agency.setCreateBy(SecurityUtils.getUsername());
return agencyMapper.insertAgency(agency); return agencyMapper.insertAgency(agency);
} }
@ -85,6 +86,7 @@ public class AgencyServiceImpl implements IAgencyService {
@Override @Override
public int updateAgency(Agency agency) { public int updateAgency(Agency agency) {
agency.setUpdateTime(DateUtils.getNowDate()); agency.setUpdateTime(DateUtils.getNowDate());
agency.setUpdateBy(SecurityUtils.getUsername());
return agencyMapper.updateAgency(agency); return agencyMapper.updateAgency(agency);
} }
@ -95,8 +97,12 @@ public class AgencyServiceImpl implements IAgencyService {
* @return 结果 * @return 结果
*/ */
@Override @Override
public int deleteAgencyByIds(Long[] ids) { public AjaxResult deleteAgencyByIds(Long[] ids) {
return agencyMapper.deleteAgencyByIds(ids); int size = agencyMapper.selectSubordinateAgencyById(ids).size();
if (size > 0) {
return AjaxResult.error("该机构存在下级机构,请先删除其下级机构!");
}
return AjaxResult.success(agencyMapper.deleteAgencyByIds(ids));
} }
/** /**

View File

@ -122,6 +122,14 @@
where id = #{id} where id = #{id}
</select> </select>
<select id="selectSubordinateAgencyById" resultType="com.xinelu.manage.domain.agency.Agency">
<include refid="selectAgencyVo"/>
where parent_id =
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</select>
<select id="selectAgencyVOById" resultType="com.xinelu.manage.vo.agency.AgencyVO"> <select id="selectAgencyVOById" resultType="com.xinelu.manage.vo.agency.AgencyVO">
select id, select id,
ay.parent_id, ay.parent_id,