mirror of
https://gitee.com/log4j/pig.git
synced 2024-12-23 05:00:23 +08:00
commit
27db1e75cb
@ -42,5 +42,16 @@ public interface SysDeptRelationMapper extends BaseMapper<SysDeptRelation> {
|
||||
* @param deptRelation
|
||||
*/
|
||||
void updateDeptRelations(SysDeptRelation deptRelation);
|
||||
/**
|
||||
* 删除部门关系
|
||||
* @param deptRelation
|
||||
*/
|
||||
void deleteDeptRelations(SysDeptRelation deptRelation);
|
||||
|
||||
/**
|
||||
* 新增部门关系
|
||||
* @param deptRelation
|
||||
*/
|
||||
void insertDeptRelations(SysDeptRelation deptRelation);
|
||||
|
||||
}
|
||||
|
@ -84,8 +84,10 @@ public class SysDeptRelationServiceImpl extends ServiceImpl<SysDeptRelationMappe
|
||||
* @param relation
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateDeptRelation(SysDeptRelation relation) {
|
||||
baseMapper.updateDeptRelations(relation);
|
||||
baseMapper.deleteDeptRelations(relation);
|
||||
baseMapper.insertDeptRelations(relation);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -28,7 +28,24 @@
|
||||
<sql id="Base_Column_List">
|
||||
ancestor, descendant
|
||||
</sql>
|
||||
|
||||
<!-- 删除机构关系 -->
|
||||
<delete id="deleteDeptRelations" >
|
||||
DELETE FROM sys_dept_relation
|
||||
WHERE
|
||||
descendant IN ( SELECT temp.descendant FROM
|
||||
( SELECT descendant FROM sys_dept_relation WHERE ancestor = #{descendant} ) temp )
|
||||
AND ancestor IN ( SELECT temp.ancestor FROM ( SELECT ancestor FROM
|
||||
sys_dept_relation WHERE descendant = #{descendant} AND ancestor != descendant ) temp )
|
||||
</delete>
|
||||
<!-- 新增机构关系 -->
|
||||
<insert id="insertDeptRelations">
|
||||
INSERT INTO sys_dept_relation (ancestor, descendant)
|
||||
SELECT a.ancestor, b.descendant
|
||||
FROM sys_dept_relation a
|
||||
CROSS JOIN sys_dept_relation b
|
||||
WHERE a.descendant = #{ancestor}
|
||||
AND b.ancestor = #{descendant}
|
||||
</insert>
|
||||
<!-- 更新部门关系 -->
|
||||
<update id="updateDeptRelations">
|
||||
DELETE FROM sys_dept_relation
|
||||
|
Loading…
Reference in New Issue
Block a user