Преглед на файлове

feat:新增获取组织列表接口
feat:新增获取微信用户信息接口

黄渊昊 преди 5 месеца
родител
ревизия
ed81ac3e5d

+ 2 - 3
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/alarmuser/controller/AlarmUserController.java

@@ -136,8 +136,7 @@ public class AlarmUserController {
      */
     @Operation(summary = "获取微信用户信息")
     @GetMapping("/coldchain/alarmuser/getUserInfo")
-    public CommonResult<AlarmUser> getUserInfo(String code) {
-        alarmUserService.getUserInfo(code);
-        return CommonResult.ok();
+    public CommonResult<String> getUserInfo(String code,String orgId) {
+        return CommonResult.data(alarmUserService.getUserInfo(code,orgId));
     }
 }

+ 1 - 1
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/alarmuser/service/AlarmUserService.java

@@ -87,5 +87,5 @@ public interface AlarmUserService extends IService<AlarmUser> {
      * 获取微信用户信息
      * @param code
      */
-    void getUserInfo(String code);
+    String getUserInfo(String code,String orgId);
 }

+ 18 - 7
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/alarmuser/service/impl/AlarmUserServiceImpl.java

@@ -115,23 +115,34 @@ public class AlarmUserServiceImpl extends ServiceImpl<AlarmUserMapper, AlarmUser
     }
 
     @Override
-    public void getUserInfo(String code) {
+    public String getUserInfo(String code,String orgId) {
         WeChatUser userInfo = PushUtil.getUserInfo(code);
         log.info("获取用户信息……:{}", userInfo.getOpenid());
         if(ObjectUtil.isEmpty(userInfo)) {
             throw new CommonException("获取用户信息失败");
         }
-        AlarmUser alarmUser = getByOpenId(userInfo.getOpenid());
-        if (ObjectUtil.isNotNull(alarmUser)) {
-            this.updateById(alarmUser);
+        List<AlarmUser> userList = getByOpenId(userInfo.getOpenid(),orgId);
+        AlarmUser alarmUser = BeanUtil.copyProperties(userInfo, AlarmUser.class);
+        alarmUser.setOpenId(userInfo.getOpenid());
+        alarmUser.setUnionId(userInfo.getUnionid());
+        alarmUser.setNickName(userInfo.getNickname());
+        alarmUser.setCreateOrg(orgId);
+        if (!userList.isEmpty()) {
+            for (AlarmUser user : userList) {
+                alarmUser.setId(user.getId());
+                updateById(alarmUser);
+            }
+            return "您已绑定过该组织,已为您更新个人信息";
         } else {
             this.save(alarmUser);
+            return "绑定成功!";
         }
     }
 
-    AlarmUser getByOpenId(String openId) {
+    List<AlarmUser> getByOpenId(String openId,String orgId) {
         LambdaQueryWrapper<AlarmUser> queryWrapper = new LambdaQueryWrapper<>();
-        queryWrapper.eq(AlarmUser::getOpenId, openId).eq(AlarmUser::getDeleteFlag, CommonDeleteFlagEnum.NOT_DELETE);
-        return getOne(queryWrapper);
+        queryWrapper.eq(AlarmUser::getOpenId, openId).eq(AlarmUser::getCreateOrg, orgId)
+                .eq(AlarmUser::getDeleteFlag, CommonDeleteFlagEnum.NOT_DELETE);
+        return list(queryWrapper);
     }
 }

+ 5 - 0
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/files/fileController.java

@@ -4,6 +4,9 @@ import cn.hutool.core.io.IoUtil;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import jakarta.servlet.http.HttpServletResponse;
+import lombok.extern.slf4j.Slf4j;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -22,6 +25,7 @@ import static cn.dev33.satoken.SaManager.log;
 @Tag(name = "文件控制器")
 @RestController
 @Validated
+@Slf4j
 public class fileController {
 
     @Value("${file.path}")
@@ -31,6 +35,7 @@ public class fileController {
     @RequestMapping("/download")
     public void fileDownLoad(HttpServletResponse response, @RequestParam("fileName") String fileName) throws IOException {
         File file = new File(filePath, fileName);
+        log.info(file.getAbsolutePath() + "--------" + filePath);
         if(!file.exists()){
             throw new CommonException("下载文件不存在");
         }

+ 0 - 1
snowy-plugin/snowy-plugin-coldchain/src/main/java/vip/xiaonuo/coldchain/modular/monitordevice/param/MonitorDeviceAddParam.java

@@ -40,7 +40,6 @@ public class MonitorDeviceAddParam {
      */
     @Schema(description = "设备编码")
     @NotNull(message = "设备编码不能为空")
-    @Pattern(regexp = "^[0-9]+$", message = "设备编码必须是数字字符串")
     private String deviceCode;
 
     /**

+ 9 - 0
snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/org/controller/SysOrgController.java

@@ -151,4 +151,13 @@ public class SysOrgController {
     public CommonResult<Page<SysUser>> userSelector(SysOrgSelectorUserParam sysOrgSelectorUserParam) {
         return CommonResult.data(sysOrgService.userSelector(sysOrgSelectorUserParam));
     }
+
+    /**
+     * 获取组织列表
+     */
+    @Operation(summary = "获取组织列表")
+    @GetMapping("/sys/org/list")
+    public CommonResult<List<SysOrg>> list() {
+        return CommonResult.data(sysOrgService.myList());
+    }
 }

+ 2 - 0
snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/org/service/SysOrgService.java

@@ -172,4 +172,6 @@ public interface SysOrgService extends IService<SysOrg> {
      * @date 2022/4/24 20:08
      */
     Page<SysUser> userSelector(SysOrgSelectorUserParam sysOrgSelectorUserParam);
+
+    List<SysOrg> myList();
 }

+ 8 - 0
snowy-plugin/snowy-plugin-sys/src/main/java/vip/xiaonuo/sys/modular/org/service/impl/SysOrgServiceImpl.java

@@ -31,6 +31,7 @@ import jakarta.annotation.Resource;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import vip.xiaonuo.common.cache.CommonCacheOperator;
+import vip.xiaonuo.common.enums.CommonDeleteFlagEnum;
 import vip.xiaonuo.common.enums.CommonSortOrderEnum;
 import vip.xiaonuo.common.exception.CommonException;
 import vip.xiaonuo.common.listener.CommonDataChangeEventCenter;
@@ -331,6 +332,13 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme
         }
     }
 
+    @Override
+    public List<SysOrg> myList() {
+        LambdaQueryWrapper<SysOrg> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysOrg::getDeleteFlag, CommonDeleteFlagEnum.NOT_DELETE);
+        return list(queryWrapper);
+    }
+
     /* ====以下为各种递归方法==== */
 
     @Override

+ 7 - 1
snowy-web-app/src/main/java/vip/xiaonuo/core/config/GlobalConfigure.java

@@ -136,7 +136,13 @@ public class GlobalConfigure implements WebMvcConfigurer {
             "/sys/userCenter/getPicCaptcha", "/sys/userCenter/findPasswordGetPhoneValidCode", "/sys/userCenter/findPasswordGetEmailValidCode", "/sys/userCenter/findPasswordByPhone", "/sys/userCenter/findPasswordByEmail",
 
             /* 微信验证 */
-            "/MP_verify_qQhnU3oZbJiKmywt.txt"
+            "/MP_verify_qQhnU3oZbJiKmywt.txt",
+
+            /* 获取组织列表 */
+            "/sys/org/list",
+
+            /* 微信获取用户信息 */
+            "/coldchain/alarmuser/getUserInfo"
     };
 
     /**

+ 2 - 3
snowy-web-app/src/main/java/vip/xiaonuo/weixin/miniapp/controller/WxPortalController.java

@@ -125,8 +125,7 @@ public class WxPortalController {
     }
 
     @GetMapping("/pc")
-    private CommonResult<String> getUserInfo(String code) {
-        alarmUserService.getUserInfo(code);
-        return CommonResult.ok();
+    private CommonResult<String> getUserInfo(String code,String orgId) {
+        return CommonResult.data(alarmUserService.getUserInfo(code,orgId));
     }
 }

+ 4 - 4
snowy-web-app/src/main/resources/application.properties

@@ -246,8 +246,8 @@ wechat.appID=wx49b1fb6f9c0d0b8d
 wechat.secret=6b177348efc2b21da105fc126b933db9
 wechat.templateId=WgKOAJrnNhnr2lIkfI_vppfY--7oImjddrd4GPnE_UA
 wechat.miniProgram=wx1eebc072a607c055
-wechat.getAccessTokenUrl=https://api.weixin.qq.com/sns/oauth2/access_token
-wechat.getUserInfoUrl=https://api.weixin.qq.com/sns/userinfo
+wechat.accessTokenUrl=https://api.weixin.qq.com/sns/oauth2/access_token
+wechat.userInfoUrl=https://api.weixin.qq.com/sns/userinfo
 
-#file.path=/software/coldchain/ui/dist
-file.path=C:/Users/xiaozun/Desktop
+file.path=/software/coldchain/ui/dist
+#file.path=C:/Users/xiaozun/Desktop