派生自 projectDept/qhighschool

EricsHu
2023-05-29 cc70ac05f3fcca3b85f7860e7404bb2bfc4429a6
src/main/java/com/qxueyou/scc/sys/action/LoginController.java
@@ -116,6 +116,18 @@
   @Value("${wx.secret}")
   private String secret;
   /**
    * 公众号appID
    */
   @Value("${wx.app.appId}")
   private String wxappId;
   /**
    * 公众号secret
    */
   @Value("${wx.app.secret}")
   private String wxsecret;
   public static String UUNUMBER="QXYUUNUMBER";
@@ -129,8 +141,19 @@
    * @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,10 +187,20 @@
         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 = "")
   @ApiImplicitParams({
@@ -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, "用户账户、密码错误");
@@ -384,7 +417,7 @@
         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 mobilePhone = ?";
         hql = "from User where deleteFlag is false and email = ?";
         params = CollectionUtils.newList(account);
      }else{
            if(StringUtils.isEmpty(password)) {