——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明






基于javaweb的SSM水果蔬菜商城系统(java+ssm+jsp+mysql)
项目描述:这是一个基于SSM框架开发的水果蔬菜商城系统。首先,这个项目页面简洁清爽,易于理解和学习。其次,这个项目功能丰富,具有一个在线水果蔬菜商城该有的所有功能,并且还涉及到沙箱支付宝支付等等技术亮点。
项目功能:此项目分为三个角色:客户、卖家和管理员。客户有登录注册、浏览商品信息、添加购物车、支付订单、收藏商品、评论商品等等功能。卖家有管理自己的商品、管理自己的订单、管理自己个人信息等等功能。管理员具有管理所有用户信息、管理所有商品信息、管理所有评论信息、管理商品种类信息、管理所有订单信息等等功能。
应用技术:Jsp + SSM + MySQL + 沙箱支付宝
运行环境:Eclipse/IntelliJ IDEA + MySQL5.7(项目压缩包中自带) + Tomcat7.0(项目压缩包中自带) + JDK1.8
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
| return ret; }
@RequestMapping(value = "/add",method = RequestMethod.POST) @ResponseBody @Transactional public Map<String, String> add(Long addressId, @RequestParam(name="remark",required=false)String remark, HttpServletRequest request, HttpServletResponse response){ Map<String, String> ret = new HashMap<String, String>(); Account onlineAccount = (Account)request.getSession().getAttribute("account"); onlineAccount = accountService.findById(onlineAccount.getId()); ret.put("type", "error"); if(addressId == null){ ret.put("msg", "请选择收货地址"); return ret; } Address address = addressService.findById(addressId); if(address == null){ ret.put("msg", "地址不存在!"); return ret; } Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("userId", onlineAccount.getId()); List<Cart> cartList = cartService.findList(queryMap); if(cartList == null){ ret.put("msg", "该用户购物车中没有商品!"); return ret; } double allOrderTotalMoney = 0; Map<Integer, Order> allOrderMap = new HashMap<Integer, Order>(); for(Cart cart : cartList) { allOrderTotalMoney += cart.getMoney(); Product selectedProduct = productService.findById(cart.getProductId()); if(selectedProduct == null) { ret.put("msg", "购物车中已经有商品不存在了,请删除!"); return ret; } if(allOrderMap.get(selectedProduct.getUserId()) == null) { Order order = new Order(); double totalMoney = 0; int totalNum = 0; order.setSellerId(selectedProduct.getUserId());
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
| @Autowired private AccountService accountService;
@RequestMapping(value="/list",method=RequestMethod.GET) public ModelAndView list(ModelAndView model){ model.setViewName("account/list"); return model; }
@RequestMapping(value="/list",method=RequestMethod.POST) @ResponseBody public Map<String, Object> list(@RequestParam(name="name",defaultValue="")String name, @RequestParam(name="sex",defaultValue="")Integer sex, @RequestParam(name="status",defaultValue="")Integer status, Page page ){ Map<String, Object> ret = new HashMap<String, Object>(); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("name", name); if(sex != null){ queryMap.put("sex", sex); } if(status != null){ queryMap.put("status", status); } queryMap.put("offset", page.getOffset()); queryMap.put("pageSize", page.getRows()); ret.put("rows", accountService.findList(queryMap)); ret.put("total", accountService.getTotal(queryMap)); return ret; }
@RequestMapping(value="/add",method=RequestMethod.POST) @ResponseBody public Map<String, Object> add(Account account){
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| * @return */ @RequestMapping(value="/list",method=RequestMethod.POST) @ResponseBody public Map<String, Object> getList(Page page, @RequestParam(name="name",required=false,defaultValue="") String name ){ Map<String, Object> ret = new HashMap<String, Object>(); Map<String, Object> queryMap = new HashMap<String, Object>(); queryMap.put("name", name); queryMap.put("offset", page.getOffset()); queryMap.put("pageSize", page.getRows()); ret.put("rows", roleService.findList(queryMap)); ret.put("total", roleService.getTotal(queryMap)); return ret; }
@RequestMapping(value="/add",method=RequestMethod.POST) @ResponseBody public Map<String, String> add(Role role){ Map<String, String> ret = new HashMap<String, String>(); if(role == null){ ret.put("type", "error"); ret.put("msg", "请填写正确的角色信息!"); return ret; } if(StringUtils.isEmpty(role.getName())){ ret.put("type", "error"); ret.put("msg", "请填写角色名称!"); return ret; } if(roleService.add(role) <= 0){ ret.put("type", "error"); ret.put("msg", "角色添加失败,请联系管理员!"); return ret; } ret.put("type", "success"); ret.put("msg", "角色添加成功!"); return ret; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
| ret.put("msg", "此商品不存在!"); return ret; } selectedProduct.setState(product.getState()); productService.edit(selectedProduct); ret.put("type", "success"); ret.put("msg", "成功修改商品状态!"); return ret; }
@RequestMapping(value="/add",method=RequestMethod.POST) @ResponseBody public Map<String, Object> add(Product product, HttpServletRequest request){ Map<String, Object> ret = new HashMap<String, Object>(); if(product == null){ ret.put("type", "error"); ret.put("msg", "请填写正确的商品信息"); return ret; } if(StringUtils.isEmpty(product.getName())){ ret.put("type", "error"); ret.put("msg", "请填写商品名称"); return ret; } if(product.getProductCategoryId() == null){ ret.put("type", "error"); ret.put("msg", "请选择所属分类!"); return ret; } if(product.getPrice() == null){ ret.put("type", "error"); ret.put("msg", "请填写商品价格!"); return ret; } if(StringUtils.isEmpty(product.getImageUrl())){ ret.put("type", "error"); ret.put("msg", "请上传商品主图"); return ret; } Role role = (Role) request.getSession().getAttribute("role"); User user = (User) request.getSession().getAttribute("admin"); if(role.getId().equals(Long.valueOf("2"))) { product.setUserId(Integer.valueOf(String.valueOf(user.getId()))); } ProductCategory productCategory = productCategoryService.findById(product.getProductCategoryId()); product.setTags(productCategory.getTags() + "," + productCategory.getId()); product.setCreateTime(new Date());
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| @RequestMapping(value="/edit",method=RequestMethod.POST) @ResponseBody public Map<String, String> edit(Role role){ Map<String, String> ret = new HashMap<String, String>(); if(role == null){ ret.put("type", "error"); ret.put("msg", "请填写正确的角色信息!"); return ret; } if(StringUtils.isEmpty(role.getName())){ ret.put("type", "error"); ret.put("msg", "请填写角色名称!"); return ret; } if(roleService.edit(role) <= 0){ ret.put("type", "error"); ret.put("msg", "角色修改失败,请联系管理员!"); return ret; } ret.put("type", "success"); ret.put("msg", "角色修改成功!"); return ret; }
@RequestMapping(value="/delete",method=RequestMethod.POST) @ResponseBody public Map<String, String> delete(Long id){ Map<String, String> ret = new HashMap<String, String>(); if(id == null){ ret.put("type", "error"); ret.put("msg", "请选择要删除的角色!"); return ret; } try { if(roleService.delete(id) <= 0){ ret.put("type", "error"); ret.put("msg", "删除失败,请联系管理员!"); return ret;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=091422292105200ek
https://javayms.pages.dev?id=091422292105200ek