liurunyu
2023-12-05 e1357ea1af1a473dc9fa93be458fd1578885630c
1、用户增加所属片区外键ID;
2、修改重置密码的方法名;
4个文件已修改
86 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml 43 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java 23 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/java/com/dy/pipIrrGlobal/pojoBa/BaUser.java
@@ -55,6 +55,12 @@
    @Schema(description = "实体id", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    public Long id;
    @Schema(description = "所属片区ID", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @JSONField(serializeUsing= ObjectWriterImplToString.class)
    @TableField(value = "blockId")
    public Long blockId ;
    /**
     * 用户姓名
     */
@@ -120,6 +126,14 @@
    /**
     * 用户所属角色Id
     */
    @Schema(hidden = true)
    @TableField(exist = false)
    public String[] roleIds ;
    /**
     * 所属片区名称
     */
    @Schema(description = "所属片区名称,表单不用填写", requiredMode = Schema.RequiredMode.NOT_REQUIRED)
    @TableField(exist = false)
    public String blockName ;
}
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -7,6 +7,7 @@
        <!--@mbg.generated-->
        <!--@Table ba_user-->
        <id property="id" column="id" />
        <result property="blockId" column="blockId"/>
        <result property="name" column="name"/>
        <result property="phone" column="phone"/>
        <result property="password" column="password"/>
@@ -29,6 +30,7 @@
    <resultMap id="loginResultMap" type="com.dy.pipIrrGlobal.pojoBa.BaUser">
        <id property="id" column="id" />
        <result property="blockId" column="blockId"/>
        <result property="name" column="name"/>
        <result property="phone" column="phone"/>
        <result property="orgTag" column="orgTag"/>
@@ -40,15 +42,15 @@
    </resultMap>
    <sql id="Base_Column_List">
        id, name, phone, password, orgTag, supperAdmin, disabled, deleted
        id, blockId, name, phone, password, orgTag, supperAdmin, disabled, deleted
    </sql>
    <sql id="part_Column_List">
        id, name, phone, disabled
        ${alias}.id, ${alias}.name, ${alias}.phone, ${alias}.disabled
    </sql>
    <sql id="Login_Column_List">
        id, name, phone, orgTag, supperAdmin
        id, blockId, name, phone, orgTag, supperAdmin
    </sql>
    <select id="login" resultMap="loginResultMap" >
@@ -61,7 +63,8 @@
    <select id="selectTotal" parameterType="java.util.Map" resultType="java.lang.Long">
        select
        count(*)
        from ba_user where supperAdmin!=1 and deleted!=1
        from ba_user
        where supperAdmin!=1 and deleted!=1
        <trim prefix="and" suffixOverrides="and">
            <if test="name != null">
                name like concat('%', #{name}, '%') and
@@ -73,14 +76,19 @@
    </select>
    <select id="selectSome" parameterType="java.util.Map" resultMap="someResultMap">
        select
        <include refid="part_Column_List" />
        from ba_user where supperAdmin!=1 and deleted!=1
        <include refid="part_Column_List" >
            <property name="alias" value="bu"/>
        </include>,
        bb.`name` blockName
        from ba_user bu
        left join ba_block bb on bu.blockId = bb.id
        where bu.supperAdmin!=1 and bu.deleted!=1
        <trim prefix="and" suffixOverrides="and">
            <if test="name != null">
                name like concat('%', #{name}, '%') and
                bu.name like concat('%', #{name}, '%') and
            </if>
            <if test="phone != null">
                phone = #{phone,jdbcType=VARCHAR}
                bu.phone = #{phone,jdbcType=VARCHAR}
            </if>
        </trim>
        order by id DESC
@@ -93,6 +101,7 @@
    <insert id="putin" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
        insert into ba_user (<include refid="Base_Column_List" />)
        values (#{id,jdbcType=BIGINT},
        #{blockId,jdbcType=BIGINT},
        #{name,jdbcType=VARCHAR},
        #{phone,jdbcType=VARCHAR},
        #{password,jdbcType=VARCHAR},
@@ -108,7 +117,10 @@
            <if test="id != null">
                id,
            </if>
            <if test="name != null">
            <if test="blockId != null">
                blockId,
            </if>
           <if test="name != null">
                `name`,
            </if>
            <if test="phone != null">
@@ -134,7 +146,10 @@
            <if test="id != null">
                #{id,jdbcType=BIGINT},
            </if>
            <if test="name != null">
            <if test="blockId != null">
                #{blockId,jdbcType=BIGINT},
            </if>
           <if test="name != null">
                #{name,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
@@ -161,7 +176,10 @@
    <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
        update ba_user
        <set>
            <if test="name != null">
            <if test="blockId != null">
                blockId = #{blockId,jdbcType=BIGINT},
            </if>
           <if test="name != null">
                `name` = #{name,jdbcType=VARCHAR},
            </if>
            <if test="phone != null">
@@ -181,7 +199,8 @@
    </update>
    <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoBa.BaUser">
        update ba_user
        set `name` = #{name,jdbcType=VARCHAR},
        set blockId = #{blockId,jdbcType=BIGINT},
        `name` = #{name,jdbcType=VARCHAR},
        phone = #{phone,jdbcType=VARCHAR},
        password = #{password,jdbcType=VARCHAR},
        disabled = #{disabled,typeHandler=com.dy.common.mybatis.envm.EnumCodeTypeHandler, jdbcType=TINYINT},
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
@@ -115,7 +115,6 @@
        }
        po.id = null;
        int count;
        int count1;
        try {
            po.disabled = Disabled.NO;//默认不禁用
            po.deleted = Deleted.NO;//默认不删除
@@ -130,12 +129,12 @@
                po.password = MD5.encrypt(defaultPassword);
            }
            count = this.sv.save(po);
            count1 = this.sv.setRoles(String.valueOf(po.id), po.roleIds);
            this.sv.setRoles(po.id, po.roleIds);
        } catch (Exception e) {
            log.error("保存用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        if (count <= 0 || count1 <= 0) {
        if (count <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
@@ -171,6 +170,7 @@
            po.deleted = null;//设置为null,不做更新
            po.orgTag = null;//设置为null,不做更新
            count = this.sv.update(po);
            this.sv.setRoles(po.id, po.roleIds);
        } catch (Exception e) {
            log.error("保存用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
@@ -250,7 +250,7 @@
     * @param id 用户ID
     * @return 是否成功
     */
    @Operation(summary = "重置密码", description = "提交用户ID")
    @Operation(summary = "重置密码为默认密码", description = "提交用户ID")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
@@ -259,9 +259,9 @@
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @GetMapping(path = "resetPassword", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "resetPasswordByDefault", consumes = MediaType.TEXT_PLAIN_VALUE)
    @SsoAop("-1")//@SsoAop(power = "-1")
    public BaseResponse<Boolean> resetPassword(@Parameter(description = "实体id", required = true) String id) throws Exception {
    public BaseResponse<Boolean> resetPasswordByDefault(@Parameter(description = "实体id", required = true) String id) throws Exception {
        if (id == null) {
            return BaseResponseUtils.buildFail("id不能为空");
        }
@@ -292,7 +292,7 @@
     * @param id 用户ID
     * @return 是否成功
     */
    @Operation(summary = "重置密码", description = "提交用户ID")
    @Operation(summary = "重置密码为随机数字加字母", description = "提交用户ID")
    @ApiResponses(value = {
            @ApiResponse(
                    responseCode = ResultCodeMsg.RsCode.SUCCESS_CODE,
@@ -301,9 +301,9 @@
                            schema = @Schema(implementation = Boolean.class))}
            )
    })
    @GetMapping(path = "resetPassword1", consumes = MediaType.TEXT_PLAIN_VALUE)
    @GetMapping(path = "resetPasswordByRandom", consumes = MediaType.TEXT_PLAIN_VALUE)
    @SsoAop("-1")//@SsoAop(power = "-1")
    public BaseResponse<String> resetPassword1(@Parameter(description = "实体id", required = true) String id) throws Exception {
    public BaseResponse<String> resetPasswordByRandom(@Parameter(description = "实体id", required = true) String id) throws Exception {
        if (id == null) {
            return BaseResponseUtils.buildFail("id不能为空");
        }
@@ -331,11 +331,12 @@
    /**
     * 2023-12-05 在 save和update方法中进行了角色设置关联,本方法废弃
     * 设置用户角色
     *
     * @param id 用户ID
     * @return 是否成功
     */
    @Operation(summary = "设置用户角色", description = "提交用户ID,及所选择的角色ID集合(数组)")
    @ApiResponses(value = {
            @ApiResponse(
@@ -365,7 +366,7 @@
        }
        return BaseResponseUtils.buildSuccess(true);
    }
     */
    /**
     * 删除用户
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -119,12 +119,12 @@
     * @param roleIds 选择的角色id集合
     * @return 插入用户与角色关联记录数量
     */
    public int setRoles(String userId, String[] roleIds) {
        this.urDao.deleteByUserId(Long.parseLong(userId));
    public int setRoles(Long userId, String[] roleIds) {
        this.urDao.deleteByUserId(userId);
        int count = 0;
        if (roleIds != null && roleIds.length > 0) {
            for (String roleId : roleIds) {
                count += this.urDao.insertSelective(new BaUserRole(Long.parseLong(userId), Long.parseLong(roleId)));
                count += this.urDao.insertSelective(new BaUserRole(userId, Long.parseLong(roleId)));
            }
        }
        return count;