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






基于javaweb的SpringBoot优咪商城系统(java+springboot+html+thymeleaf+bootstrap+layui+maven+mysql)
1 2 3 4 5 6
| 管理员(user表): admin 123456
普通用户(customer表): 13511111111 123456 13522222222 123456
|
前台用户:浏览商品、购物、收货评价等
后台管理员:管理商品、类型、订单等
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。
2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;
3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS;
4.数据库:MySql 5.7版本;
技术栈
后端:Springboot
前端:html+bootstrap+jQuery+layui+ueditor
使用说明
运行项目 前台地址:http://localhost:8080/
后台浏览地址:http://localhost:8080/login.html
——————————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
| @Override public boolean preHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o) throws Exception {
String uid = ""; Cookie[] cookies = httpServletRequest.getCookies(); if(cookies==null || cookies.length==0){ }else{ for (Cookie cookie : cookies) { if(cookie.getName().equals("login_key_auth_customer")){ uid = cookie.getValue(); } } } CustomerEntity userEntity = customerService.selectById(uid); if(userEntity==null){ httpServletRequest.setAttribute("loginFlag",false); }else{ httpServletRequest.setAttribute("loginFlag",true); httpServletRequest.setAttribute("loginCustomer",userEntity); Cookie cookie = new Cookie("login_key_auth_customer",userEntity.getId()); cookie.setPath("/"); cookie.setMaxAge(3600000); httpServletResponse.addCookie(cookie); } Contants.CUSTOMER_ENTITY_THREAD_LOCAL.set(userEntity); if(!httpServletRequest.getRequestURI().endsWith("do")){ return true; }else{ if(userEntity==null){ throw new NeedLoginException("需要登录"); } } return true; }
@Override public void postHandle(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, ModelAndView modelAndView) throws Exception {
}
@Override public void afterCompletion(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) throws Exception {
} }
|
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
|
}
@Controller @RequestMapping("file") public class ImgController { public static final String FILE_PATH = System.getProperty("user.dir") + "\\src\\main\\resources\\static\\image_upload\\";
@PostMapping("/upload") @ResponseBody public Result uplaod(@RequestParam("file") MultipartFile file) throws Exception { String fileName = IdWorker.get32UUID() + file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf("."));
|
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
|
@Controller @RequestMapping("order") public class SpOrderController { @Autowired private ShoppingGatService shoppingGatService;
@Autowired private ShopService shopService;
@Autowired private OrderShopService orderShopService;
@Autowired private OrderService orderService;
@Autowired private CustomerAddressService customerAddressService;
@Autowired private OrderShopDao orderShopDao;
|
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
| service.updateById(entity); } return Result.success("保存成功"); }
@PostMapping("del.htm") @ResponseBody public Result del(String id)throws Exception{ service.deleteById(id); return Result.success("保存成功"); }
}
@Controller @RequestMapping("shoptype") public class TypeController {
|
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
| * @return * @throws Exception */ @GetMapping("page.htm") @ResponseBody public PageVo page(String title, String summary,int page , int limit)throws Exception{ EntityWrapper entityWrapper = new EntityWrapper(); if(!StringUtils.isEmpty(title)){ entityWrapper.like(ArticleTable.TITLE,title); } if(!StringUtils.isEmpty(summary)){ entityWrapper.like(ArticleTable.SUMMARY,summary); } entityWrapper.orderBy("top",false).orderBy("time",false); Page<ArticleEntity> paged = new Page(); paged.setSize(limit); paged.setCurrent(page); Page<ArticleEntity> userTablePage = articleService.selectPage(paged, entityWrapper);
List<ArticleEntity> list = userTablePage.getRecords(); if(list!=null && !list.isEmpty()){ for (ArticleEntity articleEntity : list) { CustomerEntity customerEntity = customerService.selectById(articleEntity.getCustomerId()); if(customerEntity!=null){ articleEntity.setCustomerName(customerEntity.getName()); } ChildTypeEntity childTypeEntity = childTypeService.selectById(articleEntity.getChildType()); if(childTypeEntity!=null){ articleEntity.setChildName(childTypeEntity.getName()); } } } PageVo<ArticleEntity> pageVo = new PageVo<>(); pageVo.setCode(0); pageVo.setCount(paged.getTotal()); pageVo.setData(list); pageVo.setPageNum(limit); pageVo.setPageSize(page); return pageVo;
}
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
| return "article/edit"; }
@RequestMapping("editData.htm") @ResponseBody public Result editData(ArticleEntity articleEntity)throws Exception{ articleService.updateById(articleEntity); return Result.success("保存成功"); }
}
@Controller @RequestMapping("order")
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=461222052008200vo
https://javayms.pages.dev?id=461222052008200vo