记得上下班打卡 | git大法好,push需谨慎

Commit 90f263c2 authored by 张国柄's avatar 张国柄

~ADMIN:标签库:列表属性'关联商品数量'处理;

parent 60b7ad19
......@@ -19,9 +19,11 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.stream.Collectors;
@Api(tags = "标签库")
@Controller
......@@ -63,7 +65,21 @@ public class GoblinSelfTagAdminController extends BaseController {
GoblinSelfTag::getTagType,
GoblinSelfTag::getCounts
);
return goblinSelfTagService.list(lambdaQueryWrapper);
List<GoblinSelfTag> list = goblinSelfTagService.list(lambdaQueryWrapper);
if (!CollectionUtils.isEmpty(list)) {
List<GoblinSelfTag> cts = goblinSelfTagService.countsForList(list.stream().map(GoblinSelfTag::getTagId).collect(Collectors.toList()));
if (!CollectionUtils.isEmpty(cts)) {
cts.forEach(ct -> list.forEach(t -> {
if (t.getTagId().equals(ct.getTagId())) {
t.setCounts(ct.getCounts());
}
}));
}
}
return list;
}
// @RequiresPermissions("goblin:tag:export")
......
package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import java.util.List;
/**
* <p>
* 平台商品标签 服务类
......@@ -19,4 +20,6 @@ public interface IGoblinSelfTagService extends IService<GoblinSelfTag> {
boolean editSave(GoblinSelfTag selfTag);
boolean remove(String[] tagIdArr, String tagBelong);
List<GoblinSelfTag> countsForList(List<String> tagIds);
}
......@@ -18,6 +18,8 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/**
* <p>
* 平台商品标签 服务实现类
......@@ -31,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional;
public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapper, GoblinSelfTag> implements IGoblinSelfTagService {
@Autowired
private MongoTemplate mongoTemplate;
@Autowired
private GoblinSelfTagMapper goblinSelfTagMapper;
@Transactional
@Override
......@@ -86,4 +90,9 @@ public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapp
}
return rmvResultFlg;
}
@Override
public List<GoblinSelfTag> countsForList(List<String> tagIds) {
return goblinSelfTagMapper.countsForList(tagIds);
}
}
......@@ -2,6 +2,9 @@ package com.liquidnet.service.goblin.mapper;
import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* <p>
......@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/
public interface GoblinSelfTagMapper extends BaseMapper<GoblinSelfTag> {
List<GoblinSelfTag> countsForList(@Param("tagIds") List<String> tagIds);
}
......@@ -2,4 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.liquidnet.service.goblin.mapper.GoblinSelfTagMapper">
<select id="countsForList" resultType="com.liquidnet.service.goblin.entity.GoblinSelfTag">
SELECT tag_id tagId, count(1) counts FROM goblin_goods_tag
WHERE tag_id IN
<foreach item="tagId" collection="tagIds" open="(" separator="," close=")">
#{tagId}
</foreach>
AND del_flg='0' AND tag_belong='0'
GROUP BY tag_id
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment