Compare commits
4 Commits
Author | SHA1 | Date |
---|---|---|
|
013b02c652 | |
|
342647b13a | |
|
fd66219ea5 | |
|
2b54282abe |
|
@ -66,6 +66,8 @@ public class SysLoginService {
|
||||||
}
|
}
|
||||||
// 查询用户信息
|
// 查询用户信息
|
||||||
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
Result<LoginUser> userResult = remoteUserService.getUserInfo(username, SecurityConstants.INNER);
|
||||||
|
LoginUser data = userResult.getData();
|
||||||
|
System.out.println(data);
|
||||||
|
|
||||||
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
if (StringUtils.isNull(userResult) || StringUtils.isNull(userResult.getData())) {
|
||||||
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
recordLogService.recordLogininfor(username, Constants.LOGIN_FAIL, "登录用户不存在");
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,3 +24,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
|
|
|
@ -6,6 +6,7 @@ package com.muyu.common.core.exception;
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
public final class ServiceException extends RuntimeException {
|
public final class ServiceException extends RuntimeException {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -88,6 +88,7 @@
|
||||||
<version>${swagger.fox.version}</version>
|
<version>${swagger.fox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,6 +24,7 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
sentinel:
|
sentinel:
|
||||||
# 取消控制台懒加载
|
# 取消控制台懒加载
|
||||||
eager: true
|
eager: true
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,3 +24,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,3 +24,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,3 +24,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_attribute")
|
@TableName("as_category_attribute")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryAttribute", description = "品类属性中间")
|
@ApiModel(value = "AsCategoryAttribute", description = "品类属性中间")
|
||||||
public class AsCategoryAttribute extends BaseEntity {
|
public class AsCategoryAttribute extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -45,4 +46,15 @@ public class AsCategoryAttribute extends BaseEntity {
|
||||||
private Long attributeId;
|
private Long attributeId;
|
||||||
|
|
||||||
|
|
||||||
|
public static AsCategoryAttribute categoryBuild(Long categoryInfoId, Long attributeId) {
|
||||||
|
return AsCategoryAttribute.builder()
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.attributeId(attributeId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.attributeId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_attribute_group")
|
@TableName("as_category_attribute_group")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryAttributeGroup", description = "品类属性组中间")
|
@ApiModel(value = "AsCategoryAttributeGroup", description = "品类属性组中间")
|
||||||
public class AsCategoryAttributeGroup extends BaseEntity {
|
public class AsCategoryAttributeGroup extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -45,4 +46,15 @@ public class AsCategoryAttributeGroup extends BaseEntity {
|
||||||
private Long attributeGroupId;
|
private Long attributeGroupId;
|
||||||
|
|
||||||
|
|
||||||
|
public static AsCategoryAttributeGroup categoryBuild(Long categoryInfoId, Long attributeGroupId) {
|
||||||
|
return AsCategoryAttributeGroup.builder()
|
||||||
|
.attributeGroupId(attributeGroupId)
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.attributeGroupId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -25,7 +26,7 @@ import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
@TableName("as_category_brand")
|
@TableName("as_category_brand")
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@ApiModel(value = "AsCategoryBrand", description = "品类品牌中间")
|
@ApiModel(value = "AsCategoryBrand", description = "品类品牌中间")
|
||||||
public class AsCategoryBrand extends BaseEntity {
|
public class AsCategoryBrand extends BaseEntity implements CategoryBase {
|
||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ -44,4 +45,15 @@ public class AsCategoryBrand extends BaseEntity {
|
||||||
@ApiModelProperty(name = "品牌id", value = "品牌id", required = true)
|
@ApiModelProperty(name = "品牌id", value = "品牌id", required = true)
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
|
public static AsCategoryBrand categoryBuild(Long categoryInfoId, Long brandId) {
|
||||||
|
return AsCategoryBrand.builder()
|
||||||
|
.brandId(brandId)
|
||||||
|
.categoryId(categoryInfoId)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Long getBaseId () {
|
||||||
|
return this.brandId;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.domain;
|
||||||
import com.baomidou.mybatisplus.annotation.IdType;
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
import com.baomidou.mybatisplus.annotation.TableId;
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
import com.baomidou.mybatisplus.annotation.TableName;
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
@ -15,6 +16,10 @@ import com.muyu.product.domain.req.CategoryInfoSaveReq;
|
||||||
import com.muyu.product.domain.req.CategoryInfoEditReq;
|
import com.muyu.product.domain.req.CategoryInfoEditReq;
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息对象 category_info
|
* 品类信息对象 category_info
|
||||||
*
|
*
|
||||||
|
@ -57,6 +62,11 @@ public class CategoryInfo extends TreeEntity {
|
||||||
@ApiModelProperty(name = "介绍", value = "介绍")
|
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
|
|
||||||
|
@Excel(name = "父级id")
|
||||||
|
@ApiModelProperty(name = "父级id", value = "父级id")
|
||||||
|
private Long parentId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询构造器
|
* 查询构造器
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +74,7 @@ public class CategoryInfo extends TreeEntity {
|
||||||
return CategoryInfo.builder()
|
return CategoryInfo.builder()
|
||||||
.name(categoryInfoQueryReq.getName())
|
.name(categoryInfoQueryReq.getName())
|
||||||
.image(categoryInfoQueryReq.getImage())
|
.image(categoryInfoQueryReq.getImage())
|
||||||
|
.parentId(categoryInfoQueryReq.getParentId())
|
||||||
.start(categoryInfoQueryReq.getStart())
|
.start(categoryInfoQueryReq.getStart())
|
||||||
.introduction(categoryInfoQueryReq.getIntroduction())
|
.introduction(categoryInfoQueryReq.getIntroduction())
|
||||||
.build();
|
.build();
|
||||||
|
@ -72,12 +83,15 @@ public class CategoryInfo extends TreeEntity {
|
||||||
/**
|
/**
|
||||||
* 添加构造器
|
* 添加构造器
|
||||||
*/
|
*/
|
||||||
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq){
|
public static CategoryInfo saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
|
||||||
return CategoryInfo.builder()
|
return CategoryInfo.builder()
|
||||||
.name(categoryInfoSaveReq.getName())
|
.name(categoryInfoSaveReq.getName())
|
||||||
.image(categoryInfoSaveReq.getImage())
|
.image(categoryInfoSaveReq.getImage())
|
||||||
.start(categoryInfoSaveReq.getStart())
|
.start(categoryInfoSaveReq.getStart())
|
||||||
.introduction(categoryInfoSaveReq.getIntroduction())
|
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveReq.getParentId())
|
||||||
|
.createBy(supplier.get())
|
||||||
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +104,20 @@ public class CategoryInfo extends TreeEntity {
|
||||||
.name(categoryInfoEditReq.getName())
|
.name(categoryInfoEditReq.getName())
|
||||||
.image(categoryInfoEditReq.getImage())
|
.image(categoryInfoEditReq.getImage())
|
||||||
.start(categoryInfoEditReq.getStart())
|
.start(categoryInfoEditReq.getStart())
|
||||||
|
.parentId(categoryInfoEditReq.getParentId())
|
||||||
.introduction(categoryInfoEditReq.getIntroduction())
|
.introduction(categoryInfoEditReq.getIntroduction())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CategoryInfo saveModelBuild(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
|
return CategoryInfo.builder()
|
||||||
|
.name(categoryInfoSaveModel.getName())
|
||||||
|
.image(categoryInfoSaveModel.getImage())
|
||||||
|
.start(categoryInfoSaveModel.getStart())
|
||||||
|
.introduction(categoryInfoSaveModel.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveModel.getParentId())
|
||||||
|
.createBy(categoryInfoSaveModel.getCreateBy())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ public class CommentInfo extends BaseEntity {
|
||||||
/** 图片 */
|
/** 图片 */
|
||||||
@Excel(name = "图片")
|
@Excel(name = "图片")
|
||||||
@ApiModelProperty(name = "图片", value = "图片")
|
@ApiModelProperty(name = "图片", value = "图片")
|
||||||
private String images;
|
private String image;
|
||||||
|
|
||||||
/** 父类id */
|
/** 父类id */
|
||||||
@Excel(name = "父类id")
|
@Excel(name = "父类id")
|
||||||
|
@ -64,7 +64,7 @@ public class CommentInfo extends BaseEntity {
|
||||||
return CommentInfo.builder()
|
return CommentInfo.builder()
|
||||||
.projectId(commentInfoQueryReq.getProjectId())
|
.projectId(commentInfoQueryReq.getProjectId())
|
||||||
.comment(commentInfoQueryReq.getComment())
|
.comment(commentInfoQueryReq.getComment())
|
||||||
.images(commentInfoQueryReq.getImages())
|
.image(commentInfoQueryReq.getImages())
|
||||||
.parentId(commentInfoQueryReq.getParentId())
|
.parentId(commentInfoQueryReq.getParentId())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,7 @@ public class CommentInfo extends BaseEntity {
|
||||||
return CommentInfo.builder()
|
return CommentInfo.builder()
|
||||||
.projectId(commentInfoSaveReq.getProjectId())
|
.projectId(commentInfoSaveReq.getProjectId())
|
||||||
.comment(commentInfoSaveReq.getComment())
|
.comment(commentInfoSaveReq.getComment())
|
||||||
.images(commentInfoSaveReq.getImages())
|
.image(commentInfoSaveReq.getImages())
|
||||||
.parentId(commentInfoSaveReq.getParentId())
|
.parentId(commentInfoSaveReq.getParentId())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ public class CommentInfo extends BaseEntity {
|
||||||
.id(id)
|
.id(id)
|
||||||
.projectId(commentInfoEditReq.getProjectId())
|
.projectId(commentInfoEditReq.getProjectId())
|
||||||
.comment(commentInfoEditReq.getComment())
|
.comment(commentInfoEditReq.getComment())
|
||||||
.images(commentInfoEditReq.getImages())
|
.image(commentInfoEditReq.getImages())
|
||||||
.parentId(commentInfoEditReq.getParentId())
|
.parentId(commentInfoEditReq.getParentId())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package com.muyu.product.domain.base;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: attribute基础方法
|
||||||
|
* @Date 2024-3-1 下午 02:28
|
||||||
|
*/
|
||||||
|
public interface CategoryBase {
|
||||||
|
|
||||||
|
public Long getBaseId();
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package com.muyu.product.domain.model;
|
||||||
|
|
||||||
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
|
import com.muyu.product.domain.req.CategoryInfoSaveReq;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品类信息对象 category_info
|
||||||
|
*
|
||||||
|
* @author DongZeLiang
|
||||||
|
* @date 2024-02-27
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class CategoryInfoSaveModel extends TreeEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
/** 品类名称 */
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 图片 */
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/** 是否启用 */
|
||||||
|
private String start;
|
||||||
|
|
||||||
|
/** 介绍 */
|
||||||
|
private String introduction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品属性组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeGroupIdList;
|
||||||
|
/**
|
||||||
|
* 商品属性关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品品牌组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> brandIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加构造器
|
||||||
|
*/
|
||||||
|
public static CategoryInfoSaveModel saveBuild(CategoryInfoSaveReq categoryInfoSaveReq, Supplier<String> supplier){
|
||||||
|
return CategoryInfoSaveModel.builder()
|
||||||
|
.name(categoryInfoSaveReq.getName())
|
||||||
|
.image(categoryInfoSaveReq.getImage())
|
||||||
|
.start(categoryInfoSaveReq.getStart())
|
||||||
|
.introduction(categoryInfoSaveReq.getIntroduction())
|
||||||
|
.parentId(categoryInfoSaveReq.getParentId())
|
||||||
|
.attributeGroupIdList(categoryInfoSaveReq.getAttributeGroupIdList())
|
||||||
|
.attributeIdList(categoryInfoSaveReq.getAttributeIdList())
|
||||||
|
.brandIdList(categoryInfoSaveReq.getBrandIdList())
|
||||||
|
.createBy(supplier.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -8,6 +8,8 @@ import lombok.experimental.SuperBuilder;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息对象 category_info
|
* 品类信息对象 category_info
|
||||||
*
|
*
|
||||||
|
@ -48,4 +50,18 @@ public class CategoryInfoSaveReq extends TreeEntity {
|
||||||
@ApiModelProperty(name = "介绍", value = "介绍")
|
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||||
private String introduction;
|
private String introduction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品属性组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeGroupIdList;
|
||||||
|
/**
|
||||||
|
* 商品属性关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品品牌组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> brandIdList;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.BrandInfo;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author DongZl
|
||||||
|
* @description: 类别父通用元素
|
||||||
|
* @Date 2024-3-1 上午 11:02
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CategoryParentCommonElementResp {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性集合
|
||||||
|
*/
|
||||||
|
private List<AttributeInfo> attributeInfoList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 属性组集合
|
||||||
|
*/
|
||||||
|
private List<AttributeGroup> attributeGroupList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品牌集合
|
||||||
|
*/
|
||||||
|
private List<BrandInfo> brandInfoList;
|
||||||
|
|
||||||
|
}
|
|
@ -1,8 +1,15 @@
|
||||||
package com.muyu.product.controller;
|
package com.muyu.product.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.BrandInfo;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
@ -81,7 +88,9 @@ public class CategoryInfoController extends BaseController {
|
||||||
@PostMapping
|
@PostMapping
|
||||||
@ApiOperation("新增品类信息")
|
@ApiOperation("新增品类信息")
|
||||||
public Result<String> add(@RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
|
public Result<String> add(@RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
|
||||||
return toAjax(categoryInfoService.save(CategoryInfo.saveBuild(categoryInfoSaveReq)));
|
return toAjax(categoryInfoService.save(
|
||||||
|
CategoryInfoSaveModel.saveBuild(categoryInfoSaveReq, SecurityUtils::getUsername)
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -106,4 +115,18 @@ public class CategoryInfoController extends BaseController {
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||||
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
@GetMapping("/parentCommonElement/{categoryId}")
|
||||||
|
@ApiOperation("通过品类ID获取父级以上的属性集合")
|
||||||
|
@ApiImplicitParam(name = "categoryId", value = "categoryId", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class, example = "1")
|
||||||
|
public Result<CategoryParentCommonElementResp> parentCommonElement(
|
||||||
|
@PathVariable(value = "categoryId") Long categoryId
|
||||||
|
) {
|
||||||
|
return Result.success(categoryInfoService.parentCommonElement(categoryId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,11 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.muyu.product.domain.AsAttributeGroup;
|
import com.muyu.product.domain.AsAttributeGroup;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.product.domain.AsCategoryAttribute;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性与组中间Service接口
|
* 属性与组中间Service接口
|
||||||
|
@ -17,6 +20,6 @@ public interface AsAttributeGroupService extends IService<AsAttributeGroup> {
|
||||||
* @param asAttributeGroup 属性与组中间
|
* @param asAttributeGroup 属性与组中间
|
||||||
* @return 属性与组中间集合
|
* @return 属性与组中间集合
|
||||||
*/
|
*/
|
||||||
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup);
|
public List<AsAttributeGroup> list(LambdaQueryWrapper<AsCategoryAttribute> asAttributeGroup);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,14 @@
|
||||||
package com.muyu.product.service;
|
package com.muyu.product.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import com.muyu.product.domain.BrandInfo;
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
import com.baomidou.mybatisplus.extension.service.IService;
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service接口
|
* 品类信息Service接口
|
||||||
|
@ -19,4 +25,38 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||||
*/
|
*/
|
||||||
public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
public List<CategoryInfo> list(CategoryInfo categoryInfo);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 保存
|
||||||
|
* @param categoryInfoSaveModel 保存品类模型
|
||||||
|
* @return 是否成功
|
||||||
|
*/
|
||||||
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性组集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性组集合
|
||||||
|
*/
|
||||||
|
List<AttributeGroup> getAttributeGroup (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的品牌集合
|
||||||
|
*/
|
||||||
|
List<BrandInfo> getBrand (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性集合
|
||||||
|
*/
|
||||||
|
List<AttributeInfo> getAttribute (Long categoryId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
CategoryParentCommonElementResp parentCommonElement (Long categoryId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.service.impl;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.product.domain.AsCategoryAttribute;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
||||||
|
@ -28,20 +29,18 @@ public class AsAttributeGroupServiceImpl extends ServiceImpl<AsAttributeGroupMap
|
||||||
* @return 属性与组中间
|
* @return 属性与组中间
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AsAttributeGroup> list(AsAttributeGroup asAttributeGroup) {
|
public List<AsAttributeGroup> list(LambdaQueryWrapper<AsCategoryAttribute> asAttributeGroup) {
|
||||||
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
|
||||||
|
|
||||||
if (ObjUtils.notNull(asAttributeGroup.getGroupId())){
|
// if (ObjUtils.notNull(asAttributeGroup.getGroupId())){
|
||||||
queryWrapper.eq(AsAttributeGroup::getGroupId, asAttributeGroup.getGroupId());
|
// queryWrapper.eq(AsAttributeGroup::getGroupId, asAttributeGroup.getGroupId());
|
||||||
}
|
// }
|
||||||
|
//
|
||||||
if (ObjUtils.notNull(asAttributeGroup.getAttributeId())){
|
//
|
||||||
queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
// if (ObjUtils.notNull(asAttributeGroup.getAttributeId())){
|
||||||
}
|
// queryWrapper.eq(AsAttributeGroup::getAttributeId, asAttributeGroup.getAttributeId());
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
|
|
|
@ -62,6 +62,8 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询属性组列表
|
* 查询属性组列表
|
||||||
*
|
*
|
||||||
|
|
|
@ -64,10 +64,14 @@ public class AttributeInfoServiceImpl extends ServiceImpl<AttributeInfoMapper, A
|
||||||
}
|
}
|
||||||
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
LambdaQueryWrapper<AsAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
queryWrapper.eq(AsAttributeGroup::getGroupId, groupId);
|
queryWrapper.eq(AsAttributeGroup::getGroupId, groupId);
|
||||||
return this.listByIds(
|
List<Long> list = asAttributeGroupService.list(queryWrapper).stream()
|
||||||
asAttributeGroupService.list(queryWrapper).stream()
|
|
||||||
.map(AsAttributeGroup::getAttributeId)
|
.map(AsAttributeGroup::getAttributeId)
|
||||||
.toList()
|
.toList();
|
||||||
|
if (list == null || list.isEmpty()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return this.listByIds(
|
||||||
|
list
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,24 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.common.core.utils.ObjUtils;
|
import com.muyu.common.core.utils.ObjUtils;
|
||||||
|
import com.muyu.product.domain.*;
|
||||||
|
import com.muyu.product.domain.base.CategoryBase;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
|
import com.muyu.product.service.*;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
|
||||||
import com.muyu.product.service.CategoryInfoService;
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service业务层处理
|
* 品类信息Service业务层处理
|
||||||
|
@ -21,6 +30,25 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
@Service
|
@Service
|
||||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeService asCategoryAttributeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryBrandService asCategoryBrandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeInfoService attributeInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BrandInfoService brandInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeGroupService attributeGroupService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询品类信息列表
|
* 查询品类信息列表
|
||||||
*
|
*
|
||||||
|
@ -52,10 +80,195 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
||||||
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
queryWrapper.eq(CategoryInfo::getIntroduction, categoryInfo.getIntroduction());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
|
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
|
||||||
|
boolean save = this.save(categoryInfo);
|
||||||
|
Long categoryInfoId = categoryInfo.getId();
|
||||||
|
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
|
||||||
|
if (attributeIdList != null && !attributeIdList.isEmpty()){
|
||||||
|
asCategoryAttributeService.saveBatch(
|
||||||
|
attributeIdList.stream()
|
||||||
|
.map(attributeId -> AsCategoryAttribute.categoryBuild(categoryInfoId, attributeId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<Long> attributeGroupIdList = categoryInfoSaveModel.getAttributeGroupIdList();
|
||||||
|
if (attributeGroupIdList != null && !attributeGroupIdList.isEmpty()){
|
||||||
|
asCategoryAttributeGroupService.saveBatch(
|
||||||
|
attributeGroupIdList.stream()
|
||||||
|
.map(attributeGroupId -> AsCategoryAttributeGroup.categoryBuild(categoryInfoId, attributeGroupId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<Long> brandIdList = categoryInfoSaveModel.getBrandIdList();
|
||||||
|
if (brandIdList != null && !brandIdList.isEmpty()){
|
||||||
|
asCategoryBrandService.saveBatch(
|
||||||
|
brandIdList.stream()
|
||||||
|
.map(brandId -> AsCategoryBrand.categoryBuild(categoryInfoId, brandId))
|
||||||
|
.toList()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return save;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性组集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性组集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttributeGroup> getAttributeGroup (Long categoryId) {
|
||||||
|
List<AttributeGroup> attributeGroupList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttributeGroup> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryAttributeGroup::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryAttributeGroup> asCategoryAttributeGroupList = asCategoryAttributeGroupService.list(queryWrapper);
|
||||||
|
if (asCategoryAttributeGroupList != null && !asCategoryAttributeGroupList.isEmpty()){
|
||||||
|
List<Long> attributeGroupIdList = asCategoryAttributeGroupList.stream()
|
||||||
|
.map(AsCategoryAttributeGroup::getAttributeGroupId)
|
||||||
|
.toList();
|
||||||
|
attributeGroupList.addAll(attributeGroupService.listByIds(attributeGroupIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0){
|
||||||
|
if (attributeGroupList.isEmpty()){
|
||||||
|
attributeGroupList.addAll(getAttributeGroup(categoryInfo.getParentId()));
|
||||||
|
}else {
|
||||||
|
List<AttributeGroup> attributeGroups = getAttributeGroup(categoryInfo.getParentId());
|
||||||
|
attributeGroups.forEach(attributeGroup -> {
|
||||||
|
if (!attributeGroupList.contains(attributeGroup)){
|
||||||
|
attributeGroupList.add(attributeGroup);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attributeGroupList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的品牌集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的品牌集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<BrandInfo> getBrand (Long categoryId) {
|
||||||
|
List<BrandInfo> brandInfoList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryBrand> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryBrand::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryBrand> asCategoryBrandList = asCategoryBrandService.list(queryWrapper);
|
||||||
|
if (asCategoryBrandList != null && !asCategoryBrandList.isEmpty()){
|
||||||
|
List<Long> brandIdList = asCategoryBrandList.stream()
|
||||||
|
.map(AsCategoryBrand::getBrandId)
|
||||||
|
.toList();
|
||||||
|
brandInfoList.addAll(brandInfoService.listByIds(brandIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0){
|
||||||
|
if (brandInfoList.isEmpty()){
|
||||||
|
brandInfoList.addAll(getBrand(categoryInfo.getParentId()));
|
||||||
|
}else {
|
||||||
|
List<BrandInfo> brandInfos = getBrand(categoryInfo.getParentId());
|
||||||
|
brandInfos.forEach(brandInfo -> {
|
||||||
|
if (!brandInfoList.contains(brandInfo)){
|
||||||
|
brandInfoList.add(brandInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return brandInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public List<AttributeInfo> getAttribute (Long categoryId) {
|
||||||
|
List<AttributeInfo> attributeInfoList = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
queryWrapper.eq(AsCategoryAttribute::getCategoryId, categoryId);
|
||||||
|
List<AsCategoryAttribute> asCategoryAttributeList = asCategoryAttributeService.list(queryWrapper);
|
||||||
|
if (asCategoryAttributeList != null && !asCategoryAttributeList.isEmpty()){
|
||||||
|
List<Long> attributeIdList = asCategoryAttributeList.stream()
|
||||||
|
.map(AsCategoryAttribute::getAttributeId)
|
||||||
|
.toList();
|
||||||
|
attributeInfoList.addAll(attributeInfoService.listByIds(attributeIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0){
|
||||||
|
if (attributeInfoList.isEmpty()){
|
||||||
|
attributeInfoList.addAll(getAttribute(categoryInfo.getParentId()));
|
||||||
|
}else {
|
||||||
|
List<AttributeInfo> attributeInfos = getAttribute(categoryInfo.getParentId());
|
||||||
|
attributeInfos.forEach(attributeInfoQuery -> {
|
||||||
|
if (!attributeInfoList.contains(attributeInfoQuery)){
|
||||||
|
attributeInfoList.add(attributeInfoQuery);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return attributeInfoList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public <T,AS> List<T> getCommon(Long categoryId,IService<AS> iService,IService<T> bsiService){
|
||||||
|
List<T> list = new ArrayList();
|
||||||
|
QueryWrapper<AS> asQueryWrapper = new QueryWrapper<>();
|
||||||
|
asQueryWrapper.eq("category_id", categoryId);
|
||||||
|
List<AS> asList = iService.list(asQueryWrapper);
|
||||||
|
if (asList != null && !asList.isEmpty()){
|
||||||
|
List<Long> baseIdList = asList.stream()
|
||||||
|
.map(as -> {
|
||||||
|
if (as instanceof CategoryBase categoryBase){
|
||||||
|
return categoryBase.getBaseId();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
})
|
||||||
|
.toList();
|
||||||
|
list.addAll(bsiService.listByIds(baseIdList));
|
||||||
|
}
|
||||||
|
CategoryInfo categoryInfo = this.getById(categoryId);
|
||||||
|
if (categoryInfo.getParentId() != 0){
|
||||||
|
if (list.isEmpty()){
|
||||||
|
list.addAll(getCommon(categoryInfo.getParentId(), iService, bsiService));
|
||||||
|
}else {
|
||||||
|
List<T> commonList = getCommon(categoryInfo.getParentId(), iService, bsiService);
|
||||||
|
commonList.forEach(common -> {
|
||||||
|
if (!list.contains(common)){
|
||||||
|
list.add(common);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
|
*
|
||||||
|
* @param categoryId 品类ID
|
||||||
|
*
|
||||||
|
* @return 父级以上的属性、属性组、品牌集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CategoryParentCommonElementResp parentCommonElement (Long categoryId) {
|
||||||
|
return CategoryParentCommonElementResp.builder()
|
||||||
|
.attributeInfoList(getCommon(categoryId, asCategoryAttributeService, attributeInfoService))
|
||||||
|
.attributeGroupList(getCommon(categoryId, asCategoryAttributeGroupService, attributeGroupService))
|
||||||
|
.brandInfoList(getCommon(categoryId, asCategoryBrandService, brandInfoService))
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,99 @@
|
||||||
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.muyu.product.domain.*;
|
||||||
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
|
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||||
|
import com.muyu.product.service.*;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class CategoryInfoServiceImpl1 extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements CategoryInfoService {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsAttributeGroupService asAttributeGroupService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryAttributeService asCategoryAttributeService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AsCategoryBrandService asCategoryBrandService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BrandInfoService brandInfoService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private AttributeInfoService attributeInfoService;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CategoryInfo> list(CategoryInfo categoryInfo) {
|
||||||
|
//创建一个查询条件
|
||||||
|
LambdaQueryWrapper<CategoryInfo> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
if (Objects.nonNull(categoryInfo.getName())){
|
||||||
|
queryWrapper.like(CategoryInfo::getName,categoryInfo.getName());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(categoryInfo.getImage())){
|
||||||
|
queryWrapper.eq(CategoryInfo::getImage,categoryInfo.getImage());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(categoryInfo.getParentId())){
|
||||||
|
queryWrapper.eq(CategoryInfo::getParentId,categoryInfo.getParentId());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(categoryInfo.getStart())){
|
||||||
|
queryWrapper.eq(CategoryInfo::getStart,categoryInfo.getStart());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(categoryInfo.getIntroduction())){
|
||||||
|
queryWrapper.eq(CategoryInfo::getIntroduction,categoryInfo.getIntroduction());
|
||||||
|
}
|
||||||
|
|
||||||
|
return list(queryWrapper);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional
|
||||||
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
|
//创建对象
|
||||||
|
CategoryInfo categoryInfo = CategoryInfo.saveModelBuild(categoryInfoSaveModel);
|
||||||
|
boolean save = this.save(categoryInfo);
|
||||||
|
Long categoryInfoId = categoryInfo.getId();
|
||||||
|
List<Long> attributeIdList = categoryInfoSaveModel.getAttributeIdList();
|
||||||
|
if (attributeIdList!=null&& !attributeIdList.isEmpty()){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttributeGroup> getAttributeGroup(Long categoryId) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<BrandInfo> getBrand(Long categoryId) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AttributeInfo> getAttribute(Long categoryId) {
|
||||||
|
List<AttributeInfo> attributeInfos = new ArrayList<>();
|
||||||
|
LambdaQueryWrapper<AsCategoryAttribute> queryWrapper = new LambdaQueryWrapper<>();
|
||||||
|
asAttributeGroupService.list(queryWrapper);
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CategoryParentCommonElementResp parentCommonElement(Long categoryId) {
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -40,8 +40,8 @@ public class CommentInfoServiceImpl extends ServiceImpl<CommentInfoMapper, Comme
|
||||||
queryWrapper.eq(CommentInfo::getComment, commentInfo.getComment());
|
queryWrapper.eq(CommentInfo::getComment, commentInfo.getComment());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(commentInfo.getImages())){
|
if (ObjUtils.notNull(commentInfo.getImage())){
|
||||||
queryWrapper.eq(CommentInfo::getImages, commentInfo.getImages());
|
queryWrapper.eq(CommentInfo::getImage, commentInfo.getImage());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ObjUtils.notNull(commentInfo.getParentId())){
|
if (ObjUtils.notNull(commentInfo.getParentId())){
|
||||||
|
@ -49,9 +49,6 @@ public class CommentInfoServiceImpl extends ServiceImpl<CommentInfoMapper, Comme
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return list(queryWrapper);
|
return list(queryWrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,9 +15,11 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
# 配置文件格式
|
# 配置文件格式
|
||||||
file-extension: yml
|
file-extension: yml
|
||||||
# 共享配置
|
# 共享配置
|
||||||
|
|
|
@ -19,6 +19,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectCategoryInfoVo">
|
<sql id="selectCategoryInfoVo">
|
||||||
select id, name, image, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
|
select id, name, image, start,parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
|
||||||
</sql>
|
</sql>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<result property="id" column="id" />
|
<result property="id" column="id" />
|
||||||
<result property="projectId" column="project_id" />
|
<result property="projectId" column="project_id" />
|
||||||
<result property="comment" column="comment" />
|
<result property="comment" column="comment" />
|
||||||
<result property="images" column="images" />
|
<result property="image" column="images" />
|
||||||
<result property="parentId" column="parent_id" />
|
<result property="parentId" column="parent_id" />
|
||||||
<result property="remark" column="remark" />
|
<result property="remark" column="remark" />
|
||||||
<result property="createBy" column="create_by" />
|
<result property="createBy" column="create_by" />
|
||||||
|
|
|
@ -5,6 +5,7 @@ import com.muyu.common.security.annotation.EnableMyFeignClients;
|
||||||
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
import com.muyu.common.swagger.annotation.EnableCustomSwagger2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 系统模块
|
* 系统模块
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class SysDictDataController extends BaseController {
|
||||||
|
|
||||||
@RequiresPermissions("system:dict:list")
|
@RequiresPermissions("system:dict:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<SysDictData>> list (SysDictData dictData) {
|
public Result<TableDataInfo<SysDictData>> list (@RequestBody SysDictData dictData) {
|
||||||
startPage();
|
startPage();
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
|
@ -45,7 +45,7 @@ public class SysDictDataController extends BaseController {
|
||||||
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
@Log(title = "字典数据", businessType = BusinessType.EXPORT)
|
||||||
@RequiresPermissions("system:dict:export")
|
@RequiresPermissions("system:dict:export")
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export (HttpServletResponse response, SysDictData dictData) {
|
public void export (HttpServletResponse response,@RequestBody SysDictData dictData) {
|
||||||
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
List<SysDictData> list = dictDataService.selectDictDataList(dictData);
|
||||||
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
ExcelUtil<SysDictData> util = new ExcelUtil<SysDictData>(SysDictData.class);
|
||||||
util.exportExcel(response, list, "字典数据");
|
util.exportExcel(response, list, "字典数据");
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.common.system.domain.SysDictData;
|
import com.muyu.common.system.domain.SysDictData;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -11,6 +12,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
|
public interface SysDictDataMapper extends BaseMapper<SysDictData> {
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询字典数据
|
* 根据条件分页查询字典数据
|
||||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.system.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.common.system.domain.SysDictType;
|
import com.muyu.common.system.domain.SysDictType;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@ -10,6 +11,7 @@ import java.util.List;
|
||||||
*
|
*
|
||||||
* @author muyu
|
* @author muyu
|
||||||
*/
|
*/
|
||||||
|
@Mapper
|
||||||
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
public interface SysDictTypeMapper extends BaseMapper<SysDictType> {
|
||||||
/**
|
/**
|
||||||
* 根据条件分页查询字典类型
|
* 根据条件分页查询字典类型
|
||||||
|
|
|
@ -15,6 +15,7 @@ spring:
|
||||||
discovery:
|
discovery:
|
||||||
# 服务注册地址
|
# 服务注册地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
config:
|
config:
|
||||||
# 配置中心地址
|
# 配置中心地址
|
||||||
server-addr: 115.159.67.205:8848
|
server-addr: 115.159.67.205:8848
|
||||||
|
@ -23,6 +24,7 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
logging:
|
logging:
|
||||||
level:
|
level:
|
||||||
com.muyu.system.mapper: DEBUG
|
com.muyu.system.mapper: DEBUG
|
||||||
|
|
|
@ -23,3 +23,4 @@ spring:
|
||||||
# 共享配置
|
# 共享配置
|
||||||
shared-configs:
|
shared-configs:
|
||||||
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
- application-${spring.profiles.active}.${spring.cloud.nacos.config.file-extension}
|
||||||
|
namespace: e47d9b61-1cb9-48b7-97b3-2692bfaf34a3
|
||||||
|
|
Loading…
Reference in New Issue