类品信息TODO
parent
fba615cec8
commit
10b70d44e6
|
@ -0,0 +1,67 @@
|
||||||
|
package com.muyu.product.domain.req;
|
||||||
|
|
||||||
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.experimental.SuperBuilder;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Author:尚志豪
|
||||||
|
* @Package:com.muyu.product.domain.req
|
||||||
|
* @Project:cloud-server
|
||||||
|
* @name:CategoryInfoUpdEditReq
|
||||||
|
* @Date:2024/11/14 20:20
|
||||||
|
* TODO
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@SuperBuilder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
@ApiModel(value = "CategoryInfoUpdEditReq", description = "品类修改信息")
|
||||||
|
public class CategoryInfoUpdEditReq {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/** 主键 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "主键", value = "主键")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
/** 品类名称 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "品类名称", value = "品类名称", required = true)
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/** 图片 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "图片", value = "图片", required = true)
|
||||||
|
private String image;
|
||||||
|
|
||||||
|
/** 是否启用 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "是否启用", value = "是否启用", required = true)
|
||||||
|
private String start;
|
||||||
|
|
||||||
|
/** 介绍 */
|
||||||
|
|
||||||
|
@ApiModelProperty(name = "介绍", value = "介绍")
|
||||||
|
private String introduction;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品属性组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeGroupIdList;
|
||||||
|
/**
|
||||||
|
* 商品属性关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> attributeIdList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品品牌组关联ID
|
||||||
|
*/
|
||||||
|
private List<Long> brandIdList;
|
||||||
|
}
|
|
@ -9,10 +9,13 @@ import com.muyu.product.domain.AttributeGroup;
|
||||||
import com.muyu.product.domain.AttributeInfo;
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
import com.muyu.product.domain.BrandInfo;
|
import com.muyu.product.domain.BrandInfo;
|
||||||
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
import com.muyu.product.domain.model.CategoryInfoSaveModel;
|
||||||
|
import com.muyu.product.domain.req.CategoryInfoUpdEditReq;
|
||||||
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
import com.muyu.product.domain.resp.CategoryCommonElementResp;
|
||||||
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
|
||||||
import io.swagger.annotations.*;
|
import io.swagger.annotations.*;
|
||||||
|
import org.aspectj.weaver.Lint;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
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;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
|
@ -112,9 +115,18 @@ public class CategoryInfoController extends BaseController {
|
||||||
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
|
||||||
@PutMapping("/{id}")
|
@PutMapping("/{id}")
|
||||||
@ApiOperation("修改品类信息")
|
@ApiOperation("修改品类信息")
|
||||||
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) {
|
@Transactional
|
||||||
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
|
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoSaveReq categoryInfoSaveReq) {
|
||||||
}
|
// 删除品类属性中间表
|
||||||
|
categoryInfoService.asCategoryAttributeDel(id);
|
||||||
|
// 删除品类属性组中间表
|
||||||
|
categoryInfoService.asCategoryAttributeGroupDel(id);
|
||||||
|
// 删除品类品牌中间表
|
||||||
|
categoryInfoService.asCategoryBrandDel(id);
|
||||||
|
|
||||||
|
return toAjax(categoryInfoService.save(
|
||||||
|
CategoryInfoSaveModel.saveBuild(categoryInfoSaveReq, SecurityUtils::getUsername)
|
||||||
|
)); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除品类信息
|
* 删除品类信息
|
||||||
|
@ -124,8 +136,16 @@ public class CategoryInfoController extends BaseController {
|
||||||
@DeleteMapping("/{ids}")
|
@DeleteMapping("/{ids}")
|
||||||
@ApiOperation("删除品类信息")
|
@ApiOperation("删除品类信息")
|
||||||
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = String.class, example = "1,2,3,4")
|
||||||
public Result<String> remove(@PathVariable List<Long> ids) {
|
public Result<String> remove(@PathVariable Long ids) {
|
||||||
return toAjax(categoryInfoService.removeBatchByIds(ids));
|
System.out.println("参数:"+ids);
|
||||||
|
// 判断是否存在下一级
|
||||||
|
CategoryInfo categoryInfo = categoryInfoService.QueryBelowOneLevel(ids);
|
||||||
|
System.out.println("否存在下一级:"+categoryInfo);
|
||||||
|
// 判断没有下一删除
|
||||||
|
if (null == categoryInfo){
|
||||||
|
return toAjax(categoryInfoService.removeById(ids));
|
||||||
|
}
|
||||||
|
return Result.error("含有子集不能进行删除");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.muyu.product.mapper;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
import com.muyu.product.domain.CategoryInfo;
|
import com.muyu.product.domain.CategoryInfo;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 品类信息Mapper接口
|
* 品类信息Mapper接口
|
||||||
|
@ -12,4 +13,28 @@ import com.muyu.product.domain.CategoryInfo;
|
||||||
*/
|
*/
|
||||||
public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> {
|
public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类属性中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryAttributeDel(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品类属性组中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryAttributeGroupDel(@Param("id") Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 品类品牌中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryBrandDel(@Param("id") Long id);
|
||||||
|
/**
|
||||||
|
* 判断是否存在下一级
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CategoryInfo QueryBelowOneLevel(@Param("ids") Long ids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,4 +69,29 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
|
||||||
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
|
||||||
|
|
||||||
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService);
|
public <T, AS> List<T> getCommon (Long categoryId, IService<AS> iService, IService<T> bsiService);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类属性中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryAttributeDel(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类属性组中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryAttributeGroupDel(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类品牌中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
void asCategoryBrandDel(Long id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 判断是否存在下一级
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CategoryInfo QueryBelowOneLevel(Long ids);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.muyu.product.domain.AttributeGroup;
|
||||||
import com.muyu.product.domain.AttributeInfo;
|
import com.muyu.product.domain.AttributeInfo;
|
||||||
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
import com.muyu.product.domain.model.AttributeGroupSaveModel;
|
||||||
import com.muyu.product.domain.model.Ids;
|
import com.muyu.product.domain.model.Ids;
|
||||||
|
import com.muyu.product.domain.req.AttributeGroupEditReq;
|
||||||
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
import com.muyu.product.domain.req.AttributeGroupSaveReq;
|
||||||
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
import com.muyu.product.domain.req.AttributeInfoEditReq;
|
||||||
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
import com.muyu.product.domain.resp.AttributeGroupPageResp;
|
||||||
|
@ -140,6 +141,25 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Override
|
||||||
|
// public void updateee(Long id, AttributeGroupEditReq attributeGroupEditReq) {
|
||||||
|
// attributeGroupMapper.dell(id);
|
||||||
|
//
|
||||||
|
// List<AttributeInfo> attributeList = attributeGroupEditReq.getAttributeList();
|
||||||
|
// for (AttributeInfo attributeInfo : attributeList) {
|
||||||
|
//
|
||||||
|
// attributeGroupMapper.insertbatch(id,attributeInfo.getId());
|
||||||
|
// }
|
||||||
|
// attributeGroupMapper.insertbatch(id,attributeGroupEditReq.getAttributeList());
|
||||||
|
// attributeList.forEach(attributeInfo -> {
|
||||||
|
// attributeGroupMapper.insertbatch(attributeInfo.getId(),attributeGroupEditReq);
|
||||||
|
// });
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取属性组详细信息
|
* 获取属性组详细信息
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -39,6 +39,8 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsCategoryAttributeService asCategoryAttributeService;
|
private AsCategoryAttributeService asCategoryAttributeService;
|
||||||
|
@Autowired
|
||||||
|
private CategoryInfoMapper categoryInfoMapper;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
|
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
|
||||||
|
@ -270,6 +272,42 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类属性中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void asCategoryAttributeDel(Long id) {
|
||||||
|
categoryInfoMapper.asCategoryAttributeDel(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类属性组中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void asCategoryAttributeGroupDel(Long id) {
|
||||||
|
categoryInfoMapper.asCategoryAttributeGroupDel(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除品类品牌中间表
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void asCategoryBrandDel(Long id) {
|
||||||
|
categoryInfoMapper.asCategoryBrandDel(id);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 判断是否存在下一级
|
||||||
|
* @param ids
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public CategoryInfo QueryBelowOneLevel(Long ids) {
|
||||||
|
return categoryInfoMapper.QueryBelowOneLevel(ids);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
* 通过品类ID获取父级以上的属性、属性组、品牌集合
|
||||||
*
|
*
|
||||||
|
|
|
@ -130,6 +130,7 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
|
||||||
List<String> list = ruleAttrInfos.stream().map(RuleAttrInfo::getAttrValue).toList();
|
List<String> list = ruleAttrInfos.stream().map(RuleAttrInfo::getAttrValue).toList();
|
||||||
ruleAttrAddModel.setValueList(list);
|
ruleAttrAddModel.setValueList(list);
|
||||||
arrayList.add(ruleAttrAddModel);
|
arrayList.add(ruleAttrAddModel);
|
||||||
|
|
||||||
RuleInfoAddModel resp = new RuleInfoAddModel();
|
RuleInfoAddModel resp = new RuleInfoAddModel();
|
||||||
resp.setId(byId.getId());
|
resp.setId(byId.getId());
|
||||||
resp.setName(byId.getName());
|
resp.setName(byId.getName());
|
||||||
|
|
|
@ -21,4 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
<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, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
|
||||||
</sql>
|
</sql>
|
||||||
|
<!-- 删除品类属性中间表-->
|
||||||
|
<delete id="asCategoryAttributeDel">
|
||||||
|
delete from as_category_attribute where category_id = #{id}
|
||||||
|
</delete>
|
||||||
|
<!-- 品类属性组中间表-->
|
||||||
|
<delete id="asCategoryAttributeGroupDel">
|
||||||
|
delete from as_category_attribute_group where category_id = #{id}
|
||||||
|
</delete>
|
||||||
|
<!-- 品类品牌中间表-->
|
||||||
|
<delete id="asCategoryBrandDel">
|
||||||
|
delete from as_category_brand where category_id = #{id}
|
||||||
|
</delete>
|
||||||
|
<!-- 判断是否存在下一级-->
|
||||||
|
<select id="QueryBelowOneLevel" resultType="com.muyu.product.domain.CategoryInfo">
|
||||||
|
select * from category_info where parent_id =#{ids}
|
||||||
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
Loading…
Reference in New Issue