소스 검색

注释掉了sessioninterceptor&&修改登陆接口

CHENYIZONG 6 년 전
부모
커밋
0270660b5f

+ 1 - 1
front_end/src/utils/request.js

@@ -8,7 +8,7 @@ import router from '../router'
 
 // 创建 axios 实例
 const service = axios.create({
-  baseURL: 'http://localhost:8080',
+  baseURL: 'http://localhost:8090',
   withCredentials: true
 })
 

+ 7 - 2
src/main/java/com/example/hotel/blImpl/user/AccountServiceImpl.java

@@ -2,10 +2,13 @@ package com.example.hotel.blImpl.user;
 
 import com.example.hotel.bl.user.AccountService;
 import com.example.hotel.data.user.AccountMapper;
+import com.example.hotel.po.User;
 import com.example.hotel.vo.UserForm;
 import com.example.hotel.vo.ResponseVO;
 import com.example.hotel.vo.UserVO;
+import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.annotation.Bean;
 import org.springframework.stereotype.Service;
 
 
@@ -28,10 +31,12 @@ public class AccountServiceImpl implements AccountService {
 
     @Override
     public UserVO login(UserForm userForm) {
-        UserVO user = accountMapper.getAccountByName(userForm.getEmail());
+        UserVO userVO = new UserVO();
+        User user = accountMapper.getAccountByName(userForm.getEmail());
         if (null == user || !user.getPassword().equals(userForm.getPassword())) {
             return null;
         }
-        return user;
+        BeanUtils.copyProperties(user,userVO);
+        return userVO;
     }
 }

+ 2 - 2
src/main/java/com/example/hotel/config/CORSConfig.java

@@ -9,8 +9,8 @@ import org.springframework.web.filter.CorsFilter;
 @Configuration
 public class CORSConfig {
     private static String[] originsVal = new String[]{
-            "localhost:8081",
-            "127.0.0.1:8081",
+            "localhost:8000",
+            "127.0.0.1:8000",
             "127.0.0.1",
             "localhost",
             "172.19.144.143",

+ 2 - 1
src/main/java/com/example/hotel/data/user/AccountMapper.java

@@ -1,5 +1,6 @@
 package com.example.hotel.data.user;
 
+import com.example.hotel.po.User;
 import com.example.hotel.vo.UserVO;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
@@ -23,5 +24,5 @@ public interface AccountMapper {
      * @param email
      * @return
      */
-    public UserVO getAccountByName(@Param("email") String email);
+    public User getAccountByName(@Param("email") String email);
 }

+ 9 - 9
src/main/java/com/example/hotel/interceptor/SessionInterceptor.java

@@ -9,13 +9,13 @@ import javax.servlet.http.HttpSession;
 
 
 public class SessionInterceptor extends HandlerInterceptorAdapter {
-    @Override
-    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler) throws Exception{
-        HttpSession session=httpServletRequest.getSession();
-        if(null!=session && null!=session.getAttribute(InterceptorConfiguration.SESSION_KEY)){
-            return true;
-        }
-        httpServletResponse.sendRedirect("/index");
-        return false;
-    }
+//    @Override
+//    public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object handler) throws Exception{
+//        HttpSession session=httpServletRequest.getSession();
+//        if(null!=session && null!=session.getAttribute(InterceptorConfiguration.SESSION_KEY)){
+//            return true;
+//        }
+//        httpServletResponse.sendRedirect("/index");
+//        return false;
+//    }
 }

+ 5 - 5
src/main/java/com/example/hotel/vo/UserVO.java

@@ -6,7 +6,7 @@ package com.example.hotel.vo;
  */
 public class UserVO {
     private Integer id;
-    private String username;
+    private String email;
     private String password;
 
     public Integer getId() {
@@ -17,12 +17,12 @@ public class UserVO {
         this.id = id;
     }
 
-    public String getUsername() {
-        return username;
+    public String getEmail() {
+        return email;
     }
 
-    public void setUsername(String username) {
-        this.username = username;
+    public void setEmail(String email) {
+        this.email = email;
     }
 
     public String getPassword() {

+ 1 - 1
src/main/resources/dataImpl/user/AccountMapper.xml

@@ -6,7 +6,7 @@
         values(#{email},#{password})
     </insert>
     <select id="getAccountByName" resultMap="User">
-        select * from User where username=#{username}
+        select * from User where email=#{email}
     </select>
 
     <resultMap id="User" type="com.example.hotel.po.User">