935090232@qq.com
2022-03-20 e23c8975e6bb0934cb5db46a94d0f83c9739d9ab
zq-erp/src/main/java/com/matrix/system/app/action/ApiCommonAction.java
@@ -59,6 +59,9 @@
@RestController
@RequestMapping(value = "/api/common")
public class ApiCommonAction {
    @Autowired
    UploadUtil uploadUtil;
    @Autowired
    private SysUsersService sysUsersService;
@@ -169,11 +172,12 @@
        EXT_LIST.add(FileType.PNG);
    }
    @ApiOperation(value = "表单图片上传接口", notes = "表单图片上传接口")
    @PostMapping(value = "/uploadImg")
    public AjaxResult uploadImg(HttpServletResponse response, MultipartHttpServletRequest request)
            throws IOException, FileUploadException, NoSuchAlgorithmException {
        Map<String, String> fileMap = UploadUtil.doUpload(request, EXT_LIST, folderType, 1L);
        Map<String, String> fileMap = uploadUtil.doUpload(request, EXT_LIST, folderType, 1L);
        AjaxResult ajaxResult = AjaxResult.buildSuccessInstance("上传成功");
        ajaxResult.putInMap("file", fileMap.get("visitPath"));
        return ajaxResult;
@@ -281,6 +285,7 @@
        }
        AjaxResult ajaxResult = new AjaxResult();
        ajaxResult.setStatus(AjaxResult.STATUS_SUCCESS);
        ajaxResult.putInMap("url", list.get(0).getComWebUrl());
        return ajaxResult;
    }
@@ -292,7 +297,7 @@
            return AjaxResult.buildFailInstance("code不存在");
        }
        AjaxResult res = new AjaxResult();
        String requrl = weChatApiTools.getXcxLoginUrl(code, HostInterceptor.getCompanyId(), AppConstance.MINI_PROGRAM_MANAGER_APP_ID);
        String requrl = weChatApiTools.getManagerXcxLoginUrl(code);
        String resultData = HttpCurlUtil.sendGetHttp(requrl, null);
        JSONObject json = JSONObject.fromObject(resultData);
@@ -316,8 +321,23 @@
        String token = userCacheManager.saveUserInfo(hasBind);
        LogUtil.info("用户token={}", token);
        authorityManager.initUserPower(res, hasBind);
        UserInfoVo userInfoVo = new UserInfoVo();
        if(hasBind.getShopId()!=null){
            SysShopInfo shopInfo = sysShopInfoService.findById(hasBind.getShopId());
            hasBind.setShopName(shopInfo.getShopName());
            userInfoVo.setShopName(shopInfo.getShopShortName());
        }
        userInfoVo.setId(hasBind.getSuId());
        userInfoVo.setName(hasBind.getSuName());
        userInfoVo.setRoleName(hasBind.getRoleName());
        userInfoVo.setPhoto(hasBind.getSuPhoto());
        res.putInMap("token", token);
        res.putInMap("userInfo", hasBind);
        res.putInMap("userInfo", userInfoVo);
        return res;
    }
@@ -335,8 +355,21 @@
        AjaxResult result = AjaxResult.buildSuccessInstance("登陆成功");
        authorityManager.initUserPower(result, user);
        UserInfoVo userInfoVo = new UserInfoVo();
        if(user.getShopId()!=null){
            SysShopInfo shopInfo = sysShopInfoService.findById(user.getShopId());
            user.setShopName(shopInfo.getShopName());
            userInfoVo.setShopName(shopInfo.getShopShortName());
        }
        userInfoVo.setId(user.getSuId());
        userInfoVo.setName(user.getSuName());
        userInfoVo.setRoleName(user.getRoleName());
        userInfoVo.setPhoto(user.getSuPhoto());
        result.putInMap("token", token);
        result.putInMap("userInfo", user);
        result.putInMap("userInfo", userInfoVo);
        synchronized (this) {
            SysUsers hasBind = sysUsersService.findByOpenId(loginDto.getOpenId(), HostInterceptor.getCompanyId());
@@ -345,8 +378,7 @@
                    List<String> openIds = StrUtil.split(hasBind.getOpenIds(), ',');
                    openIds.remove(loginDto.getOpenId());
                    hasBind.setOpenIds(CollUtil.join(openIds, ","));
                    sysUsersService.modifyByModel(hasBind);
                    sysUsersService.modifyUserOpenId(CollUtil.join(openIds, ","), hasBind.getSuId());
                }
            }