Переглянути джерело

装置信息 - 装置数据隔离

wangggziwen 8 місяців тому
батько
коміт
ac6f6db3fd

+ 2 - 2
rc-admin/src/main/java/com/ruoyi/web/controller/rc/TDeptInfoController.java

@@ -51,7 +51,7 @@ public class TDeptInfoController extends BaseController
         startPage();
         List<TDeptInfo> list = tDeptInfoService.selectTDeptInfoList(tDeptInfo);
         for (TDeptInfo obj : list) {
-            String deptId = obj.getDeptId();
+            String deptId = obj.getDeptId().toString();
             if (StringUtils.isNotEmpty(deptId)) {
                 if (deptId.indexOf(",") != -1) {
                     StringBuffer sb = new StringBuffer();
@@ -112,7 +112,7 @@ public class TDeptInfoController extends BaseController
     public AjaxResult add(@RequestBody TDeptInfo tDeptInfo)
     {
         if (StringUtils.isNull(tDeptInfo.getDeptId()) || "".equals(tDeptInfo.getDeptId())) {
-            tDeptInfo.setDeptId(getLoginUser().getDeptId().toString());
+            tDeptInfo.setDeptId(getLoginUser().getDeptId());
         }
         return toAjax(tDeptInfoService.insertTDeptInfo(tDeptInfo));
     }

+ 3 - 3
rc-buisness/src/main/java/com/ruoyi/rc/domain/TDeptInfo.java

@@ -33,7 +33,7 @@ public class TDeptInfo extends BaseEntity
     private String deptInfo;
 
     /** 装置id */
-    private String deptId;
+    private Long deptId;
 
     public String getDeptName() {
         return deptName;
@@ -61,12 +61,12 @@ public class TDeptInfo extends BaseEntity
     {
         return deptInfo;
     }
-    public void setDeptId(String deptId)
+    public void setDeptId(Long deptId)
     {
         this.deptId = deptId;
     }
 
-    public String getDeptId()
+    public Long getDeptId()
     {
         return deptId;
     }

+ 3 - 0
rc-buisness/src/main/java/com/ruoyi/rc/service/impl/TDeptInfoServiceImpl.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.TDeptInfoMapper;
@@ -38,6 +40,7 @@ public class TDeptInfoServiceImpl implements ITDeptInfoService
      * @return 装置信息
      */
     @Override
+    @DataScope(deptAlias = "d")
     public List<TDeptInfo> selectTDeptInfoList(TDeptInfo tDeptInfo)
     {
         return tDeptInfoMapper.selectTDeptInfoList(tDeptInfo);

+ 9 - 9
rc-buisness/src/main/resources/mapper/rc/TDeptInfoMapper.xml

@@ -13,23 +13,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectTDeptInfoVo">
-        select d.id, d.dept_info, d.dept_id, sd.dept_name , d.year from t_dept_info d
-        left join sys_dept sd on d.dept_id = sd.dept_id
+        select i.id, i.dept_info, i.dept_id, d.dept_name , i.year from t_dept_info i
+        left join sys_dept d on i.dept_id = d.dept_id
     </sql>
 
     <select id="selectTDeptInfoList" parameterType="TDeptInfo" resultMap="TDeptInfoResult">
         <include refid="selectTDeptInfoVo"/>
         <where>
-            <if test="year != null  and year != ''"> and d.year = #{year}</if>
-
-            <if test="deptInfo != null  and deptInfo != ''"> and d.dept_info = #{deptInfo}</if>
-            <if test="deptId != null "> and d.dept_id like concat(concat('%', #{deptId}), '%')</if>
+            <if test="year != null  and year != ''"> and i.year = #{year}</if>
+            <if test="deptInfo != null  and deptInfo != ''"> and i.dept_info = #{deptInfo}</if>
+            <if test="deptId != null "> and i.dept_id like concat(concat('%', #{deptId}), '%')</if>
+            ${params.dataScope}
         </where>
     </select>
     
     <select id="selectTDeptInfoById" parameterType="Long" resultMap="TDeptInfoResult">
         <include refid="selectTDeptInfoVo"/>
-        where d.id = #{id}
+        where i.id = #{id}
     </select>
 
     <insert id="insertTDeptInfo" parameterType="TDeptInfo" useGeneratedKeys="true" keyProperty="id">
@@ -57,11 +57,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
 
     <delete id="deleteTDeptInfoById" parameterType="Long">
-        delete from t_dept_info where d.id = #{id}
+        delete from t_dept_info where id = #{id}
     </delete>
 
     <delete id="deleteTDeptInfoByIds" parameterType="String">
-        delete from t_dept_info where d.id in
+        delete from t_dept_info where id in
         <foreach item="id" collection="array" open="(" separator="," close=")">
             #{id}
         </foreach>

+ 1 - 0
ruoyi-ui/src/views/rc/deptinfo/index.vue

@@ -413,6 +413,7 @@ export default {
       const id = row.id || this.ids
       getDeptinfo(id).then(response => {
         this.form = response.data;
+        this.form.deptId = this.form.deptId + "";
         this.open = true;
         this.title = "修改装置信息";
       });