serv-学习
This commit is contained in:
@@ -38,6 +38,11 @@
|
||||
<artifactId>common-all</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.xyzh</groupId>
|
||||
<artifactId>system</artifactId>
|
||||
<version>${school-news.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
package org.xyzh.usercenter.controller;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.usercenter.achievement.UserAchievementService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
|
||||
/**
|
||||
* @description 用户成就控制器
|
||||
* @filename UserAchievementController.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/usercenter/achievement")
|
||||
public class UserAchievementController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserAchievementController.class);
|
||||
|
||||
@Autowired
|
||||
private UserAchievementService userAchievementService;
|
||||
|
||||
/**
|
||||
* 获取所有成就列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public ResultDomain<TbAchievement> getAllAchievements(
|
||||
@RequestParam(required = false) Integer type,
|
||||
@RequestParam(required = false) Integer level) {
|
||||
return userAchievementService.getAllAchievements(type, level);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户已获得的成就
|
||||
*/
|
||||
@GetMapping("/user/{userID}")
|
||||
public ResultDomain<TbUserAchievement> getUserAchievements(
|
||||
@PathVariable String userID,
|
||||
@RequestParam(required = false) Integer type) {
|
||||
return userAchievementService.getUserAchievements(userID, type);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否已获得成就
|
||||
*/
|
||||
@GetMapping("/check/{userID}/{achievementID}")
|
||||
public ResultDomain<Boolean> hasAchievement(
|
||||
@PathVariable String userID,
|
||||
@PathVariable String achievementID) {
|
||||
return userAchievementService.hasAchievement(userID, achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授予用户成就
|
||||
*/
|
||||
@PostMapping("/grant")
|
||||
public ResultDomain<TbUserAchievement> grantAchievement(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String achievementID) {
|
||||
return userAchievementService.grantAchievement(userID, achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取成就详情
|
||||
*/
|
||||
@GetMapping("/detail/{achievementID}")
|
||||
public ResultDomain<TbAchievement> getAchievementDetail(@PathVariable String achievementID) {
|
||||
return userAchievementService.getAchievementDetail(achievementID);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查用户是否满足成就条件
|
||||
*/
|
||||
@GetMapping("/condition/{userID}/{achievementID}")
|
||||
public ResultDomain<Boolean> checkAchievementCondition(
|
||||
@PathVariable String userID,
|
||||
@PathVariable String achievementID) {
|
||||
return userAchievementService.checkAchievementCondition(userID, achievementID);
|
||||
}
|
||||
}
|
||||
@@ -6,8 +6,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.xyzh.api.usercenter.collection.UserCollectionService;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
/**
|
||||
* @description 用户收藏控制器
|
||||
* @filename UserCollectionController.java
|
||||
@@ -16,7 +18,7 @@ import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/usercenter/collection")
|
||||
@RequestMapping("/usercenter/collections")
|
||||
public class UserCollectionController {
|
||||
private static final Logger logger = LoggerFactory.getLogger(UserCollectionController.class);
|
||||
|
||||
@@ -37,7 +39,7 @@ public class UserCollectionController {
|
||||
/**
|
||||
* 添加收藏
|
||||
*/
|
||||
@PostMapping("/add")
|
||||
@PostMapping("/collect")
|
||||
public ResultDomain<TbUserCollection> addCollection(@RequestBody TbUserCollection userCollection) {
|
||||
return userCollectionService.addCollection(userCollection);
|
||||
}
|
||||
@@ -45,12 +47,9 @@ public class UserCollectionController {
|
||||
/**
|
||||
* 取消收藏
|
||||
*/
|
||||
@DeleteMapping("/remove")
|
||||
public ResultDomain<Boolean> removeCollection(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String resourceID,
|
||||
@RequestParam Integer resourceType) {
|
||||
return userCollectionService.removeCollection(userID, resourceType, resourceID);
|
||||
@DeleteMapping("/collect")
|
||||
public ResultDomain<Boolean> removeCollection(@RequestBody TbUserCollection userCollection) {
|
||||
return userCollectionService.removeCollection(userCollection);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -58,10 +57,15 @@ public class UserCollectionController {
|
||||
*/
|
||||
@GetMapping("/check")
|
||||
public ResultDomain<Boolean> isCollected(
|
||||
@RequestParam String userID,
|
||||
@RequestParam String resourceID,
|
||||
@RequestParam Integer resourceType) {
|
||||
return userCollectionService.isCollected(userID, resourceType, resourceID);
|
||||
@RequestParam(value = "collectionID", required = false) String collectionID,
|
||||
@RequestParam(value = "collectionType", required = false) Integer collectionType) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
return userCollectionService.isCollected(user.getID(), collectionType, collectionID);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
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 AchievementMapper.java文件描述 成就数据访问层
|
||||
* @filename AchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface AchievementMapper extends BaseMapper<TbAchievement> {
|
||||
|
||||
/**
|
||||
* @description 查询成就列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbAchievement> 成就列表
|
||||
* @author yslg
|
||||
* @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);
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
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 UserAchievementMapper.java文件描述 用户成就数据访问层
|
||||
* @filename UserAchievementMapper.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface UserAchievementMapper extends BaseMapper<TbUserAchievement> {
|
||||
|
||||
/**
|
||||
* @description 查询用户成就列表
|
||||
* @param filter 过滤条件
|
||||
* @return List<TbUserAchievement> 用户成就列表
|
||||
* @author yslg
|
||||
* @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);
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package org.xyzh.usercenter.service;
|
||||
|
||||
import org.xyzh.api.usercenter.achievement.UserAchievementService;
|
||||
|
||||
/**
|
||||
* @description 用户成就服务接口
|
||||
* @filename UCUserAchievementService.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
public interface UCUserAchievementService extends UserAchievementService {
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package org.xyzh.usercenter.service.impl;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.usercenter.TbAchievement;
|
||||
import org.xyzh.common.dto.usercenter.TbUserAchievement;
|
||||
import org.xyzh.usercenter.mapper.AchievementMapper;
|
||||
import org.xyzh.usercenter.mapper.UserAchievementMapper;
|
||||
import org.xyzh.usercenter.service.UCUserAchievementService;
|
||||
|
||||
/**
|
||||
* @description 用户成就服务实现类
|
||||
* @filename UCUserAchievementServiceImpl.java
|
||||
* @author yslg
|
||||
* @copyright xyzh
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
@Service
|
||||
public class UCUserAchievementServiceImpl implements UCUserAchievementService {
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(UCUserAchievementServiceImpl.class);
|
||||
|
||||
@Autowired
|
||||
private AchievementMapper achievementMapper;
|
||||
|
||||
@Autowired
|
||||
private UserAchievementMapper userAchievementMapper;
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbAchievement> getAllAchievements(Integer type, Integer level) {
|
||||
// TODO: 实现获取所有成就列表
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserAchievement> getUserAchievements(String userID, Integer type) {
|
||||
// TODO: 实现获取用户已获得的成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> hasAchievement(String userID, String achievementID) {
|
||||
// TODO: 实现检查用户是否已获得成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserAchievement> grantAchievement(String userID, String achievementID) {
|
||||
// TODO: 实现授予用户成就
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbAchievement> getAchievementDetail(String achievementID) {
|
||||
// TODO: 实现获取成就详情
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> checkAchievementCondition(String userID, String achievementID) {
|
||||
// TODO: 实现检查用户是否满足成就条件
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package org.xyzh.usercenter.service.impl;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
@@ -7,7 +8,9 @@ import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.xyzh.common.core.domain.ResultDomain;
|
||||
import org.xyzh.common.dto.user.TbSysUser;
|
||||
import org.xyzh.common.dto.usercenter.TbUserCollection;
|
||||
import org.xyzh.system.utils.LoginUtil;
|
||||
import org.xyzh.usercenter.mapper.UserCollectionMapper;
|
||||
import org.xyzh.usercenter.service.UCUserCollectionService;
|
||||
|
||||
@@ -28,6 +31,14 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserCollection> addCollection(TbUserCollection userCollection) {
|
||||
TbSysUser user = LoginUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("请先登录");
|
||||
return resultDomain;
|
||||
}
|
||||
userCollection.setUserID(user.getID());
|
||||
userCollection.setCreateTime(new Date());
|
||||
int result = userCollectionMapper.insertUserCollection(userCollection);
|
||||
if (result > 0) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
@@ -82,12 +93,8 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID) {
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
filter.setCollectionID(collectionID);
|
||||
int result = userCollectionMapper.deleteUserCollection(filter);
|
||||
public ResultDomain<Boolean> removeCollection(TbUserCollection userCollection) {
|
||||
int result = userCollectionMapper.deleteUserCollection(userCollection);
|
||||
if (result > 0) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("删除收藏成功", true);
|
||||
|
||||
@@ -1,463 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.AchievementMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbAchievement">
|
||||
<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
|
||||
</sql>
|
||||
|
||||
<!-- 查询条件 -->
|
||||
<sql id="Base_Where_Clause">
|
||||
<where>
|
||||
<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>
|
||||
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectByIdCustom" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_achievement
|
||||
WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询单条记录 -->
|
||||
<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.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计成就总数 -->
|
||||
<select id="countAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -1,291 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.xyzh.usercenter.mapper.UserAchievementMapper">
|
||||
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserAchievement">
|
||||
<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="Base_Where_Clause">
|
||||
<where>
|
||||
<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>
|
||||
|
||||
<!-- 根据ID查询单条记录 -->
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_achievement
|
||||
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>
|
||||
|
||||
<!-- 根据用户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.offset}
|
||||
</select>
|
||||
|
||||
<!-- 统计用户成就总数 -->
|
||||
<select id="countUserAchievements" resultType="long">
|
||||
SELECT COUNT(1)
|
||||
FROM tb_user_achievement
|
||||
<include refid="Base_Where_Clause" />
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user