规格信息有商品不能删除
parent
cc37d9af04
commit
bbf1bd502f
|
@ -36,6 +36,7 @@ public class RuleInfoResp extends BaseEntity {
|
|||
* 规格属性集合
|
||||
*/
|
||||
private List<RuleAttrAddModel> ruleAttrList;
|
||||
private Boolean dis;
|
||||
|
||||
public static RuleInfoResp infoBuild (RuleInfo ruleInfo, Function<Long, List<RuleAttrAddModel>> ruleAttrList) {
|
||||
return RuleInfoResp.builder()
|
||||
|
|
|
@ -130,4 +130,14 @@ public class RuleInfoController extends BaseController {
|
|||
public Result<String> remove(@PathVariable List<Long> ids) {
|
||||
return toAjax(ruleInfoService.removeBatchByIds(ids));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验是否存在商品信息
|
||||
*/
|
||||
@GetMapping("have")
|
||||
@ApiOperation("校验是否存在商品信息")
|
||||
public Result have(Long id) {
|
||||
return Result.success(ruleInfoService.have(id));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,6 @@ public interface RuleInfoMapper extends BaseMapper<RuleInfo> {
|
|||
|
||||
void deleteRule(Long id);
|
||||
void addRuleAttrModel(@Param("id") Long id, @Param("name") String name, @Param("valueData") String substring);
|
||||
|
||||
Integer have(Long id);
|
||||
}
|
||||
|
|
|
@ -42,4 +42,6 @@ public interface RuleInfoService extends IService<RuleInfo> {
|
|||
|
||||
|
||||
void edit(Long id, RuleAttrInfoReq ruleInfoEditReq);
|
||||
|
||||
Result have(Long id);
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.muyu.product.service.impl;
|
|||
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
import com.github.pagehelper.PageInfo;
|
||||
|
@ -11,6 +12,7 @@ import com.muyu.common.core.utils.ObjUtils;
|
|||
import com.muyu.common.core.web.page.TableDataInfo;
|
||||
import com.muyu.common.security.utils.SecurityUtils;
|
||||
import com.muyu.product.domain.AttributeInfo;
|
||||
import com.muyu.product.domain.ProjectInfo;
|
||||
import com.muyu.product.domain.RuleAttrInfo;
|
||||
import com.muyu.product.domain.model.RuleAttrAddModel;
|
||||
import com.muyu.product.domain.model.RuleInfoAddModel;
|
||||
|
@ -20,6 +22,7 @@ import com.muyu.product.domain.req.RuleInfoQueryReq;
|
|||
import com.muyu.product.domain.req.RuleInfoSaveReq;
|
||||
import com.muyu.product.domain.resp.RuleGroupUpdResp;
|
||||
import com.muyu.product.domain.resp.RuleInfoResp;
|
||||
import com.muyu.product.service.ProjectInfoService;
|
||||
import com.muyu.product.service.RuleAttrInfoService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -45,6 +48,8 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> i
|
|||
private RuleAttrInfoService ruleAttrInfoService;
|
||||
@Autowired
|
||||
private RuleInfoMapper ruleAttrInfoMapper;
|
||||
@Autowired
|
||||
private ProjectInfoService projectInfoService;
|
||||
|
||||
/**
|
||||
* 查询商品规格列表
|
||||
|
@ -103,7 +108,14 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> i
|
|||
}))
|
||||
.toList();
|
||||
boolean isPage = ruleInfoQueryReq.getParams().get("isPage") == null || Convert.toBool(ruleInfoQueryReq.getParams().get("isPage"), true);
|
||||
|
||||
List<ProjectInfo> projectInfoList = projectInfoService.list();
|
||||
for (ProjectInfo projectInfo : projectInfoList) {
|
||||
for (RuleInfoResp ruleInfoResp : ruleInfoRespList) {
|
||||
if (Objects.equals(projectInfo.getId(), ruleInfoResp.getId())){
|
||||
ruleInfoResp.setDis(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
return TableDataInfo.<RuleInfoResp>builder()
|
||||
.rows(ruleInfoRespList)
|
||||
.total(isPage ? new PageInfo<>(list).getTotal() : 0)
|
||||
|
@ -173,4 +185,13 @@ public class RuleInfoServiceImpl extends ServiceImpl<RuleInfoMapper, RuleInfo> i
|
|||
// }
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result have(Long id) {
|
||||
Integer count = ruleAttrInfoMapper.have(id);
|
||||
if (count>0){
|
||||
return Result.error(400,"规格下有商品,无法删除");
|
||||
}
|
||||
return Result.success(count);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -53,4 +53,7 @@ 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="have" resultType="java.lang.Integer">
|
||||
SELECT count(1) FROM project_info WHERE id=#{id}
|
||||
</select>
|
||||
</mapper>
|
||||
|
|
Loading…
Reference in New Issue