| | |
| | | import cn.hutool.core.util.RandomUtil; |
| | | import cn.hutool.crypto.SecureUtil; |
| | | import cn.hutool.http.HttpRequest; |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.http.HttpUtil; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | |
| | | @GetMapping(value = "/getQrcode") |
| | | public R<String> getQrcode(@RequestParam Long userId) { |
| | | SysUser sysUser = userService.selectUserById(userId); |
| | | Object o = redisTemplate.opsForValue().get("ADMIN_WX_IMG" + sysUser.getCode()); |
| | | Object o = redisTemplate.opsForValue().get("ADMIN_WX_IMG" + sysUser.getUserId()); |
| | | if(o!=null){ |
| | | return R.ok(o.toString()); |
| | | } |
| | |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("page", "pages/home/home"); |
| | | param.put("width", 430); //二维码尺寸 |
| | | param.put("scene", "userId=" + userId); //二维码尺寸 |
| | | param.put("scene", "code=" + sysUser.getCode()+"&type=1"); //二维码尺寸 |
| | | param.put("env_version", "trial"); //二维码尺寸 |
| | | param.put("check_path", false); //二维码尺寸 |
| | | HttpRequest post = HttpUtil.createPost(url); |
| | | post.body(JSON.toJSONString(param)); |
| | | |
| | | byte[] result = post.execute().bodyBytes(); |
| | | HttpResponse execute = post.execute(); |
| | | byte[] result =execute .bodyBytes(); |
| | | // base64 |
| | | String img = Base64.getEncoder().encodeToString(result); |
| | | // 后台用户的小程序码 |
| | |
| | | // base64 |
| | | String img = Base64.getEncoder().encodeToString(result); |
| | | // 后台用户的小程序码 |
| | | redisTemplate.opsForValue().set("ADMIN_WX_IMG" + user.getCode(), img); |
| | | redisTemplate.opsForValue().set("ADMIN_WX_IMG" + user.getUserId(), img); |
| | | } |
| | | return R.ok(); |
| | | } |
| | |
| | | { |
| | | return R.fail("修改用户'" + user.getUserName() + "'失败,手机号码已存在"); |
| | | } |
| | | |
| | | user.setUpdateBy(getUsername()); |
| | | if(StringUtils.isNotEmpty(user.getPassword())){ |
| | | user.setPassword(SecurityUtils.encryptPassword(user.getPassword())); |
| | | } |
| | | // 移除之前的二维码 |
| | | redisTemplate.delete("ADMIN_WX_IMG" + user.getUserId()); |
| | | return R.ok(userService.updateUser(user)); |
| | | } |
| | | |