Ver código fonte

问卷管理 - 章节模板数据隔离

wangggziwen 8 meses atrás
pai
commit
b5cd698278

+ 3 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/impl/TChapterTemplateServiceImpl.java

@@ -1,6 +1,8 @@
 package com.ruoyi.rc.service.impl;
 
 import java.util.List;
+
+import com.ruoyi.common.annotation.DataScope;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import com.ruoyi.rc.mapper.TChapterTemplateMapper;
@@ -42,6 +44,7 @@ public class TChapterTemplateServiceImpl implements ITChapterTemplateService
      * @return 章节模板
      */
     @Override
+    @DataScope(deptAlias = "d")
     public List<TChapterTemplate> selectTChapterTemplateList(TChapterTemplate tChapterTemplate)
     {
         return tChapterTemplateMapper.selectTChapterTemplateList(tChapterTemplate);

+ 8 - 6
rc-buisness/src/main/resources/mapper/rc/TChapterTemplateMapper.xml

@@ -12,17 +12,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTChapterTemplateVo">
-        select id, code, name, dept_id, IF(INSTR(code, '.') > 0, SUBSTR(code, 1, INSTR(code, '.') - 1), code) as codeSubStr from t_chapter_template
+        select ct.id, ct.code, ct.name, ct.dept_id, IF(INSTR(ct.code, '.') > 0, SUBSTR(ct.code, 1, INSTR(ct.code, '.') - 1), ct.code) as codeSubStr from t_chapter_template ct
+        left join sys_dept d on d.dept_id = ct.dept_id
     </sql>
 
     <select id="selectTChapterTemplateList" parameterType="TChapterTemplate" resultMap="TChapterTemplateResult">
         <include refid="selectTChapterTemplateVo"/>
         <where>  
-            <if test="code != null  and code != ''"> and code = #{code}</if>
-            <if test="name != null  and name != ''"> and name like concat('%', #{name}, '%')</if>
-            <if test="deptId != null  and deptId != ''"> and dept_id = #{deptId}</if>
+            <if test="code != null  and code != ''"> and ct.code = #{code}</if>
+            <if test="name != null  and name != ''"> and ct.name like concat('%', #{name}, '%')</if>
+            <if test="deptId != null  and deptId != ''"> and ct.dept_id = #{deptId}</if>
+            ${params.dataScope}
         </where>
-        order by (IF(INSTR(code, '.') > 0, SUBSTR(code, 1, INSTR(code, '.') - 1), code) + 0) asc, code asc
+        order by (IF(INSTR(ct.code, '.') > 0, SUBSTR(ct.code, 1, INSTR(ct.code, '.') - 1), ct.code) + 0) asc, ct.code asc
     </select>
 
     <select id="selectNameByCode" parameterType="String" resultType="String">
@@ -31,7 +33,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     
     <select id="selectTChapterTemplateById" parameterType="Long" resultMap="TChapterTemplateResult">
         <include refid="selectTChapterTemplateVo"/>
-        where id = #{id}
+        where ct.id = #{id}
     </select>
 
     <insert id="insertTChapterTemplate" parameterType="TChapterTemplate" useGeneratedKeys="true" keyProperty="id">