类品信息TODO

main
尚志豪123 2024-11-15 12:00:34 +08:00
parent fba615cec8
commit 10b70d44e6
8 changed files with 217 additions and 5 deletions

View File

@ -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
* @Packagecom.muyu.product.domain.req
* @Projectcloud-server
* @nameCategoryInfoUpdEditReq
* @Date2024/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;
}

View File

@ -9,10 +9,13 @@ import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.BrandInfo;
import com.muyu.product.domain.model.CategoryInfoSaveModel;
import com.muyu.product.domain.req.CategoryInfoUpdEditReq;
import com.muyu.product.domain.resp.CategoryCommonElementResp;
import com.muyu.product.domain.resp.CategoryParentCommonElementResp;
import io.swagger.annotations.*;
import org.aspectj.weaver.Lint;
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.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
@ -112,9 +115,18 @@ public class CategoryInfoController extends BaseController {
@Log(title = "品类信息", businessType = BusinessType.UPDATE)
@PutMapping("/{id}")
@ApiOperation("修改品类信息")
public Result<String> edit(@PathVariable Long id, @RequestBody CategoryInfoEditReq categoryInfoEditReq) {
return toAjax(categoryInfoService.updateById(CategoryInfo.editBuild(id,categoryInfoEditReq)));
}
@Transactional
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}")
@ApiOperation("删除品类信息")
@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) {
return toAjax(categoryInfoService.removeBatchByIds(ids));
public Result<String> remove(@PathVariable Long 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("含有子集不能进行删除");
}
/**

View File

@ -3,6 +3,7 @@ package com.muyu.product.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.CategoryInfo;
import org.apache.ibatis.annotations.Param;
/**
* Mapper
@ -12,4 +13,28 @@ import com.muyu.product.domain.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);
}

View File

@ -69,4 +69,29 @@ public interface CategoryInfoService extends IService<CategoryInfo> {
CategoryCommonElementResp getTemplateAttributeByCateGoryId (Long cateGoryId);
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);
}

View File

@ -11,6 +11,7 @@ import com.muyu.product.domain.AttributeGroup;
import com.muyu.product.domain.AttributeInfo;
import com.muyu.product.domain.model.AttributeGroupSaveModel;
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.AttributeInfoEditReq;
import com.muyu.product.domain.resp.AttributeGroupPageResp;
@ -140,6 +141,25 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
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);
// });
//
//
// }
/**
*
*/

View File

@ -39,6 +39,8 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
@Autowired
private AsCategoryAttributeService asCategoryAttributeService;
@Autowired
private CategoryInfoMapper categoryInfoMapper;
@Autowired
private AsCategoryAttributeGroupService asCategoryAttributeGroupService;
@ -270,6 +272,42 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
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
*

View File

@ -130,6 +130,7 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
List<String> list = ruleAttrInfos.stream().map(RuleAttrInfo::getAttrValue).toList();
ruleAttrAddModel.setValueList(list);
arrayList.add(ruleAttrAddModel);
RuleInfoAddModel resp = new RuleInfoAddModel();
resp.setId(byId.getId());
resp.setName(byId.getName());

View File

@ -21,4 +21,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<sql id="selectCategoryInfoVo">
select id, name, image, parent_id, start, introduction, remark, create_by, create_time, update_by, update_time from category_info
</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>