|
@@ -1,20 +1,23 @@
|
|
|
package com.ylx.massage.service.impl;
|
|
|
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import cn.hutool.json.JSONObject;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.google.common.collect.Lists;
|
|
|
import com.ylx.common.constant.MassageConstants;
|
|
|
import com.ylx.common.exception.ServiceException;
|
|
|
import com.ylx.common.utils.StringUtils;
|
|
|
+import com.ylx.massage.domain.TCollect;
|
|
|
+import com.ylx.massage.domain.TComment;
|
|
|
import com.ylx.massage.domain.TJs;
|
|
|
import com.ylx.massage.domain.TXiangmu;
|
|
|
import com.ylx.massage.domain.vo.TJsVo;
|
|
|
import com.ylx.massage.enums.JsStatusEnum;
|
|
|
import com.ylx.massage.mapper.TJsMapper;
|
|
|
+import com.ylx.massage.service.TCollectService;
|
|
|
+import com.ylx.massage.service.TCommentService;
|
|
|
import com.ylx.massage.service.TJsService;
|
|
|
import com.ylx.massage.service.TXiangmuService;
|
|
|
import com.ylx.massage.utils.LocationUtil;
|
|
@@ -41,9 +44,15 @@ public class TJsServiceImpl extends ServiceImpl<TJsMapper, TJs> implements TJsSe
|
|
|
@Resource
|
|
|
private LocationUtil locationUtil;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TCollectService collectService;
|
|
|
+
|
|
|
@Resource
|
|
|
private TXiangmuService xiangmuService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private TCommentService commentService;
|
|
|
+
|
|
|
@Override
|
|
|
public Page<TJs> getAll(Page<TJs> page, TJsVo param) {
|
|
|
return mapper.getAll(page, param);
|
|
@@ -84,7 +93,7 @@ public class TJsServiceImpl extends ServiceImpl<TJsMapper, TJs> implements TJsSe
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public TJs getByJsId(String jsId) {
|
|
|
+ public TJs getByJsId(String jsId, String openId) {
|
|
|
if (jsId == null || jsId.trim().isEmpty()) {
|
|
|
// 处理空或空白的jsId
|
|
|
throw new ServiceException("Id为空");
|
|
@@ -99,11 +108,28 @@ public class TJsServiceImpl extends ServiceImpl<TJsMapper, TJs> implements TJsSe
|
|
|
js.setProjects(new ArrayList<>()); // 设置空列表,避免后续调用空指针
|
|
|
return js;
|
|
|
}
|
|
|
+ //项目
|
|
|
List<String> projectIds = Arrays.stream(js.getcBhList().split(",")).collect(Collectors.toList());
|
|
|
LambdaQueryWrapper<TXiangmu> xiangmuLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
xiangmuLambdaQueryWrapper.in(TXiangmu::getcId, projectIds);
|
|
|
List<TXiangmu> projects = xiangmuService.list(xiangmuLambdaQueryWrapper);
|
|
|
js.setProjects(projects);
|
|
|
+ //评论
|
|
|
+ LambdaQueryWrapper<TComment> commentLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ commentLambdaQueryWrapper.eq(TComment::getcJsid, jsId);
|
|
|
+ List<TComment> list = commentService.list(commentLambdaQueryWrapper);
|
|
|
+ if(CollectionUtil.isNotEmpty(list)){
|
|
|
+ js.setComments(list);
|
|
|
+ }
|
|
|
+ //是否收藏
|
|
|
+ LambdaQueryWrapper<TCollect> objectLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ objectLambdaQueryWrapper.eq(TCollect::getcJsId, jsId).eq(TCollect::getcWxOpenId, openId);
|
|
|
+ TCollect collect = collectService.getOne(objectLambdaQueryWrapper);
|
|
|
+ if (collect != null) {
|
|
|
+ js.setIsCollection(true);
|
|
|
+ } else {
|
|
|
+ js.setIsCollection(false);
|
|
|
+ }
|
|
|
return js;
|
|
|
}
|
|
|
|