派生自 projectDept/qhighschool

Administrator
2022-11-21 8d0e57a64fe6c31559ffcf38859fb1f5084e1e23
src/main/java/com/qxueyou/scc/sys/action/LoginController.java
@@ -3,6 +3,7 @@
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@@ -13,6 +14,8 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@@ -85,6 +88,9 @@
    @Autowired
    IStudentService studentService;
   @Resource
   RedisTemplate redisTemplate;
    @Autowired
    private IOrganizationService organizationService;
@@ -216,6 +222,7 @@
   public void khdloginout(HttpServletRequest request, HttpServletResponse response) {
      System.out.println("清除session");
      HttpSession session = request.getSession();
      redisTemplate.delete(UserInfoWrapper.SESSION_USER_INFO_KEY);
      System.out.println(session.getAttribute("userId"));
      System.out.println(session.getAttribute("classId"));
      session.invalidate();
@@ -255,7 +262,10 @@
      param.setIp(RequestClientUtils.getRemoteIP(request));
//       缓存到请求线程
      UserInfoWrapper wrapper = cacheUserInfo(param, null);
      // 存到redis
      redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper);
      request.getSession().setAttribute(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper);
      return new Result(true, "success",
            CollectionUtils.newObjectMap("userId", user.getUserId(), "userName", user.getName(), "imgPath",
                  user.getImgPath(), "orgName", ClientUtils.getOrgName(),"orgId", ClientUtils.getOrgId(), "orgLogo",
@@ -358,6 +368,8 @@
      param.setIp(RequestClientUtils.getRemoteIP(request));
//       缓存到请求线程
      UserInfoWrapper wrapper = cacheUserInfo(param, null);
      // 存到redis
      redisTemplate.opsForValue().set(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper);
      request.getSession().setAttribute(UserInfoWrapper.SESSION_USER_INFO_KEY, wrapper);
      if ("study".equals(logType)) {
         /*if (StringUtils.isEmpty(ClientUtils.getClassId()) && user.getRoles() == null) {
@@ -505,6 +517,7 @@
    private void doRelease(HttpServletRequest httpRequest, HttpServletResponse response) {
        HttpSession se = httpRequest.getSession();
        se.removeAttribute(UserInfoWrapper.SESSION_USER_INFO_KEY);
        redisTemplate.delete(UserInfoWrapper.SESSION_USER_INFO_KEY);
        se.invalidate();
    }