品类组件响应,属性组bug修改
parent
ababc20a27
commit
007aa4c276
|
@ -38,8 +38,6 @@ public class AttributeGroup extends BaseEntity
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private List<Attribute> attributeList;
|
private List<Attribute> attributeList;
|
||||||
private List<Long> checkedAttributeIds;
|
|
||||||
private List<Long> asAttributeIds;
|
|
||||||
|
|
||||||
/** 状态 */
|
/** 状态 */
|
||||||
@Excel(name = "状态")
|
@Excel(name = "状态")
|
||||||
|
@ -76,11 +74,4 @@ public class AttributeGroup extends BaseEntity
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCheckedAttributeIds(List<Long> checkedAttributeIds) {
|
|
||||||
this.checkedAttributeIds = checkedAttributeIds;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Long> getCheckedAttributeIds() {
|
|
||||||
return checkedAttributeIds;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,16 @@ package com.muyu.product.domain;
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品牌品类中间对象 brand_category
|
* 品牌品类中间对象 brand_category
|
||||||
|
@ -38,4 +40,18 @@ public class BrandCategory extends BaseEntity
|
||||||
private Long brandId;
|
private Long brandId;
|
||||||
|
|
||||||
|
|
||||||
|
public static List<BrandCategory> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> getUsername) {
|
||||||
|
return categoryReq.getCheckedBrandIds().stream().map(
|
||||||
|
brandId -> BrandCategory.saveBuilder(categoryReq.getId(),brandId,getUsername)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier<String> getUsername) {
|
||||||
|
return BrandCategory.builder()
|
||||||
|
.brandId(brandId)
|
||||||
|
.categoryId(categoryId)
|
||||||
|
.createBy(getUsername.get())
|
||||||
|
.createTime(new Date())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,16 @@ package com.muyu.product.domain;
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类属性中间对象 category_attribute
|
* 品类属性中间对象 category_attribute
|
||||||
|
@ -37,10 +39,18 @@ public class CategoryAttribute extends BaseEntity
|
||||||
@Excel(name = "品类编号")
|
@Excel(name = "品类编号")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
public static CategoryAttribute categoryBuilder(Long id, Long attributeId) {
|
public static CategoryAttribute categoryBuilder(Long categoryId, Long attributeId, Supplier<String> username) {
|
||||||
return CategoryAttribute.builder()
|
return CategoryAttribute.builder()
|
||||||
.categoryId(id)
|
.categoryId(categoryId)
|
||||||
.attributeId(attributeId)
|
.attributeId(attributeId)
|
||||||
|
.createBy(username.get())
|
||||||
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static List<CategoryAttribute> saveBuilder(CategoryInfoSaveModel categoryReq, Supplier<String> username) {
|
||||||
|
return categoryReq.getCheckedAttributeIds().stream().map(
|
||||||
|
attributeId -> categoryBuilder(categoryReq.getId(),attributeId,username)
|
||||||
|
).toList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,14 +2,16 @@ package com.muyu.product.domain;
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.annotation.Excel;
|
||||||
import com.muyu.common.core.web.domain.BaseEntity;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.EqualsAndHashCode;
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类属性组中间对象 category_attribute_group
|
* 品类属性组中间对象 category_attribute_group
|
||||||
|
@ -22,33 +24,46 @@ import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class CategoryAttributeGroup extends BaseEntity
|
public class CategoryAttributeGroup extends BaseEntity {
|
||||||
{
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
/** 主键 */
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 属性组编号 */
|
/**
|
||||||
|
* 属性组编号
|
||||||
|
*/
|
||||||
@Excel(name = "属性组编号")
|
@Excel(name = "属性组编号")
|
||||||
private Long attributeGroupId;
|
private Long attributeGroupId;
|
||||||
|
|
||||||
/** 品类编号 */
|
/**
|
||||||
|
* 品类编号
|
||||||
|
*/
|
||||||
@Excel(name = "品类编号")
|
@Excel(name = "品类编号")
|
||||||
private Long categoryId;
|
private Long categoryId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类属性组中间表构建体
|
* 品类属性组中间表构建体
|
||||||
* 作用:提供数组对象
|
* 作用:提供数组对象
|
||||||
|
*
|
||||||
* @param id
|
* @param id
|
||||||
* @param groupId
|
* @param groupId
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static CategoryAttributeGroup saveBuilder(Long id, Long groupId) {
|
public static CategoryAttributeGroup saveBuilder(Long id, Long groupId, Supplier<String> username) {
|
||||||
return CategoryAttributeGroup.builder()
|
return CategoryAttributeGroup.builder()
|
||||||
.attributeGroupId(groupId)
|
.attributeGroupId(groupId)
|
||||||
.categoryId(id)
|
.categoryId(id)
|
||||||
|
.createBy(username.get())
|
||||||
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<CategoryAttributeGroup> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> username) {
|
||||||
|
return categoryReq.getCheckedAttributeGroupIds().stream().map(
|
||||||
|
groupId -> saveBuilder(categoryReq.getId(), groupId, username)
|
||||||
|
).toList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,6 +51,7 @@ public class CategoryInfo extends TreeEntity
|
||||||
.image(req.getImage())
|
.image(req.getImage())
|
||||||
.status(req.getStatus())
|
.status(req.getStatus())
|
||||||
.remark(req.getRemark())
|
.remark(req.getRemark())
|
||||||
|
.parentId(req.getParentId())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,9 +62,24 @@ public class CategoryInfo extends TreeEntity
|
||||||
.name(req.getName())
|
.name(req.getName())
|
||||||
.status(req.getStatus())
|
.status(req.getStatus())
|
||||||
.image(req.getImage())
|
.image(req.getImage())
|
||||||
|
.parentId(req.getParentId())
|
||||||
.remark(req.getRemark())
|
.remark(req.getRemark())
|
||||||
.createBy(req.getCreateBy())
|
.createBy(req.getCreateBy())
|
||||||
.createTime(req.getCreateTime())
|
.createTime(req.getCreateTime())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CategoryInfo saveBuilder(CategoryInfoSaveModel categoryReq) {
|
||||||
|
return CategoryInfo.builder()
|
||||||
|
.id(categoryReq.getId())
|
||||||
|
.name(categoryReq.getName())
|
||||||
|
.status(categoryReq.getStatus())
|
||||||
|
.image(categoryReq.getImage())
|
||||||
|
.parentId(categoryReq.getParentId())
|
||||||
|
.status(categoryReq.getStatus())
|
||||||
|
.remark(categoryReq.getRemark())
|
||||||
|
.createBy(categoryReq.getCreateBy())
|
||||||
|
.createTime(categoryReq.getCreateTime())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,11 +42,19 @@ public class CategoryInfoSaveModel extends TreeEntity {
|
||||||
private String createBy;
|
private String createBy;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 已选属性组集合
|
||||||
|
*/
|
||||||
|
private List<Long> checkedAttributeGroupIds;
|
||||||
|
/**
|
||||||
|
* 已选属性集合
|
||||||
|
*/
|
||||||
private List<Long> checkedAttributeIds;
|
private List<Long> checkedAttributeIds;
|
||||||
|
/**
|
||||||
|
* 已选品牌集合
|
||||||
|
*/
|
||||||
|
private List<Long> checkedBrandIds;
|
||||||
|
|
||||||
private List<Long> attributeGroupIds;
|
|
||||||
|
|
||||||
private List<Long> brandIds;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存构建体
|
* 保存构建体
|
||||||
|
@ -54,13 +62,13 @@ public class CategoryInfoSaveModel extends TreeEntity {
|
||||||
public static CategoryInfoSaveModel saveBuilder(CategoryReq req, Supplier<String> username){
|
public static CategoryInfoSaveModel saveBuilder(CategoryReq req, Supplier<String> username){
|
||||||
return CategoryInfoSaveModel.builder()
|
return CategoryInfoSaveModel.builder()
|
||||||
.checkedAttributeIds(req.getCheckedAttributeIds())
|
.checkedAttributeIds(req.getCheckedAttributeIds())
|
||||||
.attributeGroupIds(req.getAttributeGroupIds())
|
.checkedAttributeGroupIds(req.getCheckedAttributeGroupIds())
|
||||||
.brandIds(req.getBrandIds())
|
.checkedBrandIds(req.getCheckedBrandIds())
|
||||||
.image(req.getImage())
|
.image(req.getImage())
|
||||||
.name(req.getName())
|
.name(req.getName())
|
||||||
.parentId(req.getParentId())
|
.parentId(req.getParentId())
|
||||||
.createBy(username.get())
|
.createBy(username.get())
|
||||||
.createTime(req.getCreateTime())
|
.createTime(new Date())
|
||||||
.status(req.getStatus())
|
.status(req.getStatus())
|
||||||
.remark(req.getRemark())
|
.remark(req.getRemark())
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package com.muyu.product.domain.req;
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
import com.muyu.common.core.annotation.Excel;
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,37 +15,60 @@ import java.util.List;
|
||||||
* @Author SaiSai.Liu
|
* @Author SaiSai.Liu
|
||||||
* @Date 2024/3/5/0005 12:35
|
* @Date 2024/3/5/0005 12:35
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@SuperBuilder
|
@SuperBuilder
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class CategoryReq {
|
@EqualsAndHashCode(callSuper = true)
|
||||||
/** 主键 */
|
public class CategoryReq extends BaseEntity {
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
/** 品类名称 */
|
/**
|
||||||
|
* 品类名称
|
||||||
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/** 图片 */
|
/**
|
||||||
|
* 图片
|
||||||
|
*/
|
||||||
private String image;
|
private String image;
|
||||||
|
|
||||||
/** 父级品类 */
|
/**
|
||||||
|
* 父级品类
|
||||||
|
*/
|
||||||
private Long parentId;
|
private Long parentId;
|
||||||
|
|
||||||
/** 是否启用 */
|
/**
|
||||||
|
* 是否启用
|
||||||
|
*/
|
||||||
private String status;
|
private String status;
|
||||||
|
|
||||||
/** 说明 */
|
/**
|
||||||
|
* 说明
|
||||||
|
*/
|
||||||
private String remark;
|
private String remark;
|
||||||
private String createBy;
|
/**
|
||||||
private Date createTime;
|
* 已选属性组集合
|
||||||
|
*/
|
||||||
|
private List<Long> checkedAttributeGroupIds;
|
||||||
|
/**
|
||||||
|
* 已选属性集合
|
||||||
|
*/
|
||||||
private List<Long> checkedAttributeIds;
|
private List<Long> checkedAttributeIds;
|
||||||
|
/**
|
||||||
private List<Long> attributeGroupIds;
|
* 已选品牌集合
|
||||||
|
*/
|
||||||
private List<Long> brandIds;
|
private List<Long> checkedBrandIds;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,85 @@
|
||||||
|
package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
|
import com.muyu.common.core.annotation.Excel;
|
||||||
|
import com.muyu.common.core.web.domain.BaseEntity;
|
||||||
|
import com.muyu.product.domain.Attribute;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.req.AttributeGroupReq;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ClassName AttributeGroupResp
|
||||||
|
* @Description 描述
|
||||||
|
* @Author SaiSai.Liu
|
||||||
|
* @Date 2024/3/14/0014 20:46
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
public class AttributeGroupResp extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 主键
|
||||||
|
*/
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组名
|
||||||
|
*/
|
||||||
|
@Excel(name = "组名")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private List<Attribute> attributeList;
|
||||||
|
|
||||||
|
private List<Long> getAsAttributeIds;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*/
|
||||||
|
@Excel(name = "状态")
|
||||||
|
private String states;
|
||||||
|
|
||||||
|
//创建添加属性组构建体
|
||||||
|
public static AttributeGroupResp saveBuilder(AttributeGroupReq attributeGroupReq) {
|
||||||
|
return AttributeGroupResp.builder()
|
||||||
|
.name(attributeGroupReq.getName())
|
||||||
|
.states(attributeGroupReq.getStates())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//创建修改属性组构建体
|
||||||
|
public static AttributeGroupResp editBuilder(AttributeGroupReq attributeGroupReq) {
|
||||||
|
return AttributeGroupResp.builder()
|
||||||
|
.id(attributeGroupReq.getId())
|
||||||
|
.name(attributeGroupReq.getName())
|
||||||
|
.states(attributeGroupReq.getStates())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AttributeGroupResp createBuilder(AttributeGroupReq attributeGroupReq) {
|
||||||
|
return AttributeGroupResp.builder()
|
||||||
|
.name(attributeGroupReq.getName())
|
||||||
|
.states(attributeGroupReq.getStates())
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AttributeGroupResp saveBuilder(AttributeGroup attributeGroup1, List<Attribute> attributes) {
|
||||||
|
return AttributeGroupResp.builder()
|
||||||
|
.name(attributeGroup1.getName())
|
||||||
|
.states(attributeGroup1.getStates())
|
||||||
|
.id(attributeGroup1.getId())
|
||||||
|
.attributeList(attributes)
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,6 +2,10 @@ package com.muyu.product.domain.resp;
|
||||||
|
|
||||||
import com.muyu.common.core.web.domain.TreeEntity;
|
import com.muyu.common.core.web.domain.TreeEntity;
|
||||||
import com.muyu.common.security.utils.SecurityUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
|
import com.muyu.product.domain.Attribute;
|
||||||
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
|
import com.muyu.product.domain.Brand;
|
||||||
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
import com.muyu.product.domain.req.CategoryReq;
|
import com.muyu.product.domain.req.CategoryReq;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
@ -9,6 +13,8 @@ import lombok.NoArgsConstructor;
|
||||||
import lombok.experimental.SuperBuilder;
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @ClassName CategoryResp
|
* @ClassName CategoryResp
|
||||||
|
@ -33,11 +39,9 @@ public class CategoryResp extends TreeEntity {
|
||||||
|
|
||||||
/** 是否启用 */
|
/** 是否启用 */
|
||||||
private String status;
|
private String status;
|
||||||
|
private List<Attribute> checkAttributeList;
|
||||||
private String createBy;
|
private List<AttributeGroup> checkedAttributeGroupList;
|
||||||
private String updateBy;
|
private List<Brand> brandList;
|
||||||
private Date createTime;
|
|
||||||
private Date updateTime;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,12 +49,12 @@ public class CategoryResp extends TreeEntity {
|
||||||
* @param categoryReq
|
* @param categoryReq
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static CategoryResp saveBuilder(CategoryReq categoryReq){
|
public static CategoryResp saveBuilder(CategoryReq categoryReq, Supplier<String> username){
|
||||||
return CategoryResp.builder()
|
return CategoryResp.builder()
|
||||||
.name(categoryReq.getName())
|
.name(categoryReq.getName())
|
||||||
.image(categoryReq.getImage())
|
.image(categoryReq.getImage())
|
||||||
.status(categoryReq.getStatus())
|
.status(categoryReq.getStatus())
|
||||||
.createBy(SecurityUtils.getUsername())
|
.createBy(username.get())
|
||||||
.createTime(new Date())
|
.createTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
@ -61,12 +65,12 @@ public class CategoryResp extends TreeEntity {
|
||||||
* @param categoryReq
|
* @param categoryReq
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static CategoryResp updateBuilder(CategoryReq categoryReq){
|
public static CategoryResp updateBuilder(CategoryReq categoryReq,Supplier<String> username){
|
||||||
return CategoryResp.builder()
|
return CategoryResp.builder()
|
||||||
.name(categoryReq.getName())
|
.name(categoryReq.getName())
|
||||||
.image(categoryReq.getImage())
|
.image(categoryReq.getImage())
|
||||||
.status(categoryReq.getStatus())
|
.status(categoryReq.getStatus())
|
||||||
.updateBy(SecurityUtils.getUsername())
|
.updateBy(username.get())
|
||||||
.updateTime(new Date())
|
.updateTime(new Date())
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
|
@ -87,6 +87,26 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{createBy: null, createTime: "2024-02-29 21:37:52", updateBy: null, updateTime: "2024-03-10 16:06:52",…}
|
||||||
|
ancestors:null
|
||||||
|
checkedAttributeGroupIds:[2]
|
||||||
|
checkedAttributeIds:[5, 3]
|
||||||
|
checkedBrandIds:[2]
|
||||||
|
children:[]
|
||||||
|
createBy:null
|
||||||
|
createTime:"2024-02-29 21:37:52"
|
||||||
|
id:1
|
||||||
|
image:"http://127.0.0.1:9300/statics/2024/02/29/8000030_20240229213748A003.jpg"
|
||||||
|
name:"电子产品"
|
||||||
|
orderNum:null
|
||||||
|
parentId:0
|
||||||
|
parentName:null
|
||||||
|
remark: null
|
||||||
|
status: "Y"
|
||||||
|
updateBy: null
|
||||||
|
updateTime: "2024-03-10 16:06:52"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import javax.servlet.http.HttpServletResponse;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.muyu.product.domain.Attribute;
|
import com.muyu.product.domain.Attribute;
|
||||||
import com.muyu.product.domain.req.AttributeGroupReq;
|
import com.muyu.product.domain.req.AttributeGroupReq;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupResp;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
@ -44,10 +45,10 @@ public class AttributeGroupController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("product:group:list")
|
@RequiresPermissions("product:group:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result<TableDataInfo<AttributeGroup>> list(AttributeGroup attributeGroup)
|
public Result<TableDataInfo<AttributeGroupResp>> list(AttributeGroup attributeGroup)
|
||||||
{
|
{
|
||||||
startPage();
|
startPage();
|
||||||
List<AttributeGroup> list = attributeGroupService.selectAttributeGroupList(attributeGroup);
|
List<AttributeGroupResp> list = attributeGroupService.selectAttributeGroupList(attributeGroup);
|
||||||
return getDataTable(list);
|
return getDataTable(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,8 +60,8 @@ public class AttributeGroupController extends BaseController
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, AttributeGroup attributeGroup)
|
public void export(HttpServletResponse response, AttributeGroup attributeGroup)
|
||||||
{
|
{
|
||||||
List<AttributeGroup> list = attributeGroupService.selectAttributeGroupList(attributeGroup);
|
List<AttributeGroupResp> list = attributeGroupService.selectAttributeGroupList(attributeGroup);
|
||||||
ExcelUtil<AttributeGroup> util = new ExcelUtil<AttributeGroup>(AttributeGroup.class);
|
ExcelUtil<AttributeGroupResp> util = new ExcelUtil<AttributeGroupResp>(AttributeGroupResp.class);
|
||||||
util.exportExcel(response, list, "属性组数据");
|
util.exportExcel(response, list, "属性组数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,9 +44,9 @@ public class CategoryInfoController extends BaseController
|
||||||
*/
|
*/
|
||||||
@RequiresPermissions("product:category_info:list")
|
@RequiresPermissions("product:category_info:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public Result list(CategoryInfo categoryInfo)
|
public Result list(CategoryInfoSaveModel categoryInfoSaveModel)
|
||||||
{
|
{
|
||||||
List<CategoryInfo> list = categoryInfoService.selectCategoryInfoList(categoryInfo);
|
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
|
||||||
return success(list);
|
return success(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,10 +56,10 @@ public class CategoryInfoController extends BaseController
|
||||||
@RequiresPermissions("product:category_info:export")
|
@RequiresPermissions("product:category_info:export")
|
||||||
@Log(title = "品类信息", businessType = BusinessType.EXPORT)
|
@Log(title = "品类信息", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(HttpServletResponse response, CategoryInfo categoryInfo)
|
public void export(HttpServletResponse response, CategoryInfoSaveModel categoryInfoSaveModel)
|
||||||
{
|
{
|
||||||
List<CategoryInfo> list = categoryInfoService.selectCategoryInfoList(categoryInfo);
|
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
|
||||||
ExcelUtil<CategoryInfo> util = new ExcelUtil<CategoryInfo>(CategoryInfo.class);
|
ExcelUtil<CategoryResp> util = new ExcelUtil<CategoryResp>(CategoryResp.class);
|
||||||
util.exportExcel(response, list, "品类信息数据");
|
util.exportExcel(response, list, "品类信息数据");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,9 +90,9 @@ public class CategoryInfoController extends BaseController
|
||||||
@RequiresPermissions("product:category_info:edit")
|
@RequiresPermissions("product:category_info:edit")
|
||||||
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping
|
@PutMapping
|
||||||
public Result edit(@RequestBody CategoryInfo categoryInfo)
|
public Result edit(@RequestBody CategoryInfoSaveModel categoryInfoSaveModel)
|
||||||
{
|
{
|
||||||
return toAjax(categoryInfoService.updateCategoryInfo(categoryInfo));
|
return toAjax(categoryInfoService.updateCategoryInfo(categoryInfoSaveModel));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.product.domain.Address;
|
import com.muyu.product.domain.Address;
|
||||||
import com.muyu.product.domain.AttributeGroup;
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
import com.muyu.product.domain.req.AttributeGroupReq;
|
import com.muyu.product.domain.req.AttributeGroupReq;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 属性组Service接口
|
* 属性组Service接口
|
||||||
|
@ -29,7 +30,7 @@ public interface IAttributeGroupService extends IService<AttributeGroup>
|
||||||
* @param attributeGroup 属性组
|
* @param attributeGroup 属性组
|
||||||
* @return 属性组集合
|
* @return 属性组集合
|
||||||
*/
|
*/
|
||||||
List<AttributeGroup> selectAttributeGroupList(AttributeGroup attributeGroup);
|
List<AttributeGroupResp> selectAttributeGroupList(AttributeGroup attributeGroup);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增属性组
|
* 新增属性组
|
||||||
|
|
|
@ -6,6 +6,8 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
import com.muyu.product.domain.Address;
|
import com.muyu.product.domain.Address;
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.req.CategoryReq;
|
||||||
|
import com.muyu.product.domain.resp.CategoryResp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service接口
|
* 品类信息Service接口
|
||||||
|
@ -26,26 +28,26 @@ public interface ICategoryInfoService extends IService<CategoryInfo>
|
||||||
/**
|
/**
|
||||||
* 查询品类信息列表
|
* 查询品类信息列表
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 品类信息集合
|
* @return 品类信息集合
|
||||||
*/
|
*/
|
||||||
List<CategoryInfo> selectCategoryInfoList(CategoryInfo categoryInfo);
|
List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增品类信息
|
* 新增品类信息
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int insertCategoryInfo(CategoryInfo categoryInfo);
|
int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改品类信息
|
* 修改品类信息
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
int updateCategoryInfo(CategoryInfo categoryInfo);
|
boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 批量删除品类信息
|
* 批量删除品类信息
|
||||||
|
|
|
@ -6,6 +6,7 @@ import com.muyu.product.domain.AsAttributeGroup;
|
||||||
import com.muyu.product.domain.Attribute;
|
import com.muyu.product.domain.Attribute;
|
||||||
import com.muyu.product.domain.AttributeGroup;
|
import com.muyu.product.domain.AttributeGroup;
|
||||||
import com.muyu.product.domain.req.AttributeGroupReq;
|
import com.muyu.product.domain.req.AttributeGroupReq;
|
||||||
|
import com.muyu.product.domain.resp.AttributeGroupResp;
|
||||||
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
import com.muyu.product.mapper.AsAttributeGroupMapper;
|
||||||
import com.muyu.product.mapper.AttributeGroupMapper;
|
import com.muyu.product.mapper.AttributeGroupMapper;
|
||||||
import com.muyu.product.service.IAsAttributeGroupService;
|
import com.muyu.product.service.IAsAttributeGroupService;
|
||||||
|
@ -64,9 +65,9 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId())));
|
asAttributeGroups.forEach(asAttributeGroup -> attributeLongs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId())));
|
||||||
asAttributeGroups.forEach(asAttributeGroup -> longs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()).getId()));
|
asAttributeGroups.forEach(asAttributeGroup -> longs.add(attributeService.selectAttributeById(asAttributeGroup.getAttributeId()).getId()));
|
||||||
asAttributeGroups.forEach(asAttributeGroup -> asIds.add(asAttributeGroup.getId()));
|
asAttributeGroups.forEach(asAttributeGroup -> asIds.add(asAttributeGroup.getId()));
|
||||||
group.setAttributeList(attributeLongs);
|
// group.setAttributeList(attributeLongs);
|
||||||
group.setCheckedAttributeIds(longs);
|
// group.setCheckedAttributeIds(longs);
|
||||||
group.setAsAttributeIds(asIds);
|
// group.setAsAttributeIds(asIds);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -78,10 +79,16 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
* @return 属性组
|
* @return 属性组
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<AttributeGroup> selectAttributeGroupList(AttributeGroup attributeGroup) {
|
public List<AttributeGroupResp> selectAttributeGroupList(AttributeGroup attributeGroup) {
|
||||||
List<AttributeGroup> attributeGroups = attributeGroupMapper.selectAttributeGroupList(attributeGroup);
|
List<AttributeGroup> attributeGroups = attributeGroupMapper.selectAttributeGroupList(attributeGroup);
|
||||||
attributeGroups.forEach(this::setAttributeList);
|
attributeGroups.forEach(this::setAttributeList);
|
||||||
return attributeGroups;
|
List<AttributeGroupResp> list = attributeGroups.stream().map(group ->
|
||||||
|
AttributeGroupResp.saveBuilder(group,attributeService.listByIds(asAttributeGroupService.list(
|
||||||
|
new LambdaQueryWrapper<AsAttributeGroup>()
|
||||||
|
.eq(AsAttributeGroup::getGroupId, group.getId()))
|
||||||
|
.stream().map(AsAttributeGroup::getAttributeId).toList()))
|
||||||
|
).toList();
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +128,11 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
.map(attributeId -> AsAttributeGroup
|
.map(attributeId -> AsAttributeGroup
|
||||||
.saveBuilder(attributeGroup.getId(), attributeId))
|
.saveBuilder(attributeGroup.getId(), attributeId))
|
||||||
.toList();
|
.toList();
|
||||||
asAttributeGroupService.removeBatchByIds(attributeGroup.getAsAttributeIds());
|
// attributeGroup.getAsAttributeIds()
|
||||||
|
asAttributeGroupService.removeBatchByIds(asAttributeGroupService.list(new LambdaQueryWrapper<AsAttributeGroup>()
|
||||||
|
.eq(AsAttributeGroup::getGroupId,attributeGroup.getId()))
|
||||||
|
.stream().map(AsAttributeGroup::getId).toList()
|
||||||
|
);
|
||||||
asAttributeGroupService.saveBatch(asAttributeGroups);
|
asAttributeGroupService.saveBatch(asAttributeGroups);
|
||||||
// asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup));
|
// asAttributeGroups.forEach(asAttributeGroup -> asAttributeGroupService.updateAsAttributeGroup(asAttributeGroup));
|
||||||
return asAttributeGroups.size();
|
return asAttributeGroups.size();
|
||||||
|
|
|
@ -1,19 +1,18 @@
|
||||||
package com.muyu.product.service.impl;
|
package com.muyu.product.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
import com.muyu.common.core.utils.DateUtils;
|
import com.muyu.common.security.utils.SecurityUtils;
|
||||||
import com.muyu.product.domain.CategoryAttribute;
|
import com.muyu.product.domain.*;
|
||||||
import com.muyu.product.domain.CategoryAttributeGroup;
|
|
||||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
import com.muyu.product.service.ICategoryAttributeService;
|
import com.muyu.product.domain.resp.CategoryResp;
|
||||||
|
import com.muyu.product.mapper.CategoryInfoMapper;
|
||||||
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.muyu.product.mapper.CategoryInfoMapper;
|
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
import java.util.List;
|
||||||
import com.muyu.product.service.ICategoryInfoService;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Service业务层处理
|
* 品类信息Service业务层处理
|
||||||
|
@ -23,14 +22,22 @@ import com.muyu.product.service.ICategoryInfoService;
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper,CategoryInfo> implements ICategoryInfoService
|
public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, CategoryInfo> implements ICategoryInfoService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryInfoMapper categoryInfoMapper;
|
private CategoryInfoMapper categoryInfoMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private ICategoryAttributeService categoryAttributeService;
|
private ICategoryAttributeService categoryAttributeService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private CategoryAttributeGroupServiceImpl categoryAttributeGroupService;
|
private ICategoryAttributeGroupService categoryAttributeGroupService;
|
||||||
|
@Autowired
|
||||||
|
private IBrandCategoryService brandCategoryService;
|
||||||
|
@Autowired
|
||||||
|
private IAttributeService attributeService;
|
||||||
|
@Autowired
|
||||||
|
private IAttributeGroupService groupService;
|
||||||
|
@Autowired
|
||||||
|
private IBrandService brandService;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询品类信息
|
* 查询品类信息
|
||||||
|
@ -39,47 +46,100 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper,Cate
|
||||||
* @return 品类信息
|
* @return 品类信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public CategoryInfo selectCategoryInfoById(Long id)
|
public CategoryInfo selectCategoryInfoById(Long id) {
|
||||||
{
|
|
||||||
return categoryInfoMapper.selectCategoryInfoById(id);
|
return categoryInfoMapper.selectCategoryInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询品类信息列表
|
* 查询品类信息列表
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 品类信息
|
* @return 品类信息
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<CategoryInfo> selectCategoryInfoList(CategoryInfo categoryInfo)
|
public List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
{
|
//三大响应结果集
|
||||||
return categoryInfoMapper.selectCategoryInfoList(categoryInfo);
|
// List<CategoryAttribute> categoryAttributes = CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||||
|
// List<CategoryAttributeGroup> categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||||
|
// List<BrandCategory> brandCategories = BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername);
|
||||||
|
// List<CategoryInfo> categoryInfos = null;
|
||||||
|
|
||||||
|
|
||||||
|
List<CategoryResp> list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryInfoSaveModel)).stream().map(categoryInfo -> {
|
||||||
|
CategoryInfoSaveModel infoSaveModel = new CategoryInfoSaveModel();
|
||||||
|
infoSaveModel.setId(categoryInfo.getId());
|
||||||
|
List<Long> attrIds = categoryAttributeService.list(new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttribute::getAttributeId).toList();
|
||||||
|
List<Long> groupIds = categoryAttributeGroupService.list(new LambdaQueryWrapper<CategoryAttributeGroup>().eq(CategoryAttributeGroup::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttributeGroup::getAttributeGroupId).toList();
|
||||||
|
List<Long> brandIds = brandCategoryService.list(new LambdaQueryWrapper<BrandCategory>().eq(BrandCategory::getCategoryId, categoryInfo.getId())).stream().map(BrandCategory::getBrandId).toList();
|
||||||
|
CategoryResp build = CategoryResp.builder()
|
||||||
|
.id(categoryInfo.getId())
|
||||||
|
.parentId(categoryInfo.getParentId())
|
||||||
|
.name(categoryInfo.getName())
|
||||||
|
.image(categoryInfo.getImage())
|
||||||
|
.status(categoryInfo.getStatus())
|
||||||
|
.brandList(brandIds.isEmpty() ? null : brandService.listByIds(brandIds))
|
||||||
|
.checkAttributeList(attrIds.isEmpty() ? null : attributeService.listByIds(attrIds))
|
||||||
|
.checkedAttributeGroupList(groupIds.isEmpty() ? null : groupService.listByIds(groupIds))
|
||||||
|
.build();
|
||||||
|
return build;
|
||||||
|
}).toList();
|
||||||
|
|
||||||
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 新增品类信息
|
* 新增品类信息
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertCategoryInfo(CategoryInfo categoryInfo)
|
public int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
{
|
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel);
|
||||||
categoryInfo.setCreateTime(DateUtils.getNowDate());
|
int i = categoryInfoMapper.insertCategoryInfo(categoryInfo);
|
||||||
return categoryInfoMapper.insertCategoryInfo(categoryInfo);
|
categoryInfoSaveModel.setId(categoryInfo.getId());
|
||||||
|
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||||
|
categoryAttributeGroupService.saveBatch(CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||||
|
brandCategoryService.saveBatch(BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||||
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改品类信息
|
* 修改品类信息
|
||||||
*
|
*
|
||||||
* @param categoryInfo 品类信息
|
* @param categoryInfoSaveModel 品类信息
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updateCategoryInfo(CategoryInfo categoryInfo)
|
public boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
{
|
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel);
|
||||||
categoryInfo.setUpdateTime(DateUtils.getNowDate());
|
|
||||||
return categoryInfoMapper.updateCategoryInfo(categoryInfo);
|
boolean updated = this.update(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, categoryInfo.getId()));
|
||||||
|
// LambdaQueryWrapper<CategoryAttribute> attributeWrapper = new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId,categoryInfoSaveModel.getId());
|
||||||
|
//删除中间表数据
|
||||||
|
categoryAttributeService.remove(new LambdaQueryWrapper<CategoryAttribute>()
|
||||||
|
.eq(CategoryAttribute::getCategoryId, categoryInfoSaveModel.getId())
|
||||||
|
);
|
||||||
|
//添加新数据
|
||||||
|
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername));
|
||||||
|
//修改属性组中间表
|
||||||
|
// LambdaQueryWrapper<CategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<CategoryAttributeGroup>();
|
||||||
|
categoryAttributeGroupService.remove(new LambdaQueryWrapper<CategoryAttributeGroup>()
|
||||||
|
.eq(CategoryAttributeGroup::getCategoryId, categoryInfoSaveModel.getId())
|
||||||
|
);
|
||||||
|
categoryAttributeGroupService.saveBatch(
|
||||||
|
CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername)
|
||||||
|
);
|
||||||
|
// LambdaQueryWrapper<BrandCategory> brandWrapper = new LambdaQueryWrapper<BrandCategory>();
|
||||||
|
brandCategoryService.remove(
|
||||||
|
new LambdaQueryWrapper<BrandCategory>()
|
||||||
|
.eq(BrandCategory::getCategoryId, categoryInfoSaveModel.getId())
|
||||||
|
);
|
||||||
|
brandCategoryService.saveBatch(
|
||||||
|
BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername)
|
||||||
|
);
|
||||||
|
|
||||||
|
return updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -89,8 +149,7 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper,Cate
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteCategoryInfoByIds(Long[] ids)
|
public int deleteCategoryInfoByIds(Long[] ids) {
|
||||||
{
|
|
||||||
return categoryInfoMapper.deleteCategoryInfoByIds(ids);
|
return categoryInfoMapper.deleteCategoryInfoByIds(ids);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -101,11 +160,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper,Cate
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deleteCategoryInfoById(Long id)
|
public int deleteCategoryInfoById(Long id) {
|
||||||
{
|
categoryAttributeService.remove(new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId, id));
|
||||||
|
categoryAttributeGroupService.remove(new LambdaQueryWrapper<CategoryAttributeGroup>().eq(CategoryAttributeGroup::getCategoryId, id));
|
||||||
|
brandCategoryService.remove(new LambdaQueryWrapper<BrandCategory>().eq(BrandCategory::getCategoryId, id));
|
||||||
return categoryInfoMapper.deleteCategoryInfoById(id);
|
return categoryInfoMapper.deleteCategoryInfoById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品类数据添加
|
||||||
|
*
|
||||||
|
* @param categoryInfoSaveModel
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) {
|
||||||
//通过品类信息构建体构建品类对象
|
//通过品类信息构建体构建品类对象
|
||||||
|
@ -117,17 +184,17 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper,Cate
|
||||||
//获取已选属性主键集
|
//获取已选属性主键集
|
||||||
List<Long> checkedAttributeIds = categoryInfoSaveModel.getCheckedAttributeIds();
|
List<Long> checkedAttributeIds = categoryInfoSaveModel.getCheckedAttributeIds();
|
||||||
//判断已选属性集是否为空
|
//判断已选属性集是否为空
|
||||||
if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()){
|
if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()) {
|
||||||
categoryAttributeService.saveBatch(
|
categoryAttributeService.saveBatch(
|
||||||
checkedAttributeIds.stream()
|
checkedAttributeIds.stream()
|
||||||
.map(attributeId -> CategoryAttribute.categoryBuilder(id,attributeId)).toList()
|
.map(attributeId -> CategoryAttribute.categoryBuilder(id, attributeId, SecurityUtils::getUsername)).toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
List<Long> attributeGroupIds = categoryInfoSaveModel.getAttributeGroupIds();
|
List<Long> attributeGroupIds = categoryInfoSaveModel.getCheckedAttributeGroupIds();
|
||||||
if (attributeGroupIds != null && !attributeGroupIds.isEmpty()){
|
if (attributeGroupIds != null && !attributeGroupIds.isEmpty()) {
|
||||||
categoryAttributeGroupService.saveBatch(
|
categoryAttributeGroupService.saveBatch(
|
||||||
attributeGroupIds.stream().
|
attributeGroupIds.stream().
|
||||||
map(groupId -> CategoryAttributeGroup.saveBuilder(id,groupId)).toList()
|
map(groupId -> CategoryAttributeGroup.saveBuilder(id, groupId, SecurityUtils::getUsername)).toList()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return save;
|
return save;
|
||||||
|
|
Loading…
Reference in New Issue