diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java index c3c653d..89e7d2f 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/FhMiniController.java @@ -70,6 +70,9 @@ public class FhMiniController extends BaseController { @Autowired private UserVipRecordService userVipRecordService; + @Autowired + private ProductService productService; + //@TokenCheck @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") @@ -316,4 +319,18 @@ public class FhMiniController extends BaseController { return AjaxResult.error("购买支付失败!"); } } + + //@TokenCheck + @ApiOperation(value="查询产品列表") + @GetMapping(value = "/listProduct") + public AjaxResult listProduct(){ + return AjaxResult.success(productService.queryFrontList()); + } + + //@TokenCheck + @ApiOperation(value="查询产品详情") + @GetMapping(value = "/queryProductDetails/{id}") + public AjaxResult queryProductDetails(@ApiParam("主键id") @PathVariable("id") Long id){ + return AjaxResult.success(productService.queryFrontDetails(id)); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/ProductController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/ProductController.java new file mode 100644 index 0000000..cb2cb88 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/ProductController.java @@ -0,0 +1,80 @@ +package com.bnyer.img.controller; + +import com.alibaba.fastjson.JSON; +import com.bnyer.common.core.web.controller.BaseController; +import com.bnyer.common.core.web.domain.AjaxResult; +import com.bnyer.common.core.web.page.TableDataInfo; +import com.bnyer.img.domain.Product; +import com.bnyer.img.dto.ProductDto; +import com.bnyer.img.dto.ProductPageDto; +import com.bnyer.img.dto.StatusDto; +import com.bnyer.img.service.ProductService; +import com.github.pagehelper.PageHelper; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; + +@Api(value = "【图文平台】产品接口",tags = "【图文平台】产品接口") +@RestController +@RequestMapping("/img/product") +@Slf4j +public class ProductController extends BaseController { + + @Autowired + private ProductService productService; + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="查询产品分页") + @PostMapping("/page") + public TableDataInfo pageProduct(@RequestBody @ApiParam("分页对象") ProductPageDto dto){ + PageHelper.startPage(dto.getPageNum(), dto.getPageSize()); + List products = productService.queryPage(dto); + return getDataTable(products); + } + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="新增产品") + @PostMapping(value = "/insert") + public AjaxResult insertProduct(@Validated @RequestBody @ApiParam("产品对象") ProductDto dto){ + log.debug("【图文平台后台】新增产品参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(productService.insert(dto.extractParam())); + } + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="修改产品") + @PostMapping(value = "/update") + public AjaxResult updateProduct(@Validated @RequestBody @ApiParam("产品对象")ProductDto dto){ + log.debug("【图文平台后台】修改产品参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(productService.update(dto.extractParam())); + } + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="删除产品") + @DeleteMapping(value = "/delete/{ids}") + public AjaxResult deleteProduct(@PathVariable @ApiParam("主键ids") List ids){ + log.debug("【图文平台后台】删除产品参数为:{}", JSON.toJSONString(ids)); + return AjaxResult.success(productService.delete(ids)); + } + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="查询产品详情") + @GetMapping(value = "/details/{id}") + public AjaxResult detailsProduct(@PathVariable @ApiParam("主键id") Long id){ + log.debug("【图文平台后台】查询产品详情参数为:{}", id); + return AjaxResult.success(productService.details(id)); + } + + //@RequiresPermissions("system:config:list") + @ApiOperation(value="变更type显示状态") + @PostMapping(value = "/changeStatus") + public AjaxResult changeStatus(@Validated @RequestBody @ApiParam("type状态对象") StatusDto dto){ + log.debug("【图文平台后台】变更type参数为:{}", JSON.toJSONString(dto)); + return AjaxResult.success(productService.changeStatus(dto.getId(),dto.getStatus())); + } +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java index fd0ee53..400db28 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/TiktokMiniController.java @@ -68,6 +68,12 @@ public class TiktokMiniController extends BaseController { @Autowired private UserVipService userVipService; + @Autowired + private UserVipRecordService userVipRecordService; + + @Autowired + private ProductService productService; + //@TokenCheck @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") @@ -303,4 +309,31 @@ public class TiktokMiniController extends BaseController { public AjaxResult queryUserVipList(){ return AjaxResult.success(userVipService.queryFront()); } + + //@TokenCheck + @ApiOperation(value="支付购买用户会员vip") + @PostMapping(value = "/payUserVip") + public AjaxResult payUserVip(@Validated @RequestBody @ApiParam("购买会员vip对象") PayUserVipDto dto){ + log.debug("【微信图文小程序】支付购买用户会员vip参数为:{}", JSON.toJSONString(dto)); + boolean b = userVipRecordService.payUserVip(dto); + if(b){ + return AjaxResult.success("购买支付成功!"); + }else{ + return AjaxResult.error("购买支付失败!"); + } + } + + //@TokenCheck + @ApiOperation(value="查询产品列表") + @GetMapping(value = "/listProduct") + public AjaxResult listProduct(){ + return AjaxResult.success(productService.queryFrontList()); + } + + //@TokenCheck + @ApiOperation(value="查询产品详情") + @GetMapping(value = "/queryProductDetails/{id}") + public AjaxResult queryProductDetails(@ApiParam("主键id") @PathVariable("id") Long id){ + return AjaxResult.success(productService.queryFrontDetails(id)); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java index 32841ce..18f0336 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/controller/WxMiniController.java @@ -70,6 +70,9 @@ public class WxMiniController extends BaseController { @Autowired private UserVipRecordService userVipRecordService; + @Autowired + private ProductService productService; + //@TokenCheck @ApiOperation(value="查询banner列表") @GetMapping(value = "/listBanner") @@ -316,4 +319,18 @@ public class WxMiniController extends BaseController { return AjaxResult.error("购买支付失败!"); } } + + //@TokenCheck + @ApiOperation(value="查询产品列表") + @GetMapping(value = "/listProduct") + public AjaxResult listProduct(){ + return AjaxResult.success(productService.queryFrontList()); + } + + //@TokenCheck + @ApiOperation(value="查询产品详情") + @GetMapping(value = "/queryProductDetails/{id}") + public AjaxResult queryProductDetails(@ApiParam("主键id") @PathVariable("id") Long id){ + return AjaxResult.success(productService.queryFrontDetails(id)); + } } diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/Product.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/Product.java new file mode 100644 index 0000000..7812939 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/Product.java @@ -0,0 +1,104 @@ +package com.bnyer.img.domain; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import lombok.AllArgsConstructor; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; +import lombok.ToString; + +@ApiModel(value="com-bnyer-img-domain-Product") +@Getter +@Setter +@ToString +@AllArgsConstructor +@NoArgsConstructor +@TableName(value = "img_product") +public class Product extends BaseDomain { + /** + * 主键id + */ + @TableId(value = "id", type = IdType.AUTO) + @ApiModelProperty(value="主键id") + private Long id; + + /** + * 商品名称 + */ + @TableField(value = "product_name") + @ApiModelProperty(value="商品名称") + private String productName; + + /** + * 商品原价 + */ + @TableField(value = "product_origin_price") + @ApiModelProperty(value="商品原价") + private BigDecimal productOriginPrice; + + /** + * 商品售价 + */ + @TableField(value = "product_sale_price") + @ApiModelProperty(value="商品售价") + private BigDecimal productSalePrice; + + /** + * 折扣 + */ + @TableField(value = "product_discount") + @ApiModelProperty(value="折扣") + private String productDiscount; + + /** + * 节省钱数 + */ + @TableField(value = "product_saved_money") + @ApiModelProperty(value="节省钱数") + private String productSavedMoney; + + /** + * 库存量 + */ + @TableField(value = "product_num") + @ApiModelProperty(value="库存量") + private Integer productNum; + + /** + * 商品描述 + */ + @TableField(value = "product_desc") + @ApiModelProperty(value="商品描述") + private String productDesc; + + /** + * 商品图片 + */ + @TableField(value = "product_img") + @ApiModelProperty(value="商品图片") + private String productImg; + + /** + * 商品类型(0->直充;1->卡密) + */ + @TableField(value = "product_type") + @ApiModelProperty(value="商品类型(0->直充;1->卡密)") + private String productType; + + /** + * 商品使用说明 + */ + @TableField(value = "product_use_desc") + @ApiModelProperty(value="商品使用说明") + private String productUseDesc; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/ProductOrder.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/ProductOrder.java index dbdf5da..bb30cd2 100644 --- a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/ProductOrder.java +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/domain/ProductOrder.java @@ -112,7 +112,7 @@ public class ProductOrder implements Serializable { * 创建时间 */ @TableField(value = "create_time") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @ApiModelProperty(value="创建时间") private Date createTime; @@ -120,7 +120,7 @@ public class ProductOrder implements Serializable { * 更新时间 */ @TableField(value = "update_time") - @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8") @ApiModelProperty(value="更新时间") private Date updateTime; diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductDto.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductDto.java new file mode 100644 index 0000000..e037e56 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductDto.java @@ -0,0 +1,80 @@ +package com.bnyer.img.dto; + +import com.bnyer.img.domain.Product; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; +import java.io.Serializable; +import java.math.BigDecimal; + + +@Getter +@Setter +@ApiModel("产品接收类") +public class ProductDto implements Serializable { + + @ApiModelProperty(value="主键id") + private Long id; + + @NotBlank(message = "商品名称不能为空!") + @ApiModelProperty(value="商品名称") + private String productName; + + @NotBlank(message = "商品原价不能为空!") + @ApiModelProperty(value="商品原价") + private String productOriginPrice; + + @NotBlank(message = "商品售价不能为空!") + @ApiModelProperty(value="商品售价") + private String productSalePrice; + + @NotBlank(message = "折扣不能为空!") + @ApiModelProperty(value="折扣") + private String productDiscount; + + @NotBlank(message = "节省钱数不能为空!") + @ApiModelProperty(value="节省钱数") + private String productSavedMoney; + + @NotNull(message = "库存量不能为空!") + @ApiModelProperty(value="库存量") + private Integer productNum; + + @NotBlank(message = "商品描述不能为空!") + @ApiModelProperty(value="商品描述") + private String productDesc; + + @NotBlank(message = "商品图片不能为空!") + @ApiModelProperty(value="商品图片") + private String productImg; + + @NotBlank(message = "商品类型不能为空!") + @ApiModelProperty(value="商品类型(0->直充;1->卡密)") + private String productType; + + @NotBlank(message = "商品使用说明不能为空!") + @ApiModelProperty(value="商品使用说明") + private String productUseDesc; + + public Product extractParam(){ + Product product = new Product(); + if(this.getId() != null){ + product.setId(this.getId()); + } + product.setProductName(this.getProductName()); + product.setProductOriginPrice(new BigDecimal(this.getProductOriginPrice())); + product.setProductSalePrice(new BigDecimal(this.getProductSalePrice())); + product.setProductDiscount(this.getProductDiscount()); + product.setProductSavedMoney(this.getProductSavedMoney()); + product.setProductNum(this.getProductNum()); + product.setProductDesc(this.getProductDesc()); + product.setProductImg(this.getProductImg()); + product.setProductType(this.getProductType()); + product.setProductUseDesc(this.getProductUseDesc()); + return product; + } +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductPageDto.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductPageDto.java new file mode 100644 index 0000000..7842697 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/dto/ProductPageDto.java @@ -0,0 +1,21 @@ +package com.bnyer.img.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +@Getter +@Setter +@ApiModel("商品分页接收类") +public class ProductPageDto extends BasePageDto { + + @ApiModelProperty(value="商品名称") + private String productName; + + @ApiModelProperty(value="商品类型(0->直充;1->卡密)") + private String productType; + + @ApiModelProperty(value="是否显示") + private String isShow; +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/ProductMapper.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/ProductMapper.java new file mode 100644 index 0000000..91e07b0 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/mapper/ProductMapper.java @@ -0,0 +1,25 @@ +package com.bnyer.img.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.bnyer.img.domain.Product; +import com.bnyer.img.vo.ProductVo; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +@Mapper +public interface ProductMapper extends BaseMapper { + + /** + * 查询前端产品列表 + * @return - + */ + List queryFrontList(); + + /** + * 商品详情 + * @param id 主键id + * @return - + */ + ProductVo queryFrontDetails(Long id); +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/ProductService.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/ProductService.java new file mode 100644 index 0000000..707c190 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/ProductService.java @@ -0,0 +1,66 @@ +package com.bnyer.img.service; + +import com.bnyer.img.domain.Product; +import com.bnyer.img.dto.ProductPageDto; +import com.bnyer.img.vo.ProductVo; + +import java.util.List; + +public interface ProductService { + + /** + * 新增商品 + * @param product 商品 + * @return - + */ + int insert(Product product); + + /** + * 编辑商品 + * @param product 商品 + * @return - + */ + int update(Product product); + + /** + * 批量删除商品 + * @param ids 商品ids + * @return - + */ + int delete(List ids); + + /** + * 查询商品分页 + * @param params 分页参数 + * @return - + */ + List queryPage(ProductPageDto params); + + /** + * 查询商品详情 + * @param id 主键id + * @return - + */ + Product details(Long id); + + /** + * 查询前端商品列表 + * @return - + */ + List queryFrontList(); + + /** + * 查询前端盖商品详情 + * @param id 主键id + * @return - + */ + ProductVo queryFrontDetails(Long id); + + /** + * 变更显示状态 + * @param id 主键id + * @param status 状态 + * @return - + */ + int changeStatus(Long id,String status); +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/ProductServiceImpl.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/ProductServiceImpl.java new file mode 100644 index 0000000..5c38710 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/service/impl/ProductServiceImpl.java @@ -0,0 +1,88 @@ +package com.bnyer.img.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.bnyer.common.core.utils.StringUtils; +import com.bnyer.img.domain.Banner; +import com.bnyer.img.domain.Product; +import com.bnyer.img.dto.ProductPageDto; +import com.bnyer.img.mapper.ProductMapper; +import com.bnyer.img.service.ProductService; +import com.bnyer.img.vo.ProductVo; +import lombok.extern.slf4j.Slf4j; +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; + +@Service +@Slf4j +public class ProductServiceImpl implements ProductService { + + @Autowired + private ProductMapper productMapper; + + @Override + @Transactional(rollbackFor = Exception.class) + public int insert(Product product) { + product.setCreateTime(new Date()); + product.setUpdateTime(new Date()); + product.setIsShow("1"); + return productMapper.insert(product); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int update(Product product) { + product.setUpdateTime(new Date()); + return productMapper.updateById(product); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int delete(List ids) { + return productMapper.deleteBatchIds(ids); + } + + @Override + public List queryPage(ProductPageDto params) { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + if(StringUtils.isNotBlank(params.getProductName())){ + wrapper.like(Product::getProductName, params.getProductName()); + } + if(StringUtils.isNotBlank(params.getProductType())){ + wrapper.eq(Product::getProductType, params.getProductType()); + } + if(StringUtils.isNotBlank(params.getIsShow())){ + wrapper.eq(Product::getIsShow, params.getIsShow()); + } + return productMapper.selectList(wrapper); + } + + @Override + public Product details(Long id) { + return productMapper.selectById(id); + } + + @Override + public List queryFrontList() { + return productMapper.queryFrontList(); + } + + @Override + public ProductVo queryFrontDetails(Long id) { + return productMapper.queryFrontDetails(id); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public int changeStatus(Long id, String status) { + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.eq(Product::getId, id); + Product product = new Product(); + product.setIsShow(status); + return productMapper.update(product,wrapper); + } +} diff --git a/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/ProductVo.java b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/ProductVo.java new file mode 100644 index 0000000..42e93f9 --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/java/com/bnyer/img/vo/ProductVo.java @@ -0,0 +1,50 @@ +package com.bnyer.img.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Getter; +import lombok.Setter; + +import java.io.Serializable; +import java.math.BigDecimal; + + +@Getter +@Setter +@ApiModel("banner响应体") +public class ProductVo implements Serializable { + @ApiModelProperty(value="主键id") + private Long id; + + @ApiModelProperty(value="商品名称") + private String productName; + + @ApiModelProperty(value="商品原价") + private BigDecimal productOriginPrice; + + @ApiModelProperty(value="商品售价") + private BigDecimal productSalePrice; + + @ApiModelProperty(value="折扣") + private String productDiscount; + + @ApiModelProperty(value="节省钱数") + private String productSavedMoney; + + @ApiModelProperty(value="库存量") + private Integer productNum; + + @ApiModelProperty(value="商品描述") + private String productDesc; + + @ApiModelProperty(value="商品图片") + private String productImg; + + @ApiModelProperty(value="商品类型(0->直充;1->卡密)") + private String productType; + + @ApiModelProperty(value="商品使用说明") + private String productUseDesc; + + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/ProductMapper.xml b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/ProductMapper.xml new file mode 100644 index 0000000..cfbc67d --- /dev/null +++ b/bnyer-services/bnyer-img/src/main/resources/com/bnyer/img/mapper/ProductMapper.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + id, product_name, product_origin_price, product_sale_price, product_discount, product_saved_money, + product_num, product_desc, product_img, product_type, product_use_desc, create_time, + update_time, is_show, sort + + + + \ No newline at end of file