From 8ff6680c1f0b50a7986d99a64a9068b340df4899 Mon Sep 17 00:00:00 2001 From: hurui <177768073@qq.com> Date: Tue, 30 Nov 2021 17:13:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/cweb/config/AuthConfig.java | 2 ++ .../cweb/controller/HighUserController.java | 31 ++++++++++--------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java index 8d876b53..78cfb369 100644 --- a/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java +++ b/hai-cweb/src/main/java/com/cweb/config/AuthConfig.java @@ -109,6 +109,8 @@ public class AuthConfig implements WebMvcConfigurer { .excludePathPatterns("/user/login") .excludePathPatterns("/user/unionPhoneLogin") .excludePathPatterns("/user/getUnionId") + .excludePathPatterns("/highUser/setCacheParam") + .excludePathPatterns("/highUser/getCacheParam") .excludePathPatterns("/order/orderToH5Pay") .excludePathPatterns("/order/orderToPay") .excludePathPatterns("/test/*") diff --git a/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java b/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java index efb82c4f..7d3c9ee1 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/HighUserController.java @@ -205,37 +205,38 @@ public class HighUserController { } } - @RequestMapping(value="/setUserParam",method = RequestMethod.GET) + @RequestMapping(value="/setCacheParam",method = RequestMethod.POST) @ResponseBody @ApiOperation(value = "设置用户参数") - public ResponseData setUserParam(@RequestParam(name = "param", required = true) String param,HttpServletRequest request) { + public ResponseData setCacheParam(@RequestBody JSONObject body) { try { - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); + if (body == null + || StringUtils.isBlank(body.getString("key")) + || StringUtils.isBlank(body.getString("value"))) { + log.error("HighUserController --> setUserPayPwd() error!", "请求参数校验失败"); + throw ErrorHelp.genException(SysCode.System, ErrorCode.REQ_PARAMS_ERROR, ""); + } - redisUtil.hset("USER_PARAM", userInfoModel.getHighUser().getPhone(), param, 60*60*60); - return ResponseMsgUtil.success(redisUtil.hget("USER_PARAM", userInfoModel.getHighUser().getPhone())); + redisUtil.hset("PROVISIONAL_CACHE_PARAM", body.getString("key"), body.getString("value"), 60*5); + + return ResponseMsgUtil.success("设置成功"); } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); + log.error("CommonController --> setCacheParam() error!", e); return ResponseMsgUtil.exception(e); } } - @RequestMapping(value="/getUserParam",method = RequestMethod.GET) + @RequestMapping(value="/getCacheParam",method = RequestMethod.GET) @ResponseBody @ApiOperation(value = "获取设置用户参数") - public ResponseData getUserParam(HttpServletRequest request) { + public ResponseData getCacheParam(@RequestParam(name = "key", required = true) String key) { try { - // 用户 - SessionObject sessionObject = userCenter.getSessionObject(request); - HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject(); - return ResponseMsgUtil.success(redisUtil.hget("USER_PARAM", userInfoModel.getHighUser().getPhone())); + return ResponseMsgUtil.success(redisUtil.hget("PROVISIONAL_CACHE_PARAM", key)); } catch (Exception e) { - log.error("CommonController --> getDictionaryByCodeTypeAndValue() error!", e); + log.error("CommonController --> getCacheParam() error!", e); return ResponseMsgUtil.exception(e); } }