基于JSP+SQL的大学生综合测评管理系统评优mysql数据源
1.包含源程序,数据库脚本。代码和数据库脚本都有详细注释。
2.课题设计仅供参考学习使用,可以在此基础上进行扩展完善
代码已经上传github,下载地址https://github.com/21503882/university-student
开发环境:
Eclipse ,MYSQL,JDK1.8,Tomcat 7
涉及技术点:
MVC模式、SpringMvc、Mybatis、Spring、HTML、JavaScript、CSS、JQUERY、log4j、Ajax、maven等
系统采用Mybatis框架实现ORM对象关系映射,前台JSP实现,后台springMvc映射,使用Spring框架进行整合。适合学习J2EE的一段时间的熟手,代码思路清晰,注解详细,数据库用的是mysql5.1,服务器用的tomcat7,JDK版本1.8. 编程软件Eclispe J2EE版本。是典型MVC架构,并且前后台分离
主要功能
大学生综合测评管理系统界面截图
1.超级用户登录界面
3、普通管理员登录管理(与超级管理员差用户管理这项)
package com.mmall.controller.backend;
import java.util.Map;
import java.util.Objects;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import com.google.common.collect.Maps;
import com.mmall.common.ResponseCode;
import com.mmall.common.RoleEnum;
import com.mmall.common.ServerResponse;
import com.mmall.domain.Product;
import com.mmall.domain.User;
import com.mmall.service.IProductService;
import com.mmall.util.FileUtil;
import com.mmall.util.PropertiesUtil;
import com.mmall.util.SessionUtil;
@Controller
@RequestMapping("/manage/product")
public class ProductManageController {
@Autowired
private IProductService productService;
@Autowired
private SessionUtil sessionUtil;
private ServerResponse checkLoginAndRole(HttpServletRequest request ){
User user = sessionUtil.checkLogin(request);
if (user == null){
return ServerResponse.Failure(ResponseCode.NEED_LOGIN.getCode(),"请登录后操作");
}else if(!Objects.equals(user.getRole() , RoleEnum.ADMIN.getCode())){
return ServerResponse.Failure("没有权限");
}
return ServerResponse.Success();
}
@RequestMapping("save.do")
@ResponseBody
public ServerResponse productSave(HttpServletRequest request , @Valid Product product , BindingResult bindingResult){
if (bindingResult.hasErrors()){
return ServerResponse.Failure(bindingResult.getFieldError().toString());
}
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
return productService.saveOrUpdateProduct(product);
}
}
@RequestMapping("list.do")
@ResponseBody
public ServerResponse productList(HttpServletRequest request ,
@RequestParam(value = "pageNum" , defaultValue = "1") int pageNum ,
@RequestParam(value = "pageSize" , defaultValue = "10") int pageSize){
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
return productService.getProductList(pageNum , pageSize);
}
}
@RequestMapping("search.do")
@ResponseBody
public ServerResponse productSearch(HttpServletRequest request ,
@RequestParam("productName") String productName,
@RequestParam(value = "productId" , required = false) Integer productId,
@RequestParam(value = "pageNum" , defaultValue = "1") int pageNum ,
@RequestParam(value = "pageSize" , defaultValue = "10") int pageSize){
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
return productService.getProductList(pageNum , pageSize);
}
}
@RequestMapping("detail.do")
@ResponseBody
public ServerResponse productDetail(HttpServletRequest request ,
@RequestParam(value = "productId" , required = true) Integer productId){
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
return productService.getProductDetail(productId);
}
}
@RequestMapping("set_sale_status.do")
@ResponseBody
public ServerResponse productSetSaleStatus(HttpServletRequest request ,
@RequestParam(value = "productId" , required = true) Integer productId,
@RequestParam(value = "status") Integer status){
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
return productService.setSaleStatus(productId , status);
}
}
@RequestMapping("upload.do")
@ResponseBody
public ServerResponse productUpload(HttpServletRequest request ,
@RequestParam("upload_file") MultipartFile file){
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()){
return loginRet;
}else{
String path = request.getServletContext().getRealPath("upload");
String uploadFileName = FileUtil.upload(file, path);
if (StringUtils.isNotBlank(uploadFileName)){
String url = PropertiesUtil.getProperty("ftp.server.http.prefix") + uploadFileName;
Map fileMap = Maps.newHashMap();
fileMap.put("uri",uploadFileName);
fileMap.put("url",url);
return ServerResponse.Success(fileMap);
}else{
return ServerResponse.Failure("上传失败");
}
}
}
@RequestMapping("richtext_img_upload.do")
@ResponseBody
public Map richtextImgUpload(@RequestParam(value = "upload_file",required = false) MultipartFile file,
HttpServletRequest request,
HttpServletResponse response) {
//富文本中对于返回值有自己的要求,我们使用是simditor所以按照simditor的要求进行返回
// {
// "success": true/false,
// "msg": "error message", # optional
// "file_path": "[real file path]"
// }
Map resultMap = Maps.newHashMap();
ServerResponse loginRet = checkLoginAndRole(request);
if (!loginRet.isSuccess()) {
resultMap.put("success",false);
resultMap.put("msg",loginRet.getMsg());
return resultMap;
} else {
String path = request.getSession().getServletContext().getRealPath("upload");
String targetFileName = FileUtil.upload(file, path);
if (StringUtils.isBlank(targetFileName)) {
resultMap.put("success",false);
resultMap.put("msg","上传失败");
return resultMap;
}
String url = PropertiesUtil.getProperty("ftp.server.http.prefix") + targetFileName;
resultMap.put("success",true);
resultMap.put("msg","上传成功");
resultMap.put("file_path",url);
response.addHeader("Access-Control-Allow-Headers", "X-File-Name");
return resultMap;
}
}
}
package com.mmall.controller.backend;
import com.mmall.common.Const;
import com.mmall.common.RoleEnum;
import com.mmall.common.ServerResponse;
import com.mmall.domain.User;
import com.mmall.service.IUserService;
import com.mmall.util.SessionUtil;
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.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/manage/user")
public class UserManageController {
@Autowired
private IUserService iUserService;
@Autowired
private SessionUtil sessionUtil;
@RequestMapping(value="login.do",method = RequestMethod.POST)
@ResponseBody
public ServerResponse
ServerResponse
if(ret.isSuccess()){
User user = ret.getData();
if(user.getRole() == RoleEnum.ADMIN.getCode()){
//说明登录的是管理员
// session.setAttribute(Const.CURRENT_USER,user);
sessionUtil.login(response , session , ret.getData());
return ret;
}else{
return ServerResponse.Failure("不是管理员,无法登录");
}
}
return ret;
}
}
代码已经上传github,下载地址https://github.com/21503882/university-student