serv-学习管理
This commit is contained in:
@@ -34,7 +34,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectByUserId(@Param("userId") String userId);
|
||||
List<TbUserCollection> selectByUserId(@Param("userID") String userID);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID和类型查询收藏记录
|
||||
@@ -44,7 +44,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectByUserIdAndType(@Param("userId") String userId, @Param("collectionType") Integer collectionType);
|
||||
List<TbUserCollection> selectByUserIdAndType(@Param("userID") String userID, @Param("collectionType") Integer collectionType);
|
||||
|
||||
/**
|
||||
* @description 根据用户ID查询收藏记录(包含用户基本信息)
|
||||
@@ -53,7 +53,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
List<TbUserCollection> selectUserCollectionsWithUser(@Param("userId") String userId);
|
||||
List<TbUserCollection> selectUserCollectionsWithUser(@Param("userID") String userID);
|
||||
|
||||
/**
|
||||
* @description 查询用户收藏统计
|
||||
@@ -62,7 +62,7 @@ public interface UserCollectionMapper extends BaseMapper<TbUserCollection> {
|
||||
* @author yslg
|
||||
* @since 2025-10-15
|
||||
*/
|
||||
TbUserCollection selectCollectionStatistics(@Param("userId") String userId);
|
||||
TbUserCollection selectCollectionStatistics(@Param("userID") String userID);
|
||||
|
||||
/**
|
||||
* @description 插入用户收藏
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package org.xyzh.usercenter.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -26,38 +28,92 @@ public class UCUserCollectionServiceImpl implements UCUserCollectionService {
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserCollection> addCollection(TbUserCollection userCollection) {
|
||||
// TODO: 实现添加收藏
|
||||
return null;
|
||||
int result = userCollectionMapper.insertUserCollection(userCollection);
|
||||
if (result > 0) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("添加收藏成功", userCollection);
|
||||
return resultDomain;
|
||||
} else {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("添加收藏失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserCollection> getCollectionDetail(String userID, Integer collectionType,
|
||||
String collectionID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<TbUserCollection> getUserCollections(String userID, Integer collectionType) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
List<TbUserCollection> list = userCollectionMapper.selectUserCollections(filter);
|
||||
if (list != null && list.size() > 0) {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("获取收藏列表成功", list);
|
||||
return resultDomain;
|
||||
} else {
|
||||
ResultDomain<TbUserCollection> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("获取收藏列表失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> isCollected(String userID, Integer collectionType, String collectionID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
filter.setCollectionID(collectionID);
|
||||
long count = userCollectionMapper.countUserCollections(filter);
|
||||
if (count > 0) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("已收藏", true);
|
||||
return resultDomain;
|
||||
} else {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("未收藏", false);
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Boolean> removeCollection(String userID, Integer collectionType, String collectionID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
filter.setCollectionID(collectionID);
|
||||
int result = userCollectionMapper.deleteUserCollection(filter);
|
||||
if (result > 0) {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("删除收藏成功", true);
|
||||
return resultDomain;
|
||||
} else {
|
||||
ResultDomain<Boolean> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("删除收藏失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResultDomain<Integer> getCollectionCount(String userID, Integer collectionType, String collectionID) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
TbUserCollection filter = new TbUserCollection();
|
||||
filter.setUserID(userID);
|
||||
filter.setCollectionType(collectionType);
|
||||
filter.setCollectionID(collectionID);
|
||||
long count = userCollectionMapper.countUserCollections(filter);
|
||||
if (count > 0) {
|
||||
ResultDomain<Integer> resultDomain = new ResultDomain<>();
|
||||
resultDomain.success("获取收藏数量成功", (int)count);
|
||||
return resultDomain;
|
||||
} else {
|
||||
ResultDomain<Integer> resultDomain = new ResultDomain<>();
|
||||
resultDomain.fail("获取收藏数量失败");
|
||||
return resultDomain;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,9 @@
|
||||
<!-- 结果映射 -->
|
||||
<resultMap id="BaseResultMap" type="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
<id column="id" property="id" />
|
||||
<result column="user_id" property="userId" />
|
||||
<result column="user_id" property=".userID" />
|
||||
<result column="collection_type" property="collectionType" />
|
||||
<result column="collection_id" property="collectionId" />
|
||||
<result column="collection_id" property="collectionID" />
|
||||
<result column="create_time" property="createTime" />
|
||||
</resultMap>
|
||||
|
||||
@@ -23,14 +23,14 @@
|
||||
<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 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 test="filter.collectionID != null and filter.collectionID != ''">
|
||||
AND collection_id = #{filter.collectionID}
|
||||
</if>
|
||||
<if test="filter.createTime != null">
|
||||
AND create_time = #{filter.createTime}
|
||||
@@ -105,7 +105,7 @@
|
||||
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}
|
||||
#{entity.id}, #{entity.userID}, #{entity.collectionType}, #{entity.collectionID}, #{entity.createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
) VALUES
|
||||
<foreach collection="entities" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id}, #{entity.userId}, #{entity.collectionType}, #{entity.collectionId}, #{entity.createTime}
|
||||
#{entity.id}, #{entity.userID}, #{entity.collectionType}, #{entity.collectionID}, #{entity.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
@@ -125,14 +125,14 @@
|
||||
<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 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 test="entity.collectionID != null and entity.collectionID != ''">
|
||||
collection_id = #{entity.collectionID},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{entity.id}
|
||||
@@ -142,14 +142,14 @@
|
||||
<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 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 test="entity.collectionID != null and entity.collectionID != ''">
|
||||
collection_id = #{entity.collectionID},
|
||||
</if>
|
||||
</set>
|
||||
<include refid="Base_Where_Clause" />
|
||||
@@ -188,7 +188,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId}
|
||||
WHERE user_id = #{userID}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -197,7 +197,7 @@
|
||||
SELECT
|
||||
<include refid="Base_Column_List" />
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId} AND collection_type = #{collectionType}
|
||||
WHERE user_id = #{userID} AND collection_type = #{collectionType}
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -207,7 +207,7 @@
|
||||
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}
|
||||
WHERE uc.user_id = #{userID}
|
||||
ORDER BY uc.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -218,7 +218,7 @@
|
||||
COUNT(*) as collection_type,
|
||||
MAX(create_time) as create_time
|
||||
FROM tb_user_collection
|
||||
WHERE user_id = #{userId}
|
||||
WHERE user_id = #{userID}
|
||||
GROUP BY user_id
|
||||
</select>
|
||||
|
||||
@@ -227,7 +227,7 @@
|
||||
INSERT INTO tb_user_collection (
|
||||
id, user_id, collection_type, collection_id, create_time
|
||||
) VALUES (
|
||||
#{id}, #{userId}, #{collectionType}, #{collectionId}, #{createTime}
|
||||
#{id}, #{userID}, #{collectionType}, #{collectionID}, #{createTime}
|
||||
)
|
||||
</insert>
|
||||
|
||||
@@ -235,14 +235,14 @@
|
||||
<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 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 test="collectionID != null and collectionID != ''">
|
||||
collection_id = #{collectionID},
|
||||
</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
@@ -251,7 +251,7 @@
|
||||
<!-- 删除用户收藏 -->
|
||||
<delete id="deleteUserCollection" parameterType="org.xyzh.common.dto.usercenter.TbUserCollection">
|
||||
DELETE FROM tb_user_collection
|
||||
WHERE id = #{id}
|
||||
WHERE user_id = #{userID} AND collection_type = #{collectionType} AND collection_id = #{collectionID}
|
||||
</delete>
|
||||
|
||||
<!-- 批量插入用户收藏 -->
|
||||
@@ -261,7 +261,7 @@
|
||||
) VALUES
|
||||
<foreach collection="userCollectionList" item="item" separator=",">
|
||||
(
|
||||
#{item.id}, #{item.userId}, #{item.collectionType}, #{item.collectionId}, #{item.createTime}
|
||||
#{item.id}, #{item.userID}, #{item.collectionType}, #{item.collectionID}, #{item.createTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
Reference in New Issue
Block a user