品类组件响应,属性组bug修改

day-06
Saisai Liu 2024-03-22 21:08:51 +08:00
parent 8733328cb1
commit b063dfca72
16 changed files with 269 additions and 227 deletions

View File

@ -37,7 +37,6 @@ public class AttributeGroup extends BaseEntity
@Excel(name = "组名") @Excel(name = "组名")
private String name; private String name;
private List<Attribute> attributeList;
/** 状态 */ /** 状态 */
@Excel(name = "状态") @Excel(name = "状态")

View File

@ -2,7 +2,7 @@ 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.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.req.CategoryReq;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -40,13 +40,13 @@ public class BrandCategory extends BaseEntity
private Long brandId; private Long brandId;
public static List<BrandCategory> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> getUsername) { public static List<BrandCategory> saveBuilderList(CategoryReq categoryReq, Supplier<String> getUsername) {
return categoryReq.getCheckedBrandIds().stream().map( return categoryReq.getCheckedBrandIds().stream().map(
brandId -> BrandCategory.saveBuilder(categoryReq.getId(),brandId,getUsername) brandId -> BrandCategory.saveBuilder(categoryReq.getId(),brandId,getUsername)
).toList(); ).toList();
} }
private static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier<String> getUsername) { public static BrandCategory saveBuilder(Long categoryId, Long brandId, Supplier<String> getUsername) {
return BrandCategory.builder() return BrandCategory.builder()
.brandId(brandId) .brandId(brandId)
.categoryId(categoryId) .categoryId(categoryId)
@ -54,4 +54,13 @@ public class BrandCategory extends BaseEntity
.createTime(new Date()) .createTime(new Date())
.build(); .build();
} }
public static BrandCategory saveBrandBuilder(Long id, Long brandId, Supplier<String> username) {
return BrandCategory.builder()
.categoryId(id)
.brandId(brandId)
.createBy(username.get())
.createTime(new Date())
.build();
}
} }

View File

@ -2,7 +2,7 @@ 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.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.req.CategoryReq;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -48,7 +48,7 @@ public class CategoryAttribute extends BaseEntity
.build(); .build();
} }
public static List<CategoryAttribute> saveBuilder(CategoryInfoSaveModel categoryReq, Supplier<String> username) { public static List<CategoryAttribute> saveBuilder(CategoryReq categoryReq, Supplier<String> username) {
return categoryReq.getCheckedAttributeIds().stream().map( return categoryReq.getCheckedAttributeIds().stream().map(
attributeId -> categoryBuilder(categoryReq.getId(),attributeId,username) attributeId -> categoryBuilder(categoryReq.getId(),attributeId,username)
).toList(); ).toList();

View File

@ -2,7 +2,7 @@ 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.product.domain.model.CategoryInfoSaveModel; import com.muyu.product.domain.req.CategoryReq;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -61,7 +61,7 @@ public class CategoryAttributeGroup extends BaseEntity {
.build(); .build();
} }
public static List<CategoryAttributeGroup> saveBuilderList(CategoryInfoSaveModel categoryReq, Supplier<String> username) { public static List<CategoryAttributeGroup> saveBuilderList(CategoryReq categoryReq, Supplier<String> username) {
return categoryReq.getCheckedAttributeGroupIds().stream().map( return categoryReq.getCheckedAttributeGroupIds().stream().map(
groupId -> saveBuilder(categoryReq.getId(), groupId, username) groupId -> saveBuilder(categoryReq.getId(), groupId, username)
).toList(); ).toList();

View File

@ -2,7 +2,6 @@ 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.TreeEntity; import com.muyu.common.core.web.domain.TreeEntity;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
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;
@ -57,7 +56,7 @@ public class CategoryInfo extends TreeEntity
/** 响应值对象 */ /** 响应值对象 */
public static CategoryInfo saveCategoryBuilder(CategoryInfoSaveModel req){ public static CategoryInfo saveCategoryBuilder(CategoryReq req){
return CategoryInfo.builder() return CategoryInfo.builder()
.name(req.getName()) .name(req.getName())
.status(req.getStatus()) .status(req.getStatus())
@ -69,7 +68,7 @@ public class CategoryInfo extends TreeEntity
.build(); .build();
} }
public static CategoryInfo saveBuilder(CategoryInfoSaveModel categoryReq) { public static CategoryInfo saveBuilder(CategoryReq categoryReq) {
return CategoryInfo.builder() return CategoryInfo.builder()
.id(categoryReq.getId()) .id(categoryReq.getId())
.name(categoryReq.getName()) .name(categoryReq.getName())

View File

@ -48,8 +48,8 @@ public class ProductInfo extends BaseEntity
private String images; private String images;
/** 发货地 */ /** 发货地 */
@Excel(name = "发货地") @Excel(name = "轮播图")
private String addressSend; private String slideshow;
/** 商品状态 */ /** 商品状态 */
@Excel(name = "商品状态") @Excel(name = "商品状态")
@ -64,112 +64,5 @@ public class ProductInfo extends BaseEntity
/** 更新人 */ /** 更新人 */
private String updatedBy; private String updatedBy;
public void setId(Long id)
{
this.id = id;
}
public Long getId()
{
return id;
}
public void setName(String name)
{
this.name = name;
}
public String getName()
{
return name;
}
public void setIntroduction(String introduction)
{
this.introduction = introduction;
}
public String getIntroduction()
{
return introduction;
}
public void setBrandId(Long brandId)
{
this.brandId = brandId;
}
public Long getBrandId()
{
return brandId;
}
public void setImages(String images)
{
this.images = images;
}
public String getImages()
{
return images;
}
public void setAddressSend(String addressSend)
{
this.addressSend = addressSend;
}
public String getAddressSend()
{
return addressSend;
}
public void setStatus(String status)
{
this.status = status;
}
public String getStatus()
{
return status;
}
public void setCreatedBy(String createdBy)
{
this.createdBy = createdBy;
}
public String getCreatedBy()
{
return createdBy;
}
public void setCreatedTime(Date createdTime)
{
this.createdTime = createdTime;
}
public Date getCreatedTime()
{
return createdTime;
}
public void setUpdatedBy(String updatedBy)
{
this.updatedBy = updatedBy;
}
public String getUpdatedBy()
{
return updatedBy;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("introduction", getIntroduction())
.append("brandId", getBrandId())
.append("images", getImages())
.append("addressSend", getAddressSend())
.append("status", getStatus())
.append("remark", getRemark())
.append("createdBy", getCreatedBy())
.append("createdTime", getCreatedTime())
.append("updatedBy", getUpdatedBy())
.append("updateTime", getUpdateTime())
.toString();
}
} }

View File

@ -11,6 +11,8 @@ import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
/** /**
* rule_product * rule_product
* *
@ -35,11 +37,12 @@ public class RuleProduct extends BaseEntity
/** 规格编号 */ /** 规格编号 */
@Excel(name = "规格编号") @Excel(name = "规格编号")
private Long ruleId; private String sku;
/** 规格值 */ /** 规格值 */
@Excel(name = "规格值") @Excel(name = "规格值")
private String ruleValue; private String ruleValue;
private Integer stock;
private BigDecimal price;
} }

View File

@ -0,0 +1,21 @@
package com.muyu.product.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @ClassName AttrValueModel
* @Description
* @Author SaiSai.Liu
* @Date 2024/3/22/0022 20:11
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AttrValueModel {
private Long id;
private String value;
}

View File

@ -0,0 +1,62 @@
package com.muyu.product.domain.model;
import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.Date;
/**
* @ClassName ProductAddModel
* @Description
* @Author SaiSai.Liu
* @Date 2024/3/22/0022 20:22
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息")
public class ProductAddModel extends BaseEntity {
/** 主键 */
private Long id;
/** 商品名 */
@Excel(name = "商品名")
private String name;
/** 商品信息 */
@Excel(name = "商品信息")
private String introduction;
/** 品牌编号 */
@Excel(name = "品牌编号")
private Long brandId;
/** 图片 */
@Excel(name = "图片")
private String images;
/** 发货地 */
@Excel(name = "轮播图")
private String slideshow;
/** 商品状态 */
@Excel(name = "商品状态")
private String status;
/** 创建人 */
private String createdBy;
/** 创建时间 */
private Date createdTime;
/** 更新人 */
private String updatedBy;
}

View File

@ -0,0 +1,25 @@
package com.muyu.product.domain.model;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.math.BigDecimal;
/**
* @ClassName ProductSkuModel
* @Description
* @Author SaiSai.Liu
* @Date 2024/3/22/0022 20:12
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class ProductSkuModel {
private String sku;
private Long stock;
private BigDecimal price;
private String image;
}

View File

@ -0,0 +1,34 @@
package com.muyu.product.domain.req;
import com.muyu.common.core.web.domain.BaseEntity;
import com.muyu.product.domain.model.AttrValueModel;
import com.muyu.product.domain.model.ProductAddModel;
import com.muyu.product.domain.model.ProductSkuModel;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.util.List;
/**
* @ClassName ProductInfoSaveReq
* @Description
* @Author SaiSai.Liu
* @Date 2024/3/22/0022 20:17
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProjectInfoSaveReq", description = "商品信息")
public class ProductInfoSaveReq extends BaseEntity {
private static final long serialVersionUID = 1L;
private ProductAddModel productAddModel;
private List<AttrValueModel> attrValueList;
private List<ProductSkuModel> productList;
}

View File

@ -0,0 +1,30 @@
package com.muyu.product.domain.req;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.annotations.ApiModel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder;
import java.math.BigDecimal;
/**
* @ClassName ProductSkuInfoEditReq
* @Description
* @Author SaiSai.Liu
* @Date 2024/3/22/0022 19:52
*/
@Data
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ProjectSkuInfoEditReq", description = "商品SKU")
public class ProductSkuInfoEditReq extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long projectId;
private String sku;
private Long stock;
private BigDecimal price;
private String image;
}

View File

@ -1,30 +1,19 @@
package com.muyu.product.controller; package com.muyu.product.controller;
import java.util.List; import com.muyu.common.core.domain.Result;
import java.io.IOException; import com.muyu.common.core.utils.poi.ExcelUtil;
import javax.servlet.http.HttpServletResponse; import com.muyu.common.core.web.controller.BaseController;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryReq;
import com.muyu.product.domain.resp.CategoryResp;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.muyu.common.log.annotation.Log; import com.muyu.common.log.annotation.Log;
import com.muyu.common.log.enums.BusinessType; import com.muyu.common.log.enums.BusinessType;
import com.muyu.common.security.annotation.RequiresPermissions; import com.muyu.common.security.annotation.RequiresPermissions;
import com.muyu.product.domain.CategoryInfo; import com.muyu.product.domain.req.CategoryReq;
import com.muyu.product.domain.resp.CategoryResp;
import com.muyu.product.service.ICategoryInfoService; import com.muyu.product.service.ICategoryInfoService;
import com.muyu.common.core.web.controller.BaseController; import org.springframework.beans.factory.annotation.Autowired;
import com.muyu.common.core.domain.Result; import org.springframework.web.bind.annotation.*;
import com.muyu.common.core.utils.poi.ExcelUtil;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/** /**
* Controller * Controller
@ -34,8 +23,7 @@ import com.muyu.common.core.utils.poi.ExcelUtil;
*/ */
@RestController @RestController
@RequestMapping("/category_info") @RequestMapping("/category_info")
public class CategoryInfoController extends BaseController public class CategoryInfoController extends BaseController {
{
@Autowired @Autowired
private ICategoryInfoService categoryInfoService; private ICategoryInfoService categoryInfoService;
@ -44,9 +32,8 @@ public class CategoryInfoController extends BaseController
*/ */
@RequiresPermissions("product:category_info:list") @RequiresPermissions("product:category_info:list")
@GetMapping("/list") @GetMapping("/list")
public Result list(CategoryInfoSaveModel categoryInfoSaveModel) public Result list(CategoryReq categoryReq) {
{ List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryReq);
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
return success(list); return success(list);
} }
@ -56,9 +43,8 @@ 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, CategoryInfoSaveModel categoryInfoSaveModel) public void export(HttpServletResponse response, CategoryReq categoryReq) {
{ List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryReq);
List<CategoryResp> list = categoryInfoService.selectCategoryInfoList(categoryInfoSaveModel);
ExcelUtil<CategoryResp> util = new ExcelUtil<CategoryResp>(CategoryResp.class); ExcelUtil<CategoryResp> util = new ExcelUtil<CategoryResp>(CategoryResp.class);
util.exportExcel(response, list, "品类信息数据"); util.exportExcel(response, list, "品类信息数据");
} }
@ -68,8 +54,7 @@ public class CategoryInfoController extends BaseController
*/ */
@RequiresPermissions("product:category_info:query") @RequiresPermissions("product:category_info:query")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public Result getInfo(@PathVariable("id") Long id) public Result getInfo(@PathVariable("id") Long id) {
{
return success(categoryInfoService.selectCategoryInfoById(id)); return success(categoryInfoService.selectCategoryInfoById(id));
} }
@ -79,9 +64,8 @@ public class CategoryInfoController extends BaseController
@RequiresPermissions("product:category_info:add") @RequiresPermissions("product:category_info:add")
@Log(title = "品类信息", businessType = BusinessType.INSERT) @Log(title = "品类信息", businessType = BusinessType.INSERT)
@PostMapping @PostMapping
public Result add(@RequestBody CategoryReq categoryReq) public Result add(@RequestBody CategoryReq categoryReq) {
{ return toAjax(categoryInfoService.save(categoryReq));
return toAjax(categoryInfoService.save(CategoryInfoSaveModel.saveBuilder(categoryReq, SecurityUtils::getUsername )));
} }
/** /**
@ -90,9 +74,8 @@ 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 CategoryInfoSaveModel categoryInfoSaveModel) public Result edit(@RequestBody CategoryReq categoryReq) {
{ return toAjax(categoryInfoService.updateCategoryInfo(categoryReq));
return toAjax(categoryInfoService.updateCategoryInfo(categoryInfoSaveModel));
} }
/** /**
@ -100,9 +83,8 @@ public class CategoryInfoController extends BaseController
*/ */
@RequiresPermissions("product:category_info:remove") @RequiresPermissions("product:category_info:remove")
@Log(title = "品类信息", businessType = BusinessType.DELETE) @Log(title = "品类信息", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}") @DeleteMapping("/{ids}")
public Result remove(@PathVariable Long[] ids) public Result remove(@PathVariable Long[] ids) {
{
return toAjax(categoryInfoService.deleteCategoryInfoByIds(ids)); return toAjax(categoryInfoService.deleteCategoryInfoByIds(ids));
} }
} }

View File

@ -1,22 +1,19 @@
package com.muyu.product.service; package com.muyu.product.service;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
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.req.CategoryReq; import com.muyu.product.domain.req.CategoryReq;
import com.muyu.product.domain.resp.CategoryResp; import com.muyu.product.domain.resp.CategoryResp;
import java.util.List;
/** /**
* Service * Service
* *
* @author Saisai * @author Saisai
* @date 2024-02-29 * @date 2024-02-29
*/ */
public interface ICategoryInfoService extends IService<CategoryInfo> public interface ICategoryInfoService extends IService<CategoryInfo> {
{
/** /**
* *
* *
@ -28,26 +25,19 @@ public interface ICategoryInfoService extends IService<CategoryInfo>
/** /**
* *
* *
* @param categoryInfoSaveModel * @param categoryReq
* @return * @return
*/ */
List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel); List<CategoryResp> selectCategoryInfoList(CategoryReq categoryReq);
/**
*
*
* @param categoryInfoSaveModel
* @return
*/
int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel);
/** /**
* *
* *
* @param categoryInfoSaveModel * @param categoryReq
* @return * @return
*/ */
boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel); boolean updateCategoryInfo(CategoryReq categoryReq);
/** /**
* *
@ -65,5 +55,5 @@ public interface ICategoryInfoService extends IService<CategoryInfo>
*/ */
int deleteCategoryInfoById(Long id); int deleteCategoryInfoById(Long id);
boolean save(CategoryInfoSaveModel categoryInfoSaveModel); boolean save(CategoryReq categoryReq);
} }

View File

@ -3,8 +3,12 @@ package com.muyu.product.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; 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.security.utils.SecurityUtils; import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.product.domain.*; import com.muyu.product.domain.BrandCategory;
import com.muyu.product.domain.CategoryAttribute;
import com.muyu.product.domain.CategoryAttributeGroup;
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; import com.muyu.product.domain.resp.CategoryResp;
import com.muyu.product.mapper.CategoryInfoMapper; import com.muyu.product.mapper.CategoryInfoMapper;
import com.muyu.product.service.*; import com.muyu.product.service.*;
@ -53,19 +57,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
/** /**
* *
* *
* @param categoryInfoSaveModel * @param categoryReq
* @return * @return
*/ */
@Override @Override
public List<CategoryResp> selectCategoryInfoList(CategoryInfoSaveModel categoryInfoSaveModel) { public List<CategoryResp> selectCategoryInfoList(CategoryReq categoryReq) {
//三大响应结果集 //三大响应结果集
// List<CategoryAttribute> categoryAttributes = CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername); // List<CategoryAttribute> categoryAttributes = CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername);
// List<CategoryAttributeGroup> categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername); // List<CategoryAttributeGroup> categoryAttributeGroups = CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername);
// List<BrandCategory> brandCategories = BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername); // List<BrandCategory> brandCategories = BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername);
// List<CategoryInfo> categoryInfos = null; // List<CategoryInfo> categoryInfos = null;
List<CategoryResp> list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryInfoSaveModel)).stream().map(categoryInfo -> { List<CategoryResp> list = categoryInfoMapper.selectCategoryInfoList(CategoryInfo.saveBuilder(categoryReq)).stream().map(categoryInfo -> {
CategoryInfoSaveModel infoSaveModel = new CategoryInfoSaveModel(); CategoryInfoSaveModel infoSaveModel = new CategoryInfoSaveModel();
infoSaveModel.setId(categoryInfo.getId()); infoSaveModel.setId(categoryInfo.getId());
List<Long> attrIds = categoryAttributeService.list(new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttribute::getAttributeId).toList(); List<Long> attrIds = categoryAttributeService.list(new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId, categoryInfo.getId())).stream().map(CategoryAttribute::getAttributeId).toList();
@ -87,59 +91,43 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
return list; return list;
} }
/**
*
*
* @param categoryInfoSaveModel
* @return
*/
@Override
public int insertCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) {
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel);
int i = 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 categoryInfoSaveModel * @param categoryReq
* @return * @return
*/ */
@Override @Override
public boolean updateCategoryInfo(CategoryInfoSaveModel categoryInfoSaveModel) { public boolean updateCategoryInfo(CategoryReq categoryReq) {
CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryInfoSaveModel); CategoryInfo categoryInfo = CategoryInfo.saveBuilder(categoryReq);
// boolean updated = this.update(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, categoryInfo.getId()));
boolean updated = this.update(new LambdaQueryWrapper<CategoryInfo>().eq(CategoryInfo::getId, categoryInfo.getId())); boolean b = this.updateById(categoryInfo);
// LambdaQueryWrapper<CategoryAttribute> attributeWrapper = new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId,categoryInfoSaveModel.getId()); // LambdaQueryWrapper<CategoryAttribute> attributeWrapper = new LambdaQueryWrapper<CategoryAttribute>().eq(CategoryAttribute::getCategoryId,categoryReq.getId());
//删除中间表数据 //删除中间表数据
categoryAttributeService.remove(new LambdaQueryWrapper<CategoryAttribute>() categoryAttributeService.remove(new LambdaQueryWrapper<CategoryAttribute>()
.eq(CategoryAttribute::getCategoryId, categoryInfoSaveModel.getId()) .eq(CategoryAttribute::getCategoryId, categoryReq.getId())
); );
//添加新数据 //添加新数据
categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryInfoSaveModel, SecurityUtils::getUsername)); categoryAttributeService.saveBatch(CategoryAttribute.saveBuilder(categoryReq, SecurityUtils::getUsername));
//修改属性组中间表 //修改属性组中间表
// LambdaQueryWrapper<CategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<CategoryAttributeGroup>(); // LambdaQueryWrapper<CategoryAttributeGroup> groupWrapper = new LambdaQueryWrapper<CategoryAttributeGroup>();
categoryAttributeGroupService.remove(new LambdaQueryWrapper<CategoryAttributeGroup>() categoryAttributeGroupService.remove(new LambdaQueryWrapper<CategoryAttributeGroup>()
.eq(CategoryAttributeGroup::getCategoryId, categoryInfoSaveModel.getId()) .eq(CategoryAttributeGroup::getCategoryId, categoryReq.getId())
); );
categoryAttributeGroupService.saveBatch( categoryAttributeGroupService.saveBatch(
CategoryAttributeGroup.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername) CategoryAttributeGroup.saveBuilderList(categoryReq, SecurityUtils::getUsername)
); );
// LambdaQueryWrapper<BrandCategory> brandWrapper = new LambdaQueryWrapper<BrandCategory>(); // LambdaQueryWrapper<BrandCategory> brandWrapper = new LambdaQueryWrapper<BrandCategory>();
brandCategoryService.remove( brandCategoryService.remove(
new LambdaQueryWrapper<BrandCategory>() new LambdaQueryWrapper<BrandCategory>()
.eq(BrandCategory::getCategoryId, categoryInfoSaveModel.getId()) .eq(BrandCategory::getCategoryId, categoryReq.getId())
); );
brandCategoryService.saveBatch( brandCategoryService.saveBatch(
BrandCategory.saveBuilderList(categoryInfoSaveModel, SecurityUtils::getUsername) BrandCategory.saveBuilderList(categoryReq, SecurityUtils::getUsername)
); );
return updated; return b;
} }
/** /**
@ -170,19 +158,19 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
/** /**
* *
* *
* @param categoryInfoSaveModel * @param categoryReq
* @return * @return
*/ */
@Override @Override
public boolean save(CategoryInfoSaveModel categoryInfoSaveModel) { public boolean save(CategoryReq categoryReq) {
//通过品类信息构建体构建品类对象 //通过品类信息构建体构建品类对象
CategoryInfo categoryInfo = CategoryInfo.saveCategoryBuilder(categoryInfoSaveModel); CategoryInfo categoryInfo = CategoryInfo.saveCategoryBuilder(categoryReq);
//调用重载方法 //调用重载方法
boolean save = this.save(categoryInfo); boolean save = this.save(categoryInfo);
//获取当前品类主键 //获取当前品类主键
Long id = categoryInfo.getId(); Long id = categoryInfo.getId();
//获取已选属性主键集 //获取已选属性主键集
List<Long> checkedAttributeIds = categoryInfoSaveModel.getCheckedAttributeIds(); List<Long> checkedAttributeIds = categoryReq.getCheckedAttributeIds();
//判断已选属性集是否为空 //判断已选属性集是否为空
if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()) { if (checkedAttributeIds != null && !checkedAttributeIds.isEmpty()) {
categoryAttributeService.saveBatch( categoryAttributeService.saveBatch(
@ -190,13 +178,20 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
.map(attributeId -> CategoryAttribute.categoryBuilder(id, attributeId, SecurityUtils::getUsername)).toList() .map(attributeId -> CategoryAttribute.categoryBuilder(id, attributeId, SecurityUtils::getUsername)).toList()
); );
} }
List<Long> attributeGroupIds = categoryInfoSaveModel.getCheckedAttributeGroupIds(); List<Long> attributeGroupIds = categoryReq.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, SecurityUtils::getUsername)).toList() map(groupId -> CategoryAttributeGroup.saveBuilder(id, groupId, SecurityUtils::getUsername)).toList()
); );
} }
List<Long> brandIds = categoryReq.getCheckedBrandIds();
if (brandIds != null && !brandIds.isEmpty()) {
brandCategoryService.saveBatch(
brandIds.stream().
map(brandId -> BrandCategory.saveBrandBuilder(id, brandId, SecurityUtils::getUsername)).toList()
);
}
return save; return save;
} }
} }

View File

@ -10,7 +10,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="introduction" column="introduction" /> <result property="introduction" column="introduction" />
<result property="brandId" column="brand_id" /> <result property="brandId" column="brand_id" />
<result property="images" column="images" /> <result property="images" column="images" />
<result property="addressSend" column="address_send" /> <result property="slideshow" column="slideshow" />
<result property="status" column="status" /> <result property="status" column="status" />
<result property="remark" column="remark" /> <result property="remark" column="remark" />
<result property="createdBy" column="created_by" /> <result property="createdBy" column="created_by" />
@ -20,7 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap> </resultMap>
<sql id="selectProductInfoVo"> <sql id="selectProductInfoVo">
select id, name, introduction, brand_id, images, address_send, status, remark, created_by, created_time, updated_by, update_time from product_info select id, name, introduction, brand_id, images, slideshow, status, remark, created_by, created_time, updated_by, update_time from product_info
</sql> </sql>
<select id="selectProductInfoList" parameterType="com.muyu.product.domain.ProductInfo" resultMap="ProductInfoResult"> <select id="selectProductInfoList" parameterType="com.muyu.product.domain.ProductInfo" resultMap="ProductInfoResult">
@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if> <if test="introduction != null and introduction != ''"> and introduction = #{introduction}</if>
<if test="brandId != null "> and brand_id = #{brandId}</if> <if test="brandId != null "> and brand_id = #{brandId}</if>
<if test="images != null and images != ''"> and images = #{images}</if> <if test="images != null and images != ''"> and images = #{images}</if>
<if test="addressSend != null and addressSend != ''"> and address_send = #{addressSend}</if> <if test="slideshow != null and slideshow != ''"> and slideshow = #{slideshow}</if>
<if test="status != null and status != ''"> and status = #{status}</if> <if test="status != null and status != ''"> and status = #{status}</if>
</where> </where>
</select> </select>
@ -47,7 +47,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="introduction != null and introduction != ''">introduction,</if> <if test="introduction != null and introduction != ''">introduction,</if>
<if test="brandId != null">brand_id,</if> <if test="brandId != null">brand_id,</if>
<if test="images != null">images,</if> <if test="images != null">images,</if>
<if test="addressSend != null">address_send,</if> <if test="slideshow != null">slideshow,</if>
<if test="status != null and status != ''">status,</if> <if test="status != null and status != ''">status,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="createdBy != null">created_by,</if> <if test="createdBy != null">created_by,</if>
@ -60,7 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="introduction != null and introduction != ''">#{introduction},</if> <if test="introduction != null and introduction != ''">#{introduction},</if>
<if test="brandId != null">#{brandId},</if> <if test="brandId != null">#{brandId},</if>
<if test="images != null">#{images},</if> <if test="images != null">#{images},</if>
<if test="addressSend != null">#{addressSend},</if> <if test="slideshow != null">#{slideshow},</if>
<if test="status != null and status != ''">#{status},</if> <if test="status != null and status != ''">#{status},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
<if test="createdBy != null">#{createdBy},</if> <if test="createdBy != null">#{createdBy},</if>
@ -77,7 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="introduction != null and introduction != ''">introduction = #{introduction},</if> <if test="introduction != null and introduction != ''">introduction = #{introduction},</if>
<if test="brandId != null">brand_id = #{brandId},</if> <if test="brandId != null">brand_id = #{brandId},</if>
<if test="images != null">images = #{images},</if> <if test="images != null">images = #{images},</if>
<if test="addressSend != null">address_send = #{addressSend},</if> <if test="slideshow != null">slideshow = #{slideshow},</if>
<if test="status != null and status != ''">status = #{status},</if> <if test="status != null and status != ''">status = #{status},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="createdBy != null">created_by = #{createdBy},</if> <if test="createdBy != null">created_by = #{createdBy},</if>