diff --git a/petplanet-common/src/main/java/top/zynorl/petplanet/common/enums/TransactionStatusEnum.java b/petplanet-common/src/main/java/top/zynorl/petplanet/common/enums/TransactionStatusEnum.java deleted file mode 100644 index dd12861..0000000 --- a/petplanet-common/src/main/java/top/zynorl/petplanet/common/enums/TransactionStatusEnum.java +++ /dev/null @@ -1,24 +0,0 @@ -package top.zynorl.petplanet.common.enums; - -import lombok.Getter; - -/** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/05 - **/ -@Getter -public enum TransactionStatusEnum { - STARTED("started", "事务开始", "本地保存"), - SUCCESS("success", "事务执行成功", "收到ack"), - FAILED("failed", "事务执行失败", "未收到ack"); - - private final String code; - private final String name; - private final String desc; - TransactionStatusEnum(String code, String name, String desc){ - this.code = code; - this.name = name; - this.desc = desc; - } -} diff --git a/petplanet-common/src/main/java/top/zynorl/petplanet/common/exception/RepeatConsumptionException.java b/petplanet-common/src/main/java/top/zynorl/petplanet/common/exception/RepeatConsumptionException.java new file mode 100644 index 0000000..fed5e49 --- /dev/null +++ b/petplanet-common/src/main/java/top/zynorl/petplanet/common/exception/RepeatConsumptionException.java @@ -0,0 +1,20 @@ +package top.zynorl.petplanet.common.exception; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Created by zynorl on 2024/1/18 15:25 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class RepeatConsumptionException extends RuntimeException{ + private static final long serialVersionUID = 1L; + private String transactionId; + + public RepeatConsumptionException(String message, String transactionId) { + super(message); + this.transactionId = transactionId; + } + +} diff --git a/petplanet-post/pom.xml b/petplanet-post/pom.xml index 556552f..f9fd009 100644 --- a/petplanet-post/pom.xml +++ b/petplanet-post/pom.xml @@ -26,11 +26,6 @@ petplanet-common ${petplanet-common.version} - - top.zynorl.petplanet - petplanet-sqlServer - ${petplanet-sqlServer.version} - top.zynorl.petplanet petplanet-mongoServer @@ -55,11 +50,19 @@ org.springframework.cloud spring-cloud-starter-openfeign - + + + mysql + mysql-connector-java + org.springframework.boot spring-boot-starter-data-mongodb + + org.springframework.boot + spring-boot-starter-data-redis + com.alibaba.cloud @@ -104,7 +107,7 @@ org.springframework.boot spring-boot-maven-plugin - top.zynorl.petplanet.user.PetplanetUserApplication + top.zynorl.petplanet.post.PetplanetPostApplication repackage diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostControllerConverter.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostControllerConverter.java index 8e4ea23..ece7ef6 100644 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostControllerConverter.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostControllerConverter.java @@ -17,5 +17,4 @@ public interface PostControllerConverter extends BaseConverter { @Mapping(target = "startEditTime", source = "startEditTime", qualifiedByName = "toLocalDataTime") PublishPostReqBO toPublishPostReqBO(PublishPostReq publishPostReq); - PublishPostReqBO toPublishPostReqBO1(PublishPostReq publishPostReq); } diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostServiceConverter.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostServiceConverter.java index c7df682..3f13ef0 100644 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostServiceConverter.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/converter/PostServiceConverter.java @@ -5,8 +5,7 @@ import top.zynorl.petplanet.common.converter.ConverterConfig; import top.zynorl.petplanet.mongoserver.entity.PostMO; import top.zynorl.petplanet.post.common.pojo.bo.req.PublishPostReqBO; -import top.zynorl.petplanet.post.common.pojo.dto.PublishPostDTO; -import top.zynorl.petplanet.sqlServer.entity.LocationInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.LocationInfoDO; /** * @version 1.0 diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/BaseTransactionDTO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/BaseTransactionDTO.java new file mode 100644 index 0000000..3100b29 --- /dev/null +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/BaseTransactionDTO.java @@ -0,0 +1,23 @@ +package top.zynorl.petplanet.post.common.pojo.dto; + +import lombok.Builder; +import lombok.Data; + +import java.io.Serializable; + +/** + * Created by zynorl on 2024/1/17 10:20 + */ +@Data +public class BaseTransactionDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 事务id + */ + private String transactionId; + + /** + * kafka主题 + */ + private String topic; +} diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PostDTO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PostDTO.java deleted file mode 100644 index 4fc1073..0000000 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PostDTO.java +++ /dev/null @@ -1,50 +0,0 @@ -package top.zynorl.petplanet.post.common.pojo.dto; - -import lombok.Data; - -import java.time.LocalDateTime; - -/** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/03 - **/ -@Data -public class PostDTO { - /** - * 关联用户id - */ - private Long userId; - /** - * 帖子标题 - */ - private String title; - /** - * 帖子的正文 - */ - private String content; - /** - * 帖子标签的名称, 比如狗狗、猫咪 - */ - private String tagName; - /** - * 发布ip - */ - private String ip; - /** - * 帖子权限类型 - */ - private String permissionType; - /** - * 是否为定时发布 - */ - private Boolean isTiming; - /** - * 首次开始编写帖子的时间 - */ - private LocalDateTime startEditTime; - /** - * 最近帖子修改时间 - */ - private LocalDateTime lastEditTime; -} diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostDTO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostFailedCallbackDTO.java similarity index 60% rename from petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostDTO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostFailedCallbackDTO.java index 5e98be3..e56b713 100644 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostDTO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostFailedCallbackDTO.java @@ -5,21 +5,18 @@ import java.io.Serializable; /** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/10 - **/ + * Created by zynorl on 2024/1/18 16:14 + */ @Data -public class PublishPostDTO implements Serializable { +public class PublishPostFailedCallbackDTO implements Serializable { private static final long serialVersionUID = 1L; - /** - * 关联用户id + * 帖子id */ - private Long userId; + private String postId; /** - * 帖子id + * 地点Id */ - private String postId; + private Long locationId; } diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostTransactionDTO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostTransactionDTO.java new file mode 100644 index 0000000..af6fee3 --- /dev/null +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/common/pojo/dto/PublishPostTransactionDTO.java @@ -0,0 +1,35 @@ +package top.zynorl.petplanet.post.common.pojo.dto; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.io.Serializable; + +/** + * @version 1.0 + * @Author niuzy + * @Date 2024/01/10 + **/ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class PublishPostTransactionDTO extends BaseTransactionDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 关联用户id + */ + private Long userId; + + /** + * 帖子id + */ + private String postId; + + /** + * 地点Id + */ + private Long locationId; +} diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/listener/TransactionFailedCallbackListener.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/listener/TransactionFailedCallbackListener.java new file mode 100644 index 0000000..0d9768b --- /dev/null +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/listener/TransactionFailedCallbackListener.java @@ -0,0 +1,28 @@ +package top.zynorl.petplanet.post.listener; + +import cn.hutool.json.JSONUtil; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.annotation.KafkaListener; +import org.springframework.stereotype.Component; +import top.zynorl.petplanet.post.common.pojo.dto.PublishPostFailedCallbackDTO; +import top.zynorl.petplanet.post.transaction.PostPublishTransactionalService; + +/** + * @version 1.0 + * @Author niuzy + * @Date 2024/01/05 + **/ +@Component +@Slf4j +public class TransactionFailedCallbackListener { + private static final String postPublishTopic = "post_publish"; + @Autowired + private PostPublishTransactionalService postPublishTransactionalService; + + @KafkaListener(topics = postPublishTopic) + public void postPublishListener(String message) { + PublishPostFailedCallbackDTO publishPostFailedCallbackDTO = JSONUtil.toBean(message, PublishPostFailedCallbackDTO.class); + postPublishTransactionalService.DoCancel(publishPostFailedCallbackDTO); + } +} diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/scheduler/KafkaTransactionSchedulerTask.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/scheduler/KafkaTransactionSchedulerTask.java deleted file mode 100644 index a8cc838..0000000 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/scheduler/KafkaTransactionSchedulerTask.java +++ /dev/null @@ -1,77 +0,0 @@ -package top.zynorl.petplanet.post.scheduler; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.data.redis.core.Cursor; -import org.springframework.data.redis.core.RedisCallback; -import org.springframework.data.redis.core.RedisTemplate; -import org.springframework.data.redis.core.ScanOptions; -import org.springframework.kafka.core.KafkaTemplate; -import org.springframework.kafka.support.SendResult; -import org.springframework.scheduling.annotation.Scheduled; -import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionSystemException; -import org.springframework.util.concurrent.ListenableFutureCallback; - -import java.util.*; - -/** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/05 - **/ -@Slf4j -@Component -public class KafkaTransactionSchedulerTask { - private static final String postPublishTopic = "post_publish"; - @Autowired - private KafkaTemplate kafkaTemplate; - @Autowired - private RedisTemplate redisTemplate; - @Scheduled(fixedRate = 2000) // 2秒钟执行一次 - public void executeTask() { - String keyPattern = postPublishTopic+"*"; - Map map = keyScanner(keyPattern); - map.entrySet().forEach(entity -> { - kafkaTemplate.send(postPublishTopic, entity).addCallback(new ListenableFutureCallback>() { - - @Override - public void onFailure(Throwable throwable) { - String Msg = String.format("事务id【%s】发送失败:%s", entity.getKey(), throwable.getMessage()); - log.error(Msg); - throw new TransactionSystemException(Msg); - } - - @Override - public void onSuccess(SendResult stringObjectSendResult) { - String Msg = String.format("事务id【%s】发送成功", entity.getKey()); - log.info(Msg); - } - }); - }); - } - - private Map keyScanner(String keyPattern){ - - Set keys = redisTemplate.execute((RedisCallback>) connection -> { - Set binaryKeys = new HashSet<>(); - ScanOptions options = ScanOptions.scanOptions().match(keyPattern).count(100).build(); - Cursor cursor = connection.scan(options); - while (cursor.hasNext()) { - binaryKeys.add(new String(cursor.next())); - } - return binaryKeys; - }); - Map scans = new HashMap<>(); - assert keys != null; - for (String key : keys) { - String value = (String)redisTemplate.opsForValue().get(key); - String tranId = key.substring(keyPattern.length()); - scans.put(tranId, value); - } - return scans; - } - - -} diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/serializer/TransactionRecordSerializer.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/serializer/TransactionRecordSerializer.java deleted file mode 100644 index 98ffd8b..0000000 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/serializer/TransactionRecordSerializer.java +++ /dev/null @@ -1,44 +0,0 @@ -package top.zynorl.petplanet.post.serializer; - - -import cn.hutool.core.util.StrUtil; -import cn.hutool.json.JSONUtil; -import org.apache.commons.lang3.SerializationException; -import org.apache.kafka.common.serialization.Serializer; -import top.zynorl.petplanet.sqlServer.entity.TransactionRecordDO; - -import java.nio.charset.StandardCharsets; -import java.util.Map; - -/** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/05 - **/ -public class TransactionRecordSerializer implements Serializer { - @Override - public void configure(Map configs, boolean isKey) { - - } - - @Override - public byte[] serialize(String topic, TransactionRecordDO data) { - try { - // 将TransactionRecordDO对象转换为JSON字符串 - String jsonStr = JSONUtil.toJsonStr(data); - // 确保json字符串不为空,并转为字节数组 - if (StrUtil.isNotBlank(jsonStr)) { - return jsonStr.getBytes(StandardCharsets.UTF_8); - } else { - throw new SerializationException("Error serializing TransactionRecordDO to byte array as JSON, JSON string is empty"); - } - } catch (Exception e) { - throw new SerializationException("Error serializing TransactionRecordDO to JSON string", e); - } - } - - @Override - public void close() { - - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/CommentInfoDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/CommentInfoDAO.java similarity index 71% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/CommentInfoDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/CommentInfoDAO.java index eef2f12..a754980 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/CommentInfoDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/CommentInfoDAO.java @@ -1,8 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.CommentInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.CommentInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/LocationInfoDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/LocationInfoDAO.java similarity index 74% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/LocationInfoDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/LocationInfoDAO.java index 7facc5f..39a744d 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/LocationInfoDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/LocationInfoDAO.java @@ -1,9 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.LocationInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.LocationInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostCommentRelationDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostCommentRelationDAO.java similarity index 73% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostCommentRelationDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostCommentRelationDAO.java index 07e2265..1c38f22 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostCommentRelationDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostCommentRelationDAO.java @@ -1,9 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostCommentRelationDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostCommentRelationDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostInfoDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostInfoDAO.java similarity index 71% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostInfoDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostInfoDAO.java index 2440936..5e651d9 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostInfoDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostInfoDAO.java @@ -1,9 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPermissionInfoDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPermissionInfoDAO.java similarity index 71% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPermissionInfoDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPermissionInfoDAO.java index 75c3d7e..a9ba12e 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPermissionInfoDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPermissionInfoDAO.java @@ -1,8 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostPermissionInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPermissionInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPetRelationDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPetRelationDAO.java similarity index 72% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPetRelationDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPetRelationDAO.java index 1a1e914..b3bf950 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPetRelationDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostPetRelationDAO.java @@ -1,8 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; + import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostPetRelationDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPetRelationDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostTagInfoDAO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostTagInfoDAO.java similarity index 72% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostTagInfoDAO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostTagInfoDAO.java index 99e11b9..9921cc3 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostTagInfoDAO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/dao/PostTagInfoDAO.java @@ -1,9 +1,9 @@ -package top.zynorl.petplanet.sqlServer.dao; +package top.zynorl.petplanet.post.sqlServer.dao; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostTagInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostTagInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/CommentInfoDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/CommentInfoDO.java similarity index 96% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/CommentInfoDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/CommentInfoDO.java index e5362c6..7138392 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/CommentInfoDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/CommentInfoDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/LocationInfoDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/LocationInfoDO.java similarity index 92% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/LocationInfoDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/LocationInfoDO.java index 8772354..997175e 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/LocationInfoDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/LocationInfoDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; @@ -23,7 +23,7 @@ @ApiModel(value = "LocationInfo对象", description = "发布帖子时候的位置信息,从第三方接口中获取") @Data @Builder -public class LocationInfoDO extends BaseTransactionalDO implements Serializable { +public class LocationInfoDO implements Serializable { private static final long serialVersionUID = 1L; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostCommentRelationDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostCommentRelationDO.java similarity index 96% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostCommentRelationDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostCommentRelationDO.java index f8c0765..f92eef2 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostCommentRelationDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostCommentRelationDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostInfoDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostInfoDO.java similarity index 97% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostInfoDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostInfoDO.java index e934a37..afa5458 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostInfoDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostInfoDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPermissionInfoDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPermissionInfoDO.java similarity index 96% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPermissionInfoDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPermissionInfoDO.java index 982ce46..8fe2857 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPermissionInfoDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPermissionInfoDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPetRelationDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPetRelationDO.java similarity index 95% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPetRelationDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPetRelationDO.java index 0aa71c7..fc56d47 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPetRelationDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostPetRelationDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostTagInfoDO.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostTagInfoDO.java similarity index 95% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostTagInfoDO.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostTagInfoDO.java index 26f63f6..2e66370 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostTagInfoDO.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/entity/PostTagInfoDO.java @@ -1,4 +1,4 @@ -package top.zynorl.petplanet.sqlServer.entity; +package top.zynorl.petplanet.post.sqlServer.entity; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ICommentInfoDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ICommentInfoDBService.java similarity index 67% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ICommentInfoDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ICommentInfoDBService.java index 91c0e7c..2ac998a 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ICommentInfoDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ICommentInfoDBService.java @@ -1,8 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.CommentInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.CommentInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ILocationInfoDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ILocationInfoDBService.java similarity index 77% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ILocationInfoDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ILocationInfoDBService.java index 0810fb3..172ae5b 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ILocationInfoDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/ILocationInfoDBService.java @@ -1,7 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; + import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.LocationInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.LocationInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostCommentRelationDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostCommentRelationDBService.java similarity index 69% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostCommentRelationDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostCommentRelationDBService.java index 016cd52..2f9ee6c 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostCommentRelationDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostCommentRelationDBService.java @@ -1,8 +1,7 @@ -package top.zynorl.petplanet.sqlServer.service; - +package top.zynorl.petplanet.post.sqlServer.server; import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostCommentRelationDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostCommentRelationDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostInfoDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostInfoDBService.java similarity index 67% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostInfoDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostInfoDBService.java index ba720ac..e1dab33 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostInfoDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostInfoDBService.java @@ -1,8 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPermissionInfoDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPermissionInfoDBService.java similarity index 67% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPermissionInfoDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPermissionInfoDBService.java index 093ec8f..8cda6eb 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPermissionInfoDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPermissionInfoDBService.java @@ -1,8 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostPermissionInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPermissionInfoDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPetRelationDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPetRelationDBService.java similarity index 67% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPetRelationDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPetRelationDBService.java index 697fd80..c7e9dd4 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPetRelationDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostPetRelationDBService.java @@ -1,7 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; + import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostPetRelationDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPetRelationDO; /** *

diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostTagInfoDBService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostTagInfoDBService.java similarity index 67% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostTagInfoDBService.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostTagInfoDBService.java index e819aee..02af6b1 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostTagInfoDBService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/IPostTagInfoDBService.java @@ -1,7 +1,8 @@ -package top.zynorl.petplanet.sqlServer.service; +package top.zynorl.petplanet.post.sqlServer.server; + import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostTagInfoDO; +import top.zynorl.petplanet.post.sqlServer.entity.PostTagInfoDO; /** *

diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/CommentInfoDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/CommentInfoDBServiceImpl.java new file mode 100644 index 0000000..2496a35 --- /dev/null +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/CommentInfoDBServiceImpl.java @@ -0,0 +1,21 @@ +package top.zynorl.petplanet.post.sqlServer.server.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import top.zynorl.petplanet.post.sqlServer.dao.CommentInfoDAO; +import top.zynorl.petplanet.post.sqlServer.entity.CommentInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.ICommentInfoDBService; + +/** + *

+ * 评论信息表 服务实现类 + *

+ * + * @author zynorl/niuzy + * @since 2024-01-02 + */ +@Service +public class CommentInfoDBServiceImpl extends ServiceImpl implements ICommentInfoDBService { + +} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/LocationInfoDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/LocationInfoDBServiceImpl.java similarity index 66% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/LocationInfoDBServiceImpl.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/LocationInfoDBServiceImpl.java index a3d2435..b7707bb 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/LocationInfoDBServiceImpl.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/LocationInfoDBServiceImpl.java @@ -1,13 +1,12 @@ -package top.zynorl.petplanet.sqlServer.service.impl; +package top.zynorl.petplanet.post.sqlServer.server.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.LocationInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.LocationInfoDO; -import top.zynorl.petplanet.sqlServer.service.ILocationInfoDBService; +import top.zynorl.petplanet.post.sqlServer.dao.LocationInfoDAO; +import top.zynorl.petplanet.post.sqlServer.entity.LocationInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.ILocationInfoDBService; /** *

@@ -18,7 +17,6 @@ * @since 2024-01-02 */ @Service -@DataSourceSwitch(value = "postDataSource") public class LocationInfoDBServiceImpl extends ServiceImpl implements ILocationInfoDBService { @Override public void deleteByTransactionId(String transactionId) { diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostCommentRelationDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostCommentRelationDBServiceImpl.java similarity index 52% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostCommentRelationDBServiceImpl.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostCommentRelationDBServiceImpl.java index 37a4e71..661a195 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostCommentRelationDBServiceImpl.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostCommentRelationDBServiceImpl.java @@ -1,12 +1,11 @@ -package top.zynorl.petplanet.sqlServer.service.impl; +package top.zynorl.petplanet.post.sqlServer.server.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostCommentRelationDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostCommentRelationDO; -import top.zynorl.petplanet.sqlServer.service.IPostCommentRelationDBService; +import top.zynorl.petplanet.post.sqlServer.dao.PostCommentRelationDAO; +import top.zynorl.petplanet.post.sqlServer.entity.PostCommentRelationDO; +import top.zynorl.petplanet.post.sqlServer.server.IPostCommentRelationDBService; /** *

@@ -17,7 +16,6 @@ * @since 2024-01-02 */ @Service -@DataSourceSwitch(value = "postDataSource") public class PostCommentRelationDBServiceImpl extends ServiceImpl implements IPostCommentRelationDBService { } diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostInfoDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostInfoDBServiceImpl.java new file mode 100644 index 0000000..f3c8603 --- /dev/null +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostInfoDBServiceImpl.java @@ -0,0 +1,21 @@ +package top.zynorl.petplanet.post.sqlServer.server.impl; + + +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.stereotype.Service; +import top.zynorl.petplanet.post.sqlServer.dao.PostInfoDAO; +import top.zynorl.petplanet.post.sqlServer.entity.PostInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.IPostInfoDBService; + +/** + *

+ * 帖子信息表 服务实现类 + *

+ * + * @author zynorl/niuzy + * @since 2024-01-02 + */ +@Service +public class PostInfoDBServiceImpl extends ServiceImpl implements IPostInfoDBService { + +} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPermissionInfoDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPermissionInfoDBServiceImpl.java similarity index 50% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPermissionInfoDBServiceImpl.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPermissionInfoDBServiceImpl.java index 7e05b04..5c720d8 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPermissionInfoDBServiceImpl.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPermissionInfoDBServiceImpl.java @@ -1,12 +1,11 @@ -package top.zynorl.petplanet.sqlServer.service.impl; +package top.zynorl.petplanet.post.sqlServer.server.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostPermissionInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostPermissionInfoDO; -import top.zynorl.petplanet.sqlServer.service.IPostPermissionInfoDBService; +import top.zynorl.petplanet.post.sqlServer.dao.PostPermissionInfoDAO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPermissionInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.IPostPermissionInfoDBService; /** *

@@ -17,7 +16,6 @@ * @since 2024-01-02 */ @Service -@DataSourceSwitch(value = "postDataSource") public class PostPermissionInfoDBServiceImpl extends ServiceImpl implements IPostPermissionInfoDBService { } diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPetRelationDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPetRelationDBServiceImpl.java similarity index 50% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPetRelationDBServiceImpl.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPetRelationDBServiceImpl.java index bc9b55b..4f258b6 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPetRelationDBServiceImpl.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostPetRelationDBServiceImpl.java @@ -1,12 +1,11 @@ -package top.zynorl.petplanet.sqlServer.service.impl; +package top.zynorl.petplanet.post.sqlServer.server.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostPetRelationDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostPetRelationDO; -import top.zynorl.petplanet.sqlServer.service.IPostPetRelationDBService; +import top.zynorl.petplanet.post.sqlServer.dao.PostPetRelationDAO; +import top.zynorl.petplanet.post.sqlServer.entity.PostPetRelationDO; +import top.zynorl.petplanet.post.sqlServer.server.IPostPetRelationDBService; /** *

@@ -17,7 +16,6 @@ * @since 2024-01-02 */ @Service -@DataSourceSwitch(value = "postDataSource") public class PostPetRelationDBServiceImpl extends ServiceImpl implements IPostPetRelationDBService { } diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostTagInfoDBServiceImpl.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostTagInfoDBServiceImpl.java similarity index 50% rename from petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostTagInfoDBServiceImpl.java rename to petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostTagInfoDBServiceImpl.java index 5bb9d51..357a466 100644 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostTagInfoDBServiceImpl.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/sqlServer/server/impl/PostTagInfoDBServiceImpl.java @@ -1,12 +1,11 @@ -package top.zynorl.petplanet.sqlServer.service.impl; +package top.zynorl.petplanet.post.sqlServer.server.impl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostTagInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostTagInfoDO; -import top.zynorl.petplanet.sqlServer.service.IPostTagInfoDBService; +import top.zynorl.petplanet.post.sqlServer.dao.PostTagInfoDAO; +import top.zynorl.petplanet.post.sqlServer.entity.PostTagInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.IPostTagInfoDBService; /** *

@@ -17,7 +16,6 @@ * @since 2024-01-02 */ @Service -@DataSourceSwitch(value = "postDataSource") public class PostTagInfoDBServiceImpl extends ServiceImpl implements IPostTagInfoDBService { } diff --git a/petplanet-post/src/main/java/top/zynorl/petplanet/post/transaction/PostPublishTransactionalService.java b/petplanet-post/src/main/java/top/zynorl/petplanet/post/transaction/PostPublishTransactionalService.java index bfa3f08..20be248 100644 --- a/petplanet-post/src/main/java/top/zynorl/petplanet/post/transaction/PostPublishTransactionalService.java +++ b/petplanet-post/src/main/java/top/zynorl/petplanet/post/transaction/PostPublishTransactionalService.java @@ -1,21 +1,21 @@ package top.zynorl.petplanet.post.transaction; import cn.hutool.core.lang.UUID; -import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.support.SendResult; import org.springframework.stereotype.Component; -import org.springframework.transaction.annotation.Transactional; -import top.zynorl.petplanet.common.enums.TransactionStatusEnum; +import org.springframework.transaction.TransactionSystemException; +import org.springframework.util.concurrent.ListenableFutureCallback; import top.zynorl.petplanet.mongoserver.entity.PostMO; import top.zynorl.petplanet.mongoserver.service.PostMOService; import top.zynorl.petplanet.post.common.pojo.bo.req.PublishPostReqBO; import top.zynorl.petplanet.post.common.pojo.converter.PostServiceConverter; -import top.zynorl.petplanet.post.common.pojo.dto.PublishPostDTO; -import top.zynorl.petplanet.sqlServer.entity.LocationInfoDO; -import top.zynorl.petplanet.sqlServer.entity.TransactionRecordDO; -import top.zynorl.petplanet.sqlServer.service.ILocationInfoDBService; -import top.zynorl.petplanet.sqlServer.service.ITransactionRecordService; +import top.zynorl.petplanet.post.common.pojo.dto.PublishPostFailedCallbackDTO; +import top.zynorl.petplanet.post.common.pojo.dto.PublishPostTransactionDTO; +import top.zynorl.petplanet.post.sqlServer.entity.LocationInfoDO; +import top.zynorl.petplanet.post.sqlServer.server.ILocationInfoDBService; import java.time.LocalDateTime; @@ -33,13 +33,16 @@ public class PostPublishTransactionalService implements TCCTransactionalService< @Autowired private ILocationInfoDBService locationInfoDBService; @Autowired - private ITransactionRecordService transactionRecordService; - @Autowired private PostServiceConverter postServiceConverter; + @Autowired + private KafkaTemplate kafkaTemplate; + private static final String postPublishTopic = "post_publish"; + private static String postId; + private static Long locationId; private PostMO post = null; private LocationInfoDO locationInfoDO = null; - private final PublishPostDTO publishPostDTO = new PublishPostDTO(); + private final PublishPostTransactionDTO publishPostDTO = new PublishPostTransactionDTO(); @Override public boolean doProcess(PublishPostReqBO publishPostReqBO) { @@ -50,7 +53,7 @@ public boolean doProcess(PublishPostReqBO publishPostReqBO) { try { confirm(transactionId, post, locationInfoDO); } catch (Exception e) { - cancel(transactionId); + cancel(); return false; } return true; @@ -66,6 +69,7 @@ private boolean doTry(PublishPostReqBO publishPostReqBO) { locationInfoDO = postServiceConverter.toLocationInfoDO(publishPostReqBO); // 解构出user,跨服务保存到user服务中 publishPostDTO.setUserId(publishPostReqBO.getUserId()); + publishPostDTO.setTopic(postPublishTopic); } catch (Exception e) { log.error("转化出错" + e.getMessage()); return false; @@ -75,19 +79,38 @@ private boolean doTry(PublishPostReqBO publishPostReqBO) { private void confirm(String transactionId, PostMO post, LocationInfoDO locationInfoDO) { - String postId = postMOService.savePost(post); - locationInfoDBService.save(locationInfoDO); + postId = postMOService.savePost(post); + boolean isOk = locationInfoDBService.save(locationInfoDO); + if(isOk){ + locationId = locationInfoDO.getId(); + } + publishPostDTO.setTransactionId(transactionId); publishPostDTO.setPostId(postId); - String jsonStr = JSONUtil.toJsonStr(publishPostDTO); - TransactionRecordDO transactionRecordDO = TransactionRecordDO.builder() - .status(TransactionStatusEnum.STARTED.getCode()).transactionId(transactionId).data(jsonStr).build(); - transactionRecordService.save(transactionRecordDO); + publishPostDTO.setLocationId(locationId); + kafkaTemplate.send(postPublishTopic, publishPostDTO).addCallback(new ListenableFutureCallback<>() { + @Override + public void onFailure(Throwable throwable) { + String Msg = String.format("事务id【%s】发送失败:%s, 本地事务回滚", publishPostDTO.getTransactionId(), throwable.getMessage()); + log.error(Msg); + throw new TransactionSystemException(Msg); + } + + @Override + public void onSuccess(SendResult stringObjectSendResult) { + String Msg = String.format("事务id【%s】发送成功, 本地事务回滚", publishPostDTO.getTransactionId()); + log.info(Msg); + } + }); } - private void cancel(String transactionId) { - postMOService.deletePostByTransactionId(transactionId); - locationInfoDBService.deleteByTransactionId(transactionId); - transactionRecordService.deleteByTransactionId(transactionId); + private void cancel() { + postMOService.deletePostById(postId); + locationInfoDBService.removeById(locationId); + } + + public void DoCancel(PublishPostFailedCallbackDTO publishPostFailedCallbackDTO) { + postMOService.deletePostById(publishPostFailedCallbackDTO.getPostId()); + locationInfoDBService.removeById(publishPostFailedCallbackDTO.getLocationId()); } } diff --git a/petplanet-post/src/main/resources/application.properties b/petplanet-post/src/main/resources/application.properties index 02309cf..054e49a 100644 --- a/petplanet-post/src/main/resources/application.properties +++ b/petplanet-post/src/main/resources/application.properties @@ -1,4 +1,4 @@ -##spring.main.allow-bean-definition-overriding=true +spring.main.allow-bean-definition-overriding=true # #server.port=8882 #server.servlet.context-path =/post diff --git a/petplanet-post/src/main/resources/application.yml b/petplanet-post/src/main/resources/application.yml index 6d3f476..d329d63 100644 --- a/petplanet-post/src/main/resources/application.yml +++ b/petplanet-post/src/main/resources/application.yml @@ -1,4 +1,9 @@ spring: + datasource: + username: petplanet + password: petplanet + url: jdbc:mysql://124.220.36.202:3306/petplanet-user?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai + driver-class-name: com.mysql.cj.jdbc.Driver kafka: bootstrap-servers: localhost:9092 producer: @@ -6,9 +11,17 @@ spring: batch-size: 16384 buffer-memory: 33554432 key-serializer: org.apache.kafka.common.serialization.StringSerializer - value-serializer: top.zynorl.transaction.fund.payment.serializer.TransactionRecordSerializer + value-serializer: org.apache.kafka.common.serialization.StringDeserializer properties: linger.ms: 100 + consumer: + group-id: mq-transaction-test + auto-offset-reset: earliest + enable-auto-commit: false + auto-commit-interval: 1000 + key-deserializer: org.apache.kafka.common.serialization.StringDeserializer + value-deserializer: org.apache.kafka.common.serialization.StringDeserializer + application: name: petplanet-post cloud: @@ -22,3 +35,9 @@ server: port: 8882 servlet: context-path: /post + +mybatis-plus: + mapper-locations: classpath:/mapper/*Mapper.xml + global-config: + db-config: + id-type: auto diff --git a/petplanet-sqlServer/src/main/resources/mapper/CommentInfoDOMapper.xml b/petplanet-post/src/main/resources/mapper/CommentInfoDOMapper.xml similarity index 67% rename from petplanet-sqlServer/src/main/resources/mapper/CommentInfoDOMapper.xml rename to petplanet-post/src/main/resources/mapper/CommentInfoDOMapper.xml index 1138900..a552662 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/CommentInfoDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/CommentInfoDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/LocationInfoDOMapper.xml b/petplanet-post/src/main/resources/mapper/LocationInfoDOMapper.xml similarity index 67% rename from petplanet-sqlServer/src/main/resources/mapper/LocationInfoDOMapper.xml rename to petplanet-post/src/main/resources/mapper/LocationInfoDOMapper.xml index e330b12..2a967ab 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/LocationInfoDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/LocationInfoDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostCommentRelationDOMapper.xml b/petplanet-post/src/main/resources/mapper/PostCommentRelationDOMapper.xml similarity index 65% rename from petplanet-sqlServer/src/main/resources/mapper/PostCommentRelationDOMapper.xml rename to petplanet-post/src/main/resources/mapper/PostCommentRelationDOMapper.xml index c2240c1..c2eb4eb 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/PostCommentRelationDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/PostCommentRelationDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostInfoDOMapper.xml b/petplanet-post/src/main/resources/mapper/PostInfoDOMapper.xml similarity index 68% rename from petplanet-sqlServer/src/main/resources/mapper/PostInfoDOMapper.xml rename to petplanet-post/src/main/resources/mapper/PostInfoDOMapper.xml index f46f03a..a8fcf36 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/PostInfoDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/PostInfoDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostPermissionInfoDOMapper.xml b/petplanet-post/src/main/resources/mapper/PostPermissionInfoDOMapper.xml similarity index 65% rename from petplanet-sqlServer/src/main/resources/mapper/PostPermissionInfoDOMapper.xml rename to petplanet-post/src/main/resources/mapper/PostPermissionInfoDOMapper.xml index 6c9f038..0a700ca 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/PostPermissionInfoDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/PostPermissionInfoDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostPetRelationDOMapper.xml b/petplanet-post/src/main/resources/mapper/PostPetRelationDOMapper.xml similarity index 66% rename from petplanet-sqlServer/src/main/resources/mapper/PostPetRelationDOMapper.xml rename to petplanet-post/src/main/resources/mapper/PostPetRelationDOMapper.xml index 19de62c..33690ce 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/PostPetRelationDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/PostPetRelationDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostTagInfoDOMapper.xml b/petplanet-post/src/main/resources/mapper/PostTagInfoDOMapper.xml similarity index 67% rename from petplanet-sqlServer/src/main/resources/mapper/PostTagInfoDOMapper.xml rename to petplanet-post/src/main/resources/mapper/PostTagInfoDOMapper.xml index a04e1f9..67d54f1 100644 --- a/petplanet-sqlServer/src/main/resources/mapper/PostTagInfoDOMapper.xml +++ b/petplanet-post/src/main/resources/mapper/PostTagInfoDOMapper.xml @@ -1,5 +1,5 @@ - + diff --git a/petplanet-sqlServer/.gitignore b/petplanet-sqlServer/.gitignore deleted file mode 100644 index 549e00a..0000000 --- a/petplanet-sqlServer/.gitignore +++ /dev/null @@ -1,33 +0,0 @@ -HELP.md -target/ -!.mvn/wrapper/maven-wrapper.jar -!**/src/main/**/target/ -!**/src/test/**/target/ - -### STS ### -.apt_generated -.classpath -.factorypath -.project -.settings -.springBeans -.sts4-cache - -### IntelliJ IDEA ### -.idea -*.iws -*.iml -*.ipr - -### NetBeans ### -/nbproject/private/ -/nbbuild/ -/dist/ -/nbdist/ -/.nb-gradle/ -build/ -!**/src/main/**/build/ -!**/src/test/**/build/ - -### VS Code ### -.vscode/ diff --git a/petplanet-sqlServer/pom.xml b/petplanet-sqlServer/pom.xml deleted file mode 100644 index 3d71df4..0000000 --- a/petplanet-sqlServer/pom.xml +++ /dev/null @@ -1,78 +0,0 @@ - - - 4.0.0 - - top.zynorl.petplanet - petplanet - 0.0.1-SNAPSHOT - - petplanet-sqlServer - 0.0.1-SNAPSHOT - petplanet-sqlServer - petplanet-sqlServer - - 11 - - - - - org.springframework.boot - spring-boot-starter - - - org.springframework.boot - spring-boot-starter-test - test - - - - mysql - mysql-connector-java - - - - com.baomidou - mybatis-plus-boot-starter - - - log4j - log4j - - - - - - io.springfox - springfox-swagger2 - - - org.mapstruct - mapstruct - - - - - io.springfox - springfox-swagger-ui - - - org.projectlombok - lombok - - - org.springframework.boot - spring-boot-starter-aop - - - - - - - org.springframework.boot - spring-boot-maven-plugin - - - - - diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplication.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplication.java deleted file mode 100644 index aef3d02..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplication.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer; - -import org.mybatis.spring.annotation.MapperScan; -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; -import org.springframework.context.annotation.EnableAspectJAutoProxy; - -@SpringBootApplication -@MapperScan("top.zynorl.petplanet.sqlServer.dao") -public class PetplanetSqlServerApplication { - - public static void main(String[] args) { - SpringApplication.run(PetplanetSqlServerApplication.class, args); - } - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PetInfoDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PetInfoDAO.java deleted file mode 100644 index 43b41db..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PetInfoDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PetInfoDO; - -/** - *

- * 宠物信息表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface PetInfoDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PictureInfoDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PictureInfoDAO.java deleted file mode 100644 index 35fe518..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PictureInfoDAO.java +++ /dev/null @@ -1,18 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PictureInfoDO; - -/** - *

- * 图片信息表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface PictureInfoDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPictureRelationDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPictureRelationDAO.java deleted file mode 100644 index a03b2ed..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/PostPictureRelationDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.PostPictureRelationDO; - -/** - *

- * 帖子与其图片集映射表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface PostPictureRelationDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/TransactionRecordDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/TransactionRecordDAO.java deleted file mode 100644 index 435111b..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/TransactionRecordDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.TransactionRecordDO; - -/** - *

- * 事务记录表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-05 - */ -@Mapper -public interface TransactionRecordDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserBlacklistDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserBlacklistDAO.java deleted file mode 100644 index 4f10f53..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserBlacklistDAO.java +++ /dev/null @@ -1,18 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.UserBlacklistDO; - -/** - *

- * 用户黑名单表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface UserBlacklistDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserCommentRelationDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserCommentRelationDAO.java deleted file mode 100644 index 193116e..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserCommentRelationDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.UserCommentRelationDO; - -/** - *

- * 用户与评论的关联表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface UserCommentRelationDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserFollowerDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserFollowerDAO.java deleted file mode 100644 index 85706e1..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserFollowerDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.UserFollowerDO; - -/** - *

- * 用户粉丝表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface UserFollowerDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserInfoDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserInfoDAO.java deleted file mode 100644 index 0286d14..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserInfoDAO.java +++ /dev/null @@ -1,28 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import org.apache.ibatis.annotations.Param; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserInfoDO; - -import java.util.List; - -/** - *

- * 用户信息表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface UserInfoDAO extends BaseMapper { - - /** - * 根据keyword模糊查询用户名,得到用户信息列表 - */ - List getUserInfoDOListByKeyword(@Param("keyword") String keyword); - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserPostRelationDAO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserPostRelationDAO.java deleted file mode 100644 index 4b9c524..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/dao/UserPostRelationDAO.java +++ /dev/null @@ -1,19 +0,0 @@ -package top.zynorl.petplanet.sqlServer.dao; - - -import com.baomidou.mybatisplus.core.mapper.BaseMapper; -import org.apache.ibatis.annotations.Mapper; -import top.zynorl.petplanet.sqlServer.entity.UserPostRelationDO; - -/** - *

- * 用户与帖子的关联表 Mapper 接口 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Mapper -public interface UserPostRelationDAO extends BaseMapper { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/annotation/DataSourceSwitch.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/annotation/DataSourceSwitch.java deleted file mode 100644 index 5091b5c..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/annotation/DataSourceSwitch.java +++ /dev/null @@ -1,13 +0,0 @@ -package top.zynorl.petplanet.sqlServer.datasource.annotation; - -import java.lang.annotation.*; - -/** - * Created by zynorl on 2024/1/15 13:55 - */ -@Documented -@Retention(RetentionPolicy.RUNTIME) -@Target({ElementType.TYPE, ElementType.METHOD}) -public @interface DataSourceSwitch { - String value() default ""; // 数据源名称或标识符 -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/config/MyBatisConfig.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/config/MyBatisConfig.java deleted file mode 100644 index 388516b..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/config/MyBatisConfig.java +++ /dev/null @@ -1,33 +0,0 @@ -package top.zynorl.petplanet.sqlServer.datasource.config; - -import org.apache.ibatis.session.SqlSessionFactory; -import org.mybatis.spring.SqlSessionFactoryBean; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.core.io.Resource; -import org.springframework.core.io.support.PathMatchingResourcePatternResolver; -import org.springframework.core.io.support.ResourcePatternResolver; - -import javax.sql.DataSource; - -/** - * Created by zynorl on 2024/1/15 15:45 - */ -@Configuration -public class MyBatisConfig { - @Autowired - private DataSource dynamicRoutingDataSource; - - - @Bean - public SqlSessionFactory sqlSessionFactory() throws Exception { - SqlSessionFactoryBean factoryBean = new SqlSessionFactoryBean(); - factoryBean.setDataSource(dynamicRoutingDataSource); - ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver(); - Resource[] mappings = resourcePatternResolver.getResources("classpath:/mapper/*Mapper.xml"); - factoryBean.setMapperLocations(mappings); // 配置Mapping映射路径 - return factoryBean.getObject(); - } - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/context/DataSourceContextHolder.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/context/DataSourceContextHolder.java deleted file mode 100644 index 90a18c0..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/context/DataSourceContextHolder.java +++ /dev/null @@ -1,20 +0,0 @@ -package top.zynorl.petplanet.sqlServer.datasource.context; - -/** - * Created by zynorl on 2024/1/15 14:22 - */ -public class DataSourceContextHolder { - private static final ThreadLocal contextHolder = new ThreadLocal<>(); - - public static void setDataSourceType(String dataSourceType) { - contextHolder.set(dataSourceType); - } - - public static String getDataSourceType() { - return contextHolder.get(); - } - - public static void clearDataSourceType() { - contextHolder.remove(); - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceBeanPostProcessor.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceBeanPostProcessor.java deleted file mode 100644 index 79ce37e..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceBeanPostProcessor.java +++ /dev/null @@ -1,30 +0,0 @@ -package top.zynorl.petplanet.sqlServer.datasource.dynamic; - -import org.springframework.beans.BeansException; -import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.stereotype.Component; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.datasource.context.DataSourceContextHolder; - -/** - * Created by zynorl on 2024/1/16 11:38 - */ -@Component -public class DataSourceBeanPostProcessor implements BeanPostProcessor { - @Override - public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { - Class clazz = bean.getClass(); - DataSourceSwitch classLevelAnnotation = clazz.getAnnotation(DataSourceSwitch.class); - if (classLevelAnnotation != null) { - // 设置类级别的数据源 - String targetDataSource = classLevelAnnotation.value(); - DataSourceContextHolder.setDataSourceType(targetDataSource); - } - return bean; - } - - @Override - public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException { - return bean; - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceConfig.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceConfig.java deleted file mode 100644 index 5a69cda..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/datasource/dynamic/DataSourceConfig.java +++ /dev/null @@ -1,60 +0,0 @@ -package top.zynorl.petplanet.sqlServer.datasource.dynamic; - -import org.springframework.boot.context.properties.ConfigurationProperties; -import org.springframework.boot.jdbc.DataSourceBuilder; -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; -import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource; -import top.zynorl.petplanet.sqlServer.datasource.context.DataSourceContextHolder; - -import javax.sql.DataSource; -import java.util.HashMap; -import java.util.Map; - -/** - * Created by zynorl on 2024/1/15 15:30 - */ -@Configuration -public class DataSourceConfig { - - @Bean(name = "defaultDataSource") - @ConfigurationProperties(prefix = "spring.datasource.db") - public DataSource defaultDataSource() { - return DataSourceBuilder.create().build(); - } - @Bean(name = "userDataSource") - @ConfigurationProperties(prefix = "spring.datasource.db1") - public DataSource userDataSource() { - return DataSourceBuilder.create().build(); - } - - @Bean(name = "postDataSource") - @ConfigurationProperties(prefix = "spring.datasource.db2") - public DataSource postDataSource() { - return DataSourceBuilder.create().build(); - } - - @Bean(name = "petDataSource") - @ConfigurationProperties(prefix = "spring.datasource.db3") - public DataSource petDataSource() { - return DataSourceBuilder.create().build(); - } - - // 实现自定义的RoutingDataSource - @Bean - public DataSource dynamicRoutingDataSource() { - AbstractRoutingDataSource dataSource = new AbstractRoutingDataSource() { - @Override - protected Object determineCurrentLookupKey() { - return DataSourceContextHolder.getDataSourceType(); - } - }; - Map targetDataSources = new HashMap<>(); - targetDataSources.put("userDataSource", userDataSource()); - targetDataSources.put("postDataSource", postDataSource()); - targetDataSources.put("petDataSource", postDataSource()); - dataSource.setTargetDataSources(targetDataSources); - dataSource.setDefaultTargetDataSource(defaultDataSource()); - return dataSource; - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/BaseTransactionalDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/BaseTransactionalDO.java deleted file mode 100644 index dc46811..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/BaseTransactionalDO.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -/** - * @version 1.0 - * @Author niuzy - * @Date 2024/01/09 - **/ -@Data -public class BaseTransactionalDO { - @ApiModelProperty("关联事务uuid") - private String transactionId; -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PetInfoDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PetInfoDO.java deleted file mode 100644 index a0f8c30..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PetInfoDO.java +++ /dev/null @@ -1,62 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 宠物信息表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("pet_info") -@ApiModel(value = "PetInfo对象", description = "宠物信息表") -@Data -@Builder -public class PetInfoDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("主人") - private Long userId; - - private String name; - - @ApiModelProperty("宠物头像,url, 资源服务器") - private String photo; - - @ApiModelProperty("宠物简介") - private String introduction; - - @ApiModelProperty("宠物出生日期") - private LocalDateTime birthday; - - @ApiModelProperty("宠物的状态:1.正常、2.流浪、3.已领养、4.死亡") - private Integer status; - - @ApiModelProperty("宠物死亡时间") - private LocalDateTime deathTime; - - @ApiModelProperty("宠物注册时间") - private LocalDateTime createTime; - - @ApiModelProperty("宠物信息更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PictureInfoDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PictureInfoDO.java deleted file mode 100644 index 4b2fc68..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PictureInfoDO.java +++ /dev/null @@ -1,49 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 图片信息表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("picture_info") -@ApiModel(value = "PictureInfo对象", description = "图片信息表") -@Data -@Builder -public class PictureInfoDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("图片的id") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("图片存放在服务器的位置") - private String url; - - @ApiModelProperty("图片的名称") - private String name; - - @ApiModelProperty("图片的创建时间") - private LocalDateTime createTime; - - @ApiModelProperty("图片信息更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPictureRelationDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPictureRelationDO.java deleted file mode 100644 index 097acda..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/PostPictureRelationDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 帖子与其图片集映射表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("post_picture_relation") -@ApiModel(value = "PostPictureRelation对象", description = "帖子与其图片集映射表") -@Data -@Builder -public class PostPictureRelationDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("帖子的id") - private Long postId; - - @ApiModelProperty("帖子所对应的图片id") - private Long pictureId; - - @ApiModelProperty("创建时间") - private LocalDateTime createTime; - - @ApiModelProperty("更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/TransactionRecordDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/TransactionRecordDO.java deleted file mode 100644 index 8da4858..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/TransactionRecordDO.java +++ /dev/null @@ -1,52 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 事务记录表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-05 - */ -@TableName("transaction_record") -@Builder -@Data -@ApiModel(value = "TransactionRecord对象", description = "事务记录表") -public class TransactionRecordDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @ApiModelProperty("自增主键") - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("事务uuid") - private String transactionId; - - @ApiModelProperty("此次事务涉及到的交易数据") - private String data; - - @ApiModelProperty("事务状态") - private String status; - - @ApiModelProperty("创建时间") - private LocalDateTime createTime; - - @ApiModelProperty("更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("是否删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserBlacklistDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserBlacklistDO.java deleted file mode 100644 index cf256bd..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserBlacklistDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户黑名单表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("user_blacklist") -@ApiModel(value = "UserBlacklist对象", description = "用户黑名单表") -@Data -@Builder -public class UserBlacklistDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("user id") - private Long userId; - - @ApiModelProperty("user id拉黑的人的id") - private Long blackId; - - @ApiModelProperty("关联时间") - private LocalDateTime createTime; - - @ApiModelProperty("更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserCommentRelationDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserCommentRelationDO.java deleted file mode 100644 index 7f97377..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserCommentRelationDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户与评论的关联表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("user_comment_relation") -@ApiModel(value = "UserCommentRelation对象", description = "用户与评论的关联表") -@Data -@Builder -public class UserCommentRelationDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("评论id") - private Long commentId; - - @ApiModelProperty("用户发表评论的时间") - private LocalDateTime createTime; - - @ApiModelProperty("用户更新评论的时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserFollowerDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserFollowerDO.java deleted file mode 100644 index 4e513e3..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserFollowerDO.java +++ /dev/null @@ -1,48 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户粉丝表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("user_follower") -@ApiModel(value = "UserFollower对象", description = "用户粉丝表") -@Data -@Builder -public class UserFollowerDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("user id") - private Long userId; - - @ApiModelProperty("跟随者的id,即粉丝") - private Long followerId; - - @ApiModelProperty("关联时间") - private LocalDateTime createTime; - - @ApiModelProperty("更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserInfoDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserInfoDO.java deleted file mode 100644 index 74eb441..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserInfoDO.java +++ /dev/null @@ -1,70 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.AllArgsConstructor; -import lombok.Builder; -import lombok.Data; -import lombok.NoArgsConstructor; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户信息表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("user_info") -@ApiModel(value = "UserInfo对象", description = "用户信息表") -@Data -@Builder -@AllArgsConstructor -@NoArgsConstructor -public class UserInfoDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - private String username; - - private String phoneNumber; - - private String password; - - @ApiModelProperty("用户权限角色") - private String role; - - @ApiModelProperty("个人简介") - private String introduction; - - @ApiModelProperty("用户邮箱") - private String email; - - @ApiModelProperty("所在省份") - private String address; - - @ApiModelProperty("头像-url-资源服务器") - private String url; - - @ApiModelProperty("出生日期") - private LocalDateTime birthday; - - @ApiModelProperty("用户注册时间") - private LocalDateTime createTime; - - @ApiModelProperty("用户信息更新时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserPostRelationDO.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserPostRelationDO.java deleted file mode 100644 index d93f8df..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/entity/UserPostRelationDO.java +++ /dev/null @@ -1,51 +0,0 @@ -package top.zynorl.petplanet.sqlServer.entity; - -import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableId; -import com.baomidou.mybatisplus.annotation.TableName; -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; -import lombok.Builder; -import lombok.Data; - -import java.io.Serializable; -import java.time.LocalDateTime; - -/** - *

- * 用户与帖子的关联表 - *

- * - * @author zynorl/niuzy - * @since 2024-01-03 - */ -@TableName("user_post_relation") -@ApiModel(value = "UserPostRelation对象", description = "用户与帖子的关联表") -@Data -@Builder -public class UserPostRelationDO extends BaseTransactionalDO implements Serializable { - - private static final long serialVersionUID = 1L; - - @TableId(value = "id", type = IdType.AUTO) - private Long id; - - @ApiModelProperty("用户id") - private Long userId; - - @ApiModelProperty("帖子id") - private Long postId; - - @ApiModelProperty("关联帖子的mongoDB中的Id") - private String postMongoId; - - @ApiModelProperty("用户发布帖子的时间") - private LocalDateTime createTime; - - @ApiModelProperty("用户更新帖子的时间") - private LocalDateTime updateTime; - - @ApiModelProperty("1表示删除,实现逻辑删除") - private Boolean isDelete; - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPetInfoDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPetInfoDBService.java deleted file mode 100644 index 05eefd4..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPetInfoDBService.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PetInfoDO; - -/** - *

- * 宠物信息表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IPetInfoDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPictureInfoDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPictureInfoDBService.java deleted file mode 100644 index e473520..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPictureInfoDBService.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PictureInfoDO; - -/** - *

- * 图片信息表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IPictureInfoDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPictureRelationDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPictureRelationDBService.java deleted file mode 100644 index c8f2079..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IPostPictureRelationDBService.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.PostPictureRelationDO; - -/** - *

- * 帖子与其图片集映射表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IPostPictureRelationDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ITransactionRecordService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ITransactionRecordService.java deleted file mode 100644 index 025e253..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/ITransactionRecordService.java +++ /dev/null @@ -1,21 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.TransactionRecordDO; - -/** - *

- * 事务记录表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-05 - */ -public interface ITransactionRecordService extends IService { - /** - * 根据分布式事务Id,删除记录 - * @param transactionId - */ - void deleteByTransactionId(String transactionId); - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserBlacklistDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserBlacklistDBService.java deleted file mode 100644 index c4ea70c..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserBlacklistDBService.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.UserBlacklistDO; - -/** - *

- * 用户黑名单表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IUserBlacklistDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserCommentRelationDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserCommentRelationDBService.java deleted file mode 100644 index 4c5a535..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserCommentRelationDBService.java +++ /dev/null @@ -1,17 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.UserCommentRelationDO; - -/** - *

- * 用户与评论的关联表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IUserCommentRelationDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserFollowerDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserFollowerDBService.java deleted file mode 100644 index 2eb067f..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserFollowerDBService.java +++ /dev/null @@ -1,16 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.UserFollowerDO; - -/** - *

- * 用户粉丝表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IUserFollowerDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserInfoDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserInfoDBService.java deleted file mode 100644 index 2bd1544..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserInfoDBService.java +++ /dev/null @@ -1,32 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - - -import com.baomidou.mybatisplus.extension.service.IService; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserInfoDO; - -import java.util.List; - -/** - *

- * 用户信息表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IUserInfoDBService extends IService { - - /** - * 根据keyword模糊查询用户名,得到用户信息列表 - */ - @DataSourceSwitch(value = "userDataSource") - List getUserInfoDOListByKeyword(String keyword); - - /** - * 根据username获取用户记录 - */ - UserInfoDO getByUsername(String username); - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserPostRelationDBService.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserPostRelationDBService.java deleted file mode 100644 index 860f236..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/IUserPostRelationDBService.java +++ /dev/null @@ -1,17 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service; - - -import com.baomidou.mybatisplus.extension.service.IService; -import top.zynorl.petplanet.sqlServer.entity.UserPostRelationDO; - -/** - *

- * 用户与帖子的关联表 服务类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -public interface IUserPostRelationDBService extends IService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/CommentInfoDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/CommentInfoDBServiceImpl.java deleted file mode 100644 index 55c7fa4..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/CommentInfoDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.CommentInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.CommentInfoDO; -import top.zynorl.petplanet.sqlServer.service.ICommentInfoDBService; - -/** - *

- * 评论信息表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "postDataSource") -public class CommentInfoDBServiceImpl extends ServiceImpl implements ICommentInfoDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PetInfoDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PetInfoDBServiceImpl.java deleted file mode 100644 index 1c0bb5e..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PetInfoDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PetInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PetInfoDO; -import top.zynorl.petplanet.sqlServer.service.IPetInfoDBService; - -/** - *

- * 宠物信息表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "petDataSource") -public class PetInfoDBServiceImpl extends ServiceImpl implements IPetInfoDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PictureInfoDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PictureInfoDBServiceImpl.java deleted file mode 100644 index 8a12c8a..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PictureInfoDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PictureInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PictureInfoDO; -import top.zynorl.petplanet.sqlServer.service.IPictureInfoDBService; - -/** - *

- * 图片信息表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "postDataSource") -public class PictureInfoDBServiceImpl extends ServiceImpl implements IPictureInfoDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostInfoDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostInfoDBServiceImpl.java deleted file mode 100644 index c89a682..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostInfoDBServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostInfoDO; -import top.zynorl.petplanet.sqlServer.service.IPostInfoDBService; - -/** - *

- * 帖子信息表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "postDataSource") -public class PostInfoDBServiceImpl extends ServiceImpl implements IPostInfoDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPictureRelationDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPictureRelationDBServiceImpl.java deleted file mode 100644 index 2777d29..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/PostPictureRelationDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.PostPictureRelationDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.PostPictureRelationDO; -import top.zynorl.petplanet.sqlServer.service.IPostPictureRelationDBService; - -/** - *

- * 帖子与其图片集映射表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "postDataSource") -public class PostPictureRelationDBServiceImpl extends ServiceImpl implements IPostPictureRelationDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/TransactionRecordServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/TransactionRecordServiceImpl.java deleted file mode 100644 index 7042904..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/TransactionRecordServiceImpl.java +++ /dev/null @@ -1,27 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.TransactionRecordDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.TransactionRecordDO; -import top.zynorl.petplanet.sqlServer.service.ITransactionRecordService; - -/** - *

- * 事务记录表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-05 - */ -@Service -@DataSourceSwitch(value = "postDataSource") -public class TransactionRecordServiceImpl extends ServiceImpl implements ITransactionRecordService { - @Override - public void deleteByTransactionId(String transactionId) { - QueryWrapper queryWrapper = new QueryWrapper().eq("transaction_id", transactionId); - remove(queryWrapper); - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserBlacklistDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserBlacklistDBServiceImpl.java deleted file mode 100644 index 22c9eee..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserBlacklistDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.UserBlacklistDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserBlacklistDO; -import top.zynorl.petplanet.sqlServer.service.IUserBlacklistDBService; - -/** - *

- * 用户黑名单表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "userDataSource") -public class UserBlacklistDBServiceImpl extends ServiceImpl implements IUserBlacklistDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserCommentRelationDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserCommentRelationDBServiceImpl.java deleted file mode 100644 index c4ca99c..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserCommentRelationDBServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.UserCommentRelationDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserCommentRelationDO; -import top.zynorl.petplanet.sqlServer.service.IUserCommentRelationDBService; - -/** - *

- * 用户与评论的关联表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "userDataSource") -public class UserCommentRelationDBServiceImpl extends ServiceImpl implements IUserCommentRelationDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserFollowerDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserFollowerDBServiceImpl.java deleted file mode 100644 index 6eab880..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserFollowerDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.UserFollowerDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserFollowerDO; -import top.zynorl.petplanet.sqlServer.service.IUserFollowerDBService; - -/** - *

- * 用户粉丝表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "userDataSource") -public class UserFollowerDBServiceImpl extends ServiceImpl implements IUserFollowerDBService { - -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserInfoDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserInfoDBServiceImpl.java deleted file mode 100644 index d6c6274..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserInfoDBServiceImpl.java +++ /dev/null @@ -1,39 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.UserInfoDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserInfoDO; -import top.zynorl.petplanet.sqlServer.service.IUserInfoDBService; - -import java.util.List; - -/** - *

- * 用户信息表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "userDataSource") -public class UserInfoDBServiceImpl extends ServiceImpl implements IUserInfoDBService { - @Autowired - private UserInfoDAO userInfoDAO; - @Override - public List getUserInfoDOListByKeyword(String keyword) { - - return userInfoDAO.getUserInfoDOListByKeyword(keyword); - } - - @Override - public UserInfoDO getByUsername(String username) { - QueryWrapper queryWrapper = new QueryWrapper().eq("username", username); - return getOne(queryWrapper); - } -} diff --git a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserPostRelationDBServiceImpl.java b/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserPostRelationDBServiceImpl.java deleted file mode 100644 index eeb8294..0000000 --- a/petplanet-sqlServer/src/main/java/top/zynorl/petplanet/sqlServer/service/impl/UserPostRelationDBServiceImpl.java +++ /dev/null @@ -1,23 +0,0 @@ -package top.zynorl.petplanet.sqlServer.service.impl; - - -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.springframework.stereotype.Service; -import top.zynorl.petplanet.sqlServer.dao.UserPostRelationDAO; -import top.zynorl.petplanet.sqlServer.datasource.annotation.DataSourceSwitch; -import top.zynorl.petplanet.sqlServer.entity.UserPostRelationDO; -import top.zynorl.petplanet.sqlServer.service.IUserPostRelationDBService; - -/** - *

- * 用户与帖子的关联表 服务实现类 - *

- * - * @author zynorl/niuzy - * @since 2024-01-02 - */ -@Service -@DataSourceSwitch(value = "userDataSource") -public class UserPostRelationDBServiceImpl extends ServiceImpl implements IUserPostRelationDBService { - -} diff --git a/petplanet-sqlServer/src/main/resources/application.properties b/petplanet-sqlServer/src/main/resources/application.properties deleted file mode 100644 index 5c469b8..0000000 --- a/petplanet-sqlServer/src/main/resources/application.properties +++ /dev/null @@ -1,19 +0,0 @@ -pring.datasource.db.jdbcUrl=jdbc:mysql://124.220.36.202:3306/petplanet?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai -spring.datasource.db.username=petplanet -spring.datasource.db.password=petplanet -spring.datasource.db.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.datasource.db1.jdbcUrl=jdbc:mysql://124.220.36.202:3306/petplanet-user?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai -spring.datasource.db1.username=petplanet -spring.datasource.db1.password=petplanet -spring.datasource.db1.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.datasource.db2.jdbcUrl=jdbc:mysql://124.220.36.202:3306/petplanet-post?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai -spring.datasource.db2.username=petplanet -spring.datasource.db2.password=petplanet -spring.datasource.db2.driver-class-name=com.mysql.cj.jdbc.Driver - -spring.datasource.db3.jdbcUrl=jdbc:mysql://124.220.36.202:3306/petplanet-pet?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai -spring.datasource.db3.username=petplanet -spring.datasource.db3.password=petplanet -spring.datasource.db3.driver-class-name=com.mysql.cj.jdbc.Driver \ No newline at end of file diff --git a/petplanet-sqlServer/src/main/resources/application.yml b/petplanet-sqlServer/src/main/resources/application.yml deleted file mode 100644 index 90a1965..0000000 --- a/petplanet-sqlServer/src/main/resources/application.yml +++ /dev/null @@ -1,8 +0,0 @@ -server: - port: 7001 - -mybatis-plus: - mapper-locations: classpath:/mapper/*Mapper.xml - global-config: - db-config: - id-type: auto \ No newline at end of file diff --git a/petplanet-sqlServer/src/main/resources/mapper/PetInfoDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/PetInfoDOMapper.xml deleted file mode 100644 index 03734ca..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/PetInfoDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/PictureInfoDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/PictureInfoDOMapper.xml deleted file mode 100644 index d43e5fb..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/PictureInfoDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/PostPictureRelationDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/PostPictureRelationDOMapper.xml deleted file mode 100644 index 056c5f1..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/PostPictureRelationDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/TransactionRecordDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/TransactionRecordDOMapper.xml deleted file mode 100644 index fa64683..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/TransactionRecordDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/UserBlacklistDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/UserBlacklistDOMapper.xml deleted file mode 100644 index b3223ca..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/UserBlacklistDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/UserCommentRelationDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/UserCommentRelationDOMapper.xml deleted file mode 100644 index 6b71c1a..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/UserCommentRelationDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/UserFollowerDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/UserFollowerDOMapper.xml deleted file mode 100644 index 50659a1..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/UserFollowerDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/UserInfoDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/UserInfoDOMapper.xml deleted file mode 100644 index 3ffc71e..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/UserInfoDOMapper.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - id, username, phone_number, password, introduction, email, address, url, birthday, create_time, update_time, is_delete - - - - diff --git a/petplanet-sqlServer/src/main/resources/mapper/UserPostRelationDOMapper.xml b/petplanet-sqlServer/src/main/resources/mapper/UserPostRelationDOMapper.xml deleted file mode 100644 index d80d433..0000000 --- a/petplanet-sqlServer/src/main/resources/mapper/UserPostRelationDOMapper.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - - diff --git a/petplanet-sqlServer/src/test/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplicationTests.java b/petplanet-sqlServer/src/test/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplicationTests.java deleted file mode 100644 index 699157f..0000000 --- a/petplanet-sqlServer/src/test/java/top/zynorl/petplanet/sqlServer/PetplanetSqlServerApplicationTests.java +++ /dev/null @@ -1,36 +0,0 @@ -package top.zynorl.petplanet.sqlServer; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import top.zynorl.petplanet.sqlServer.entity.UserInfoDO; -import top.zynorl.petplanet.sqlServer.service.IUserInfoDBService; - -import java.util.List; - -@SpringBootTest -@RunWith(SpringRunner.class) -public class PetplanetSqlServerApplicationTests { - - @Autowired - private IUserInfoDBService userInfoDBService; - - @Test - public void contextLoads() { - } - @Test - public void testDynamicDataSource(){ - List userInfoDOS = userInfoDBService.getUserInfoDOListByKeyword("zynorl"); - if(userInfoDOS==null || userInfoDOS.isEmpty()){ - System.out.println("没有查询到信息"); - }else { - userInfoDOS.forEach(userInfoDO -> - System.out.println(userInfoDO.getUsername()) - ); - } - } - - -} diff --git a/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostFailedCallbackDTO.java b/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostFailedCallbackDTO.java new file mode 100644 index 0000000..1c82a2e --- /dev/null +++ b/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostFailedCallbackDTO.java @@ -0,0 +1,22 @@ +package top.zynorl.petplanet.user.common.pojo.dto; + +import lombok.Data; + +import java.io.Serializable; + +/** + * Created by zynorl on 2024/1/18 16:14 + */ +@Data +public class PublishPostFailedCallbackDTO implements Serializable { + private static final long serialVersionUID = 1L; + /** + * 帖子id + */ + private String postId; + + /** + * 地点Id + */ + private Long locationId; +} diff --git a/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostTransactionDTO.java b/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostTransactionDTO.java index 8e6e3d0..128a111 100644 --- a/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostTransactionDTO.java +++ b/petplanet-user/src/main/java/top/zynorl/petplanet/user/common/pojo/dto/PublishPostTransactionDTO.java @@ -22,4 +22,9 @@ public class PublishPostTransactionDTO extends BaseTransactionDTO implements Ser * 帖子id */ private String postId; + + /** + * 地点Id + */ + private Long locationId; } diff --git a/petplanet-user/src/main/java/top/zynorl/petplanet/user/listener/MqTransactionListener.java b/petplanet-user/src/main/java/top/zynorl/petplanet/user/listener/MqTransactionListener.java index 6c86213..ec8eb30 100644 --- a/petplanet-user/src/main/java/top/zynorl/petplanet/user/listener/MqTransactionListener.java +++ b/petplanet-user/src/main/java/top/zynorl/petplanet/user/listener/MqTransactionListener.java @@ -3,13 +3,13 @@ import cn.hutool.json.JSONUtil; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.dao.DuplicateKeyException; -import org.springframework.data.redis.core.RedisTemplate; import org.springframework.kafka.annotation.KafkaListener; import org.springframework.kafka.support.Acknowledgment; import org.springframework.stereotype.Component; -import top.zynorl.petplanet.common.enums.TransactionStatusEnum; +import top.zynorl.petplanet.common.exception.RepeatConsumptionException; +import top.zynorl.petplanet.user.common.pojo.dto.PublishPostFailedCallbackDTO; import top.zynorl.petplanet.user.common.pojo.dto.PublishPostTransactionDTO; +import top.zynorl.petplanet.user.sender.TransactionFailedCallbackSender; import top.zynorl.petplanet.user.service.UserPostRelationService; /** @@ -23,31 +23,28 @@ public class MqTransactionListener { @Autowired private UserPostRelationService userPostRelationService; @Autowired - private RedisTemplate redisTemplate; + private TransactionFailedCallbackSender transactionFailedCallbackSender; private static final String postPublishTopic = "post_publish"; @KafkaListener(containerFactory = "manualImmediateListenerContainerFactory", topics = postPublishTopic) public void postPublishListener(String message, Acknowledgment ack) { PublishPostTransactionDTO publishPostTransactionDTO = JSONUtil.toBean(message, PublishPostTransactionDTO.class); - String redisKey = publishPostTransactionDTO.getTopic()+publishPostTransactionDTO.getTransactionId(); - String redisValue = (String)redisTemplate.opsForValue().get(redisKey); - if (redisValue == null) { - String logMeg = String.format("%s未查询到该事务,已经被消费过,或者无该事务", redisKey); - log.warn(logMeg); - throw new DuplicateKeyException("重复消费异常"); - } else if (!TransactionStatusEnum.STARTED.getCode().equals(redisValue)) { - String logMeg = String.format("%s事务状态异常", redisKey); - log.warn(logMeg); - throw new RuntimeException(logMeg); - } + String logKey = postPublishTopic+"_"+publishPostTransactionDTO.getTransactionId(); try { userPostRelationService.saveFromPostPublish(publishPostTransactionDTO); - redisTemplate.delete(redisKey); - log.info(String.format("%s事务执行成功", redisKey)); + log.info(String.format("%s事务执行成功", logKey)); + }catch (RepeatConsumptionException repeatConsumptionException){ + String logMeg = String.format("%s被消费过了,%s", logKey, repeatConsumptionException.getMessage()); + log.warn(logMeg); } catch (Exception e){ // 记录错误信息并触发重试 log.error(e.getMessage()); - redisTemplate.opsForValue().setIfPresent(redisKey, TransactionStatusEnum.FAILED.getCode()); + // 给调用方,发送异常 + PublishPostFailedCallbackDTO publishPostFailedCallbackDTO = new PublishPostFailedCallbackDTO(); + publishPostFailedCallbackDTO.setLocationId(publishPostTransactionDTO.getLocationId()); + publishPostFailedCallbackDTO.setPostId(publishPostTransactionDTO.getPostId()); + String jsonStr = JSONUtil.toJsonStr(publishPostFailedCallbackDTO); + transactionFailedCallbackSender.send(postPublishTopic, publishPostTransactionDTO.getTransactionId() ,jsonStr); // TODO 重试逻辑 如果重试服务决定不再重试,或者重试次数已达到上限,则确认消息 }finally { ack.acknowledge(); diff --git a/petplanet-user/src/main/java/top/zynorl/petplanet/user/sender/TransactionFailedCallbackSender.java b/petplanet-user/src/main/java/top/zynorl/petplanet/user/sender/TransactionFailedCallbackSender.java new file mode 100644 index 0000000..64d4005 --- /dev/null +++ b/petplanet-user/src/main/java/top/zynorl/petplanet/user/sender/TransactionFailedCallbackSender.java @@ -0,0 +1,42 @@ +package top.zynorl.petplanet.user.sender; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.kafka.core.KafkaTemplate; +import org.springframework.kafka.support.SendResult; +import org.springframework.stereotype.Component; +import org.springframework.util.concurrent.ListenableFutureCallback; + +/** + * Created by zynorl on 2024/1/18 15:41 + */ +@Component +@Slf4j +public class TransactionFailedCallbackSender { + @Autowired + private KafkaTemplate kafkaTemplate; + + /** + * + * @param topic + * @param dataJson + */ + public void send(String topic, String transactionId, String dataJson){ + String logKey = topic+"_"+transactionId; + kafkaTemplate.send(topic, dataJson).addCallback(new ListenableFutureCallback<>() { + @Override + public void onFailure(Throwable throwable) { + String msg = String.format("%s发送失败:%s",logKey, throwable.getMessage()); + log.error(msg); + throw new RuntimeException(msg); + } + + @Override + public void onSuccess(SendResult stringObjectSendResult) { + String msg = String.format("%s发送成功",logKey); + log.info(msg); + } + }); + } + +} diff --git a/petplanet-user/src/main/java/top/zynorl/petplanet/user/service/impl/UserPostRelationServiceImpl.java b/petplanet-user/src/main/java/top/zynorl/petplanet/user/service/impl/UserPostRelationServiceImpl.java index 9211a7f..7aafda4 100644 --- a/petplanet-user/src/main/java/top/zynorl/petplanet/user/service/impl/UserPostRelationServiceImpl.java +++ b/petplanet-user/src/main/java/top/zynorl/petplanet/user/service/impl/UserPostRelationServiceImpl.java @@ -1,10 +1,12 @@ package top.zynorl.petplanet.user.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import top.zynorl.petplanet.common.exception.RepeatConsumptionException; import top.zynorl.petplanet.user.common.pojo.dto.PublishPostTransactionDTO; import top.zynorl.petplanet.user.service.UserPostRelationService; import top.zynorl.petplanet.user.sqlServer.entity.UserPostRelationDO; @@ -27,7 +29,14 @@ public class UserPostRelationServiceImpl implements UserPostRelationService { public void saveFromPostPublish(PublishPostTransactionDTO publishPostDTO) { UserPostRelationDO userPostRelationDO = UserPostRelationDO.builder() .postMongoId(publishPostDTO.getPostId()).userId(publishPostDTO.getUserId()).build(); - userPostRelationDBService.save(userPostRelationDO); + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.setEntity(userPostRelationDO); + UserPostRelationDO one = userPostRelationDBService.getOne(queryWrapper); + if(one!=null){ + userPostRelationDBService.save(userPostRelationDO); + }else { + throw new RepeatConsumptionException("重复消费", publishPostDTO.getTransactionId()); + } } } diff --git a/petplanet-user/src/main/resources/application.yml b/petplanet-user/src/main/resources/application.yml index 391d374..430a8b3 100644 --- a/petplanet-user/src/main/resources/application.yml +++ b/petplanet-user/src/main/resources/application.yml @@ -6,6 +6,14 @@ spring: driver-class-name: com.mysql.cj.jdbc.Driver kafka: bootstrap-servers: 121.43.116.232:9092 + producer: + retries: 1 + batch-size: 16384 + buffer-memory: 33554432 + key-serializer: org.apache.kafka.common.serialization.StringSerializer + value-serializer: org.apache.kafka.common.serialization.StringDeserializer + properties: + linger.ms: 100 consumer: group-id: mq-transaction-test auto-offset-reset: earliest diff --git a/pom.xml b/pom.xml index 9f52410..d336a6c 100644 --- a/pom.xml +++ b/pom.xml @@ -24,9 +24,7 @@ petplanet-pet petplanet-post petplanet-user - petplanet-auth petplanet-api - petplanet-sqlServer petplanet-mongoServer