|
@@ -1,13 +1,12 @@
|
|
|
package cn.qinys.platform.mobile.service.impl;
|
|
package cn.qinys.platform.mobile.service.impl;
|
|
|
-
|
|
|
|
|
-import cn.qinys.platform.entity.wishing.Wish;
|
|
|
|
|
|
|
+import cn.qinys.platform.entity.wishing.UserWish;
|
|
|
import cn.qinys.platform.entity.wishing.WishingTree;
|
|
import cn.qinys.platform.entity.wishing.WishingTree;
|
|
|
-import cn.qinys.platform.mobile.mapper.WishMapper;
|
|
|
|
|
|
|
+import cn.qinys.platform.mobile.mapper.UserWishMapper;
|
|
|
import cn.qinys.platform.mobile.mapper.WishingTreeMapper;
|
|
import cn.qinys.platform.mobile.mapper.WishingTreeMapper;
|
|
|
import cn.qinys.platform.mobile.req.WishCreateReq;
|
|
import cn.qinys.platform.mobile.req.WishCreateReq;
|
|
|
import cn.qinys.platform.mobile.resp.WishDetailResp;
|
|
import cn.qinys.platform.mobile.resp.WishDetailResp;
|
|
|
import cn.qinys.platform.mobile.resp.WishListResp;
|
|
import cn.qinys.platform.mobile.resp.WishListResp;
|
|
|
-import cn.qinys.platform.mobile.service.WishService;
|
|
|
|
|
|
|
+import cn.qinys.platform.mobile.service.UserWishService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
@@ -22,10 +21,10 @@ import java.util.List;
|
|
|
|
|
|
|
|
@Slf4j
|
|
@Slf4j
|
|
|
@Service
|
|
@Service
|
|
|
-public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
+public class UserWishServiceImpl implements UserWishService {
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
- private WishMapper wishMapper;
|
|
|
|
|
|
|
+ private UserWishMapper wishMapper;
|
|
|
|
|
|
|
|
@Resource
|
|
@Resource
|
|
|
private WishingTreeMapper wishingTreeMapper;
|
|
private WishingTreeMapper wishingTreeMapper;
|
|
@@ -34,13 +33,13 @@ public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public WishListResp listByTree(Long treeId, Integer page, Integer pageSize) {
|
|
public WishListResp listByTree(Long treeId, Integer page, Integer pageSize) {
|
|
|
- Page<Wish> mpPage = wishMapper.selectPage(
|
|
|
|
|
|
|
+ Page<UserWish> mpPage = wishMapper.selectPage(
|
|
|
new Page<>(page, pageSize),
|
|
new Page<>(page, pageSize),
|
|
|
- new LambdaQueryWrapper<Wish>()
|
|
|
|
|
- .eq(Wish::getTreeId, treeId)
|
|
|
|
|
- .eq(Wish::getIsPublic, 1)
|
|
|
|
|
- .eq(Wish::getStatus, 0)
|
|
|
|
|
- .orderByDesc(Wish::getCreatedAt)
|
|
|
|
|
|
|
+ new LambdaQueryWrapper<UserWish>()
|
|
|
|
|
+ .eq(UserWish::getTreeId, treeId)
|
|
|
|
|
+ .eq(UserWish::getIsPublic, 1)
|
|
|
|
|
+ .eq(UserWish::getStatus, 0)
|
|
|
|
|
+ .orderByDesc(UserWish::getCreatedAt)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
WishListResp resp = new WishListResp();
|
|
WishListResp resp = new WishListResp();
|
|
@@ -51,11 +50,11 @@ public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public WishListResp listMyWishes(String userId, Integer page, Integer pageSize) {
|
|
public WishListResp listMyWishes(String userId, Integer page, Integer pageSize) {
|
|
|
- Page<Wish> mpPage = wishMapper.selectPage(
|
|
|
|
|
|
|
+ Page<UserWish> mpPage = wishMapper.selectPage(
|
|
|
new Page<>(page, pageSize),
|
|
new Page<>(page, pageSize),
|
|
|
- new LambdaQueryWrapper<Wish>()
|
|
|
|
|
- .eq(Wish::getUserId, userId)
|
|
|
|
|
- .orderByDesc(Wish::getCreatedAt)
|
|
|
|
|
|
|
+ new LambdaQueryWrapper<UserWish>()
|
|
|
|
|
+ .eq(UserWish::getUserId, userId)
|
|
|
|
|
+ .orderByDesc(UserWish::getCreatedAt)
|
|
|
);
|
|
);
|
|
|
|
|
|
|
|
WishListResp resp = new WishListResp();
|
|
WishListResp resp = new WishListResp();
|
|
@@ -66,7 +65,7 @@ public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public WishDetailResp getDetail(Long id) {
|
|
public WishDetailResp getDetail(Long id) {
|
|
|
- Wish wish = wishMapper.selectById(id);
|
|
|
|
|
|
|
+ UserWish wish = wishMapper.selectById(id);
|
|
|
return wish != null ? toDetailResp(wish) : null;
|
|
return wish != null ? toDetailResp(wish) : null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -74,7 +73,7 @@ public class WishServiceImpl implements WishService {
|
|
|
public WishDetailResp create(WishCreateReq req, String userId) {
|
|
public WishDetailResp create(WishCreateReq req, String userId) {
|
|
|
WishingTree tree = wishingTreeMapper.selectById(req.getTreeId());
|
|
WishingTree tree = wishingTreeMapper.selectById(req.getTreeId());
|
|
|
|
|
|
|
|
- Wish wish = new Wish();
|
|
|
|
|
|
|
+ UserWish wish = new UserWish();
|
|
|
wish.setTreeId(req.getTreeId());
|
|
wish.setTreeId(req.getTreeId());
|
|
|
wish.setTreeName(tree != null ? tree.getName() : "");
|
|
wish.setTreeName(tree != null ? tree.getName() : "");
|
|
|
wish.setUserId(userId);
|
|
wish.setUserId(userId);
|
|
@@ -92,7 +91,7 @@ public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public boolean delete(Long id, String userId) {
|
|
public boolean delete(Long id, String userId) {
|
|
|
- Wish wish = wishMapper.selectById(id);
|
|
|
|
|
|
|
+ UserWish wish = wishMapper.selectById(id);
|
|
|
if (wish == null || !wish.getUserId().equals(userId)) {
|
|
if (wish == null || !wish.getUserId().equals(userId)) {
|
|
|
return false;
|
|
return false;
|
|
|
}
|
|
}
|
|
@@ -102,7 +101,7 @@ public class WishServiceImpl implements WishService {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public int like(Long id) {
|
|
public int like(Long id) {
|
|
|
- Wish wish = wishMapper.selectById(id);
|
|
|
|
|
|
|
+ UserWish wish = wishMapper.selectById(id);
|
|
|
if (wish == null) {
|
|
if (wish == null) {
|
|
|
return 0;
|
|
return 0;
|
|
|
}
|
|
}
|
|
@@ -111,7 +110,7 @@ public class WishServiceImpl implements WishService {
|
|
|
return wish.getLikes();
|
|
return wish.getLikes();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private WishDetailResp toDetailResp(Wish wish) {
|
|
|
|
|
|
|
+ private WishDetailResp toDetailResp(UserWish wish) {
|
|
|
WishDetailResp resp = new WishDetailResp();
|
|
WishDetailResp resp = new WishDetailResp();
|
|
|
resp.setId(wish.getId());
|
|
resp.setId(wish.getId());
|
|
|
resp.setTreeId(wish.getTreeId());
|
|
resp.setTreeId(wish.getTreeId());
|