# Conflicts: # demo/src/main/resources/application.ymlmaster
commit
7ce887620a
@ -0,0 +1,7 @@
|
|||||||
|
package com.example.demo.loginService.API;
|
||||||
|
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
public User selectUserByuserName(String userName);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.demo.loginService.API.impl;
|
||||||
|
|
||||||
|
import com.example.demo.Dao.userMapper;
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
import com.example.demo.loginService.API.UserService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service("UserServiceImpl")
|
||||||
|
public class UserServiceImpl implements UserService{
|
||||||
|
private userMapper UserMapper;
|
||||||
|
@Transactional(propagation=Propagation.REQUIRED,readOnly = true)
|
||||||
|
public User selectUserByuserName(String userName){
|
||||||
|
return this.UserMapper.selectUserByuserName(userName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.example.demo.loginService;
|
||||||
|
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
import com.example.demo.loginService.API.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class UserController extends HttpServlet{
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@PostMapping("/Login.do")
|
||||||
|
public String doPost1(HttpServletRequest request, HttpServletResponse response){
|
||||||
|
String userName=request.getParameter("userName");
|
||||||
|
String userPwd=request.getParameter("userPwd");
|
||||||
|
User user=this.userService.selectUserByuserName(userName);
|
||||||
|
if(user!=null){
|
||||||
|
if(user.getUserPwd().equals(userPwd)){
|
||||||
|
return "/login1";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return "/login2";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return "/login2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
package com.example.demo.loginService.API;
|
||||||
|
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
|
||||||
|
public interface UserService {
|
||||||
|
public User selectUserByuserName(String userName);
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package com.example.demo.loginService.API.impl;
|
||||||
|
|
||||||
|
import com.example.demo.Dao.userMapper;
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
import com.example.demo.loginService.API.UserService;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Propagation;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
@Service("UserServiceImpl")
|
||||||
|
public class UserServiceImpl implements UserService{
|
||||||
|
private userMapper UserMapper;
|
||||||
|
@Transactional(propagation=Propagation.REQUIRED,readOnly = true)
|
||||||
|
public User selectUserByuserName(String userName){
|
||||||
|
return this.UserMapper.selectUserByuserName(userName);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package com.example.demo.loginService;
|
||||||
|
|
||||||
|
import com.example.demo.bean.User;
|
||||||
|
import com.example.demo.loginService.API.UserService;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class UserController extends HttpServlet{
|
||||||
|
@Autowired
|
||||||
|
private UserService userService;
|
||||||
|
@PostMapping("/Login.do")
|
||||||
|
public String doPost1(HttpServletRequest request, HttpServletResponse response){
|
||||||
|
String userName=request.getParameter("userName");
|
||||||
|
String userPwd=request.getParameter("userPwd");
|
||||||
|
User user=this.userService.selectUserByuserName(userName);
|
||||||
|
if(user!=null){
|
||||||
|
if(user.getUserPwd().equals(userPwd)){
|
||||||
|
return "/login1";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
return "/login2";
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
return "/login2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue