Java项目:SSM教师师资管理系统

news2024/11/15 12:52:03

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

本项目包含管理员与教师两种角色;

管理员角色包含以下功能:

管理员角色登录,教师管理,教师授课管理,审批教师的项目开题,项目详情审批,项目总结审批,公告管理等功能。

教师角色包含以下功能:

教师角色登录,修改个人信息,修改密码,公告列表管理,开题审批管理,项目排名,项目详情审批管理,项目总结管理等功能。

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可
4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 

5.数据库:MySql 5.7/8.0版本均可;

6.是否Maven项目:是;

技术栈

1. 后端:Spring+SpringMVC+Mybatis

2. 前端:Jsp+CSS+JavaScript+jQuery+bootstrap

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;

3. 将项目中db.properties配置文件中的数据库配置改为自己的配置;

4. 运行项目,输入localhost:8080/ 登录

运行截图

管理员角色

教师角色 

相关代码

登录模块

package com.kewen.teacher.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONObject;
import com.kewen.teacher.base.BaseController;
import com.kewen.teacher.po.Manage;
import com.kewen.teacher.po.Teacher;
import com.kewen.teacher.po.Teacherclass;
import com.kewen.teacher.service.ManageService;
import com.kewen.teacher.service.TeacherService;

@Controller
@RequestMapping("/login")
public class LoginController  extends BaseController{
	
	@Autowired
	private ManageService manageService;
	
	@Autowired
	private TeacherService teacherService;
	
	/**
	 * 跳转登陆
	 * @return
	 */
	@RequestMapping("/login")
	public String login(){
		return "login/mLogin";
	}
	
	
	@RequestMapping("/mtuichu")
	public String mtuichu(HttpServletRequest request){
		//request.getSession().invalidate();
		return "login/mLogin";
	}
	@RequestMapping("/welcome")
	private String welcome(){
		return "login/welcome";
	}
	
	@RequestMapping("/toLogin")
	public String toLogin(Manage manage, Integer type,HttpServletRequest request, HttpServletResponse response){
		
		if (type == null){
			return "redirect:/login/mtuichu";	
		}
		
		if (type == 1){
			Manage byEntity = manageService.getByEntity(manage);
			if(byEntity == null){
				return "redirect:/login/mtuichu";	
			}else{
				request.getSession().setAttribute("role", 1);
				request.getSession().setAttribute("username", byEntity.getUserName());
				request.getSession().setAttribute("userId", byEntity.getId());
			}
		}
		if (type == 2){
			Teacher t = new Teacher();
			t.setPassword(manage.getPassWord());
			t.setUsername(manage.getUserName());
			t.setIsDelete(0);
			Teacher byEntity = teacherService.getByEntity(t);
			if(byEntity == null){
				return "redirect:/login/mtuichu";	
			}else{
				request.getSession().setAttribute("role", 2);
				request.getSession().setAttribute("username", byEntity.getUsername());
				request.getSession().setAttribute("userId", byEntity.getId());
			}
		}
		
		
		return "login/mIndex";
	}
	
	/**
	 * 退出
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping("/tuichu")
	public String tuichu( HttpServletRequest request, HttpServletResponse response){
		HttpSession session = request.getSession();
		session.invalidate();
		return "login/login";
	}

	@RequestMapping("/head")
	private String head(){
		return "inc/head";
	}
	
	@RequestMapping("/left")
	private String left(){
		return "inc/left";
	}
	
	
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model,HttpServletRequest request) {
		
		Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
			return "redirect:/login/mtuichu";	
		}
		
		Integer userId = Integer.valueOf(attribute.toString());
		Teacher byId = teacherService.getById(userId);
		model.addAttribute("obj",byId);
		return "login/update";
	}
	

	@RequestMapping(value = "/toUpdate")
	public String toUpdate(Integer id,String phone,Model model,HttpServletRequest request) {
		
		Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
			return "redirect:/login/mtuichu";	
		}
		
		Integer userId = Integer.valueOf(attribute.toString());
		Teacher byId = teacherService.getById(userId);
		byId.setPhone(phone);
		teacherService.updateById(byId);
		model.addAttribute("obj",byId);
		return "login/update";
	}
	
	@RequestMapping(value = "/pass")
	public String pass(Integer id,Model model,HttpServletRequest request) {
		
		Object attribute = request.getSession().getAttribute("userId");
		
		if (attribute == null){
			return "redirect:/login/mtuichu";	
		}
		
		Integer userId = Integer.valueOf(attribute.toString());
		Teacher byId = teacherService.getById(userId);
		model.addAttribute("obj",byId);
		return "login/pass";
	}
	
	@RequestMapping("/upass")
	@ResponseBody
	public String upass(HttpServletRequest request,String password){
      Object attribute = request.getSession().getAttribute("userId");
      JSONObject j = new  JSONObject();
	   	if (attribute == null){
	   		j.put("res", 0);
	   		return j.toString();
		}
			Integer userId = Integer.valueOf(attribute.toString());
			Teacher byId = teacherService.getById(userId);
			byId.setPassword(password);
			teacherService.updateById(byId);
			j.put("res", 1);
			return j.toString();
			
	}
	
}

管理模块

package com.kewen.teacher.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSONObject;
import com.kewen.teacher.base.BaseController;
import com.kewen.teacher.mapper.*;
import com.kewen.teacher.po.*;
import com.kewen.teacher.service.*;
import com.kewen.teacher.utils.Pager;

import java.util.*;



@Controller
@RequestMapping("/manage")
public class ManageController extends BaseController {
	
	
	/**
	 * 依赖注入 start dao/service/===
	 */
	@Autowired
	private ManageService manageService;
	
	// --------------------------------------- 华丽分割线 ------------------------------
	
	/*********************************查询列表【不分页】***********************************************/
	
	/**
	 * 【不分页 => 查询列表 => 无条件】
	* @Title: listAll 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listAll")
	public String listAll(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAll();
		model.addAttribute("list", listAll);
		return "manage/manage";
	}
	
	/**
	 *  【不分页=》查询列表=>有条件】
	* @Title: listByEntity 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listByEntity")
	public String listByEntity(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAllByEntity(manage);
		model.addAttribute("list", listAll);
		return "manage/manage";
	}
	
	/**
	 *  【不分页=》查询列表=>有条件】
	* @Title: listByMap 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author 
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listByMap")
	public String listByMap(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response){
		//通过map查询
		Map<String,Object> params = new HashMap<String,Object>();
	        if(!isEmpty(manage.getUserName())){
	        	params.put("userName", manage.getUserName());
			}
	        if(!isEmpty(manage.getPassWord())){
	        	params.put("passWord", manage.getPassWord());
			}
	        if(!isEmpty(manage.getRealName())){
	        	params.put("realName", manage.getRealName());
			}
	    List<Manage> listAll = manageService.listByMap(params);
		model.addAttribute("list", listAll);
		return "manage/manage";
	}
	
	
	/*********************************查询列表【分页】***********************************************/
	
	
	
	/**
	 * 分页查询 返回list对象(通过对象)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findByObj")
	public String findByObj(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//分页查询
		Pager<Manage> pagers = manageService.findByEntity(manage);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", manage);
		return "manage/manage";
	}
	
	/**
	 * 分页查询 返回list对象(通过对By Sql)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findBySql")
	public String findBySql(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//分页查询
		String sql = "SELECT * FROM manage WHERE 1=1 ";
        if(!isEmpty(manage.getUserName())){
        	sql += " and userName like '%"+manage.getUserName()+"%'";
		}
        if(!isEmpty(manage.getPassWord())){
        	sql += " and passWord like '%"+manage.getPassWord()+"%'";
		}
        if(!isEmpty(manage.getRealName())){
        	sql += " and realName like '%"+manage.getRealName()+"%'";
		}
       sql += " ORDER BY ID DESC ";
		Pager<Manage> pagers = manageService.findBySqlRerturnEntity(sql);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", manage);
		return "manage/manage";
	}
	
	
	/**
	 * 分页查询 返回list对象(通过Map)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findByMap")
	public String findByMap(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//通过map查询
		Map<String,Object> params = new HashMap<String,Object>();
        if(!isEmpty(manage.getUserName())){
        	params.put("userName", manage.getUserName());
		}
        if(!isEmpty(manage.getPassWord())){
        	params.put("passWord", manage.getPassWord());
		}
        if(!isEmpty(manage.getRealName())){
        	params.put("realName", manage.getRealName());
		}
		//分页查询
		Pager<Manage> pagers = manageService.findByMap(params);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", manage);
		return "manage/manage";
	}
	
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "manage/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Manage obj = manageService.load(id);
		model.addAttribute("obj",obj);
		return "manage/view";
	}
	
	/**
	 * 添加执行
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	public String exAdd(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		manageService.insert(manage);
		return "redirect:/manage/findBySql.action";
	}
	
	
	/**
	 * 跳至修改页面
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		Manage obj = manageService.load(id);
		model.addAttribute("obj",obj);
		return "manage/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1.通过实体类修改,可以多传修改条件
		manageService.updateById(manage);
		//2.通过主键id修改
		//manageService.updateById(manage);
		return "redirect:/manage/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		///1.通过主键删除
		manageService.deleteById(id);
		/*以下是多种删除方式*/
//		//2.通过实体条件删除
//		manageService.deleteByEntity(manage);
//		//3.通过参数删除
//     //通过map查询
//		Map<String,Object> params = new HashMap<String,Object>();
//		
//        if(!isEmpty(manage.getUserName())){
//        	params.put("userName", manage.getUserName());
//		}
//       
//        if(!isEmpty(manage.getPassWord())){
//        	params.put("passWord", manage.getPassWord());
//		}
//       
//        if(!isEmpty(manage.getRealName())){
//        	params.put("realName", manage.getRealName());
//		}
//       
//		manageService.deleteByMap(params);
//		//4.状态删除
//		Manage load = manageService.getById(manage.getId())
//		load.setIsDelete(1);
//		manageService.update(load);
		//5.状态删除
		//Manage load = manageService.load(id);
		//load.setIsDelete(1);
		//manageService.update(load);
		return "redirect:/manage/findBySql.action";
	}
	
	// --------------------------------------- 华丽分割线 ------------------------------
	// --------------------------------------- 【下面是ajax操作的方法。】 ------------------------------

	/*********************************查询列表【不分页】***********************************************/
	
	/**
	 * 【不分页 => 查询列表 => 无条件】
	* @Title: listAll 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listAllJson", method = RequestMethod.POST)
	@ResponseBody
	public String listAllJson(Manage manage, HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAll();
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("list", listAll);
		jsonObject.put("obj", manage);
		return jsonObject.toString();
	}
	
	/**
	 *  【不分页=》查询列表=>有条件】
	* @Title: listByEntity 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listByEntityJson", method = RequestMethod.POST)
	@ResponseBody
	public String listByEntityJson(Manage manage,  HttpServletRequest request, HttpServletResponse response){
		List<Manage> listAll = manageService.listAllByEntity(manage);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("list", listAll);
		jsonObject.put("obj", manage);
		return jsonObject.toString();
	}
	
	/**
	 *  【不分页=》查询列表=>有条件】
	* @Title: listByMap 
	* @Description: TODO(这里用一句话描述这个方法的作用) 
	* @param @return 设定文件 
	* @author 
	* @return String 返回类型 
	* @throws
	 */
	@RequestMapping(value = "/listByMapJson", method = RequestMethod.POST)
	@ResponseBody
	public String listByMapJson(Manage manage,HttpServletRequest request, HttpServletResponse response){
		//通过map查询
		Map<String,Object> params = new HashMap<String,Object>();
	        if(!isEmpty(manage.getUserName())){
	        	params.put("userName", manage.getUserName());
			}
	        if(!isEmpty(manage.getPassWord())){
	        	params.put("passWord", manage.getPassWord());
			}
	        if(!isEmpty(manage.getRealName())){
	        	params.put("realName", manage.getRealName());
			}
	    List<Manage> listAll = manageService.listByMap(params);
	    JSONObject jsonObject = new JSONObject();
		jsonObject.put("list", listAll);
		jsonObject.put("obj", manage);
		return jsonObject.toString();
	}
	
	
	/**
	 * 分页查询 返回list json(通过对象)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findByObjJson", method = RequestMethod.POST)
	@ResponseBody
	public String findByObjByEntityJson(Manage manage, HttpServletRequest request, HttpServletResponse response) {
		//分页查询
		Pager<Manage> pagers = manageService.findByEntity(manage);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("pagers", pagers);
		jsonObject.put("obj", manage);
		return jsonObject.toString();
	}
	
	  
	/**
	 * 分页查询 返回list json(通过Map)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findByMapJson",  method = RequestMethod.POST)
	@ResponseBody
	public String findByMapJson(Manage manage,HttpServletRequest request, HttpServletResponse response) {
		//通过map查询
		Map<String,Object> params = new HashMap<String,Object>();
        if(!isEmpty(manage.getUserName())){
        	params.put("userName", manage.getUserName());
		}
        if(!isEmpty(manage.getPassWord())){
        	params.put("passWord", manage.getPassWord());
		}
        if(!isEmpty(manage.getRealName())){
        	params.put("realName", manage.getRealName());
		}
		//分页查询
		Pager<Manage> pagers = manageService.findByMap(params);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("pagers", pagers);
		jsonObject.put("obj", manage);
		return jsonObject.toString();
	}
	
	
	/**
	 * ajax 添加
	 * @param 
	 * @return
	 */
	@RequestMapping(value = "/exAddJson", method = RequestMethod.POST)
	@ResponseBody
	public String exAddJson(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		manageService.insert(manage);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("message", "添加成功");
		return jsonObject.toString();
	}
	

	/**
	 * ajax 修改
	 * @param 
	 * @return
	 */
	@RequestMapping(value = "/exUpdate.json", method = RequestMethod.POST)
	@ResponseBody
	public String exUpdateJson(Manage manage, Model model, HttpServletRequest request, HttpServletResponse response) {
		//1.通过实体类修改,可以多传修改条件
		manageService.updateById(manage);
		//2.通过主键id修改
		//manageService.updateById(manage);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("message", "修改成功");
		return jsonObject.toString();
	}

	/**
	 * ajax 删除
	 * @return
	 */
	@RequestMapping(value = "/delete.json", method = RequestMethod.POST)
	@ResponseBody
	public String exDeleteJson(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		///1.通过主键删除
		manageService.deleteById(id);
		/*以下是多种删除方式*/
//		//2.通过实体条件删除
//		manageService.deleteByEntity(manage);
//		//3.通过参数删除
//        //通过map查询
//		Map<String,Object> params = new HashMap<String,Object>();
//		
//        if(!isEmpty(manage.getUserName())){
//        	params.put("userName", manage.getUserName());
//		}
//       
//        if(!isEmpty(manage.getPassWord())){
//        	params.put("passWord", manage.getPassWord());
//		}
//       
//        if(!isEmpty(manage.getRealName())){
//        	params.put("realName", manage.getRealName());
//		}
//       
//		manageService.deleteByMap(params);
//		//4.状态删除
//		Manage load = manageService.getById(manage.getId())
//		load.setIsDelete(1);
//		manageService.updateById(load);
		//5.状态删除
		//Manage load = manageService.load(id);
		//load.setIsDelete(1);
		//manageService.updateById(load);
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("message", "删除成功");
		return jsonObject.toString();
	}
	/**
	 * 单文件上传
	 * @param file
	 * @param request
	 * @param model
	 * @return
	 */
    @RequestMapping(value = "/saveFile")  
    public String saveFile(@RequestParam(value = "file", required = false) MultipartFile file, HttpServletRequest request, Model model) {  
  
        System.out.println("开始");  
        String path = request.getSession().getServletContext().getRealPath("/upload");  
        String fileName = file.getOriginalFilename();  
        System.out.println(path);  
        File targetFile = new File(path, fileName);  
        if(!targetFile.exists()){  
            targetFile.mkdirs();  
        }  
        //保存  
        try {  
            file.transferTo(targetFile);  
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
  
        return "";  
    }  
	
	
	/**
	 * springMvc多文件上传
	 * @param files
	 * @param id
	 * @return
	 */
    @RequestMapping(value = "/saveFiles")
    public String saveFiles(@RequestParam("file") CommonsMultipartFile[] files,Integer id,HttpServletRequest request){
		for(int i = 0;i<files.length;i++){
	      	System.out.println("fileName---------->" + files[i].getOriginalFilename());
		  if(!files[i].isEmpty()){
            int pre = (int) System.currentTimeMillis();
	     	try {
			//拿到输出流,同时重命名上传的文件
			 String filePath = request.getRealPath("/upload");
			 File f=new File(filePath);
			 if(!f.exists()){
				f.mkdirs();
			 }
		     String fileNmae=new Date().getTime() + files[i].getOriginalFilename();
		     File file=new File(filePath+"/"+pre + files[i].getOriginalFilename());
			  if(!file.exists()){
				  file.createNewFile();
			 }
			  files[i].transferTo(file);
		     } catch (Exception e) {
				e.printStackTrace();
				System.out.println("上传出错");
			 }
		  }
		}
	  return "";
	}
 // --------------------------------------- 华丽分割线 ------------------------------
	
	
}

教师模块

package com.kewen.teacher.controller;
import java.io.File;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
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.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import com.alibaba.fastjson.JSONObject;
import com.kewen.teacher.base.BaseController;
import com.kewen.teacher.po.*;
import com.kewen.teacher.utils.Pager;
import java.util.*;

import com.kewen.teacher.po.*;
import com.kewen.teacher.mapper.*;
import com.kewen.teacher.service.*;

/**
 * @ClassName:  
 * @Description: 
 * @author  - - admin
 * @date - 2018年10月23日 19时51分27秒
 */


@Controller
@RequestMapping("/teacher")
public class TeacherController extends BaseController {
	
	
	/**
	 * 依赖注入 start dao/service/===
	 */
	@Autowired
	private TeacherService teacherService;
	
	// --------------------------------------- 华丽分割线 ------------------------------
	
	/**
	 * 分页查询 返回list对象(通过对By Sql)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findBySql")
	public String findBySql(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
		//分页查询
		String sql = "SELECT * FROM teacher WHERE isDelete = 0 ";
        if(!isEmpty(teacher.getUsername())){
        	sql += " and username like '%"+teacher.getUsername()+"%'";
		}
        if(!isEmpty(teacher.getSex())){
        	sql += " and sex like '%"+teacher.getSex()+"%'";
		}
        if(!isEmpty(teacher.getPassword())){
        	sql += " and password like '%"+teacher.getPassword()+"%'";
		}
        if(!isEmpty(teacher.getXw())){
        	sql += " and xw like '%"+teacher.getXw()+"%'";
		}
        if(!isEmpty(teacher.getPhone())){
        	sql += " and phone like '%"+teacher.getPhone()+"%'";
		}
        if(!isEmpty(teacher.getIsDelete())){
        	sql += " and isDelete like '%"+teacher.getIsDelete()+"%'";
		}
       sql += " ORDER BY ID DESC ";
		Pager<Teacher> pagers = teacherService.findBySqlRerturnEntity(sql);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", teacher);
		return "teacher/teacher";
	}
	
	
	/**
	 * 分页查询 返回list对象(通过Map)
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@RequestMapping(value = "/findByMap")
	public String findByMap(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
		//通过map查询
		Map<String,Object> params = new HashMap<String,Object>();
        if(!isEmpty(teacher.getUsername())){
        	params.put("username", teacher.getUsername());
		}
        if(!isEmpty(teacher.getSex())){
        	params.put("sex", teacher.getSex());
		}
        if(!isEmpty(teacher.getPassword())){
        	params.put("password", teacher.getPassword());
		}
        if(!isEmpty(teacher.getXw())){
        	params.put("xw", teacher.getXw());
		}
        if(!isEmpty(teacher.getPhone())){
        	params.put("phone", teacher.getPhone());
		}
        if(!isEmpty(teacher.getIsDelete())){
        	params.put("isDelete", teacher.getIsDelete());
		}
		//分页查询
		Pager<Teacher> pagers = teacherService.findByMap(params);
		model.addAttribute("pagers", pagers);
		//存储查询条件
		model.addAttribute("obj", teacher);
		return "teacher/teacher";
	}
	
	/**********************************【增删改】******************************************************/
	
	/**
	 * 跳至添加页面
	 * @return
	 */
	@RequestMapping(value = "/add")
	public String add() {
		return "teacher/add";
	}

	/**
	 * 跳至详情页面
	 * @return
	 */
	@RequestMapping(value = "/view")
	public String view(Integer id,Model model) {
		Teacher obj = teacherService.load(id);
		model.addAttribute("obj",obj);
		return "teacher/view";
	}
	
	/**
	 * 添加执行
	 * @return
	 */
	@RequestMapping(value = "/exAdd")
	public String exAdd(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
		teacher.setIsDelete(0);
		teacher.setPassword("111111");
		teacherService.insert(teacher);
		return "redirect:/teacher/findBySql.action";
	}
	
	
	/**
	 * 跳至修改页面
	 * @return
	 */
	@RequestMapping(value = "/update")
	public String update(Integer id,Model model) {
		Teacher obj = teacherService.load(id);
		model.addAttribute("obj",obj);
		return "teacher/update";
	}
	
	/**
	 * 添加修改
	 * @return
	 */
	@RequestMapping(value = "/exUpdate")
	public String exUpdate(Teacher teacher, Model model, HttpServletRequest request, HttpServletResponse response) {
		teacherService.updateById(teacher);
		return "redirect:/teacher/findBySql.action";
	}
	
	/**
	 * 删除通过主键
	 * @return
	 */
	@RequestMapping(value = "/delete")
	public String delete(Integer id, Model model, HttpServletRequest request, HttpServletResponse response) {
		Teacher load = teacherService.load(id);
		load.setIsDelete(1);
		teacherService.updateById(load);
		return "redirect:/teacher/findBySql.action";
	}
	
}

如果也想学习本系统,下面领取。关注并回复:097ssm 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/61600.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【前沿技术RPA】 一文了解UiPath 文件与文件夹自动化功能

&#x1f40b;作者简介&#xff1a;博主是一位.Net开发者&#xff0c;同时也是RPA和低代码平台的践行者。 &#x1f42c;个人主页&#xff1a;会敲键盘的肘子 &#x1f430;系列专栏&#xff1a;UiPath &#x1f980;专栏简介&#xff1a;UiPath在传统的RPA&#xff08;Robotic…

[YOLOv7/YOLOv5系列改进NO.40]融入适配GPU的轻量级 G-GhostNet

文章目录前言一、解决问题二、基本原理三、​添加方法四、总结前言 作为当前先进的深度学习目标检测算法YOLOv7&#xff0c;已经集合了大量的trick&#xff0c;但是还是有提高和改进的空间&#xff0c;针对具体应用场景下的检测难点&#xff0c;可以不同的改进方法。此后的系列…

头歌计算机组成原理汉字字库存储芯片扩展实验

全部答案点击底部 <?xml version"1.0" encoding"UTF-8" standalone"no"?> <project source"2.15.0.2.exe" version"1.0"> This file is intended to be loaded by Logisim http://logisim.altervista.org &…

如何在 Spring 或 Spring Boot 中使用键集分页

介绍 在本文中&#xff0c;我将向您展示如何在 Spring 或 Spring Boot 中使用键集分页技术。 虽然 Spring DataPagingAndSortingRepository提供的基于偏移量的默认分页在许多情况下很有用&#xff0c;但如果您必须迭代大型结果集&#xff0c;那么键集分页或查找方法技术可以提…

使用awk聚合和排序

用awk聚合和排序 文章目录用awk聚合和排序一、需求1.1 源文件格式1.2 需求二、用awk实现2.1 写法2.2 效果一、需求 1.1 源文件格式 一份csv文件&#xff08;默认逗号分隔&#xff09;一共五列&#xff0c;其中一列是用户名文件名&#xff1a;日志文件.csv type日记idusernam…

Android使用ListView,DrawerLayout实现简单注册功能界面

1.效果展示 2.实现 1.主页面activity_main.xml 主页面就是简单的几个TextView和EditText以及单选框组成的一个注册表单。 <?xml version"1.0" encoding"utf-8"?> <LinearLayoutxmlns:android"http://schemas.android.com/apk/res/andro…

[附源码]JAVA毕业设计口腔医院网站(系统+LW)

[附源码]JAVA毕业设计口腔医院网站&#xff08;系统LW&#xff09; 目运行 环境项配置&#xff1a; Jdk1.8 Tomcat8.5 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&…

java通过lock实现同步锁

这里我们是一个卖票的演示代码 其实 同步锁 远不止一个synchronized 它本身有一个 加上锁 和释放锁的过程 为了 让我们更好的理解这个过程 JDK5之后 为我们提供了一个单独的锁工具 lock lock是一个接口 他提供了 synchronized 方法 和 更广泛的语句操作 lock方法 获得锁 unl…

【C语言】函数传参与指针理解

文章目录指针与变量注意指针的本质指针和变量的用法函数与传参传变量与传指针的区别传变量与传指针的时机指针与变量 大三&#xff0c;但是C语言。目标&#xff1a;高屋建瓴&#xff0c;深入浅出。 注意 所有人在最开始学C语言的时候&#xff0c;老师都会和你说指针指向一个…

[附源码]JAVA毕业设计课程答疑系统(系统+LW)

[附源码]JAVA毕业设计课程答疑系统&#xff08;系统LW&#xff09; 目运行 环境项配置&#xff1a; Jdk1.8 Tomcat8.5 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&…

LLM.int8()——自适应混合精度量化方法

Paper地址&#xff1a;https://arxiv.org/abs/2208.07339 GitHub链接&#xff1a;GitHub - TimDettmers/bitsandbytes: 8-bit CUDA functions for PyTorch 随着模型参数规模的增加&#xff0c;大模型&#xff08;如GPT-3&#xff0c;OPT-175B等NLP稠密大模型&#xff09;的实际…

某验三代滑块流程分析

一、请求流程 slide-float.html 首先请求了个HTML文本jquery.js 拿回一个jQuery的jsgt.js 拿回gt.js 像是某验的网址信息register-slide?t1669432270469 一个请求、携带时间戳。返回challenge gt等信息gettype.php 获取验证码类型 携带gtfullpage.9.1.0.js 滑块js代码get.php …

【Java开发】 Spring 08 :访问 Web 资源( 借助 RestTemplate 或 WebClient )

web 资源就是运行在服务器上的资源&#xff0c;比如放到 web 下的页面 js 文件、图片、css等&#xff0c;web资源分为静态web资源和动态web资源两类&#xff0c;接下来访问的就是动态资源&#xff08;页面返回的数据是动态的&#xff0c;由后端程序产生&#xff09;&#xff0…

Rust权威指南之编写自动化测试

一. 简述 虽然Rust的类型系统为我们提供了相当多的安全保障&#xff0c;但是还是不足以防止所有的错误。因此&#xff0c;Rust在语言层面内置了编写测试代码、执行自动化测试任务的功能。 测试是一门复杂的技术&#xff0c;本章覆盖关于如何编写优秀测试的每一个细节&#xf…

[LeetCode周赛复盘] 第 322 场周赛20221204

[LeetCode周赛复盘] 第 322 场周赛20221204 一、本周周赛总结二、 [Easy] 6253. 回环句1. 题目描述2. 思路分析3. 代码实现三、[Medium] 6254. 划分技能点相等的团队1. 题目描述2. 思路分析3. 代码实现四、[Medium] 6255. 两个城市间路径的最小分数1. 题目描述2. 思路分析3. 代…

细粒度图像分类论文研读-2017

文章目录Higher-order Integration of Hierarchical Convolutional Activations for Fine-grained Visual Categorization(by end-to-end feature encoding)AbstractIntroduction关于核关于多尺度Kernelized convolutional activationsMatching kernel and polynomial predicto…

秒懂数据结构之Map _ Set ,竟如此简单

Map、Set 文章目录 前言一、Map、Set的初步理解二、Map、Set的CURD方法的实现三、Map、Set的遍历总结前言 Set和Map天然就是高效搜索/查找的语义在这里我为什么将这两个集合分别列举比较呢&#xff1f;希望通过我的这篇博客可以增进大家对Map和Set的认识&#xff01;一、Map、…

[附源码]Python计算机毕业设计Django汽车美容店管理系统

项目运行 环境配置&#xff1a; Pychram社区版 python3.7.7 Mysql5.7 HBuilderXlist pipNavicat11Djangonodejs。 项目技术&#xff1a; django python Vue 等等组成&#xff0c;B/S模式 pychram管理等等。 环境需要 1.运行环境&#xff1a;最好是python3.7.7&#xff0c;…

计算卫星高度角、方位角

最小二乘定权、电离层对流层改正&#xff0c;都需要卫星的高度角、方位角。本章将介绍求解完卫星的地固坐标系的位置后&#xff0c;如何求解卫星的高度角、方位角。 卫星位置求解请参考之前的博客&#xff1a;卫星位置解算原理与程序设计 参考书籍&#xff1a;黄丁发&#xff0…

读<算法图解><笔记摘录>

从很多途径当中,看到过这本书的知识点,是一本很有趣的算法入门书籍,最近花费了几天的时间将其阅读完,总想着总结一下这本书的算法知识点,分享给大家,也让自己掌握地更加踏实一点. 算法:一组完成任何任务的指令 算法这玩意,在保证满足条件,并且不浪费内存的情况下,要尽可能速度…