Эх сурвалжийг харах

* 增加数据权限功能

chen.cheng 10 сар өмнө
parent
commit
ee7d02832f

+ 3 - 0
ruoyi-admin/src/main/resources/application-druid.yml

@@ -84,3 +84,6 @@ spring:
 wechat:
   appid: wxf385eefdd03327fd
   app-secret: 7bca97ad298a17539c7c75a5bf337063
+app:
+  cfg:
+    role-top-dept-id: 201

+ 3 - 0
ruoyi-admin/src/main/resources/application-hm.yml

@@ -84,3 +84,6 @@ spring:
 wechat:
   appid: wxf385eefdd03327fd
   app-secret: 7bca97ad298a17539c7c75a5bf337063
+app:
+  cfg:
+    role-top-dept-id: 201

+ 3 - 0
ruoyi-admin/src/main/resources/application-prod.yml

@@ -84,3 +84,6 @@ spring:
 wechat:
   appid: wxf385eefdd03327fd
   app-secret: 7bca97ad298a17539c7c75a5bf337063
+app:
+  cfg:
+    role-top-dept-id: 201

+ 3 - 0
ruoyi-admin/src/main/resources/application-test.yml

@@ -84,3 +84,6 @@ spring:
 wechat:
   appid: wxf385eefdd03327fd
   app-secret: 7bca97ad298a17539c7c75a5bf337063
+app:
+  cfg:
+    role-top-dept-id: 201

+ 1 - 0
ruoyi-admin/src/main/resources/application.yml

@@ -117,3 +117,4 @@ xss:
   excludes: /system/notice
   # 匹配链接
   urlPatterns: /system/*,/monitor/*,/tool/*
+

+ 18 - 0
ruoyi-common/src/main/java/com/ruoyi/common/config/AppCfg.java

@@ -0,0 +1,18 @@
+package com.ruoyi.common.config;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+import org.springframework.context.annotation.Configuration;
+
+@Configuration
+@ConfigurationProperties(prefix = "app.cfg")
+public class AppCfg {
+    private String roleTopDeptId;
+
+    public String getRoleTopDeptId() {
+        return roleTopDeptId;
+    }
+
+    public void setRoleTopDeptId(String roleTopDeptId) {
+        this.roleTopDeptId = roleTopDeptId;
+    }
+}

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsContentInfo.java

@@ -38,6 +38,8 @@ public class CpsContentInfo extends BaseEntity
     @Excel(name = "收藏数")
     private Integer collectedCnt;
 
+    private String deptId;
+
 
     public void setId(Long id)
     {
@@ -105,6 +107,14 @@ public class CpsContentInfo extends BaseEntity
         this.collectedCnt = collectedCnt;
     }
 
+    public String getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(String deptId) {
+        this.deptId = deptId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 10 - 0
ruoyi-system/src/main/java/com/ruoyi/system/domain/CpsUsrApply.java

@@ -69,6 +69,8 @@ public class CpsUsrApply extends BaseEntity
     @Excel(name = "与会内容")
     private String contentTitle;
 
+    private String deptId;
+
     private CpsContentInfo content;
 
     public void setId(Long id)
@@ -215,6 +217,14 @@ public class CpsUsrApply extends BaseEntity
         this.contentTitle = contentTitle;
     }
 
+    public String getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(String deptId) {
+        this.deptId = deptId;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 9 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsMeetingUsrServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.impl;
 
+import com.ruoyi.common.config.AppCfg;
 import com.ruoyi.common.core.domain.model.LoginUser;
 import com.ruoyi.common.core.domain.model.WeChatUser;
 import com.ruoyi.common.enums.MeetingType;
@@ -54,6 +55,9 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
     @Autowired
     private ScheduledExecutorService executor;
 
+    @Autowired
+    private AppCfg appCfg;
+
     /**
      * 查询cps_usr_wechat微信用户
      *
@@ -159,6 +163,8 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
         user.setReviewMsg("");
         WeChatUser loginUser = (WeChatUser)SecurityUtils.getLoginUser();
         user.setUpdateBy(loginUser.getOpenid());
+        CpsContentInfo cpsContentInfo = contentInfoMapper.selectCpsContentInfoById(user.getContentId());
+        user.setDeptId(cpsContentInfo.getDeptId());
         cpsUsrApplyMapper.insertCpsUsrApplyOrUpdate(user);
     }
 
@@ -197,16 +203,19 @@ public class CpsMeetingUsrServiceImpl implements ICpsMeetingUsrService {
             user.setContentTitle(cpsContentInfo.getTitle());
             user.setApplyType(MeetingType.CONFERENCE.getCode());
             user.setConferenceFlag(SysYesNo.NO.getCode());
+            user.setDeptId(cpsContentInfo.getDeptId());
             cpsUsrApplyMapper.insertCpsUsrApplyOrUpdate(user);
             user.setConferenceFlag(SysYesNo.YES.getCode());
             user.setApplyType(MeetingType.MEETING.getCode());
             user.setConferenceRel(user.getId());
+            user.setDeptId(appCfg.getRoleTopDeptId());
             cpsUsrApplyMapper.insertCpsUsrApplyOrUpdate(user);
             return;
         }
         user.setApplyType(MeetingType.MEETING.getCode());
         user.setConferenceRel(null);
         user.setReviewMsg("");
+        user.setDeptId(appCfg.getRoleTopDeptId());
         cpsUsrApplyMapper.insertCpsUsrApplyOrUpdate(user);
     }
 

+ 2 - 0
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/CpsUsrApplyServiceImpl.java

@@ -1,5 +1,6 @@
 package com.ruoyi.system.service.impl;
 
+import com.ruoyi.common.annotation.DataScope;
 import com.ruoyi.common.core.domain.model.WeChatUser;
 import com.ruoyi.common.enums.MeetingType;
 import com.ruoyi.common.enums.ReviewStatus;
@@ -80,6 +81,7 @@ public class CpsUsrApplyServiceImpl implements ICpsUsrApplyService {
      * @return cps_usr_apply与会申请
      */
     @Override
+    @DataScope(deptAlias = "usrApply")
     public List<CpsUsrApply> selectCpsUsrApplyList(CpsUsrApply cpsUsrApply) {
         return cpsUsrApplyMapper.selectCpsUsrApplyList(cpsUsrApply);
     }

+ 49 - 26
ruoyi-system/src/main/resources/mapper/cp/CpsContentInfoMapper.xml

@@ -1,33 +1,48 @@
 <?xml version="1.0" encoding="UTF-8" ?>
 <!DOCTYPE mapper
-PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
-"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.ruoyi.system.mapper.CpsContentInfoMapper">
 
     <resultMap type="com.ruoyi.system.domain.CpsContentInfo" id="CpsContentInfoResult">
-        <result property="id"    column="id"    />
-        <result property="title"    column="title"    />
-        <result property="content"    column="content"    />
-        <result property="thumbnail"    column="thumbnail"    />
-        <result property="likeCnt"    column="like_cnt"    />
-        <result property="collectedCnt"    column="collected_cnt"    />
-        <result property="contentType"    column="content_type"    />
-        <result property="updateTime"    column="update_time"    />
-        <result property="createTime"    column="create_time"    />
-        <result property="createBy"    column="create_by"    />
-        <result property="updateBy"    column="update_by"    />
+        <result property="id" column="id"/>
+        <result property="title" column="title"/>
+        <result property="content" column="content"/>
+        <result property="thumbnail" column="thumbnail"/>
+        <result property="likeCnt" column="like_cnt"/>
+        <result property="collectedCnt" column="collected_cnt"/>
+        <result property="contentType" column="content_type"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateBy" column="update_by"/>
     </resultMap>
 
     <sql id="selectCpsContentInfoVo">
-        select id, title, content, thumbnail, content_type,like_cnt, collected_cnt, update_time, create_time, create_by, update_by from cps_content_info
+        select id,
+               title,
+               content,
+               thumbnail,
+               content_type,
+               like_cnt,
+               collected_cnt,
+               dept_id,
+               update_time,
+               create_time,
+               create_by,
+               update_by
+        from cps_content_info
     </sql>
 
-    <select id="selectCpsContentInfoList" parameterType="com.ruoyi.system.domain.CpsContentInfo" resultMap="CpsContentInfoResult">
-        select id, title, thumbnail, content_type,like_cnt, collected_cnt, update_time, create_time, create_by, update_by from cps_content_info
+    <select id="selectCpsContentInfoList" parameterType="com.ruoyi.system.domain.CpsContentInfo"
+            resultMap="CpsContentInfoResult">
+        select id, title, thumbnail, content_type,like_cnt, collected_cnt,dept_id, update_time, create_time, create_by,
+        update_by from cps_content_info
         <where>
-            <if test="title != null  and title != ''"> and title like concat('%', #{title}, '%')</if>
-            <if test="content != null  and content != ''"> and content like concat('%', #{content}, '%')</if>
-            <if test="contentType != null "> and content_type = #{contentType}</if>
+            <if test="title != null  and title != ''">and title like concat('%', #{title}, '%')</if>
+            <if test="content != null  and content != ''">and content like concat('%', #{content}, '%')</if>
+            <if test="contentType != null ">and content_type = #{contentType}</if>
         </where>
         order by create_time desc
     </select>
@@ -37,28 +52,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
-    <insert id="insertCpsContentInfo" parameterType="com.ruoyi.system.domain.CpsContentInfo" useGeneratedKeys="true" keyProperty="id">
+    <insert id="insertCpsContentInfo" parameterType="com.ruoyi.system.domain.CpsContentInfo" useGeneratedKeys="true"
+            keyProperty="id">
         insert into cps_content_info
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="title != null">title,</if>
             <if test="content != null">content,</if>
             <if test="thumbnail != null">thumbnail,</if>
             <if test="contentType != null">content_type,</if>
+            <if test="dept_id !=null">dept_id,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
-         </trim>
+        </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="title != null">#{title},</if>
             <if test="content != null">#{content},</if>
             <if test="thumbnail != null">#{thumbnail},</if>
             <if test="contentType != null">#{contentType},</if>
+            <if test="dept_id !=null">#{dept_id},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
-         </trim>
+        </trim>
     </insert>
 
     <update id="updateCpsContentInfo" parameterType="com.ruoyi.system.domain.CpsContentInfo">
@@ -68,6 +86,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="content != null">content = #{content},</if>
             <if test="thumbnail != null">thumbnail = #{thumbnail},</if>
             <if test="contentType != null">content_type = #{contentType},</if>
+            <if test="deptId !=null">dept_id = #{deptId},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
@@ -83,24 +102,28 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </update>
     <update id="updateDisCollectContent" parameterType="java.lang.Long">
         update cps_content_info
-        set collected_cnt = collected_cnt -1,
+        set collected_cnt = collected_cnt - 1,
             update_time   = now()
         where id = #{id}
     </update>
     <update id="updateLikeContent" parameterType="java.lang.Long">
         update cps_content_info
-        set like_cnt = like_cnt + 1, update_time = now()
+        set like_cnt    = like_cnt + 1,
+            update_time = now()
         where id = #{id}
     </update>
 
     <update id="updateDisLikeContent" parameterType="java.lang.Long">
         update cps_content_info
-        set like_cnt = like_cnt -1, update_time = now()
+        set like_cnt    = like_cnt - 1,
+            update_time = now()
         where id = #{id}
     </update>
 
     <delete id="deleteCpsContentInfoById" parameterType="Long">
-        delete from cps_content_info where id = #{id}
+        delete
+        from cps_content_info
+        where id = #{id}
     </delete>
 
     <delete id="deleteCpsContentInfoByIds" parameterType="String">

+ 11 - 2
ruoyi-system/src/main/resources/mapper/cp/CpsUsrApplyMapper.xml

@@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="usrWechatId"    column="usr_wechat_id"    />
         <result property="contentId"    column="content_id"    />
         <result property="contentTitle" column="content_title"/>
+        <result property="deptId" column="dept_id"/>
         <result property="updateTime"    column="update_time"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
@@ -27,7 +28,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectCpsUsrApplyVo">
-        select id,
+        select usrApply.id,
                usr_name,
                tel,
                org_unit_name,
@@ -42,11 +43,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                usr_wechat_id,
                content_id,
                content_title,
+               dept_id,
                update_time,
                create_time,
                create_by,
                update_by
-        from cps_usr_apply
+        from cps_usr_apply usrApply
     </sql>
 
     <select id="selectCpsUsrApplyList" parameterType="com.ruoyi.system.domain.CpsUsrApply" resultMap="CpsUsrApplyResult">
@@ -60,6 +62,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="conferenceFlag != null  and conferenceFlag != ''"> and conference_flag = #{conferenceFlag}</if>
             <if test="applyType != null  and applyType != ''"> and apply_type = #{applyType}</if>
             <if test="reviewState != null  and reviewState != ''"> and review_state = #{reviewState}</if>
+            ${params.dataScope}
         </where>
     </select>
 
@@ -90,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">usr_wechat_id,</if>
             <if test="contentId != null">content_id,</if>
             <if test="contentTitle !=null">content_title,</if>
+            <if test="deptId !=null">dept_id,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
@@ -110,6 +114,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">#{usrWechatId},</if>
             <if test="contentId != null">#{contentId},</if>
             <if test="contentTitle !=null">#{contentTitle},</if>
+            <if test="deptId !=null">#{deptId},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
@@ -134,6 +139,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">usr_wechat_id,</if>
             <if test="contentId != null">content_id,</if>
             <if test="contentTitle !=null">content_title,</if>
+            <if test="deptId !=null">dept_id,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateBy != null">update_by,</if>
             update_time,
@@ -154,6 +160,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">#{usrWechatId},</if>
             <if test="contentId != null">#{contentId},</if>
             <if test="contentTitle !=null">#{contentTitle},</if>
+            <if test="deptId !=null">#{deptId},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateBy != null">#{updateBy},</if>
             now(),
@@ -174,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">usr_wechat_id = VALUES(usr_wechat_id),</if>
             <if test="contentId != null">content_id = VALUES(content_id),</if>
             <if test="contentTitle !=null">content_title = VALUES(content_title),</if>
+            <if test="deptId !=null">dept_id = VALUES(dept_id),</if>
             <if test="updateBy != null">update_by = VALUES(update_by),</if>
             conference_rel = VALUES(conference_rel),
             update_time = now()
@@ -197,6 +205,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="usrWechatId != null">usr_wechat_id = #{usrWechatId},</if>
             <if test="contentId != null">content_id = #{contentId},</if>
             <if test="contentTitle !=null">content_title = #{contentTitle},</if>
+            <if test="deptId !=null">dept_id = #{deptId},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>

+ 16 - 1
ruoyi-ui/src/views/cp/contentInfo/index.vue

@@ -129,6 +129,9 @@
             ></el-option>
           </el-select>
         </el-form-item>
+        <el-form-item label="归属部门" prop="deptId">
+          <Treeselect v-model="form.deptId" :options="deptOptions" :show-count="true" placeholder="请选择归属部门" />
+        </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
         <el-button type="primary" @click="submitForm">确 定</el-button>
@@ -140,9 +143,12 @@
 
 <script>
 import { listContentIfon, getContentIfon, delContentIfon, addContentIfon, updateContentIfon } from "@/api/cp/contentInfo";
-
+import { deptTreeSelect } from '@/api/system/user';
+import Treeselect from "@riophae/vue-treeselect";
+import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 export default {
   name: "ContentIfon",
+  components: { Treeselect },
   dicts: ['content_type'],
   data() {
     return {
@@ -164,6 +170,8 @@ export default {
       title: "",
       // 是否显示弹出层
       open: false,
+      // 部门树选项
+      deptOptions: undefined,
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -193,8 +201,15 @@ export default {
   },
   created() {
     this.getList();
+    this.getDeptTree();
   },
   methods: {
+    /** 查询部门下拉树结构 */
+    getDeptTree() {
+      deptTreeSelect().then(response => {
+        this.deptOptions = response.data;
+      });
+    },
     /** 查询发布内容列表 */
     getList() {
       this.loading = true;