Administrator
2025-07-21 0b80f415c2ab98d545f246d2c8adb4c40c0f55d6
feat(mall): 添加我的社区收藏功能

- 新增 myCollect接口用于获取用户收藏的社区内容
- 实现 ApiClothesSocialService 接口的 myCollect 方法
- 添加 ApiSocialMyCollectAddDto 和 ApiSocialMyCollectVo 类用于处理我的收藏相关数据- 在 ClothesSocialFollowMapper 中添加 selectPageInMyComment 方法用于查询用户收藏的社区内容
- 在 ClothesSocialFollowMapper.xml 中添加对应的 SQL 查询语句
5 files modified
2 files added
100 ■■■■■ changed files
src/main/java/cc/mrbird/febs/mall/controller/clothes/ApiClothesSocialController.java 10 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialMyCollectAddDto.java 24 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/mapper/ClothesSocialFollowMapper.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/ApiClothesSocialService.java 2 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiSocialMyCollectVo.java 27 ●●●●● patch | view | raw | blame | history
src/main/resources/mapper/modules/ClothesSocialFollowMapper.xml 17 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/clothes/ApiClothesSocialController.java
@@ -93,6 +93,16 @@
        return apiClothesSocialService.addCollect(dto);
    }
    @ApiOperation(value = "我的社区收藏", notes = "我的社区收藏")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = ApiSocialMyCollectVo.class)
    })
    @PostMapping(value = "/myCollect")
    public FebsResponse myCollect(@RequestBody @Validated ApiSocialMyCollectAddDto dto) {
        return apiClothesSocialService.myCollect(dto);
    }
    @ApiOperation(value = "我的灵感-跳转到开始设计", notes = "我的灵感-跳转到开始设计")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = ApiClothesSocialMuseVo.class)
src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialMyCollectAddDto.java
New file
@@ -0,0 +1,24 @@
package cc.mrbird.febs.mall.dto.clothes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "ApiSocialMyCollectAddDto", description = "参数")
public class ApiSocialMyCollectAddDto {
    @NotNull(message = "页码不能为空")
    @ApiModelProperty(value = "页码", example = "1")
    private Integer pageNow;
    @NotNull(message = "每页数量不能为空")
    @ApiModelProperty(value = "每页数量", example = "10")
    private Integer pageSize;
    @ApiModelProperty(hidden = true)
    private Long memberId;
}
src/main/java/cc/mrbird/febs/mall/mapper/ClothesSocialFollowMapper.java
@@ -1,7 +1,14 @@
package cc.mrbird.febs.mall.mapper;
import cc.mrbird.febs.mall.dto.clothes.ApiSocialMyCollectAddDto;
import cc.mrbird.febs.mall.entity.ClothesSocialFollow;
import cc.mrbird.febs.mall.vo.clothes.ApiSocialMyCollectVo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param;
public interface ClothesSocialFollowMapper extends BaseMapper<ClothesSocialFollow> {
    Page<ApiSocialMyCollectVo> selectPageInMyComment(Page<ApiSocialMyCollectVo> page, @Param("record")ApiSocialMyCollectAddDto dto);
}
src/main/java/cc/mrbird/febs/mall/service/ApiClothesSocialService.java
@@ -22,6 +22,8 @@
    FebsResponse addCollect(ApiSocialCollectAddDto dto);
    FebsResponse myCollect(ApiSocialMyCollectAddDto dto);
    FebsResponse museToDesign(ApiClothesSocialMuseDto dto);
    FebsResponse comment(ApiClothesSocialCommentDto dto);
src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
@@ -441,6 +441,19 @@
    }
    @Override
    public FebsResponse myCollect(ApiSocialMyCollectAddDto dto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        dto.setMemberId(memberId);
        // 创建分页对象,传入当前页和每页大小
        Page<ApiSocialMyCollectVo> page = new Page<>(dto.getPageNow(), dto.getPageSize());
        // 调用Mapper方法获取活动分页数据
        Page<ApiSocialMyCollectVo> voPage = clothesSocialFollowMapper.selectPageInMyComment(page, dto);
        return new FebsResponse().success().data(voPage);
    }
    @Override
    public FebsResponse museToDesign(ApiClothesSocialMuseDto dto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
src/main/java/cc/mrbird/febs/mall/vo/clothes/ApiSocialMyCollectVo.java
New file
@@ -0,0 +1,27 @@
package cc.mrbird.febs.mall.vo.clothes;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel(value = "ApiSocialMyCollectVo", description = "参数")
public class ApiSocialMyCollectVo {
    @ApiModelProperty(value = "id")
    private Long id;
    @ApiModelProperty(value = "用户")
    private String memberName;
    @ApiModelProperty(value = "头像")
    private String memberAvatar;
    @ApiModelProperty(value = "标题")
    private String name;
    @ApiModelProperty(value = "封面")
    private String indexFile;
}
src/main/resources/mapper/modules/ClothesSocialFollowMapper.xml
@@ -2,5 +2,22 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cc.mrbird.febs.mall.mapper.ClothesSocialFollowMapper">
    <select id="selectPageInMyComment" resultType="cc.mrbird.febs.mall.vo.clothes.ApiSocialMyCollectVo">
        select
        c.id as id,
        b.name as memberName,
        b.avatar as memberAvatar,
        c.name as name,
        c.index_file as indexFile
        from clothes_social_follow a
        left join mall_member b on a.member_id = b.id
        left join clothes_social c on a.source_id = c.id
            where a.source_type = 1
            and a.type = 2
            and a.member_id = #{record.memberId}
            group by c.id
        order by a.created_time desc
    </select>
</mapper>