From 2eb13baa57ddf6da38bba134f6c90025f5ac4396 Mon Sep 17 00:00:00 2001 From: EricsHu <hrr145632> Date: 星期二, 05 九月 2023 11:19:21 +0800 Subject: [PATCH] 退出登录null --- src/main/java/com/qxueyou/scc/sys/action/LoginController.java | 102 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 69 insertions(+), 33 deletions(-) diff --git a/src/main/java/com/qxueyou/scc/sys/action/LoginController.java b/src/main/java/com/qxueyou/scc/sys/action/LoginController.java index 4a51522..a763aac 100644 --- a/src/main/java/com/qxueyou/scc/sys/action/LoginController.java +++ b/src/main/java/com/qxueyou/scc/sys/action/LoginController.java @@ -54,12 +54,12 @@ import io.swagger.annotations.ApiOperation; /** - * 娉ㄥ唽controller 鎻愪緵娉ㄥ唽锛岀櫥褰曪紝娉ㄩ攢鏈嶅姟 + * 娉ㄥ唽controller 鎻愪緵娉ㄥ唽锛屽綍锛屾敞閿�鏈嶅姟 * * @author 寰疯檸 * @history 2014-11-25 鏂板缓 澶忓痉铏� */ -@Api(tags="鐧诲叆鐩稿叧鎺ュ彛") +@Api(tags="鍏ョ浉鍏虫帴鍙�") @Controller @CrossOrigin(origins="*",maxAge=3600) @EnableConfigurationProperties(SccConfig.class) @@ -116,6 +116,18 @@ @Value("${wx.secret}") private String secret; + /** + * 鍏紬鍙穉ppID + */ + @Value("${wx.app.appId}") + private String wxappId; + + + /** + * 鍏紬鍙穝ecret + */ + @Value("${wx.app.secret}") + private String wxsecret; public static String UUNUMBER="QXYUUNUMBER"; @@ -123,14 +135,25 @@ IWechatService wechatService; /** - * 寰俊鐧诲綍 + * 寰俊褰� * * @param uid * @throws IOException */ + @PostMapping("/wxAccountsLogin") + @ApiOperation("寰俊鍏紬鍙峰綍") + @ResponseBody + public Result wxAccountsLogin(String code) { + JSONObject gettoken = wechatService.gettoken(wxappId, wxsecret); + JSONObject OpenId = wechatService.getSessionKeyOrOpenId(code); + JSONObject user = wechatService.getUser(gettoken.get("access_token").toString(), OpenId.get("openid").toString()); + return new Result(true,"鎴愬姛",user); + } + + @PostMapping("/wxlogin") - @ApiOperation("寰俊鐧诲綍") + @ApiOperation("寰俊灏忕▼搴忓綍") @ResponseBody public Result wechatLogin(String code,String number) { JSONObject sessionKeyOrOpenId = wechatService.getSessionKeyOrOpenId(code); @@ -164,12 +187,22 @@ String studentSql = "from StuStudent where deleteFlag is false and userId = ? "; List<Object> stuParams = CollectionUtils.newList(user.getUserId()); StuStudent stuStudent = commonDAO.findUnique(studentSql, stuParams, StuStudent.class); + CacheParamters param = new CacheParamters(); + param.setUserId(user.getUserId()); + param.setCustomRoleValue(user.getEmail()); + param.setCustomOrgId(user.getImei()); + param.setCacheIpFlag(true); + // 缂撳瓨鍒拌姹傜嚎绋� + UserInfoWrapper wrapper = cacheUserInfo(param, null); + // 瀛樺埌redis + redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); return new Result(true,"鎺堟潈鎴愬姛",CollectionUtils.newObjectMap("user",user,"ClassId",stuStudent.getClassId())); } return phone; -} + } - @ApiOperation(value = "鐧诲叆鎺ュ彛", notes = "") + + @ApiOperation(value = "鍏ユ帴鍙�", notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "account", value = "璐﹀彿", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "password", value = "瀵嗙爜", required = true, paramType="query", dataType = "String"), @@ -184,8 +217,8 @@ // 鏌ヨ鐢ㄦ埛淇℃伅 String uuNumber=null; String uuReNumber=null; - String hql = "from User where deleteFlag is false and account = ?"; - List<Object> params = CollectionUtils.newList(account); + String hql = "from User where deleteFlag is false and account = ? and password= ?"; + List<Object> params = CollectionUtils.newList(account,password); User user = commonDAO.findUnique(hql,params, User.class); if (user == null ) { return new Result(false, "鐢ㄦ埛璐︽埛銆佸瘑鐮侀敊璇�"); @@ -224,7 +257,7 @@ return new Result(true, "楠岃瘉鎴愬姛",CollectionUtils.newObjectMap("uuNumber",uuNumber,"uuReNumber",uuReNumber)); } - @ApiOperation(value = "鐧诲叆鎺ュ彛", notes = "") + @ApiOperation(value = "鍏ユ帴鍙�", notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "uuNumber", value = "uuNumber", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "uuReNumber", value = "uuReNumber", required = true, paramType="query", dataType = "String"), @@ -260,7 +293,7 @@ return new Result(true, "楠岃瘉鎴愬姛"); } - @ApiOperation(value = "鐧诲叆鎺ュ彛", notes = "") + @ApiOperation(value = "鍏ユ帴鍙�", notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "uuNumber", value = "uuNumber", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "uuReNumber", value = "uuReNumber", required = true, paramType="query", dataType = "String"), @@ -294,7 +327,7 @@ return new Result(true, "楠岃瘉鎴愬姛"); } - //閫�鍑虹櫥褰� 娓呴櫎session + //閫�鍑哄綍 娓呴櫎session @RequestMapping(value = "khdloginout", method = RequestMethod.POST) @ResponseBody public void khdloginout(HttpServletRequest request, HttpServletResponse response) { @@ -307,19 +340,19 @@ } /** - * 瀛﹀憳绔櫥褰� + * 瀛﹀憳绔綍 * * @param account 璐︽埛 * @param password 瀵嗙爜 * @return */ - @ApiOperation(value = "鐧诲叆鎺ュ彛", notes = "") + @ApiOperation(value = "鍏ユ帴鍙�", notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "account", value = "璐﹀彿", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "password", value = "瀵嗙爜", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "organizationId", value = "鏈烘瀯id", required = true, paramType="query", dataType = "String"), - @ApiImplicitParam(name = "platForm", value = "鐧诲叆骞冲彴锛坅pp锛寃eb锛宷Live锛宲c锛寃eixin锛�", required = true, paramType="query", dataType = "String"), - @ApiImplicitParam(name = "logType", value = "鐧诲叆type锛坰tudy瀛﹀憳锛宼eacher鏁欏笀,鍚﹀垯涓哄悗鍙帮級", required = true, paramType="query", dataType = "String"), + @ApiImplicitParam(name = "platForm", value = "鍏ュ钩鍙帮紙app锛寃eb锛宷Live锛宲c锛寃eixin锛�", required = true, paramType="query", dataType = "String"), + @ApiImplicitParam(name = "logType", value = "鍏ype锛坰tudy瀛﹀憳锛宼eacher鏁欏笀,鍚﹀垯涓哄悗鍙帮級", required = true, paramType="query", dataType = "String"), }) @RequestMapping(value = "studentLogin", method = RequestMethod.POST) @ResponseBody @@ -353,19 +386,19 @@ } /** - * 鍚庡彴鐧诲綍 + * 鍚庡彴褰� * * @param account 璐︽埛 * @param password 瀵嗙爜 * @return */ - @ApiOperation(value = "鐧诲叆鎺ュ彛", notes = "") + @ApiOperation(value = "鍏ユ帴鍙�", notes = "") @ApiImplicitParams({ @ApiImplicitParam(name = "account", value = "璐﹀彿", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "password", value = "瀵嗙爜", required = true, paramType="query", dataType = "String"), @ApiImplicitParam(name = "organizationId", value = "鏈烘瀯id", required = true, paramType="query", dataType = "String"), - @ApiImplicitParam(name = "platForm", value = "鐧诲叆骞冲彴锛坅pp锛寃eb锛宷Live锛宲c锛寃eixin锛�", required = true, paramType="query", dataType = "String"), - @ApiImplicitParam(name = "logType", value = "鐧诲叆type锛坰tudy瀛﹀憳锛宼eacher鏁欏笀,鍚﹀垯涓哄悗鍙帮級", required = true, paramType="query", dataType = "String"), + @ApiImplicitParam(name = "platForm", value = "鍏ュ钩鍙帮紙app锛寃eb锛宷Live锛宲c锛寃eixin锛�", required = true, paramType="query", dataType = "String"), + @ApiImplicitParam(name = "logType", value = "鍏ype锛坰tudy瀛﹀憳锛宼eacher鏁欏笀,鍚﹀垯涓哄悗鍙帮級", required = true, paramType="query", dataType = "String"), }) @RequestMapping(value = "platformLogin", method = RequestMethod.POST) @ResponseBody @@ -384,6 +417,9 @@ hql = "from User where deleteFlag is false and account = ?"; params = CollectionUtils.newList(account); }else if("portal".equals(logType)){ + hql = "from User where deleteFlag is false and email = ?"; + params = CollectionUtils.newList(account); + }else if("zhyly".equals(logType)){ hql = "from User where deleteFlag is false and mobilePhone = ?"; params = CollectionUtils.newList(account); }else{ @@ -403,12 +439,12 @@ User user = commonDAO.findUnique(hql,params, User.class); if(uuNumber!=null&&!"".equals(uuNumber)&&!"null".equals(uuNumber)){ - //鐧诲綍鎴愬姛瀛樺叆user閲岋紝鍒犻櫎session閲岀殑uuNumber锛屼笅涓汉鏃犳硶浣跨敤 + //褰曟垚鍔熷瓨鍏ser閲岋紝鍒犻櫎session閲岀殑uuNumber锛屼笅涓汉鏃犳硶浣跨敤 user.setEmail(uuNumber); // request.getSession().removeAttribute("uuNumber"); } // if(uuReNumber!=null&&!"".equals(uuReNumber)&&!"null".equals(uuReNumber)){ -// //鐧诲綍鎴愬姛瀛樺叆user閲岋紝鍒犻櫎session閲岀殑uuReNumber锛屼笅涓汉鏃犳硶浣跨敤 +// //褰曟垚鍔熷瓨鍏ser閲岋紝鍒犻櫎session閲岀殑uuReNumber锛屼笅涓汉鏃犳硶浣跨敤 // user.setImei(uuReNumber); // request.getSession().removeAttribute("uuReNumber"); // } @@ -432,7 +468,7 @@ } /** - * 鐧诲叆楠岃瘉 + * 鍏ラ獙璇� * @param user * @param type * @param request @@ -458,26 +494,26 @@ // 瀛樺埌redis redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); request.getSession().setAttribute(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper); - if ("study".equals(logType) || "portal".equals(logType)) { + if ("study".equals(logType) || "portal".equals(logType) || "zhyly".equals(logType)) { /*if (StringUtils.isEmpty(ClientUtils.getClassId()) && user.getRoles() == null) { return new Result(false, "璇ョ敤鎴锋湭鍔犲叆浠讳綍鐝骇鎴栨湭婵�娲伙紝璇疯仈绯荤彮涓讳换"); }*/ if (StringUtils.isEmpty(user.getOrganizationId())) { - return new Result(false, "璇ョ敤鎴蜂笉灞炰簬浠讳綍鏈烘瀯锛屾棤娉曠櫥鍏�"); + return new Result(false, "璇ョ敤鎴蜂笉灞炰簬浠讳綍鏈烘瀯锛屾棤娉曞叆"); } if (StringUtils.isNoneBlank(organizationId) && !user.getOrganizationId().equals(organizationId)) { return new Result(false, "閫夋嫨鐨勬満鏋勯敊璇紝璇风‘璁�"); } - //鍒ゆ柇鏄惁涓哄鐢燂紝濡傛灉鏄鐢燂紝鍒ゆ柇鏄惁宸插喕缁撴垨绉婚櫎锛屽喕缁撴垨绉婚櫎鐨勫鐢熶笉璁╃櫥褰� + //鍒ゆ柇鏄惁涓哄鐢燂紝濡傛灉鏄鐢燂紝鍒ゆ柇鏄惁宸插喕缁撴垨绉婚櫎锛屽喕缁撴垨绉婚櫎鐨勫鐢熶笉璁╁綍 StuStudent stu = this.studentService.getStudentByUserId(user.getUserId()); if(stu!=null && (stu.getDeleteFlag() || stu.getStatus().equalsIgnoreCase(StuStudent.STATUS_DEACTIVE))){ return new Result(false, "鐢ㄦ埛璐︽埛宸茬粡琚喕缁撴垨绉婚櫎"); } /*if(StringUtils.isEmpty(wrapper.getInfo(UserInfoWrapper.INF_CLASS_ID))) { - return new Result(false, "璇ョ敤鎴锋湭鍔犲叆浠讳綍鐝骇锛屾棤娉曠櫥鍏�"); + return new Result(false, "璇ョ敤鎴锋湭鍔犲叆浠讳綍鐝骇锛屾棤娉曞叆"); }*/ // 淇濆瓨鍒皊ession涓� return new Result(true, "success", @@ -488,16 +524,16 @@ }else if("teacher".equals(logType)) { String teacherId = teacherService.getTeacherIdByUserId(user.getUserId()); if (StringUtils.isEmpty(teacherId)) { - return new Result(false, "璇ヨ处鎴蜂笉鏄�佸笀瑙掕壊锛屾棤娉曠櫥鍏�"); + return new Result(false, "璇ヨ处鎴蜂笉鏄�佸笀瑙掕壊锛屾棤娉曞叆"); } if (StringUtils.isEmpty(user.getOrganizationId())) { - return new Result(false, "璇ョ敤鎴蜂笉灞炰簬浠讳綍鏈烘瀯锛屾棤娉曠櫥鍏�"); + return new Result(false, "璇ョ敤鎴蜂笉灞炰簬浠讳綍鏈烘瀯锛屾棤娉曞叆"); } if (StringUtils.isNoneBlank(organizationId) && !user.getOrganizationId().equals(organizationId)) { return new Result(false, "閫夋嫨鐨勬満鏋勯敊璇紝璇风‘璁�"); } - //鑾峰彇鐢ㄦ埛瀵瑰簲鐨剆essionId鏄惁涓庝繚瀛樺湪redis涓殑涓�鑷达紝濡傛灉涓嶄竴鑷村垯璺宠浆鍒扮櫥褰曢〉闈� + //鑾峰彇鐢ㄦ埛瀵瑰簲鐨剆essionId鏄惁涓庝繚瀛樺湪redis涓殑涓�鑷达紝濡傛灉涓嶄竴鑷村垯璺宠浆鍒板綍椤甸潰 // stringRedisTemplate.opsForHash().put(UserInfoWrapper.REDIS_USER_ONLINE_MAP_KEY, user.getUserId(), request.getSession().getId()); return new Result(true, "success", CollectionUtils.newObjectMap("userId", user.getUserId(), "userName", user.getName(), "imgPath", @@ -524,7 +560,7 @@ } /** - * 鍚庡彴锛氶��鍑虹櫥褰�,鍚庡彴绯荤粺 + * 鍚庡彴锛氶��鍑哄綍,鍚庡彴绯荤粺 * * @param account 璐︽埛 * @return @@ -533,11 +569,11 @@ @RequestMapping(value = "release", method = RequestMethod.GET) public String release(HttpServletRequest httpRequest, HttpServletResponse response) { doRelease(httpRequest, response); - return "redirect:/web/admin/index.html#login"; + return null; } /** - * 鍚庡彴锛氶��鍑虹櫥褰�,鍚庡彴绯荤粺 + * 鍚庡彴锛氶��鍑哄綍,鍚庡彴绯荤粺 * * @return */ @@ -567,7 +603,7 @@ } /** - * 鎻掑叆鐧诲綍鏃ュ織 + * 鎻掑叆褰曟棩蹇� * * @param request * @param lstUser -- Gitblit v1.8.0