商品测试

dev798
wxy 2024-05-11 15:29:32 +08:00
parent 2de2e966c3
commit 950a623a74
18 changed files with 330 additions and 225 deletions

View File

@ -0,0 +1,32 @@
package com.nuyu.product.domain;
import com.muyu.common.core.web.controller.BaseController;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@AllArgsConstructor
@NoArgsConstructor
public class MallProductText extends BaseController implements Serializable {
@Serial
private static final long serialVersionUID = 1L;
private Integer pageSize=10;
private Integer pageNum=1;
private Integer id;
private String name;
}

View File

@ -1,24 +1,32 @@
package com.nuyu.product.domain;
import lombok.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import java.io.Serial;
/**
* mall_product_type_info
*
* @author muyu
* @date 2024-04-27
*/
@Data
public class MallProductTypeInfo extends BaseEntity
{
@Serial
private static final long serialVersionUID = 1L;
/** 分类id */
private Long catId;
private Integer pageSize=10;
private Integer pageNum =1;
/** 分类名称 */
@Excel(name = "分类名称")
private String name;
@ -55,99 +63,6 @@ public class MallProductTypeInfo extends BaseEntity
@Excel(name = "乐观锁")
private Long revision;
public void setCatId(Long catId)
{
this.catId = catId;
}
public Long getCatId()
{
return catId;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setParentCid(Long parentCid)
{
this.parentCid = parentCid;
}
public Long getParentCid()
{
return parentCid;
}
public void setCatLevel(Long catLevel)
{
this.catLevel = catLevel;
}
public Long getCatLevel()
{
return catLevel;
}
public void setShowStatus(Integer showStatus)
{
this.showStatus = showStatus;
}
public Integer getShowStatus()
{
return showStatus;
}
public void setSort(Long sort)
{
this.sort = sort;
}
public Long getSort()
{
return sort;
}
public void setIcon(String icon)
{
this.icon = icon;
}
public String getIcon()
{
return icon;
}
public void setProductUnit(String productUnit)
{
this.productUnit = productUnit;
}
public String getProductUnit()
{
return productUnit;
}
public void setProductCount(Long productCount)
{
this.productCount = productCount;
}
public Long getProductCount()
{
return productCount;
}
public void setRevision(Long revision)
{
this.revision = revision;
}
public Long getRevision()
{
return revision;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -161,6 +76,8 @@ public class MallProductTypeInfo extends BaseEntity
.append("productUnit", getProductUnit())
.append("productCount", getProductCount())
.append("revision", getRevision())
.append("pageSize",getPageSize())
.append("pageNum",getPageNum())
.toString();
}
}

View File

@ -0,0 +1,20 @@
package com.nuyu.product.resp;
import com.nuyu.product.domain.MallProductTypeInfo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 9:12
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class MallProductTypeInfoVO extends MallProductTypeInfo {
private List<MallProductTypeInfoVO> childrenList;
}

View File

@ -0,0 +1,35 @@
package com.muyu.product.controller;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
import com.muyu.common.core.web.domain.AjaxResult;
import com.muyu.product.service.MallProductTextService;
import com.nuyu.product.domain.MallProductText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:21
*/
@RestController
@RequestMapping("/lian")
public class MallProductTextController {
@Autowired
private MallProductTextService mallProductTextService;
@GetMapping("/list")
public AjaxResult list(MallProductText mallProductText){
PageInfo<MallProductText>info = mallProductTextService.list(mallProductText);
return AjaxResult.success(info);
}
@DeleteMapping("/delete")
public Result delete(Long id){
return Result.success(mallProductTextService.deleteMallProductTextById(id));
}
}

View File

@ -10,6 +10,7 @@ import com.muyu.product.service.MallProductTypeInfoService;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.dto.Pur;
import com.nuyu.product.req.BookReq;
import com.nuyu.product.resp.MallProductTypeInfoVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -44,14 +45,6 @@ public class MallProductTypeInfoController extends BaseController
private MallProductTypeInfoService mallProductTypeInfoService;
@GetMapping("/test")
@RequiresPermissions("product:type:test")
public Result<TableDataInfo<MallProductTypeInfo>> list(MallProductTypeInfo mallProductTypeInfo)
{
startPage();
List<MallProductTypeInfo> list = mallProductTypeInfoService.selectMallProductTypeInfoList(mallProductTypeInfo);
return getDataTable(list);
}
/**
*
@ -67,6 +60,12 @@ public class MallProductTypeInfoController extends BaseController
return AjaxResult.success(info);
}
@GetMapping("/listAll")
public Result<List<MallProductTypeInfoVO>>listAll(MallProductTypeInfo mallProductTypeInfo){
List<MallProductTypeInfoVO>list=mallProductTypeInfoService.listAll(mallProductTypeInfo);
return Result.success(list);
}
/**
*
*/

View File

@ -1,36 +0,0 @@
package com.muyu.product.controller;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.web.domain.AjaxResult;
import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.product.service.ProductTypeAttrValueService;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.domain.ProductTypeAttrValue;
import com.nuyu.product.req.BookReq;
import io.swagger.annotations.ApiOperation;
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;
/**
* @Author: wangxinyuan
* @Date: 2024/5/8 7:13
*/
@RestController
@RequestMapping("/text")
public class ProductTypeAttrValueController {
@Autowired
private ProductTypeAttrValueService productTypeAttrValueService;
@GetMapping("/list")
public AjaxResult list(ProductTypeAttrValue productTypeAttrValue){
PageInfo<ProductTypeAttrValue> info=productTypeAttrValueService.list(productTypeAttrValue);
return AjaxResult.success(info);
}
}

View File

@ -0,0 +1,101 @@
package com.muyu.product.exception;
import java.io.PrintStream;
import java.io.PrintWriter;
public class ProductException extends RuntimeException{
public ProductException() {
super();
}
@Override
public int hashCode() {
return super.hashCode();
}
@Override
public boolean equals(Object obj) {
return super.equals(obj);
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
public ProductException(String message) {
super(message);
}
public ProductException(String message, Throwable cause) {
super(message, cause);
}
public ProductException(Throwable cause) {
super(cause);
}
protected ProductException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}
@Override
public String getMessage() {
return super.getMessage();
}
@Override
public String getLocalizedMessage() {
return super.getLocalizedMessage();
}
@Override
public synchronized Throwable getCause() {
return super.getCause();
}
@Override
public synchronized Throwable initCause(Throwable cause) {
return super.initCause(cause);
}
@Override
public String toString() {
return super.toString();
}
@Override
protected void finalize() throws Throwable {
super.finalize();
}
@Override
public void printStackTrace() {
super.printStackTrace();
}
@Override
public void printStackTrace(PrintStream s) {
super.printStackTrace(s);
}
@Override
public void printStackTrace(PrintWriter s) {
super.printStackTrace(s);
}
@Override
public synchronized Throwable fillInStackTrace() {
return super.fillInStackTrace();
}
@Override
public StackTraceElement[] getStackTrace() {
return super.getStackTrace();
}
@Override
public void setStackTrace(StackTraceElement[] stackTrace) {
super.setStackTrace(stackTrace);
}
}

View File

@ -0,0 +1,19 @@
package com.muyu.product.mapper;
import com.nuyu.product.domain.MallProductText;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:22
*/
@Mapper
public interface MallProductTextMapper {
List<MallProductText> list(MallProductText mallProductText);
String deleteMallProductTextById(Long id);
}

View File

@ -1,15 +0,0 @@
package com.muyu.product.mapper;
import com.nuyu.product.domain.ProductTypeAttrValue;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/8 7:14
*/
@Mapper
public interface ProductTypeAttrValueMapper {
List<ProductTypeAttrValue> list(ProductTypeAttrValue productTypeAttrValue);
}

View File

@ -0,0 +1,37 @@
package com.muyu.product.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.product.mapper.MallProductTextMapper;
import com.muyu.product.service.MallProductTextService;
import com.nuyu.product.domain.MallProductText;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:22
*/
@Service
public class MallProductTextServiceImpl implements MallProductTextService {
@Autowired
private MallProductTextMapper mallProductTextMapper;
@Override
public PageInfo<MallProductText> list(MallProductText mallProductText) {
PageHelper.startPage(mallProductText.getPageNum(),mallProductText.getPageSize());
List<MallProductText>list=mallProductTextMapper.list(mallProductText);
PageInfo<MallProductText>info=new PageInfo<>(list);
return info;
}
@Override
public String deleteMallProductTextById(Long id) {
return mallProductTextMapper.deleteMallProductTextById(id);
}
}

View File

@ -1,6 +1,7 @@
package com.muyu.product.service.Impl;
import java.util.List;
import java.util.stream.Collectors;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
@ -8,6 +9,8 @@ import com.muyu.product.service.MallProductTypeInfoService;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.dto.Pur;
import com.nuyu.product.req.BookReq;
import com.nuyu.product.resp.MallProductTypeInfoVO;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.muyu.product.mapper.MallProductTypeInfoMapper;
@ -107,4 +110,35 @@ public class MallProductTypeInfoServiceImpl implements MallProductTypeInfoServic
PageInfo<MallProductTypeInfo> pageInfo = new PageInfo<>(products);
return pageInfo;
}
public static final Long PARENT_ID=0L;
@Override
public List<MallProductTypeInfoVO> listAll(MallProductTypeInfo mallProductTypeInfo) {
/**
* 1.
* 2.
* 3.
*/
List<MallProductTypeInfo> mallProductTypeInfos = selectMallProductTypeInfoList(mallProductTypeInfo);
List<MallProductTypeInfoVO>returnList= mallProductTypeInfos.stream().filter(item->PARENT_ID.equals(item.getParentCid())).map(newItem->{
MallProductTypeInfoVO mallProductTypeInfoVO = new MallProductTypeInfoVO();
BeanUtils.copyProperties(newItem,mallProductTypeInfoVO);
return mallProductTypeInfoVO;
}).map(mallProductTypeInfoVO -> {
mallProductTypeInfoVO.setChildrenList(packageChildrenList(mallProductTypeInfoVO,mallProductTypeInfos));
return mallProductTypeInfoVO;
}).collect(Collectors.toList());
return returnList;
}
private List<MallProductTypeInfoVO> packageChildrenList(MallProductTypeInfoVO mallProductTypeInfoVO, List<MallProductTypeInfo> mallProductTypeInfos) {
Long parentId = mallProductTypeInfoVO.getCatId();
List<MallProductTypeInfoVO> collect = mallProductTypeInfos.stream().filter(item -> parentId.equals(item.getParentCid())).map(newItem -> {
MallProductTypeInfoVO returnVo = new MallProductTypeInfoVO();
BeanUtils.copyProperties(newItem, returnVo);
returnVo.setChildrenList(packageChildrenList(returnVo, mallProductTypeInfos));
return returnVo;
}).collect(Collectors.toList());
return collect;
}
}

View File

@ -1,30 +0,0 @@
package com.muyu.product.service.Impl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.product.mapper.ProductTypeAttrValueMapper;
import com.muyu.product.service.ProductTypeAttrValueService;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.domain.ProductTypeAttrValue;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* @Author: wangxinyuan
* @Date: 2024/5/8 7:14
*/
@Service
public class ProductTypeAttrValueServiceImpl implements ProductTypeAttrValueService {
@Autowired
private ProductTypeAttrValueMapper productTypeAttrValueMapper;
@Override
public PageInfo<ProductTypeAttrValue> list(ProductTypeAttrValue productTypeAttrValue) {
PageHelper.startPage(productTypeAttrValue.getPageNum(),productTypeAttrValue.getPageSize());
List<ProductTypeAttrValue> products = productTypeAttrValueMapper.list(productTypeAttrValue);
PageInfo<ProductTypeAttrValue> pageInfo = new PageInfo<>(products);
return pageInfo;
}
}

View File

@ -0,0 +1,16 @@
package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.nuyu.product.domain.MallProductText;
/**
* @Author: wangxinyuan
* @Date: 2024/5/10 8:22
*/
public interface MallProductTextService {
PageInfo<MallProductText> list(MallProductText mallProductText);
String deleteMallProductTextById(Long id);
}

View File

@ -3,6 +3,7 @@ package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.req.BookReq;
import com.nuyu.product.resp.MallProductTypeInfoVO;
import java.util.List;
@ -64,4 +65,6 @@ public interface MallProductTypeInfoService
public int deleteMallProductTypeInfoByCatId(Long catId);
PageInfo<MallProductTypeInfo> list(BookReq bookReq);
List<MallProductTypeInfoVO> listAll(MallProductTypeInfo mallProductTypeInfo);
}

View File

@ -1,18 +0,0 @@
package com.muyu.product.service;
import com.github.pagehelper.PageInfo;
import com.muyu.product.controller.ProductTypeAttrValueController;
import com.nuyu.product.domain.MallProductTypeInfo;
import com.nuyu.product.domain.ProductTypeAttrValue;
import com.nuyu.product.req.BookReq;
/**
* @Author: wangxinyuan
* @Date: 2024/5/8 7:14
*/
public interface ProductTypeAttrValueService {
PageInfo<ProductTypeAttrValue> list(ProductTypeAttrValue productTypeAttrValue);
}

View File

@ -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.muyu.product.mapper.MallProductTextMapper">
<delete id="deleteMallProductTextById">
delete from mall_product_text where id = #{id}
</delete>
<select id="list" resultType="com.nuyu.product.domain.MallProductText">
select id , name from mall_product_text
</select>
</mapper>

View File

@ -1,25 +0,0 @@
<?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.muyu.product.mapper.ProductTypeAttrValueMapper">
<resultMap type="com.nuyu.product.domain.ProductTypeAttrValue" id="MallProductInfoResult">
<result property="id" column="id" />
<result property="typeAttrValue" column="type_attr_value" />
<result property="inputMethod" column="input_method" />
<result property="createTime" column="create_time" />
<result property="updateTime" column="update_time" />
<result property="idDelete" column="id_delete" />
<result property="createBy" column="create_by" />
</resultMap>
<sql id="selectMallProductInfoVo">
select id, type_attr_value, input_method, create_time, update_time, id_delete, create_by from mall_product_info
</sql>
<select id="list" resultType="com.nuyu.product.domain.ProductTypeAttrValue">
<include refid="selectMallProductInfoVo"/>
</select>
</mapper>

View File

@ -12,6 +12,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableAdminServer
@SpringBootApplication
public class MuYuMonitorApplication {
public static void main (String[] args) {
SpringApplication.run(MuYuMonitorApplication.class, args);
}