提交 931b84f6 作者: xiaowang

修复:列表查询

上级 61ba2ab8
...@@ -62,4 +62,6 @@ public interface CategoriesDao { ...@@ -62,4 +62,6 @@ public interface CategoriesDao {
List<Categories> selectCategoryByDirectoryId(List<Integer> directoryIds); List<Categories> selectCategoryByDirectoryId(List<Integer> directoryIds);
List<Categories> getCategoriesListByDirectoryIds(List<Integer> directoryIds); List<Categories> getCategoriesListByDirectoryIds(List<Integer> directoryIds);
int countChildById(Integer id);
} }
...@@ -108,4 +108,6 @@ public interface GoodsInfoDao { ...@@ -108,4 +108,6 @@ public interface GoodsInfoDao {
void removeWareInfo(List<Integer> ids); void removeWareInfo(List<Integer> ids);
List<SpecPriceVO> getPriceBySpecId(Integer productSpecId, Integer leaseTerm); List<SpecPriceVO> getPriceBySpecId(Integer productSpecId, Integer leaseTerm);
int countGoodsInfoByCategoryId(Integer id);
} }
...@@ -41,7 +41,7 @@ public interface WebDeviceDao { ...@@ -41,7 +41,7 @@ public interface WebDeviceDao {
List<GoodsInfo> listWareInfoPage( List<GoodsInfo> listWareInfoPage(
@Param("param") WareInfoQO param, @Param("param") WareInfoQO param,
@Param("userIds") List<Integer> userId, @Param("userIds") List<Integer> userIds,
@Param("type") Integer type); @Param("type") Integer type);
WareInfoDO getWareInfoById(Integer id); WareInfoDO getWareInfoById(Integer id);
......
...@@ -240,11 +240,11 @@ public class CategoriesServiceImpl implements CategoriesService { ...@@ -240,11 +240,11 @@ public class CategoriesServiceImpl implements CategoriesService {
@Override @Override
public List<AllCategoryDTO> feigQqueryCategoryInfoByType(Integer type) { public List<AllCategoryDTO> feigQqueryCategoryInfoByType(Integer type) {
List<DirectoryDO> categoryDirectoryList = getCategoryDirectoryList(type); List<DirectoryDO> categoryDirectoryList = getCategoryDirectoryList(type);
if (CollectionUtils.isNotEmpty(categoryDirectoryList)){ if (CollectionUtils.isNotEmpty(categoryDirectoryList)) {
List<AllCategoryDTO> allCategoryDTOList = List<AllCategoryDTO> allCategoryDTOList =
categoryDirectoryList.stream() categoryDirectoryList.stream()
.map(DirectoryDO::buildAllCategoryDTO) .map(DirectoryDO::buildAllCategoryDTO)
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<Integer, List<CategoriesInfoListDTO>> categoryMap = getCategoryMap(allCategoryDTOList); Map<Integer, List<CategoriesInfoListDTO>> categoryMap = getCategoryMap(allCategoryDTOList);
addSubCategories(allCategoryDTOList, categoryMap); addSubCategories(allCategoryDTOList, categoryMap);
System.out.println("Res: " + JSONObject.toJSON(allCategoryDTOList)); System.out.println("Res: " + JSONObject.toJSON(allCategoryDTOList));
...@@ -255,7 +255,19 @@ public class CategoriesServiceImpl implements CategoriesService { ...@@ -255,7 +255,19 @@ public class CategoriesServiceImpl implements CategoriesService {
@Override @Override
public ResultBody deleteRelevantBusiness(Integer id) { public ResultBody deleteRelevantBusiness(Integer id) {
int count = categoriesDao.deleteById(id); int count = goodsInfoDao.countGoodsInfoByCategoryId(id);
if (count > 0) {
return ResultBody.error(ResultEnum.GROUP_DONT_DELETE);
}
// 获取分类信息
Categories categories = categoriesDao.getGoodsGroupById(id);
if (categories != null && categories.getParentId().equals(0)) {
int childCount = categoriesDao.countChildById(id);
if (childCount > 0) {
return ResultBody.error(ResultEnum.GROUP_DONT_DELETE_BY_CHILD);
}
}
categoriesDao.deleteById(id);
return ResultBody.success(); return ResultBody.success();
} }
......
...@@ -23,6 +23,7 @@ import com.mmc.pms.model.sale.vo.SpecPriceVO; ...@@ -23,6 +23,7 @@ import com.mmc.pms.model.sale.vo.SpecPriceVO;
import com.mmc.pms.page.PageResult; import com.mmc.pms.page.PageResult;
import com.mmc.pms.service.WebDeviceService; import com.mmc.pms.service.WebDeviceService;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -171,7 +172,9 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -171,7 +172,9 @@ public class WebDeviceServiceImpl implements WebDeviceService {
param.getProvinceId(), param.getProvinceId(),
null, null,
null, null,
request == null ? null : request.getHeader(TokenConstant.TOKEN)); StringUtils.isBlank(request.getHeader(TokenConstant.TOKEN))
? null
: request.getHeader(TokenConstant.TOKEN));
if (userIds == null || userIds.size() == 0) { if (userIds == null || userIds.size() == 0) {
userIds = Collections.singletonList(-1); userIds = Collections.singletonList(-1);
} }
...@@ -183,7 +186,7 @@ public class WebDeviceServiceImpl implements WebDeviceService { ...@@ -183,7 +186,7 @@ public class WebDeviceServiceImpl implements WebDeviceService {
} }
int pageNo = param.getPageNo(); int pageNo = param.getPageNo();
param.buildCurrentPage(); param.buildCurrentPage();
if (request == null) { if (StringUtils.isBlank(request.getHeader(TokenConstant.TOKEN))) {
List<GoodsInfo> list = webDeviceDao.listWareInfoPage(param, userIds, param.getType()); List<GoodsInfo> list = webDeviceDao.listWareInfoPage(param, userIds, param.getType());
List<LeaseGoodsInfoDTO> pageList = List<LeaseGoodsInfoDTO> pageList =
list.stream().map(GoodsInfo::buildLeaseGoodsInfoDTO).collect(Collectors.toList()); list.stream().map(GoodsInfo::buildLeaseGoodsInfoDTO).collect(Collectors.toList());
......
...@@ -215,6 +215,13 @@ ...@@ -215,6 +215,13 @@
</foreach> </foreach>
</where> </where>
</select> </select>
<select id="countChildById" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM categories c1
INNER JOIN categories c2 ON c1.id = c2.parent_id
AND c2.is_deleted = 0
WHERE c1.id = #{id}
</select>
<update id="deleteById"> <update id="deleteById">
UPDATE `categories` UPDATE `categories`
......
...@@ -579,4 +579,11 @@ ...@@ -579,4 +579,11 @@
AND lease_term = #{leaseTerm} AND lease_term = #{leaseTerm}
and type = 1 and type = 1
</select> </select>
<select id="countGoodsInfoByCategoryId" resultType="java.lang.Integer">
SELECT COUNT(*)
FROM categories c
LEFT JOIN goods_info gi ON gi.category_by_one = c.id OR gi.category_by_two = c.id
WHERE c.is_deleted = 0
AND c.id = #{id}
</select>
</mapper> </mapper>
...@@ -181,7 +181,8 @@ ...@@ -181,7 +181,8 @@
<where> <where>
gi.is_deleted = 0 and gi.shelf_status = 1 and gi.goods_type = #{type} gi.is_deleted = 0 and gi.shelf_status = 1 and gi.goods_type = #{type}
<if test="param.categoryId != null"> <if test="param.categoryId != null">
<foreach collection="param" item="item" index="index" open="and gi.category_by_one IN (" close=")" <foreach collection="param.categoryId" item="item" index="index" open="and gi.category_by_one IN ("
close=")"
separator=","> separator=",">
#{item} #{item}
</foreach> </foreach>
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论