From 44475dca374251fdf32762ab7ab4266b28c6a8a4 Mon Sep 17 00:00:00 2001
From: liuxm <liuxm@fescotech.com>
Date: 星期一, 22 四月 2024 08:54:22 +0800
Subject: [PATCH] 角色管理功能
---
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java | 13 ++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java | 1
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java | 13 +++++-
pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml | 45 ++++++++++++++++++++++
pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java | 1
pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml | 6 +++
pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml | 18 +++++++++
7 files changed, 94 insertions(+), 3 deletions(-)
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
index 3015a93..0af28a4 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaPrivilegeMapper.java
@@ -16,6 +16,7 @@
* @return List<BaPrivilege>
*/
List<BaPrivilege> selectAll() ;
+ List<BaPrivilege> selectByIds(List<String> ids) ;
/**
* 鏌ヨ鏌愪釜鐢ㄦ埛鎵�闅跺睘鎵�鏈夎鑹茬殑鎵�鏈夋潈闄�
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
index a5187f0..37e8842 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRoleMapper.java
@@ -1,10 +1,12 @@
package com.dy.pmsGlobal.daoBa;
import com.dy.pmsGlobal.pojoBa.BaRole;
+import com.dy.pmsGlobal.pojoBa.BaUser;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
+import java.util.Map;
@Mapper
public interface BaRoleMapper {
@@ -29,4 +31,15 @@
int deleteByPrimaryKey(Long id);
+
+ /**
+ * 閫昏緫鍒犻櫎
+ * @param id primaryKey
+ * @return update count
+ */
+ int deleteLogicById(Long id);
+
+ Long selectSomeCount(Map<String, Object> params);
+
+ List<BaRole> selectSome(Map<String, Object> params);
}
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
index 05d1623..b77dd74 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/daoBa/BaRolePrivilegeMapper.java
@@ -7,6 +7,7 @@
@Mapper
public interface BaRolePrivilegeMapper {
int deleteByPrimaryKey(@Param("roleId") Long roleId, @Param("privilegeId") Long privilegeId);
+ int deleteByRoleId(@Param("roleId") Long roleId);
int insert(BaRolePrivilege record);
diff --git a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
index dc282fd..7ba2890 100644
--- a/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
+++ b/pms-parent/pms-global/src/main/java/com/dy/pmsGlobal/pojoBa/BaRole.java
@@ -7,12 +7,15 @@
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import jakarta.validation.constraints.NotEmpty;
import lombok.*;
import org.hibernate.validator.constraints.Length;
+
+import java.util.List;
/**
* 鐢ㄦ埛
@@ -47,8 +50,8 @@
/**
* 瑙掕壊鍚嶇О
*/
- @NotEmpty(message = "濮撳悕涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
- @Length(message = "濮撳悕涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 2, max = 50)
+ @NotEmpty(message = "瑙掕壊鍚嶇О涓嶈兘涓虹┖") //涓嶈兘涓虹┖涔熶笉鑳戒负null
+ @Length(message = "瑙掕壊鍚嶇О涓嶅ぇ浜巤max}瀛楋紝涓嶅皬浜巤min}瀛�", min = 2, max = 50)
public String name;
/**
@@ -61,4 +64,10 @@
*/
public Boolean deleted;
+ /**
+ * 鍓嶇web鐣岄潰鎻愪氦鐨勮鑹叉墍灞炴潈闄愮殑id锛屽叾鏄竴涓瓧绗︿覆鏁扮粍
+ */
+ @TableField(exist = false)
+ public List<String> priIds ;
+
}
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
index a452108..37fa18a 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaPrivilegeMapper.xml
@@ -54,6 +54,15 @@
</if>
</select>
+<!-- <select id="selectByRole" resultType="com.dy.pmsGlobal.pojoBa.BaPrivilege">-->
+<!-- select p.id,p.num,p.name,p.type-->
+<!-- from ba_privilege p-->
+<!-- inner join ba_role_privilege rp on p.id = rp.privilege_id-->
+<!-- <if test="roleId != null">-->
+<!-- where rp.role_id = #{roleId, jdbcType=BIGINT}-->
+<!-- </if>-->
+<!-- </select>-->
+
<insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaPrivilege">
@@ -123,4 +132,13 @@
delete from ba_privilege
where id = #{id}
</delete>
+
+ <select id="selectByIds" parameterType="arraylist" resultMap="BaseResultMap">
+ select
+ <include refid="Base_Column_List" />
+ from ba_privilege where id in
+ <foreach item="id" collection="ids" open="(" separator="," close=")">
+ #{id}
+ </foreach>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
index eacb14e..cfc729f 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaRoleMapper.xml
@@ -14,6 +14,10 @@
<result column="name" property="name" />
</resultMap>
+ <resultMap id="someResultMap" extends="partResultMap" type="com.dy.pmsGlobal.pojoBa.BaRole">
+ <collection property="priIds" ofType="java.lang.String" fetchType="eager" column="{roleId=id}" select="com.dy.pmsGlobal.daoBa.BaPrivilegeMapper.selectPrivilegeByRoleId" />
+ </resultMap>
+
<sql id="Base_Column_List">
<!--@mbg.generated-->
id, `name`, disabled, deleted
@@ -24,7 +28,7 @@
id, `name`, disabled
</sql>
- <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
+ <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="someResultMap">
<!--@mbg.generated-->
select
<include refid="Base_Column_List" />
@@ -111,4 +115,43 @@
deleted = #{deleted}
where id = #{id}
</update>
+
+ <delete id="deleteLogicById" parameterType="java.lang.Long">
+ update ba_role set deleted = 1
+ where id = #{id}
+ </delete>
+
+ <select id="selectSomeCount" resultType="java.lang.Long">
+ select
+ count(*)
+ from ba_role r
+ inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id
+ where r.disabled!=1 and r.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null and name != ''">
+ r.name like concat('%', #{name}, '%') and
+ </if>
+ </trim>
+ </select>
+
+ <select id="selectSome" resultMap="someResultMap">
+ select
+ <include refid="Part_Column_List" >
+ <property name="alias" value="r"/>
+ </include>
+ from ba_role r
+ inner join (select DISTINCT role_id from ba_role_privilege) rp on r.id=rp.role_id
+ where r.disabled!=1 and r.deleted!=1
+ <trim prefix="and" suffixOverrides="and">
+ <if test="name != null and name != ''">
+ r.name like concat('%', #{name}, '%') and
+ </if>
+ </trim>
+ order by id DESC
+ <trim prefix="limit " >
+ <if test="start != null and count != null">
+ #{start}, #{count}
+ </if>
+ </trim>
+ </select>
</mapper>
\ No newline at end of file
diff --git a/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml b/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
index 938e840..daad892 100644
--- a/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
+++ b/pms-parent/pms-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
@@ -17,6 +17,12 @@
where role_id = #{roleId}
and privilege_id = #{privilegeId}
</delete>
+
+ <delete id="deleteByRoleId" parameterType="map">
+ <!--@mbg.generated-->
+ delete from ba_role_privilege
+ where role_id = #{roleId}
+ </delete>
<insert id="insert" parameterType="com.dy.pmsGlobal.pojoBa.BaRolePrivilege">
<!--@mbg.generated-->
insert into ba_role_privilege (role_id, privilege_id)
--
Gitblit v1.8.0