源码获取:博客首页 "资源" 里下载!
项目介绍
汉服文化bbs商城系统,主要分为前后台。共分两种角色:管理员与普通用户;
管理员可登录前后台,普通用户仅可登录前台;普通用户登录后可发布、修改、删除自己的文章;
前台主要功能包括:
首页:文章列表、公告列表、汉服舞曲;
汉服形制:汉服发展史、汉服名词;
汉服礼仪;
汉服穿搭:汉服妆容、汉服摄影;
汉服活动:汉服事记;
推荐:汉服店铺、汉服推荐、汉服体验;
后台主要功能包括:
文章管理:查询、删除;
店铺推荐:新增推荐店、查看、修改、删除;
汉服体验店推荐:新增体验店、查看、修改、删除;
社团推荐:新增社团、查看、修改、删除;
汉服舞曲:新增舞曲、查看、删除;
公告管理:新增公告、查看、修改、删除;
留言管理:查询、修改、删除;
评论管理:查询、修改、删除;
环境需要
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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
6.数据库:MySql 5.7版本;
技术栈
1. 后端:SpringBoot
2. 前端:Thymeleaf+html+layui+jQuery+bootstrap
使用说明
1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;
4. 运行项目,输入http://localhost:8080/ 登录
后台管理订单控制层:
@Controller
@RequestMapping("/admin/order")
public class AdminOrderController {
@Autowired
private OrderService orderService;
/**
* 打开订单列表页面
* @return
*/
@RequestMapping("/toList.html")
public String toList() {
return "admin/order/list";
}
/**
* 获取所有订单的总数
* @return
*/
@ResponseBody
@RequestMapping("/getTotal.do")
public ResultBean<Integer> getTotal() {
Pageable pageable = new PageRequest(1, 15, null);
int total = (int) orderService.findAll(pageable).getTotalElements();
return new ResultBean<>(total);
}
/**
* 获取所有订单
* @param pageindex
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/list.do")
public ResultBean<List<Order>> listData(int pageindex,
@RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
Pageable pageable = new PageRequest(pageindex, pageSize, null);
List<Order> list = orderService.findAll(pageable).getContent();
return new ResultBean<>(list);
}
/**
* 获取订单项
* @param orderId
* @return
*/
@ResponseBody
@RequestMapping("/getDetail.do")
public ResultBean<List<OrderItem>> getDetail(int orderId) {
List<OrderItem> list = orderService.findItems(orderId);
return new ResultBean<>(list);
}
/**
* 发货
* @param id
* @return
*/
@ResponseBody
@RequestMapping("/send.do")
public ResultBean<Boolean> send(int id) {
orderService.updateStatus(id,3);
return new ResultBean<>(true);
}
}
后台用户管理控制层:
@Controller
@RequestMapping("/admin/user")
public class AdminUserController {
@Autowired
private UserService userService;
/**
* 打开用户列表页面
* @return
*/
@RequestMapping("/toList.html")
public String toList() {
return "admin/user/list";
}
/**
* 打开编辑页面
* @param id
* @param map
* @return
*/
@RequestMapping("/toEdit.html")
public String toEdit(int id, Map<String, Object> map) {
User user = userService.findById(id);
map.put("user", user);
return "admin/user/edit";
}
/**
* 获取所有用户列表
*
* @param pageindex
* @return
*/
@ResponseBody
@RequestMapping("/list.do")
public ResultBean<List<User>> findAllUser(int pageindex,
@RequestParam(value = "pageSize", defaultValue = "15") int pageSize) {
Pageable pageable = new PageRequest(pageindex, pageSize, null);
List<User> users = userService.findAll(pageable).getContent();
return new ResultBean<>(users);
}
@ResponseBody
@RequestMapping("/getTotal.do")
public ResultBean<Integer> geTotal() {
Pageable pageable = new PageRequest(1, 15, null);
int total = (int) userService.findAll(pageable).getTotalElements();
return new ResultBean<>(total);
}
@ResponseBody
@RequestMapping("/del.do")
public ResultBean<Boolean> del(int id) {
userService.delById(id);
return new ResultBean<>(true);
}
@ResponseBody
@RequestMapping(method = RequestMethod.POST, value = "/update.do")
public ResultBean<Boolean> update(int id,String username,
String password,String name,
String phone,String email,
String addr) {
// 更新前先查询
User user = userService.findById(id);
user.setId(id);
user.setName(name);
user.setUsername(username);
user.setPassword(password);
user.setAddr(addr);
user.setEmail(email);
user.setPhone(phone);
userService.update(user);
return new ResultBean<>(true);
}
}
前台用户订单管理:
@Controller
@RequestMapping("/order")
public class OrderController {
@Autowired
private OrderService orderService;
/**
* 打开订单列表页面
*
* @return
*/
@RequestMapping("/toList.html")
public String toOrderList() {
return "mall/order/list";
}
/**
* 查询用户订单列表
*
* @param request
* @return
*/
@RequestMapping("/list.do")
@ResponseBody
public ResultBean<List<Order>> listData(HttpServletRequest request) {
List<Order> orders = orderService.findUserOrder(request);
return new ResultBean<>(orders);
}
/**
* 查询订单详情
*
* @param orderId
* @return
*/
@RequestMapping("/getDetail.do")
@ResponseBody
public ResultBean<List<OrderItem>> getDetail(int orderId) {
List<OrderItem> orderItems = orderService.findItems(orderId);
return new ResultBean<>(orderItems);
}
/**
* 提交订单
*
* @param name
* @param phone
* @param addr
* @param request
* @param response
*/
@RequestMapping("/submit.do")
public void submit(String name,
String phone,
String addr,
HttpServletRequest request,
HttpServletResponse response) throws Exception {
orderService.submit(name, phone, addr, request, response);
}
/**
* 支付方法
*
* @param orderId
*/
@RequestMapping("pay.do")
@ResponseBody
public ResultBean<Boolean> pay(int orderId, HttpServletResponse response) throws IOException {
orderService.pay(orderId);
return new ResultBean<>(true);
}
/**
* 确认收货
* @param orderId
* @param response
* @return
* @throws IOException
*/
@RequestMapping("receive.do")
@ResponseBody
public ResultBean<Boolean> receive(int orderId, HttpServletResponse response) throws IOException {
orderService.receive(orderId);
return new ResultBean<>(true);
}
}
前台商品控制层:
@Controller
@RequestMapping("/product")
public class ProductController {
@Autowired
private ProductService productService;
@Autowired
private ClassificationService classificationService;
@Autowired
private ShopCartService shopCartService;
/**
* 获取商品信息
*
* @param id
* @return
*/
@RequestMapping("/get.do")
public ResultBean<Product> getProduct(int id) {
Product product = productService.findById(id);
return new ResultBean<>(product);
}
/**
* 打开商品详情页面
*
* @param id
* @param map
* @return
*/
@RequestMapping("/get.html")
public String toProductPage(int id, Map<String, Object> map) {
Product product = productService.findById(id);
map.put("product", product);
return "mall/product/info";
}
/**
* 查找热门商品
*
* @return
*/
@ResponseBody
@RequestMapping("/hot.do")
public ResultBean<List<Product>> getHotProduct() {
List<Product> products = productService.findHotProduct();
return new ResultBean<>(products);
}
/**
* 查找最新商品
*
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/new.do")
public ResultBean<List<Product>> getNewProduct(int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findNewProduct(pageable);
return new ResultBean<>(products);
}
/**
* 打开分类查看商品页面
*
* @return
*/
@RequestMapping("/category.html")
public String toCatePage(int cid, Map<String, Object> map) {
Classification classification = classificationService.findById(cid);
map.put("category", classification);
return "mall/product/category";
}
@RequestMapping("/toCart.html")
public String toCart(){
return "mall/product/cart";
}
/**
* 按一级分类查找商品
*
* @param cid
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/category.do")
public ResultBean<List<Product>> getCategoryProduct(int cid, int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findByCid(cid, pageable);
return new ResultBean<>(products);
}
/**
* 按二级分类查找商品
*
* @param csId
* @param pageNo
* @param pageSize
* @return
*/
@ResponseBody
@RequestMapping("/categorySec.do")
public ResultBean<List<Product>> getCategorySecProduct(int csId, int pageNo, int pageSize) {
Pageable pageable = new PageRequest(pageNo, pageSize);
List<Product> products = productService.findByCsid(csId, pageable);
return new ResultBean<>(products);
}
/**
* 根据一级分类查询它所有的二级分类
* @param cid
* @return
*/
@ResponseBody
@RequestMapping("/getCategorySec.do")
public ResultBean<List<Classification>> getCategorySec(int cid){
List<Classification> list = classificationService.findByParentId(cid);
return new ResultBean<>(list);
}
/**
* 加购物车
*
* @param productId
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/addCart.do")
public ResultBean<Boolean> addToCart(int productId, HttpServletRequest request) throws Exception {
shopCartService.addCart(productId, request);
return new ResultBean<>(true);
}
/**
* 移除购物车
*
* @param productId
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/delCart.do")
public ResultBean<Boolean> delToCart(int productId, HttpServletRequest request) throws Exception {
shopCartService.remove(productId, request);
return new ResultBean<>(true);
}
/**
* 查看购物车商品
* @param request
* @return
*/
@ResponseBody
@RequestMapping("/listCart.do")
public ResultBean<List<OrderItem>> listCart(HttpServletRequest request) throws Exception {
List<OrderItem> orderItems = shopCartService.listCart(request);
return new ResultBean<>(orderItems);
}
}
源码获取:博客首页 "资源" 里下载!