serv-mapper和.xml 基本增删改
This commit is contained in:
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 成就数据访问层
|
||||
* @description AchievementMapper.java文件描述 成就数据访问层
|
||||
* @filename AchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,115 @@ public interface AchievementMapper extends BaseMapper<TbAchievement> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievements(TbAchievement filter);
|
||||
|
||||
/**
|
||||
* @description 根据成就ID查询成就信息
|
||||
* @param achievementId 成就ID
|
||||
* @return TbAchievement 成就信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbAchievement selectByAchievementId(@Param("achievementId") String achievementId);
|
||||
|
||||
/**
|
||||
* @description 根据类型查询成就列表
|
||||
* @param type 成就类型
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectByType(@Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* @description 根据类型和等级查询成就列表
|
||||
* @param type 成就类型
|
||||
* @param level 成就等级
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectByTypeAndLevel(@Param("type") Integer type, @Param("level") Integer level);
|
||||
|
||||
/**
|
||||
* @description 查询成就排行榜
|
||||
* @param limit 限制数量
|
||||
* @return List<TbAchievement> 成就排行榜
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievementRanking(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* @description 检查成就名称是否存在
|
||||
* @param name 成就名称
|
||||
* @param excludeId 排除的成就ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int countByName(@Param("name") String name, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 插入成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 更新成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 删除成就
|
||||
* @param achievement 成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteAchievement(TbAchievement achievement);
|
||||
|
||||
/**
|
||||
* @description 批量插入成就
|
||||
* @param achievementList 成就列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertAchievements(@Param("achievementList") List<TbAchievement> achievementList);
|
||||
|
||||
/**
|
||||
* @description 批量删除成就
|
||||
* @param ids 成就ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteAchievements(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询成就
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbAchievement> selectAchievementsPage(@Param("filter") TbAchievement filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计成就总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countAchievements(@Param("filter") TbAchievement filter);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbPointsRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 积分记录数据访问层
|
||||
* @description PointsRecordMapper.java文件描述 积分记录数据访问层
|
||||
* @filename PointsRecordMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,105 @@ public interface PointsRecordMapper extends BaseMapper<TbPointsRecord> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbPointsRecord> selectPointsRecords(TbPointsRecord filter);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询积分记录
|
||||
* @param userId 用户ID
|
||||
* @return List<TbPointsRecord> 积分记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbPointsRecord> selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和类型查询积分记录
|
||||
* @param userId 用户ID
|
||||
* @param type 积分类型
|
||||
* @return List<TbPointsRecord> 积分记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbPointsRecord> selectByUserIdAndType(@Param("userId") String userId, @Param("type") Integer type);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询积分记录(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return List<TbPointsRecord> 积分记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbPointsRecord> selectPointsRecordsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询用户积分统计
|
||||
* @param userId 用户ID
|
||||
* @return TbPointsRecord 积分统计信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbPointsRecord selectPointsStatistics(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 插入积分记录
|
||||
* @param pointsRecord 积分记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertPointsRecord(TbPointsRecord pointsRecord);
|
||||
|
||||
/**
|
||||
* @description 更新积分记录
|
||||
* @param pointsRecord 积分记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updatePointsRecord(TbPointsRecord pointsRecord);
|
||||
|
||||
/**
|
||||
* @description 删除积分记录
|
||||
* @param pointsRecord 积分记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deletePointsRecord(TbPointsRecord pointsRecord);
|
||||
|
||||
/**
|
||||
* @description 批量插入积分记录
|
||||
* @param pointsRecordList 积分记录列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertPointsRecords(@Param("pointsRecordList") List<TbPointsRecord> pointsRecordList);
|
||||
|
||||
/**
|
||||
* @description 批量删除积分记录
|
||||
* @param ids 记录ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeletePointsRecords(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询积分记录
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbPointsRecord> 积分记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbPointsRecord> selectPointsRecordsPage(@Param("filter") TbPointsRecord filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计积分记录总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countPointsRecords(@Param("filter") TbPointsRecord filter);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 用户成就数据访问层
|
||||
* @description UserAchievementMapper.java文件描述 用户成就数据访问层
|
||||
* @filename UserAchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,105 @@ public interface UserAchievementMapper extends BaseMapper<TbUserAchievement> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievements(TbUserAchievement filter);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询成就记录
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和成就ID查询成就记录
|
||||
* @param userId 用户ID
|
||||
* @param achievementId 成就ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectByUserIdAndAchievementId(@Param("userId") String userId, @Param("achievementId") String achievementId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询成就记录(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserAchievement> 成就记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievementsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询用户成就统计
|
||||
* @param userId 用户ID
|
||||
* @return TbUserAchievement 成就统计信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserAchievement selectAchievementStatistics(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 插入用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 更新用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 删除用户成就
|
||||
* @param userAchievement 用户成就
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteUserAchievement(TbUserAchievement userAchievement);
|
||||
|
||||
/**
|
||||
* @description 批量插入用户成就
|
||||
* @param userAchievementList 用户成就列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertUserAchievements(@Param("userAchievementList") List<TbUserAchievement> userAchievementList);
|
||||
|
||||
/**
|
||||
* @description 批量删除用户成就
|
||||
* @param ids 成就ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteUserAchievements(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询用户成就
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbUserAchievement> 用户成就列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserAchievement> selectUserAchievementsPage(@Param("filter") TbUserAchievement filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计用户成就总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countUserAchievements(@Param("filter") TbUserAchievement filter);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbUserBrowseRecord;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 用户浏览记录数据访问层
|
||||
* @description UserBrowseRecordMapper.java文件描述 用户浏览记录数据访问层
|
||||
* @filename UserBrowseRecordMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,105 @@ public interface UserBrowseRecordMapper extends BaseMapper<TbUserBrowseRecord> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserBrowseRecord> selectUserBrowseRecords(TbUserBrowseRecord filter);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询浏览记录
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserBrowseRecord> 浏览记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserBrowseRecord> selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和类型查询浏览记录
|
||||
* @param userId 用户ID
|
||||
* @param browseType 浏览类型
|
||||
* @return List<TbUserBrowseRecord> 浏览记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserBrowseRecord> selectByUserIdAndType(@Param("userId") String userId, @Param("browseType") Integer browseType);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询浏览记录(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserBrowseRecord> 浏览记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserBrowseRecord> selectUserBrowseRecordsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询用户浏览统计
|
||||
* @param userId 用户ID
|
||||
* @return TbUserBrowseRecord 浏览统计信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserBrowseRecord selectBrowseStatistics(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 插入用户浏览记录
|
||||
* @param userBrowseRecord 用户浏览记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertUserBrowseRecord(TbUserBrowseRecord userBrowseRecord);
|
||||
|
||||
/**
|
||||
* @description 更新用户浏览记录
|
||||
* @param userBrowseRecord 用户浏览记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateUserBrowseRecord(TbUserBrowseRecord userBrowseRecord);
|
||||
|
||||
/**
|
||||
* @description 删除用户浏览记录
|
||||
* @param userBrowseRecord 用户浏览记录
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteUserBrowseRecord(TbUserBrowseRecord userBrowseRecord);
|
||||
|
||||
/**
|
||||
* @description 批量插入用户浏览记录
|
||||
* @param userBrowseRecordList 用户浏览记录列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertUserBrowseRecords(@Param("userBrowseRecordList") List<TbUserBrowseRecord> userBrowseRecordList);
|
||||
|
||||
/**
|
||||
* @description 批量删除用户浏览记录
|
||||
* @param ids 记录ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteUserBrowseRecords(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询用户浏览记录
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbUserBrowseRecord> 用户浏览记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserBrowseRecord> selectUserBrowseRecordsPage(@Param("filter") TbUserBrowseRecord filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计用户浏览记录总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countUserBrowseRecords(@Param("filter") TbUserBrowseRecord filter);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 用户收藏数据访问层
|
||||
* @description UserCollectionMapper.java文件描述 用户收藏数据访问层
|
||||
* @filename UserCollectionMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,105 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectUserCollections(TbUserCollection filter);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询收藏记录
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserCollection> 收藏记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和类型查询收藏记录
|
||||
* @param userId 用户ID
|
||||
* @param collectionType 收藏类型
|
||||
* @return List<TbUserCollection> 收藏记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectByUserIdAndType(@Param("userId") String userId, @Param("collectionType") Integer collectionType);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询收藏记录(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return List<TbUserCollection> 收藏记录列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectUserCollectionsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询用户收藏统计
|
||||
* @param userId 用户ID
|
||||
* @return TbUserCollection 收藏统计信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserCollection selectCollectionStatistics(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 插入用户收藏
|
||||
* @param userCollection 用户收藏
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertUserCollection(TbUserCollection userCollection);
|
||||
|
||||
/**
|
||||
* @description 更新用户收藏
|
||||
* @param userCollection 用户收藏
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateUserCollection(TbUserCollection userCollection);
|
||||
|
||||
/**
|
||||
* @description 删除用户收藏
|
||||
* @param userCollection 用户收藏
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteUserCollection(TbUserCollection userCollection);
|
||||
|
||||
/**
|
||||
* @description 批量插入用户收藏
|
||||
* @param userCollectionList 用户收藏列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertUserCollections(@Param("userCollectionList") List<TbUserCollection> userCollectionList);
|
||||
|
||||
/**
|
||||
* @description 批量删除用户收藏
|
||||
* @param ids 收藏ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteUserCollections(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询用户收藏
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbUserCollection> 用户收藏列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectUserCollectionsPage(@Param("filter") TbUserCollection filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计用户收藏总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countUserCollections(@Param("filter") TbUserCollection filter);
|
||||
}
|
||||
|
||||
@@ -2,12 +2,14 @@ package org.xyzh.usercenter.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.xyzh.common.core.page.PageParam;
|
||||
import org.xyzh.common.dto.usercenter.TbUserPoints;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @description 用户积分数据访问层
|
||||
* @description UserPointsMapper.java文件描述 用户积分数据访问层
|
||||
* @filename UserPointsMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
@@ -24,4 +26,105 @@ public interface UserPointsMapper extends BaseMapper<TbUserPoints> {
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserPoints> selectUserPoints(TbUserPoints filter);
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询积分信息
|
||||
* @param userId 用户ID
|
||||
* @return TbUserPoints 用户积分信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserPoints selectByUserId(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 检查用户积分是否存在
|
||||
* @param userId 用户ID
|
||||
* @param excludeId 排除的积分ID(用于更新时排除自身)
|
||||
* @return int 存在的数量
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int countByUserId(@Param("userId") String userId, @Param("excludeId") String excludeId);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询积分信息(包含用户基本信息)
|
||||
* @param userId 用户ID
|
||||
* @return TbUserPoints 用户积分信息
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserPoints selectUserPointsWithUser(@Param("userId") String userId);
|
||||
|
||||
/**
|
||||
* @description 查询积分排行榜
|
||||
* @param limit 限制数量
|
||||
* @return List<TbUserPoints> 积分排行榜
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserPoints> selectPointsRanking(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* @description 插入用户积分
|
||||
* @param userPoints 用户积分
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int insertUserPoints(TbUserPoints userPoints);
|
||||
|
||||
/**
|
||||
* @description 更新用户积分
|
||||
* @param userPoints 用户积分
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int updateUserPoints(TbUserPoints userPoints);
|
||||
|
||||
/**
|
||||
* @description 删除用户积分
|
||||
* @param userPoints 用户积分
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int deleteUserPoints(TbUserPoints userPoints);
|
||||
|
||||
/**
|
||||
* @description 批量插入用户积分
|
||||
* @param userPointsList 用户积分列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchInsertUserPoints(@Param("userPointsList") List<TbUserPoints> userPointsList);
|
||||
|
||||
/**
|
||||
* @description 批量删除用户积分
|
||||
* @param ids 积分ID列表
|
||||
* @return int 影响行数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
int batchDeleteUserPoints(@Param("ids") List<String> ids);
|
||||
|
||||
/**
|
||||
* @description 分页查询用户积分
|
||||
* @param filter 过滤条件
|
||||
* @param pageParam 分页参数
|
||||
* @return List<TbUserPoints> 用户积分列表
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserPoints> selectUserPointsPage(@Param("filter") TbUserPoints filter, @Param("pageParam") PageParam pageParam);
|
||||
|
||||
/**
|
||||
* @description 统计用户积分总数
|
||||
* @param filter 过滤条件
|
||||
* @return long 总数
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
long countUserPoints(@Param("filter") TbUserPoints filter);
|
||||
}
|
||||
@@ -2,63 +2,462 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.AchievementMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="achievement_id" property="achievementID" jdbcType="VARCHAR"/>
|
||||
<result column="name" property="name" jdbcType="VARCHAR"/>
|
||||
<result column="description" property="description" jdbcType="VARCHAR"/>
|
||||
<result column="icon" property="icon" jdbcType="VARCHAR"/>
|
||||
<result column="type" property="type" jdbcType="INTEGER"/>
|
||||
<result column="level" property="level" jdbcType="INTEGER"/>
|
||||
<result column="condition_type" property="conditionType" jdbcType="INTEGER"/>
|
||||
<result column="condition_value" property="conditionValue" jdbcType="INTEGER"/>
|
||||
<result column="points" property="points" jdbcType="INTEGER"/>
|
||||
<result column="order_num" property="orderNum" jdbcType="INTEGER"/>
|
||||
<result column="creator" property="creator" jdbcType="VARCHAR"/>
|
||||
<result column="updater" property="updater" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="delete_time" property="deleteTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="deleted" property="deleted" jdbcType="BOOLEAN"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="achievement_id" property="achievementId" />
|
||||
<result column="name" property="name" />
|
||||
<result column="description" property="description" />
|
||||
<result column="icon" property="icon" />
|
||||
<result column="type" property="type" />
|
||||
<result column="level" property="level" />
|
||||
<result column="condition_type" property="conditionType" />
|
||||
<result column="condition_value" property="conditionValue" />
|
||||
<result column="points" property="points" />
|
||||
<result column="order_num" property="orderNum" />
|
||||
<result column="creator" property="creator" />
|
||||
<result column="updater" property="updater" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
<result column="delete_time" property="deleteTime" />
|
||||
<result column="deleted" property="deleted" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time,
|
||||
update_time, delete_time, deleted
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
deleted = 0
|
||||
<if test="achievementID != null and achievementID != ''">
|
||||
AND achievement_id = #{achievementID}
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="type != null">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
<if test="level != null">
|
||||
AND level = #{level}
|
||||
</if>
|
||||
<if test="conditionType != null">
|
||||
AND condition_type = #{conditionType}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.achievementId != null and filter.achievementId != ''">
|
||||
AND achievement_id = #{filter.achievementId}
|
||||
</if>
|
||||
<if test="filter.name != null and filter.name != ''">
|
||||
AND name LIKE CONCAT('%', #{filter.name}, '%')
|
||||
</if>
|
||||
<if test="filter.type != null">
|
||||
AND type = #{filter.type}
|
||||
</if>
|
||||
<if test="filter.level != null">
|
||||
AND level = #{filter.level}
|
||||
</if>
|
||||
<if test="filter.conditionType != null">
|
||||
AND condition_type = #{filter.conditionType}
|
||||
</if>
|
||||
<if test="filter.points != null">
|
||||
AND points = #{filter.points}
|
||||
</if>
|
||||
<if test="filter.creator != null and filter.creator != ''">
|
||||
AND creator = #{filter.creator}
|
||||
</if>
|
||||
<if test="filter.deleted != null">
|
||||
AND deleted = #{filter.deleted}
|
||||
</if>
|
||||
<if test="filter.createTime != null">
|
||||
AND create_time = #{filter.createTime}
|
||||
</if>
|
||||
<if test="filter.updateTime != null">
|
||||
AND update_time = #{filter.updateTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectAchievements -->
|
||||
<select id="selectAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectByIdCustom" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY order_num ASC, create_time ASC
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOneCustom" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.achievementId}, #{entity.name}, #{entity.description}, #{entity.icon},
|
||||
#{entity.type}, #{entity.level}, #{entity.conditionType}, #{entity.conditionValue},
|
||||
#{entity.points}, #{entity.orderNum}, #{entity.creator}, #{entity.updater},
|
||||
#{entity.createTime}, #{entity.updateTime}, #{entity.deleteTime}, #{entity.deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.achievementId}, #{entity.name}, #{entity.description}, #{entity.icon},
|
||||
#{entity.type}, #{entity.level}, #{entity.conditionType}, #{entity.conditionValue},
|
||||
#{entity.points}, #{entity.orderNum}, #{entity.creator}, #{entity.updater},
|
||||
#{entity.createTime}, #{entity.updateTime}, #{entity.deleteTime}, #{entity.deleted}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateByIdCustom" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.name != null and entity.name != ''">
|
||||
name = #{entity.name},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
<if test="entity.icon != null and entity.icon != ''">
|
||||
icon = #{entity.icon},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.level != null">
|
||||
level = #{entity.level},
|
||||
</if>
|
||||
<if test="entity.conditionType != null">
|
||||
condition_type = #{entity.conditionType},
|
||||
</if>
|
||||
<if test="entity.conditionValue != null">
|
||||
condition_value = #{entity.conditionValue},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.orderNum != null">
|
||||
order_num = #{entity.orderNum},
|
||||
</if>
|
||||
<if test="entity.creator != null and entity.creator != ''">
|
||||
creator = #{entity.creator},
|
||||
</if>
|
||||
<if test="entity.updater != null and entity.updater != ''">
|
||||
updater = #{entity.updater},
|
||||
</if>
|
||||
<if test="entity.updateTime != null">
|
||||
update_time = #{entity.updateTime},
|
||||
</if>
|
||||
<if test="entity.deleteTime != null">
|
||||
delete_time = #{entity.deleteTime},
|
||||
</if>
|
||||
<if test="entity.deleted != null">
|
||||
deleted = #{entity.deleted},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.name != null and entity.name != ''">
|
||||
name = #{entity.name},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
<if test="entity.icon != null and entity.icon != ''">
|
||||
icon = #{entity.icon},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.level != null">
|
||||
level = #{entity.level},
|
||||
</if>
|
||||
<if test="entity.conditionType != null">
|
||||
condition_type = #{entity.conditionType},
|
||||
</if>
|
||||
<if test="entity.conditionValue != null">
|
||||
condition_value = #{entity.conditionValue},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.orderNum != null">
|
||||
order_num = #{entity.orderNum},
|
||||
</if>
|
||||
<if test="entity.creator != null and entity.creator != ''">
|
||||
creator = #{entity.creator},
|
||||
</if>
|
||||
<if test="entity.updater != null and entity.updater != ''">
|
||||
updater = #{entity.updater},
|
||||
</if>
|
||||
<if test="entity.updateTime != null">
|
||||
update_time = #{entity.updateTime},
|
||||
</if>
|
||||
<if test="entity.deleteTime != null">
|
||||
delete_time = #{entity.deleteTime},
|
||||
</if>
|
||||
<if test="entity.deleted != null">
|
||||
deleted = #{entity.deleted},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询成就列表 -->
|
||||
<select id="selectAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据成就ID查询成就信息 -->
|
||||
<select id="selectByAchievementId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE achievement_id = #{achievementId}
|
||||
</select>
|
||||
|
||||
<!-- 根据类型查询成就列表 -->
|
||||
<select id="selectByType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE type = #{type}
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据类型和等级查询成就列表 -->
|
||||
<select id="selectByTypeAndLevel" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE type = #{type} AND level = #{level}
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询成就排行榜 -->
|
||||
<select id="selectAchievementRanking" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE deleted = 0
|
||||
ORDER BY points DESC, level DESC, order_num ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 检查成就名称是否存在 -->
|
||||
<select id="countByName" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
WHERE name = #{name} AND deleted = 0
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入成就 -->
|
||||
<insert id="insertAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES (
|
||||
#{id}, #{achievementId}, #{name}, #{description}, #{icon}, #{type}, #{level},
|
||||
#{conditionType}, #{conditionValue}, #{points}, #{orderNum}, #{creator}, #{updater},
|
||||
#{createTime}, #{updateTime}, #{deleteTime}, #{deleted}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新成就 -->
|
||||
<update id="updateAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
UPDATE tb_achievement
|
||||
<set>
|
||||
<if test="achievementId != null and achievementId != ''">
|
||||
achievement_id = #{achievementId},
|
||||
</if>
|
||||
<if test="name != null and name != ''">
|
||||
name = #{name},
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description},
|
||||
</if>
|
||||
<if test="icon != null and icon != ''">
|
||||
icon = #{icon},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
level = #{level},
|
||||
</if>
|
||||
<if test="conditionType != null">
|
||||
condition_type = #{conditionType},
|
||||
</if>
|
||||
<if test="conditionValue != null">
|
||||
condition_value = #{conditionValue},
|
||||
</if>
|
||||
<if test="points != null">
|
||||
points = #{points},
|
||||
</if>
|
||||
<if test="orderNum != null">
|
||||
order_num = #{orderNum},
|
||||
</if>
|
||||
<if test="creator != null and creator != ''">
|
||||
creator = #{creator},
|
||||
</if>
|
||||
<if test="updater != null and updater != ''">
|
||||
updater = #{updater},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
<if test="deleteTime != null">
|
||||
delete_time = #{deleteTime},
|
||||
</if>
|
||||
<if test="deleted != null">
|
||||
deleted = #{deleted},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除成就 -->
|
||||
<delete id="deleteAchievement" parameterType="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
DELETE FROM tb_achievement
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入成就 -->
|
||||
<insert id="batchInsertAchievements" parameterType="java.util.List">
|
||||
INSERT INTO tb_achievement (
|
||||
id, achievement_id, name, description, icon, type, level, condition_type,
|
||||
condition_value, points, order_num, creator, updater, create_time, update_time,
|
||||
delete_time, deleted
|
||||
) VALUES
|
||||
<foreach collection="achievementList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.achievementId}, #{item.name}, #{item.description}, #{item.icon},
|
||||
#{item.type}, #{item.level}, #{item.conditionType}, #{item.conditionValue},
|
||||
#{item.points}, #{item.orderNum}, #{item.creator}, #{item.updater},
|
||||
#{item.createTime}, #{item.updateTime}, #{item.deleteTime}, #{item.deleted}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除成就 -->
|
||||
<delete id="batchDeleteAchievements">
|
||||
DELETE FROM tb_achievement
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询成就 -->
|
||||
<select id="selectAchievementsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY order_num ASC, create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计成就总数 -->
|
||||
<select id="countAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,48 +2,339 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.PointsRecordMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="points" property="points" jdbcType="INTEGER"/>
|
||||
<result column="type" property="type" jdbcType="INTEGER"/>
|
||||
<result column="source_type" property="sourceType" jdbcType="INTEGER"/>
|
||||
<result column="source_id" property="sourceID" jdbcType="VARCHAR"/>
|
||||
<result column="description" property="description" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="points" property="points" />
|
||||
<result column="type" property="type" />
|
||||
<result column="source_type" property="sourceType" />
|
||||
<result column="source_id" property="sourceId" />
|
||||
<result column="description" property="description" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, points, type, source_type, source_id, description, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="type != null">
|
||||
AND type = #{type}
|
||||
</if>
|
||||
<if test="sourceType != null">
|
||||
AND source_type = #{sourceType}
|
||||
</if>
|
||||
<if test="sourceID != null and sourceID != ''">
|
||||
AND source_id = #{sourceID}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.points != null">
|
||||
AND points = #{filter.points}
|
||||
</if>
|
||||
<if test="filter.type != null">
|
||||
AND type = #{filter.type}
|
||||
</if>
|
||||
<if test="filter.sourceType != null">
|
||||
AND source_type = #{filter.sourceType}
|
||||
</if>
|
||||
<if test="filter.sourceId != null and filter.sourceId != ''">
|
||||
AND source_id = #{filter.sourceId}
|
||||
</if>
|
||||
<if test="filter.description != null and filter.description != ''">
|
||||
AND description LIKE CONCAT('%', #{filter.description}, '%')
|
||||
</if>
|
||||
<if test="filter.createTime != null">
|
||||
AND create_time = #{filter.createTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectPointsRecords -->
|
||||
<select id="selectPointsRecords" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Where_Clause"/>
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOne" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
INSERT INTO tb_points_record (
|
||||
id, user_id, points, type, source_type, source_id, description, create_time
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.userId}, #{entity.points}, #{entity.type},
|
||||
#{entity.sourceType}, #{entity.sourceId}, #{entity.description}, #{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_points_record (
|
||||
id, user_id, points, type, source_type, source_id, description, create_time
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.points}, #{entity.type},
|
||||
#{entity.sourceType}, #{entity.sourceId}, #{entity.description}, #{entity.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
UPDATE tb_points_record
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.sourceType != null">
|
||||
source_type = #{entity.sourceType},
|
||||
</if>
|
||||
<if test="entity.sourceId != null and entity.sourceId != ''">
|
||||
source_id = #{entity.sourceId},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
UPDATE tb_points_record
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.points != null">
|
||||
points = #{entity.points},
|
||||
</if>
|
||||
<if test="entity.type != null">
|
||||
type = #{entity.type},
|
||||
</if>
|
||||
<if test="entity.sourceType != null">
|
||||
source_type = #{entity.sourceType},
|
||||
</if>
|
||||
<if test="entity.sourceId != null and entity.sourceId != ''">
|
||||
source_id = #{entity.sourceId},
|
||||
</if>
|
||||
<if test="entity.description != null and entity.description != ''">
|
||||
description = #{entity.description},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询积分记录列表 -->
|
||||
<select id="selectPointsRecords" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询积分记录 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据用户ID和类型查询积分记录 -->
|
||||
<select id="selectByUserIdAndType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
WHERE user_id = #{userId} AND type = #{type}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询积分记录(包含用户基本信息) -->
|
||||
<select id="selectPointsRecordsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
pr.id, pr.user_id, pr.points, pr.type, pr.source_type, pr.source_id,
|
||||
pr.description, pr.create_time
|
||||
FROM tb_points_record pr
|
||||
LEFT JOIN tb_sys_user u ON pr.user_id = u.id
|
||||
WHERE pr.user_id = #{userId}
|
||||
ORDER BY pr.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询用户积分统计 -->
|
||||
<select id="selectPointsStatistics" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
user_id,
|
||||
SUM(points) as points,
|
||||
COUNT(*) as type,
|
||||
MAX(create_time) as create_time
|
||||
FROM tb_points_record
|
||||
WHERE user_id = #{userId}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<!-- 插入积分记录 -->
|
||||
<insert id="insertPointsRecord" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
INSERT INTO tb_points_record (
|
||||
id, user_id, points, type, source_type, source_id, description, create_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{points}, #{type}, #{sourceType}, #{sourceId},
|
||||
#{description}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新积分记录 -->
|
||||
<update id="updatePointsRecord" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
UPDATE tb_points_record
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="points != null">
|
||||
points = #{points},
|
||||
</if>
|
||||
<if test="type != null">
|
||||
type = #{type},
|
||||
</if>
|
||||
<if test="sourceType != null">
|
||||
source_type = #{sourceType},
|
||||
</if>
|
||||
<if test="sourceId != null and sourceId != ''">
|
||||
source_id = #{sourceId},
|
||||
</if>
|
||||
<if test="description != null and description != ''">
|
||||
description = #{description},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除积分记录 -->
|
||||
<delete id="deletePointsRecord" parameterType="org.xyzh.common.dto.usercenter.TbPointsRecord">
|
||||
DELETE FROM tb_points_record
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入积分记录 -->
|
||||
<insert id="batchInsertPointsRecords" parameterType="java.util.List">
|
||||
INSERT INTO tb_points_record (
|
||||
id, user_id, points, type, source_type, source_id, description, create_time
|
||||
) VALUES
|
||||
<foreach collection="pointsRecordList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.points}, #{item.type},
|
||||
#{item.sourceType}, #{item.sourceId}, #{item.description}, #{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除积分记录 -->
|
||||
<delete id="batchDeletePointsRecords">
|
||||
DELETE FROM tb_points_record
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询积分记录 -->
|
||||
<select id="selectPointsRecordsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计积分记录总数 -->
|
||||
<select id="countPointsRecords" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_points_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,38 +2,290 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.UserAchievementMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="achievement_id" property="achievementID" jdbcType="VARCHAR"/>
|
||||
<result column="obtain_time" property="obtainTime" jdbcType="TIMESTAMP"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="achievement_id" property="achievementId" />
|
||||
<result column="obtain_time" property="obtainTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, achievement_id, obtain_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="achievementID != null and achievementID != ''">
|
||||
AND achievement_id = #{achievementID}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.achievementId != null and filter.achievementId != ''">
|
||||
AND achievement_id = #{filter.achievementId}
|
||||
</if>
|
||||
<if test="filter.obtainTime != null">
|
||||
AND obtain_time = #{filter.obtainTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectUserAchievements -->
|
||||
<select id="selectUserAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Where_Clause"/>
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOne" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.userId}, #{entity.achievementId}, #{entity.obtainTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.achievementId}, #{entity.obtainTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.obtainTime != null">
|
||||
obtain_time = #{entity.obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.achievementId != null and entity.achievementId != ''">
|
||||
achievement_id = #{entity.achievementId},
|
||||
</if>
|
||||
<if test="entity.obtainTime != null">
|
||||
obtain_time = #{entity.obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询用户成就列表 -->
|
||||
<select id="selectUserAchievements" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询成就记录 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY obtain_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据用户ID和成就ID查询成就记录 -->
|
||||
<select id="selectByUserIdAndAchievementId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId} AND achievement_id = #{achievementId}
|
||||
ORDER BY obtain_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询成就记录(包含用户基本信息) -->
|
||||
<select id="selectUserAchievementsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
ua.id, ua.user_id, ua.achievement_id, ua.obtain_time
|
||||
FROM tb_user_achievement ua
|
||||
LEFT JOIN tb_sys_user u ON ua.user_id = u.id
|
||||
WHERE ua.user_id = #{userId}
|
||||
ORDER BY ua.obtain_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询用户成就统计 -->
|
||||
<select id="selectAchievementStatistics" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
user_id,
|
||||
COUNT(*) as achievement_id,
|
||||
MAX(obtain_time) as obtain_time
|
||||
FROM tb_user_achievement
|
||||
WHERE user_id = #{userId}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<!-- 插入用户成就 -->
|
||||
<insert id="insertUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{achievementId}, #{obtainTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户成就 -->
|
||||
<update id="updateUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
UPDATE tb_user_achievement
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="achievementId != null and achievementId != ''">
|
||||
achievement_id = #{achievementId},
|
||||
</if>
|
||||
<if test="obtainTime != null">
|
||||
obtain_time = #{obtainTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户成就 -->
|
||||
<delete id="deleteUserAchievement" parameterType="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
DELETE FROM tb_user_achievement
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户成就 -->
|
||||
<insert id="batchInsertUserAchievements" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_achievement (
|
||||
id, user_id, achievement_id, obtain_time
|
||||
) VALUES
|
||||
<foreach collection="userAchievementList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.achievementId}, #{item.obtainTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除用户成就 -->
|
||||
<delete id="batchDeleteUserAchievements">
|
||||
DELETE FROM tb_user_achievement
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询用户成就 -->
|
||||
<select id="selectUserAchievementsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY obtain_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户成就总数 -->
|
||||
<select id="countUserAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,46 +2,319 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.UserBrowseRecordMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="browse_type" property="browseType" jdbcType="INTEGER"/>
|
||||
<result column="browse_id" property="browseID" jdbcType="VARCHAR"/>
|
||||
<result column="browse_time" property="browseTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="ip_address" property="ipAddress" jdbcType="VARCHAR"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="browse_type" property="browseType" />
|
||||
<result column="browse_id" property="browseId" />
|
||||
<result column="browse_time" property="browseTime" />
|
||||
<result column="ip_address" property="ipAddress" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, browse_type, browse_id, browse_time, ip_address
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="browseType != null">
|
||||
AND browse_type = #{browseType}
|
||||
</if>
|
||||
<if test="browseID != null and browseID != ''">
|
||||
AND browse_id = #{browseID}
|
||||
</if>
|
||||
<if test="ipAddress != null and ipAddress != ''">
|
||||
AND ip_address = #{ipAddress}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.browseType != null">
|
||||
AND browse_type = #{filter.browseType}
|
||||
</if>
|
||||
<if test="filter.browseId != null and filter.browseId != ''">
|
||||
AND browse_id = #{filter.browseId}
|
||||
</if>
|
||||
<if test="filter.ipAddress != null and filter.ipAddress != ''">
|
||||
AND ip_address = #{filter.ipAddress}
|
||||
</if>
|
||||
<if test="filter.browseTime != null">
|
||||
AND browse_time = #{filter.browseTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectUserBrowseRecords -->
|
||||
<select id="selectUserBrowseRecords" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Where_Clause"/>
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOne" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
INSERT INTO tb_user_browse_record (
|
||||
id, user_id, browse_type, browse_id, browse_time, ip_address
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.userId}, #{entity.browseType}, #{entity.browseId},
|
||||
#{entity.browseTime}, #{entity.ipAddress}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_browse_record (
|
||||
id, user_id, browse_type, browse_id, browse_time, ip_address
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.browseType}, #{entity.browseId},
|
||||
#{entity.browseTime}, #{entity.ipAddress}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
UPDATE tb_user_browse_record
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.browseType != null">
|
||||
browse_type = #{entity.browseType},
|
||||
</if>
|
||||
<if test="entity.browseId != null and entity.browseId != ''">
|
||||
browse_id = #{entity.browseId},
|
||||
</if>
|
||||
<if test="entity.browseTime != null">
|
||||
browse_time = #{entity.browseTime},
|
||||
</if>
|
||||
<if test="entity.ipAddress != null and entity.ipAddress != ''">
|
||||
ip_address = #{entity.ipAddress},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
UPDATE tb_user_browse_record
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.browseType != null">
|
||||
browse_type = #{entity.browseType},
|
||||
</if>
|
||||
<if test="entity.browseId != null and entity.browseId != ''">
|
||||
browse_id = #{entity.browseId},
|
||||
</if>
|
||||
<if test="entity.browseTime != null">
|
||||
browse_time = #{entity.browseTime},
|
||||
</if>
|
||||
<if test="entity.ipAddress != null and entity.ipAddress != ''">
|
||||
ip_address = #{entity.ipAddress},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询用户浏览记录列表 -->
|
||||
<select id="selectUserBrowseRecords" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询浏览记录 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY browse_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据用户ID和类型查询浏览记录 -->
|
||||
<select id="selectByUserIdAndType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
WHERE user_id = #{userId} AND browse_type = #{browseType}
|
||||
ORDER BY browse_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询浏览记录(包含用户基本信息) -->
|
||||
<select id="selectUserBrowseRecordsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
ubr.id, ubr.user_id, ubr.browse_type, ubr.browse_id, ubr.browse_time, ubr.ip_address
|
||||
FROM tb_user_browse_record ubr
|
||||
LEFT JOIN tb_sys_user u ON ubr.user_id = u.id
|
||||
WHERE ubr.user_id = #{userId}
|
||||
ORDER BY ubr.browse_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询用户浏览统计 -->
|
||||
<select id="selectBrowseStatistics" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
user_id,
|
||||
COUNT(*) as browse_type,
|
||||
MAX(browse_time) as browse_time
|
||||
FROM tb_user_browse_record
|
||||
WHERE user_id = #{userId}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<!-- 插入用户浏览记录 -->
|
||||
<insert id="insertUserBrowseRecord" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
INSERT INTO tb_user_browse_record (
|
||||
id, user_id, browse_type, browse_id, browse_time, ip_address
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{browseType}, #{browseId}, #{browseTime}, #{ipAddress}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户浏览记录 -->
|
||||
<update id="updateUserBrowseRecord" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
UPDATE tb_user_browse_record
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="browseType != null">
|
||||
browse_type = #{browseType},
|
||||
</if>
|
||||
<if test="browseId != null and browseId != ''">
|
||||
browse_id = #{browseId},
|
||||
</if>
|
||||
<if test="browseTime != null">
|
||||
browse_time = #{browseTime},
|
||||
</if>
|
||||
<if test="ipAddress != null and ipAddress != ''">
|
||||
ip_address = #{ipAddress},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户浏览记录 -->
|
||||
<delete id="deleteUserBrowseRecord" parameterType="org.xyzh.common.dto.usercenter.TbUserBrowseRecord">
|
||||
DELETE FROM tb_user_browse_record
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户浏览记录 -->
|
||||
<insert id="batchInsertUserBrowseRecords" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_browse_record (
|
||||
id, user_id, browse_type, browse_id, browse_time, ip_address
|
||||
) VALUES
|
||||
<foreach collection="userBrowseRecordList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.browseType}, #{item.browseId},
|
||||
#{item.browseTime}, #{item.ipAddress}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除用户浏览记录 -->
|
||||
<delete id="batchDeleteUserBrowseRecords">
|
||||
DELETE FROM tb_user_browse_record
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询用户浏览记录 -->
|
||||
<select id="selectUserBrowseRecordsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY browse_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户浏览记录总数 -->
|
||||
<select id="countUserBrowseRecords" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_browse_record
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,42 +2,294 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.UserCollectionMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="collection_type" property="collectionType" jdbcType="INTEGER"/>
|
||||
<result column="collection_id" property="collectionID" jdbcType="VARCHAR"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="collection_type" property="collectionType" />
|
||||
<result column="collection_id" property="collectionId" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="collectionType != null">
|
||||
AND collection_type = #{collectionType}
|
||||
</if>
|
||||
<if test="collectionID != null and collectionID != ''">
|
||||
AND collection_id = #{collectionID}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.collectionType != null">
|
||||
AND collection_type = #{filter.collectionType}
|
||||
</if>
|
||||
<if test="filter.collectionId != null and filter.collectionId != ''">
|
||||
AND collection_id = #{filter.collectionId}
|
||||
</if>
|
||||
<if test="filter.createTime != null">
|
||||
AND create_time = #{filter.createTime}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectUserCollections -->
|
||||
<select id="selectUserCollections" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Where_Clause"/>
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<select id="selectOne" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询列表 -->
|
||||
<select id="selectList" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询 -->
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询记录(支持排序) -->
|
||||
<select id="selectListWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据条件分页查询(支持排序) -->
|
||||
<select id="selectPageWithOrder" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
<if test="orderBy != null and orderBy != ''">
|
||||
ORDER BY ${orderBy}
|
||||
<if test="orderDirection != null and orderDirection != ''">
|
||||
${orderDirection}
|
||||
</if>
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入单条记录 -->
|
||||
<insert id="insertOne" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
INSERT INTO tb_user_collection (
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
) VALUES (
|
||||
#{entity.id}, #{entity.userId}, #{entity.collectionType}, #{entity.collectionId}, #{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 批量插入记录 -->
|
||||
<insert id="batchInsert" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_collection (
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.collectionType}, #{entity.collectionId}, #{entity.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 根据ID更新记录 -->
|
||||
<update id="updateById" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
UPDATE tb_user_collection
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.collectionType != null">
|
||||
collection_type = #{entity.collectionType},
|
||||
</if>
|
||||
<if test="entity.collectionId != null and entity.collectionId != ''">
|
||||
collection_id = #{entity.collectionId},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
</update>
|
||||
|
||||
<!-- 根据条件更新记录 -->
|
||||
<update id="updateByFilter" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
UPDATE tb_user_collection
|
||||
<set>
|
||||
<if test="entity.userId != null and entity.userId != ''">
|
||||
user_id = #{entity.userId},
|
||||
</if>
|
||||
<if test="entity.collectionType != null">
|
||||
collection_type = #{entity.collectionType},
|
||||
</if>
|
||||
<if test="entity.collectionId != null and entity.collectionId != ''">
|
||||
collection_id = #{entity.collectionId},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
</update>
|
||||
|
||||
<!-- 删除方法使用MyBatis-Plus的BaseMapper提供的方法 -->
|
||||
<!-- deleteById(Serializable id) - 根据ID删除 -->
|
||||
<!-- deleteBatchIds(Collection<? extends Serializable> idList) - 批量删除 -->
|
||||
<!-- deleteByMap(Map<String, Object> columnMap) - 根据Map删除 -->
|
||||
<!-- delete(Wrapper<T> queryWrapper) - 根据条件删除 -->
|
||||
|
||||
<!-- 根据条件统计记录数 -->
|
||||
<select id="countByFilter" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 检查记录是否存在 -->
|
||||
<select id="existsByFilter" resultType="boolean">
|
||||
SELECT COUNT(1) > 0
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 查询用户收藏列表 -->
|
||||
<select id="selectUserCollections" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询收藏记录 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据用户ID和类型查询收藏记录 -->
|
||||
<select id="selectByUserIdAndType" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId} AND collection_type = #{collectionType}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询收藏记录(包含用户基本信息) -->
|
||||
<select id="selectUserCollectionsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
uc.id, uc.user_id, uc.collection_type, uc.collection_id, uc.create_time
|
||||
FROM tb_user_collection uc
|
||||
LEFT JOIN tb_sys_user u ON uc.user_id = u.id
|
||||
WHERE uc.user_id = #{userId}
|
||||
ORDER BY uc.create_time DESC
|
||||
</select>
|
||||
|
||||
<!-- 查询用户收藏统计 -->
|
||||
<select id="selectCollectionStatistics" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
user_id,
|
||||
COUNT(*) as collection_type,
|
||||
MAX(create_time) as create_time
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
<!-- 插入用户收藏 -->
|
||||
<insert id="insertUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
INSERT INTO tb_user_collection (
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{collectionType}, #{collectionId}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户收藏 -->
|
||||
<update id="updateUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
UPDATE tb_user_collection
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="collectionType != null">
|
||||
collection_type = #{collectionType},
|
||||
</if>
|
||||
<if test="collectionId != null and collectionId != ''">
|
||||
collection_id = #{collectionId},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户收藏 -->
|
||||
<delete id="deleteUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
DELETE FROM tb_user_collection
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户收藏 -->
|
||||
<insert id="batchInsertUserCollections" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_collection (
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
) VALUES
|
||||
<foreach collection="userCollectionList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.collectionType}, #{item.collectionId}, #{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除用户收藏 -->
|
||||
<delete id="batchDeleteUserCollections">
|
||||
DELETE FROM tb_user_collection
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询用户收藏 -->
|
||||
<select id="selectUserCollectionsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户收藏总数 -->
|
||||
<select id="countUserCollections" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_collection
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -2,41 +2,168 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.UserPointsMapper">
|
||||
|
||||
<!-- 基础结果映射 -->
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserPoints">
|
||||
<id column="id" property="id" jdbcType="VARCHAR"/>
|
||||
<result column="user_id" property="userID" jdbcType="VARCHAR"/>
|
||||
<result column="total_points" property="totalPoints" jdbcType="INTEGER"/>
|
||||
<result column="current_points" property="currentPoints" jdbcType="INTEGER"/>
|
||||
<result column="level" property="level" jdbcType="INTEGER"/>
|
||||
<result column="create_time" property="createTime" jdbcType="TIMESTAMP"/>
|
||||
<result column="update_time" property="updateTime" jdbcType="TIMESTAMP"/>
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="total_points" property="totalPoints" />
|
||||
<result column="current_points" property="currentPoints" />
|
||||
<result column="level" property="level" />
|
||||
<result column="create_time" property="createTime" />
|
||||
<result column="update_time" property="updateTime" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 基础字段 -->
|
||||
<!-- 字段列表 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, user_id, total_points, current_points, level, create_time, update_time
|
||||
</sql>
|
||||
|
||||
<!-- 通用条件 -->
|
||||
<sql id="Where_Clause">
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<if test="userID != null and userID != ''">
|
||||
AND user_id = #{userID}
|
||||
</if>
|
||||
<if test="level != null">
|
||||
AND level = #{level}
|
||||
<if test="filter != null">
|
||||
<if test="filter.id != null and filter.id != ''">
|
||||
AND id = #{filter.id}
|
||||
</if>
|
||||
<if test="filter.userId != null and filter.userId != ''">
|
||||
AND user_id = #{filter.userId}
|
||||
</if>
|
||||
<if test="filter.totalPoints != null">
|
||||
AND total_points = #{filter.totalPoints}
|
||||
</if>
|
||||
<if test="filter.currentPoints != null">
|
||||
AND current_points = #{filter.currentPoints}
|
||||
</if>
|
||||
<if test="filter.level != null">
|
||||
AND level = #{filter.level}
|
||||
</if>
|
||||
</if>
|
||||
</where>
|
||||
</sql>
|
||||
|
||||
<!-- selectUserPoints -->
|
||||
<!-- 查询用户积分列表 -->
|
||||
<select id="selectUserPoints" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List"/>
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_points
|
||||
<include refid="Where_Clause"/>
|
||||
ORDER BY level DESC, current_points DESC
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
<!-- 根据用户ID查询积分信息 -->
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_points
|
||||
WHERE user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 检查用户积分是否存在 -->
|
||||
<select id="countByUserId" resultType="int">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_points
|
||||
WHERE user_id = #{userId}
|
||||
<if test="excludeId != null and excludeId != ''">
|
||||
AND id != #{excludeId}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 根据用户ID查询积分信息(包含用户基本信息) -->
|
||||
<select id="selectUserPointsWithUser" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
up.id, up.user_id, up.total_points, up.current_points, up.level,
|
||||
up.create_time, up.update_time
|
||||
FROM tb_user_points up
|
||||
LEFT JOIN tb_sys_user u ON up.user_id = u.id
|
||||
WHERE up.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<!-- 查询积分排行榜 -->
|
||||
<select id="selectPointsRanking" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_points
|
||||
ORDER BY current_points DESC, total_points DESC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 插入用户积分 -->
|
||||
<insert id="insertUserPoints" parameterType="org.xyzh.common.dto.usercenter.TbUserPoints">
|
||||
INSERT INTO tb_user_points (
|
||||
id, user_id, total_points, current_points, level, create_time, update_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{totalPoints}, #{currentPoints},
|
||||
#{level}, #{createTime}, #{updateTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
<!-- 更新用户积分 -->
|
||||
<update id="updateUserPoints" parameterType="org.xyzh.common.dto.usercenter.TbUserPoints">
|
||||
UPDATE tb_user_points
|
||||
<set>
|
||||
<if test="userId != null and userId != ''">
|
||||
user_id = #{userId},
|
||||
</if>
|
||||
<if test="totalPoints != null">
|
||||
total_points = #{totalPoints},
|
||||
</if>
|
||||
<if test="currentPoints != null">
|
||||
current_points = #{currentPoints},
|
||||
</if>
|
||||
<if test="level != null">
|
||||
level = #{level},
|
||||
</if>
|
||||
<if test="updateTime != null">
|
||||
update_time = #{updateTime},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<!-- 删除用户积分 -->
|
||||
<delete id="deleteUserPoints" parameterType="org.xyzh.common.dto.usercenter.TbUserPoints">
|
||||
DELETE FROM tb_user_points
|
||||
WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户积分 -->
|
||||
<insert id="batchInsertUserPoints" parameterType="java.util.List">
|
||||
INSERT INTO tb_user_points (
|
||||
id, user_id, total_points, current_points, level, create_time, update_time
|
||||
) VALUES
|
||||
<foreach collection="userPointsList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.totalPoints}, #{item.currentPoints},
|
||||
#{item.level}, #{item.createTime}, #{item.updateTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<!-- 批量删除用户积分 -->
|
||||
<delete id="batchDeleteUserPoints">
|
||||
DELETE FROM tb_user_points
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</delete>
|
||||
|
||||
<!-- 分页查询用户积分 -->
|
||||
<select id="selectUserPointsPage" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_points
|
||||
<include refid="Base_Where_Clause" />
|
||||
ORDER BY create_time DESC
|
||||
LIMIT #{pageParam.pageSize} OFFSET #{pageParam.pageNumber}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户积分总数 -->
|
||||
<select id="countUserPoints" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_points
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user