Compare commits
26 Commits
5efbc229f8
...
9fc4afebc2
Author | SHA1 | Date |
---|---|---|
|
9fc4afebc2 | |
|
8f3ff6e9a3 | |
|
e0115dbf30 | |
|
50f376d312 | |
|
315659d1f7 | |
|
2b921ce7fd | |
|
580e1155db | |
|
ac36b13ee1 | |
|
1d8ff42dda | |
|
77bd3496d5 | |
|
0affca82f0 | |
|
a8ba62125f | |
|
3d69821e67 | |
|
27105b3220 | |
|
605647283a | |
|
b70fc9ed4e | |
|
943c945cfb | |
|
608f0defaf | |
|
6f9a28d25e | |
|
b950c186fa | |
|
d45eac0623 | |
|
6de6b4d232 | |
|
8dddea3bf5 | |
|
1dd176a1af | |
|
fa58dad04b | |
|
f2bc0a1bfd |
|
@ -2,6 +2,6 @@
|
||||||
.idea
|
.idea
|
||||||
*.iml
|
*.iml
|
||||||
*.class
|
*.class
|
||||||
*Test.java
|
#*Test.java
|
||||||
**/test/
|
#**/test/
|
||||||
logs
|
logs
|
|
@ -38,7 +38,7 @@ public class WebMvcConfiguration extends WebMvcConfigurationSupport {
|
||||||
protected void addInterceptors(InterceptorRegistry registry) {
|
protected void addInterceptors(InterceptorRegistry registry) {
|
||||||
log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
log.info("WebMvcConfiguration===>开始注册自定义拦截器...");
|
||||||
// 需要拦截的
|
// 需要拦截的
|
||||||
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/**")
|
registry.addInterceptor(loginAuthInterceptor).addPathPatterns("/admin/**")
|
||||||
.excludePathPatterns(interceptorsProperties.getNoAuthUrls());
|
.excludePathPatterns(interceptorsProperties.getNoAuthUrls());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -20,4 +20,7 @@ public class MessageConstant {
|
||||||
public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
|
public static final String UPDATE_ID_IS_NOT_EMPTY = "删除id不能为空";
|
||||||
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
public static final String DELETE_ID_IS_NOT_EMPTY = "修改id不能为空";
|
||||||
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
public static final String MENU_IS_NOT_EXIST = "菜单不存在";
|
||||||
|
public static final String SAVE_DTO_IS_NULL = "添加参数不能为空";
|
||||||
|
public static final String UPDATE_DTO_IS_NULL = "修改参数不能为空";
|
||||||
|
public static final String FIND_ID_IS_NOT_EMPTY = "查询ID不能为空";
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,8 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Tag(name = "品牌管理")
|
@Tag(name = "品牌管理")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/admin/product/brand")
|
@RequestMapping(value = "/admin/product/brand")
|
||||||
|
@ -43,4 +45,11 @@ public class BrandController {
|
||||||
brandService.deleteById(id);
|
brandService.deleteById(id);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "品牌列表", description = "品牌列表接口")
|
||||||
|
@GetMapping("findAll")
|
||||||
|
public Result<List<Brand>> findAll() {
|
||||||
|
List<Brand> list = brandService.findAll();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||||
|
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
@Tag(name = "分类品牌")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/categoryBrand")
|
||||||
|
public class CategoryBrandController {
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandService categoryBrandService;
|
||||||
|
|
||||||
|
@Operation(summary = "分类品牌列表", description = "分类品牌列表接口")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<PageInfo<CategoryBrand>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, CategoryBrandDto dto) {
|
||||||
|
PageInfo<CategoryBrand> pageInfo = categoryBrandService.findByPage(page, limit, dto);
|
||||||
|
return Result.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加功能", description = "添加功能")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<CategoryBrand> save(@RequestBody CategoryBrand categoryBrand) {
|
||||||
|
categoryBrandService.save(categoryBrand);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改功能", description = "修改功能")
|
||||||
|
@PutMapping("updateById")
|
||||||
|
public Result<CategoryBrand> updateById(@RequestBody CategoryBrand categoryBrand) {
|
||||||
|
categoryBrandService.updateById(categoryBrand);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除功能", description = "删除功能")
|
||||||
|
@DeleteMapping("deleteById/{id}")
|
||||||
|
public Result<Long> deleteById(@PathVariable Long id) {
|
||||||
|
categoryBrandService.deleteById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,7 +3,6 @@ package com.atguigu.spzx.manger.controller;
|
||||||
import com.atguigu.spzx.manger.service.CategoryService;
|
import com.atguigu.spzx.manger.service.CategoryService;
|
||||||
import com.atguigu.spzx.model.entity.product.Category;
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
import com.atguigu.spzx.model.vo.result.Result;
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
@ -21,21 +20,21 @@ public class CategoryController {
|
||||||
private CategoryService categoryService;
|
private CategoryService categoryService;
|
||||||
|
|
||||||
@Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点")
|
@Operation(summary = "根据parentId获取下级节点", description = "根据parentId获取下级节点")
|
||||||
@GetMapping(value = "findByParentId/{parentId}")
|
@GetMapping(value = "findCategoryList/{parentId}")
|
||||||
public Result<List<Category>> findByParentId(@PathVariable Long parentId) {
|
public Result<List<Category>> findByParentId(@PathVariable Long parentId) {
|
||||||
List<Category> list = categoryService.findByParentId(parentId);
|
List<Category> list = categoryService.findByParentId(parentId);
|
||||||
return Result.success(list);
|
return Result.success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "导出数据",description = "导出数据")
|
@Operation(summary = "导出数据", description = "导出数据")
|
||||||
@GetMapping(value = "/exportData")
|
@GetMapping(value = "/exportData")
|
||||||
public void exportData(HttpServletResponse response) {
|
public void exportData(HttpServletResponse response) {
|
||||||
categoryService.exportData(response);
|
categoryService.exportData(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "导入功能",description = "导入功能")
|
@Operation(summary = "导入功能", description = "导入功能")
|
||||||
@PostMapping("importData")
|
@PostMapping("importData")
|
||||||
public Result<String > importData(MultipartFile file) {
|
public Result<String> importData(MultipartFile file) {
|
||||||
categoryService.importData(file);
|
categoryService.importData(file);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.OrderInfoService;
|
||||||
|
import com.atguigu.spzx.model.dto.order.OrderStatisticsDto;
|
||||||
|
import com.atguigu.spzx.model.vo.order.OrderStatisticsVo;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
@Tag(name = "统计查询")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/order/orderInfo")
|
||||||
|
public class OrderInfoController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderInfoService orderInfoService;
|
||||||
|
|
||||||
|
@Operation(summary = "统计查询", description = "统计查询")
|
||||||
|
@GetMapping("/getOrderStatisticsData")
|
||||||
|
public Result<OrderStatisticsVo> getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto) {
|
||||||
|
OrderStatisticsVo orderStatisticsVo = orderInfoService.getOrderStatisticsData(orderStatisticsDto);
|
||||||
|
return Result.build(orderStatisticsVo, ResultCodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,83 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||||
|
import com.atguigu.spzx.manger.service.ProductService;
|
||||||
|
import com.atguigu.spzx.model.dto.product.ProductDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Product;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.Parameter;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "商品管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/product")
|
||||||
|
public class ProductController {
|
||||||
|
@Autowired
|
||||||
|
private ProductService productService;
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandService categoryBrandService;
|
||||||
|
|
||||||
|
@Operation(summary = "列表查询", description = "列表查询")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<PageInfo<Product>> findByPage(@PathVariable Integer page, @PathVariable Integer limit, ProductDto dto) {
|
||||||
|
PageInfo<Product> pageInfo = productService.findByPage(page, limit, dto);
|
||||||
|
return Result.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加功能", description = "添加功能")
|
||||||
|
@GetMapping("findBrandByCategoryId/{categoryId}")
|
||||||
|
public Result<List<Brand>> findBrandByCategoryId(@PathVariable Long categoryId) {
|
||||||
|
List<Brand> brandList = categoryBrandService.findBrandByCategoryId(categoryId);
|
||||||
|
return Result.success(brandList);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "保存商品数据接口", description = "保存商品数据接口")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<Product> save(@RequestBody Product product) {
|
||||||
|
productService.save(product);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询商品详情", description = "查询商品详情")
|
||||||
|
@GetMapping("getById/{id}")
|
||||||
|
public Result<Product> getById(@PathVariable Long id) {
|
||||||
|
Product product = productService.getById(id);
|
||||||
|
return Result.success(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "保存修改数据接口", description = "保存修改数据接口")
|
||||||
|
@PutMapping("updateById")
|
||||||
|
public Result<Product> updateById(@Parameter(name = "product", description = "请求参数实体类", required = true) @RequestBody Product product) {
|
||||||
|
productService.updateById(product);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除商品", description = "删除商品")
|
||||||
|
@DeleteMapping("/deleteById/{id}")
|
||||||
|
public Result<Long> deleteById(@Parameter(name = "id", description = "商品id", required = true) @PathVariable Long id) {
|
||||||
|
productService.deleteById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "商品审核", description = "商品审核")
|
||||||
|
@GetMapping("/updateAuditStatus/{id}/{auditStatus}")
|
||||||
|
public Result<Product> updateAuditStatus(@PathVariable Long id, @PathVariable Integer auditStatus) {
|
||||||
|
productService.updateAuditStatus(id, auditStatus);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "商品上下架", description = "商品上下架")
|
||||||
|
@GetMapping("/updateStatus/{id}/{status}")
|
||||||
|
public Result updateStatus(@PathVariable Long id, @PathVariable Integer status) {
|
||||||
|
productService.updateStatus(id, status);
|
||||||
|
return Result.build(null, ResultCodeEnum.SUCCESS);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.ProductSpecService;
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "商品规格管理")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/admin/product/productSpec")
|
||||||
|
public class ProductSpecController {
|
||||||
|
@Autowired
|
||||||
|
private ProductSpecService productSpecService;
|
||||||
|
|
||||||
|
@Operation(summary = "列表查询", description = "列表查询")
|
||||||
|
@GetMapping("{page}/{limit}")
|
||||||
|
public Result<PageInfo<ProductSpec>> findByPage(@PathVariable Integer page, @PathVariable Integer limit) {
|
||||||
|
PageInfo<ProductSpec> pageInfo = productSpecService.findByPage(page, limit);
|
||||||
|
return Result.success(pageInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "添加功能", description = "添加功能")
|
||||||
|
@PostMapping("save")
|
||||||
|
public Result<ProductSpec> save(@RequestBody ProductSpec productSpec) {
|
||||||
|
productSpecService.save(productSpec);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "修改功能", description = "修改功能")
|
||||||
|
@PutMapping("updateById")
|
||||||
|
public Result<ProductSpec> updateById(@RequestBody ProductSpec productSpec) {
|
||||||
|
productSpecService.updateById(productSpec);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除功能", description = "删除功能")
|
||||||
|
@DeleteMapping("deleteById/{id}")
|
||||||
|
public Result<Long> removeById(@PathVariable Long id) {
|
||||||
|
productSpecService.deleteById(id);
|
||||||
|
return Result.success();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "加载商品规格数据", description = "加载商品规格数据")
|
||||||
|
@GetMapping("findAll")
|
||||||
|
public Result<List<ProductSpec>> findAll() {
|
||||||
|
List<ProductSpec> list = productSpecService.findAll();
|
||||||
|
return Result.success(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.atguigu.spzx.manger.controller;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.service.ProductUnitService;
|
||||||
|
import com.atguigu.spzx.model.entity.base.ProductUnit;
|
||||||
|
import com.atguigu.spzx.model.vo.result.Result;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Tag(name = "品牌数据")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/admin/product/productUnit")
|
||||||
|
public class ProductUnitController {
|
||||||
|
@Autowired
|
||||||
|
private ProductUnitService productUnitService;
|
||||||
|
|
||||||
|
@Operation(summary = "加载商品单元数据", description = "加载商品单元数据")
|
||||||
|
@GetMapping("findAll")
|
||||||
|
public Result<List<ProductUnit>> findAll() {
|
||||||
|
List<ProductUnit> productUnitList = productUnitService.findAll();
|
||||||
|
return Result.success(productUnitList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -29,7 +29,7 @@ public class SysRoleController {
|
||||||
|
|
||||||
@Operation(summary = "添加角色", description = "添加角色相关内容")
|
@Operation(summary = "添加角色", description = "添加角色相关内容")
|
||||||
@PostMapping(value = "saveSysRole")
|
@PostMapping(value = "saveSysRole")
|
||||||
public Result saveSysRole(@RequestBody SysRole sysRole) {
|
public Result<SysRole> saveSysRole(@RequestBody SysRole sysRole) {
|
||||||
sysRoleService.saveSysRole(sysRole);
|
sysRoleService.saveSysRole(sysRole);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ public class SysRoleMenuController {
|
||||||
|
|
||||||
@Operation(summary = "保存菜单", description = "保存菜单")
|
@Operation(summary = "保存菜单", description = "保存菜单")
|
||||||
@PostMapping("doAssign")
|
@PostMapping("doAssign")
|
||||||
public Result doAssign(@RequestBody AssginMenuDto assginMenuDto) {
|
public Result<AssginMenuDto> doAssign(@RequestBody AssginMenuDto assginMenuDto) {
|
||||||
sysRoleMenuService.doAssign(assginMenuDto);
|
sysRoleMenuService.doAssign(assginMenuDto);
|
||||||
return Result.success();
|
return Result.success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.atguigu.spzx.manger.excel;
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import com.alibaba.excel.util.ListUtils;
|
||||||
|
import com.atguigu.spzx.manger.mapper.CategoryMapper;
|
||||||
|
import com.atguigu.spzx.model.vo.product.CategoryExcelVo;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class CategoryExcelListener<T> extends AnalysisEventListener<T> {
|
||||||
|
// 每个5条存储数据库,方便垃圾回收
|
||||||
|
private static final int BATCH_COUNT = 100;
|
||||||
|
// 缓存的数据
|
||||||
|
private final List<CategoryExcelVo> cachedDataList = ListUtils.newArrayListWithExpectedSize(BATCH_COUNT);
|
||||||
|
// 获取mapper对象
|
||||||
|
private final CategoryMapper categoryMapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void invoke(T t, AnalysisContext analysisContext) {
|
||||||
|
CategoryExcelVo data = (CategoryExcelVo) t;
|
||||||
|
cachedDataList.add(data);
|
||||||
|
if (cachedDataList.size() >= BATCH_COUNT) {
|
||||||
|
saveData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
// excel解析完毕以后需要执行的代码
|
||||||
|
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
||||||
|
saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 写入数据库
|
||||||
|
*/
|
||||||
|
private void saveData() {
|
||||||
|
categoryMapper.batchInsert(cachedDataList);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package com.atguigu.spzx.manger.excel;
|
||||||
|
|
||||||
|
import com.alibaba.excel.context.AnalysisContext;
|
||||||
|
import com.alibaba.excel.event.AnalysisEventListener;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@Data
|
||||||
|
public class ExcelListener<T> extends AnalysisEventListener<T> {
|
||||||
|
// 可以通过实例获取该值
|
||||||
|
private final List<T> dataList = new ArrayList<T>();
|
||||||
|
|
||||||
|
// 每解析一行数据就会调用一次该方法
|
||||||
|
@Override
|
||||||
|
|
||||||
|
public void invoke(T t, AnalysisContext analysisContext) {
|
||||||
|
// 数据存储到list,供批量处理,或后续自己业务逻辑处理。
|
||||||
|
dataList.add(t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||||
|
// excel解析完毕以后需要执行的代码
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,11 @@
|
||||||
package com.atguigu.spzx.manger.mapper;
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
import com.atguigu.spzx.model.entity.product.Brand;
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
public interface BrandMapper {
|
public interface BrandMapper {
|
||||||
/**
|
/**
|
||||||
* 查找分页品牌
|
* 查找分页品牌
|
||||||
|
@ -32,4 +34,11 @@ public interface BrandMapper {
|
||||||
* @param id 品牌id
|
* @param id 品牌id
|
||||||
*/
|
*/
|
||||||
void deleteById(Long id);
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌列表
|
||||||
|
*
|
||||||
|
* @return 品牌列表
|
||||||
|
*/
|
||||||
|
List<Brand> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface CategoryBrandMapper {
|
||||||
|
/**
|
||||||
|
* 分类品牌列表
|
||||||
|
*
|
||||||
|
* @param dto 搜索条件实体类
|
||||||
|
* @return PageInfo<CategoryBrand>
|
||||||
|
*/
|
||||||
|
List<CategoryBrand> findByPage(CategoryBrandDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
void save(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
void updateById(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryId 查询ID
|
||||||
|
* @return List<Brand>
|
||||||
|
*/
|
||||||
|
List<Brand> findBrandByCategoryId(Long categoryId);
|
||||||
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atguigu.spzx.manger.mapper;
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
import com.atguigu.spzx.model.entity.product.Category;
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
|
import com.atguigu.spzx.model.vo.product.CategoryExcelVo;
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -22,4 +23,18 @@ public interface CategoryMapper {
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
int countByParentId(Long id);
|
int countByParentId(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读取所以分类数据
|
||||||
|
*
|
||||||
|
* @return 分类实体类列表
|
||||||
|
*/
|
||||||
|
List<Category> selectAll();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量插入数据库
|
||||||
|
*
|
||||||
|
* @param cachedDataList Excel表品牌管理实体类
|
||||||
|
*/
|
||||||
|
void batchInsert(List<CategoryExcelVo> cachedDataList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.order.OrderStatistics;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface OrderInfoMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询指定日期产生的订单数据
|
||||||
|
*
|
||||||
|
* @param createTime 创建时间
|
||||||
|
* @return OrderStatistics
|
||||||
|
*/
|
||||||
|
OrderStatistics selectOrderStatistics(String createTime);
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.order.OrderStatisticsDto;
|
||||||
|
import com.atguigu.spzx.model.entity.order.OrderStatistics;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface OrderStatisticsMapper {
|
||||||
|
/**
|
||||||
|
* 插入
|
||||||
|
*
|
||||||
|
* @param orderStatistics 订单
|
||||||
|
*/
|
||||||
|
void insert(OrderStatistics orderStatistics);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询统计结果数据
|
||||||
|
*
|
||||||
|
* @param orderStatisticsDto 搜索条件实体类
|
||||||
|
* @return 搜索条件实体类列表
|
||||||
|
*/
|
||||||
|
List<OrderStatistics> selectList(OrderStatisticsDto orderStatisticsDto);
|
||||||
|
}
|
|
@ -0,0 +1,36 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductDetails;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductDetailsMapper {
|
||||||
|
/**
|
||||||
|
* 保存数据
|
||||||
|
*
|
||||||
|
* @param productDetails 商品实体类
|
||||||
|
*/
|
||||||
|
void save(ProductDetails productDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品的id查询商品详情数据
|
||||||
|
*
|
||||||
|
* @param id 查询的ID
|
||||||
|
* @return ProductDetails
|
||||||
|
*/
|
||||||
|
ProductDetails selectByProductId(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品的详情数据
|
||||||
|
*
|
||||||
|
* @param productDetails ProductDetails
|
||||||
|
*/
|
||||||
|
void updateById(ProductDetails productDetails);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品的id删除商品的详情数据
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
void deleteByProductId(Long id);
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.product.ProductDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Product;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductMapper {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @return 查询结果
|
||||||
|
*/
|
||||||
|
List<Product> findByPage(ProductDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存商品数据
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
void save(Product product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id查询商品数据
|
||||||
|
*
|
||||||
|
* @param id 查询的ID
|
||||||
|
* @return 商品实体类
|
||||||
|
*/
|
||||||
|
Product selectById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品基本数据
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
void updateById(Product product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据id删除商品基本数据
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
}
|
|
@ -0,0 +1,38 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductSkuMapper {
|
||||||
|
/**
|
||||||
|
* 保存数据
|
||||||
|
*
|
||||||
|
* @param productSku 商品实体类
|
||||||
|
*/
|
||||||
|
void save(ProductSku productSku);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品的id查询sku数据
|
||||||
|
*
|
||||||
|
* @param id 查询的ID
|
||||||
|
* @return 商品实体类列表
|
||||||
|
*/
|
||||||
|
List<ProductSku> selectByProductId(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改商品的sku数据
|
||||||
|
*
|
||||||
|
* @param productSku 商品实体类
|
||||||
|
*/
|
||||||
|
void updateById(ProductSku productSku);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据商品id删除商品的sku数据
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
void deleteByProductId(Long id);
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductSpecMapper {
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
List<ProductSpec> findByPage();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void save(ProductSpec productSpec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void updateById(ProductSpec productSpec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 要删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载商品规格数据
|
||||||
|
*
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
List<ProductSpec> findAll();
|
||||||
|
}
|
|
@ -0,0 +1,16 @@
|
||||||
|
package com.atguigu.spzx.manger.mapper;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.base.ProductUnit;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Mapper
|
||||||
|
public interface ProductUnitMapper {
|
||||||
|
/**
|
||||||
|
* 加载商品单元数据
|
||||||
|
*
|
||||||
|
* @return 产品单元实体类列表
|
||||||
|
*/
|
||||||
|
List<ProductUnit> findAll();
|
||||||
|
}
|
|
@ -3,6 +3,8 @@ package com.atguigu.spzx.manger.service;
|
||||||
import com.atguigu.spzx.model.entity.product.Brand;
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
import com.github.pagehelper.PageInfo;
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface BrandService {
|
public interface BrandService {
|
||||||
/**
|
/**
|
||||||
* 品牌列表查询
|
* 品牌列表查询
|
||||||
|
@ -33,4 +35,11 @@ public interface BrandService {
|
||||||
* @param id 品牌id
|
* @param id 品牌id
|
||||||
*/
|
*/
|
||||||
void deleteById(Long id);
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌列表
|
||||||
|
*
|
||||||
|
* @return 品牌列表
|
||||||
|
*/
|
||||||
|
List<Brand> findAll();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,49 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface CategoryBrandService {
|
||||||
|
/**
|
||||||
|
* 分类品牌列表
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @param dto 搜索条件实体类
|
||||||
|
* @return PageInfo<CategoryBrand>
|
||||||
|
*/
|
||||||
|
PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
void save(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
void updateById(CategoryBrand categoryBrand);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryId 查询ID
|
||||||
|
* @return List<Brand>
|
||||||
|
*/
|
||||||
|
List<Brand> findBrandByCategoryId(Long categoryId);
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.order.OrderStatisticsDto;
|
||||||
|
import com.atguigu.spzx.model.vo.order.OrderStatisticsVo;
|
||||||
|
|
||||||
|
public interface OrderInfoService {
|
||||||
|
/**
|
||||||
|
* 统计查询
|
||||||
|
*
|
||||||
|
* @param orderStatisticsDto 搜索条件实体类
|
||||||
|
* @return 统计结果实体类
|
||||||
|
*/
|
||||||
|
OrderStatisticsVo getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto);
|
||||||
|
}
|
|
@ -0,0 +1,62 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.dto.product.ProductDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Product;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
public interface ProductService {
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前也
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageInfo<Product> findByPage(Integer page, Integer limit, ProductDto dto);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存商品数据接口
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
void save(Product product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询商品详情
|
||||||
|
*
|
||||||
|
* @param id 查询ID
|
||||||
|
* @return 商品实体类
|
||||||
|
*/
|
||||||
|
Product getById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存修改数据接口
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
void updateById(Product product);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品审核
|
||||||
|
*
|
||||||
|
* @param id 审核ID
|
||||||
|
* @param auditStatus 审核状态
|
||||||
|
*/
|
||||||
|
void updateAuditStatus(Long id, Integer auditStatus);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品上下架
|
||||||
|
*
|
||||||
|
* @param id 上下架ID
|
||||||
|
* @param status 上下架状态
|
||||||
|
*/
|
||||||
|
void updateStatus(Long id, Integer status);
|
||||||
|
}
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProductSpecService {
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
PageInfo<ProductSpec> findByPage(Integer page, Integer limit);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void save(ProductSpec productSpec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
void updateById(ProductSpec productSpec);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 要删除的ID
|
||||||
|
*/
|
||||||
|
void deleteById(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载商品规格数据
|
||||||
|
*
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
List<ProductSpec> findAll();
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
package com.atguigu.spzx.manger.service;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.model.entity.base.ProductUnit;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public interface ProductUnitService {
|
||||||
|
/**
|
||||||
|
* 加载商品单元数据
|
||||||
|
*
|
||||||
|
* @return 产品单元实体类列表
|
||||||
|
*/
|
||||||
|
List<ProductUnit> findAll();
|
||||||
|
}
|
|
@ -68,4 +68,14 @@ public class BrandServiceImpl implements BrandService {
|
||||||
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
|
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
|
||||||
brandMapper.deleteById(id);
|
brandMapper.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌列表
|
||||||
|
*
|
||||||
|
* @return 品牌列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Brand> findAll() {
|
||||||
|
return brandMapper.findAll();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,92 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.constant.MessageConstant;
|
||||||
|
import com.atguigu.exception.BunnyException;
|
||||||
|
import com.atguigu.spzx.manger.mapper.CategoryBrandMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.CategoryBrandService;
|
||||||
|
import com.atguigu.spzx.model.dto.product.CategoryBrandDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Brand;
|
||||||
|
import com.atguigu.spzx.model.entity.product.CategoryBrand;
|
||||||
|
import com.atguigu.utils.StringEmptyUtil;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class CategoryBrandServiceImpl implements CategoryBrandService {
|
||||||
|
@Autowired
|
||||||
|
private CategoryBrandMapper categoryBrandMapper;
|
||||||
|
@Autowired
|
||||||
|
private StringEmptyUtil emptyUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 分类品牌列表
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @param dto 搜索条件实体类
|
||||||
|
* @return PageInfo<CategoryBrand>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageInfo<CategoryBrand> findByPage(Integer page, Integer limit, CategoryBrandDto dto) {
|
||||||
|
Page<Object> startPage = PageHelper.startPage(page, limit);
|
||||||
|
List<CategoryBrand> categoryBrandList = categoryBrandMapper.findByPage(dto);
|
||||||
|
|
||||||
|
// 关闭资源
|
||||||
|
startPage.close();
|
||||||
|
return new PageInfo<>(categoryBrandList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(CategoryBrand categoryBrand) {
|
||||||
|
if (categoryBrand == null) {
|
||||||
|
throw new BunnyException(MessageConstant.SAVE_DTO_IS_NULL);
|
||||||
|
}
|
||||||
|
categoryBrandMapper.save(categoryBrand);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param categoryBrand 分类品牌实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateById(CategoryBrand categoryBrand) {
|
||||||
|
if (categoryBrand == null) {
|
||||||
|
throw new BunnyException(MessageConstant.UPDATE_DTO_IS_NULL);
|
||||||
|
}
|
||||||
|
categoryBrandMapper.updateById(categoryBrand);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 删除的ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
emptyUtil.isEmpty(id, MessageConstant.DELETE_ID_IS_NOT_EMPTY);
|
||||||
|
categoryBrandMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param categoryId 查询ID
|
||||||
|
* @return List<Brand>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<Brand> findBrandByCategoryId(Long categoryId) {
|
||||||
|
emptyUtil.isEmpty(categoryId, MessageConstant.FIND_ID_IS_NOT_EMPTY);
|
||||||
|
return categoryBrandMapper.findBrandByCategoryId(categoryId);
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,11 +1,15 @@
|
||||||
package com.atguigu.spzx.manger.service.impl;
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.atguigu.exception.BunnyException;
|
||||||
|
import com.atguigu.spzx.manger.excel.CategoryExcelListener;
|
||||||
import com.atguigu.spzx.manger.mapper.CategoryMapper;
|
import com.atguigu.spzx.manger.mapper.CategoryMapper;
|
||||||
import com.atguigu.spzx.manger.service.CategoryService;
|
import com.atguigu.spzx.manger.service.CategoryService;
|
||||||
import com.atguigu.spzx.model.entity.product.Category;
|
import com.atguigu.spzx.model.entity.product.Category;
|
||||||
import com.atguigu.spzx.model.vo.product.CategoryExcelVo;
|
import com.atguigu.spzx.model.vo.product.CategoryExcelVo;
|
||||||
|
import com.atguigu.spzx.model.vo.result.ResultCodeEnum;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.BeanUtils;
|
import org.springframework.beans.BeanUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
@ -19,6 +23,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
|
@Slf4j
|
||||||
public class CategoryServiceImpl implements CategoryService {
|
public class CategoryServiceImpl implements CategoryService {
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryMapper categoryMapper;
|
private CategoryMapper categoryMapper;
|
||||||
|
@ -50,7 +55,29 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void exportData(HttpServletResponse response) {
|
public void exportData(HttpServletResponse response) {
|
||||||
// TODO 导出数据
|
// 设置响应结果类型
|
||||||
|
response.setContentType("application/vnd.ms-excel");
|
||||||
|
response.setCharacterEncoding("utf-8");
|
||||||
|
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
|
||||||
|
String filename = URLEncoder.encode("分类数据", StandardCharsets.UTF_8);
|
||||||
|
response.setHeader("Content-disposition", "attachment;filename=" + filename + ".xlsx");
|
||||||
|
// 查询数据库中的数据
|
||||||
|
List<Category> categoryList = categoryMapper.selectAll();
|
||||||
|
ArrayList<CategoryExcelVo> excelVoArrayList = new ArrayList<>();
|
||||||
|
// 将从数据库中查询到的Category对象转换成CategoryExcelVo对象
|
||||||
|
categoryList.forEach(category -> {
|
||||||
|
CategoryExcelVo vo = new CategoryExcelVo();
|
||||||
|
BeanUtils.copyProperties(category, vo, CategoryExcelVo.class);
|
||||||
|
excelVoArrayList.add(vo);
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 写出数据到浏览器端
|
||||||
|
EasyExcel.write(response.getOutputStream(), CategoryExcelVo.class).sheet("分类数据").doWrite(excelVoArrayList);
|
||||||
|
} catch (IOException exception) {
|
||||||
|
log.error("文件写入失败:{}", exception.getMessage());
|
||||||
|
throw new BunnyException(ResultCodeEnum.WRITE_FILE_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,6 +87,13 @@ public class CategoryServiceImpl implements CategoryService {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void importData(MultipartFile file) {
|
public void importData(MultipartFile file) {
|
||||||
// TODO 导入功能
|
// 创建监听器对象,传递mapper对象
|
||||||
|
CategoryExcelListener<CategoryExcelVo> listener = new CategoryExcelListener<>(categoryMapper);
|
||||||
|
// 调用read方法读取excel数据
|
||||||
|
try {
|
||||||
|
EasyExcel.read(file.getInputStream(), CategoryExcelVo.class, listener).sheet().doRead();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new BunnyException(ResultCodeEnum.DATA_ERROR);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.atguigu.spzx.manger.mapper.OrderStatisticsMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.OrderInfoService;
|
||||||
|
import com.atguigu.spzx.model.dto.order.OrderStatisticsDto;
|
||||||
|
import com.atguigu.spzx.model.entity.order.OrderStatistics;
|
||||||
|
import com.atguigu.spzx.model.vo.order.OrderStatisticsVo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class OrderInfoServiceImpl implements OrderInfoService {
|
||||||
|
@Autowired
|
||||||
|
private OrderStatisticsMapper orderStatisticsMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 统计查询
|
||||||
|
*
|
||||||
|
* @param orderStatisticsDto 搜索条件实体类
|
||||||
|
* @return 统计结果实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public OrderStatisticsVo getOrderStatisticsData(OrderStatisticsDto orderStatisticsDto) {
|
||||||
|
// 查询统计结果数据
|
||||||
|
List<OrderStatistics> orderStatisticsList = orderStatisticsMapper.selectList(orderStatisticsDto);
|
||||||
|
|
||||||
|
// 日期列表
|
||||||
|
List<String> dateList = orderStatisticsList.stream().map(orderStatistics -> DateUtil.format(orderStatistics.getOrderDate(), "yyyy-MM-dd")).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 统计金额列表
|
||||||
|
List<BigDecimal> amountList = orderStatisticsList.stream().map(OrderStatistics::getTotalAmount).collect(Collectors.toList());
|
||||||
|
|
||||||
|
// 创建OrderStatisticsVo对象封装响应结果数据
|
||||||
|
OrderStatisticsVo orderStatisticsVo = new OrderStatisticsVo();
|
||||||
|
orderStatisticsVo.setDateList(dateList);
|
||||||
|
orderStatisticsVo.setAmountList(amountList);
|
||||||
|
|
||||||
|
// 返回数据
|
||||||
|
return orderStatisticsVo;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,175 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.mapper.ProductDetailsMapper;
|
||||||
|
import com.atguigu.spzx.manger.mapper.ProductMapper;
|
||||||
|
import com.atguigu.spzx.manger.mapper.ProductSkuMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.ProductService;
|
||||||
|
import com.atguigu.spzx.model.dto.product.ProductDto;
|
||||||
|
import com.atguigu.spzx.model.entity.product.Product;
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductDetails;
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSku;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProductServiceImpl implements ProductService {
|
||||||
|
@Autowired
|
||||||
|
private ProductMapper productMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProductDetailsMapper productDetailsMapper;
|
||||||
|
@Autowired
|
||||||
|
private ProductSkuMapper productSkuMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前也
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @param dto 商品实体类
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageInfo<Product> findByPage(Integer page, Integer limit, ProductDto dto) {
|
||||||
|
Page<Object> startPage = PageHelper.startPage(page, limit);
|
||||||
|
|
||||||
|
List<Product> productList = productMapper.findByPage(dto);
|
||||||
|
startPage.close();
|
||||||
|
return new PageInfo<>(productList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存商品数据接口
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@Override
|
||||||
|
public void save(Product product) {
|
||||||
|
// 保存商品数据
|
||||||
|
product.setStatus(0); // 设置上架状态为0
|
||||||
|
product.setAuditStatus(0); // 设置审核状态为0
|
||||||
|
productMapper.save(product);
|
||||||
|
|
||||||
|
// 保存商品sku数据
|
||||||
|
List<ProductSku> productSkuList = product.getProductSkuList();
|
||||||
|
for (int i = 0, size = productSkuList.size(); i < size; i++) {
|
||||||
|
|
||||||
|
// 获取ProductSku对象
|
||||||
|
ProductSku productSku = productSkuList.get(i);
|
||||||
|
productSku.setSkuCode(product.getId() + "_" + i); // 构建skuCode
|
||||||
|
|
||||||
|
productSku.setProductId(product.getId()); // 设置商品id
|
||||||
|
productSku.setSkuName(product.getName() + productSku.getSkuSpec());
|
||||||
|
productSku.setSaleNum(0); // 设置销量
|
||||||
|
productSku.setStatus(0);
|
||||||
|
productSkuMapper.save(productSku); // 保存数据
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存商品详情数据
|
||||||
|
ProductDetails productDetails = new ProductDetails();
|
||||||
|
productDetails.setProductId(product.getId());
|
||||||
|
productDetails.setImageUrls(product.getDetailsImageUrls());
|
||||||
|
productDetailsMapper.save(productDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询商品详情
|
||||||
|
*
|
||||||
|
* @param id 查询ID
|
||||||
|
* @return 商品实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public Product getById(Long id) {
|
||||||
|
// 根据id查询商品数据
|
||||||
|
Product product = productMapper.selectById(id);
|
||||||
|
// 根据商品的id查询sku数据
|
||||||
|
List<ProductSku> productSkuList = productSkuMapper.selectByProductId(id);
|
||||||
|
product.setProductSkuList(productSkuList);
|
||||||
|
|
||||||
|
// 根据商品的id查询商品详情数据
|
||||||
|
ProductDetails productDetails = productDetailsMapper.selectByProductId(product.getId());
|
||||||
|
product.setDetailsImageUrls(productDetails.getImageUrls());
|
||||||
|
|
||||||
|
// 返回数据
|
||||||
|
return product;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存修改数据接口
|
||||||
|
*
|
||||||
|
* @param product 商品实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateById(Product product) {
|
||||||
|
// 修改商品基本数据
|
||||||
|
productMapper.updateById(product);
|
||||||
|
|
||||||
|
// 修改商品的sku数据
|
||||||
|
List<ProductSku> productSkuList = product.getProductSkuList();
|
||||||
|
productSkuList.forEach(productSku -> {
|
||||||
|
productSkuMapper.updateById(productSku);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 修改商品的详情数据
|
||||||
|
ProductDetails productDetails = productDetailsMapper.selectByProductId(product.getId());
|
||||||
|
productDetails.setImageUrls(product.getDetailsImageUrls());
|
||||||
|
productDetailsMapper.updateById(productDetails);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除商品
|
||||||
|
*
|
||||||
|
* @param id 删除ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
productMapper.deleteById(id); // 根据id删除商品基本数据
|
||||||
|
productSkuMapper.deleteByProductId(id); // 根据商品id删除商品的sku数据
|
||||||
|
productDetailsMapper.deleteByProductId(id); // 根据商品的id删除商品的详情数据
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品审核
|
||||||
|
*
|
||||||
|
* @param id 审核ID
|
||||||
|
* @param auditStatus 审核状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateAuditStatus(Long id, Integer auditStatus) {
|
||||||
|
Product product = new Product();
|
||||||
|
product.setId(id);
|
||||||
|
if (auditStatus == 1) {
|
||||||
|
product.setAuditStatus(1);
|
||||||
|
product.setAuditMessage("审批通过");
|
||||||
|
} else {
|
||||||
|
product.setAuditStatus(-1);
|
||||||
|
product.setAuditMessage("审批不通过");
|
||||||
|
}
|
||||||
|
productMapper.updateById(product);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品上下架
|
||||||
|
*
|
||||||
|
* @param id 上下架ID
|
||||||
|
* @param status 上下架状态
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateStatus(Long id, Integer status) {
|
||||||
|
Product product = new Product();
|
||||||
|
product.setId(id);
|
||||||
|
if (status == 1) {
|
||||||
|
product.setStatus(1);
|
||||||
|
} else {
|
||||||
|
product.setStatus(-1);
|
||||||
|
}
|
||||||
|
productMapper.updateById(product);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,88 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.constant.MessageConstant;
|
||||||
|
import com.atguigu.exception.BunnyException;
|
||||||
|
import com.atguigu.spzx.manger.mapper.ProductSpecMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.ProductSpecService;
|
||||||
|
import com.atguigu.spzx.model.entity.product.ProductSpec;
|
||||||
|
import com.atguigu.utils.StringEmptyUtil;
|
||||||
|
import com.github.pagehelper.Page;
|
||||||
|
import com.github.pagehelper.PageHelper;
|
||||||
|
import com.github.pagehelper.PageInfo;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProductSpecServiceImpl implements ProductSpecService {
|
||||||
|
@Autowired
|
||||||
|
private ProductSpecMapper productSpecMapper;
|
||||||
|
@Autowired
|
||||||
|
private StringEmptyUtil emptyUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 列表查询
|
||||||
|
*
|
||||||
|
* @param page 当前页
|
||||||
|
* @param limit 每页限制
|
||||||
|
* @return 分页结果
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PageInfo<ProductSpec> findByPage(Integer page, Integer limit) {
|
||||||
|
Page<Object> startPage = PageHelper.startPage(page, limit);
|
||||||
|
List<ProductSpec> productSpecList = productSpecMapper.findByPage();
|
||||||
|
|
||||||
|
startPage.close();
|
||||||
|
return new PageInfo<>(productSpecList);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void save(ProductSpec productSpec) {
|
||||||
|
if (productSpec == null) {
|
||||||
|
throw new BunnyException(MessageConstant.SAVE_DTO_IS_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
productSpecMapper.save(productSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改功能
|
||||||
|
*
|
||||||
|
* @param productSpec 商品规格实体类
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void updateById(ProductSpec productSpec) {
|
||||||
|
if (productSpec == null) {
|
||||||
|
throw new BunnyException(MessageConstant.UPDATE_DTO_IS_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
productSpecMapper.updateById(productSpec);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除功能
|
||||||
|
*
|
||||||
|
* @param id 要删除的ID
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void deleteById(Long id) {
|
||||||
|
emptyUtil.isEmpty(id, MessageConstant.UPDATE_ID_IS_NOT_EMPTY);
|
||||||
|
productSpecMapper.deleteById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载商品规格数据
|
||||||
|
*
|
||||||
|
* @return 列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProductSpec> findAll() {
|
||||||
|
return productSpecMapper.findAll();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,25 @@
|
||||||
|
package com.atguigu.spzx.manger.service.impl;
|
||||||
|
|
||||||
|
import com.atguigu.spzx.manger.mapper.ProductUnitMapper;
|
||||||
|
import com.atguigu.spzx.manger.service.ProductUnitService;
|
||||||
|
import com.atguigu.spzx.model.entity.base.ProductUnit;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProductUnitServiceImpl implements ProductUnitService {
|
||||||
|
@Autowired
|
||||||
|
private ProductUnitMapper productUnitMapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 加载商品单元数据
|
||||||
|
*
|
||||||
|
* @return 产品单元实体类列表
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<ProductUnit> findAll() {
|
||||||
|
return productUnitMapper.findAll();
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.atguigu.spzx.manger.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import com.atguigu.spzx.manger.mapper.OrderInfoMapper;
|
||||||
|
import com.atguigu.spzx.manger.mapper.OrderStatisticsMapper;
|
||||||
|
import com.atguigu.spzx.model.entity.order.OrderStatistics;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class OrderStatisticsTask {
|
||||||
|
@Autowired
|
||||||
|
private OrderInfoMapper orderInfoMapper;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private OrderStatisticsMapper orderStatisticsMapper;
|
||||||
|
|
||||||
|
@Scheduled(cron = "0 0 2 * * ?")
|
||||||
|
public void orderTotalAmountStatistics() {
|
||||||
|
String createTime = DateUtil.offsetDay(new Date(), -1).toString(new SimpleDateFormat("yyyy-MM-dd"));
|
||||||
|
OrderStatistics orderStatistics = orderInfoMapper.selectOrderStatistics(createTime);
|
||||||
|
if (orderStatistics != null) {
|
||||||
|
orderStatisticsMapper.insert(orderStatistics);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -20,4 +20,4 @@ bunny:
|
||||||
noAuthUrls:
|
noAuthUrls:
|
||||||
- /admin/system/index/login
|
- /admin/system/index/login
|
||||||
- /admin/system/index/generateValidateCode
|
- /admin/system/index/generateValidateCode
|
||||||
- /v3/**
|
|
||||||
|
|
|
@ -42,4 +42,11 @@
|
||||||
where is_deleted = 0
|
where is_deleted = 0
|
||||||
order by id desc
|
order by id desc
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 品牌列表 -->
|
||||||
|
<select id="findAll" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from brand where is_deleted = 0 order by id desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,66 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.CategoryBrandMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,brand_id,category_id,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 添加功能 -->
|
||||||
|
<insert id="save">
|
||||||
|
insert into category_brand (id, brand_id, category_id, create_time, update_time, is_deleted)
|
||||||
|
values (#{id}, #{brandId}, #{categoryId}, now(), now(), 0);
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改功能 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update category_brand
|
||||||
|
set
|
||||||
|
<if test="brandId != null and brandId != ''">
|
||||||
|
brand_id = #{brandId},
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
category_id = #{categoryId},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where id = #{id};
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 删除功能 -->
|
||||||
|
<update id="deleteById">
|
||||||
|
update category_brand
|
||||||
|
set is_deleted = 1
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 分类品牌列表 -->
|
||||||
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.CategoryBrand">
|
||||||
|
select
|
||||||
|
cb.id,cb.brand_id,cb.category_id,cb.create_time,cb.update_time,
|
||||||
|
c.name as categoryName,
|
||||||
|
b.name as brandName, b.logo
|
||||||
|
from category_brand cb
|
||||||
|
left join category c on c.id = cb.category_id
|
||||||
|
left join brand b on b.id = cb.brand_id
|
||||||
|
<where>
|
||||||
|
<if test="brandId != null and brandId != ''">
|
||||||
|
and cb.brand_id = #{brandId}
|
||||||
|
</if>
|
||||||
|
<if test="categoryId != null and categoryId != ''">
|
||||||
|
and cb.category_id = #{categoryId}
|
||||||
|
</if>
|
||||||
|
and cb.is_deleted = 0
|
||||||
|
</where>
|
||||||
|
order by cb.id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 添加功能 -->
|
||||||
|
<select id="findBrandByCategoryId" resultType="com.atguigu.spzx.model.entity.product.Brand">
|
||||||
|
select b.*
|
||||||
|
from category_brand cb
|
||||||
|
left join brand b on b.id = cb.brand_id
|
||||||
|
where cb.category_id = #{categoryId}
|
||||||
|
and cb.is_deleted = 0
|
||||||
|
order by cb.id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -8,6 +8,16 @@
|
||||||
id,name,image_url,parent_id,status,order_num,create_time,update_time,is_deleted
|
id,name,image_url,parent_id,status,order_num,create_time,update_time,is_deleted
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<!-- 批量插入数据库 -->
|
||||||
|
<insert id="batchInsert">
|
||||||
|
insert into category (id, name, image_url, parent_id, status, order_num, create_time, update_time, is_deleted)
|
||||||
|
values
|
||||||
|
<foreach collection="cachedDataList" item="item" separator=",">
|
||||||
|
( #{item.id}, #{item.name}, #{item.imageUrl}, #{item.parentId}, #{item.status}, #{item.orderNum}, now(),
|
||||||
|
now(), 0)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
<!-- 根据分类id查询它下面的所有的子分类数据 -->
|
<!-- 根据分类id查询它下面的所有的子分类数据 -->
|
||||||
<select id="selectByParentId" resultType="com.atguigu.spzx.model.entity.product.Category">
|
<select id="selectByParentId" resultType="com.atguigu.spzx.model.entity.product.Category">
|
||||||
select
|
select
|
||||||
|
@ -23,4 +33,13 @@
|
||||||
where parent_id = #{id}
|
where parent_id = #{id}
|
||||||
and is_deleted = 0
|
and is_deleted = 0
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 读取所以分类数据 -->
|
||||||
|
<select id="selectAll" resultType="com.atguigu.spzx.model.entity.product.Category">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from category
|
||||||
|
where is_deleted = 0
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.OrderInfoMapper">
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 查询指定日期产生的订单数据 -->
|
||||||
|
<select id="selectOrderStatistics" resultType="com.atguigu.spzx.model.entity.order.OrderStatistics">
|
||||||
|
select DATE_FORMAT(oi.create_time, '%Y-%m-%d') orderDate,
|
||||||
|
sum(oi.total_amount) totalAmount,
|
||||||
|
count(oi.id) totalNum
|
||||||
|
from order_info oi
|
||||||
|
where DATE_FORMAT(oi.create_time, '%Y-%m-%d') = #{createTime}
|
||||||
|
GROUP BY DATE_FORMAT(oi.create_time, '%Y-%m-%d')
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.OrderStatisticsMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,order_date,total_amount,total_num,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 插入 -->
|
||||||
|
<insert id="insert" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into order_statistics (id, order_date, total_amount, total_num)
|
||||||
|
values (#{id}, #{orderDate}, #{totalAmount}, #{totalNum})
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 查询统计结果数据 -->
|
||||||
|
<select id="selectList" resultType="com.atguigu.spzx.model.entity.order.OrderStatistics">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from order_statistics
|
||||||
|
<where>
|
||||||
|
<if test="createTimeBegin != null and createTimeBegin != ''">
|
||||||
|
and order_date >= #{createTimeBegin}
|
||||||
|
</if>
|
||||||
|
<if test="createTimeEnd != null and createTimeEnd != ''">
|
||||||
|
and order_date <= #{createTimeEnd}
|
||||||
|
</if>
|
||||||
|
</where>
|
||||||
|
order by order_date
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,44 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductDetailsMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,product_id,image_urls,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 保存数据 -->
|
||||||
|
<insert id="save" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into product_details (id, product_id, image_urls, create_time, update_time, is_deleted)
|
||||||
|
values (#{id}, #{productId}, #{imageUrls}, now(), now(), 0)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改商品的详情数据 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update product_details set
|
||||||
|
<if test="productId != null and productId != ''">
|
||||||
|
product_id = #{productId},
|
||||||
|
</if>
|
||||||
|
<if test="imageUrls != null and imageUrls != ''">
|
||||||
|
image_urls = #{imageUrls},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where
|
||||||
|
id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 根据商品的id删除商品的详情数据 -->
|
||||||
|
<update id="deleteByProductId">
|
||||||
|
update product_details
|
||||||
|
set update_time = now(),
|
||||||
|
is_deleted = 1
|
||||||
|
where product_id = #{productId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectByProductId" resultType="com.atguigu.spzx.model.entity.product.ProductDetails">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from product_details
|
||||||
|
where
|
||||||
|
product_id = #{productId}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,name,brand_id,category1_id,category2_id,category3_id,unit_name,slider_urls,spec_value,status,audit_status,audit_message,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 保存商品数据 -->
|
||||||
|
<insert id="save">
|
||||||
|
insert into product (id, name, brand_id, category1_id, category2_id, category3_id, unit_name, slider_urls,
|
||||||
|
spec_value, status, audit_status, audit_message, create_time, update_time, is_deleted)
|
||||||
|
values (#{id}, #{name}, #{brandId}, #{category1Id}, #{category2Id}, #{category3Id}, #{unitName}, #{sliderUrls},
|
||||||
|
#{specValue}, #{status}, #{auditStatus}, #{auditMessage}, now(), now(), 0)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改商品基本数据 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update product set
|
||||||
|
<if test="name != null and name != ''">
|
||||||
|
name = #{name},
|
||||||
|
</if>
|
||||||
|
<if test="brandId != null and brandId != ''">
|
||||||
|
brand_id = #{brandId},
|
||||||
|
</if>
|
||||||
|
<if test="category1Id != null and category1Id != ''">
|
||||||
|
category1_id = #{category1Id},
|
||||||
|
</if>
|
||||||
|
<if test="category2Id != null and category2Id != ''">
|
||||||
|
category2_id = #{category2Id},
|
||||||
|
</if>
|
||||||
|
<if test="category3Id != null and category3Id != ''">
|
||||||
|
category3_id = #{category3Id},
|
||||||
|
</if>
|
||||||
|
<if test="unitName != null and unitName != ''">
|
||||||
|
unit_name = #{unitName},
|
||||||
|
</if>
|
||||||
|
<if test="sliderUrls != null and sliderUrls != ''">
|
||||||
|
slider_urls = #{sliderUrls},
|
||||||
|
</if>
|
||||||
|
<if test="specValue != null and specValue != ''">
|
||||||
|
spec_value = #{specValue},
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
<if test="auditStatus != null and auditStatus != ''">
|
||||||
|
audit_status = #{auditStatus},
|
||||||
|
</if>
|
||||||
|
<if test="auditMessage != null and auditMessage != ''">
|
||||||
|
audit_message = #{auditMessage},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where
|
||||||
|
id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 根据id删除商品基本数据 -->
|
||||||
|
<update id="deleteById">
|
||||||
|
update product
|
||||||
|
set update_time = now(),
|
||||||
|
is_deleted = 1
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 列表查询 -->
|
||||||
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.Product">
|
||||||
|
select
|
||||||
|
p.id, p.name , p.brand_id , p.category1_id , p.category2_id , p.category3_id, p.unit_name,
|
||||||
|
p.slider_urls , p.spec_value , p.status , p.audit_status , p.audit_message , p.create_time , p.update_time ,
|
||||||
|
p.is_deleted ,
|
||||||
|
b.name brandName , c1.name category1Name , c2.name category2Name , c3.name category3Name
|
||||||
|
from product p
|
||||||
|
LEFT JOIN brand b on b.id = p.brand_id
|
||||||
|
LEFT JOIN category c1 on c1.id = p.category1_id
|
||||||
|
LEFT JOIN category c2 on c2.id = p.category2_id
|
||||||
|
LEFT JOIN category c3 on c3.id = p.category3_id
|
||||||
|
<where>
|
||||||
|
<if test="brandId != null and brandId != ''">
|
||||||
|
and p.brand_id = #{brandId}
|
||||||
|
</if>
|
||||||
|
<if test="category1Id != null and category1Id != ''">
|
||||||
|
and p.category1_id = #{category1Id}
|
||||||
|
</if>
|
||||||
|
<if test="category2Id != null and category2Id != ''">
|
||||||
|
and p.category2_id = #{category2Id}
|
||||||
|
</if>
|
||||||
|
<if test="category3Id != null and category3Id != ''">
|
||||||
|
and p.category3_id = #{category3Id}
|
||||||
|
</if>
|
||||||
|
and p.is_deleted = 0
|
||||||
|
</where>
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据id查询商品数据 -->
|
||||||
|
<select id="selectById" resultType="com.atguigu.spzx.model.entity.product.Product">
|
||||||
|
select p.id,
|
||||||
|
p.name,
|
||||||
|
p.brand_id,
|
||||||
|
p.category1_id,
|
||||||
|
p.category2_id,
|
||||||
|
p.category3_id,
|
||||||
|
p.unit_name,
|
||||||
|
p.slider_urls,
|
||||||
|
p.spec_value,
|
||||||
|
p.status,
|
||||||
|
p.audit_status,
|
||||||
|
p.audit_message,
|
||||||
|
p.create_time,
|
||||||
|
p.update_time,
|
||||||
|
p.is_deleted,
|
||||||
|
b.name brandName,
|
||||||
|
c1.name category1Name,
|
||||||
|
c2.name category2Name,
|
||||||
|
c2.name category3Name
|
||||||
|
from product p
|
||||||
|
LEFT JOIN brand b on b.id = p.brand_id
|
||||||
|
LEFT JOIN category c1 on c1.id = p.category1_id
|
||||||
|
LEFT JOIN category c2 on c2.id = p.category2_id
|
||||||
|
LEFT JOIN category c3 on c3.id = p.category3_id
|
||||||
|
where p.id = #{id}
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,79 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductSkuMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,sku_code,sku_name,product_id,thumb_img,sale_price,market_price,cost_price,stock_num,sku_spec,weight,volume,status,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 保存数据 -->
|
||||||
|
<insert id="save" useGeneratedKeys="true" keyProperty="id">
|
||||||
|
insert into product_sku (id, sku_code, sku_name, product_id, thumb_img, sale_price, market_price, cost_price,
|
||||||
|
stock_num, sku_spec, weight, volume, status, sale_num, create_time, update_time,
|
||||||
|
is_deleted)
|
||||||
|
values (#{id}, #{skuCode}, #{skuName}, #{productId}, #{thumbImg}, #{salePrice}, #{marketPrice},
|
||||||
|
#{costPrice}, #{stockNum}, #{skuSpec}, #{weight}, #{volume}, #{status}, #{saleNum}, now(), now(), 0)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改商品的sku数据 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update product_sku set
|
||||||
|
<if test="skuCode != null and skuCode != ''">
|
||||||
|
sku_code = #{skuCode},
|
||||||
|
</if>
|
||||||
|
<if test="skuName != null and skuName != ''">
|
||||||
|
sku_name = #{skuName},
|
||||||
|
</if>
|
||||||
|
<if test="productId != null and productId != ''">
|
||||||
|
product_id = #{productId},
|
||||||
|
</if>
|
||||||
|
<if test="thumbImg != null and thumbImg != ''">
|
||||||
|
thumb_img = #{thumbImg},
|
||||||
|
</if>
|
||||||
|
<if test="salePrice != null and salePrice != ''">
|
||||||
|
sale_price = #{salePrice},
|
||||||
|
</if>
|
||||||
|
<if test="marketPrice != null and marketPrice != ''">
|
||||||
|
market_price = #{marketPrice},
|
||||||
|
</if>
|
||||||
|
<if test="costPrice != null and costPrice != ''">
|
||||||
|
cost_price = #{costPrice},
|
||||||
|
</if>
|
||||||
|
<if test="stockNum != null and stockNum != ''">
|
||||||
|
stock_num = #{stockNum},
|
||||||
|
</if>
|
||||||
|
<if test="skuSpec != null and skuSpec != ''">
|
||||||
|
sku_spec = #{skuSpec},
|
||||||
|
</if>
|
||||||
|
<if test="weight != null and weight != ''">
|
||||||
|
weight = #{weight},
|
||||||
|
</if>
|
||||||
|
<if test="volume != null and volume != ''">
|
||||||
|
volume = #{volume},
|
||||||
|
</if>
|
||||||
|
<if test="status != null and status != ''">
|
||||||
|
status = #{status},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where
|
||||||
|
id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 根据商品id删除商品的sku数据 -->
|
||||||
|
<update id="deleteByProductId">
|
||||||
|
update product_sku
|
||||||
|
set update_time = now(),
|
||||||
|
is_deleted = 1
|
||||||
|
where product_id = #{productId}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 根据商品的id查询sku数据 -->
|
||||||
|
<select id="selectByProductId" resultType="com.atguigu.spzx.model.entity.product.ProductSku">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from product_sku
|
||||||
|
where product_id = #{productId}
|
||||||
|
and is_deleted = 0
|
||||||
|
order by id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,51 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductSpecMapper">
|
||||||
|
<!-- 用于select查询公用抽取的列 -->
|
||||||
|
<sql id="columns">
|
||||||
|
id,spec_name,spec_value,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 添加功能 -->
|
||||||
|
<insert id="save">
|
||||||
|
insert into product_spec (id, spec_name, spec_value, create_time, update_time, is_deleted)
|
||||||
|
values (#{id}, #{specName}, #{specValue}, now(), now(), 0);
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- 修改功能 -->
|
||||||
|
<update id="updateById">
|
||||||
|
update product_spec
|
||||||
|
set
|
||||||
|
<if test="specName != null and specName != ''">
|
||||||
|
spec_name = #{specName},
|
||||||
|
</if>
|
||||||
|
<if test="specValue != null and specValue != ''">
|
||||||
|
spec_value = #{specValue},
|
||||||
|
</if>
|
||||||
|
update_time = now()
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 删除功能 -->
|
||||||
|
<update id="deleteById">
|
||||||
|
update product_spec
|
||||||
|
set is_deleted = 1,
|
||||||
|
update_time = now()
|
||||||
|
where id = #{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- 列表查询 -->
|
||||||
|
<select id="findByPage" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from product_spec
|
||||||
|
where is_deleted = 0 order by id desc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<!-- 加载商品规格数据 -->
|
||||||
|
<select id="findAll" resultType="com.atguigu.spzx.model.entity.product.ProductSpec">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from product_spec where is_deleted = 0 order by id
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,15 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.atguigu.spzx.manger.mapper.ProductUnitMapper">
|
||||||
|
<sql id="columns">
|
||||||
|
id,name,create_time,update_time,is_deleted
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<!-- 加载商品单元数据 -->
|
||||||
|
<select id="findAll" resultType="com.atguigu.spzx.model.entity.base.ProductUnit">
|
||||||
|
select
|
||||||
|
<include refid="columns"/>
|
||||||
|
from product_unit
|
||||||
|
where is_deleted = 0 order by id desc
|
||||||
|
</select>
|
||||||
|
</mapper>
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.atguigu.spzx.manger;
|
||||||
|
|
||||||
|
import com.alibaba.excel.EasyExcel;
|
||||||
|
import com.atguigu.spzx.manger.excel.ExcelListener;
|
||||||
|
import com.atguigu.spzx.model.vo.product.CategoryExcelVo;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@SpringBootTest
|
||||||
|
public class EasyExcelTest {
|
||||||
|
private static final String filename = "F:\\java项目\\尚硅谷-尚品甄选项目\\资料\\01.xlsx";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void readDateToExcel() {
|
||||||
|
ExcelListener<CategoryExcelVo> listener = new ExcelListener<>();
|
||||||
|
EasyExcel.read(filename, CategoryExcelVo.class, listener).sheet().doRead();// 解析excel表格
|
||||||
|
List<CategoryExcelVo> dataList = listener.getDataList();
|
||||||
|
dataList.forEach(System.out::println);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void writeDataToExcel() {
|
||||||
|
ArrayList<CategoryExcelVo> list = new ArrayList<>();
|
||||||
|
list.add(new CategoryExcelVo(1L, "数码办公", "", 0L, 1, 1));
|
||||||
|
list.add(new CategoryExcelVo(11L, "华为手机", "", 1L, 1, 2));
|
||||||
|
EasyExcel.write(filename, CategoryExcelVo.class).sheet("分类数据1").doWrite(list);
|
||||||
|
}
|
||||||
|
}
|
|
@ -6,11 +6,9 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "搜索条件实体类")
|
@Schema(description = "搜索条件实体类")
|
||||||
public class OrderStatisticsDto {
|
public class OrderStatisticsDto {
|
||||||
|
|
||||||
@Schema(description = "开始时间")
|
@Schema(description = "开始时间")
|
||||||
private String createTimeBegin;
|
private String createTimeBegin;
|
||||||
|
|
||||||
@Schema(description = "结束时间")
|
@Schema(description = "结束时间")
|
||||||
private String createTimeEnd;
|
private String createTimeEnd;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,12 +2,12 @@ package com.atguigu.spzx.model.entity.base;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "产品单元实体类")
|
@Schema(description = "产品单元实体类")
|
||||||
public class ProductUnit extends BaseEntity {
|
public class ProductUnit extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "名称")
|
@Schema(description = "名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
}
|
}
|
|
@ -2,15 +2,15 @@ package com.atguigu.spzx.model.entity.order;
|
||||||
|
|
||||||
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
public class OrderStatistics extends BaseEntity {
|
public class OrderStatistics extends BaseEntity {
|
||||||
|
|
||||||
private Date orderDate;
|
private Date orderDate;
|
||||||
private BigDecimal totalAmount;
|
private BigDecimal totalAmount;
|
||||||
private Integer totalNum;
|
private Integer totalNum;
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,13 +3,14 @@ package com.atguigu.spzx.model.entity.product;
|
||||||
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "分类实体类")
|
@Schema(description = "分类实体类")
|
||||||
public class Category extends BaseEntity {
|
public class Category extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "分类名称")
|
@Schema(description = "分类名称")
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
@ -30,5 +31,4 @@ public class Category extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "子节点List集合")
|
@Schema(description = "子节点List集合")
|
||||||
private List<Category> children;
|
private List<Category> children;
|
||||||
|
|
||||||
}
|
}
|
|
@ -7,20 +7,18 @@ import lombok.Data;
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "分类品牌实体类")
|
@Schema(description = "分类品牌实体类")
|
||||||
public class CategoryBrand extends BaseEntity {
|
public class CategoryBrand extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "品牌id")
|
@Schema(description = "品牌id")
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
@Schema(description = "分类id")
|
@Schema(description = "分类id")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
@Schema(description = "分类名称" , required = false)
|
@Schema(description = "分类名称", required = false)
|
||||||
private String categoryName;
|
private String categoryName;
|
||||||
|
|
||||||
@Schema(description = "品牌名称" , required = false)
|
@Schema(description = "品牌名称", required = false)
|
||||||
private String brandName;
|
private String brandName;
|
||||||
|
|
||||||
@Schema(description = "品牌logo" , required = false)
|
@Schema(description = "品牌logo", required = false)
|
||||||
private String logo;
|
private String logo;
|
||||||
|
|
||||||
}
|
}
|
|
@ -3,13 +3,14 @@ package com.atguigu.spzx.model.entity.product;
|
||||||
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
import com.atguigu.spzx.model.entity.base.BaseEntity;
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "商品实体类")
|
@Schema(description = "商品实体类")
|
||||||
public class Product extends BaseEntity {
|
public class Product extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "商品名称")
|
@Schema(description = "商品名称")
|
||||||
private String name; // 商品名称
|
private String name; // 商品名称
|
||||||
|
|
||||||
|
@ -61,5 +62,4 @@ public class Product extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "图片详情列表")
|
@Schema(description = "图片详情列表")
|
||||||
private String detailsImageUrls; // 图片详情列表
|
private String detailsImageUrls; // 图片详情列表
|
||||||
|
|
||||||
}
|
}
|
|
@ -5,12 +5,10 @@ import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@Schema(description = "ProductSku")
|
@Schema(description = "ProductSku")
|
||||||
public class ProductSku extends BaseEntity {
|
public class ProductSku extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "商品编号")
|
@Schema(description = "商品编号")
|
||||||
private String skuCode;
|
private String skuCode;
|
||||||
|
|
||||||
|
@ -49,5 +47,4 @@ public class ProductSku extends BaseEntity {
|
||||||
|
|
||||||
@Schema(description = "线上状态:0-初始值,1-上架,-1-自主下架")
|
@Schema(description = "线上状态:0-初始值,1-上架,-1-自主下架")
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,6 +1,7 @@
|
||||||
package com.atguigu.spzx.model.vo.product;
|
package com.atguigu.spzx.model.vo.product;
|
||||||
|
|
||||||
import com.alibaba.excel.annotation.ExcelProperty;
|
import com.alibaba.excel.annotation.ExcelProperty;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -8,24 +9,23 @@ import lombok.NoArgsConstructor;
|
||||||
@Data
|
@Data
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
|
@Schema(description = "Excel表品牌管理实体类")
|
||||||
public class CategoryExcelVo {
|
public class CategoryExcelVo {
|
||||||
|
@ExcelProperty(value = "id", index = 0)
|
||||||
@ExcelProperty(value = "id" ,index = 0)
|
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@ExcelProperty(value = "名称" ,index = 1)
|
@ExcelProperty(value = "名称", index = 1)
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@ExcelProperty(value = "图片url" ,index = 2)
|
@ExcelProperty(value = "图片url", index = 2)
|
||||||
private String imageUrl ;
|
private String imageUrl;
|
||||||
|
|
||||||
@ExcelProperty(value = "上级id" ,index = 3)
|
@ExcelProperty(value = "上级id", index = 3)
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
@ExcelProperty(value = "状态" ,index = 4)
|
@ExcelProperty(value = "状态", index = 4)
|
||||||
private Integer status;
|
private Integer status;
|
||||||
|
|
||||||
@ExcelProperty(value = "排序" ,index = 5)
|
@ExcelProperty(value = "排序", index = 5)
|
||||||
private Integer orderNum;
|
private Integer orderNum;
|
||||||
|
|
||||||
}
|
}
|
|
@ -8,15 +8,16 @@ import lombok.Getter;
|
||||||
@Getter
|
@Getter
|
||||||
public enum ResultCodeEnum {
|
public enum ResultCodeEnum {
|
||||||
SUCCESS(200, "成功"),
|
SUCCESS(200, "成功"),
|
||||||
|
PERMISSION(401, "没有权限"),
|
||||||
FAIL(500, "失败"),
|
FAIL(500, "失败"),
|
||||||
USE_NOT_EXIST(500, "失败"),
|
USE_NOT_EXIST(500, "失败"),
|
||||||
SERVICE_ERROR(2012, "服务异常"),
|
SERVICE_ERROR(500, "服务异常"),
|
||||||
DATA_ERROR(204, "数据异常"),
|
DATA_ERROR(500, "数据异常"),
|
||||||
LOGIN_AUTH(208, "需要先登陆"),
|
LOGIN_AUTH(500, "需要先登陆"),
|
||||||
LOGIN_MOBLE_ERROR(208, "登录验证失败"),
|
LOGIN_MOBLE_ERROR(500, "登录验证失败"),
|
||||||
ACCOUNT_DEACTIVATION(208, "账户停用"),
|
ACCOUNT_DEACTIVATION(500, "账户停用"),
|
||||||
PERMISSION(209, "没有权限"),
|
|
||||||
USERNAME_IS_EXISTS(500, "用户名已存在"),
|
USERNAME_IS_EXISTS(500, "用户名已存在"),
|
||||||
|
WRITE_FILE_ERROR(500, "写入文件失败"),
|
||||||
;
|
;
|
||||||
|
|
||||||
private final Integer code;
|
private final Integer code;
|
||||||
|
|
Loading…
Reference in New Issue