第三次优化

master
‘mahaoran’ 2024-11-16 09:33:47 +08:00
parent 662723be28
commit 414ab09bd8
15 changed files with 159 additions and 14 deletions

View File

@ -17,6 +17,7 @@ import com.muyu.product.domain.req.CategoryInfoEditReq;
import com.muyu.common.core.web.domain.TreeEntity;
import java.util.Date;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;
@ -62,6 +63,8 @@ public class CategoryInfo extends TreeEntity {
@ApiModelProperty(name = "介绍", value = "介绍")
private String introduction;
/**
*
*/

View File

@ -128,6 +128,17 @@ public class AttributeGroupController extends BaseController {
return toAjax(attributeGroupService.updateById(AttributeGroup.editBuild(id,attributeGroupEditReq)));
}
/**
*
*/
@Log(title = "属性组", businessType = BusinessType.UPDATE)
@PutMapping("updStatus")
@ApiOperation("修改状态")
public Result updStatus(String states,Long id) {
return attributeGroupService.updateStatus(states, id);
}
/**
*
*/

View File

@ -78,6 +78,7 @@ public class CategoryInfoController extends BaseController {
@GetMapping(value = "/{id}")
@ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class)
public Result<CategoryInfo> getInfo(@PathVariable("id") Long id) {
return Result.success(categoryInfoService.getById(id));
}

View File

@ -106,6 +106,27 @@ public class RuleInfoController extends BaseController {
return toAjax(ruleInfoService.updateById(RuleInfo.editBuild(id,ruleInfoEditReq)));
}
/**
*
*/
@GetMapping("have")
@ApiOperation("校验是否存在商品信息")
public Result have(Long id) {
Result have = ruleInfoService.have(id);
return have;
}
/**
*
*/
@Log(title = "属性组", businessType = BusinessType.UPDATE)
@PutMapping("updStatus")
@ApiOperation("修改状态")
public Result updStatus(String status,Long id) {
return ruleInfoService.updateStatus(status, id);
}
/**
*
*/

View File

@ -41,4 +41,5 @@ public interface AsAttributeGroupMapper extends BaseMapper<AsAttributeGroup> {
*/
void add(@Param("groupId") Long groupId , @Param("list") List<AttributeInfo> list);
void updStatus(@Param("states") String states, @Param("id") Long id);
}

View File

@ -21,11 +21,20 @@ public interface CategoryInfoMapper extends BaseMapper<CategoryInfo> {
void delArandIdList(Long id);
void addAttributeGroupId(@Param("id") Long id, @Param("attributeGroupId") Long attributeGroupId);
// void addAttributeGroupId(@Param("id") Long id, @Param("attributeGroupId") Long attributeGroupId);
void attributeGroupIdList(@Param("id") Long id, @Param("aLong") Long aLong);
void addAttributeIdList(@Param("id") Long id, @Param("attributeId") Long attributeId);
void addArandIdList(@Param("id") Long id, @Param("brandId") Long brandId);
Integer selectByPid(String ids);
Integer selectAsCategoryBrand(String ids);
Integer selectAsCategoryAttribute(String ids);
Integer selectAsCategoryAttributeGroup(String ids);
}

View File

@ -3,8 +3,7 @@ package com.muyu.product.mapper;
import java.util.List;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.muyu.product.domain.RuleAttrInfo;
import com.muyu.product.domain.RuleInfo;
import com.muyu.product.domain.req.RuleInfoEditReq;
import com.muyu.product.domain.resp.RuleInfoResp;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -24,4 +23,9 @@ public interface RuleAttrInfoMapper extends BaseMapper<RuleAttrInfo> {
void add(@Param("id") Long id, @Param("name") String name, @Param("attrValue") String attrValue);
void updateStatus(@Param("status") String status, @Param("id") Long id);
Integer selectByAttributeGroupCount(Long id);
}

View File

@ -67,4 +67,8 @@ public interface AttributeGroupService extends IService<AttributeGroup> {
AttributeGroupUpdResp getUpdById(Long id);
Result updateAttibuteGroup(Long id, AttributeGroupEditReq attributeGroupEditReq);
Result updateStatus(String status,Long id);
}

View File

@ -44,4 +44,8 @@ public interface RuleInfoService extends IService<RuleInfo> {
Result upd(Long id, RuleInfoEditReq ruleInfoEditReq);
Result updateStatus(String status, Long id);
Result have(Long id);
}

View File

@ -169,4 +169,15 @@ public class AttributeGroupServiceImpl extends ServiceImpl<AttributeGroupMapper,
asAttributeGroupMapper.add(id,attributeGroupEditReq.getAttributeList());
return Result.success(0,"修改成功");
}
/**
*
* @param states
* @return
*/
@Override
public Result updateStatus(String states,Long id) {
asAttributeGroupMapper.updStatus(states,id);
return Result.success(0,"修改成功");
}
}

View File

@ -278,22 +278,27 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
@Transactional
@Override
public Result updateCategory(Long id, CategoryInfoEditReq categoryInfoEditReq) {
categoryInfoMapper.delAttributeGroupId(id);
List<Long> attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList();
for (Long aLong : attributeGroupIdList) {
categoryInfoMapper.addAttributeGroupId(id,aLong);
}
categoryInfoMapper.delAttributeIdList(id);
List<Long> attributeIdList = categoryInfoEditReq.getAttributeIdList();
for (Long aLong : attributeIdList) {
categoryInfoMapper.addAttributeIdList(id,aLong);
}
categoryInfoMapper.delArandIdList(id);
List<Long> brandIdList = categoryInfoEditReq.getBrandIdList();
for (Long aLong : brandIdList) {
categoryInfoMapper.addArandIdList(id,aLong);
}
categoryInfoMapper.delAttributeGroupId(id);
List<Long> attributeGroupIdList = categoryInfoEditReq.getAttributeGroupIdList();
for (Long aLong : attributeGroupIdList) {
categoryInfoMapper.attributeGroupIdList(id,aLong);
}
return Result.success(0,"修改成功");
}
@ -303,6 +308,21 @@ public class CategoryInfoServiceImpl extends ServiceImpl<CategoryInfoMapper, Cat
if(count>0){
return Result.error(400,"该数据存在子集,禁止删除");
}
Integer countAsCategoryBrand = categoryInfoMapper.selectAsCategoryBrand(ids);
if(countAsCategoryBrand>0){
return Result.error(400,"该数据存在关联关系,禁止删除");
}
Integer countAsCategoryAttribute = categoryInfoMapper.selectAsCategoryAttribute(ids);
if(countAsCategoryAttribute>0){
return Result.error(400,"该数据存在关联关系,禁止删除");
}
Integer countAsCategoryAttributeGroup = categoryInfoMapper.selectAsCategoryAttributeGroup(ids);
if(countAsCategoryAttributeGroup>0){
return Result.error(400,"该数据存在关联关系,禁止删除");
}
categoryInfoMapper.deleteById(ids);
return Result.success(200,"删除成功");
}

View File

@ -7,6 +7,7 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.muyu.common.core.domain.Result;
@ -48,6 +49,9 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
@Autowired
private RuleAttrInfoMapper ruleAttrInfoMapper;
@Autowired
private RuleInfoMapper ruleInfoMapper;
/**
*
*
@ -100,6 +104,8 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
*/
@Override
public TableDataInfo<RuleInfoResp> queryList (RuleInfoQueryReq ruleInfoQueryReq) {
List<RuleInfo> list = this.list(RuleInfo.queryBuild(ruleInfoQueryReq));
List<RuleInfoResp> ruleInfoRespList = list.stream()
.map(ruleInfo -> RuleInfoResp.infoBuild(ruleInfo, ruleId -> {
@ -131,6 +137,9 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
@Transactional
@Override
public Result upd(Long id, RuleInfoEditReq ruleInfoEditReq) {
ruleAttrInfoMapper.del(id);
List<RuleAttrAddModel> ruleAttrList = ruleInfoEditReq.getRuleAttrList();
for (RuleAttrAddModel ruleAttrAddModel : ruleAttrList) {
@ -144,4 +153,24 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo>
return Result.success(0,"修改成功");
}
@Override
public Result updateStatus(String status, Long id) {
LambdaUpdateWrapper<RuleInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(RuleInfo::getId,id);
updateWrapper.set(RuleInfo::getStatus,status);
ruleInfoMapper.update(null,updateWrapper);
// ruleAttrInfoMapper.updateStatus(status,id);
return Result.success(0,"修改成功");
}
@Override
public Result have(Long id) {
Integer count = ruleAttrInfoMapper.selectByAttributeGroupCount(id);
if(count>0){
return Result.error(400,"有商品关联禁止操作");
}
return Result.success(count);
}
}

View File

@ -25,6 +25,9 @@
</foreach>
</insert>
<update id="updStatus">
update attribute_group set states = #{states} where id = #{id}
</update>
<delete id="del">
delete from as_attribute_group where group_id =#{groupId}
</delete>

View File

@ -21,28 +21,46 @@ 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>
<insert id="addAttributeGroupId">
INSERT INTO `as_category_attribute_group` (`category_id`, `attribute_group_id`) values
(#{id},#{attributeGroupId})
</insert>
<insert id="addAttributeIdList">
INSERT INTO `as_category_attribute` (`category_id`, `attribute_id`) values
(#{id},#{attributeId})
INSERT INTO `as_category_attribute` ( `category_id`, `attribute_id`)
VALUES (#{id},#{attributeId});
</insert>
<insert id="addArandIdList">
INSERT INTO `as_category_brand` (`category_id`, `brand_id`) values
(#{id},#{brandId})
</insert>
<insert id="attributeGroupIdList">
INSERT INTO `as_category_attribute_group` ( `category_id`, `attribute_group_id`)
VALUES (#{id},#{aLong});
</insert>
<delete id="delAttributeGroupId">
delete from as_category_attribute where category_id = #{id}
</delete>
<delete id="delAttributeIdList">
delete from as_category_brand where category_id = #{id}
</delete>
<delete id="delArandIdList">
delete from as_category_attribute_group where category_id = #{id}
</delete>
<select id="selectByPid" resultType="java.lang.Integer">
select count(1) from category_info where parent_id = #{ids}
</select>
<select id="selectAsCategoryBrand" resultType="java.lang.Integer">
select count(1) from as_category_brand where category_id = #{ids}
</select>
<select id="selectAsCategoryAttribute" resultType="java.lang.Integer">
select count(1) from as_category_attribute where category_id = #{ids}
</select>
<select id="selectAsCategoryAttributeGroup" resultType="java.lang.Integer">
select count(1) from as_category_attribute_group where category_id = #{ids}
</select>
</mapper>

View File

@ -24,6 +24,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="attrValue" column="attr_value"/>
</collection>
</resultMap>
<update id="updateStatus">
update rule_info set status = #{status} where id = #{id}
</update>
<select id="getRuleById" resultMap="RuleAttrInfo">
SELECT
@ -36,6 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
INNER JOIN rule_attr_info ON rule_info.id = rule_attr_info.rule_id
WHERE rule_info.`id`=#{id}
</select>
<select id="selectByAttributeGroupCount" resultType="java.lang.Integer">
select count(1) from project_info where rule_id =#{id}
</select>
<sql id="selectRuleAttrInfoVo">
select id, rule_id, name, attr_value, remark, create_by, create_time, update_by, update_time from rule_attr_info