yjwang пре 6 дана
родитељ
комит
004c2b98d6

+ 8 - 1
fs-service/src/main/java/com/fs/system/service/impl/SysDeptServiceImpl.java

@@ -27,6 +27,7 @@ import com.fs.common.utils.spring.SpringUtils;
 import com.fs.system.mapper.SysDeptMapper;
 import com.fs.system.mapper.SysRoleMapper;
 import com.fs.system.service.ISysDeptService;
+import org.springframework.transaction.annotation.Transactional;
 
 /**
  * 部门管理 服务实现
@@ -198,6 +199,7 @@ public class SysDeptServiceImpl implements ISysDeptService {
      * @return 结果
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public int insertDept(SysDept dept) {
         SysDept info = deptMapper.selectDeptById(dept.getParentId());
         // 如果父节点不为正常状态,则不允许新增子节点
@@ -205,7 +207,12 @@ public class SysDeptServiceImpl implements ISysDeptService {
             throw new ServiceException("部门停用,不允许新增");
         }
         dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
-        return deptMapper.insertDept(dept);
+        if(deptMapper.insertDept(dept) > 0){
+            SysDeptConfig config =new SysDeptConfig();
+            config.setDeptId(dept.getDeptId());
+            sysDeptConfigMapper.insertSysDeptConfig(config);
+        }
+        return 1;
     }
 
     /**

+ 1 - 1
fs-service/src/main/resources/mapper/system/SysDeptMapper.xml

@@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 		where dept_name=#{deptName} and parent_id = #{parentId} limit 1
 	</select>
     
-    <insert id="insertDept" parameterType="SysDept">
+    <insert id="insertDept" parameterType="SysDept" useGeneratedKeys="true" keyProperty="deptId">
  		insert into sys_dept(
  			<if test="deptId != null and deptId != 0">dept_id,</if>
  			<if test="parentId != null and parentId != 0">parent_id,</if>