Merge remote-tracking branch 'refs/remotes/origin/dev'
This commit is contained in:
@@ -2,22 +2,25 @@ package com.schisandra.share.application.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.share.application.convert.SchisandraShareCircleDTOConverter;
|
||||
import com.schisandra.share.application.dto.SchisandraShareCircleDTO;
|
||||
import com.schisandra.share.common.entity.Result;
|
||||
import com.schisandra.share.common.redis.RedisUtil;
|
||||
import com.schisandra.share.domain.bo.SchisandraShareCircleBO;
|
||||
import com.schisandra.share.domain.service.SchisandraShareCircleDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.client.producer.SendCallback;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 分享圈 controller
|
||||
@@ -29,7 +32,9 @@ import java.util.List;
|
||||
@RequestMapping("/share/circle/")
|
||||
@Slf4j
|
||||
public class SchisandraShareCircleController {
|
||||
|
||||
private final String SHARE_USER_RECENT = "share:user:recent:situation";
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
@Resource
|
||||
private SchisandraShareCircleDomainService schisandraShareCircleDomainService;
|
||||
@Resource
|
||||
@@ -48,7 +53,16 @@ public class SchisandraShareCircleController {
|
||||
Preconditions.checkNotNull(schisandraShareCircleDTO.getIcon(), "图标不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareCircleDTO.getDescription(), "描述不能为空");
|
||||
SchisandraShareCircleBO SchisandraShareCircleBO = SchisandraShareCircleDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCircleDTO);
|
||||
return Result.ok(schisandraShareCircleDomainService.add(SchisandraShareCircleBO));
|
||||
if (schisandraShareCircleDomainService.add(SchisandraShareCircleBO)) {
|
||||
String value = "您最近创建了一个圈子:" + schisandraShareCircleDTO.getName();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareCircleDTO.getUserId(), formattedDate);
|
||||
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraShareCircleController.register.error:{}", e.getMessage(), e);
|
||||
return Result.fail("新增分享圈失败");
|
||||
@@ -59,14 +73,14 @@ public class SchisandraShareCircleController {
|
||||
/**
|
||||
* 分享圈列表返回
|
||||
*/
|
||||
@Cacheable(value = "sharelist",key = "'sharelist'")
|
||||
@Cacheable(value = "sharelist", key = "'sharelist'")
|
||||
@GetMapping("sharelist")
|
||||
public Result<List<SchisandraShareCircleDTO>> getShareList() {
|
||||
try {
|
||||
List<SchisandraShareCircleBO> result = schisandraShareCircleDomainService.queryAll();
|
||||
List<SchisandraShareCircleDTO> schisandraShareCircleDTOS = SchisandraShareCircleDTOConverter.INSTANCE.convertBOToDTOList(result);
|
||||
return Result.ok(schisandraShareCircleDTOS);
|
||||
}catch (Exception e) {
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraShareCircleController.getShareList.error:{}", e.getMessage(), e);
|
||||
return Result.fail("分享圈列表获取失败");
|
||||
}
|
||||
@@ -119,7 +133,17 @@ public class SchisandraShareCircleController {
|
||||
Preconditions.checkNotNull(schisandraShareCircleDTO.getViews(), "不能为空");
|
||||
|
||||
SchisandraShareCircleBO schisandraShareCircleBO = SchisandraShareCircleDTOConverter.INSTANCE.convertDTOToBO(schisandraShareCircleDTO);
|
||||
return Result.ok(schisandraShareCircleDomainService.delete(schisandraShareCircleBO));
|
||||
|
||||
if (schisandraShareCircleDomainService.delete(schisandraShareCircleBO)) {
|
||||
String value = "您最近删除了一个圈子:" + schisandraShareCircleDTO.getName();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareCircleDTO.getUserId(), formattedDate);
|
||||
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraShareCircleController.delete.error:{}", e.getMessage(), e);
|
||||
return Result.fail("删除分享圈信息失败");
|
||||
|
@@ -4,10 +4,14 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.share.application.convert.SchisandraShareCommentReplyDTOConverter;
|
||||
import com.schisandra.share.application.convert.SchisandraUserLikesCommentDTOConverter;
|
||||
import com.schisandra.share.application.dto.SchisandraShareCommentReplyDTO;
|
||||
import com.schisandra.share.application.dto.SchisandraUserLikesCommentDTO;
|
||||
import com.schisandra.share.common.entity.Result;
|
||||
import com.schisandra.share.common.redis.RedisUtil;
|
||||
import com.schisandra.share.common.utils.CaffeineUtil;
|
||||
import com.schisandra.share.domain.bo.SchisandraShareCommentReplyBO;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import com.schisandra.share.domain.service.SchisandraShareCommentReplyDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.client.producer.SendCallback;
|
||||
@@ -16,8 +20,11 @@ import org.apache.rocketmq.spring.core.RocketMQTemplate;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 评论回复表 controller
|
||||
@@ -29,14 +36,7 @@ import java.util.List;
|
||||
@RequestMapping("/share/comment/reply/")
|
||||
@Slf4j
|
||||
public class SchisandraShareCommentReplyController {
|
||||
|
||||
/**
|
||||
* 点赞
|
||||
*
|
||||
* @param Id
|
||||
* @return
|
||||
*/
|
||||
|
||||
private final String SHARE_USER_RECENT = "share:user:recent:situation";
|
||||
@Resource
|
||||
RocketMQTemplate rocketMQTemplate;
|
||||
@Resource
|
||||
@@ -44,14 +44,21 @@ public class SchisandraShareCommentReplyController {
|
||||
@Resource
|
||||
private SchisandraShareCommentReplyDomainService schisandraShareCommentReplyDomainService;
|
||||
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
/**
|
||||
* @description: 点赞
|
||||
* @param: [schisandraUserLikesCommentDTO]
|
||||
* @return: void
|
||||
* @author zlg
|
||||
* @date: 2024/7/20 14:39
|
||||
*/
|
||||
@GetMapping("addlike")
|
||||
public void addLike(@RequestParam String Id) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Id", Id);
|
||||
map.put("like", true);
|
||||
Gson gson = new Gson();
|
||||
String message = gson.toJson(map);
|
||||
rocketMQTemplate.asyncSend("CommentLikes-topic", message, new SendCallback() {
|
||||
public void addLike(@RequestParam SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) {
|
||||
Preconditions.checkNotNull(schisandraUserLikesCommentDTO);
|
||||
SchisandraUserLikesCommentBO schisandraUserLikesCommentBO=SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO);
|
||||
schisandraUserLikesCommentBO.setLike(true);
|
||||
rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
@@ -66,13 +73,12 @@ public class SchisandraShareCommentReplyController {
|
||||
}
|
||||
|
||||
@GetMapping("dellike")
|
||||
public void delLike(String Id) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Id", Id);
|
||||
map.put("like", false);
|
||||
Gson gson = new Gson();
|
||||
String message = gson.toJson(map);
|
||||
rocketMQTemplate.asyncSend("CommentLikes-topic", message, new SendCallback() {
|
||||
public void delLike( @RequestParam SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO) {
|
||||
|
||||
Preconditions.checkNotNull(schisandraUserLikesCommentDTO);
|
||||
SchisandraUserLikesCommentBO schisandraUserLikesCommentBO=SchisandraUserLikesCommentDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesCommentDTO);
|
||||
schisandraUserLikesCommentBO.setLike(false);
|
||||
rocketMQTemplate.asyncSend("CommentLikes-topic", schisandraUserLikesCommentBO, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
@@ -212,6 +218,12 @@ public class SchisandraShareCommentReplyController {
|
||||
}
|
||||
}
|
||||
);
|
||||
String value = "您最近发表评论:" + schisandraShareCommentReplyDTO.getContent();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(SHARE_USER_RECENT,schisandraShareCommentReplyDTO.getUserId(), formattedDate);
|
||||
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
|
@@ -4,11 +4,16 @@ import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.base.Preconditions;
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.share.application.convert.SchisandraShareDetailDTOConverter;
|
||||
import com.schisandra.share.application.convert.SchisandraUserLikesDetailDTOConverter;
|
||||
import com.schisandra.share.application.dto.SchisandraShareDetailDTO;
|
||||
import com.schisandra.share.application.dto.SchisandraUserLikesDetailDTO;
|
||||
import com.schisandra.share.common.entity.Result;
|
||||
import com.schisandra.share.common.redis.RedisUtil;
|
||||
import com.schisandra.share.common.utils.CaffeineUtil;
|
||||
import com.schisandra.share.domain.bo.SchisandraShareDetailBO;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
import com.schisandra.share.domain.service.SchisandraShareDetailDomainService;
|
||||
import feign.form.FormData;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.client.producer.SendCallback;
|
||||
import org.apache.rocketmq.client.producer.SendResult;
|
||||
@@ -17,8 +22,11 @@ import org.springframework.cache.annotation.Cacheable;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* 分享详情表 controller
|
||||
@@ -31,12 +39,62 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class SchisandraShareDetailController {
|
||||
|
||||
private final String SHARE_USER_RECENT = "share:user:recent:situation";
|
||||
@Resource
|
||||
CaffeineUtil caffeineUtil;
|
||||
@Resource
|
||||
RedisUtil redisUtil;
|
||||
@Resource
|
||||
private SchisandraShareDetailDomainService schisandraShareDetailDomainService;
|
||||
@Resource
|
||||
private RocketMQTemplate rocketMQTemplate;
|
||||
@Resource
|
||||
CaffeineUtil caffeineUtil;
|
||||
|
||||
|
||||
/**
|
||||
* @description: 点赞
|
||||
* @param: [schisandraUserLikesDetailDTO]
|
||||
* @return: void
|
||||
* @author zlg
|
||||
* @date: 2024/7/20 14:38
|
||||
*/
|
||||
@GetMapping("addlike")
|
||||
public void addLike(@RequestParam SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) {
|
||||
Preconditions.checkNotNull(schisandraUserLikesDetailDTO);
|
||||
SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO);
|
||||
schisandraUserLikesDetailBO.setLike(true);
|
||||
rocketMQTemplate.asyncSend("DetailLikes-topic", schisandraUserLikesDetailBO, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@GetMapping("dellike")
|
||||
public void delLike(@RequestParam SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO) {
|
||||
Preconditions.checkNotNull(schisandraUserLikesDetailDTO);
|
||||
SchisandraUserLikesDetailBO schisandraUserLikesDetailBO = SchisandraUserLikesDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraUserLikesDetailDTO);
|
||||
schisandraUserLikesDetailBO.setLike(false);
|
||||
rocketMQTemplate.asyncSend("DetailLikes-topic", schisandraUserLikesDetailBO, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回评论回复总数
|
||||
@@ -52,6 +110,7 @@ public class SchisandraShareDetailController {
|
||||
return Result.fail("获取评论数量失败!!!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取我的分享
|
||||
*/
|
||||
@@ -59,7 +118,7 @@ public class SchisandraShareDetailController {
|
||||
public Result mydetail(@RequestParam("userId") String userId) {
|
||||
List<SchisandraShareDetailBO> result = (List<SchisandraShareDetailBO>) caffeineUtil
|
||||
.caffeineBuild().getIfPresent("mydetail" + userId);
|
||||
if(result == null) {
|
||||
if (result == null) {
|
||||
result = schisandraShareDetailDomainService.mydetail(userId);
|
||||
caffeineUtil.caffeineBuild().put("list" + userId, result);
|
||||
return Result.ok(SchisandraShareDetailDTOConverter.INSTANCE.convertBOToDTOList(result));
|
||||
@@ -73,37 +132,44 @@ public class SchisandraShareDetailController {
|
||||
* @param schisandraShareDetailDTO
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("add_detail")
|
||||
public Result addDetail(@RequestBody SchisandraShareDetailDTO schisandraShareDetailDTO) {
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getTitle(),"标题不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getIcon(),"图标不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getDescription(),"摘要不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getCircleId(),"摘要不能为空");
|
||||
caffeineUtil.caffeineBuild().invalidate("list" + schisandraShareDetailDTO.getCircleId());
|
||||
caffeineUtil.caffeineBuild().invalidate("mydetail" + schisandraShareDetailDTO.getUserId());
|
||||
SchisandraShareDetailBO schisandraShareDetailBO = SchisandraShareDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraShareDetailDTO);
|
||||
if (schisandraShareDetailDomainService.addDetail(schisandraShareDetailBO)){
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Id", schisandraShareDetailDTO.getCircleId());
|
||||
map.put("isCount", true);
|
||||
Gson gson = new Gson();
|
||||
String message = gson.toJson(map);
|
||||
rocketMQTemplate.asyncSend("CircleCounts-topic", message, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
@PostMapping("add_detail")
|
||||
public Result addDetail(@RequestBody SchisandraShareDetailDTO schisandraShareDetailDTO) {
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getTitle(), "标题不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getIcon(), "图标不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getDescription(), "摘要不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getCircleId(), "摘要不能为空");
|
||||
caffeineUtil.caffeineBuild().invalidate("list" + schisandraShareDetailDTO.getCircleId());
|
||||
caffeineUtil.caffeineBuild().invalidate("mydetail" + schisandraShareDetailDTO.getUserId());
|
||||
SchisandraShareDetailBO schisandraShareDetailBO = SchisandraShareDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraShareDetailDTO);
|
||||
if (schisandraShareDetailDomainService.addDetail(schisandraShareDetailBO)) {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("Id", schisandraShareDetailDTO.getCircleId());
|
||||
map.put("isCount", true);
|
||||
Gson gson = new Gson();
|
||||
String message = gson.toJson(map);
|
||||
rocketMQTemplate.asyncSend("CircleCounts-topic", message, new SendCallback() {
|
||||
@Override
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
}
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
String value="您最近创建了一个分享:"+schisandraShareDetailDTO.getTitle();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareDetailDTO.getUserId(),formattedDate);
|
||||
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -124,6 +190,7 @@ public class SchisandraShareDetailController {
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
@@ -148,7 +215,7 @@ public class SchisandraShareDetailController {
|
||||
public Result<List<SchisandraShareDetailDTO>> selectCircleList(@RequestParam("circleId") String circleId) {
|
||||
List<SchisandraShareDetailBO> result = (List<SchisandraShareDetailBO>) caffeineUtil
|
||||
.caffeineBuild().getIfPresent("list" + circleId);
|
||||
if(result == null){
|
||||
if (result == null) {
|
||||
result = schisandraShareDetailDomainService.list(circleId);
|
||||
caffeineUtil.caffeineBuild().put("list" + circleId, result);
|
||||
return Result.ok(SchisandraShareDetailDTOConverter.INSTANCE.convertBOToDTOList(result));
|
||||
@@ -163,6 +230,7 @@ public class SchisandraShareDetailController {
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
@@ -189,7 +257,7 @@ public class SchisandraShareDetailController {
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getDescription(), "描述不能为空");
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getContent(), "内容不能为空");
|
||||
SchisandraShareDetailBO SchisandraShareDetailBO = SchisandraShareDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraShareDetailDTO);
|
||||
if(schisandraShareDetailDomainService.add(SchisandraShareDetailBO)){
|
||||
if (schisandraShareDetailDomainService.add(SchisandraShareDetailBO)) {
|
||||
caffeineUtil.caffeineBuild().invalidate("list" + schisandraShareDetailDTO.getCircleId());
|
||||
caffeineUtil.caffeineBuild().invalidate("mydetail" + schisandraShareDetailDTO.getUserId());
|
||||
}
|
||||
@@ -248,7 +316,7 @@ public class SchisandraShareDetailController {
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraShareDetailDTO.getId(), "详情id不能为空");
|
||||
SchisandraShareDetailBO schisandraShareDetailBO = SchisandraShareDetailDTOConverter.INSTANCE.convertDTOToBO(schisandraShareDetailDTO);
|
||||
if (schisandraShareDetailDomainService.delete(schisandraShareDetailBO)){
|
||||
if (schisandraShareDetailDomainService.delete(schisandraShareDetailBO)) {
|
||||
caffeineUtil.caffeineBuild().invalidate("list" + schisandraShareDetailDTO.getCircleId());
|
||||
caffeineUtil.caffeineBuild().invalidate("mydetail" + schisandraShareDetailDTO.getUserId());
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
@@ -261,12 +329,19 @@ public class SchisandraShareDetailController {
|
||||
public void onSuccess(SendResult sendResult) {
|
||||
System.out.println(sendResult);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onException(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
);
|
||||
String value="您最近删除了一个分享:"+schisandraShareDetailDTO.getTitle();
|
||||
Date date = new Date();
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
String formattedDate = dateFormat.format(date);
|
||||
String key = redisUtil.buildKey(SHARE_USER_RECENT, schisandraShareDetailDTO.getUserId(),formattedDate);
|
||||
redisUtil.setNx(key, value, 30L, TimeUnit.DAYS);
|
||||
return Result.ok();
|
||||
}
|
||||
return Result.fail();
|
||||
|
@@ -5,14 +5,17 @@ import com.google.common.base.Preconditions;
|
||||
import com.schisandra.share.application.convert.SchisandraUserFavoritesDTOConverter;
|
||||
import com.schisandra.share.application.dto.SchisandraUserFavoritesDTO;
|
||||
import com.schisandra.share.common.entity.Result;
|
||||
import com.schisandra.share.common.utils.CaffeineUtil;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserFavoritesBO;
|
||||
import com.schisandra.share.domain.service.SchisandraUserFavoritesDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 controller
|
||||
@@ -28,26 +31,46 @@ public class SchisandraUserFavoritesController {
|
||||
@Resource
|
||||
private SchisandraUserFavoritesDomainService schisandraUserFavoritesDomainService;
|
||||
|
||||
@Resource
|
||||
CaffeineUtil caffeineUtil;
|
||||
|
||||
/**
|
||||
* 新增收藏表
|
||||
* 我的收藏
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("myfavor")
|
||||
public Result<SchisandraUserFavoritesDTO> myfavor(String userId) {
|
||||
try{
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraUserFavoritesController.myfavor.userId:{}", JSON.toJSONString(userId));
|
||||
}
|
||||
Preconditions.checkNotNull(userId, "userId不能为空");
|
||||
List<SchisandraUserFavoritesBO> result= (List<SchisandraUserFavoritesBO>) caffeineUtil
|
||||
.caffeineBuild().getIfPresent("myfavor"+userId);
|
||||
if(result!=null){
|
||||
return Result.ok(result);
|
||||
}
|
||||
result = schisandraUserFavoritesDomainService.returnMyFavor(userId);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
log.error("SchisandraUserFavoritesController.myfavor.error:{}", e.getMessage(), e);
|
||||
return Result.fail("获取用户收藏表失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增收藏
|
||||
*/
|
||||
@RequestMapping("add")
|
||||
public Result<Boolean> add(@RequestBody SchisandraUserFavoritesDTO schisandraUserFavoritesDTO) {
|
||||
|
||||
try {
|
||||
if (log.isInfoEnabled()) {
|
||||
log.info("SchisandraUserFavoritesController.add.dto:{}", JSON.toJSONString(schisandraUserFavoritesDTO));
|
||||
}
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getUserId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getDetailId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getCircleId(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getExtJson(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getCreatedBy(), "创建人不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getCreatedTime(), "创建时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getUpdateBy(), "更新人不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getUpdateTime(), "更新时间不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getIsDeleted(), "不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getUserId(), "userId不能为空");
|
||||
Preconditions.checkNotNull(schisandraUserFavoritesDTO.getDetailId(), "detailId不能为空");
|
||||
SchisandraUserFavoritesBO SchisandraUserFavoritesBO = SchisandraUserFavoritesDTOConverter.INSTANCE.convertDTOToBO(schisandraUserFavoritesDTO);
|
||||
return Result.ok(schisandraUserFavoritesDomainService.add(SchisandraUserFavoritesBO));
|
||||
} catch (Exception e) {
|
||||
|
@@ -0,0 +1,25 @@
|
||||
package com.schisandra.share.application.convert;
|
||||
|
||||
import com.schisandra.share.application.dto.SchisandraUserLikesCommentDTO;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 评论点赞表 dto转换器
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraUserLikesCommentDTOConverter {
|
||||
|
||||
SchisandraUserLikesCommentDTOConverter INSTANCE = Mappers.getMapper(SchisandraUserLikesCommentDTOConverter.class);
|
||||
|
||||
SchisandraUserLikesCommentBO convertDTOToBO(SchisandraUserLikesCommentDTO schisandraUserLikesCommentDTO);
|
||||
SchisandraUserLikesCommentDTO convertBOToDTO(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO);
|
||||
List<SchisandraUserLikesCommentDTO> convertBOToDTOList(List<SchisandraUserLikesCommentBO> schisandraUserLikesCommentBOList);
|
||||
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
package com.schisandra.share.application.convert;
|
||||
|
||||
import com.schisandra.share.application.dto.SchisandraUserLikesDetailDTO;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 dto转换器
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraUserLikesDetailDTOConverter {
|
||||
|
||||
SchisandraUserLikesDetailDTOConverter INSTANCE = Mappers.getMapper(SchisandraUserLikesDetailDTOConverter.class);
|
||||
|
||||
SchisandraUserLikesDetailBO convertDTOToBO(SchisandraUserLikesDetailDTO schisandraUserLikesDetailDTO);
|
||||
SchisandraUserLikesDetailDTO convertBOToDTO(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO);
|
||||
List<SchisandraUserLikesDetailDTO> convertBOToDTOList(List<SchisandraUserLikesDetailBO> schisandraUserLikesDetailBOList);
|
||||
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.schisandra.share.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 评论点赞表 dto
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraUserLikesCommentDTO implements Serializable {
|
||||
|
||||
private Boolean like;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,39 @@
|
||||
package com.schisandra.share.application.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 dto
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraUserLikesDetailDTO implements Serializable {
|
||||
private Boolean like;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String detailId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -2,7 +2,9 @@ package com.schisandra.share.mq.comment;
|
||||
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import com.schisandra.share.domain.service.SchisandraShareCommentReplyDomainService;
|
||||
import com.schisandra.share.domain.service.SchisandraUserLikesCommentDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
@@ -15,19 +17,19 @@ import java.util.HashMap;
|
||||
@RocketMQMessageListener(topic = "CommentLikes-topic", consumerGroup = "schisandra-cloud-storage-CommentLikes-consumer-group")
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CommentLikesConsumer implements RocketMQListener<String> {
|
||||
public class CommentLikesConsumer implements RocketMQListener<SchisandraUserLikesCommentBO> {
|
||||
@Resource
|
||||
SchisandraShareCommentReplyDomainService schisandraShareCommentReplyDomainService;
|
||||
@Resource
|
||||
SchisandraUserLikesCommentDomainService schisandraUserLikesCommentDomainService;
|
||||
|
||||
@Override
|
||||
public void onMessage(String message) {
|
||||
Gson gson = new Gson();
|
||||
HashMap<Object, Object> map = gson.fromJson(message, HashMap.class);
|
||||
log.info("收到消息:{}", map);
|
||||
String id = (String) map.get("Id");
|
||||
Boolean likes = (Boolean) map.get("like");
|
||||
public void onMessage(SchisandraUserLikesCommentBO message) {
|
||||
log.info("收到消息:{}", message);
|
||||
String id = message.getCommentId();
|
||||
Boolean likes = message.getLike();
|
||||
schisandraShareCommentReplyDomainService.updateCommentsLikes(id, likes);
|
||||
|
||||
schisandraUserLikesCommentDomainService.add(message);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -0,0 +1,32 @@
|
||||
package com.schisandra.share.mq.comment;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
import com.schisandra.share.domain.service.SchisandraShareDetailDomainService;
|
||||
import com.schisandra.share.domain.service.SchisandraUserLikesDetailDomainService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
|
||||
import org.apache.rocketmq.spring.core.RocketMQListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.HashMap;
|
||||
|
||||
@RocketMQMessageListener(topic = "DetailLikes-topic", consumerGroup = "schisandra-cloud-storage-DetailLikes-consumer-group")
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DetailLikesConsumer implements RocketMQListener<SchisandraUserLikesDetailBO> {
|
||||
@Resource
|
||||
SchisandraShareDetailDomainService schisandraShareDetailDomainService;
|
||||
@Resource
|
||||
SchisandraUserLikesDetailDomainService schisandraUserLikesDetailDomainService;
|
||||
@Override
|
||||
public void onMessage(SchisandraUserLikesDetailBO message) {
|
||||
log.info("收到消息:{}", message);
|
||||
String id = message.getDetailId();
|
||||
Boolean likes = message.getLike();
|
||||
schisandraShareDetailDomainService.updateDetailLikes(id, likes);
|
||||
schisandraUserLikesDetailDomainService.add(message);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.schisandra.share.common.redis;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAutoDetect;
|
||||
import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
||||
import com.fasterxml.jackson.annotation.PropertyAccessor;
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.RedisSerializer;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
|
||||
/**
|
||||
* Redis的config处理
|
||||
*
|
||||
* @author: schisandra
|
||||
*/
|
||||
@Configuration
|
||||
public class RedisConfig {
|
||||
|
||||
@Bean
|
||||
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory redisConnectionFactory) {
|
||||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
|
||||
RedisSerializer<String> redisSerializer = new StringRedisSerializer();
|
||||
redisTemplate.setConnectionFactory(redisConnectionFactory);
|
||||
redisTemplate.setKeySerializer(redisSerializer);
|
||||
redisTemplate.setHashKeySerializer(redisSerializer);
|
||||
redisTemplate.setValueSerializer(jackson2JsonRedisSerializer());
|
||||
redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer());
|
||||
return redisTemplate;
|
||||
}
|
||||
|
||||
private Jackson2JsonRedisSerializer<Object> jackson2JsonRedisSerializer() {
|
||||
Jackson2JsonRedisSerializer<Object> jsonRedisSerializer = new Jackson2JsonRedisSerializer<>(Object.class);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY);
|
||||
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||
objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.PROPERTY);
|
||||
jsonRedisSerializer.setObjectMapper(objectMapper);
|
||||
return jsonRedisSerializer;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,150 @@
|
||||
package com.schisandra.share.common.redis;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* RedisUtil工具类
|
||||
*
|
||||
* @author: schisandra
|
||||
* @date: 2024/2/19
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class RedisUtil {
|
||||
|
||||
@Resource
|
||||
private RedisTemplate redisTemplate;
|
||||
|
||||
private static final String CACHE_KEY_SEPARATOR = ":";
|
||||
|
||||
|
||||
public List<Object> getDataFromDirectory(String directory) {
|
||||
Set<String>keys=redisTemplate.keys(directory+":*");
|
||||
List<Object> keysList=new ArrayList<>();
|
||||
keys.forEach(key->{
|
||||
HashMap<String,String> map=new HashMap<>();
|
||||
String value= (String) redisTemplate.opsForValue().get(key);
|
||||
String keyName=key.substring(key.lastIndexOf(":")+1);
|
||||
map.put(keyName,value);
|
||||
keysList.add(map);
|
||||
});
|
||||
return keysList;
|
||||
}
|
||||
public List<HashMap<Object,Object>> getDataFromDir(String directory) {
|
||||
|
||||
Set<String>keys=redisTemplate.keys(directory);
|
||||
List<HashMap<Object,Object>> keysList=new ArrayList<>();
|
||||
keys.forEach(key->{
|
||||
HashMap<Object,Object> map=new HashMap<>();
|
||||
HashMap<Object,Object> value= (HashMap<Object, Object>) redisTemplate.opsForValue().get(key);
|
||||
map.put(key,value);
|
||||
keysList.add(map);
|
||||
});
|
||||
return keysList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 构建缓存key
|
||||
*/
|
||||
public String buildKey(String... strObjs) {
|
||||
return Stream.of(strObjs).collect(Collectors.joining(CACHE_KEY_SEPARATOR));
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否存在key
|
||||
*/
|
||||
public boolean exist(String key) {
|
||||
return redisTemplate.hasKey(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除key
|
||||
*/
|
||||
public boolean del(String key) {
|
||||
return redisTemplate.delete(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* set(不带过期)
|
||||
*/
|
||||
public void set(String key, String value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
public void setJson(String key, Object value) {
|
||||
redisTemplate.opsForValue().set(key, value);
|
||||
}
|
||||
|
||||
public HashMap<String, String> getJson(String key) {
|
||||
return (HashMap<String, String>) redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* set(带过期)
|
||||
*/
|
||||
public boolean setNx(String key, String value, Long time, TimeUnit timeUnit) {
|
||||
return redisTemplate.opsForValue().setIfAbsent(key, value, time, timeUnit);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取string类型缓存
|
||||
*/
|
||||
public String get(String key) {
|
||||
return (String) redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
public Boolean zAdd(String key, String value, Long score) {
|
||||
return redisTemplate.opsForZSet().add(key, value, Double.valueOf(String.valueOf(score)));
|
||||
}
|
||||
|
||||
public Long countZset(String key) {
|
||||
return redisTemplate.opsForZSet().size(key);
|
||||
}
|
||||
|
||||
public Set<String> rangeZset(String key, long start, long end) {
|
||||
return redisTemplate.opsForZSet().range(key, start, end);
|
||||
}
|
||||
|
||||
public Long removeZset(String key, Object value) {
|
||||
return redisTemplate.opsForZSet().remove(key, value);
|
||||
}
|
||||
|
||||
public void removeZsetList(String key, Set<String> value) {
|
||||
value.stream().forEach((val) -> redisTemplate.opsForZSet().remove(key, val));
|
||||
}
|
||||
|
||||
public Double score(String key, Object value) {
|
||||
return redisTemplate.opsForZSet().score(key, value);
|
||||
}
|
||||
|
||||
public Set<String> rangeByScore(String key, long start, long end) {
|
||||
return redisTemplate.opsForZSet().rangeByScore(key, Double.valueOf(String.valueOf(start)), Double.valueOf(String.valueOf(end)));
|
||||
}
|
||||
|
||||
public Object addScore(String key, Object obj, double score) {
|
||||
return redisTemplate.opsForZSet().incrementScore(key, obj, score);
|
||||
}
|
||||
|
||||
public Object rank(String key, Object obj) {
|
||||
return redisTemplate.opsForZSet().rank(key, obj);
|
||||
}
|
||||
|
||||
|
||||
public void setNx(String key, HashMap<Object, Object> map, Long time, TimeUnit timeUnit) {
|
||||
redisTemplate.opsForValue().set(key, map, time, timeUnit);
|
||||
}
|
||||
}
|
@@ -0,0 +1,39 @@
|
||||
package com.schisandra.share.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 评论点赞表 bo
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraUserLikesCommentBO implements Serializable {
|
||||
|
||||
private Boolean like;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,38 @@
|
||||
package com.schisandra.share.domain.bo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
/**
|
||||
* 分享详情点赞表 bo
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Data
|
||||
public class SchisandraUserLikesDetailBO implements Serializable {
|
||||
|
||||
private Boolean like;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private String detailId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ import com.schisandra.share.infra.basic.entity.SchisandraUserFavorites;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 bo转换器
|
||||
*
|
||||
@@ -19,4 +21,5 @@ public interface SchisandraUserFavoritesBOConverter {
|
||||
SchisandraUserFavorites convertBOToEntity(SchisandraUserFavoritesBO schisandraUserFavoritesBO);
|
||||
SchisandraUserFavoritesBO convertEntityToBO(SchisandraUserFavorites schisandraUserFavorites);
|
||||
|
||||
List<SchisandraUserFavoritesBO> convertEntityToBOList(List<SchisandraUserFavorites> schisandraUserFavorites);
|
||||
}
|
||||
|
@@ -0,0 +1,22 @@
|
||||
package com.schisandra.share.domain.convert;
|
||||
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 评论点赞表 bo转换器
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraUserLikesCommentBOConverter {
|
||||
|
||||
SchisandraUserLikesCommentBOConverter INSTANCE = Mappers.getMapper(SchisandraUserLikesCommentBOConverter.class);
|
||||
|
||||
SchisandraUserLikesComment convertBOToEntity(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO);
|
||||
SchisandraUserLikesCommentBO convertEntityToBO(SchisandraUserLikesComment schisandraUserLikesComment);
|
||||
|
||||
}
|
@@ -0,0 +1,22 @@
|
||||
package com.schisandra.share.domain.convert;
|
||||
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 bo转换器
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Mapper
|
||||
public interface SchisandraUserLikesDetailBOConverter {
|
||||
|
||||
SchisandraUserLikesDetailBOConverter INSTANCE = Mappers.getMapper(SchisandraUserLikesDetailBOConverter.class);
|
||||
|
||||
SchisandraUserLikesDetail convertBOToEntity(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO);
|
||||
SchisandraUserLikesDetailBO convertEntityToBO(SchisandraUserLikesDetail schisandraUserLikesDetail);
|
||||
|
||||
}
|
@@ -37,4 +37,6 @@ public interface SchisandraShareDetailDomainService {
|
||||
|
||||
Boolean updateCommentsLikes(String id,Boolean isReply);
|
||||
Boolean updateDetailViews(String id,Boolean isView);
|
||||
|
||||
Boolean updateDetailLikes(String id,Boolean isLike);
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package com.schisandra.share.domain.service;
|
||||
|
||||
import com.schisandra.share.domain.bo.SchisandraUserFavoritesBO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 领域service
|
||||
*
|
||||
@@ -25,4 +27,6 @@ public interface SchisandraUserFavoritesDomainService {
|
||||
*/
|
||||
Boolean delete(SchisandraUserFavoritesBO schisandraUserFavoritesBO);
|
||||
|
||||
List<SchisandraUserFavoritesBO> returnMyFavor(String userId);
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,28 @@
|
||||
package com.schisandra.share.domain.service;
|
||||
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
|
||||
/**
|
||||
* 评论点赞表 领域service
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
public interface SchisandraUserLikesCommentDomainService {
|
||||
|
||||
/**
|
||||
* 添加 评论点赞表 信息
|
||||
*/
|
||||
Boolean add(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO);
|
||||
|
||||
/**
|
||||
* 更新 评论点赞表 信息
|
||||
*/
|
||||
Boolean update(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO);
|
||||
|
||||
/**
|
||||
* 删除 评论点赞表 信息
|
||||
*/
|
||||
Boolean delete(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO);
|
||||
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.schisandra.share.domain.service;
|
||||
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 领域service
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
public interface SchisandraUserLikesDetailDomainService {
|
||||
|
||||
/**
|
||||
* 添加 分享详情点赞表 信息
|
||||
*/
|
||||
Boolean add(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO);
|
||||
|
||||
/**
|
||||
* 更新 分享详情点赞表 信息
|
||||
*/
|
||||
Boolean update(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO);
|
||||
|
||||
/**
|
||||
* 删除 分享详情点赞表 信息
|
||||
*/
|
||||
Boolean delete(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO);
|
||||
|
||||
}
|
@@ -199,4 +199,13 @@ public class SchisandraShareDetailDomainServiceImpl implements SchisandraShareDe
|
||||
return schisandraShareDetailService.delDetailViews(id) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateDetailLikes(String id, Boolean isLike) {
|
||||
if (isLike) {
|
||||
return schisandraShareDetailService.addDetailLike(id) > 0;
|
||||
} else {
|
||||
return schisandraShareDetailService.delDetailLike(id) > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 领域service实现了
|
||||
@@ -45,4 +46,10 @@ public class SchisandraUserFavoritesDomainServiceImpl implements SchisandraUserF
|
||||
return schisandraUserFavoritesService.update(schisandraUserFavorites) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchisandraUserFavoritesBO> returnMyFavor(String userId){
|
||||
List<SchisandraUserFavoritesBO> schisandraUserFavoritesBOS = SchisandraUserFavoritesBOConverter.INSTANCE.convertEntityToBOList(schisandraUserFavoritesService.returnMyFavor(userId));
|
||||
return schisandraUserFavoritesBOS;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,48 @@
|
||||
package com.schisandra.share.domain.service.impl;
|
||||
|
||||
import com.schisandra.share.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.share.domain.convert.SchisandraUserLikesCommentBOConverter;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesCommentBO;
|
||||
import com.schisandra.share.domain.service.SchisandraUserLikesCommentDomainService;
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment;
|
||||
import com.schisandra.share.infra.basic.service.SchisandraUserLikesCommentService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 评论点赞表 领域service实现了
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraUserLikesCommentDomainServiceImpl implements SchisandraUserLikesCommentDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraUserLikesCommentService schisandraUserLikesCommentService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO) {
|
||||
SchisandraUserLikesComment schisandraUserLikesComment = SchisandraUserLikesCommentBOConverter.INSTANCE.convertBOToEntity(schisandraUserLikesCommentBO);
|
||||
schisandraUserLikesComment.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraUserLikesCommentService.insert(schisandraUserLikesComment) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO) {
|
||||
SchisandraUserLikesComment schisandraUserLikesComment = SchisandraUserLikesCommentBOConverter.INSTANCE.convertBOToEntity(schisandraUserLikesCommentBO);
|
||||
return schisandraUserLikesCommentService.update(schisandraUserLikesComment) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraUserLikesCommentBO schisandraUserLikesCommentBO) {
|
||||
SchisandraUserLikesComment schisandraUserLikesComment = new SchisandraUserLikesComment();
|
||||
schisandraUserLikesComment.setId(schisandraUserLikesCommentBO.getId());
|
||||
schisandraUserLikesComment.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraUserLikesCommentService.update(schisandraUserLikesComment) > 0;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.schisandra.share.domain.service.impl;
|
||||
|
||||
import com.schisandra.share.common.enums.IsDeletedFlagEnum;
|
||||
import com.schisandra.share.domain.convert.SchisandraUserLikesDetailBOConverter;
|
||||
import com.schisandra.share.domain.bo.SchisandraUserLikesDetailBO;
|
||||
import com.schisandra.share.domain.service.SchisandraUserLikesDetailDomainService;
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail;
|
||||
import com.schisandra.share.infra.basic.service.SchisandraUserLikesDetailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 领域service实现了
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class SchisandraUserLikesDetailDomainServiceImpl implements SchisandraUserLikesDetailDomainService {
|
||||
|
||||
@Resource
|
||||
private SchisandraUserLikesDetailService schisandraUserLikesDetailService;
|
||||
|
||||
@Override
|
||||
public Boolean add(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO) {
|
||||
SchisandraUserLikesDetail schisandraUserLikesDetail = SchisandraUserLikesDetailBOConverter.INSTANCE.convertBOToEntity(schisandraUserLikesDetailBO);
|
||||
schisandraUserLikesDetail.setIsDeleted(IsDeletedFlagEnum.UN_DELETED.getCode());
|
||||
return schisandraUserLikesDetailService.insert(schisandraUserLikesDetail) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean update(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO) {
|
||||
SchisandraUserLikesDetail schisandraUserLikesDetail = SchisandraUserLikesDetailBOConverter.INSTANCE.convertBOToEntity(schisandraUserLikesDetailBO);
|
||||
return schisandraUserLikesDetailService.update(schisandraUserLikesDetail) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean delete(SchisandraUserLikesDetailBO schisandraUserLikesDetailBO) {
|
||||
SchisandraUserLikesDetail schisandraUserLikesDetail = new SchisandraUserLikesDetail();
|
||||
schisandraUserLikesDetail.setId(schisandraUserLikesDetailBO.getId());
|
||||
schisandraUserLikesDetail.setIsDeleted(IsDeletedFlagEnum.DELETED.getCode());
|
||||
return schisandraUserLikesDetailService.update(schisandraUserLikesDetail) > 0;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,17 @@
|
||||
package com.schisandra.share.infra.basic.dao;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 评论点赞表 表数据库访问层
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraUserLikesCommentDao extends BaseMapper<SchisandraUserLikesComment> {
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,17 @@
|
||||
package com.schisandra.share.infra.basic.dao;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail;
|
||||
import com.mybatisflex.core.BaseMapper;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 表数据库访问层
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Repository
|
||||
public interface SchisandraUserLikesDetailDao extends BaseMapper<SchisandraUserLikesDetail> {
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,47 @@
|
||||
package com.schisandra.share.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 评论点赞表 实体类
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Data
|
||||
@Table("schisandra_user_likes_comment")
|
||||
public class SchisandraUserLikesComment implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("comment_id")
|
||||
private String commentId;
|
||||
|
||||
/**
|
||||
* 是否删除 0 未删除 1已删除
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,47 @@
|
||||
package com.schisandra.share.infra.basic.entity;
|
||||
|
||||
import com.mybatisflex.annotation.Column;
|
||||
import com.mybatisflex.annotation.Id;
|
||||
import com.mybatisflex.annotation.KeyType;
|
||||
import com.mybatisflex.annotation.Table;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 实体类
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Data
|
||||
@Table("schisandra_user_likes_detail")
|
||||
public class SchisandraUserLikesDetail implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Id(value = "id", keyType = KeyType.Auto)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("user_id")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("detail_id")
|
||||
private String detailId;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Column("is_deleted")
|
||||
private Integer isDeleted;
|
||||
|
||||
}
|
||||
|
@@ -31,6 +31,9 @@ public interface SchisandraShareDetailService {
|
||||
|
||||
int delDetailViews(String Id);
|
||||
|
||||
int addDetailLike(String Id);
|
||||
int delDetailLike(String Id);
|
||||
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
|
@@ -2,6 +2,8 @@ package com.schisandra.share.infra.basic.service;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserFavorites;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 表服务接口
|
||||
*
|
||||
@@ -42,5 +44,5 @@ public interface SchisandraUserFavoritesService {
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
List<SchisandraUserFavorites> returnMyFavor(String userId);
|
||||
}
|
||||
|
@@ -0,0 +1,46 @@
|
||||
package com.schisandra.share.infra.basic.service;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment;
|
||||
|
||||
/**
|
||||
* 评论点赞表 表服务接口
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
public interface SchisandraUserLikesCommentService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraUserLikesComment queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraUserLikesComment 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraUserLikesComment schisandraUserLikesComment);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraUserLikesComment 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraUserLikesComment schisandraUserLikesComment);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.schisandra.share.infra.basic.service;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 表服务接口
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
public interface SchisandraUserLikesDetailService {
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
SchisandraUserLikesDetail queryById(Long id);
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraUserLikesDetail 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int insert(SchisandraUserLikesDetail schisandraUserLikesDetail);
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraUserLikesDetail 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
int update(SchisandraUserLikesDetail schisandraUserLikesDetail);
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean deleteById(Long id);
|
||||
|
||||
|
||||
}
|
@@ -65,6 +65,24 @@ public class SchisandraShareDetailServiceImpl implements SchisandraShareDetailSe
|
||||
return schisandraShareDetailDao.update(schisandraShareDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int addDetailLike(String Id) {
|
||||
SchisandraShareDetail schisandraShareDetail = UpdateEntity.of(SchisandraShareDetail.class, Id);
|
||||
UpdateWrapper wrapper = UpdateWrapper.of(schisandraShareDetail);
|
||||
wrapper.set(SchisandraShareDetailTableDef.SCHISANDRA_SHARE_DETAIL.LIKES_COUNT,
|
||||
SchisandraShareDetailTableDef.SCHISANDRA_SHARE_DETAIL.LIKES_COUNT.add(1));
|
||||
return schisandraShareDetailDao.update(schisandraShareDetail);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int delDetailLike(String Id) {
|
||||
SchisandraShareDetail schisandraShareDetail = UpdateEntity.of(SchisandraShareDetail.class, Id);
|
||||
UpdateWrapper wrapper = UpdateWrapper.of(schisandraShareDetail);
|
||||
wrapper.set(SchisandraShareDetailTableDef.SCHISANDRA_SHARE_DETAIL.LIKES_COUNT,
|
||||
SchisandraShareDetailTableDef.SCHISANDRA_SHARE_DETAIL.LIKES_COUNT.subtract(1));
|
||||
return schisandraShareDetailDao.update(schisandraShareDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
|
@@ -1,11 +1,14 @@
|
||||
package com.schisandra.share.infra.basic.service.impl;
|
||||
|
||||
import com.mybatisflex.core.query.QueryWrapper;
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserFavorites;
|
||||
import com.schisandra.share.infra.basic.dao.SchisandraUserFavoritesDao;
|
||||
import com.schisandra.share.infra.basic.entity.table.SchisandraUserFavoritesTableDef;
|
||||
import com.schisandra.share.infra.basic.service.SchisandraUserFavoritesService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 收藏表 表服务实现类
|
||||
@@ -63,5 +66,17 @@ public class SchisandraUserFavoritesServiceImpl implements SchisandraUserFavorit
|
||||
return this.schisandraUserFavoritesDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SchisandraUserFavorites> returnMyFavor(String userId) {
|
||||
QueryWrapper wrapper = QueryWrapper.create()
|
||||
.select(SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.ID,
|
||||
SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.DETAIL_ID,
|
||||
SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.CIRCLE_ID,
|
||||
SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.CREATED_TIME)
|
||||
.where(SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.USER_ID.eq(userId))
|
||||
.orderBy(SchisandraUserFavoritesTableDef.SCHISANDRA_USER_FAVORITES.CREATED_TIME,false);
|
||||
return this.schisandraUserFavoritesDao.selectListByQuery(wrapper);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@@ -0,0 +1,67 @@
|
||||
package com.schisandra.share.infra.basic.service.impl;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment;
|
||||
import com.schisandra.share.infra.basic.dao.SchisandraUserLikesCommentDao;
|
||||
import com.schisandra.share.infra.basic.service.SchisandraUserLikesCommentService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 评论点赞表 表服务实现类
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:11:01
|
||||
*/
|
||||
@Service("SchisandraUserLikesCommentService")
|
||||
public class SchisandraUserLikesCommentServiceImpl implements SchisandraUserLikesCommentService {
|
||||
|
||||
@Resource
|
||||
private SchisandraUserLikesCommentDao schisandraUserLikesCommentDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraUserLikesComment queryById(Long id) {
|
||||
return this.schisandraUserLikesCommentDao.selectOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraUserLikesComment 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraUserLikesComment schisandraUserLikesComment) {
|
||||
return this.schisandraUserLikesCommentDao.insertSelective(schisandraUserLikesComment);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraUserLikesComment 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraUserLikesComment schisandraUserLikesComment) {
|
||||
return this.schisandraUserLikesCommentDao.update(schisandraUserLikesComment,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraUserLikesCommentDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
package com.schisandra.share.infra.basic.service.impl;
|
||||
|
||||
import com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail;
|
||||
import com.schisandra.share.infra.basic.dao.SchisandraUserLikesDetailDao;
|
||||
import com.schisandra.share.infra.basic.service.SchisandraUserLikesDetailService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 分享详情点赞表 表服务实现类
|
||||
*
|
||||
* @author zlg
|
||||
* @since 2024-07-20 14:12:42
|
||||
*/
|
||||
@Service("SchisandraUserLikesDetailService")
|
||||
public class SchisandraUserLikesDetailServiceImpl implements SchisandraUserLikesDetailService {
|
||||
|
||||
@Resource
|
||||
private SchisandraUserLikesDetailDao schisandraUserLikesDetailDao;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public SchisandraUserLikesDetail queryById(Long id) {
|
||||
return this.schisandraUserLikesDetailDao.selectOneById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增数据
|
||||
*
|
||||
* @param schisandraUserLikesDetail 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int insert(SchisandraUserLikesDetail schisandraUserLikesDetail) {
|
||||
return this.schisandraUserLikesDetailDao.insertSelective(schisandraUserLikesDetail);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改数据
|
||||
*
|
||||
* @param schisandraUserLikesDetail 实例对象
|
||||
* @return 实例对象
|
||||
*/
|
||||
@Override
|
||||
public int update(SchisandraUserLikesDetail schisandraUserLikesDetail) {
|
||||
return this.schisandraUserLikesDetailDao.update(schisandraUserLikesDetail,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过主键删除数据
|
||||
*
|
||||
* @param id 主键
|
||||
* @return 是否成功
|
||||
*/
|
||||
@Override
|
||||
public boolean deleteById(Long id) {
|
||||
return this.schisandraUserLikesDetailDao.deleteById(id) > 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.share.infra.basic.dao.SchisandraUserLikesCommentDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.share.infra.basic.entity.SchisandraUserLikesComment">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="comment_id" jdbcType="VARCHAR" property="commentId"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.schisandra.share.infra.basic.dao.SchisandraUserLikesDetailDao">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.schisandra.share.infra.basic.entity.SchisandraUserLikesDetail">
|
||||
<id column="id" jdbcType="VARCHAR" property="id"/>
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId"/>
|
||||
<result column="detail_id" jdbcType="VARCHAR" property="detailId"/>
|
||||
<result column="is_deleted" jdbcType="INTEGER" property="isDeleted"/>
|
||||
</resultMap>
|
||||
|
||||
</mapper>
|
Reference in New Issue
Block a user