Преглед изворни кода

添加查询酒厂小程序个人信息接口
添加修改手机号邮箱的接口
添加查询子账号列表的接口
添加查询子账号详情的接口

v_HuilingDeng пре 4 година
родитељ
комит
7b20b5d9c6

+ 64 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/controller/wx/WxUserInfoController.java

@@ -0,0 +1,64 @@
+package com.abi.qms.platform.controller.wx;
+
+import com.abi.qms.platform.dto.req.UpdatePhoneEmailWxReq;
+import com.abi.qms.platform.dto.res.GetUserInfoWxRes;
+import com.abi.qms.platform.dto.res.ListSubAccountWxRes;
+import com.abi.qms.platform.service.UserManagerService;
+import com.abi.task.common.api.base.BaseResponse;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 10:13
+ * @Description:
+ */
+@Slf4j
+@RestController
+@RequestMapping("/wxQrPackage")
+@Api(tags = "个人信息")
+public class WxUserInfoController {
+
+    @Autowired
+    private UserManagerService userManagerService;
+
+    @ApiOperation("查询个人信息")
+    @GetMapping("getUserInfoWx/{userId}")
+    public BaseResponse<GetUserInfoWxRes> getUserInfoWx(@PathVariable("userId") Long userId){
+        //查询单个用户信息
+        GetUserInfoWxRes result = userManagerService.getUserInfoWx(userId);
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+    @ApiOperation("修改手机号邮箱")
+    @PostMapping("updatePhoneEmailWx")
+    public BaseResponse<GetUserInfoWxRes> updatePhoneEmailWx(@RequestBody @Valid UpdatePhoneEmailWxReq userId){
+        userManagerService.updatePhoneEmailWx(userId);
+        //包装出参
+        return BaseResponse.create();
+    }
+
+    @ApiOperation("查询子账号列表")
+    @GetMapping("listSubAccountWx")
+    public BaseResponse<ListSubAccountWxRes> listSubAccountWx(){
+        ListSubAccountWxRes result = userManagerService.listSubAccountWx();
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+    @ApiOperation("查询子账号详情")
+    @GetMapping("subAccountDetailWx/{subUserInfoId}")
+    public BaseResponse<ListSubAccountWxRes.SubAccount> subAccountDetailWx(@PathVariable("subUserInfoId") Long subUserInfoId){
+        ListSubAccountWxRes.SubAccount result = userManagerService.subAccountDetailWx(subUserInfoId);
+        //包装出参
+        return BaseResponse.create(result);
+    }
+
+
+}

+ 15 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/UserInfoMapper.java

@@ -1,6 +1,7 @@
 package com.abi.qms.platform.dao.mapper;
 
 import com.abi.qms.platform.dao.entity.UserInfo;
+import com.abi.qms.platform.dao.vo.result.ListSubAccountVO;
 import com.abi.qms.platform.dto.req.BatchEnableUserReq;
 import com.abi.qms.platform.dto.req.ListUserReq;
 import com.abi.qms.platform.dto.res.entity.UserInfoResp;
@@ -34,4 +35,18 @@ public interface UserInfoMapper extends BaseMapper<UserInfo> {
      * @return
      */
     List<UserInfo> selectUserInfoByRoleCodeEnable(@Param("roleCode") String roleCode);
+
+    /**
+     * 查询子账号列表(小程序)
+     * @param factoryId
+     * @return
+     */
+    List<ListSubAccountVO> selectSubAccountList(@Param("factoryId")Long factoryId);
+
+    /**
+     * 根据子账号id查询子账号详情
+     * @param userId
+     * @return
+     */
+    ListSubAccountVO selectSubAccountDetail(@Param("userId")Long userId);
 }

+ 23 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListProductionLineNameVO.java

@@ -0,0 +1,23 @@
+package com.abi.qms.platform.dao.vo.result;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 17:58
+ * @Description: 产线名称List 映射返回
+ */
+@Data
+@ApiModel
+public class ListProductionLineNameVO implements Serializable {
+
+    @ApiModelProperty(value = "啤酒厂员工产线关联id")
+    private Long id;
+
+    @ApiModelProperty(value = "产线名称")
+    private String productionLineName;
+}

+ 36 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/vo/result/ListSubAccountVO.java

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dao.vo.result;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 17:22
+ * @Description: 子账号查询映射结果(小程序)
+ */
+@Data
+@ApiModel
+public class ListSubAccountVO implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "工号")
+    private String employeeNo;
+
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+    @ApiModelProperty(value = "产线名称列表")
+    private List<ListProductionLineNameVO> productionLineNameList;
+}

+ 1 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListFactorySelectReq.java

@@ -22,7 +22,7 @@ public class ListFactorySelectReq implements Serializable {
 
     @NotNull(message = "是否数据隔离为空")
     @ApiModelProperty(value = "是否数据隔离")
-    private Integer dataLimit;
+    private Integer dataLimit = 1;
 
     @ApiModelProperty(value = "是否一级包材厂")
     private Integer isFirstFactory;

+ 22 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/SubAccountDetailWxReq.java

@@ -0,0 +1,22 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/10 17:24
+ * @Description: 查询子账号详情 出参
+ */
+@Data
+@ApiModel
+public class SubAccountDetailWxReq implements Serializable {
+
+    @NotNull(message = "子账号不能为空")
+    @ApiModelProperty(value = "子账号id")
+    private Long id;
+}

+ 36 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/UpdatePhoneEmailWxReq.java

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dto.req;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.Email;
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Pattern;
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 11:47
+ * @Description: 更新手机号和邮箱(小程序) 入参
+ */
+@Data
+@ApiModel
+public class UpdatePhoneEmailWxReq implements Serializable {
+
+    @NotNull(message = "用户id为空")
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @NotEmpty(message = "手机号为空")
+    @Pattern(regexp = "^1[0-9]{10}$", message = "手机格式不正确,请重新输入")
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @NotEmpty(message = "邮箱为空")
+    @Email(message = "邮件格式不正确,请重新输入")
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+}

+ 36 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/GetUserInfoWxRes.java

@@ -0,0 +1,36 @@
+package com.abi.qms.platform.dto.res;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 10:29
+ * @Description: 查询个人信息(微信)
+ */
+@Data
+@ApiModel
+public class GetUserInfoWxRes implements Serializable {
+
+    @ApiModelProperty(value = "用户id")
+    private Long id;
+
+    @ApiModelProperty(value = "用户名")
+    private String userName;
+
+    @ApiModelProperty(value = "工号")
+    private String employeeNo;
+
+    @ApiModelProperty(value = "手机号")
+    private String phone;
+
+    @ApiModelProperty(value = "邮箱")
+    private String email;
+
+    @ApiModelProperty(value = "是否主账号")
+    private Integer isMainAccount;
+
+}

+ 70 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListSubAccountWxRes.java

@@ -0,0 +1,70 @@
+package com.abi.qms.platform.dto.res;
+
+import com.abi.qms.platform.dao.vo.result.ListProductionLineNameVO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import lombok.ToString;
+
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * @author Eurus
+ * @date 2021/6/9 18:23
+ * @Description: 查询子账号列表(小程序) 出参
+ */
+@Data
+@ApiModel
+public class ListSubAccountWxRes implements Serializable {
+
+    @ApiModelProperty(value = "子账号列表")
+    private List<SubAccount> subAccountList;
+
+    /**
+     * 产线bean
+     */
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ToString
+    @ApiModel(value = "ListSubAccountRes_ProductionLineName")
+    public static class ProductionLineName implements Serializable {
+        @ApiModelProperty(value = "啤酒厂员工产线关联id")
+        private Long id;
+
+        @ApiModelProperty(value = "产线名称")
+        private String productionLineName;
+    }
+
+    /**
+     * 子账号bean
+     */
+    @Data
+    @NoArgsConstructor
+    @AllArgsConstructor
+    @ToString
+    @ApiModel(value = "ListSubAccountRes_SubAccount")
+    public static class SubAccount implements Serializable {
+        @ApiModelProperty(value = "用户id")
+        private Long id;
+
+        @ApiModelProperty(value = "用户名")
+        private String userName;
+
+        @ApiModelProperty(value = "工号")
+        private String employeeNo;
+
+        @ApiModelProperty(value = "手机号")
+        private String phone;
+
+        @ApiModelProperty(value = "邮箱")
+        private String email;
+
+        @ApiModelProperty(value = "产线名称列表")
+        private List<ProductionLineName> productionLineNameList;
+    }
+
+}

+ 29 - 4
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/UserManagerService.java

@@ -2,10 +2,7 @@ package com.abi.qms.platform.service;
 
 
 import com.abi.qms.platform.dto.req.*;
-import com.abi.qms.platform.dto.res.GetUserInfoRes;
-import com.abi.qms.platform.dto.res.ListRoleTreeRes;
-import com.abi.qms.platform.dto.res.ListUserRes;
-import com.abi.task.common.api.base.BaseResponse;
+import com.abi.qms.platform.dto.res.*;
 
 
 /**
@@ -70,4 +67,32 @@ public interface UserManagerService {
      * @throws Exception
      */
     void batchEnableUser(BatchEnableUserReq req)throws Exception;
+
+    /**
+     * 根据id查询单个用户信息(小程序)
+     *
+     * @param userInfoId
+     * @return
+     * @throws Exception
+     */
+    GetUserInfoWxRes getUserInfoWx(Long userInfoId);
+
+    /**
+     * 更新手机号和邮箱(小程序)
+     * @param updatePhoneEmailWxReq
+     */
+    void updatePhoneEmailWx(UpdatePhoneEmailWxReq updatePhoneEmailWxReq);
+
+    /**
+     * 查询子账号列表(小程序)
+     * @return
+     */
+    ListSubAccountWxRes listSubAccountWx();
+
+    /**
+     * 查询子账号详情
+     * @param subUserInfoId
+     * @return
+     */
+    ListSubAccountWxRes.SubAccount subAccountDetailWx(Long subUserInfoId);
 }

+ 66 - 16
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/UserManagerServiceImpl.java

@@ -1,21 +1,12 @@
 package com.abi.qms.platform.service.impl;
 
-import com.abi.qms.platform.dao.entity.BaseFactory;
-import com.abi.qms.platform.dao.entity.UserInfo;
-import com.abi.qms.platform.dao.entity.UserMappingInfoRole;
-import com.abi.qms.platform.dao.entity.UserRole;
+import cn.hutool.core.collection.CollectionUtil;
+import com.abi.qms.platform.dao.entity.*;
 import com.abi.qms.platform.dao.enums.TrueFalseEnum;
-import com.abi.qms.platform.dao.mapper.BaseFactoryMapper;
-import com.abi.qms.platform.dao.mapper.UserInfoMapper;
-import com.abi.qms.platform.dao.mapper.UserMappingInfoRoleMapper;
-import com.abi.qms.platform.dao.mapper.UserRoleMapper;
-import com.abi.qms.platform.dto.req.BatchEnableUserReq;
-import com.abi.qms.platform.dto.req.CreateUserReq;
-import com.abi.qms.platform.dto.req.ListUserReq;
-import com.abi.qms.platform.dto.req.UpdateUserReq;
-import com.abi.qms.platform.dto.res.GetUserInfoRes;
-import com.abi.qms.platform.dto.res.ListRoleTreeRes;
-import com.abi.qms.platform.dto.res.ListUserRes;
+import com.abi.qms.platform.dao.mapper.*;
+import com.abi.qms.platform.dao.vo.result.ListSubAccountVO;
+import com.abi.qms.platform.dto.req.*;
+import com.abi.qms.platform.dto.res.*;
 import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.infrastructure.util.PageUtil;
 import com.abi.qms.platform.infrastructure.util.UserUtil;
@@ -27,11 +18,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
-import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 
@@ -64,6 +55,9 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
     @Autowired
     private UserUtil userUtil;
 
+    @Autowired
+    private UserRoleDetailMapper userRoleDetailMapper;
+
     /**
      * 创建用户
      **/
@@ -266,5 +260,61 @@ public class UserManagerServiceImpl extends ServiceImpl<UserInfoMapper, UserInfo
         userInfoMapper.batchEnableUser(req);
     }
 
+    @Override
+    public GetUserInfoWxRes getUserInfoWx(Long userInfoId) {
+        //查询用户
+        UserInfo userInfo = userInfoMapper.selectById(userInfoId);
+
+        //构造出参
+        GetUserInfoWxRes getUserInfoWxRes = PojoConverterUtils.copy(userInfo,GetUserInfoWxRes.class);
+        getUserInfoWxRes.setIsMainAccount(userUtil.getWholeUser().getIsMainAccount());
+
+        return getUserInfoWxRes;
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void updatePhoneEmailWx(UpdatePhoneEmailWxReq req) {
+        //0-校验入参
+        UserInfo userInfo = userInfoMapper.selectById(req.getId());
+        if(Objects.isNull(userInfo)){
+            throw new BusinessException("该用户不存在。");
+        }
+        userInfo.setEmail(req.getEmail());
+        userInfo.setPhone(req.getPhone());
+        userInfo.setUpdateBy(userUtil.getWholeUser().getId());
+        userInfoMapper.updateById(userInfo);
+    }
+
+    @Override
+    public ListSubAccountWxRes listSubAccountWx() {
+        ListSubAccountWxRes listSubAccountWxRes = new ListSubAccountWxRes();
+        List<ListSubAccountVO> listSubAccountVOList = userInfoMapper.selectSubAccountList(userUtil.getWholeUser().getFactoryId());
+        if (CollectionUtil.isNotEmpty(listSubAccountVOList)) {
+            List<ListSubAccountWxRes.SubAccount> subAccountList = new ArrayList<>();
+            //循环构造出参
+            listSubAccountVOList.forEach(listSubAccountVO -> {
+                ListSubAccountWxRes.SubAccount subAccount = PojoConverterUtils.copy(listSubAccountVO, ListSubAccountWxRes.SubAccount.class);
+                List<ListSubAccountWxRes.ProductionLineName> productionLineNames = PojoConverterUtils.copyList(listSubAccountVO.getProductionLineNameList(), ListSubAccountWxRes.ProductionLineName.class);
+                subAccount.setProductionLineNameList(productionLineNames);
+                subAccountList.add(subAccount);
+            });
+            listSubAccountWxRes.setSubAccountList(subAccountList);
+        }
+        return listSubAccountWxRes;
+    }
+
+    @Override
+    public ListSubAccountWxRes.SubAccount subAccountDetailWx(Long subUserInfoId) {
+        ListSubAccountVO listSubAccountVO = userInfoMapper.selectSubAccountDetail(subUserInfoId);
+        if(Objects.nonNull(listSubAccountVO)){
+            ListSubAccountWxRes.SubAccount subAccount = PojoConverterUtils.copy(listSubAccountVO, ListSubAccountWxRes.SubAccount.class);
+            List<ListSubAccountWxRes.ProductionLineName> productionLineNames = PojoConverterUtils.copyList(listSubAccountVO.getProductionLineNameList(), ListSubAccountWxRes.ProductionLineName.class);
+            subAccount.setProductionLineNameList(productionLineNames);
+            return subAccount;
+        }
+        return null;
+    }
+
 
 }

+ 50 - 0
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/UserInfoMapper.xml

@@ -24,6 +24,21 @@
         <result column="UPDATE_BY" property="updateBy" />
     </resultMap>
 
+    <!--子账号查询映射结果(小程序)-->
+    <resultMap id="SubAccountResultMap" type="com.abi.qms.platform.dao.vo.result.ListSubAccountVO">
+        <id column="ID" property="id"/>
+        <result column="USER_NAME" property="userName"/>
+        <result column="EMPLOYEE_NO" property="employeeNo"/>
+        <result column="PHONE" property="phone"/>
+        <result column="EMAIL" property="email"/>
+
+        <collection property="productionLineNameList" javaType="java.util.List"
+                    ofType="com.abi.qms.platform.dao.vo.result.ListProductionLineNameVO">
+            <result property="id" column="production_line_id"/>
+            <result property="productionLineName" column="production_line_name"/>
+        </collection>
+    </resultMap>
+
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id, user_name, employee_no, phone, email, login_name, password, is_abi, factory_id, factory_type, role_code, is_enable, create_time, create_by, update_time, is_delete,update_by
@@ -78,4 +93,39 @@
         from user_info
         WHERE role_code = #{roleCode} AND is_enable = 1 and is_delete = 0
     </select>
+
+    <!--查询子账号列表(小程序)-->
+    <select id="selectSubAccountList" resultMap="SubAccountResultMap">
+        SELECT
+        ui.id,
+        ui.USER_NAME,
+        ui.EMPLOYEE_NO,
+        ui.PHONE,
+        ui.EMAIL,
+        bpl.id as production_line_id,
+        bpl.production_line_name
+        from user_info ui
+        inner JOIN user_role_detail urd ON ui.role_code = urd.role_code
+        LEFT JOIN brewery_production_line bpl ON ui.id = bpl.user_name
+        WHERE  ui.factory_id = #{factoryId}
+        and ui.is_enable = 1 and ui.is_delete = 0
+        and urd.is_activate_mini_app_main_account = 0
+        and urd.is_activate_mini_app_sub_account = 1
+    </select>
+
+    <!--查询子账号详情-->
+    <select id="selectSubAccountDetail" resultMap="SubAccountResultMap">
+        SELECT
+        ui.id,
+        ui.USER_NAME,
+        ui.EMPLOYEE_NO,
+        ui.PHONE,
+        ui.EMAIL,
+        bpl.id as production_line_id,
+        bpl.production_line_name
+        from user_info ui
+        inner JOIN user_role_detail urd ON ui.role_code = urd.role_code
+        LEFT JOIN brewery_production_line bpl ON ui.id = bpl.user_name
+        WHERE  ui.id = #{userId}
+    </select>
 </mapper>