后端实现控制器,拦截器等层

main
lhr 1 year ago
parent 9433686d00
commit 5b5ced17b5

@ -0,0 +1,27 @@
package com.rain.controller;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class CommonController {
@RequestMapping(value="/{formName}")
public String loginForm(@PathVariable String formName){
// 作为一个空方法可以匹配任何无效输入再跳转到404
return formName;
// String blank = "blank";
// return blank;
}
@RequestMapping(value="/")
public String index(){
String blank = "index";
return blank;
}
@RequestMapping(value="/welcome")
public String welcome(){
String blank = "welcome";
return blank;
}
}

@ -0,0 +1,83 @@
package com.rain.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Dept;
import com.rain.service.RainService;
@Controller
public class DeptController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/dept/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("dept/list");
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/dept/{formName}")
public String index2(@PathVariable String formName){
// return formName;
String blank = "/dept/list";
return blank;
}
@RequestMapping(value="/dept/list",method=RequestMethod.GET)
public String index(Model model,String content){
// System.out.println("4234");
List<Dept> dept_list = rainservice.findAllDept();
if (content!=null){
dept_list = rainservice.findAllDept(content);
}
model.addAttribute("list",dept_list);
// for(Dept attribute : dept_list) {
// System.out.println(attribute.getName());
// }
return "dept/list";
}
@RequestMapping(value="/dept/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
// System.out.println(id);
if(id!=null){
Dept dept = rainservice.get_Info(id);
model.addAttribute("dept",dept);
// System.out.println(dept.getName());
}
return "/dept/add";
}
@RequestMapping(value="/dept/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Dept dept ,Integer id){
System.out.println(id);
// System.out.println(dept.getId());
if(id!=null){
rainservice.update_Info(dept);
System.out.println(dept.getId());
}else{
rainservice.addDept(dept);
}
// System.out.println(dept.getName());
mv.setViewName("redirect:/dept/list");
return mv;
}
@RequestMapping(value="/dept/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_Info(id);
}
}
}

@ -0,0 +1,91 @@
package com.rain.controller;
import java.io.File;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.apache.commons.io.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Document;
import com.rain.service.RainService;
@Controller
public class DocumentController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/document/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("document/list");
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/document/{formName}")
public String index2(@PathVariable String formName){
String blank = "/document/list";
return blank;
}
@RequestMapping(value="/document/list",method=RequestMethod.GET)
public String index(Model model,String content){
List<Document> job_list = rainservice.get_DocumentList();
if (content!=null){
job_list = rainservice.get_DocumentLikeList(content);
}
model.addAttribute("list",job_list);
return "document/list";
}
@RequestMapping(value="/document/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Document job = rainservice.get_DocumentInfo(id);
model.addAttribute("job",job);
}
return "/document/add";
}
@RequestMapping(value="/document/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Document document ,Integer id,HttpSession session
)
throws Exception{
System.out.println(id);
if(id!=null){
rainservice.update_DocumentInfo(document);
}else{
/**
*
*/
String path = session.getServletContext().getRealPath("/upload/");
String filename = document.getFile().getOriginalFilename();
path = "C://Users//Rain//Documents//RainMe//JavaWed//";
File tempFile = new File(path+File.separator+filename);
tempFile.createNewFile();
document.getFile().transferTo(tempFile);
document.setFilename(filename);
rainservice.insert_DocumentInfo(document);
}
mv.setViewName("redirect:/document/list");
return mv;
}
@RequestMapping(value="/document/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_DocumentInfo(id);
}
}
}

@ -0,0 +1,76 @@
package com.rain.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Dept;
import com.rain.domain.Employee;
import com.rain.domain.Job;
import com.rain.service.RainService;
@Controller
public class EmployeeController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/employee/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("employee/list");
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/employee/{formName}")
public String index2(@PathVariable String formName){
String blank = "/employee/list";
return blank;
}
@RequestMapping(value="/employee/list",method=RequestMethod.GET)
public String index(Model model,String content){
List<Employee> job_list = rainservice.get_EmployeeList();
if (content!=null){
job_list = rainservice.get_EmployeeLikeList(content);
}
model.addAttribute("list",job_list);
return "employee/list";
}
@RequestMapping(value="/employee/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Employee employee = rainservice.get_EmployeeInfo(id);
model.addAttribute("job",employee);
}
List<Dept> dept_list = rainservice.findAllDept();
List<Job> job_list = rainservice.findAllJob();
model.addAttribute("job_list", job_list);
model.addAttribute("dept_list",dept_list);
return "/employee/add";
}
@RequestMapping(value="/employee/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Employee job ,Integer id){
// System.out.println(id);
if(id!=null){
rainservice.update_EmployeeInfo(job);
}else{
rainservice.insert_EmployeeInfo(job);
}
mv.setViewName("redirect:/employee/list");
return mv;
}
@RequestMapping(value="/employee/delete",method=RequestMethod.GET)
public void delete(Integer id){
// System.out.println(id);
if(id!=null){
rainservice.delete_EmployeeInfo(id);
}
}
}

@ -0,0 +1,70 @@
package com.rain.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Job;
import com.rain.service.RainService;
@Controller
public class JobController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/job/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("job/list");
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/job/{formName}")
public String index2(@PathVariable String formName){
String blank = "/job/list";
return blank;
}
@RequestMapping(value="/job/list",method=RequestMethod.GET)
public String index(Model model,String content){
List<Job> job_list = rainservice.findAllJob();
if (content!=null){
job_list = rainservice.findAllJob(content);
}
model.addAttribute("list",job_list);
return "job/list";
}
@RequestMapping(value="/job/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Job job = rainservice.get_JobInfo(id);
model.addAttribute("job",job);
}
return "/job/add";
}
@RequestMapping(value="/job/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Job job ,Integer id){
System.out.println(id);
if(id!=null){
rainservice.update_JobInfo(job);
}else{
rainservice.insert_JobInfo(job);
}
mv.setViewName("redirect:/job/list");
return mv;
}
@RequestMapping(value="/job/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_JobInfo(id);
}
}
}

@ -0,0 +1,71 @@
package com.rain.controller;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Job;
import com.rain.domain.Notice;
import com.rain.service.RainService;
@Controller
public class NoticeController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/notice/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("notice/list");
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/notice/{formName}")
public String index2(@PathVariable String formName){
String blank = "/notice/list";
return blank;
}
@RequestMapping(value="/notice/list",method=RequestMethod.GET)
public String index(Model model,String content){
List<Notice> job_list = rainservice.get_NoticeList();
if (content!=null){
job_list = rainservice.get_NoticeLikeList(content);
}
model.addAttribute("list",job_list);
return "notice/list";
}
@RequestMapping(value="/notice/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
Notice job = rainservice.get_NoticeInfo(id);
model.addAttribute("job",job);
}
return "/notice/add";
}
@RequestMapping(value="/notice/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute Notice notice ,Integer id){
System.out.println(id);
if(id!=null){
rainservice.update_NoticeInfo(notice);
}else{
rainservice.insert_NoticeInfo(notice);
}
mv.setViewName("redirect:/notice/list");
return mv;
}
@RequestMapping(value="/notice/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_NoticeInfo(id);
}
}
}

@ -0,0 +1,148 @@
package com.rain.controller;
import java.util.List;
import javax.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;
import com.rain.domain.Employee;
import com.rain.domain.Job;
import com.rain.domain.Notice;
import com.rain.domain.User;
import com.rain.service.RainService;
import com.rain.util.common.Constants;
@Controller
public class UserController {
@Autowired
@Qualifier("RainService")
private RainService rainservice;
// 如果在目录下输入为空,则跳转到指定链接
@RequestMapping(value="/user/")
public ModelAndView index2(ModelAndView mv){
mv.setViewName("/user/list");
return mv;
}
// 退出功能
@RequestMapping(value="/user/logout")
public ModelAndView logout(ModelAndView mv, HttpSession session){
session.setAttribute(Constants.USER_SESSION, null);
session.setAttribute("tip", null);
mv.setViewName("redirect:/index");
return mv;
}
@RequestMapping(value="/login")
public ModelAndView login(@RequestParam("loginname") String loginname,
@RequestParam("password") String password,@RequestParam("tip") String tip,
HttpSession session,
ModelAndView mv){
// 调用业务逻辑组件判断用户是否可以登录
boolean flag = false;
if("1".equals(tip)) {
User user = rainservice.login(loginname, password);
if(user!=null){
// 将用户保存到HttpSession当中
System.out.println("HttpSession");
session.setAttribute(Constants.USER_SESSION, user);
session.setAttribute("tip", "1");
// 客户端跳转到main页面
mv.setViewName("redirect:/index");
}else{
// 设置登录失败提示信息
System.out.println("设置登录失败提示信息");
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
}else {
Employee user = rainservice.login2(loginname, password);
if(user!=null){
// 将用户保存到HttpSession当中
System.out.println("HttpSession");
session.setAttribute(Constants.USER_SESSION, user);
session.setAttribute("tip", "2");
// 客户端跳转到main页面
mv.setViewName("redirect:/indexcustomer/");
}else{
// 设置登录失败提示信息
System.out.println("设置登录失败提示信息");
mv.addObject("message", "登录名或密码错误!请重新输入");
// 服务器内部跳转到登录页面
mv.setViewName("forward:/loginForm");
}
}
return mv;
}
// 如果在目录下输入任何不存在的参数则跳转到list
@RequestMapping(value="/user/{formName}")
public String index2(@PathVariable String formName){
String blank = "/user/list";
return blank;
}
@RequestMapping(value="/user/list",method=RequestMethod.GET)
public String index(Model model,String content){
List<User> job_list = rainservice.get_UserList();
if (content!=null){
job_list = rainservice.get_UserLikeList(content);
}
model.addAttribute("list",job_list);
return "user/list";
}
@RequestMapping(value="/user/add",method=RequestMethod.GET)
public String add(Model model,Integer id){
if(id!=null){
User job = rainservice.get_UserInfo(id);
model.addAttribute("job",job);
}
return "/user/add";
}
@RequestMapping(value="/user/add",method=RequestMethod.POST)
public ModelAndView add(ModelAndView mv,@ModelAttribute User notice ,Integer id){
System.out.println(id);
if(id!=null){
rainservice.update_UserInfo(notice);
}else{
rainservice.insert_UserInfo(notice);
}
mv.setViewName("redirect:/user/list");
return mv;
}
@RequestMapping(value="/user/delete",method=RequestMethod.GET)
public void delete(Integer id){
System.out.println(id);
if(id!=null){
rainservice.delete_UserInfo(id);
}
}
// 管理员自己修改密码时跳转的页面
@RequestMapping(value="/user/myupdate",method=RequestMethod.GET)
public String update(Model model,HttpSession session){
User user = (User) session.getAttribute(Constants.USER_SESSION);
model.addAttribute("job",user);
return "/user/myupdate";
}
@RequestMapping(value="/user/myupdate",method=RequestMethod.POST)
public ModelAndView update(ModelAndView mv,Model model,HttpSession session,User notice){
User user = (User) session.getAttribute(Constants.USER_SESSION);
// 如果是自己修改自己的密码则更新session
user.setLoginname(notice.getLoginname());
user.setPassword(notice.getPassword());
user.setUsername(notice.getUsername());
rainservice.update_UserInfo(user);
session.setAttribute(Constants.USER_SESSION, user);
mv.setViewName("redirect:/user/myupdate");
return mv;
}
}

@ -0,0 +1,33 @@
package com.rain.dao;
import static com.rain.util.common.Constants.DEPTTABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.DeptDynaSqlProvider;
import com.rain.domain.Dept;
public interface DeptDao {
//查询
@Select("select * from "+DEPTTABLE+" ")
List<Dept> selectAllDept();
@Select("select * from "+DEPTTABLE+" where name like CONCAT('%',#{content},'%')")
List<Dept> selectLikeAllDept(String content);
@SelectProvider(type=DeptDynaSqlProvider.class,method="insertDept")
void save(Dept dept);
@Select("select * from "+DEPTTABLE+" where id = #{id}")
Dept get_Info(Integer id);
@SelectProvider(type=DeptDynaSqlProvider.class,method="updateDept")
void update_Info(Dept dept);
// 根据id删除部门
@Delete(" delete from "+DEPTTABLE+" where id = #{id} ")
void delete_Info(Integer id);
}

@ -0,0 +1,33 @@
package com.rain.dao;
import static com.rain.util.common.Constants.DOCUMENTTABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.DocumentDynaSqlProvider;
import com.rain.domain.Document;
public interface DocumentDao {
//查询
@Select("select * from "+DOCUMENTTABLE+" ")
List<Document> get_List();
@Select("select * from "+DOCUMENTTABLE+" where title like CONCAT('%',#{content},'%')")
List<Document> get_LikeList(String content);
@SelectProvider(type=DocumentDynaSqlProvider.class,method="insert")
void insert_Info(Document dept);
@Select("select * from "+DOCUMENTTABLE+" where id = #{id}")
Document get_Info(Integer id);
@SelectProvider(type=DocumentDynaSqlProvider.class,method="update")
void update_Info(Document dept);
// 根据id删除部门
@Delete(" delete from "+DOCUMENTTABLE+" where id = #{id} ")
void delete_Info(Integer id);
}

@ -0,0 +1,41 @@
package com.rain.dao;
import static com.rain.util.common.Constants.EMPLOYEETABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.EmployeeDynaSqlProvider;
import com.rain.domain.Employee;
public interface EmployeeDao {
/**
*
* @return
*/
//查询
@Select("select * from "+EMPLOYEETABLE+" ")
List<Employee> get_List();
@Select("select * from "+EMPLOYEETABLE+" where name like CONCAT('%',#{content},'%')")
List<Employee> get_LikeList(String content);
@SelectProvider(type=EmployeeDynaSqlProvider.class,method="insert_Employee")
void insert_Info(Employee employee);
@Select("select * from "+EMPLOYEETABLE+" where id = #{id}")
Employee get_Info(Integer id);
@SelectProvider(type=EmployeeDynaSqlProvider.class,method="update_Employee")
void update_Info(Employee employee);
// 根据id删除部门
@Delete(" delete from "+EMPLOYEETABLE+" where id = #{id} ")
void delete_Info(Integer id);
@Select("select * from "+EMPLOYEETABLE+" where name=#{name} and password=#{password}")
Employee get_ByInfo(@Param("name") String name, @Param("password") String password);
}

@ -0,0 +1,34 @@
package com.rain.dao;
import static com.rain.util.common.Constants.JOBTABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.JobDynaSqlProvider;
import com.rain.domain.Dept;
import com.rain.domain.Job;
public interface JobDao {
//查询
@Select("select * from "+JOBTABLE+" ")
List<Job> get_List();
@Select("select * from "+JOBTABLE+" where name like CONCAT('%',#{content},'%')")
List<Job> get_LikeList(String content);
@SelectProvider(type=JobDynaSqlProvider.class,method="insertDept")
void insert_Info(Job job);
@Select("select * from "+JOBTABLE+" where id = #{id}")
Job get_Info(Integer id);
@SelectProvider(type=JobDynaSqlProvider.class,method="updateDept")
void update_Info(Job job);
// 根据id删除部门
@Delete(" delete from "+JOBTABLE+" where id = #{id} ")
void delete_Info(Integer id);
}

@ -0,0 +1,33 @@
package com.rain.dao;
import static com.rain.util.common.Constants.NOTICETABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.NoticeDynaSqlProvider;
import com.rain.domain.Notice;
public interface NoticeDao {
@Select("select * from "+NOTICETABLE+" ")
List<Notice> get_List();
@Select("select * from "+NOTICETABLE+" where title like CONCAT('%',#{content},'%')")
List<Notice> get_LikeList(String content);
@SelectProvider(type=NoticeDynaSqlProvider.class,method="insert_Notice")
void insert_Info(Notice employee);
@Select("select * from "+NOTICETABLE+" where id = #{id}")
Notice get_Info(Integer id);
@SelectProvider(type=NoticeDynaSqlProvider.class,method="update_Notice")
void update_Info(Notice employee);
// 根据id删除部门
@Delete(" delete from "+NOTICETABLE+" where id = #{id} ")
void delete_Info(Integer id);
}

@ -0,0 +1,38 @@
package com.rain.dao;
import static com.rain.util.common.Constants.USERTABLE;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import com.rain.dao.provider.UserDynaSqlProvider;
import com.rain.domain.User;
public interface UserDao {
@Select("select * from "+USERTABLE+" ")
List<User> get_List();
@Select("select * from "+USERTABLE+" where loginname like CONCAT('%',#{content},'%')")
List<User> get_LikeList(String content);
@Select("select * from "+USERTABLE+" where loginname = #{loginname} AND password = #{password}")
User get_login(@Param("loginname") String loginname,
@Param("password") String password);
@SelectProvider(type=UserDynaSqlProvider.class,method="insert_Notice")
void insert_Info(User employee);
@Select("select * from "+USERTABLE+" where id = #{id}")
User get_Info(Integer id);
@SelectProvider(type=UserDynaSqlProvider.class,method="update_Notice")
void update_Info(User employee);
// 根据id删除部门
@Delete(" delete from "+USERTABLE+" where id = #{id} ")
void delete_Info(Integer id);
}

@ -0,0 +1,78 @@
package com.rain.interceptor;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.rain.domain.User;
import com.rain.util.common.Constants;
import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;
/**
* Spring MVC
*/
public class AuthorizedInterceptor implements HandlerInterceptor {
/** 定义不需要拦截的请求 */
private static final String[] IGNORE_URI = {"/loginForm", "/login","/404.html"};
/**
* preHandletrue
*
*/
@Override
public void afterCompletion(HttpServletRequest request,
HttpServletResponse response, Object handler, Exception exception)
throws Exception {
}
/**
* preHandletrue
* Controller
*/
@Override
public void postHandle(HttpServletRequest request, HttpServletResponse response,
Object handler, ModelAndView mv) throws Exception {
}
/**
* preHandleController
* preHandlefalse
* preHandletruepostHandleafterCompletion
*/
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
Object handler) throws Exception {
/** 默认用户没有登录 */
boolean flag = false;
/** 获得请求的ServletPath */
String servletPath = request.getServletPath();
System.out.println(servletPath);
/** 判断请求是否需要拦截 */
for (String s : IGNORE_URI) {
if (servletPath.contains(s)) {
flag = true;
System.out.println("*********************");
break;
}
}
/** 拦截请求 */
if (!flag){
/** 1.获取session中的用户 */
User user = (User) request.getSession().getAttribute(Constants.USER_SESSION);
/** 2.判断用户是否已经登录 */
if(user == null){
/** 如果用户没有登录,跳转到登录页面 */
request.setAttribute("message", "请先登录再访问网站!");
request.getRequestDispatcher(Constants.LOGIN).forward(request, response);
return flag;
}else{
flag = true;
}
}
return flag;
}
}

@ -0,0 +1,8 @@
dataSource.driverClass=com.mysql.cj.jdbc.Driver
dataSource.jdbcUrl=jdbc:mysql://localhost:3306/personnel?useSSL=false&serverTimezone=UTC
dataSource.user=root
dataSource.password=12345.com
dataSource.maxPoolSize=20
dataSource.maxIdleTime = 1000
dataSource.minPoolSize=6
dataSource.initialPoolSize=5
Loading…
Cancel
Save