| @@ -96,27 +96,27 @@ public class WxTagsController extends BaseController | |||||
| @ApiOperation("查询用户人群") | @ApiOperation("查询用户人群") | ||||
| @GetMapping("findUserByTag") | @GetMapping("findUserByTag") | ||||
| public Result findUserByTag(Long[] tagIds) { | public Result findUserByTag(Long[] tagIds) { | ||||
| WxTags wxTags = new WxTags(); | |||||
| List<Long> ids = new ArrayList<>(); | |||||
| for(Long id :tagIds) { | |||||
| ids.add(id); | |||||
| } | |||||
| wxTags.setIds(ids); | |||||
| PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 5000); | |||||
| List<WxTags> list = page.getList(); | |||||
| StringBuffer names= new StringBuffer(); | |||||
| for(WxTags t:list) { | |||||
| names.append(t.getName()+"/"); | |||||
| } | |||||
| Map<String,Object> map = new HashMap<>(); | |||||
| String endName=""; | |||||
| if(names.length()>0) { | |||||
| endName = names.toString().substring(0,names.length()-1); | |||||
| } | |||||
| map.put("names",endName ); | |||||
| map.put("ids", ids); | |||||
| map.put("userCout", wxCUserTagsService.findCountByTag(Arrays.asList(tagIds))); | |||||
| return new ResultData(Result.SUCCESS,"查询成功",map); | |||||
| // WxTags wxTags = new WxTags(); | |||||
| // List<Long> ids = new ArrayList<>(); | |||||
| // for(Long id :tagIds) { | |||||
| // ids.add(id); | |||||
| // } | |||||
| // wxTags.setIds(ids); | |||||
| // PageInfo<WxTags> page = wxTagsService.listAsPage(wxTags, 1, 5000); | |||||
| // List<WxTags> list = page.getList(); | |||||
| // StringBuffer names= new StringBuffer(); | |||||
| // for(WxTags t:list) { | |||||
| // names.append(t.getName()+"/"); | |||||
| // } | |||||
| // Map<String,Object> map = new HashMap<>(); | |||||
| // String endName=""; | |||||
| // if(names.length()>0) { | |||||
| // endName = names.toString().substring(0,names.length()-1); | |||||
| // } | |||||
| // map.put("names",endName ); | |||||
| // map.put("tagIds", ids); | |||||
| long count = wxCUserTagsService.findCountByTag(Arrays.asList(tagIds)); | |||||
| return new ResultData(Result.SUCCESS,"查询成功",count); | |||||
| } | } | ||||
| // @ApiOperation("分页列表接口") | // @ApiOperation("分页列表接口") | ||||
| @@ -11,7 +11,6 @@ public interface WxCUserTagsMapper extends CommonMapper<WxCUserTags, String> { | |||||
| long findCountByTag(List<Long> tagIds); | long findCountByTag(List<Long> tagIds); | ||||
| List<Long> findUserByTag(List<Long> tagIds); | |||||
| } | } | ||||
| @@ -1,7 +1,9 @@ | |||||
| package com.simple.service; | package com.simple.service; | ||||
| import java.util.*; | |||||
| import java.util.List; | |||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCUser; | |||||
| import com.simple.domain.po.WxCUserTags; | import com.simple.domain.po.WxCUserTags; | ||||
| public interface WxCUserTagsService { | public interface WxCUserTagsService { | ||||
| @@ -38,10 +40,20 @@ public interface WxCUserTagsService { | |||||
| */ | */ | ||||
| void deleteById(Long id); | void deleteById(Long id); | ||||
| /** | |||||
| * tagIds查询 用户数量 | |||||
| * @param tagIds | |||||
| * @return | |||||
| */ | |||||
| long findCountByTag(List<Long> tagIds); | long findCountByTag(List<Long> tagIds); | ||||
| /** | |||||
| * | |||||
| * tagIds查询用户user信息集合 | |||||
| * @param tagIds | |||||
| * @return | |||||
| */ | |||||
| List<WxCUser> findUserByTag(List<Long> tagIds); | |||||
| @@ -3,7 +3,9 @@ package com.simple.service.impl; | |||||
| import java.util.*; | import java.util.*; | ||||
| import com.github.pagehelper.PageHelper; | import com.github.pagehelper.PageHelper; | ||||
| import com.github.pagehelper.PageInfo; | import com.github.pagehelper.PageInfo; | ||||
| import com.simple.domain.po.WxCUser; | |||||
| import com.simple.domain.po.WxCUserTags; | import com.simple.domain.po.WxCUserTags; | ||||
| import com.simple.mapper.WxCUserMapper; | |||||
| import com.simple.mapper.WxCUserTagsMapper; | import com.simple.mapper.WxCUserTagsMapper; | ||||
| import com.simple.service.WxCUserTagsService; | import com.simple.service.WxCUserTagsService; | ||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||
| @@ -15,6 +17,9 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| @Autowired | @Autowired | ||||
| WxCUserTagsMapper wxCUserTagsMapper; | WxCUserTagsMapper wxCUserTagsMapper; | ||||
| @Autowired | |||||
| WxCUserMapper wxCUserMapper; | |||||
| @Override | @Override | ||||
| @@ -48,6 +53,14 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| public long findCountByTag(List<Long> tagIds) { | public long findCountByTag(List<Long> tagIds) { | ||||
| return wxCUserTagsMapper.findCountByTag(tagIds); | return wxCUserTagsMapper.findCountByTag(tagIds); | ||||
| } | } | ||||
| @Override | |||||
| public List<WxCUser> findUserByTag(List<Long> tagIds) { | |||||
| List<Long> userIds = wxCUserTagsMapper.findUserByTag(tagIds); | |||||
| WxCUser wxCUser = new WxCUser(); | |||||
| wxCUser.setIds(userIds); | |||||
| return wxCUserMapper.findList(wxCUser); | |||||
| } | |||||
| @@ -64,5 +64,8 @@ | |||||
| select count(user_id) from wx_c_user_tags where JSON_CONTAINS(tags,JSON_ARRAY(#{list}) ); | select count(user_id) from wx_c_user_tags where JSON_CONTAINS(tags,JSON_ARRAY(#{list}) ); | ||||
| </select> | </select> | ||||
| <select id ="findUserByTag" resultType="java.lang.Long"> | |||||
| select user_id from wx_c_user_tags where JSON_CONTAINS(tags,JSON_ARRAY(#{list}) ); | |||||
| </select> | |||||
| </mapper> | </mapper> | ||||