完成的商品搜索和条件功能
This commit is contained in:
41
moved/product/product-rest/pom.xml
Normal file
41
moved/product/product-rest/pom.xml
Normal file
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>product</artifactId>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>product-rest</artifactId>
|
||||
<description>提供 system 服务的 Rest 接口的实现,提供对外调用</description>
|
||||
|
||||
<dependencies>
|
||||
<!-- Mall 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>product-biz</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Web 相关 -->
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-web</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-security</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>cn.iocoder.mall</groupId>
|
||||
<artifactId>mall-spring-boot-starter-swagger</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,54 @@
|
||||
package cn.iocoder.mall.product.rest.controller.attr;
|
||||
|
||||
import cn.iocoder.common.framework.vo.CommonResult;
|
||||
import cn.iocoder.common.framework.vo.PageResult;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrSimpleWithValueBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrValueBO;
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrWithValueBO;
|
||||
import cn.iocoder.mall.product.biz.dto.attr.*;
|
||||
import cn.iocoder.mall.product.biz.service.attr.ProductAttrService;
|
||||
import cn.iocoder.mall.product.rest.convert.attr.ProductAttrConvert;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrPageRequest;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrAddRequest;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrUpdateRequest;
|
||||
import cn.iocoder.mall.product.rest.request.attr.ProductAttrValueAddRequest;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrPageResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrSimpleResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProdutAttrResponse;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrValueResponse;
|
||||
import cn.iocoder.mall.security.core.context.AdminSecurityContextHolder;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 商品规格
|
||||
*
|
||||
* @author lanmao
|
||||
* @version 1.0
|
||||
* @date 2020/05/06 16:36
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("admins")
|
||||
@Api("商品规格")
|
||||
public class AdminsProductAttrController {
|
||||
|
||||
@Autowired
|
||||
private ProductAttrService productAttrService;
|
||||
|
||||
@GetMapping("/attr/tree")
|
||||
@ApiOperation(value = "获得规格树结构", notes = "该接口返回的信息更为精简。一般用于前端缓存数据字典到本地。")
|
||||
public CommonResult<List<AdminsProductAttrSimpleResponse>> tree() {
|
||||
// 查询全列表
|
||||
List<ProductAttrSimpleWithValueBO> result = productAttrService.getProductAttrList();
|
||||
return CommonResult.success(ProductAttrConvert.INSTANCE.convertSimple(result));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.product.rest.controller.favorite;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 用户收藏
|
||||
* @author xiaofeng
|
||||
* @date 2019/07/07 11:06
|
||||
* @version 1.0
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("users/favorite")
|
||||
@Api("用户收藏")
|
||||
// TODO FROM 芋艿 to ilnhj:controller 分包的话,还是按照模块。然后通过 Admins 和 Users 前缀,区分不同的 Controlller
|
||||
public class UserFavoriteController {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cn.iocoder.mall.product.rest.convert.attr;
|
||||
|
||||
import cn.iocoder.mall.product.biz.bo.attr.ProductAttrSimpleWithValueBO;
|
||||
import cn.iocoder.mall.product.rest.response.attr.AdminsProductAttrSimpleResponse;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.Mappings;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ProductAttrConvert {
|
||||
|
||||
ProductAttrConvert INSTANCE = Mappers.getMapper(ProductAttrConvert.class);
|
||||
|
||||
@Mappings({})
|
||||
List<AdminsProductAttrSimpleResponse> convertSimple(List<ProductAttrSimpleWithValueBO> simpleList);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.product.rest.request.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
|
||||
@ApiModel("商品 - 规格模块 - 商品规格添加 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrAddRequest {
|
||||
|
||||
@ApiModelProperty(name = "name", value = "规格名", required = true, example = "颜色")
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cn.iocoder.mall.product.rest.request.attr;
|
||||
|
||||
import cn.iocoder.common.framework.vo.PageParam;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
@ApiModel("商品 - 规格模块 - 商品规格 Request")
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrPageRequest extends PageParam {
|
||||
|
||||
@ApiModelProperty(value = "商品规格名字,模糊匹配", example = "材料")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package cn.iocoder.mall.product.rest.request.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品 - 规格模块 - 商品规格修改 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrUpdateRequest {
|
||||
|
||||
@ApiModelProperty(name = "id", value = "规格编号", required = true, example = "1")
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(name = "name", value = "规格名", required = true, example = "颜色")
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.product.rest.request.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
@ApiModel("商品 - 规格模块 - 商品规格值添加 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrValueAddRequest {
|
||||
|
||||
@ApiModelProperty(name = "attrId", value = "规格编号", required = true, example = "1")
|
||||
@NotNull(message = "规格编号不能为空")
|
||||
private Integer attrId;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty(name = "name", value = "规格值名", required = true, example = "红色")
|
||||
@NotEmpty(message = "规格值名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package cn.iocoder.mall.product.rest.request.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* Product 规格值修改 DTO
|
||||
* <p>
|
||||
* 注意,不允许修改所属规格
|
||||
*/
|
||||
@ApiModel("商品 - 规格模块 - 商品规格值修改 Request")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class ProductAttrValueUpdateRequest {
|
||||
|
||||
@ApiModelProperty(name = "id", value = "规格值编号", required = true, example = "1")
|
||||
@NotNull(message = "规格值编号不能为空")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty(name = "id", value = "规格值编号", required = true, example = "1")
|
||||
@NotEmpty(message = "规格名不能为空")
|
||||
private String name;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package cn.iocoder.mall.product.rest.response.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel("商品管理 - 商品规格模块 - 商品规格分页信息 Response")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductAttrPageResponse {
|
||||
|
||||
/**
|
||||
* 规格编号
|
||||
*/
|
||||
private Integer id;
|
||||
/**
|
||||
* 规格名
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 规格值数组
|
||||
*/
|
||||
private List<ProductAttrValue> values;
|
||||
|
||||
@ApiModel("规格值")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class ProductAttrValue {
|
||||
|
||||
/**
|
||||
* 规格值编号
|
||||
*/
|
||||
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
/**
|
||||
* 规格值名
|
||||
*/
|
||||
@ApiModelProperty(value = "规格值名", required = true, example = "小")
|
||||
private String name;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳格式")
|
||||
private Date createTime;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package cn.iocoder.mall.product.rest.response.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiModel(value = "商品规格精简 VO", description = "带有规格值数组")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductAttrSimpleResponse {
|
||||
|
||||
@ApiModelProperty(value = "规格编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "规格值数组", required = true)
|
||||
private List<ProductAttrValue> values;
|
||||
|
||||
@ApiModel("规格值")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class ProductAttrValue {
|
||||
|
||||
/**
|
||||
* 规格值编号
|
||||
*/
|
||||
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
/**
|
||||
* 规格值名
|
||||
*/
|
||||
@ApiModelProperty(value = "规格值名", required = true, example = "小")
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package cn.iocoder.mall.product.rest.response.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel(value = "商品规格值 VO")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProductAttrValueResponse {
|
||||
|
||||
@ApiModelProperty(value = "规格值编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "规格编号", required = true, example = "1")
|
||||
private Integer attrId;
|
||||
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package cn.iocoder.mall.product.rest.response.attr;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
@ApiModel(value = "商品规格 VO", description = "不带有规格值数组")
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class AdminsProdutAttrResponse {
|
||||
|
||||
@ApiModelProperty(value = "规格编号", required = true, example = "1")
|
||||
private Integer id;
|
||||
@ApiModelProperty(value = "规格名", required = true, example = "颜色")
|
||||
private String name;
|
||||
@ApiModelProperty(value = "状态", required = true, example = "1")
|
||||
private Integer status;
|
||||
@ApiModelProperty(value = "创建时间", required = true, example = "时间戳")
|
||||
private Date createTime;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user