产品模块

This commit is contained in:
xuelijun
2025-07-28 17:28:04 +08:00
parent 94f5254e5c
commit ba3fe6a242
60 changed files with 1662 additions and 5004 deletions

View File

@@ -0,0 +1,54 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*//*
package com.tashow.cloud.product.controller;
import com.tashow.cloud.product.domain.Category;
import com.tashow.cloud.product.domain.ServerResponseEntity;
import com.tashow.cloud.product.service.CategoryService;
import jakarta.annotation.security.PermitAll;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
*/
/**
* 分类接口
* @author lanhai
*//*
@RestController
@RequestMapping("/category")
public class CategoryController {
@Autowired
private CategoryService categoryService;
*/
/**
* 分类信息列表接口
*//*
@PermitAll
@GetMapping("/categoryInfo")
public ServerResponseEntity<List<Category>> categoryInfo() {
List<Category> categories = categoryService.tableCategory(1L);
return ServerResponseEntity.success(categories);
}
}
*/

View File

@@ -0,0 +1,77 @@
package com.tashow.cloud.product.controller;
import com.tashow.cloud.product.dto.ProdDO;
import com.tashow.cloud.product.vo.prod.*;
import jakarta.annotation.security.PermitAll;
import org.springframework.web.bind.annotation.*;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.security.access.prepost.PreAuthorize;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import jakarta.validation.constraints.*;
import jakarta.validation.*;
import jakarta.servlet.http.*;
import java.util.*;
import java.io.IOException;
import com.tashow.cloud.common.pojo.PageParam;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.common.util.object.BeanUtils;
import static com.tashow.cloud.common.pojo.CommonResult.success;
import com.tashow.cloud.web.apilog.core.annotation.ApiAccessLog;
import static com.tashow.cloud.web.apilog.core.enums.OperateTypeEnum.*;
import com.tashow.cloud.product.service.ProdService;
@Tag(name = "管理后台 - 商品")
@RestController
@RequestMapping("/prod")
@Validated
public class ProdController {
@Resource
private ProdService prodService;
@PostMapping("/create")
@Operation(summary = "创建商品")
@PreAuthorize("@ss.hasPermission('tashow-module-product:prod:create')")
public CommonResult<Long> createProd(@Valid @RequestBody ProdSaveReqVO createReqVO) {
return success(prodService.createProd(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新商品")
@PreAuthorize("@ss.hasPermission('tashow-module-product:prod:update')")
public CommonResult<Boolean> updateProd(@Valid @RequestBody ProdSaveReqVO updateReqVO) {
prodService.updateProd(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除商品")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('tashow-module-product:prod:delete')")
public CommonResult<Boolean> deleteProd(@RequestParam("id") Long id) {
prodService.deleteProd(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得商品")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('tashow-module-product:prod:query')")
public CommonResult<ProdRespVO> getProd(@RequestParam("id") Long id) {
ProdDO prod = prodService.getProd(id);
return success(BeanUtils.toBean(prod, ProdRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得商品分页")
@PreAuthorize("@ss.hasPermission('tashow-module-product:prod:query')")
@PermitAll
public CommonResult<PageResult<ProdRespVO>> getProdPage(@Valid ProdPageReqVO pageReqVO) {
PageResult<ProdDO> pageResult = prodService.getProdPage(pageReqVO);
return success(BeanUtils.toBean(pageResult, ProdRespVO.class));
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*//*
package com.tashow.cloud.product.domain;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
*/
/**
* @author lanhai
*//*
@Data
@TableName("tz_category")
public class Category implements Serializable {
*/
/**
* 类目ID
*//*
private Long categoryId;
*/
/**
* 店铺ID
*//*
private Long shopId;
*/
/**
* 父节点
*//*
private Long parentId;
*/
/**
* 产品类目名称
*//*
private String categoryName;
*/
/**
* 类目图标
*//*
private String icon;
*/
/**
* 类目的显示图片
*//*
private String pic;
*/
/**
* 类目描述
*//*
private String describe;
*/
/**
* 标签
*//*
private String tag;
*/
/**
* 排序
*//*
private Integer seq;
*/
/**
* 默认是1表示正常状态,0为下线状态
*//*
private Integer status;
*/
/**
* 创建时间
*//*
private Date createTime;
*/
/**
* 创建时间
*//*
private String creator;
*/
/**
* 分类层级
*//*
private Integer grade;
*/
/**
* 更新时间
*//*
private Date updateTime;
*/
/**
* 修改人
*//*
private String updater;
private static final long serialVersionUID = 1L;
}
*/

View File

@@ -0,0 +1,200 @@
package com.tashow.cloud.product.domain;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data;
/**
* 商品对象 prod
*
* @author ruoyi
* @date 2025-07-25
*/
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Prod extends BaseEntity {
private static final long serialVersionUID=1L;
/**
* 产品ID
*/
@ApiModelProperty(value = "产品ID", position = 0)
private Long prodId;
/**
* 商品名称
*/
@ApiModelProperty(value = "商品名称", position = 1)
private String prodName;
/**
* 展示的权重
*/
@ApiModelProperty(value = "商品简称", position = 2)
private String abbreviation;
/**
* 展示的权重
*/
@ApiModelProperty(value = "seo标题", position = 3)
private String seoName;
/**
* 展示的权重
*/
@ApiModelProperty(value = "seo搜索", position = 4)
private String seoSearch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "关键词", position = 5)
private String keyword;
/**
* 展示的权重
*/
@ApiModelProperty(value = "店铺id", position = 6)
private Long shopId;
/**
* 展示的权重
*/
@ApiModelProperty(value = "简要描述,卖点等", position = 7)
private String brief;
/**
* 展示的权重
*/
@ApiModelProperty(value = "品牌", position = 8)
private String brand;
/**
* 展示的权重
*/
@ApiModelProperty(value = "详细描述", position = 9)
private String content;
/**
* 展示的权重
*/
@ApiModelProperty(value = "商品编号", position = 10)
private String prodNumber;
/**
* 展示的权重
*/
@ApiModelProperty(value = "商品主图", position = 11)
private String pic;
/**
* 展示的权重
*/
@ApiModelProperty(value = "商品轮播图片,以,分割", position = 12)
private String imgs;
/**
* 展示的权重
*/
@ApiModelProperty(value = "默认是1表示正常状态, -1表示删除, 0下架", position = 13)
private Long status;
/**
* 展示的权重
*/
@ApiModelProperty(value = "商品分类", position = 14)
private Long categoryId;
/**
* 展示的权重
*/
@ApiModelProperty(value = "销量", position = 15)
private Long soldNum;
/**
* 展示的权重
*/
@ApiModelProperty(value = "分享图", position = 16)
private String shareImage;
/**
* 展示的权重
*/
@ApiModelProperty(value = "分享话术", position = 17)
private String shareContent;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否开启区域0关1开", position = 18)
private Integer regionSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否特殊时段0关1开", position = 19)
private Integer additionalSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否特殊日期节假日周末什么的0关1开", position = 20)
private Integer additionalFeeSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否紧急响应服务0关1开", position = 21)
private Integer emergencySwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否预约0关1开", position = 22)
private Integer reservationSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否接单上线0关1开", position = 23)
private Integer orderLimitSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "是否开启体重配置0关1开", position = 24)
private Integer weightSwitch;
/**
* 展示的权重
*/
@ApiModelProperty(value = "版本 乐观锁", position = 29)
private Long version;
/**
* 展示的权重
*/
@ApiModelProperty(value = "展示的权重", position = 30)
private Long top;
}

View File

@@ -0,0 +1,198 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*/
package com.tashow.cloud.product.domain;
import lombok.extern.slf4j.Slf4j;
import java.io.Serializable;
import java.util.Objects;
/**
* @author lanhai
*/
@Slf4j
public class ServerResponseEntity<T> implements Serializable {
/**
* 状态码
*/
private String code;
/**
* 信息
*/
private String msg;
/**
* 数据
*/
private T data;
/**
* 版本
*/
private String version;
/**
* 时间
*/
private Long timestamp;
private String sign;
public String getSign() {
return sign;
}
public void setSign(String sign) {
this.sign = sign;
}
public String getCode() {
return code;
}
public void setCode(String code) {
this.code = code;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public T getData() {
return data;
}
public ServerResponseEntity setData(T data) {
this.data = data;
return this;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public Long getTimestamp() {
return timestamp;
}
public void setTimestamp(Long timestamp) {
this.timestamp = timestamp;
}
public boolean isSuccess() {
return Objects.equals(ResponseEnum.OK.value(), this.code);
}
public boolean isFail() {
return !Objects.equals(ResponseEnum.OK.value(), this.code);
}
public ServerResponseEntity() {
// 版本号
this.version = "mall4j.v230424";
}
public static <T> ServerResponseEntity<T> success(T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setData(data);
serverResponseEntity.setCode(ResponseEnum.OK.value());
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> success() {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(ResponseEnum.OK.value());
serverResponseEntity.setMsg(ResponseEnum.OK.getMsg());
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> success(Integer code, T data) {
return success(String.valueOf(code), data);
}
public static <T> ServerResponseEntity<T> success(String code, T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(code);
serverResponseEntity.setData(data);
return serverResponseEntity;
}
/**
* 前端显示失败消息
* @param msg 失败消息
* @return
*/
public static <T> ServerResponseEntity<T> showFailMsg(String msg) {
log.error(msg);
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(msg);
serverResponseEntity.setCode(ResponseEnum.SHOW_FAIL.value());
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum) {
log.error(responseEnum.toString());
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(responseEnum.getMsg());
serverResponseEntity.setCode(responseEnum.value());
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> fail(ResponseEnum responseEnum, T data) {
log.error(responseEnum.toString());
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(responseEnum.getMsg());
serverResponseEntity.setCode(responseEnum.value());
serverResponseEntity.setData(data);
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> fail(String code, String msg, T data) {
log.error(msg);
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setMsg(msg);
serverResponseEntity.setCode(code);
serverResponseEntity.setData(data);
return serverResponseEntity;
}
public static <T> ServerResponseEntity<T> fail(String code, String msg) {
return fail(code, msg, null);
}
public static <T> ServerResponseEntity<T> fail(Integer code, T data) {
ServerResponseEntity<T> serverResponseEntity = new ServerResponseEntity<>();
serverResponseEntity.setCode(String.valueOf(code));
serverResponseEntity.setData(data);
return serverResponseEntity;
}
@Override
public String toString() {
return "ServerResponseEntity{" +
"code='" + code + '\'' +
", msg='" + msg + '\'' +
", data=" + data +
", version='" + version + '\'' +
", timestamp=" + timestamp +
", sign='" + sign + '\'' +
'}';
}
}

View File

@@ -0,0 +1,143 @@
package com.tashow.cloud.product.dto;
import lombok.*;
import java.util.*;
import java.time.LocalDateTime;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.tashow.cloud.mybatis.mybatis.core.dataobject.BaseDO;
/**
* 商品 DO
*
* @author 芋道源码
*/
@TableName("tz_prod")
@KeySequence("tz_prod_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProdDO extends BaseDO {
/**
* 产品ID
*/
@TableId
private Long prodId;
/**
* 商品名称
*/
private String prodName;
/**
* 商品简称
*/
private String abbreviation;
/**
* seo标题
*/
private String seoName;
/**
* seo搜索
*/
private String seoSearch;
/**
* 关键词
*/
private String keyword;
/**
* 店铺id
*/
private Long shopId;
/**
* 简要描述,卖点等
*/
private String brief;
/**
* 品牌
*/
private String brand;
/**
* 详细描述
*/
private String content;
/**
* 商品编号
*/
private String prodNumber;
/**
* 商品主图
*/
private String pic;
/**
* 商品轮播图片,以,分割
*/
private String imgs;
/**
* 默认是1表示正常状态, -1表示删除, 0下架
*/
private Integer status;
/**
* 商品分类
*/
private Long categoryId;
/**
* 销量
*/
private Integer soldNum;
/**
* 分享图
*/
private String shareImage;
/**
* 分享话术
*/
private String shareContent;
/**
* 是否开启区域0关1开
*/
private Boolean regionSwitch;
/**
* 是否特殊时段0关1开
*/
private Boolean additionalSwitch;
/**
* 是否特殊日期节假日周末什么的0关1开
*/
private Boolean additionalFeeSwitch;
/**
* 是否紧急响应服务0关1开
*/
private Boolean emergencySwitch;
/**
* 是否预约0关1开
*/
private Boolean reservationSwitch;
/**
* 是否接单上线0关1开
*/
private Boolean orderLimitSwitch;
/**
* 是否开启体重配置0关1开
*/
private Boolean weightSwitch;
/**
* 创建人
*/
private String createBy;
/**
* 修改人
*/
private String updateBy;
/**
* 版本 乐观锁
*/
private Integer version;
/**
* 展示的权重
*/
private Integer top;
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*//*
package com.tashow.cloud.product.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tashow.cloud.product.domain.Category;
import java.util.List;
*/
/**
* @author lanhai
*//*
public interface CategoryMapper extends BaseMapper<Category> {
*/
/**
* 根据父级id获取分类列表
*
* @param parentId
* @return
*//*
List<Category> listByParentId(Long parentId);
*/
/**
* 根据店铺id获取分类列表
*
* @param shopId
* @return
*//*
List<Category> tableCategory(Long shopId);
}*/

View File

@@ -0,0 +1,22 @@
package com.tashow.cloud.product.mapper;
import java.util.*;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.mybatis.mybatis.core.query.LambdaQueryWrapperX;
import com.tashow.cloud.mybatis.mybatis.core.mapper.BaseMapperX;
import com.tashow.cloud.product.dto.ProdDO;
import com.tashow.cloud.product.vo.prod.ProdPageReqVO;
import org.apache.ibatis.annotations.Mapper;
/**
* 商品 Mapper
*
* @author 芋道源码
*/
@Mapper
public interface ProdMapper extends BaseMapperX<ProdDO> {
// PageResult<ProdDO> getProdPage1(ProdPageReqVO reqVO);
}

View File

@@ -0,0 +1,71 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*//*
package com.tashow.cloud.product.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.tashow.cloud.product.domain.Category;
import java.util.List;
*/
/**
* @author lanhai
* 商品分类
*//*
public interface CategoryService extends IService<Category> {
*/
/**
* 根据parentId获取分类
* @param parentId 0 一级分类
* @return
*//*
List<Category> listByParentId(Long parentId);
*/
/**
* 获取用于页面表单展现的category列表根据seq排序
* @param shopId 店铺id
* @return
*//*
List<Category> tableCategory(Long shopId);
*/
/**
* 保存分类、品牌、参数
* @param category
*//*
void saveCategory(Category category);
*/
/**
* 修改分类、品牌、参数
* @param category
*//*
void updateCategory(Category category);
*/
/**
* 删除分类、品牌、参数 以及分类对应的图片
* @param categoryId 分类id
*//*
void deleteCategory(Long categoryId);
}
*/

View File

@@ -0,0 +1,57 @@
package com.tashow.cloud.product.service;
import java.util.*;
import com.tashow.cloud.product.dto.ProdDO;
import com.tashow.cloud.product.vo.prod.ProdPageReqVO;
import com.tashow.cloud.product.vo.prod.ProdSaveReqVO;
import jakarta.validation.*;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.pojo.PageParam;
/**
* 商品 Service 接口
*
* @author 芋道源码
*/
public interface ProdService {
/**
* 创建商品
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createProd(@Valid ProdSaveReqVO createReqVO);
/**
* 更新商品
*
* @param updateReqVO 更新信息
*/
void updateProd(@Valid ProdSaveReqVO updateReqVO);
/**
* 删除商品
*
* @param id 编号
*/
void deleteProd(Long id);
/**
* 获得商品
*
* @param id 编号
* @return 商品
*/
ProdDO getProd(Long id);
/**
* 获得商品分页
*
* @param pageReqVO 分页查询
* @return 商品分页
*/
PageResult<ProdDO> getProdPage(ProdPageReqVO pageReqVO);
}

View File

@@ -0,0 +1,79 @@
/*
* Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
*
* https://www.mall4j.com/
*
* 未经允许,不可做商业用途!
*
* 版权所有,侵权必究!
*//*
package com.tashow.cloud.product.service.impl;
import cn.hutool.core.collection.CollUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.collect.Lists;
import com.tashow.cloud.product.domain.Category;
import com.tashow.cloud.product.mapper.CategoryMapper;
import com.tashow.cloud.product.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
*/
/**
* @author lanhai
*//*
@Service
public class CategoryServiceImpl extends ServiceImpl<CategoryMapper, Category> implements CategoryService {
@Autowired
private CategoryMapper categoryMapper;
@Override
public List<Category> listByParentId(Long parentId) {
return categoryMapper.listByParentId(parentId);
}
@Override
public List<Category> tableCategory(Long shopId) {
return categoryMapper.tableCategory(shopId);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveCategory(Category category) {
category.setCreateTime(new Date());
// 保存分类信息
categoryMapper.insert(category);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateCategory(Category category) {
Category dbCategory = categoryMapper.selectById(category.getCategoryId());
category.setUpdateTime(new Date());
// 保存分类信息
categoryMapper.updateById(category);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteCategory(Long categoryId) {
Category category = categoryMapper.selectById(categoryId);
categoryMapper.deleteById(categoryId);
}
}
*/

View File

@@ -0,0 +1,75 @@
package com.tashow.cloud.product.service.impl;
import com.tashow.cloud.product.dto.ProdDO;
import com.tashow.cloud.product.mapper.ProdMapper;
import com.tashow.cloud.product.service.ProdService;
import com.tashow.cloud.product.vo.prod.ProdPageReqVO;
import com.tashow.cloud.product.vo.prod.ProdSaveReqVO;
import org.springframework.stereotype.Service;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import com.tashow.cloud.common.pojo.PageResult;
import com.tashow.cloud.common.pojo.PageParam;
import com.tashow.cloud.common.util.object.BeanUtils;
import static com.tashow.cloud.common.exception.util.ServiceExceptionUtil.exception;
/**
* 商品 Service 实现类
*
* @author 芋道源码
*/
@Service
@Validated
public class ProdServiceImpl implements ProdService {
@Resource
private ProdMapper prodMapper;
@Override
public Long createProd(ProdSaveReqVO createReqVO) {
// 插入
ProdDO prod = BeanUtils.toBean(createReqVO, ProdDO.class);
prodMapper.insert(prod);
// 返回
return prod.getProdId();
}
@Override
public void updateProd(ProdSaveReqVO updateReqVO) {
// 校验存在
validateProdExists(updateReqVO.getProdId());
// 更新
ProdDO updateObj = BeanUtils.toBean(updateReqVO, ProdDO.class);
prodMapper.updateById(updateObj);
}
@Override
public void deleteProd(Long id) {
// 校验存在
validateProdExists(id);
// 删除
prodMapper.deleteById(id);
}
private void validateProdExists(Long id) {
if (prodMapper.selectById(id) == null) {
//throw exception(100, "商品不存在");
}
}
@Override
public ProdDO getProd(Long id) {
return prodMapper.selectById(id);
}
@Override
public PageResult<ProdDO> getProdPage(ProdPageReqVO pageReqVO) {
return null;// prodMapper.getProdPage1(pageReqVO);
}
}

View File

@@ -0,0 +1,108 @@
package com.tashow.cloud.product.vo.prod;
import com.tashow.cloud.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static com.tashow.cloud.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 商品分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class ProdPageReqVO extends PageParam {
@Schema(description = "商品名称", example = "赵六")
private String prodName;
@Schema(description = "商品简称")
private String abbreviation;
@Schema(description = "seo标题", example = "李四")
private String seoName;
@Schema(description = "seo搜索")
private String seoSearch;
@Schema(description = "关键词")
private String keyword;
@Schema(description = "店铺id", example = "10843")
private Long shopId;
@Schema(description = "简要描述,卖点等")
private String brief;
@Schema(description = "品牌")
private String brand;
@Schema(description = "详细描述")
private String content;
@Schema(description = "商品编号")
private String prodNumber;
@Schema(description = "商品主图")
private String pic;
@Schema(description = "商品轮播图片,以,分割")
private String imgs;
@Schema(description = "默认是1表示正常状态, -1表示删除, 0下架", example = "2")
private Integer status;
@Schema(description = "商品分类", example = "14895")
private Long categoryId;
@Schema(description = "销量")
private Integer soldNum;
@Schema(description = "分享图")
private String shareImage;
@Schema(description = "分享话术")
private String shareContent;
@Schema(description = "是否开启区域0关1开")
private Boolean regionSwitch;
@Schema(description = "是否特殊时段0关1开")
private Boolean additionalSwitch;
@Schema(description = "是否特殊日期节假日周末什么的0关1开")
private Boolean additionalFeeSwitch;
@Schema(description = "是否紧急响应服务0关1开")
private Boolean emergencySwitch;
@Schema(description = "是否预约0关1开")
private Boolean reservationSwitch;
@Schema(description = "是否接单上线0关1开")
private Boolean orderLimitSwitch;
@Schema(description = "是否开启体重配置0关1开")
private Boolean weightSwitch;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
@Schema(description = "创建人")
private String createBy;
@Schema(description = "修改人")
private String updateBy;
@Schema(description = "版本 乐观锁")
private Integer version;
@Schema(description = "展示的权重")
private Integer top;
}

View File

@@ -0,0 +1,135 @@
package com.tashow.cloud.product.vo.prod;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 商品 Response VO")
@Data
@ExcelIgnoreUnannotated
public class ProdRespVO {
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6943")
@ExcelProperty("产品ID")
private Long prodId;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@ExcelProperty("商品名称")
private String prodName;
@Schema(description = "商品简称")
@ExcelProperty("商品简称")
private String abbreviation;
@Schema(description = "seo标题", example = "李四")
@ExcelProperty("seo标题")
private String seoName;
@Schema(description = "seo搜索")
@ExcelProperty("seo搜索")
private String seoSearch;
@Schema(description = "关键词")
@ExcelProperty("关键词")
private String keyword;
@Schema(description = "店铺id", example = "10843")
@ExcelProperty("店铺id")
private Long shopId;
@Schema(description = "简要描述,卖点等")
@ExcelProperty("简要描述,卖点等")
private String brief;
@Schema(description = "品牌")
@ExcelProperty("品牌")
private String brand;
@Schema(description = "详细描述")
@ExcelProperty("详细描述")
private String content;
@Schema(description = "商品编号")
@ExcelProperty("商品编号")
private String prodNumber;
@Schema(description = "商品主图")
@ExcelProperty("商品主图")
private String pic;
@Schema(description = "商品轮播图片,以,分割")
@ExcelProperty("商品轮播图片,以,分割")
private String imgs;
@Schema(description = "默认是1表示正常状态, -1表示删除, 0下架", example = "2")
@ExcelProperty("默认是1表示正常状态, -1表示删除, 0下架")
private Integer status;
@Schema(description = "商品分类", example = "14895")
@ExcelProperty("商品分类")
private Long categoryId;
@Schema(description = "销量")
@ExcelProperty("销量")
private Integer soldNum;
@Schema(description = "分享图")
@ExcelProperty("分享图")
private String shareImage;
@Schema(description = "分享话术")
@ExcelProperty("分享话术")
private String shareContent;
@Schema(description = "是否开启区域0关1开")
@ExcelProperty("是否开启区域0关1开")
private Boolean regionSwitch;
@Schema(description = "是否特殊时段0关1开")
@ExcelProperty("是否特殊时段0关1开")
private Boolean additionalSwitch;
@Schema(description = "是否特殊日期节假日周末什么的0关1开")
@ExcelProperty("是否特殊日期节假日周末什么的0关1开")
private Boolean additionalFeeSwitch;
@Schema(description = "是否紧急响应服务0关1开")
@ExcelProperty("是否紧急响应服务0关1开")
private Boolean emergencySwitch;
@Schema(description = "是否预约0关1开")
@ExcelProperty("是否预约0关1开")
private Boolean reservationSwitch;
@Schema(description = "是否接单上线0关1开")
@ExcelProperty("是否接单上线0关1开")
private Boolean orderLimitSwitch;
@Schema(description = "是否开启体重配置0关1开")
@ExcelProperty("是否开启体重配置0关1开")
private Boolean weightSwitch;
@Schema(description = "创建时间")
@ExcelProperty("创建时间")
private LocalDateTime createTime;
@Schema(description = "创建人")
@ExcelProperty("创建人")
private String createBy;
@Schema(description = "修改人")
@ExcelProperty("修改人")
private String updateBy;
@Schema(description = "版本 乐观锁")
@ExcelProperty("版本 乐观锁")
private Integer version;
@Schema(description = "展示的权重")
@ExcelProperty("展示的权重")
private Integer top;
}

View File

@@ -0,0 +1,99 @@
package com.tashow.cloud.product.vo.prod;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
@Schema(description = "管理后台 - 商品新增/修改 Request VO")
@Data
public class ProdSaveReqVO {
@Schema(description = "产品ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "6943")
private Long prodId;
@Schema(description = "商品名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "商品名称不能为空")
private String prodName;
@Schema(description = "商品简称")
private String abbreviation;
@Schema(description = "seo标题", example = "李四")
private String seoName;
@Schema(description = "seo搜索")
private String seoSearch;
@Schema(description = "关键词")
private String keyword;
@Schema(description = "店铺id", example = "10843")
private Long shopId;
@Schema(description = "简要描述,卖点等")
private String brief;
@Schema(description = "品牌")
private String brand;
@Schema(description = "详细描述")
private String content;
@Schema(description = "商品编号")
private String prodNumber;
@Schema(description = "商品主图")
private String pic;
@Schema(description = "商品轮播图片,以,分割")
private String imgs;
@Schema(description = "默认是1表示正常状态, -1表示删除, 0下架", example = "2")
private Integer status;
@Schema(description = "商品分类", example = "14895")
private Long categoryId;
@Schema(description = "销量")
private Integer soldNum;
@Schema(description = "分享图")
private String shareImage;
@Schema(description = "分享话术")
private String shareContent;
@Schema(description = "是否开启区域0关1开")
private Boolean regionSwitch;
@Schema(description = "是否特殊时段0关1开")
private Boolean additionalSwitch;
@Schema(description = "是否特殊日期节假日周末什么的0关1开")
private Boolean additionalFeeSwitch;
@Schema(description = "是否紧急响应服务0关1开")
private Boolean emergencySwitch;
@Schema(description = "是否预约0关1开")
private Boolean reservationSwitch;
@Schema(description = "是否接单上线0关1开")
private Boolean orderLimitSwitch;
@Schema(description = "是否开启体重配置0关1开")
private Boolean weightSwitch;
@Schema(description = "创建人")
private String createBy;
@Schema(description = "修改人")
private String updateBy;
@Schema(description = "版本 乐观锁")
private Integer version;
@Schema(description = "展示的权重")
private Integer top;
}

View File

@@ -0,0 +1,16 @@
--- #################### 注册中心 + 配置中心相关配置 ####################
spring:
cloud:
nacos:
server-addr: 43.139.42.137:8848 # Nacos 服务器地址
username: nacos # Nacos 账号
password: nacos # Nacos 密码
discovery: # 【配置中心】配置项
namespace: 76667956-2ac2-4e05-906b-4bca4ebcc5f0 # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
metadata:
version: 1.0.0 # 服务实例的版本号,可用于灰度发布
config: # 【注册中心】配置项
namespace: 76667956-2ac2-4e05-906b-4bca4ebcc5f0 # 命名空间。这里使用 dev 开发环境
group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP

View File

@@ -0,0 +1,12 @@
server:
port: 48083
spring:
application:
name: product-server
profiles:
active: local
config:
import:
- optional:classpath:application-${spring.profiles.active}.yaml # 加载【本地】配置
- optional:nacos:application.yaml # 加载【Nacos】的配置
- optional:nacos:${spring.application.name}-${spring.profiles.active}.yaml # 加载【Nacos】的配置

View File

@@ -0,0 +1,35 @@
<!--
<?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.tashow.cloud.product.mapper.CategoryMapper">
<resultMap id="BaseResultMap" type="com.tashow.cloud.product.domain.Category">
<id property="categoryId" column="category_id" />
<result property="shopId" column="shop_id" />
<result property="parentId" column="parent_id" />
<result property="categoryName" column="category_name" />
<result property="icon" column="icon" />
<result property="pic" column="pic" />
<result property="describe" column="describe" />
<result property="tag" column="tag" />
<result property="seq" column="seq" />
<result property="status" column="status" />
<result property="createTime" column="create_time" />
<result property="creator" column="creator" />
<result property="grade" column="grade" />
<result property="updateTime" column="update_time" />
<result property="updater" column="updater" />
</resultMap>
<select id="listByParentId" resultType="com.tashow.cloud.product.domain.Category">
select category_id,icon,category_name,`seq`,`status`,pic from tz_category where parent_id = #{parentId} and `status` = 1 order by seq
</select>
<select id="tableCategory" resultType="com.tashow.cloud.product.domain.Category">
select category_id ,parent_id ,category_name,pic,seq,status from tz_category where shop_id = #{shopId} order by seq
</select>
</mapper>
-->