基于javaweb+mysql的springboot网上商城系统(java+springboot+maven+vue+vuerouter+elementui+axios+mysql+redis)
私信源码获取及调试交流
运行环境
Java≥8、MySQL≥5.7、Node.js≥10
开发工具
后端:eclipse/idea/myeclipse/sts等均可配置运行
前端:WebStorm/VSCode/HBuilderX等均可
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的SpringBoot网上商城系统(java+springboot+maven+vue+vuerouter+elementui+axios+mysql+redis)
管理员
admin 123456
用户
user1 123456
user2 123456
项目介绍
角色:普通用户、管理员角色 整体功能包含用户登录注册,商品浏览,商品检索,添加商品,意见反馈,个人中心,地址管理,个人收藏管理,商品下单,订单管理,用户管理,统计图表,用户信息管理,地址管理,商品信息管理,商品分类管理,收藏商品管理,购物车管理,足迹管理,订单发货,退换货,订单处理等。
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 4.数据库:MySql 5.7/8.0版本均可; 5.是否Maven项目:是;
技术栈
后台:SpringBoot+Mybatis
前端:Vue+Vue Router+ELementUI+Axios
使用说明
项目运行: 1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置;
商城首页展示:
登录首页展示:
商品详情信息展示:
订单详情展示:
后台模块展示:
后台统计信息展示:
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/confirm")
public class ConfirmController {
@Resource
private ConfirmMapper confirmMapper;
@GetMapping("/findAll")
public List<Confirm> findAll(){
List<Confirm> confirms = confirmMapper.selectList(null);
return confirms;
}
@GetMapping("/finds/{customerId}")
public Result<?> findCustomerId(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@PathVariable Integer customerId){
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/shopping")
public class ShoppingController {
@Resource
private ShoppingMapper shoppingMapper;
@GetMapping("/findAll")
public List<Shopping> findAll(){
List<Shopping> shops = shoppingMapper.selectList(null);
return shops;
}
@GetMapping("/finds/{customerId}")
public Result<?> findCustomerId(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@PathVariable Integer customerId){
Page<Shopping> page = shoppingMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Shopping>lambdaQuery().eq(Shopping::getCustomerId, customerId));
return Result.success(page);
}
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable("id") Integer id){
shoppingMapper.deleteById(id);
return Result.success();
}
@GetMapping("/find/{id}")
public Shopping find(@PathVariable("id") Integer id){
return this.shoppingMapper.selectById(id);
}
@PutMapping("/update")
public Result<?> update(@RequestBody Shopping shopping){
shoppingMapper.updateById(shopping);
return Result.success();
}
@PostMapping("/add")
public Result<?> insert(@RequestBody Shopping shopping){
shoppingMapper.insert(shopping);
return Result.success();
}
@PostMapping("/add")
public Result<?> insert(@RequestBody Refund refund){
refundMapper.insert(refund);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
refundMapper.deleteBatchIds(ids);
return Result.success();
}
@GetMapping("/count")
public Result Count(){
Integer count = refundMapper.selectCount(null);
return Result.success(count);
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Refund> refundPage = refundMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Refund>lambdaQuery().like(Refund::getProductName, search));
LambdaQueryWrapper<Refund> query = Wrappers.<Refund>lambdaQuery().orderByDesc(Refund::getRefundId);
if (StrUtil.isNotBlank(search)) {
query.like(Refund::getProductName, search);
}
return Result.success(refundPage);
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/assess")
public class AssessController {
@Autowired
private AssessMapper assessMapper;
@GetMapping("/findAll")
public List<Assess> findAll(){
List<Assess> assesss = assessMapper.selectList(null);
return assesss;
}
@GetMapping("/finds/{customerId}")
public Result<?> findCustomerId(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@PathVariable Integer customerId){
Page<Assess> page = assessMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Assess>lambdaQuery().eq(Assess::getCustomerId, customerId));
return Result.success(page);
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Integer id){
assessMapper.deleteById(id);
return Result.success();
}
@GetMapping("/find/{id}")
public Assess find(@PathVariable("id") Integer id){
return this.assessMapper.selectById(id);
}
@PutMapping("/update")
public Result Count(){
Integer count = infoMapper.selectCount(null);
return Result.success(count);
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Info> infoPage = infoMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Info>lambdaQuery().like(Info::getProductName, search));
LambdaQueryWrapper<Info> query = Wrappers.<Info>lambdaQuery().orderByDesc(Info::getProductId);
if (StrUtil.isNotBlank(search)) {
query.like(Info::getProductName, search);
}
return Result.success(infoPage);
}
}
@RestController
@RequestMapping("/receipt")
public class ReceiptController {
@Resource
private ReceiptMapper receiptMapper;
@GetMapping("/findAll")
public List<Receipt> findAll(){
List<Receipt> receipts = receiptMapper.selectList(null);
return receipts;
}
@GetMapping("/finds/{customerId}")
public Result<?> findCustomerId(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "5") Integer pageSize,
@PathVariable Integer customerId){
Page<Receipt> page = receiptMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Receipt>lambdaQuery().eq(Receipt::getCustomerId, customerId));
return Result.success(page);
}
@DeleteMapping("/delete/{id}")
public Result delete(@PathVariable("id") Integer id){
receiptMapper.deleteById(id);
return Result.success();
}
@GetMapping("/find/{id}")
public Receipt find(@PathVariable("id") Integer id){
return this.receiptMapper.selectById(id);
}
@PutMapping("/update")
public Result update(@RequestBody Receipt receipt){
receiptMapper.updateById(receipt);
return Result.success();
}
@PostMapping("/add")
public Result insert(@RequestBody Receipt receipt){
receiptMapper.insert(receipt);
return Result.success();
}
System.out.println("交易金额: " + params.get("total_amount"));
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
System.out.println("买家付款时间: " + params.get("gmt_payment"));
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
// 更新订单未已支付
masterMapper.updateState(tradeNo, 1);
}
}
return "success";
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/record")
public class RecordController {
@Resource
public Result<?> insert(@RequestBody Shopping shopping){
shoppingMapper.insert(shopping);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
shoppingMapper.deleteBatchIds(ids);
return Result.success();
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Shopping> shoppingPage = shoppingMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Shopping>lambdaQuery().like(Shopping::getProductName, search));
LambdaQueryWrapper<Shopping> query = Wrappers.<Shopping>lambdaQuery().orderByDesc(Shopping::getProductId);
if (StrUtil.isNotBlank(search)) {
query.like(Shopping::getProductName, search);
}
return Result.success(shoppingPage);
}
}
Page<Shopping> page = shoppingMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Shopping>lambdaQuery().eq(Shopping::getCustomerId, customerId));
return Result.success(page);
}
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable("id") Integer id){
shoppingMapper.deleteById(id);
return Result.success();
}
@GetMapping("/find/{id}")
public Shopping find(@PathVariable("id") Integer id){
return this.shoppingMapper.selectById(id);
}
@PutMapping("/update")
public Result<?> update(@RequestBody Shopping shopping){
shoppingMapper.updateById(shopping);
return Result.success();
}
@PostMapping("/add")
public Result<?> insert(@RequestBody Shopping shopping){
shoppingMapper.insert(shopping);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
shoppingMapper.deleteBatchIds(ids);
return Result.success();
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Shopping> shoppingPage = shoppingMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Shopping>lambdaQuery().like(Shopping::getProductName, search));
LambdaQueryWrapper<Shopping> query = Wrappers.<Shopping>lambdaQuery().orderByDesc(Shopping::getProductId);
if (StrUtil.isNotBlank(search)) {
public class RecordController {
@Resource
private RecordMapper recordMapper;
@GetMapping("/findAll")
public List<Record> findAll(){
List<Record> records = recordMapper.selectList(null);
return records;
}
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable("id") Integer id){
recordMapper.deleteById(id);
return Result.success();
}
@GetMapping("/find/{id}")
public Record find(@PathVariable("id") Integer id){
return this.recordMapper.selectById(id);
}
@PutMapping("/update")
public Result<?> update(@RequestBody Record record){
recordMapper.updateById(record);
return Result.success();
}
@PostMapping("/add")
public Result<?> insert(@RequestBody Record record){
recordMapper.insert(record);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
recordMapper.deleteBatchIds(ids);
return Result.success();
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Record> recordPage = recordMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Record>lambdaQuery().like(Record::getUsername, search).orderByDesc(Record::getCreateTime));
LambdaQueryWrapper<Record> query = Wrappers.<Record>lambdaQuery().orderByDesc(Record::getRecordId);
if (StrUtil.isNotBlank(search)) {
query.like(Record::getUsername, search);
}
return Result.success(recordPage);
}
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search) {
new Page<>(pageNum, pageSize);
Page<Good> goodPage = goodMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Good>lambdaQuery().like(Good::getGoodDescribe, search));
LambdaQueryWrapper<Good> query = Wrappers.<Good>lambdaQuery().orderByDesc(Good::getGoodId);
if (StrUtil.isNotBlank(search)) {
query.like(Good::getGoodDescribe, search);
}
return Result.success(goodPage);
}
}
@RestController
@RequestMapping("/alipay")
public class AliPayController {
@Resource
MasterMapper masterMapper;
@GetMapping("/pay")
public String pay(AliPay aliPay) {
AlipayTradePagePayResponse response;
try {
// 发起API调用(以创建当面付收款二维码为例)
response = Factory.Payment.Page()
.pay(aliPay.getSubject(), aliPay.getTraceNo(), aliPay.getTotalAmount(), "");
} catch (Exception e) {
System.err.println("调用遭遇异常,原因:" + e.getMessage());
throw new RuntimeException(e.getMessage(), e);
/**
* <p>
* 评论 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/comment")
public class CommentController {
@Resource
CommentSerivce commentSerivce;
@Resource
CommentMapper commentMapper;
@PostMapping("/add")
public Result<?> save(@Validated @RequestBody Comment comment){
commentSerivce.save(comment);
return Result.success();
}
@PutMapping
public Result<?> update(@Validated @RequestBody Comment comment){
commentSerivce.updateById(comment);
return Result.success();
}
@DeleteMapping("/{commentId}")
public Result<?> delete(@PathVariable Integer commentId){
commentSerivce.removeById(commentId);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
commentSerivce.removeByIds(ids);
}
@GetMapping("/{cid}")
public Result<?> find(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@PathVariable Integer cid){
Page<Info> page = infoMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Info>lambdaQuery().eq(Info::getTwoCategoryId, cid).or().eq(Info::getOneCategoryId,cid));
return Result.success(page);
}
@GetMapping("/{cid}/{bid}")
public Result<?> findBrand(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@PathVariable Integer cid,@PathVariable Integer bid){
Page<Info> page = infoMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Info>lambdaQuery().eq(Info::getTwoCategoryId, cid).eq(Info::getBrandId,bid).or().eq(Info::getOneCategoryId,cid).eq(Info::getBrandId,bid));
return Result.success(page);
}
@GetMapping("/find/{oid}/{tid}")
public Result<?> findId(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@PathVariable Integer oid,@PathVariable Integer tid){
Page<Info> page = infoMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Info>lambdaQuery().eq(Info::getOneCategoryId, oid).eq(Info::getThreeCategoryId,tid));
return Result.success(page);
}
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable("id") Integer id){
infoMapper.deleteById(id);
return Result.success();
}
@GetMapping("/group")
public Result group(){
List<Map<String, Object>> id = infoMapper.selectMaps(Wrappers.<Info>query().select("one_category_id,COUNT(product_name) as num").groupBy("one_category_id"));
return Result.success(id);
}
@GetMapping("/find/{id}")
public Info find(@PathVariable("id") Integer id){
return this.infoMapper.selectById(id);
}
@PutMapping("/update")
public Result<?> update(@RequestBody Info info){
infoMapper.updateById(info);
return Result.success();
}
@PostMapping("/add")
public Result<?> insert(@RequestBody Info info){
infoMapper.insert(info);
return Result.success();
}
@PostMapping("/deleteBatch")
public Result<?> deleteBatch(@RequestBody List<Integer> ids){
infoMapper.deleteBatchIds(ids);
return Result.success(receiptPage);
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/collection")
public class CollectionController {
@Resource
private CollectionMapper collectionMapper;
@GetMapping("/findAll")
public List<Collection> findAll(){
List<Collection> collections = collectionMapper.selectList(null);
return collections;
}
@DeleteMapping("/delete/{id}")
public Result<?> delete(@PathVariable("id") Integer id){
collectionMapper.deleteById(id);
} catch (IOException e1) {
}
return false;
}
/**
* 对跨域提供支持
*/
@Override
protected boolean preHandle(ServletRequest request, ServletResponse response) throws Exception {
HttpServletRequest httpServletRequest = WebUtils.toHttp(request);
HttpServletResponse httpServletResponse = WebUtils.toHttp(response);
httpServletResponse.setHeader("Access-control-Allow-Origin", httpServletRequest.getHeader("Origin"));
httpServletResponse.setHeader("Access-Control-Allow-Methods", "GET,POST,OPTIONS,PUT,DELETE");
httpServletResponse.setHeader("Access-Control-Allow-Headers", httpServletRequest.getHeader("Access-Control-Request-Headers"));
// 跨域时会首先发送一个OPTIONS请求,这里我们给OPTIONS请求直接返回正常状态
if (httpServletRequest.getMethod().equals(RequestMethod.OPTIONS.name())) {
httpServletResponse.setStatus(org.springframework.http.HttpStatus.OK.value());
return false;
}
return super.preHandle(request, response);
}
}
/**
* <p>
* 前端控制器
* </p>
*
*/
@RestController
/**
* <p>
* 分类信息表 前端控制器
* </p>
*
*/
@RestController
@RequestMapping("/productCategory")
public class ProductCategoryController {
@Resource
ProductCategorySerivce productCategorySerivce;
@Resource
ProductCategoryMapper productCategoryMapper;
@GetMapping("/list")
public Result<?> list(){
List<ProductCategoryVO> all = productCategorySerivce.getAllProductCategoryVO();
return Result.success(all);
}
@GetMapping("/{id}")
public Result<?> findId(@PathVariable Integer id){
ProductCategory byId = productCategorySerivce.getById(id);
return Result.success(byId);
}
@GetMapping("/parent/{id}")
public Result findPId(@PathVariable Integer id){
List<ProductCategory> list = productCategorySerivce.list(Wrappers.<ProductCategory>lambdaQuery().eq(ProductCategory::getParentId, id));
return Result.success(list);
}
@PostMapping
public Result<?> save(@RequestBody ProductCategory productCategory){
productCategory.setCreateTime(new Date());
productCategory.setUpdateTime(new Date());
productCategorySerivce.save(productCategory);
return Result.success();
}
@PutMapping
public Result<?> update(@RequestBody ProductCategory productCategory){
productCategorySerivce.updateById(productCategory);
return Result.success();
}
@DeleteMapping("/{categoryId}")
}
return response.getBody();
}
@PostMapping("/notify") // 注意这里必须是POST接口
public String payNotify(HttpServletRequest request) throws Exception {
if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) {
System.out.println("=========支付宝异步回调========");
Map<String, String> params = new HashMap<>();
Map<String, String[]> requestParams = request.getParameterMap();
for (String name : requestParams.keySet()) {
params.put(name, request.getParameter(name));
}
String tradeNo = params.get("out_trade_no");
// 支付宝验签
if (Factory.Payment.Common().verifyNotify(params)) {
// 验签通过
System.out.println("交易名称: " + params.get("subject"));
System.out.println("交易状态: " + params.get("trade_status"));
System.out.println("支付宝交易凭证号: " + params.get("trade_no"));
System.out.println("商户订单号: " + params.get("out_trade_no"));
System.out.println("交易金额: " + params.get("total_amount"));
System.out.println("买家在支付宝唯一id: " + params.get("buyer_id"));
System.out.println("买家付款时间: " + params.get("gmt_payment"));
System.out.println("买家付款金额: " + params.get("buyer_pay_amount"));
// 更新订单未已支付
masterMapper.updateState(tradeNo, 1);
}
}
return "success";
}
}
/**
}
@GetMapping("/page")
public Result<?> findPage(@RequestParam(defaultValue = "1") Integer pageNum,
@RequestParam(defaultValue = "10") Integer pageSize,
@RequestParam(defaultValue = "") String search){
new Page<>(pageNum,pageSize);
Page<Comment> customerInfoPage = commentMapper.selectPage(new Page<>(pageNum, pageSize), Wrappers.<Comment>lambdaQuery().like(Comment::getCustomerName,search));
LambdaQueryWrapper<Comment> query = Wrappers.<Comment>lambdaQuery().orderByDesc(Comment::getCommentId);
if (StrUtil.isNotBlank(search)) {
query.like(Comment::getCustomerName, search);
}
return Result.success(customerInfoPage);
}
}
/**
* <p>
* 用户信息表 前端控制器