Administrator
2024-02-26 0d545d5a305a4da5d06d916cc213b87d4a5bbeb6
2024-02-26 朱宝民 修改用户添加接口、获取一页用户接口
5个文件已修改
37 ■■■■■ 已修改文件
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/QueryVo.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
pipIrr-platform/pipIrr-common/src/main/java/com/dy/common/mybatis/AutoGenerateIdInterceptor.java
@@ -44,10 +44,10 @@
                Class<?> entityClass = entity.getClass();
                Method setMt = null ;
                try{
                    // 判断主键是id还是userId
                    // 添加用户时userId为自动生成主键。roleId存在时是为用户绑角色
                    String jsonString = JSONObject.toJSONString(entity, JSONWriter.Feature.WriteMapNullValue);
                    JSONObject jsonObject = JSONObject.parseObject(jsonString);
                    if(jsonObject.containsKey("userId")) {
                    if(jsonObject.containsKey("userId") && !jsonObject.containsKey("roleId")) {
                        setMt = entityClass.getMethod(BASE_FIELD_SET_PRIMARY_KEY_FUNTION_NAME2, Long.class) ;
                    }else {
                        //有一些实体没有id,例如中间表
pipIrr-platform/pipIrr-global/src/main/resources/mapper/BaUserMapper.xml
@@ -271,8 +271,8 @@
            AND user.supperAdmin != 1
            AND user.deleted = 0
            <if test = "name != null and name !=''">
                AND user.name like CONCAT('%',#{name},'%')
            <if test = "userName != null and userName !=''">
                AND user.name like CONCAT('%',#{userName},'%')
            </if>
            <if test = "phone != null and phone !=''">
@@ -304,8 +304,8 @@
            AND user.supperAdmin != 1
            AND user.deleted = 0
            <if test = "name != null and name !=''">
                AND user.name like CONCAT('%',#{name},'%')
            <if test = "userName != null and userName !=''">
                AND user.name like CONCAT('%',#{userName},'%')
            </if>
            <if test = "phone != null and phone !=''">
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/QueryVo.java
@@ -15,7 +15,7 @@
public class QueryVo extends QueryConditionVo {
    @Schema(description = "用户姓名")
    public String name;
    public String userName;
    @Schema(description = "用户姓名电话")
    public String phone;
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserCtrl.java
@@ -89,11 +89,18 @@
            )
    })
    @GetMapping(path = "some")
    //@PostMapping(path = "some", consumes = MediaType.APPLICATION_JSON_VALUE)
    @SsoAop()
    public BaseResponse<QueryResultVo<List<VoUserInfo>>> some(QueryVo vo) {
        try {
            QueryResultVo<List<VoUserInfo>> res = this.sv.selectSome(vo);
            return BaseResponseUtils.buildSuccess(res);
            if(res.itemTotal == 0) {
                return BaseResponseUtils.buildFail(SystemResultCode.THE_USER_NOT_EXIST.getMessage());
            }else {
                return BaseResponseUtils.buildSuccess(res);
            }
        } catch (Exception e) {
            log.error("查询用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
@@ -143,7 +150,7 @@
            return BaseResponseUtils.buildFail(Objects.requireNonNull(bindingResult.getFieldError()).getDefaultMessage());
        }
        po.userId = null;
        int count;
        Long userId;
        try {
            po.supperAdmin = Constant.no.byteValue() ;
            po.disabled = Disabled.NO;//默认不禁用
@@ -158,13 +165,13 @@
            } else {
                po.password = MD5.encrypt(defaultPassword);
            }
            count = this.sv.save(po);
            this.sv.setRoles(po.userId, po.roleIds);
            userId = this.sv.save(po);
            this.sv.setRoles(userId, po.roleIds);
        } catch (Exception e) {
            log.error("保存用户异常", e);
            return BaseResponseUtils.buildException(e.getMessage());
        }
        if (count <= 0) {
        if (userId <= 0) {
            return BaseResponseUtils.buildFail("数据库存储失败");
        } else {
            return BaseResponseUtils.buildSuccess(true);
pipIrr-platform/pipIrr-web/pipIrr-web-base/src/main/java/com/dy/pipIrrBase/user/UserSv.java
@@ -113,8 +113,10 @@
     * @return 影响记录数量
     */
    @Transactional
    public int save(BaUser po){
        return this.dao.putin(po) ;
    public Long save(BaUser po){
        //return this.dao.putin(po) ;
        this.dao.putin(po) ;
        return po.getUserId();
    }
    /**