Java项目:springboot超市订单管理系统

作者主页:源码空间站2022

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

文末获取源码

项目介绍

该超市订单管理毕业设计基于jdk8版本开发,在部署时需要使用jdk8以上的版本。使用了目前流行的框架组合springboot+mybatis的框架技术, 实现了供应商管理对供应商实现增删改查、订单管理对超市订单实现增删改查、用户管理等功能,适用于小型超市的使用,通过学习该超市订单管理的毕业设计,对于springboot+mybatis框架的组合能够有更深层次的理解。

由于本程序规模不大,可供课程设计,毕业设计学习演示之用

环境需要

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版本;

6.是否Maven项目: 是

技术栈

1. 后端:springboot MyBatis

2. 前端:JSP+css+javascript

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;

4. 运行成功后,访问http://localhost:8080/ 到登录页面

运行截图

 Java项目:springboot超市订单管理系统_第1张图片

Java项目:springboot超市订单管理系统_第2张图片

Java项目:springboot超市订单管理系统_第3张图片

Java项目:springboot超市订单管理系统_第4张图片

Java项目:springboot超市订单管理系统_第5张图片

Java项目:springboot超市订单管理系统_第6张图片

代码相关

登录控制器

@Controller
public class LoginServlet{
	@Autowired
	UserServiceImpl userService;
	@Autowired
	RoleServiceImpl roleService;
	@Autowired
	ProviderServiceImpl providerService;
	@Autowired
	BillServiceImpl billService;

	@RequestMapping(value="/login.do",method = {RequestMethod.POST, RequestMethod.GET})
	public String doPost(HttpServletRequest request, HttpServletResponse response, Model model){
		System.out.println("login ============ " );
		//获取用户名和密码
		String userCode = request.getParameter("userCode");
		String userPassword = request.getParameter("userPassword");
		System.out.println(userCode+" "+userPassword);
		//调用service方法,进行用户匹配
		User user = userService.login(userCode,userPassword);
		System.out.println(user);
		if(null != user){//登录成功
			//放入session
			request.getSession().setAttribute(Constants.USER_SESSION, user);
			//页面跳转(frame.jsp)
			return "frame";
		}else{
			//页面跳转(login.jsp)带出提示信息--转发
			model.addAttribute("error", "用户名或密码不正确");
			return "login";
			//.forward(request, response);
		}
	}



}

 供应商管理控制器

@Controller
public class ProviderServlet {
	@Autowired
	BillServiceImpl billService;
	@Autowired
	ProviderServiceImpl providerService;
	@Autowired
	UserServiceImpl userService;

	@RequestMapping(value="/provider.do",method = {RequestMethod.POST, RequestMethod.GET})
	public String doPost(HttpServletRequest request, HttpServletResponse response, @RequestParam(value="method",required = false) String method)
			throws ServletException, IOException {
		if(method != null && method.equals("query")){
			return this.query(request,response);
		}else if(method != null && method.equals("add")){
			return this.add(request,response);
		}else if(method != null && method.equals("view")){
			return this.getProviderById(request,response,"providerview");
		}else if(method != null && method.equals("modify")){
			return this.getProviderById(request,response,"providermodify");
		}else if(method != null && method.equals("modifysave")){
			return this.modify(request,response);
		}else if(method != null && method.equals("delprovider")){
			 this.delProvider(request,response);
		}
		return "error";
	}

	private void delProvider(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String id = request.getParameter("proid");
		HashMap resultMap = new HashMap();
		if(!StringUtils.isNullOrEmpty(id)){

			int flag = providerService.deleteProviderById(id);
			if(flag == 0){//删除成功
				resultMap.put("delResult", "true");
			}else if(flag == -1){//删除失败
				resultMap.put("delResult", "false");
			}else if(flag > 0){//该供应商下有订单,不能删除,返回订单数
				resultMap.put("delResult", String.valueOf(flag));
			}
		}else{
			resultMap.put("delResult", "notexit");
		}
		//把resultMap转换成json对象输出
				//		response.setContentType("application/json");
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		PrintWriter outPrintWriter = response.getWriter();
		outPrintWriter.write(JSONArray.toJSONString(resultMap));
		outPrintWriter.flush();
		outPrintWriter.close();
	}

	private String modify(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String proContact = request.getParameter("proContact");
		String proPhone = request.getParameter("proPhone");
		String proAddress = request.getParameter("proAddress");
		String proFax = request.getParameter("proFax");
		String proDesc = request.getParameter("proDesc");
		String id = request.getParameter("id");
		Provider provider = new Provider();
		provider.setId(Integer.valueOf(id));
		provider.setProContact(proContact);
		provider.setProPhone(proPhone);
		provider.setProFax(proFax);
		provider.setProAddress(proAddress);
		provider.setProDesc(proDesc);
		provider.setModifyBy(((User)request.getSession().getAttribute(Constants.USER_SESSION)).getId());
		provider.setModifyDate(new Date());
		boolean flag = false;

		flag = providerService.modify(provider);
		System.out.println("--------flag="+flag);
		if(flag){
			return "redirect:/provider.do?method=query";
//			response.sendRedirect(request.getContextPath()+"/jsp/provider.do?method=query");
		}else{
			return "providermodify";
//			request.getRequestDispatcher("providermodify.jsp").forward(request, response);
		}

	}

	private String getProviderById(HttpServletRequest request, HttpServletResponse response, String url)
			throws ServletException, IOException {

		String id = request.getParameter("proid");
		System.out.println("-------------"+id);
		if(!StringUtils.isNullOrEmpty(id)){

			Provider provider = null;
			provider = providerService.getProviderById(id);
			request.setAttribute("provider", provider);
			System.out.println("-------------"+id);
			return url;
//			request.getRequestDispatcher(url).forward(request, response);
		}
		return "error";
	}
	private String add(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String proCode = request.getParameter("proCode");
		String proName = request.getParameter("proName");
		String proContact = request.getParameter("proContact");
		String proPhone = request.getParameter("proPhone");
		String proAddress = request.getParameter("proAddress");
		String proFax = request.getParameter("proFax");
		String proDesc = request.getParameter("proDesc");

		Provider provider = new Provider();
		provider.setProCode(proCode);
		provider.setProName(proName);
		provider.setProContact(proContact);
		provider.setProPhone(proPhone);
		provider.setProFax(proFax);
		provider.setProAddress(proAddress);
		provider.setProDesc(proDesc);
		provider.setCreatedBy(((User)request.getSession().getAttribute(Constants.USER_SESSION)).getId());
		provider.setCreationDate(new Date());
		boolean flag = false;

		flag = providerService.add(provider);
		if(flag){
			return "redirect:/provider.do?method=query";
//			response.sendRedirect(request.getContextPath()+"/jsp/provider.do?method=query");
		}else{
			return "provideradd";
//			request.getRequestDispatcher("provideradd.jsp").forward(request, response);
		}
	}

	private String query(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String queryProName = request.getParameter("queryProName");
		String queryProCode = request.getParameter("queryProCode");
		if(StringUtils.isNullOrEmpty(queryProName)){
			queryProName = "";
		}
		if(StringUtils.isNullOrEmpty(queryProCode)){
			queryProCode = "";
		}
		List providerList = new ArrayList();
		providerList = providerService.getProviderList(queryProName,queryProCode);
		request.setAttribute("providerList", providerList);
		request.setAttribute("queryProName", queryProName);
		request.setAttribute("queryProCode", queryProCode);
		return "providerlist";
//		request.getRequestDispatcher("providerlist.jsp").forward(request, response);
	}


}

如果也想学习本系统,下面领取。回复:086springboot

 

你可能感兴趣的:(java,springboot,java,spring,boot,spring)