Administrator
2024-06-27 ca869ad6522246095f500c5e9d13fa990c9aeaec
2024-06-27 朱宝民 临时解决登录问题
6个文件已添加
3个文件已修改
330 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaPrivilegeMapper.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRolePrivilegeMapper.java 47 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaPrivilege.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaRolePrivilege.java 32 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaPrivilegeMapper.xml 88 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml 61 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaPrivilegeMapper.java
New file
@@ -0,0 +1,45 @@
package com.dy.pipIrrGlobal.daoBa;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoBa.BaPrivilege;
import org.apache.ibatis.annotations.Param;
import java.util.List;
public interface BaPrivilegeMapper extends BaseMapper<BaPrivilege> {
     /**
     * 查询全部
     * @return List<BaPrivilege>
     */
    List<BaPrivilege> selectAll() ;
    /**
     * 查询某个用户所隶属所有角色的所有权限
     * @param userId 用户ID
     * @return List<Integer>
     */
    List<Integer> selectPrivilegeByUserId(@Param("userId") Long userId) ;
    /**
     * 查询某个角色所隶属于该角色的所有权限
     * @param roleId 用户ID
     * @return List<Integer>
     */
    List<Integer> selectPrivilegeByRoleId(@Param("roleId") Long roleId) ;
    /**
     * insert record to table
     * @param record the record
     * @return insert count
     */
    int putin(BaPrivilege record);
    /**
     * insert record to table selective
     * @param record the record
     * @return insert count
     */
    int insertSelective(BaPrivilege record);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRolePrivilegeMapper.java
New file
@@ -0,0 +1,47 @@
package com.dy.pipIrrGlobal.daoBa;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface BaRolePrivilegeMapper extends BaseMapper<BaRolePrivilege> {
    /**
     * insert record to table
     * @param record the record
     * @return insert count
     */
    int putin(BaRolePrivilege record);
    /**
     * insert record to table selective
     * @param record the record
     * @return insert count
     */
    int insertSelective(BaRolePrivilege record);
    /**
     * delete by primary key
     * @param roleId primaryKey
     * @param privilegeId primaryKey
     * @return deleteCount
     */
    int deleteByPrimaryKey(@Param("roleId") Long roleId, @Param("privilegeId") Long privilegeId);
    /**
     * delete by roleId
     * @param roleId 角色ID
     * @return deleteCount
     */
    int deleteByRoleId(@Param("roleId") Long roleId);
    /**
     * delete by roleId
     * @param privilegeId 权限ID
     * @return deleteCount
     */
    int deleteByPrivilegeId(@Param("privilegeId") Long privilegeId);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaPrivilege.java
New file
@@ -0,0 +1,42 @@
package com.dy.pipIrrGlobal.pojoBa;
import com.alibaba.fastjson2.annotation.JSONField;
import com.alibaba.fastjson2.writer.ObjectWriterImplToString;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.dy.common.po.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
/**
 * 权限实体
 */
@TableName(value="ba_privilege", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
@Schema(name = "权限实体")
public class BaPrivilege implements BaseEntity {
    public static final long serialVersionUID = 202310211551001L;
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    private Long id;
    /**
     * 权限编号
     */
    public Integer num;
    /**
     * 权限名称
     */
    public String name;
    /**
     * 权限类别
     */
    public String type;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaRolePrivilege.java
New file
@@ -0,0 +1,32 @@
package com.dy.pipIrrGlobal.pojoBa;
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 lombok.*;
/**
 * 角色与权限关系实体
 */
@TableName(value="ba_role_privilege", autoResultMap = true)
@Data
@Builder
@ToString
@NoArgsConstructor
@AllArgsConstructor
public class BaRolePrivilege implements BaseEntity {
    public static final long serialVersionUID = 202311062027001L;
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableField(value = "roleId")
    public Long roleId;
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableField(value = "privilegeId")
    public Long privilegeId;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java
@@ -127,6 +127,15 @@
    public List<?> roleList ;
    /**
     * 用户所拥有的权限,针对登录应用
     */
    @Schema(hidden = true)
    @TableField(exist = false)
    @JSONField(serialize = false)
    public List<Integer> privileges;
    /**
     * 所属片区名称
     */
    @Schema(description = "所属片区名称,用于显示,表单不用填写", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
pipIrr-platform/pipIrr-global/src/main/resources/application-database-ym.yml
@@ -5,8 +5,8 @@
            #name: ym
            type: com.alibaba.druid.pool.DruidDataSource
            driverClassName: com.mysql.cj.jdbc.Driver
            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
#            url: jdbc:mysql://192.168.40.166:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            url: jdbc:mysql://127.0.0.1:3306/pipIrr_ym?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&useSSL=false&serverTimezone=GMT%2B8&zeroDateTimeBehavior=convertToNull
            username: root
            password: dysql,;.abc!@#
            druid:
pipIrr-platform/pipIrr-global/src/main/resources/application-global.yml
@@ -72,7 +72,7 @@
pipIrr:
    global:
        dev: false   #是否开发阶段,true或false
        dev: true   #是否开发阶段,true或false
        dsName: ym  #开发阶段,设置临时的数据库名称
    mw:
        webPort: 8070
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaPrivilegeMapper.xml
New file
@@ -0,0 +1,88 @@
<?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">
<mapper namespace="com.dy.pipIrrGlobal.daoBa.BaPrivilegeMapper">
    <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaPrivilege">
        <!--@mbg.generated-->
        <!--@Table ba_privilege-->
        <result column="id" jdbcType="BIGINT" property="id" />
        <result column="num" jdbcType="INTEGER" property="num" />
        <result column="name" jdbcType="VARCHAR" property="name" />
        <result column="type" jdbcType="VARCHAR" property="type" />
    </resultMap>
    <sql id="Base_Column_List">
        <!--@mbg.generated-->
        id, num, name, type
    </sql>
    <select id="selectAll" resultMap="BaseResultMap">
        select
        <include refid="Base_Column_List" />
        from ba_privilege
    </select>
    <select id="selectPrivilegeByUserId" resultType="Integer">
        select p.num
        from ba_privilege p
        inner join ba_role_privilege rp on p.id = rp.privilegeId
        inner join ba_user_role ur on rp.roleId = ur.roleId
        inner join ba_role r on ur.roleId = r.id
        where r.deleted != 1
        <if test="userId != null">
            and ur.userId = #{userId, jdbcType=BIGINT}
        </if>
    </select>
    <select id="selectPrivilegeByRoleId" resultType="Integer">
        select p.num
        from ba_privilege p
        inner join ba_role_privilege rp on p.id = rp.privilegeId
        <if test="roleId != null">
            where rp.roleId = #{roleId, jdbcType=BIGINT}
        </if>
    </select>
    <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaPrivilege">
        <!--@mbg.generated-->
        insert into ba_privilege (<include refid="Base_Column_List" />)
        values (#{id,jdbcType=BIGINT},
        #{num,jdbcType=INTEGER},
        #{name,jdbcType=VARCHAR},
        #{type, jdbcType=VARCHAR}
        )
    </insert>
    <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaPrivilege">
        <!--@mbg.generated-->
        insert into ba_privilege
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">
                id,
            </if>
            <if test="num != null">
                id,
            </if>
            <if test="name != null">
                name,
            </if>
            <if test="type != null">
                type,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="num != null">
                #{name,jdbcType=INTEGER},
            </if>
            <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="type != null">
                #{type,jdbcType=VARCHAR},
            </if>
        </trim>
    </insert>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRolePrivilegeMapper.xml
New file
@@ -0,0 +1,61 @@
<?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">
<mapper namespace="com.dy.pipIrrGlobal.daoBa.BaRolePrivilegeMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege">
    <!--@mbg.generated-->
    <!--@Table ba_role_privilege-->
    <id column="roleId" jdbcType="BIGINT" property="roleId" />
    <id column="privilegeId" jdbcType="BIGINT" property="privilegeId" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    roleId, privilegeId
  </sql>
  <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege">
    <!--@mbg.generated-->
    insert into ba_role_privilege (roleId, privilegeId)
    values (#{roleId,jdbcType=BIGINT}, #{privilegeId,jdbcType=BIGINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege">
    <!--@mbg.generated-->
    insert into ba_role_privilege
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="roleId != null">
        roleId,
      </if>
      <if test="privilegeId != null">
        privilegeId,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="roleId != null">
        #{roleId,jdbcType=BIGINT},
      </if>
      <if test="privilegeId != null">
        #{privilegeId,jdbcType=BIGINT},
      </if>
    </trim>
  </insert>
  <delete id="deleteByPrimaryKey" parameterType="map">
    <!--@mbg.generated-->
    delete from ba_role_privilege
    where roleId = #{roleId,jdbcType=BIGINT}
    and privilegeId = #{privilegeId,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByRoleId" parameterType="long">
    delete from ba_role_privilege
    where roleId = #{roleId,jdbcType=BIGINT}
  </delete>
  <delete id="deleteByPrivilegeId" parameterType="long">
    delete from ba_role_privilege
    where privilegeId = #{privilegeId,jdbcType=BIGINT}
  </delete>
</mapper>