Commit 0c2596c3 authored by muhong's avatar muhong

修改 我发布的和收藏品列表

parent 69441bb2
...@@ -2,8 +2,12 @@ package com.wwdz.ch.db.dao; ...@@ -2,8 +2,12 @@ package com.wwdz.ch.db.dao;
import com.wwdz.ch.db.domain.ItemsOfficialUsersRelation; import com.wwdz.ch.db.domain.ItemsOfficialUsersRelation;
import java.util.List;
public interface ItemsOfficialUsersRelationDao { public interface ItemsOfficialUsersRelationDao {
ItemsOfficialUsersRelation findUser(Long itemId); ItemsOfficialUsersRelation findUser(Long itemId);
ItemsOfficialUsersRelation findItems(Long user); ItemsOfficialUsersRelation findItems(Long user);
List<ItemsOfficialUsersRelation> list();
} }
...@@ -7,6 +7,8 @@ import com.wwdz.ch.db.mapper.ItemsOfficialUsersRelationMapper; ...@@ -7,6 +7,8 @@ import com.wwdz.ch.db.mapper.ItemsOfficialUsersRelationMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
@Repository @Repository
public class ItemsOfficialUsersRelationDaoImpl implements ItemsOfficialUsersRelationDao { public class ItemsOfficialUsersRelationDaoImpl implements ItemsOfficialUsersRelationDao {
@Autowired @Autowired
...@@ -28,4 +30,10 @@ public class ItemsOfficialUsersRelationDaoImpl implements ItemsOfficialUsersRela ...@@ -28,4 +30,10 @@ public class ItemsOfficialUsersRelationDaoImpl implements ItemsOfficialUsersRela
criteria.andUserIdEqualTo(userId); criteria.andUserIdEqualTo(userId);
return itemsOfficialUsersRelationMapper.selectOneByExample(example); return itemsOfficialUsersRelationMapper.selectOneByExample(example);
} }
@Override
public List<ItemsOfficialUsersRelation> list() {
ItemsOfficialUsersRelationExample example = new ItemsOfficialUsersRelationExample();
return itemsOfficialUsersRelationMapper.selectByExample(example);
}
} }
...@@ -261,10 +261,9 @@ public class FavoritesServiceImpl implements FavoritesService { ...@@ -261,10 +261,9 @@ public class FavoritesServiceImpl implements FavoritesService {
// 设置价格 // 设置价格
vo.setPrice(getPrice(item.getPrice())); vo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的 // 设置是否收藏或是否是自己发布的
vo.setIsCollected(0); vo.setIsCollected(favoritesItemsRelationDao.isCollected(userId, relation.getItemId(), null) ? 1 : 0);
vo.setIsMine(0); vo.setIsMine(0);
if (Objects.nonNull(dto.getUserId()) && dto.getUserId() != 0L) { if (Objects.nonNull(dto.getUserId()) && dto.getUserId() != 0L) {
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), relation.getItemId(), null) ? 1 : 0);
if (!isGuest) { if (!isGuest) {
vo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0); vo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0);
} }
......
...@@ -99,8 +99,6 @@ public class ItemServiceImpl implements ItemService { ...@@ -99,8 +99,6 @@ public class ItemServiceImpl implements ItemService {
@Autowired @Autowired
private FollowFansRecordService followFansRecordService; private FollowFansRecordService followFansRecordService;
private static final List<Long> officialUserIds = new ArrayList<>(Arrays.asList(1L));
@Override @Override
public Result nameList(ItemRequestDto dto) { public Result nameList(ItemRequestDto dto) {
try { try {
...@@ -222,6 +220,14 @@ public class ItemServiceImpl implements ItemService { ...@@ -222,6 +220,14 @@ public class ItemServiceImpl implements ItemService {
} }
// 是否客态 // 是否客态
boolean isGuest = !dto.getUserId().equals(userId); boolean isGuest = !dto.getUserId().equals(userId);
// 获取官方用户id
List<ItemsOfficialUsersRelation> itemsOfficialUsersRelations = itemsOfficialUsersRelationDao.list();
List<Long> officialUserIds = new ArrayList<>();
if (CollectionUtils.isNotEmpty(itemsOfficialUsersRelations)) {
officialUserIds = itemsOfficialUsersRelations.stream()
.map(ItemsOfficialUsersRelation::getUserId).collect(Collectors.toList());
}
if (!officialUserIds.contains(dto.getUserId())) { if (!officialUserIds.contains(dto.getUserId())) {
// 查询用户和藏品关联表 // 查询用户和藏品关联表
List<UserItemsRelation> userItemsRelations = userItemsRelationDao.listByUserIds(dto.getUserId(), null); List<UserItemsRelation> userItemsRelations = userItemsRelationDao.listByUserIds(dto.getUserId(), null);
...@@ -259,7 +265,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -259,7 +265,7 @@ public class ItemServiceImpl implements ItemService {
// 设置是否收藏和是否是自己发布的 // 设置是否收藏和是否是自己发布的
vo.setIsCollected(0); vo.setIsCollected(0);
vo.setIsMine(isGuest ? 0 : 1); vo.setIsMine(isGuest ? 0 : 1);
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), item.getId(), null) ? 1 : 0); vo.setIsCollected(favoritesItemsRelationDao.isCollected(userId, item.getId(), null) ? 1 : 0);
// 设置收藏数 // 设置收藏数
long count = favoritesItemsRelationDao.countByItemId(item.getId()); long count = favoritesItemsRelationDao.countByItemId(item.getId());
vo.setCollectCount(StringUtil.formatCount(count)); vo.setCollectCount(StringUtil.formatCount(count));
...@@ -307,7 +313,7 @@ public class ItemServiceImpl implements ItemService { ...@@ -307,7 +313,7 @@ public class ItemServiceImpl implements ItemService {
vo.setHomePageImage(MediaUtil.getHomePageImage(es.getImages(), es.getVideos())); vo.setHomePageImage(MediaUtil.getHomePageImage(es.getImages(), es.getVideos()));
// 设置是否收藏和是否是自己发布的 // 设置是否收藏和是否是自己发布的
vo.setIsMine(isGuest ? 0 : 1); vo.setIsMine(isGuest ? 0 : 1);
vo.setIsCollected(favoritesItemsRelationDao.isCollected(dto.getUserId(), es.getId(), null) ? 1 : 0); vo.setIsCollected(favoritesItemsRelationDao.isCollected(userId, es.getId(), null) ? 1 : 0);
// 设置收藏数 // 设置收藏数
long count = favoritesItemsRelationDao.countByItemId(es.getId()); long count = favoritesItemsRelationDao.countByItemId(es.getId());
vo.setCollectCount(StringUtil.formatCount(count)); vo.setCollectCount(StringUtil.formatCount(count));
...@@ -381,11 +387,12 @@ public class ItemServiceImpl implements ItemService { ...@@ -381,11 +387,12 @@ public class ItemServiceImpl implements ItemService {
// 设置价格 // 设置价格
itemResponseVo.setPrice(getPrice(item.getPrice())); itemResponseVo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的 // 设置是否收藏或是否是自己发布的
itemResponseVo.setIsCollected(1); itemResponseVo.setIsCollected(0);
itemResponseVo.setIsMine(0); itemResponseVo.setIsMine(0);
if (!isGuest) { if (!isGuest) {
itemResponseVo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0); itemResponseVo.setIsMine(userItemsRelationDao.isExisted(dto.getUserId(), item.getId()) ? 1 : 0);
} }
itemResponseVo.setIsCollected(favoritesItemsRelationDao.isCollected(userId, item.getId(), null) ? 1 : 0);
// 设置收藏数 // 设置收藏数
long count = favoritesItemsRelationDao.countByItemId(item.getId()); long count = favoritesItemsRelationDao.countByItemId(item.getId());
itemResponseVo.setCollectCount(StringUtil.formatCount(count)); itemResponseVo.setCollectCount(StringUtil.formatCount(count));
...@@ -544,13 +551,13 @@ public class ItemServiceImpl implements ItemService { ...@@ -544,13 +551,13 @@ public class ItemServiceImpl implements ItemService {
} }
// 设置价格 // 设置价格
itemResponseVo.setPrice(getPrice(item.getPrice())); itemResponseVo.setPrice(getPrice(item.getPrice()));
// 设置是否收藏或是否是自己发布的
itemResponseVo.setIsCollected(0);
itemResponseVo.setIsMine(0);
// 设置藏品的发布用户昵称和头像 // 设置藏品的发布用户昵称和头像
itemCommonService.getNicknameAvatar(item.getId(), itemResponseVo); itemCommonService.getNicknameAvatar(item.getId(), itemResponseVo);
itemResponseVo.setIsFollowed(false); itemResponseVo.setIsFollowed(false);
itemResponseVo.setFollowedId(null); itemResponseVo.setFollowedId(null);
// 设置是否收藏或是否是自己发布的
itemResponseVo.setIsCollected(0);
itemResponseVo.setIsMine(0);
if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) { if (Objects.nonNull(dto.getUserId()) && !dto.getUserId().equals(0L)) {
FavoritesItemsRelation favoritesItemsRelation = favoritesItemsRelationDao.selectByUserIdItemId(dto.getUserId(), item.getId()); FavoritesItemsRelation favoritesItemsRelation = favoritesItemsRelationDao.selectByUserIdItemId(dto.getUserId(), item.getId());
if (Objects.nonNull(favoritesItemsRelation)) { if (Objects.nonNull(favoritesItemsRelation)) {
......
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