——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
该项目分为前台用户和后台管理员两个角色,
用户角色的功能:登录(JWT的token验证)、注册、浏览商品、修改个人信息(上传图片)、修改密码、评论商品、添加商品到购物车、提交订单、查看订单、收藏商品等等功能。
管理员角色的功能:管理用户信息、管理用户评论信息、管理商品信息、管理订单信息等等功能。

前台:











后台:








技术框架
SpringBoot SpringMVC MyBatis FreeMarker JWT Redis
基于javaweb的SpringBoot+MyBatis在线商城水果蔬菜商城果蔬商城(前台、后台)(java+springboot+ssm+freemarker+mysql+maven)
——————————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
| }
public void writefile(HttpServletResponse response, File file) { ServletOutputStream sos = null; FileInputStream aa = null; try { aa = new FileInputStream(file); sos = response.getOutputStream(); byte[] data = new byte[(int) file.length()]; IOUtils.readFully(aa, data); IOUtils.write(data, sos); } catch (IOException e) { e.printStackTrace(); } finally { try { sos.close(); aa.close(); } catch (IOException e) { e.printStackTrace(); } } } } package com.demo.controller.admin;
|
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
|
@RequestMapping(value="/add",method=RequestMethod.GET) public String add(Model model) { model.addAttribute("productCategoryList", productCategoryMapper.selectAll()); return "admin/product/add"; }
@RequestMapping(value="/edit",method=RequestMethod.GET) public String edit(Model model,Long id) { Product selectByPrimaryKey = productMapper.selectByPrimaryKey(id); if(selectByPrimaryKey == null) { return "error/404"; } model.addAttribute("productCategoryList", productCategoryMapper.selectAll()); model.addAttribute("Product", selectByPrimaryKey); return "admin/product/edit"; }
@RequestMapping(value="/add",method=RequestMethod.POST) @ResponseBody public ResponseVo<Boolean> add(Product product){ return productService.add(product); }
@RequestMapping(value="/edit",method=RequestMethod.POST) @ResponseBody public ResponseVo<Boolean> edit(Product product){
|
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
|
@RequestMapping("/upload") @Controller public class UploadController {
private String uploadPhotoSufix = ".jpg,.png,.gif,.jpeg";
private long uploadPhotoMaxSize = 10240;
private String uploadPhotoPath = System.getProperty("user.dir") + "/src/main/resources/upload/photo/";
private long uploadAttachmentMaxSize = 204800;
private String uploadAttachmentPath = System.getProperty("user.dir") + "/src/main/resources/upload/attachment/";
private Logger log = LoggerFactory.getLogger(UploadController.class);
@Autowired private AttachmentMapper attachmentMapper;
@RequestMapping(value = "/upload_photo", method = RequestMethod.POST) @ResponseBody public ResponseVo<String> uploadPhoto(@RequestParam(name = "photo", required = true) MultipartFile photo) { String originalFilename = photo.getOriginalFilename(); String suffix = originalFilename.substring(originalFilename.lastIndexOf("."), originalFilename.length()); if (!uploadPhotoSufix.contains(suffix.toLowerCase())) { return ResponseVo.errorByMsg(CodeMsg.UPLOAD_PHOTO_SUFFIX_ERROR); } if (photo.getSize() / 1024 > uploadPhotoMaxSize) { CodeMsg codeMsg = CodeMsg.UPLOAD_PHOTO_ERROR; codeMsg.setMsg("图片大小不能超过" + (uploadPhotoMaxSize / 1024) + "M");
|
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
| model.addAttribute("onThirdMenus", menuService.getThirdMenus(allMenusByStateAndPrimaryKeys).getData()); model.addAttribute("parentMenu", menuMapper.selectByPrimaryKey(selectByPrimaryKey.getParentId())); model.addAttribute("currentMenu", selectByPrimaryKey); return "admin/menu/index"; }
@RequestMapping(value="/icon",method=RequestMethod.GET) public String icon(Model model) { return "admin/menu/icon"; }
@RequestMapping(value="/add",method=RequestMethod.GET) public String add(Model model) { List<Menu> allMenus = menuMapper.selectAll(); model.addAttribute("FirstMenus",menuService.getFirstMenus(allMenus).getData()); return "admin/menu/add"; }
@RequestMapping(value="/edit",method=RequestMethod.GET) public String edit(Model model,Integer id) { Menu selectByPrimaryKey = menuMapper.selectByPrimaryKey(id); if(selectByPrimaryKey == null) { return "error/404"; } List<Menu> allMenus = menuMapper.selectAll(); model.addAttribute("FirstMenus",menuService.getFirstMenus(allMenus).getData()); model.addAttribute("SecondMenus",menuService.getSecondMenus(allMenus).getData()); model.addAttribute("editMenu",selectByPrimaryKey); return "admin/menu/edit"; }
|
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
|
@RequestMapping("/upload") @Controller public class UploadController {
private String uploadPhotoSufix = ".jpg,.png,.gif,.jpeg";
private long uploadPhotoMaxSize = 10240;
private String uploadPhotoPath = System.getProperty("user.dir") + "/src/main/resources/upload/photo/";
private long uploadAttachmentMaxSize = 204800;
private String uploadAttachmentPath = System.getProperty("user.dir") + "/src/main/resources/upload/attachment/";
private Logger log = LoggerFactory.getLogger(UploadController.class);
@Autowired private AttachmentMapper attachmentMapper;
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| } finally { try { sos.close(); aa.close(); } catch (IOException e) { e.printStackTrace(); } } } } package com.demo.controller.admin;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=251922520705106af
https://javayms.pages.dev?id=251922520705106af