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

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

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

parent 60b7ad19
...@@ -19,9 +19,11 @@ import org.apache.commons.lang3.StringUtils; ...@@ -19,9 +19,11 @@ import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions; import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Api(tags = "标签库") @Api(tags = "标签库")
@Controller @Controller
...@@ -63,7 +65,21 @@ public class GoblinSelfTagAdminController extends BaseController { ...@@ -63,7 +65,21 @@ public class GoblinSelfTagAdminController extends BaseController {
GoblinSelfTag::getTagType, GoblinSelfTag::getTagType,
GoblinSelfTag::getCounts 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") // @RequiresPermissions("goblin:tag:export")
......
package com.liquidnet.client.admin.zhengzai.goblin.service; package com.liquidnet.client.admin.zhengzai.goblin.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.liquidnet.service.goblin.entity.GoblinSelfGoodsCategory;
import com.liquidnet.service.goblin.entity.GoblinSelfTag; import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import java.util.List;
/** /**
* <p> * <p>
* 平台商品标签 服务类 * 平台商品标签 服务类
...@@ -19,4 +20,6 @@ public interface IGoblinSelfTagService extends IService<GoblinSelfTag> { ...@@ -19,4 +20,6 @@ public interface IGoblinSelfTagService extends IService<GoblinSelfTag> {
boolean editSave(GoblinSelfTag selfTag); boolean editSave(GoblinSelfTag selfTag);
boolean remove(String[] tagIdArr, String tagBelong); boolean remove(String[] tagIdArr, String tagBelong);
List<GoblinSelfTag> countsForList(List<String> tagIds);
} }
...@@ -18,6 +18,8 @@ import org.springframework.data.mongodb.core.query.Update; ...@@ -18,6 +18,8 @@ import org.springframework.data.mongodb.core.query.Update;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.util.List;
/** /**
* <p> * <p>
* 平台商品标签 服务实现类 * 平台商品标签 服务实现类
...@@ -31,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional; ...@@ -31,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional;
public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapper, GoblinSelfTag> implements IGoblinSelfTagService { public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapper, GoblinSelfTag> implements IGoblinSelfTagService {
@Autowired @Autowired
private MongoTemplate mongoTemplate; private MongoTemplate mongoTemplate;
@Autowired
private GoblinSelfTagMapper goblinSelfTagMapper;
@Transactional @Transactional
@Override @Override
...@@ -86,4 +90,9 @@ public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapp ...@@ -86,4 +90,9 @@ public class GoblinSelfGoodsTagServiceImpl extends ServiceImpl<GoblinSelfTagMapp
} }
return rmvResultFlg; return rmvResultFlg;
} }
@Override
public List<GoblinSelfTag> countsForList(List<String> tagIds) {
return goblinSelfTagMapper.countsForList(tagIds);
}
} }
...@@ -2,6 +2,9 @@ package com.liquidnet.service.goblin.mapper; ...@@ -2,6 +2,9 @@ package com.liquidnet.service.goblin.mapper;
import com.liquidnet.service.goblin.entity.GoblinSelfTag; import com.liquidnet.service.goblin.entity.GoblinSelfTag;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* <p> * <p>
...@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; ...@@ -13,4 +16,5 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
*/ */
public interface GoblinSelfTagMapper extends BaseMapper<GoblinSelfTag> { public interface GoblinSelfTagMapper extends BaseMapper<GoblinSelfTag> {
List<GoblinSelfTag> countsForList(@Param("tagIds") List<String> tagIds);
} }
...@@ -2,4 +2,13 @@ ...@@ -2,4 +2,13 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!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"> <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> </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