caolinxuan 2 weeks ago
parent
commit
8ff0fb1b46

+ 109 - 0
src/main/java/com/zhentao/moment/domain/MomentComments.java

@@ -0,0 +1,109 @@
+package com.zhentao.moment.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 朋友圈评论表
+ * @TableName moment_comments
+ */
+@TableName(value ="moment_comments")
+@Data
+public class MomentComments implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long commentId;
+
+    /**
+     * 动态ID
+     */
+    private Long momentId;
+
+    /**
+     * 评论用户ID
+     */
+    private Long userId;
+
+    /**
+     * 评论内容
+     */
+    private String content;
+
+    /**
+     * 回复的评论ID
+     */
+    private Long replyTo;
+
+    /**
+     * 回复的用户ID
+     */
+    private Long replyToUser;
+
+    /**
+     * 
+     */
+    private Date createdAt;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        MomentComments other = (MomentComments) that;
+        return (this.getCommentId() == null ? other.getCommentId() == null : this.getCommentId().equals(other.getCommentId()))
+            && (this.getMomentId() == null ? other.getMomentId() == null : this.getMomentId().equals(other.getMomentId()))
+            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
+            && (this.getReplyTo() == null ? other.getReplyTo() == null : this.getReplyTo().equals(other.getReplyTo()))
+            && (this.getReplyToUser() == null ? other.getReplyToUser() == null : this.getReplyToUser().equals(other.getReplyToUser()))
+            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getCommentId() == null) ? 0 : getCommentId().hashCode());
+        result = prime * result + ((getMomentId() == null) ? 0 : getMomentId().hashCode());
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
+        result = prime * result + ((getReplyTo() == null) ? 0 : getReplyTo().hashCode());
+        result = prime * result + ((getReplyToUser() == null) ? 0 : getReplyToUser().hashCode());
+        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", commentId=").append(commentId);
+        sb.append(", momentId=").append(momentId);
+        sb.append(", userId=").append(userId);
+        sb.append(", content=").append(content);
+        sb.append(", replyTo=").append(replyTo);
+        sb.append(", replyToUser=").append(replyToUser);
+        sb.append(", createdAt=").append(createdAt);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 85 - 0
src/main/java/com/zhentao/moment/domain/MomentLikes.java

@@ -0,0 +1,85 @@
+package com.zhentao.moment.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 朋友圈点赞表
+ * @TableName moment_likes
+ */
+@TableName(value ="moment_likes")
+@Data
+public class MomentLikes implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long likeId;
+
+    /**
+     * 动态ID
+     */
+    private Long momentId;
+
+    /**
+     * 点赞用户ID
+     */
+    private Long userId;
+
+    /**
+     * 
+     */
+    private Date createdAt;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        MomentLikes other = (MomentLikes) that;
+        return (this.getLikeId() == null ? other.getLikeId() == null : this.getLikeId().equals(other.getLikeId()))
+            && (this.getMomentId() == null ? other.getMomentId() == null : this.getMomentId().equals(other.getMomentId()))
+            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getLikeId() == null) ? 0 : getLikeId().hashCode());
+        result = prime * result + ((getMomentId() == null) ? 0 : getMomentId().hashCode());
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", likeId=").append(likeId);
+        sb.append(", momentId=").append(momentId);
+        sb.append(", userId=").append(userId);
+        sb.append(", createdAt=").append(createdAt);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 92 - 0
src/main/java/com/zhentao/moment/domain/MomentMedias.java

@@ -0,0 +1,92 @@
+package com.zhentao.moment.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import lombok.Data;
+
+/**
+ * 朋友圈媒体表
+ * @TableName moment_medias
+ */
+@TableName(value ="moment_medias")
+@Data
+public class MomentMedias implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long mediaId;
+
+    /**
+     * 动态ID
+     */
+    private Long momentId;
+
+    /**
+     * 资源URL
+     */
+    private String mediaUrl;
+
+    /**
+     * 类型(1-图片,2-视频)
+     */
+    private Integer mediaType;
+
+    /**
+     * 排序
+     */
+    private Integer sortOrder;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        MomentMedias other = (MomentMedias) that;
+        return (this.getMediaId() == null ? other.getMediaId() == null : this.getMediaId().equals(other.getMediaId()))
+            && (this.getMomentId() == null ? other.getMomentId() == null : this.getMomentId().equals(other.getMomentId()))
+            && (this.getMediaUrl() == null ? other.getMediaUrl() == null : this.getMediaUrl().equals(other.getMediaUrl()))
+            && (this.getMediaType() == null ? other.getMediaType() == null : this.getMediaType().equals(other.getMediaType()))
+            && (this.getSortOrder() == null ? other.getSortOrder() == null : this.getSortOrder().equals(other.getSortOrder()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getMediaId() == null) ? 0 : getMediaId().hashCode());
+        result = prime * result + ((getMomentId() == null) ? 0 : getMomentId().hashCode());
+        result = prime * result + ((getMediaUrl() == null) ? 0 : getMediaUrl().hashCode());
+        result = prime * result + ((getMediaType() == null) ? 0 : getMediaType().hashCode());
+        result = prime * result + ((getSortOrder() == null) ? 0 : getSortOrder().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", mediaId=").append(mediaId);
+        sb.append(", momentId=").append(momentId);
+        sb.append(", mediaUrl=").append(mediaUrl);
+        sb.append(", mediaType=").append(mediaType);
+        sb.append(", sortOrder=").append(sortOrder);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 117 - 0
src/main/java/com/zhentao/moment/domain/UserMoments.java

@@ -0,0 +1,117 @@
+package com.zhentao.moment.domain;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.io.Serializable;
+import java.util.Date;
+import lombok.Data;
+
+/**
+ * 朋友圈动态表
+ * @TableName user_moments
+ */
+@TableName(value ="user_moments")
+@Data
+public class UserMoments implements Serializable {
+    /**
+     * 
+     */
+    @TableId(type = IdType.AUTO)
+    private Long momentId;
+
+    /**
+     * 发布者ID
+     */
+    private Long userId;
+
+    /**
+     * 动态内容
+     */
+    private String content;
+
+    /**
+     * 内容类型(1-文本,2-图片,3-视频)
+     */
+    private Integer contentType;
+
+    /**
+     * 可见性(0-公开,1-仅好友,2-私密)
+     */
+    private Integer visibility;
+
+    /**
+     * 位置信息
+     */
+    private String location;
+
+    /**
+     * 
+     */
+    private Date createdAt;
+
+    /**
+     * 
+     */
+    private Date updatedAt;
+
+    @TableField(exist = false)
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public boolean equals(Object that) {
+        if (this == that) {
+            return true;
+        }
+        if (that == null) {
+            return false;
+        }
+        if (getClass() != that.getClass()) {
+            return false;
+        }
+        UserMoments other = (UserMoments) that;
+        return (this.getMomentId() == null ? other.getMomentId() == null : this.getMomentId().equals(other.getMomentId()))
+            && (this.getUserId() == null ? other.getUserId() == null : this.getUserId().equals(other.getUserId()))
+            && (this.getContent() == null ? other.getContent() == null : this.getContent().equals(other.getContent()))
+            && (this.getContentType() == null ? other.getContentType() == null : this.getContentType().equals(other.getContentType()))
+            && (this.getVisibility() == null ? other.getVisibility() == null : this.getVisibility().equals(other.getVisibility()))
+            && (this.getLocation() == null ? other.getLocation() == null : this.getLocation().equals(other.getLocation()))
+            && (this.getCreatedAt() == null ? other.getCreatedAt() == null : this.getCreatedAt().equals(other.getCreatedAt()))
+            && (this.getUpdatedAt() == null ? other.getUpdatedAt() == null : this.getUpdatedAt().equals(other.getUpdatedAt()));
+    }
+
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = 1;
+        result = prime * result + ((getMomentId() == null) ? 0 : getMomentId().hashCode());
+        result = prime * result + ((getUserId() == null) ? 0 : getUserId().hashCode());
+        result = prime * result + ((getContent() == null) ? 0 : getContent().hashCode());
+        result = prime * result + ((getContentType() == null) ? 0 : getContentType().hashCode());
+        result = prime * result + ((getVisibility() == null) ? 0 : getVisibility().hashCode());
+        result = prime * result + ((getLocation() == null) ? 0 : getLocation().hashCode());
+        result = prime * result + ((getCreatedAt() == null) ? 0 : getCreatedAt().hashCode());
+        result = prime * result + ((getUpdatedAt() == null) ? 0 : getUpdatedAt().hashCode());
+        return result;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", momentId=").append(momentId);
+        sb.append(", userId=").append(userId);
+        sb.append(", content=").append(content);
+        sb.append(", contentType=").append(contentType);
+        sb.append(", visibility=").append(visibility);
+        sb.append(", location=").append(location);
+        sb.append(", createdAt=").append(createdAt);
+        sb.append(", updatedAt=").append(updatedAt);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 18 - 0
src/main/java/com/zhentao/moment/mapper/MomentCommentsMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.moment.mapper;
+
+import com.zhentao.moment.domain.MomentComments;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 86159
+* @description 针对表【moment_comments(朋友圈评论表)】的数据库操作Mapper
+* @createDate 2025-06-04 11:56:59
+* @Entity com.zhentao.moment.domain.MomentComments
+*/
+public interface MomentCommentsMapper extends BaseMapper<MomentComments> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/moment/mapper/MomentLikesMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.moment.mapper;
+
+import com.zhentao.moment.domain.MomentLikes;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 86159
+* @description 针对表【moment_likes(朋友圈点赞表)】的数据库操作Mapper
+* @createDate 2025-06-04 11:56:59
+* @Entity com.zhentao.moment.domain.MomentLikes
+*/
+public interface MomentLikesMapper extends BaseMapper<MomentLikes> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/moment/mapper/MomentMediasMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.moment.mapper;
+
+import com.zhentao.moment.domain.MomentMedias;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 86159
+* @description 针对表【moment_medias(朋友圈媒体表)】的数据库操作Mapper
+* @createDate 2025-06-04 11:56:59
+* @Entity com.zhentao.moment.domain.MomentMedias
+*/
+public interface MomentMediasMapper extends BaseMapper<MomentMedias> {
+
+}
+
+
+
+

+ 18 - 0
src/main/java/com/zhentao/moment/mapper/UserMomentsMapper.java

@@ -0,0 +1,18 @@
+package com.zhentao.moment.mapper;
+
+import com.zhentao.moment.domain.UserMoments;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author 86159
+* @description 针对表【user_moments(朋友圈动态表)】的数据库操作Mapper
+* @createDate 2025-06-04 11:56:59
+* @Entity com.zhentao.moment.domain.UserMoments
+*/
+public interface UserMomentsMapper extends BaseMapper<UserMoments> {
+
+}
+
+
+
+

+ 13 - 0
src/main/java/com/zhentao/moment/service/MomentCommentsService.java

@@ -0,0 +1,13 @@
+package com.zhentao.moment.service;
+
+import com.zhentao.moment.domain.MomentComments;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author 86159
+* @description 针对表【moment_comments(朋友圈评论表)】的数据库操作Service
+* @createDate 2025-06-04 11:56:59
+*/
+public interface MomentCommentsService extends IService<MomentComments> {
+
+}

+ 13 - 0
src/main/java/com/zhentao/moment/service/MomentLikesService.java

@@ -0,0 +1,13 @@
+package com.zhentao.moment.service;
+
+import com.zhentao.moment.domain.MomentLikes;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author 86159
+* @description 针对表【moment_likes(朋友圈点赞表)】的数据库操作Service
+* @createDate 2025-06-04 11:56:59
+*/
+public interface MomentLikesService extends IService<MomentLikes> {
+
+}

+ 13 - 0
src/main/java/com/zhentao/moment/service/MomentMediasService.java

@@ -0,0 +1,13 @@
+package com.zhentao.moment.service;
+
+import com.zhentao.moment.domain.MomentMedias;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author 86159
+* @description 针对表【moment_medias(朋友圈媒体表)】的数据库操作Service
+* @createDate 2025-06-04 11:56:59
+*/
+public interface MomentMediasService extends IService<MomentMedias> {
+
+}

+ 18 - 0
src/main/java/com/zhentao/moment/service/UserMomentsService.java

@@ -0,0 +1,18 @@
+package com.zhentao.moment.service;
+
+import com.zhentao.moment.domain.UserMoments;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.zhentao.moment.dto.MonmentDto;
+import com.zhentao.vo.Result;
+
+/**
+* @author 86159
+* @description 针对表【user_moments(朋友圈动态表)】的数据库操作Service
+* @createDate 2025-06-04 11:56:59
+*/
+public interface UserMomentsService extends IService<UserMoments> {
+//  发布朋友圈
+    Result sendMonment(String  token,MonmentDto monmentDto);
+//  删除朋友圈
+//    Result deleteMonment(MonmentDto monmentDto);
+}

+ 22 - 0
src/main/java/com/zhentao/moment/service/impl/MomentCommentsServiceImpl.java

@@ -0,0 +1,22 @@
+package com.zhentao.moment.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.moment.domain.MomentComments;
+import com.zhentao.moment.service.MomentCommentsService;
+import com.zhentao.moment.mapper.MomentCommentsMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 86159
+* @description 针对表【moment_comments(朋友圈评论表)】的数据库操作Service实现
+* @createDate 2025-06-04 11:56:59
+*/
+@Service
+public class MomentCommentsServiceImpl extends ServiceImpl<MomentCommentsMapper, MomentComments>
+    implements MomentCommentsService{
+
+}
+
+
+
+

+ 22 - 0
src/main/java/com/zhentao/moment/service/impl/MomentLikesServiceImpl.java

@@ -0,0 +1,22 @@
+package com.zhentao.moment.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.moment.domain.MomentLikes;
+import com.zhentao.moment.service.MomentLikesService;
+import com.zhentao.moment.mapper.MomentLikesMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 86159
+* @description 针对表【moment_likes(朋友圈点赞表)】的数据库操作Service实现
+* @createDate 2025-06-04 11:56:59
+*/
+@Service
+public class MomentLikesServiceImpl extends ServiceImpl<MomentLikesMapper, MomentLikes>
+    implements MomentLikesService{
+
+}
+
+
+
+

+ 22 - 0
src/main/java/com/zhentao/moment/service/impl/MomentMediasServiceImpl.java

@@ -0,0 +1,22 @@
+package com.zhentao.moment.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.moment.domain.MomentMedias;
+import com.zhentao.moment.service.MomentMediasService;
+import com.zhentao.moment.mapper.MomentMediasMapper;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 86159
+* @description 针对表【moment_medias(朋友圈媒体表)】的数据库操作Service实现
+* @createDate 2025-06-04 11:56:59
+*/
+@Service
+public class MomentMediasServiceImpl extends ServiceImpl<MomentMediasMapper, MomentMedias>
+    implements MomentMediasService{
+
+}
+
+
+
+

+ 95 - 0
src/main/java/com/zhentao/moment/service/impl/UserMomentsServiceImpl.java

@@ -0,0 +1,95 @@
+package com.zhentao.moment.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.zhentao.moment.domain.UserMoments;
+import com.zhentao.moment.dto.MonmentDto;
+import com.zhentao.moment.enums.ContentTypeEnum;
+import com.zhentao.moment.service.UserMomentsService;
+import com.zhentao.moment.mapper.UserMomentsMapper;
+import com.zhentao.tool.TokenUtils;
+import com.zhentao.utils.SensitiveWordFilter;
+import com.zhentao.utils.SnowflakeUtil;
+import com.zhentao.vo.Result;
+import io.jsonwebtoken.Claims;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+* @author 86159
+* @description 针对表【user_moments(朋友圈动态表)】的数据库操作Service实现
+* @createDate 2025-06-04 11:56:59
+*/
+@Service
+public class UserMomentsServiceImpl extends ServiceImpl<UserMomentsMapper, UserMoments>
+    implements UserMomentsService{
+    @Autowired
+    private UserMomentsMapper userMomentsMapper;
+    @Override
+    public Result sendMonment(String token,MonmentDto monmentDto) {
+        if (monmentDto.getContent()==null){
+            return Result.error(400,"请输入内容");
+        }
+        if (monmentDto.getContentType()==null){
+            return Result.error(400,"内容类型不能为空");
+        }
+        try {
+            UserMoments userMoments=new UserMoments();
+            userMoments.setMomentId(SnowflakeUtil.nextId());
+            String userId = TokenUtils.getUserIdFromToken(token);
+            userMoments.setUserId(Long.valueOf(userId));
+            Integer typeCode = monmentDto.getContentType();
+            ContentTypeEnum type = ContentTypeEnum.getByCode(typeCode);
+            switch (type){
+                case TEXT:
+                    String filter = SensitiveWordFilter.filter(monmentDto.getContent());
+                    userMoments.setContent(filter);
+                    break;
+                case IMAGE:
+                    validateImageContent(monmentDto.getContent());
+//                    userMoments.setContentType(ContentTypeEnum.IMAGE.getCode());
+                    break;
+                case VIDEO:
+                    validateVideoContent(monmentDto.getContent());
+//                    userMoments.setContentType(ContentTypeEnum.VIDEO.getCode());
+                    break;
+                default:
+                    return Result.error(400,"内容类型错误");
+            }
+////            userMoments.setContentType();
+//            userMoments.setContent(monmentDto.getContent());
+            userMomentsMapper.insert(userMoments);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.OK(null,"发送成功");
+    }
+
+//    @Override
+//    public Result deleteMonment(MonmentDto monmentDto) {
+//
+//
+//    }
+
+    // 图片内容校验
+    private void validateImageContent(String content) {
+        // content 存图片 URL 列表,用逗号分隔
+        String[] imageUrls = content.split(",");
+        for (String url : imageUrls) {
+            if (!url.matches("^https?://.*\\.(png|jpg|jpeg)$")) {
+                throw new IllegalArgumentException("图片 URL 格式错误: " + url);
+            }
+        }
+    }
+
+    // 视频内容校验
+    private void validateVideoContent(String content) {
+        //  content 存视频 URL
+        if (!content.matches("^https?://.*\\.(mp4|avi)$")) {
+            throw new IllegalArgumentException("视频 URL 格式错误: " + content);
+        }
+    }
+}
+
+
+
+

+ 22 - 0
src/main/resources/mapper/MomentCommentsMapper.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.moment.mapper.MomentCommentsMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.moment.domain.MomentComments">
+            <id property="commentId" column="comment_id" jdbcType="BIGINT"/>
+            <result property="momentId" column="moment_id" jdbcType="BIGINT"/>
+            <result property="userId" column="user_id" jdbcType="BIGINT"/>
+            <result property="content" column="content" jdbcType="VARCHAR"/>
+            <result property="replyTo" column="reply_to" jdbcType="BIGINT"/>
+            <result property="replyToUser" column="reply_to_user" jdbcType="BIGINT"/>
+            <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        comment_id,moment_id,user_id,
+        content,reply_to,reply_to_user,
+        created_at
+    </sql>
+</mapper>

+ 18 - 0
src/main/resources/mapper/MomentLikesMapper.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.moment.mapper.MomentLikesMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.moment.domain.MomentLikes">
+            <id property="likeId" column="like_id" jdbcType="BIGINT"/>
+            <result property="momentId" column="moment_id" jdbcType="BIGINT"/>
+            <result property="userId" column="user_id" jdbcType="BIGINT"/>
+            <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        like_id,moment_id,user_id,
+        created_at
+    </sql>
+</mapper>

+ 19 - 0
src/main/resources/mapper/MomentMediasMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.moment.mapper.MomentMediasMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.moment.domain.MomentMedias">
+            <id property="mediaId" column="media_id" jdbcType="BIGINT"/>
+            <result property="momentId" column="moment_id" jdbcType="BIGINT"/>
+            <result property="mediaUrl" column="media_url" jdbcType="VARCHAR"/>
+            <result property="mediaType" column="media_type" jdbcType="TINYINT"/>
+            <result property="sortOrder" column="sort_order" jdbcType="INTEGER"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        media_id,moment_id,media_url,
+        media_type,sort_order
+    </sql>
+</mapper>

+ 23 - 0
src/main/resources/mapper/UserMomentsMapper.xml

@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.zhentao.moment.mapper.UserMomentsMapper">
+
+    <resultMap id="BaseResultMap" type="com.zhentao.moment.domain.UserMoments">
+            <id property="momentId" column="moment_id" jdbcType="BIGINT"/>
+            <result property="userId" column="user_id" jdbcType="BIGINT"/>
+            <result property="content" column="content" jdbcType="VARCHAR"/>
+            <result property="contentType" column="content_type" jdbcType="TINYINT"/>
+            <result property="visibility" column="visibility" jdbcType="TINYINT"/>
+            <result property="location" column="location" jdbcType="VARCHAR"/>
+            <result property="createdAt" column="created_at" jdbcType="TIMESTAMP"/>
+            <result property="updatedAt" column="updated_at" jdbcType="TIMESTAMP"/>
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        moment_id,user_id,content,
+        content_type,visibility,location,
+        created_at,updated_at
+    </sql>
+</mapper>