项目介绍
本项目为前后台管理系统,包括管理员与普通用户两种角色;
管理员角色包含以下功能:
管理员登录,用户管理,商品类型管理,商品管理,订单信息管理,用户留言管理,资讯管理等功能。
用户角色包含以下功能:
用户首页,用户登录,商品推荐,资讯信息,留言板,查看商品,提交订单,查看订单信息,个人资料管理等功能。
ps:推荐模块用了协同过滤推荐算法,下订单模块用的是百度地图api。本商城可以修改为任意商城不止是体育商城。
环境需要
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项目:是;
技术栈
-
后端:SpringBoot
-
前端:HTML+JSP+CSS+JavaScript+jQuery
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
- 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; - 将项目中application.properties配置文件中的数据库配置改为自己的配置;
- 运行项目,在浏览器中输入http://localhost:8110/ 登录
管理员账号/密码:admin/admin
用户账号/密码: user/123456
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
return "/index/goods.jsp";
}
/**
* 新品上市
* @return
* @throws UnsupportedEncodingException
*/
@GetMapping("/new")
public String news(HttpServletRequest request,
@RequestParam(required=false, defaultValue="1")int page,
@RequestParam(required=false, defaultValue="10")int size) throws UnsupportedEncodingException{
request.setAttribute("flag", 4);
request.setAttribute("goodList", goodService.getList(page, size));
request.setAttribute("pageHtml", PageUtil.getPageHtml(request, goodService.getCount(), page, size));
return "/index/goods.jsp";
}
/**
* 搜索
* @return
/**
* 订单完成
* @return
*/
@GetMapping("/orderFinish")
public String orderFinish(int id, byte status,
@RequestParam(required=false, defaultValue="1") int page) {
orderService.finish(id);
return "redirect:orderList?flag=3&status="+status+"&page="+page;
}
/**
* 订单删除
* @return
*/
@GetMapping("/orderDelete")
* @return
*/
@PostMapping("/register")
public String register(Users user, HttpServletRequest request){
if (user.getUsername().isEmpty()) {
request.setAttribute("msg", "用户名不能为空!");
}else if (Objects.nonNull(userService.getByUsername(user.getUsername()))) {
request.setAttribute("msg", "用户名已存在!");
}else {
userService.add(user);
request.setAttribute("msg", "注册成功 可以去登录了!");
return "/index/login.jsp";
}
return "/index/register.jsp";
}
/**
* 用户登录
* @return
*/
@GetMapping("/login")
public String log() {
return "/index/login.jsp";
// 今日推荐
List<Goods> todayList = goodService.getListByTopType(Tops.TYPE_TODAY, 1, 6); // 取前6个
request.setAttribute("todayList", todayList);
// 热销排行
List<Goods> hotList = goodService.getListOrderSales(1, 10); // 取前10个
request.setAttribute("hotList", hotList);
// 类目列表
List<Types> typeList = typeService.getList();
List<Map<String, Object>> dataList = new ArrayList<>();
for(Types type : typeList) {
Map<String, Object> map = new HashMap<>();
map.put("type", type);
map.put("goodList", goodService.getListByType(type.getId(), 1, 15)); // 取前15个
dataList.add(map);
}
request.setAttribute("dataList", dataList);
return "/index/index.jsp";
}
/**
* 商品分类
* @return
* @throws UnsupportedEncodingException
*/
@GetMapping("/type")
public String type(HttpServletRequest request,
@RequestParam(required=false, defaultValue="0")int id,
public String userAdd(HttpServletRequest request) {
request.setAttribute("flag", 4);
return "/admin/user_add.jsp";
}
/**
* 顾客添加
* @return
*/
@PostMapping("/userSave")
public String userSave(Users user, HttpServletRequest request,
@RequestParam(required=false, defaultValue="1") int page) {
if (Objects.nonNull(userService.getByUsername(user.getUsername()))) {
request.setAttribute("msg", "用户名已存在!");
return "/admin/user_add.jsp";
}
@GetMapping("/cart")
public String cart(HttpServletRequest request, HttpSession session) {
Users user = (Users) session.getAttribute("user");
request.setAttribute("cartList", cartService.getList(user.getId()));
request.setAttribute("cartCount", cartService.getCount(user.getId()));
request.setAttribute("cartTotal", cartService.getTotal(user.getId()));
return "/index/cart.jsp";
}
/**
* 购物车总金额
* @return
*/
@GetMapping("/cartTotal")
public @ResponseBody int cartTotal(HttpSession session){
Users user = (Users) session.getAttribute("user");
return cartService.getTotal(user.getId());
}
*/
@GetMapping("/goodEdit")
public String goodEdit(int id, HttpServletRequest request) {
request.setAttribute("flag", 2);
request.setAttribute("typeList", typeService.getList());
request.setAttribute("good", goodService.get(id));
return "/admin/good_edit.jsp";
}
/**
* 产品更新
* @return
* @throws Exception
*/
@PostMapping("/goodUpdate")
public String goodUpdate(Goods good, MultipartFile file,
@RequestParam(required=false, defaultValue="1") int page) throws Exception {
if (Objects.nonNull(file) && !file.isEmpty()) {
good.setCover(UploadUtil.upload(file));
/**
* 类目更新
* @return
* @throws Exception
*/
@PostMapping("/typeUpdate")
public String typeUpdate(Types type) throws Exception {
typeService.update(type);
return "redirect:typeList?flag=1";
}
/**
* 类目删除
* @return
*/
@GetMapping("/typeDelete")
public String typeDelete(int id) {
typeService.delete(id);
return "redirect:typeList?flag=1";
}
/**
* 产品列表
* @return
*/
*/
@GetMapping("/login")
public String log() {
return "/index/login.jsp";
}
/**
* 用户登录
* @return
*/
@PostMapping("/login")
public String login(Users user, HttpServletRequest request, HttpSession session) {
Users loginUser = userService.getByUsernameAndPassword(user.getUsername(), user.getPassword());
}
request.setAttribute("msg", "用户名或密码错误!");
return "/admin/login.jsp";
}
/**
* 退出
* @return
*/
@GetMapping("/logout")
public String logout(HttpSession session) {
session.removeAttribute("admin");
return "/admin/login.jsp";
}
*/
@GetMapping("/hot")
public String hot(HttpServletRequest request,
@RequestParam(required=false, defaultValue="1")int page,
@RequestParam(required=false, defaultValue="10")int size) throws UnsupportedEncodingException{
request.setAttribute("flag", 3);
request.setAttribute("goodList", goodService.getListOrderSales(page, size));
request.setAttribute("pageHtml", PageUtil.getPageHtml(request, goodService.getCount(), page, size));
return "/index/goods.jsp";
}
/**
* 新品上市
* @return
* @throws UnsupportedEncodingException
*/
@GetMapping("/new")
public String news(HttpServletRequest request,
@RequestParam(required=false, defaultValue="1")int page,
@RequestParam(required=false, defaultValue="10")int size) throws UnsupportedEncodingException{