文章目录
- 在线商城系统
- 一、项目演示
- 二、项目介绍
- 三、万字项目文档
- 四、部分功能截图
- 五、部分代码展示
- 六、底部获取项目源码带万字文档(9.9¥带走)
在线商城系统
一、项目演示
在线商城系统
二、项目介绍
基于springboot+vue的前后端分离在线商城系统
语言: Java 数据库:MySQL
前端技术:Vue、Element-Plus
后端技术:SpringBoot、Mybatis-Plus、Redis
系统角色 : 管理员、用户
管理员:登录、商品管理、分类管理、广告管理、头像管理、文件信息管理、图表分析、收入排行等
用户:注册、登录、商城首页、购物车信息、商品分类信息、订单信息
三、万字项目文档
四、部分功能截图
五、部分代码展示
package com.rabbiter.em.controller;
import com.auth0.jwt.JWT;
import com.rabbiter.em.annotation.Authority;
import com.rabbiter.em.common.Result;
import com.rabbiter.em.entity.AuthorityType;
import com.rabbiter.em.entity.Good;
import com.rabbiter.em.service.GoodService;
import com.rabbiter.em.service.UserService;
import com.rabbiter.em.entity.Carousel;
import com.rabbiter.em.service.CarouselService;
import com.rabbiter.em.entity.User;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;
@RestController
@RequestMapping("/api/carousel")
public class CarouselController {
@Resource
private CarouselService carouselService;
@Resource
private HttpServletRequest request;
@Resource
private UserService userService;
@Resource
private GoodService goodService;
public User getUser() {
String token = request.getHeader("token");
String username = JWT.decode(token).getAudience().get(0);
return userService.getOne(Wrappers.<User>lambdaQuery().eq(User::getUsername, username));
}
/*
查询
*/
@GetMapping("/{id}")
public Result findById(@PathVariable Long id) {
return Result.success(carouselService.getById(id));
}
@GetMapping
public Result findAll() {
List<Carousel> list = carouselService.getAllCarousel();
return Result.success(list);
}
/*
保存
*/
@Authority(AuthorityType.requireAuthority)
@PostMapping
public Result save(@RequestBody Carousel carousel) {
Good good = goodService.getById(carousel.getGoodId());
if(good == null) {
return Result.error("400", "商品id错误,未查询到商品id = " + carousel.getGoodId());
}
carouselService.saveOrUpdate(carousel);
return Result.success();
}
@Authority(AuthorityType.requireAuthority)
@PutMapping
public Result update(@RequestBody Carousel carousel) {
Good good = goodService.getById(carousel.getGoodId());
if(good == null) {
return Result.error("400", "商品id错误,未查询到商品id = " + carousel.getGoodId());
}
carouselService.updateById(carousel);
return Result.success();
}
/*
删除
*/
@Authority(AuthorityType.requireAuthority)
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
carouselService.removeById(id);
return Result.success();
}
}
package com.rabbiter.em.controller;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.rabbiter.em.annotation.Authority;
import com.rabbiter.em.constants.Constants;
import com.rabbiter.em.common.Result;
import com.rabbiter.em.entity.AuthorityType;
import com.rabbiter.em.entity.MyFile;
import com.rabbiter.em.service.FileService;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
@RestController
@RequestMapping("/file")
public class FileController {
@Resource
private FileService fileService;
//上传文件
@PostMapping("/upload")
public Result upload(@RequestParam MultipartFile file){
String url = fileService.upload(file);
return Result.success(url);
}
//根据文件名下载文件,即文件的url
@GetMapping("/{fileName}")
public void download(@PathVariable String fileName, HttpServletResponse response){
fileService.download(fileName,response);
}
//根据文件id删除文件
@Authority(AuthorityType.requireAuthority)
@DeleteMapping("/{id}")
public Result deleteById(@PathVariable int id){
int i = fileService.fakeDelete(id);
if(i == 1){
return Result.success();
}else{
return Result.error(Constants.CODE_500,"删除失败");
}
}
//批量删除文件
@Authority(AuthorityType.requireAuthority)
@PostMapping("/del/batch")
public Result deleteBatch(@RequestBody List<Integer> ids){
for (Integer id : ids) {
int i = fileService.fakeDelete(id);
if(i != 1){
return Result.error(Constants.CODE_500,"删除文件:"+fileService.getById(id).getName()+"时失败,删除已终止");
}
}
return Result.success();
}
@Authority(AuthorityType.requireAuthority)
@GetMapping("/enable")
public Result changeEnable(@RequestParam int id,@RequestParam boolean enable){
int i = fileService.changeEnable(id, enable);
if(i == 0){
return Result.error(Constants.CODE_500,"修改失败");
}else {
return Result.success();
}
}
//查询
@GetMapping("/page")
public Result selectPage(@RequestParam int pageNum,
@RequestParam int pageSize,
@RequestParam(required = false) String fileName){
IPage<MyFile> myFileIPage = fileService.selectPage(pageNum, pageSize, fileName);
return Result.success(myFileIPage);
}
}
package com.rabbiter.em.controller;
import com.rabbiter.em.annotation.Authority;
import com.rabbiter.em.constants.Constants;
import com.rabbiter.em.common.Result;
import com.rabbiter.em.entity.AuthorityType;
import com.rabbiter.em.entity.Good;
import com.rabbiter.em.entity.Standard;
import com.rabbiter.em.service.GoodService;
import com.rabbiter.em.service.StandardService;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;
@RestController
@RequestMapping("/api/good")
public class GoodController {
@Resource
private GoodService goodService;
@Resource
private StandardService standardService;
@Authority(AuthorityType.requireAuthority)
@PostMapping
public Result save(@RequestBody Good good) {
System.out.println(good);
return Result.success(goodService.saveOrUpdateGood(good));
}
@Authority(AuthorityType.requireAuthority)
@PutMapping
public Result update(@RequestBody Good good) {
goodService.update(good);
return Result.success();
}
@Authority(AuthorityType.requireAuthority)
@DeleteMapping("/{id}")
public Result delete(@PathVariable Long id) {
goodService.deleteGood(id);
return Result.success();
}
@GetMapping("/{id}")
public Result findById(@PathVariable Long id) {
return Result.success(goodService.getGoodById(id));
}
//获取商品的规格信息
@GetMapping("/standard/{id}")
public Result getStandard(@PathVariable int id) {
return Result.success(goodService.getStandard(id));
}
//查询推荐商品,即recommend=1
@GetMapping
public Result findAll() {
return Result.success(goodService.findFrontGoods());
}
//查询销量排行
@GetMapping("/rank")
public Result getSaleRank(@RequestParam int num){
return Result.success(goodService.getSaleRank(num));
}
//保存商品的规格信息
@PostMapping("/standard")
public Result saveStandard(@RequestBody List<Standard> standards, @RequestParam int goodId) {
//先删除全部旧记录
standardService.deleteAll(goodId);
//然后插入新记录
for (Standard standard : standards) {
standard.setGoodId(goodId);
if(!standardService.save(standard)){
return Result.error(Constants.CODE_500,"保存失败");
}
}
return Result.success();
}
//删除商品的规格信息
@Authority(AuthorityType.requireAuthority)
@DeleteMapping("/standard")
public Result delStandard(@RequestBody Standard standard) {
boolean delete = standardService.delete(standard);
if(delete) {
return Result.success();
}else {
return Result.error(Constants.CODE_500,"删除失败");
}
}
//修改商品的推荐字段
@Authority(AuthorityType.requireAuthority)
@GetMapping("/recommend")
public Result setRecommend(@RequestParam Long id,@RequestParam Boolean isRecommend){
return Result.success(goodService.setRecommend(id,isRecommend));
}
@GetMapping("/page")
public Result findPage(
@RequestParam(required = false, defaultValue = "1") Integer pageNum,
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
@RequestParam(required = false, defaultValue = "") String searchText,
@RequestParam(required = false) Integer categoryId) {
return Result.success(goodService.findPage(pageNum,pageSize,searchText,categoryId));
}
@GetMapping("/fullPage")
public Result findFullPage(
@RequestParam(required = false, defaultValue = "1") Integer pageNum,
@RequestParam(required = false, defaultValue = "10") Integer pageSize,
@RequestParam(required = false, defaultValue = "") String searchText,
@RequestParam(required = false) Integer categoryId) {
return Result.success(goodService.findFullPage(pageNum,pageSize,searchText,categoryId));
}
}
六、底部获取项目源码带万字文档(9.9¥带走)
有问题,或者需要协助调试运行项目的也可以