50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
package com.emotionmuseum.mapper;
|
|
|
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.emotionmuseum.entity.DiaryPost;
|
|
import org.apache.ibatis.annotations.Mapper;
|
|
import org.apache.ibatis.annotations.Param;
|
|
import org.apache.ibatis.annotations.Select;
|
|
|
|
/**
|
|
* 日记Mapper接口
|
|
*
|
|
* @author emotion-museum
|
|
* @version 1.0.0
|
|
* @since 2024-01-01
|
|
*/
|
|
@Mapper
|
|
public interface DiaryPostMapper extends BaseMapper<DiaryPost> {
|
|
|
|
/**
|
|
* 分页查询用户的日记
|
|
*/
|
|
@Select("SELECT * FROM diary_post WHERE user_id = #{userId} AND deleted = 0 ORDER BY create_time DESC")
|
|
IPage<DiaryPost> selectUserDiaries(Page<DiaryPost> page, @Param("userId") String userId);
|
|
|
|
/**
|
|
* 分页查询公开的日记
|
|
*/
|
|
@Select("SELECT * FROM diary_post WHERE is_public = 1 AND status = 1 AND deleted = 0 ORDER BY create_time DESC")
|
|
IPage<DiaryPost> selectPublicDiaries(Page<DiaryPost> page);
|
|
|
|
/**
|
|
* 根据情绪标签查询日记
|
|
*/
|
|
@Select("SELECT * FROM diary_post WHERE emotion_tags LIKE CONCAT('%', #{emotionTag}, '%') AND is_public = 1 AND status = 1 AND deleted = 0 ORDER BY create_time DESC")
|
|
IPage<DiaryPost> selectDiariesByEmotionTag(Page<DiaryPost> page, @Param("emotionTag") String emotionTag);
|
|
|
|
/**
|
|
* 统计用户的日记数量
|
|
*/
|
|
@Select("SELECT COUNT(*) FROM diary_post WHERE user_id = #{userId} AND deleted = 0")
|
|
int countByUserId(@Param("userId") String userId);
|
|
|
|
/**
|
|
* 统计公开日记数量
|
|
*/
|
|
@Select("SELECT COUNT(*) FROM diary_post WHERE is_public = 1 AND status = 1 AND deleted = 0")
|
|
int countPublicDiaries();
|
|
} |