| @@ -762,15 +762,44 @@ public class WxCUserTagsServiceImpl implements WxCUserTagsService { | |||||
| WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId); | WxCUserBasicInfo wxCUserBasicInfo = wxCUserBasicInfoMapper.selectById(cUserId); | ||||
| WxCUserTags userTags = getById(wxCUserBasicInfo.getTagId()); | WxCUserTags userTags = getById(wxCUserBasicInfo.getTagId()); | ||||
| List<Long> tagList = JSONArray.parseArray(userTags.getTags(), Long.class); | List<Long> tagList = JSONArray.parseArray(userTags.getTags(), Long.class); | ||||
| Set<Long> set = new HashSet<>(); | |||||
| set.addAll(tagList); | |||||
| List<Long> tempList = new ArrayList<>(); | |||||
| tempList.addAll(set); | |||||
| String tagStr = JSONArray.toJSONString(tempList); | |||||
| //先从现有标签中查看用户是否有 服饰尺码 和 鞋码 类别 有 删除 | |||||
| Long tagId = 0L; | |||||
| WxTags wxTags = new WxTags(); | |||||
| wxTags.setTypeId(EnumTagType.ID_27.getCode()); | |||||
| tagId = getTagId(tagList, tagId, wxTags); | |||||
| if (!tagId.equals(0L)) { | |||||
| tagList.remove(tagId); | |||||
| } | |||||
| wxTags.setTypeId(EnumTagType.ID_28.getCode()); | |||||
| tagId = getTagId(tagList, tagId, wxTags); | |||||
| if (!tagId.equals(0L)) { | |||||
| tagList.remove(tagId); | |||||
| } | |||||
| //添加新的标签 | |||||
| tagList.addAll(tags); | |||||
| String tagStr = JSONArray.toJSONString(tagList); | |||||
| userTags.setTags(tagStr); | userTags.setTags(tagStr); | ||||
| userTags.setUpdateDate(new Date()); | userTags.setUpdateDate(new Date()); | ||||
| wxCUserTagsMapper.updateById(userTags); | wxCUserTagsMapper.updateById(userTags); | ||||
| } | } | ||||
| public Long getTagId(List<Long> tagList, Long id, WxTags wxTags) { | |||||
| List<WxTags> list = wxTagsMapper.findList(wxTags); | |||||
| for (WxTags tag : list) { | |||||
| boolean flag = false; | |||||
| for (Long tagId : tagList) { | |||||
| if (tag.getId().equals(tagId)) { | |||||
| id = tagId; | |||||
| flag = true; | |||||
| break; | |||||
| } | |||||
| } | |||||
| if (flag) { | |||||
| break; | |||||
| } | |||||
| } | |||||
| return id; | |||||
| } | |||||
| } | } | ||||