Java项目:零食商城系统(java+SSM+jsp+MySQL+EasyUI)

Posted qq_1334611189

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java项目:零食商城系统(java+SSM+jsp+MySQL+EasyUI)相关的知识,希望对你有一定的参考价值。

系统主要实现的功能有:用户浏览商品、加入商品到购物车、登录注册、提交订单,会员中心修改个人信息、查看订单等。

后台管理员登录后可以分角色添加管理员,不同角色有不同权限,可以管理用户信息、商品信息、订单信息,订单信息可以导出到excel。其中支付是模拟在线支付,从账户余额中扣费的,用户注册后自动设置余额为指定值。

 

 

购物车信息控制层:

@Controller
@RequestMapping("/cartInfo")
public class CartInfoController  
	@Autowired
	private ICartInfoBiz cartInfoBiz;

	
	@RequestMapping("/finds")
	@ResponseBody
	public List<GoodsInfo> finds(String mno) 					
		return cartInfoBiz.finds(mno);
	
	
	@RequestMapping("/update")
	@ResponseBody
	public Integer update(String cno, Integer num) 
		return cartInfoBiz.update(cno, num);
	
	
	@RequestMapping("/del")
	@ResponseBody
	public Integer del(String cno) 
		return cartInfoBiz.del(cno);
	
	
	@RequestMapping("/add")
	@ResponseBody
	public Integer add(String mno, String gno, Integer num) 					
		return cartInfoBiz.add(mno,gno,num);
	
	
	@RequestMapping("/checkCar")
	@ResponseBody
	public Integer checkCar(String mno, String gno) 					
		return cartInfoBiz.checkCar(mno,gno);
	
	
	@RequestMapping("/dels")
	@ResponseBody
	public Integer dels(String[]  gnos)throws IOException 
		return cartInfoBiz.dels(gnos);	
	
	

商品信息控制层:

@Controller
@RequestMapping("/goodsInfo")
public class GoodsInfoController  
	@Autowired
	private IGoodsInfoBiz goodsInfoBiz;

	
	@RequestMapping("/findAll")
	@ResponseBody
	public List<GoodsInfo> findAll() 									
		return goodsInfoBiz.findAll();
	
	
	@RequestMapping("/find")
	@ResponseBody
	public GoodsInfo find(String str) 
		System.out.println(goodsInfoBiz.find(str));
		return goodsInfoBiz.find(str);
	
	
	@RequestMapping("/findByTno")
	@ResponseBody
	public List<GoodsInfo> findByTno(String tno,String start) 
		return goodsInfoBiz.findByTno(tno,start);
	
	
	@RequestMapping("/updateBal")
	@ResponseBody
	public Integer updateBal(String[] gnos,String[] nums) 
		return goodsInfoBiz.updateBal(gnos,nums);
	
	
	
	@RequestMapping("/finds")
	@ResponseBody
	public List<GoodsInfo> finds() 
		return goodsInfoBiz.finds();
	
	@RequestMapping("/upload")
	@ResponseBody
	public Map<String, Object> add(@RequestParam("upload")MultipartFile pic,HttpServletRequest request) 
		Map<String, Object> map = new HashMap<String, Object>();
		if(pic.isEmpty())
			return map;
		
		try
			String savePath = "images/goods";
			
			String path = request.getServletContext().getRealPath("");
			String temp = request.getServletContext().getInitParameter("uploadPath");
			if(temp != null)
				savePath = temp;
			
			
			//在用户上传的文件名的前面加上时间戳
			savePath += "/" + new Date().getTime() + "_" +pic.getOriginalFilename();
			File dest = new File(new File(path).getParentFile(),savePath);
			
			//将本地图片保存到服务器
			pic.transferTo(dest);
			
			map.put("fileName", pic.getOriginalFilename());
			map.put("uploaded", 1);
			map.put("url","../../../"+savePath);
		catch(IllegalStateException e)
			e.printStackTrace();
		catch(IOException e)
			e.printStackTrace();
		
		return map;
		
	
	//管理员端的商品信息
	@RequestMapping("/addGood")
	@ResponseBody
	public int addGood(@RequestParam Map<String,Object> map,@RequestParam MultipartFile pic, HttpServletRequest request)
		int result =-1;

		if(pic.isEmpty())
			result=-2;//说明没有图片需要上传
		
		String savePath="";
		try 
			String path= request.getServletContext().getRealPath("");
			String temp = request.getServletContext().getInitParameter("uploadpath");
			if(!StringUtil.checkNull(temp))
				savePath = temp;
			
			
			savePath="images/goods/"+pic.getOriginalFilename();

			File dest = new File(path, savePath);
			//将图片存到服务器的指定文件夹
			pic.transferTo(dest);

		 catch (IllegalStateException e) 
			e.printStackTrace();
		 catch (IOException e) 
			e.printStackTrace();
		
		map.put("pics", savePath);
		result=goodsInfoBiz.addGood(map);
		return result;
	
	
	@RequestMapping("/findgoods")
	@ResponseBody
	public List<GoodsInfo> findgoods() 									
		return goodsInfoBiz.findgoods();
	
	
	@RequestMapping("/del")
	@ResponseBody
	public int del(String gno) 			
		return goodsInfoBiz.del(gno);
	
	
	@RequestMapping("/getPage")
	@ResponseBody
	public Integer getPage(String tno) 
		int total=goodsInfoBiz.getTotal(tno);
		int page=total%10==0?total/10:total/10+1;
		return page;
	

管理员信息控制层:

@Controller
@RequestMapping("/admin")
public class AdminInfoController  
	@Autowired
	private IAdminInfoBiz adminInfoBiz;

	@RequestMapping("/checkLogin")
	@ResponseBody
	public Object checkLogin(HttpSession session) 
		Object obj = session.getAttribute("currentLoginUser");
		if(obj == null)
			return "\\"code\\":\\"101\\"";
		 else 
			return obj;
		
	
	@RequestMapping("/login")
	@ResponseBody
	public int login(String aname, String pwd, HttpSession session) 			
		AdminInfo af = adminInfoBiz.login(aname, pwd);
		int result = 0;
		if(af != null)
			session.setAttribute("currentLoginUser", af);
			result = 1;
		
		return result;
	
	
	@RequestMapping("/success")
	public String loginSuccess(HttpSession session) 			
		if(session.getAttribute("currentLoginUser") != null)
			return "/WEB-INF/back/page/index.html";
		 else 
			return "/bk/index.html";//以/开头从项目目录开始算
		
	
	
	@RequestMapping("/findAll")
	@ResponseBody
	public List<AdminInfo> findAll() 			
		return adminInfoBiz.findAll();
	
	
	@RequestMapping("/add")
	@ResponseBody
	public int add(String aname, String pwd, String tel) 			
		return adminInfoBiz.add(aname,pwd,tel);
	
	
	@RequestMapping("/update")
	@ResponseBody
	public int update(String aid,String tel) 			
		return adminInfoBiz.update(aid,tel);
	
	
	@RequestMapping("/del")
	@ResponseBody
	public int del(String aid) 			
		return adminInfoBiz.del(aid);
	
	
	/*@RequestMapping("/upload")
	@ResponseBody
	public Map<String, String> upload(MultipartFile pics, HttpServletRequest request, @RequestParam Map<String, Object> params) 
		if (pics.isEmpty())
			return Collections.emptyMap();
		
		String savePath = "../pics";
		try
			String path = request.getServletContext().getRealPath("");
			String temp = request.getServletContext().getInitParameter("uploadpath");
			if(!StringUtil.checkNull(temp))
				savePath = temp;
			
			
			savePath += "/" + new Date().getTime() + "_" + new Random().nextInt(10000) + "-" + pics.getOriginalFilename();
			
			File dest = new File(path, savePath);
			//将图片存到服务器的指定文件
			pics.transferTo(dest);
		 catch (IllegalStateException e)
			e.printStackTrace();
		 catch (IOException e) 
			e.printStackTrace();
		
		params.put("photo", savePath);
		
		if(adminInfoBiz.updatephoto(params) > 0)
			Map<String, String> map = new HashMap<String, String>();
			map.put("savepath", savePath);
			return map;
		 else 
			return Collections.emptyMap();
		
		
	*/

以上是关于Java项目:零食商城系统(java+SSM+jsp+MySQL+EasyUI)的主要内容,如果未能解决你的问题,请参考以下文章

毕设网上零食商城基于SSM

基于ssm框架开发的零食商城源码

002基于ssm+bootstrap开发网上零食商城管理系统

基于Java+SpringBoot+Vue+uniapp微信小程序零食商城系统设计和实现

基于Java+SpringBoot+Vue+uniapp微信小程序零食商城系统设计和实现

基于Java+SpringBoot+Vue+uniapp微信小程序零食商城系统设计和实现