Administrator
2024-01-10 3496e5390b866618efafd56159f36c91d0d22689
2024-01-10 朱宝民 重构分水房3个接口
10个文件已修改
2个文件已添加
1129 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRoleMapper.java 89 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaRole.java 57 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoRole.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRoleMapper.xml 188 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRolePermissionsMapper.xml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/result/SystemResultCode.java 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/DtoRole.java 48 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/QueryVo.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java 487 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java 177 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java 29 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/daoBa/BaRoleMapper.java
@@ -1,84 +1,49 @@
package com.dy.pipIrrGlobal.daoBa;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.dy.pipIrrGlobal.pojoBa.BaRole;
import org.apache.ibatis.annotations.Mapper;
import com.dy.pipIrrGlobal.voBa.VoRole;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface BaRoleMapper extends BaseMapper<BaRole> {
/**
 * @author ZhuBaoMin
 * @date 2024-01-10 11:00
 * @LastEditTime 2024-01-10 11:00
 * @Description
 */
public interface BaRoleMapper {
    int deleteByPrimaryKey(Long id);
    /**
     * 查询全部
     * @return List<BaRole>
     */
    List<BaRole> selectAll() ;
    int insert(BaRole record);
    /**
     * 查询某个用户所隶属于的角色
     * @param userId 用户ID
     * @return List<BaRole>
     */
    List<BaRole> selectByUserId(@Param("userId") Long userId) ;
    /**
     * 查询总数
     * @param params 查询条件
     * @return 总数
     */
    Long selectTotal(Map<?, ?> params) ;
    /**
     * 分页查询一些
     * @param params 查询条件
     * @return 实体集合
     */
    List<BaRole> selectSome(Map<?, ?> params) ;
    /**
     * insert record to table
     * @param record the record
     * @return insert count
     */
    int putin(BaRole record);
    /**
     * insert record to table selective
     * @param record the record
     * @return insert count
     */
    int insertSelective(BaRole record);
    /**
     * update record selective
     * @param record the updated record
     * @return update count
     */
    BaRole selectByPrimaryKey(Long id);
    int updateByPrimaryKeySelective(BaRole record);
    /**
     * update record
     * @param record the updated record
     * @return update count
     */
    int updateByPrimaryKey(BaRole record);
    /**
     * delete by primary key
     * @param id primaryKey
     * @return deleteCount
     * 根据角色名称查询记录数量
     * @param roleName
     * @return
     */
    int deleteByPrimaryKey(Long id);
    Integer getRecordCountByName(@Param("roleName") String roleName);
    /**
     * 逻辑删除
     * @param id primaryKey
     * @return update count
     * 根据指定条件获取角色记录数
     * @param params
     * @return
     */
    int deleteLogicById(Long id);
    Long getRecordCount(Map<?, ?> params);
    /**
     * 根据指定条件获取角色记录
     * @param params
     * @return
     */
    List<VoRole> getRoles(Map<?, ?> params);
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaRole.java
@@ -1,24 +1,26 @@
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.mybatis.envm.Deleted;
import com.dy.common.po.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Positive;
import lombok.*;
import org.hibernate.validator.constraints.Length;
import java.util.List;
import java.util.Date;
/**
 * 角色实体
 * @author ZhuBaoMin
 * @date 2024-01-10 11:00
 * @LastEditTime 2024-01-10 11:00
 * @Description
 */
@TableName(value="ba_role", autoResultMap = true)
@Data
@Builder
@@ -27,33 +29,40 @@
@AllArgsConstructor
@Schema(name = "角色实体")
public class BaRole implements BaseEntity {
    public static final long serialVersionUID = 1L;
    public static final long serialVersionUID = 202310211546001L;
    /**
    * 主键
    */
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableId(type = IdType.INPUT)
    @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public Long id ;
    private Long id;
    /**
     * 角色名称
     */
    * 角色名称
    */
    @Schema(description = "名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotEmpty(message = "名称不能为空") //不能为空也不能为null
    @Length(message = "名称不大于{max}字,不小于{min}字", min = 2, max = 25)
    public String name ;
    @NotBlank(message = "名称不能为空")
    private String name;
    /**
     * 是否删除: 0表示未删除  1表示删除.
     */
    * 操作人编号
    */
    @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "操作人编号必须为大于0的整数")
    private Long operator;
    /**
    * 操作时间
    */
    @Schema(description = "操作时间", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    private Date operateDt;
    /**
    * 逻辑删除标识;0-未删除,1-删除
    */
    @Schema(description = "删除标识,表单不用填写", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public Deleted deleted;
    /**
     * 角色所拥有的权限
     */
    @TableField(exist = false)
    public List<BaPrivilege> priviList ;
    private Byte deleted;
}
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/voBa/VoRole.java
New file
@@ -0,0 +1,42 @@
package com.dy.pipIrrGlobal.voBa;
import com.dy.common.po.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
 * @author ZhuBaoMin
 * @date 2024-01-10 15:13
 * @LastEditTime 2024-01-10 15:13
 * @Description
 */
@Data
@Schema(title = "角色信息视图对象")
public class VoRole implements BaseEntity {
    private static final long serialVersionUID = 1L;
    @Schema(title = "ID")
    private Long id;
    @Schema(title = "角色编号")
    private Long roleId;
    @Schema(title = "角色名称")
    private String roleName;
    @Schema(title = "权限列表")
    private String permissions;
    @Schema(title = "操作人")
    private String operator;
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @Schema(title = "操作时间")
    private Date operateDt;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRoleMapper.xml
@@ -1,84 +1,42 @@
<?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.BaRoleMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <result column="id" jdbcType="BIGINT" property="id" />
    <!--@mbg.generated-->
    <!--@Table ba_role-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result property="deleted" column="deleted" typeHandler="com.dy.common.mybatis.envm.EnumCodeTypeHandler" javaType="com.dy.common.mybatis.envm.Deleted"/>
    <result column="operator" jdbcType="BIGINT" property="operator" />
    <result column="operate_dt" jdbcType="TIMESTAMP" property="operateDt" />
    <result column="deleted" jdbcType="TINYINT" property="deleted" />
  </resultMap>
  <resultMap id="partResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <result column="id" jdbcType="BIGINT" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
  </resultMap>
  <resultMap id="someResultMap" extends="partResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <collection property="priviList" fetchType="eager" column="{roleId=id}" select="com.dy.pipIrrGlobal.daoBa.BaPrivilegeMapper.selectPrivilegeByRoleId" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, deleted
    <!--@mbg.generated-->
    id, `name`, `operator`, operate_dt, deleted
  </sql>
  <sql id="part_Column_List">
    id, name, deleted
  </sql>
  <select id="selectAll" resultMap="BaseResultMap">
    select
    <include refid="part_Column_List" />
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select
    <include refid="Base_Column_List" />
    from ba_role
    where deleted!=1
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from ba_role
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <select id="selectByUserId" resultMap="partResultMap">
    select <include refid="part_Column_List" />
    from ba_role r
    inner join ba_user_role ur on r.id = ur.roleId
    where r.deleted != 1
    <if test="userId != null">
      and ur.userId = #{userId,jdbcType=BIGINT}
    </if>
  </select>
  <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
    select
    count(*)
    from ba_role where deleted!=1
    <trim prefix="and" suffixOverrides="and">
      <if test="name != null and name != ''">
        name like concat('%', #{name}, '%')
      </if>
    </trim>
  </select>
  <select id="selectSome" parameterType="java.util.Map" resultMap="someResultMap">
    select
    <include refid="part_Column_List" />
    from ba_role where deleted!=1
    <trim prefix="and" suffixOverrides="and">
      <if test="name != null and name != ''">
        name like concat('%', #{name}, '%')
      </if>
    </trim>
    order by id DESC
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
  <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRole">
    insert into ba_role (<include refid="Base_Column_List" />)
    values (#{id,jdbcType=BIGINT},
            #{name,jdbcType=VARCHAR},
            #{deleted, typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
      )
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <!--@mbg.generated-->
    insert into ba_role (id, `name`, `operator`,
      operate_dt, deleted)
    values (#{id,jdbcType=BIGINT}, #{name,jdbcType=VARCHAR}, #{operator,jdbcType=BIGINT},
      #{operateDt,jdbcType=TIMESTAMP}, #{deleted,jdbcType=TINYINT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <!--@mbg.generated-->
    insert into ba_role
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
@@ -86,6 +44,12 @@
      </if>
      <if test="name != null">
        `name`,
      </if>
      <if test="operator != null">
        `operator`,
      </if>
      <if test="operateDt != null">
        operate_dt,
      </if>
      <if test="deleted != null">
        deleted,
@@ -98,41 +62,103 @@
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="operator != null">
        #{operator,jdbcType=BIGINT},
      </if>
      <if test="operateDt != null">
        #{operateDt,jdbcType=TIMESTAMP},
      </if>
      <if test="deleted != null">
        #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
        #{deleted,jdbcType=TINYINT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <!--@mbg.generated-->
    update ba_role
    <set>
      <if test="name != null">
        `name` = #{name,jdbcType=VARCHAR},
      </if>
      <if test="operator != null">
        `operator` = #{operator,jdbcType=BIGINT},
      </if>
      <if test="operateDt != null">
        operate_dt = #{operateDt,jdbcType=TIMESTAMP},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
        deleted = #{deleted,jdbcType=TINYINT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRole">
    <!--@mbg.generated-->
    update ba_role
    set `name` = #{name,jdbcType=VARCHAR},
     deleted = #{deleted,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT}
      `operator` = #{operator,jdbcType=BIGINT},
      operate_dt = #{operateDt,jdbcType=TIMESTAMP},
      deleted = #{deleted,jdbcType=TINYINT}
    where id = #{id,jdbcType=BIGINT}
  </update>
  <!--根据角色名称查询记录数量,添加角色时判断是否重名-->
  <select id="getRecordCountByName" resultType="java.lang.Integer">
    SELECT
        COUNT(*) AS recordCount
    FROM ba_role
    WHERE name = #{roleName}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    delete from ba_role
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <!--根据指定条件获取角色记录数-->
  <select id="getRecordCount" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM ba_role role
    LEFT JOIN ba_role_permissions per ON per.roleId = role.id
    <where>
      AND role.deleted = 0
  <delete id="deleteLogicById" parameterType="java.lang.Long">
    update ba_role set deleted = 1
    where id = #{id,jdbcType=BIGINT}
  </delete>
      <if test = "roleId != null and roleId > 0">
        AND role.id = ${roleId}
      </if>
      <if test = "roleName != null and roleName !=''">
        AND role.name LIKE CONCAT('%',#{roleName},'%')
      </if>
    </where>
  </select>
  <!--根据指定条件获取角色记录-->
  <select id="getRoles" resultType="com.dy.pipIrrGlobal.voBa.VoRole">
    SELECT
        (@i:=@i+1) AS id,
        t.* FROM
        (
          SELECT
            role.id AS roleId,
            role.name AS roleName,
            per.permissions,
            (SELECT `name` FROM ba_user WHERE id =  role.operator) AS operator,
            role.operate_dt AS operateDt
          FROM ba_role role
            LEFT JOIN ba_role_permissions per ON per.roleId = role.id
          <where>
            AND role.deleted = 0
            <if test = "roleId != null and roleId > 0">
              AND role.id = ${roleId}
            </if>
            <if test = "roleName != null and roleName !=''">
              AND role.name LIKE CONCAT('%',#{roleName},'%')
            </if>
          </where>
          ORDER BY role.operate_dt DESC
          <if test="pageCurr != null and pageSize != null">
            LIMIT ${pageCurr}, ${pageSize}
          </if>
      ) t
    , (SELECT @i:=0) AS itable
  </select>
</mapper>
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaRolePermissionsMapper.xml
@@ -37,6 +37,7 @@
    values (#{id,jdbcType=BIGINT}, #{roleid,jdbcType=BIGINT}, #{permissions,jdbcType=VARCHAR}
      )
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaRolePermissions">
    <!--@mbg.generated-->
    insert into ba_role_permissions
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/result/SystemResultCode.java
@@ -16,7 +16,10 @@
    /**
     * 角色
     */
    PERMISSION_ERROR(10001, "授权错误");
    PERMISSION_ERROR(10001, "授权错误"),
    ADD_ROLE_FAIL(10002, "角色添加失败"),
    ROLE_NAME_EXIST(10003, "角色名称已存在"),
    NO_ROLES(10004, "没有符合条件的角色记录");
    private final Integer code;
    private final String message;
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/DtoRole.java
New file
@@ -0,0 +1,48 @@
package com.dy.pipIrrBase.role;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Positive;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
/**
 * @author ZhuBaoMin
 * @date 2024-01-10 9:16
 * @LastEditTime 2024-01-10 9:16
 * @Description
 */
@Data
@Schema(name = "角色传入对象")
public class DtoRole {
    public static final long serialVersionUID = 1L;
    /**
     * 角色编号
     */
    @Schema(description = "角色编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "角色编号必须为大于0的整数")
    private Long roleid;
    /**
     * 角色名称
     */
    @Schema(description = "角色名称", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "角色名称不能为空")
    @Length(max = 25, message = "角色名称最多25字")
    private String roleName;
    /**
     * 权限列表
     */
    @Schema(description = "权限列表", requiredMode = Schema.RequiredMode.REQUIRED)
    private String permissions;
    /**
     * 操作人编号
     */
    @Schema(description = "操作人编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @Positive(message = "操作人编号必须为大于0的整数")
    private Long operator;
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/QueryVo.java
@@ -13,8 +13,10 @@
@Builder
@Schema(name = "角色查询条件")
public class QueryVo extends QueryConditionVo {
    @Schema(description = "角色ID")
    public Long roleId;
    @Schema(description = "角色名称")
    public String name;
    public String roleName;
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleCtrl.java
@@ -7,9 +7,10 @@
import com.dy.common.webUtil.QueryResultVo;
import com.dy.common.webUtil.ResultCodeMsg;
import com.dy.pipIrrBase.result.SystemResultCode;
import com.dy.pipIrrBase.user.QueryVo;
import com.dy.pipIrrGlobal.pojoBa.BaRole;
import com.dy.pipIrrGlobal.pojoBa.BaRolePermissions;
import com.dy.pipIrrGlobal.voBa.VoRole;
import com.dy.pipIrrGlobal.voSe.VoActiveCard;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Content;
import io.swagger.v3.oas.annotations.media.Schema;
@@ -19,12 +20,12 @@
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@@ -37,90 +38,158 @@
@SuppressWarnings("unchecked")//java版本越高,对泛型约束越严,所以配置SuppressWarnings("unchecked")
public class RoleCtrl {
    private RoleSv sv ;
    //private RoleSv sv ;
    private final RoleSv roleSv;
    @Autowired
    private void setSv(RoleSv sv){
        this.sv = sv ;
    //@Autowired
    //private void setSv(RoleSv sv){
    //    this.sv = sv ;
    //}
    /**
     * 根据指定条件(角色编号、角色名称)获取角色列表
     * 当获取一条记录时,传入roleId即可
     * @param vo
     * @return
     */
    @Operation(summary = "获得一页角色记录", description = "返回一页角色数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页控制器数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = VoActiveCard.class))}
            )
    })
    @GetMapping(path = "/roles")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoRole>>> getRoles(QueryVo vo){
        try {
            QueryResultVo<List<VoRole>> res = roleSv.getRoles(vo);
            if(res.itemTotal != null && res.itemTotal > 0) {
                return BaseResponseUtils.buildSuccess(res);
            }else {
                return BaseResponseUtils.buildFail(SystemResultCode.NO_ROLES.getMessage());
            }
        } catch (Exception e) {
            log.error("获取开卡记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    /**
     * 客户端请求得到所有角色数据
     * @return 所有角色数据
     */
    @Operation(summary = "获得全部角色", description = "返回全部角色数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回全部角色数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaRole.class))}
            )
    })
    @GetMapping(path = "all")
    @SsoAop()
    public BaseResponse<QueryResultVo<List<BaRole>>> all(){
        try {
            QueryResultVo<List<BaRole>> res = this.sv.selectAll() ;
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询角色异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    //@Operation(summary = "获得全部角色", description = "返回全部角色数据")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "返回全部角色数据(BaseResponse.content:QueryResultVo[{}])",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = BaRole.class))}
    //        )
    //})
    //@GetMapping(path = "all")
    //@SsoAop()
    //public BaseResponse<QueryResultVo<List<BaRole>>> all(){
    //    try {
    //        QueryResultVo<List<BaRole>> res = this.sv.selectAll() ;
    //        return BaseResponseUtils.buildSuccess(res);
    //    } catch (Exception e) {
    //        log.error("查询角色异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //}
    /**
     * 客户端请求得到一页角色数据
     * @return 所有角色数据
     */
    @Operation(summary = "获得一页角色", description = "返回一页角色数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一页角色数据(BaseResponse.content:QueryResultVo[{}])",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaRole.class))}
            )
    })
    @PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody @Valid QueryVo vo){
        try {
            QueryResultVo<List<BaRole>> res = this.sv.selectSome(vo) ;
            return BaseResponseUtils.buildSuccess(res);
        } catch (Exception e) {
            log.error("查询角色异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
    }
    //@Operation(summary = "获得一页角色", description = "返回一页角色数据")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "返回一页角色数据(BaseResponse.content:QueryResultVo[{}])",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = BaRole.class))}
    //        )
    //})
    //@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop()
    //public BaseResponse<QueryResultVo<List<BaRole>>> some(@RequestBody @Valid QueryVo vo){
    //    try {
    //        QueryResultVo<List<BaRole>> res = this.sv.selectSome(vo) ;
    //        return BaseResponseUtils.buildSuccess(res);
    //    } catch (Exception e) {
    //        log.error("查询角色异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //}
    /**
     * 得到一个角色数据
     * @return 一个角色数据
     */
    @Operation(summary = "一个角色", description = "得到一个角色数据")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "返回一个角色数据(BaseResponse.content:{})",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = BaRole.class))}
            )
    })
    //@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "one")
    @SsoAop()
    public BaseResponse<BaRole> one(Long id){
        return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
    }
    //@Operation(summary = "一个角色", description = "得到一个角色数据")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "返回一个角色数据(BaseResponse.content:{})",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = BaRole.class))}
    //        )
    //})
    ////@GetMapping(path = "one", consumes = MediaType.TEXT_PLAIN_VALUE)
    //@GetMapping(path = "one")
    //@SsoAop()
    //public BaseResponse<BaRole> one(Long id){
    //    return BaseResponseUtils.buildSuccess(this.sv.selectById(id));
    //}
    /**
     * 保存角色
     * @param po 保存角色form表单对象
     * @return 是否成功
     */
    @Operation(summary = "保存角色", description = "提交角色数据(form表单),进行保存")
    //@Operation(summary = "保存角色", description = "提交角色数据(form表单),进行保存")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "操作结果:true:成功,false:失败(BaseResponse.content)",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = Boolean.class))}
    //        )
    //})
    //@PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop()
    //public BaseResponse<Boolean> save(@RequestBody @Valid BaRole po, BindingResult bindingResult){
    //    if(bindingResult != null && bindingResult.hasErrors()){
    //        return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
    //    }
    //    po.id = null ;
    //    Long count;
    //    try {
    //        po.deleted = Deleted.NO ;//默认不删除
    //        count = this.sv.save(po);
    //    } catch (Exception e) {
    //        log.error("保存角色异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //    if(count <= 0){
    //        return BaseResponseUtils.buildFail("数据库存储失败") ;
    //    }else{
    //        return BaseResponseUtils.buildSuccess(true) ;
    //    }
    //}
    /**
     * 添加角色及权限列表,添加前判断角色名是否已存在
     * @param po 角色传入对象,包括角色名称、权限列表、操作人编号
     * @param bindingResult
     * @return
     */
    @Operation(summary = "添加角色", description = "提交角色数据及权限数据,进行保存")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
@@ -130,136 +199,57 @@
            )
    })
    @PostMapping(path = "save", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> save(@RequestBody @Valid BaRole po, BindingResult bindingResult){
    public BaseResponse<Boolean> save(@RequestBody @Valid DtoRole po, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        po.id = null ;
        Long count;
        // 获取角色名称级权限列表
        String roleName = Optional.ofNullable(po.getRoleName()).orElse("");
        String permissions = Optional.ofNullable(po.getPermissions()).orElse("");
        Long operator = Optional.ofNullable(po.getOperator()).orElse(0L);
        // 判断角色名称是否重名
        Integer recordCount = Optional.ofNullable(roleSv.getRecordCountByName(roleName)).orElse(0);
        if(recordCount > 0)
            return BaseResponseUtils.buildFail(SystemResultCode.ROLE_NAME_EXIST.getMessage());
        // 添加角色
        BaRole baRole = new BaRole();
        Long roleId = 0L;
        try {
            po.deleted = Deleted.NO ;//默认不删除
            count = this.sv.save(po);
            baRole.setName(roleName);
            baRole.setOperator(operator);
            Date operateTime = new Date();
            baRole.setOperateDt(operateTime);
            baRole.setDeleted(Deleted.NO.getCode());
            roleId = roleSv.addRole(baRole);
        } catch (Exception e) {
            log.error("保存角色异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
    /**
     * 编辑修改角色
     * @param po 保存角色form表单对象
     * @return 是否成功
     */
    @Operation(summary = "编辑修改角色", description = "提交角色数据(form表单),进行修改")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Boolean> update(@RequestBody @Valid BaRole po, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        if(po.id == null){
            return BaseResponseUtils.buildFail("无数据实体ID") ;
        }
        int count;
        try {
            po.deleted = null ;//设置为null,不做更新
            count = this.sv.update(po);
        } catch (Exception e) {
            log.error("保存角色异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
        if(roleId <= 0)
            return BaseResponseUtils.buildFail(SystemResultCode.ADD_ROLE_FAIL.getMessage());
    /**
     * 设置角色权限
     * @param id 角色ID
     * @return 是否成功
     */
    @Operation(summary = "设置角色权限", description = "提交角色ID,及所选择的权限ID集合(数组)")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    //@GetMapping(path = "setPrivs", consumes = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(path = "setPrivs", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Boolean> setPrivileges(Long id, Long[] privIds){
        Long[] privIds_lg = null ;
        if(privIds != null && privIds.length > 0){
            privIds_lg = new Long[privIds.length] ;
            int index = 0 ;
            for(Long privId : privIds){
                privIds_lg[index++] = privId ;
            }
        }
        try {
            this.sv.setRoles(id, privIds_lg);
        } catch (Exception e) {
            log.error("保存用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        // 添加权限列表
        BaRolePermissions  baRolePermissions = new BaRolePermissions();
        baRolePermissions.setRoleid(roleId);
        baRolePermissions.setPermissions(permissions);
        Integer rc = Optional.ofNullable(roleSv.addPermissions(baRolePermissions)).orElse(0);
        if(rc <= 0) {
            return BaseResponseUtils.buildFail(SystemResultCode.ADD_ROLE_FAIL.getMessage());
        }
        return BaseResponseUtils.buildSuccess(true) ;
    }
    /**
     * 删除角色
     * @param id 角色ID
     * @return 是否成功
     */
    @Operation(summary = "删除角色", description = "提交角色ID,进行逻辑删除")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
                    description = "操作结果:true:成功,false:失败(BaseResponse.content)",
                    content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    //@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "delete")
    @SsoAop()
    public BaseResponse<Boolean> delete(Long id){
        if(id == null){
            return BaseResponseUtils.buildFail("id不能为空") ;
        }
        int count;
        try {
            count = this.sv.delete(id);
        } catch (Exception e) {
            log.error("保存角色异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
        }
        if(count <= 0){
            return BaseResponseUtils.buildFail("数据库存储失败") ;
        }else{
            return BaseResponseUtils.buildSuccess(true) ;
        }
    }
    /**
     * 角色授权,当角色编号为空时,实际为添加角色及权限列表
     * @param po
     * @param bindingResult
     * @return
     */
    @Operation(summary = "授权", description = "授权")
    @ApiResponses(value = {
            @ApiResponse(
@@ -272,7 +262,7 @@
    @PostMapping(path = "addPermissions", consumes = MediaType.APPLICATION_JSON_VALUE)
    @Transactional(rollbackFor = Exception.class)
    @SsoAop()
    public BaseResponse<Boolean> permission(@RequestBody  @Valid BaRolePermissions po, BindingResult bindingResult){
    public BaseResponse<Boolean> permission(@RequestBody  @Valid DtoRole po, BindingResult bindingResult){
        if(bindingResult != null && bindingResult.hasErrors()){
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
@@ -287,28 +277,149 @@
         *      2. 添加角色、权限记录
         */
        Long roleid = Optional.ofNullable(po.getRoleid()).orElse(0L);
        Long roleId = Optional.ofNullable(po.getRoleid()).orElse(0L);
        String roleName = Optional.ofNullable(po.getRoleName()).orElse("");
        String permissions = Optional.ofNullable(po.getPermissions()).orElse("");
        Long operator = Optional.ofNullable(po.getOperator()).orElse(0L);
        if(roleid == 0 && roleName.length() == 0) {
        if(roleId == 0 && roleName.length() == 0)
            return BaseResponseUtils.buildFail(SystemResultCode.PERMISSION_ERROR.getMessage());
        }
        // 新建角色且授权
        if(roleid == 0) {
        if(roleId == 0) {
            BaRole baRole = new BaRole();
            baRole.setName(roleName);
            roleid = Optional.ofNullable(roleSv.save(baRole)).orElse(0L);
            po.setRoleid(roleid);
            roleSv.addPermissions(po);
            baRole.setOperator(operator);
            Date operateTime = new Date();
            baRole.setOperateDt(operateTime);
            baRole.setDeleted(Deleted.NO.getCode());
            roleId = Optional.ofNullable(roleSv.addRole(baRole)).orElse(0L);
            BaRolePermissions baRolePermissions = new BaRolePermissions();
            baRolePermissions.setRoleid(roleId);
            baRolePermissions.setPermissions(permissions);
            roleSv.addPermissions(baRolePermissions);
            return BaseResponseUtils.buildSuccess(true) ;
        }
        // 修改角色授权
        roleSv.delPermissionsByRoleId(roleid);
        roleSv.addPermissions(po);
        BaRolePermissions baRolePermissions = new BaRolePermissions();
        baRolePermissions.setRoleid(roleId);
        baRolePermissions.setPermissions(permissions);
        roleSv.delPermissionsByRoleId(roleId);
        roleSv.addPermissions(baRolePermissions);
        return BaseResponseUtils.buildSuccess(true) ;
    }
    /**
     * 编辑修改角色
     * @param po 保存角色form表单对象
     * @return 是否成功
     */
    //@Operation(summary = "编辑修改角色", description = "提交角色数据(form表单),进行修改")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "操作结果:true:成功,false:失败(BaseResponse.content)",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = Boolean.class))}
    //        )
    //})
    //@PostMapping(path = "update", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop()
    //public BaseResponse<Boolean> update(@RequestBody @Valid BaRole po, BindingResult bindingResult){
    //    if(bindingResult != null && bindingResult.hasErrors()){
    //        return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
    //    }
    //    if(po.id == null){
    //        return BaseResponseUtils.buildFail("无数据实体ID") ;
    //    }
    //    int count;
    //    try {
    //        po.deleted = null ;//设置为null,不做更新
    //        count = this.sv.update(po);
    //    } catch (Exception e) {
    //        log.error("保存角色异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //    if(count <= 0){
    //        return BaseResponseUtils.buildFail("数据库存储失败") ;
    //    }else{
    //        return BaseResponseUtils.buildSuccess(true) ;
    //    }
    //}
    ///**
    // * 设置角色权限
    // * @param id 角色ID
    // * @return 是否成功
    // */
    //@Operation(summary = "设置角色权限", description = "提交角色ID,及所选择的权限ID集合(数组)")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "操作结果:true:成功,false:失败(BaseResponse.content)",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = Boolean.class))}
    //        )
    //})
    ////@GetMapping(path = "setPrivs", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@PostMapping(path = "setPrivs", consumes = MediaType.APPLICATION_JSON_VALUE)
    //@SsoAop()
    //public BaseResponse<Boolean> setPrivileges(Long id, Long[] privIds){
    //    Long[] privIds_lg = null ;
    //    if(privIds != null && privIds.length > 0){
    //        privIds_lg = new Long[privIds.length] ;
    //        int index = 0 ;
    //        for(Long privId : privIds){
    //            privIds_lg[index++] = privId ;
    //        }
    //    }
    //    try {
    //        this.sv.setRoles(id, privIds_lg);
    //    } catch (Exception e) {
    //        log.error("保存用户异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //    return BaseResponseUtils.buildSuccess(true) ;
    //}
    ///**
    // * 删除角色
    // * @param id 角色ID
    // * @return 是否成功
    // */
    //@Operation(summary = "删除角色", description = "提交角色ID,进行逻辑删除")
    //@ApiResponses(value = {
    //        @ApiResponse(
    //                responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
    //                description = "操作结果:true:成功,false:失败(BaseResponse.content)",
    //                content = {@Content(mediaType = MediaType.APPLICATION_JSON_VALUE,
    //                        schema = @Schema(implementation = Boolean.class))}
    //        )
    //})
    ////@GetMapping(path = "delete", consumes = MediaType.TEXT_PLAIN_VALUE)
    //@GetMapping(path = "delete")
    //@SsoAop()
    //public BaseResponse<Boolean> delete(Long id){
    //    if(id == null){
    //        return BaseResponseUtils.buildFail("id不能为空") ;
    //    }
    //    int count;
    //    try {
    //        count = this.sv.delete(id);
    //    } catch (Exception e) {
    //        log.error("保存角色异常", e);
    //        return BaseResponseUtils.buildException(e.getMessage()) ;
    //    }
    //    if(count <= 0){
    //        return BaseResponseUtils.buildFail("数据库存储失败") ;
    //    }else{
    //        return BaseResponseUtils.buildSuccess(true) ;
    //    }
    //}
}
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/role/RoleSv.java
@@ -1,51 +1,87 @@
package com.dy.pipIrrBase.role;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrBase.user.QueryVo;
import com.dy.pipIrrGlobal.daoBa.BaRoleMapper;
import com.dy.pipIrrGlobal.daoBa.BaRolePermissionsMapper;
import com.dy.pipIrrGlobal.daoBa.BaRolePrivilegeMapper;
import com.dy.pipIrrGlobal.pojoBa.BaRole;
import com.dy.pipIrrGlobal.pojoBa.BaRolePermissions;
import com.dy.pipIrrGlobal.pojoBa.BaRolePrivilege;
import com.dy.pipIrrGlobal.voBa.VoRole;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
 * @author ZhuBaoMin
 * @date 2024-01-10 11:00
 * @LastEditTime 2024-01-10 11:00
 * @Description
 */
@Slf4j
@Service
public class RoleSv {
    private BaRoleMapper dao;
    private BaRolePrivilegeMapper rolePrivDao ;
    //private BaRoleMapper baRoleMapper;
    //private BaRolePrivilegeMapper rolePrivDao ;
    @Autowired
    private void setDao(BaRoleMapper dao){
        this.dao = dao;
    }
    //@Autowired
    //private void setDao(BaRoleMapper dao){
    //    this.dao = dao;
    //}
    //@Autowired
    //private void setRolePrivDao(BaRolePrivilegeMapper dao){
    //    this.rolePrivDao = dao;
    //}
    @Autowired
    private void setRolePrivDao(BaRolePrivilegeMapper dao){
        this.rolePrivDao = dao;
    }
    private BaRoleMapper baRoleMapper;
    @Autowired
    private BaRolePermissionsMapper baRolePermissionsMapper;
    /**
     * 根据指定条件(角色编号、角色名称)获取角色列表
     * 当获取一条记录时,传入roleId即可
     * @param queryVo
     * @return
     */
    public QueryResultVo<List<VoRole>> getRoles(QueryVo queryVo) {
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
        Long itemTotal = baRoleMapper.getRecordCount(params);
        QueryResultVo<List<VoRole>> rsVo = new QueryResultVo<>() ;
        Integer pageCurr = 0;
        Integer pageSize = 10000;
        rsVo.pageCurr = 1;
        rsVo.pageSize = 10000;
        if(queryVo.pageSize != null && queryVo.pageCurr != null) {
            rsVo.pageSize = queryVo.pageSize ;
            rsVo.pageCurr = queryVo.pageCurr;
            pageSize = queryVo.pageSize ;
            pageCurr = (Integer.parseInt(params.get("pageCurr").toString()) - 1) * Integer.parseInt(params.get("pageSize").toString());
        }
        params.put("pageCurr", pageCurr);
        params.put("pageSize", pageSize);
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = baRoleMapper.getRoles(params);
        return rsVo ;
    }
    /**
     * 得到所有角色
     * @return 所有角色集合
     */
    public QueryResultVo<List<BaRole>> selectAll(){
        QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>() ;
        rsVo.obj = this.dao.selectAll() ;
        return rsVo ;
    }
    //public QueryResultVo<List<BaRole>> selectAll(){
    //    QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>() ;
    //    rsVo.obj = this.dao.selectAll() ;
    //    return rsVo ;
    //}
    /**
@@ -53,44 +89,47 @@
     * @param id 角色ID
     * @return 角色实体
     */
    public BaRole selectById(Long id){
        return this.dao.selectById(id) ;
    }
    //public BaRole selectById(Long id){
    //    return this.dao.selectById(id) ;
    //}
    /**
     * 得到一个用户
     * @param vo 查询条件值对象
     //* @param vo 查询条件值对象
     * @return 用户实体
     */
    @SuppressWarnings("unchecked")
    public QueryResultVo<List<BaRole>> selectSome(QueryVo vo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ;
        Long itemTotal = this.dao.selectTotal(params) ;
    //public QueryResultVo<List<BaRole>> selectSome(QueryVo vo){
    //    Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(vo) ;
    //    Long itemTotal = this.dao.selectTotal(params) ;
    //
    //    QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>() ;
    //    rsVo.pageSize = vo.pageSize ;
    //    rsVo.pageCurr = vo.pageCurr ;
    //    rsVo.calculateAndSet(itemTotal, params);
    //    rsVo.obj = this.dao.selectSome(params) ;
    //
    //    return rsVo ;
    //}
        QueryResultVo<List<BaRole>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = vo.pageSize ;
        rsVo.pageCurr = vo.pageCurr ;
        rsVo.calculateAndSet(itemTotal, params);
        rsVo.obj = this.dao.selectSome(params) ;
        return rsVo ;
    /**
     * 添加角色
     * @param po 角色实体
     * @return 角色ID
     */
    public Long addRole(BaRole po){
        baRoleMapper.insert(po);
        return po.getId();
    }
    /**
     * 保存实体
     * @param po 实体
     * @return 影响记录数量
     * 根据角色名称查询记录数量,添加角色前判断是否重名
     * @param roleName 角色名称
     * @return 符合条件记录数
     */
    /**
     * 12月20日 朱宝民修改返回值,添加角色后返回主键
     */
    @Transactional
    public Long save(BaRole po){
        //return this.dao.putin(po) ;
        this.dao.putin(po) ;
        return po.getId();
    public Integer getRecordCountByName(String roleName) {
        return baRoleMapper.getRecordCountByName(roleName);
    }
    /**
@@ -98,10 +137,10 @@
     * @param po 实体
     * @return 影响记录数量
     */
    @Transactional
    public int update(BaRole po){
        return this.dao.updateByPrimaryKeySelective(po) ;
    }
    //@Transactional
    //public int update(BaRole po){
    //    return this.dao.updateByPrimaryKeySelective(po) ;
    //}
    /**
     * 设置角色权限
@@ -109,35 +148,36 @@
     * @param priviIds 选择的权限id集合
     * @return 插入角色与权限关联记录数量
     */
    public int setRoles(Long roleId, Long[] priviIds){
        this.rolePrivDao.deleteByRoleId(roleId) ;
        int count = 0 ;
        if(priviIds != null && priviIds.length > 0){
            for(Long privId : priviIds){
                count += this.rolePrivDao.insertSelective(new BaRolePrivilege(roleId, privId)) ;
            }
        }
        return count ;
    }
    //public int setRoles(Long roleId, Long[] priviIds){
    //    this.rolePrivDao.deleteByRoleId(roleId) ;
    //    int count = 0 ;
    //    if(priviIds != null && priviIds.length > 0){
    //        for(Long privId : priviIds){
    //            count += this.rolePrivDao.insertSelective(new BaRolePrivilege(roleId, privId)) ;
    //        }
    //    }
    //    return count ;
    //}
    /**
     * 保存修改实体
     * @param id 实体ID
     * @return 影响记录数量
     */
    @Transactional
    public int delete(Long id){
        //int count = this.dao.deleteLogicById(id) ;
        //逻辑删除,所以不实际删除其关联的权限
        //if(count > 0){
        //    this.rolePrivDao.deleteByRoleId(id) ;
        //}
        //return count ;
        return this.dao.deleteLogicById(id) ;
    }
    //@Transactional
    //public int delete(Long id){
    //    //int count = this.dao.deleteLogicById(id) ;
    //    //逻辑删除,所以不实际删除其关联的权限
    //    //if(count > 0){
    //    //    this.rolePrivDao.deleteByRoleId(id) ;
    //    //}
    //    //return count ;
    //    return this.dao.deleteLogicById(id) ;
    //}
    /**
     * 添加授权记录
     * @Auth 朱宝民
     * @param po
     * @return
     */
@@ -147,6 +187,7 @@
    /**
     * 依据角色编号删除授权记录
     * @Auth 朱宝民
     * @param roleid
     * @return
     */
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/divide/DivideCtrl.java
@@ -68,7 +68,11 @@
    public BaseResponse<QueryResultVo<List<VoDivide>>> getDivides(QueryVo vo){
        try {
            QueryResultVo<List<VoDivide>> res = divideSv.getDivides(vo);
            return BaseResponseUtils.buildSuccess(res);
            if(res.itemTotal != null && res.itemTotal > 0) {
                return BaseResponseUtils.buildSuccess(res);
            }else {
                return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage());
            }
        } catch (Exception e) {
            log.error("获取开卡记录异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -94,7 +98,11 @@
    public BaseResponse<PrDivide> getOneDivide(@PathVariable("id") Long id){
        try {
            PrDivide res = divideSv.getOneDivide(id);
            return BaseResponseUtils.buildSuccess(res);
            if(res != null) {
                return BaseResponseUtils.buildSuccess(res);
            }else {
                return BaseResponseUtils.buildFail(ProjectResultCode.NO_DIVIDES.getMessage());
            }
        } catch (Exception e) {
            log.error("查询农户异常", e);
            return BaseResponseUtils.buildException(e.getMessage()) ;
@@ -153,7 +161,7 @@
    /**
     * 根据分水房ID逻辑删除分水房
     * @param id
     * @param map
     * @return
     */
    @Operation(summary = "删除一个分水房", description = "删除一个分水房数据")
@@ -166,14 +174,19 @@
            )
    })
    @GetMapping(path = "/delone/{id}")
    //@GetMapping(path = "/delone/{id}")
    @PostMapping(path = "delete", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<Boolean> deleteDivideById(@PathVariable("id") Long id){
    public BaseResponse<Boolean> deleteDivideById(@RequestBody Map map){
        Long id = Optional.ofNullable(Long.parseLong(map.get("id").toString())).orElse(0L);
        if(id == 0)
            return BaseResponseUtils.buildException(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
        try {
            Integer res = Optional.ofNullable(divideSv.deleteDivideById(id)).orElse(0);
            if(res == 0) {
                return BaseResponseUtils.buildFail("分水房删除失败");
            }
            if(res == 0)
                return BaseResponseUtils.buildFail(ProjectResultCode.DELETE_DIVIDE_FAIL.getMessage());
            return BaseResponseUtils.buildSuccess(true);
        } catch (Exception e) {
            log.error("删除分水房异常", e);
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/result/ProjectResultCode.java
@@ -17,6 +17,8 @@
     * 分水房
     */
    DIVIDE_FAIL(10001, "分水房添加失败"),
    DELETE_DIVIDE_FAIL(10001, "分水房删除失败"),
    NO_DIVIDES(10001, "无符合条件的分水房记录"),
    /**
     * 取水口