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) ; /** * 查询某个用户所隶属所有角色的所有权限 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); } 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); 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 ; } 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> 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> 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)