Administrator
2025-07-22 87b793dc328b8cd4a6263acc45bc7dcfdacf04d1
feat(mall): 添加收藏、点赞、关注状态接口

- 新增 followState 接口,用于获取用户对某个社区的收藏、点赞、关注状态
- 在 ApiClothesSocialService 中添加 followState 方法
- 实现 followState 方法,查询用户对指定社区的收藏和点赞状态
- 添加 ApiSocialCollectFollowStateDto 数据传输对象,用于传递社区 ID
3 files modified
1 files added
51 ■■■■■ changed files
src/main/java/cc/mrbird/febs/mall/controller/clothes/ApiClothesSocialController.java 7 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialCollectFollowStateDto.java 16 ●●●●● 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 26 ●●●●● patch | view | raw | blame | history
src/main/java/cc/mrbird/febs/mall/controller/clothes/ApiClothesSocialController.java
@@ -94,6 +94,13 @@
        return apiClothesSocialService.addCollect(dto);
    }
    @ApiOperation(value = "是否收藏点赞收藏", notes = "是否收藏点赞收藏")
    @PostMapping(value = "/followState")
    public FebsResponse followState(@RequestBody @Validated ApiSocialCollectFollowStateDto dto) {
        return apiClothesSocialService.followState(dto);
    }
    @ApiOperation(value = "我的社区收藏", notes = "我的社区收藏")
    @ApiResponses({
            @ApiResponse(code = 200, message = "success", response = ApiSocialMyCollectVo.class)
src/main/java/cc/mrbird/febs/mall/dto/clothes/ApiSocialCollectFollowStateDto.java
New file
@@ -0,0 +1,16 @@
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 = "ApiSocialCollectFollowStateDto", description = "参数")
public class ApiSocialCollectFollowStateDto {
    @NotNull(message = "社区不能为空")
    @ApiModelProperty(value = "社区ID")
    private Long socialId;
}
src/main/java/cc/mrbird/febs/mall/service/ApiClothesSocialService.java
@@ -32,4 +32,6 @@
    FebsResponse allComment(ApiAllCommentDto dto);
    FebsResponse delCollection(ApiColletDelDto dto);
    FebsResponse followState(ApiSocialCollectFollowStateDto dto);
}
src/main/java/cc/mrbird/febs/mall/service/impl/ApiClothesSocialServiceImpl.java
@@ -669,6 +669,32 @@
        return new FebsResponse().success().message("操作成功");
    }
    @Override
    public FebsResponse followState(ApiSocialCollectFollowStateDto dto) {
        Long memberId = LoginUserUtil.getLoginUser().getId();
        HashMap<String, Object> stringObjectHashMap = new HashMap<>();
        Integer collectState = clothesSocialFollowMapper.selectCount(
                Wrappers.lambdaQuery(ClothesSocialFollow.class)
                        .eq(ClothesSocialFollow::getMemberId, memberId)
                        .eq(ClothesSocialFollow::getSourceType, SocialSourceTypeEnum.SOCIAL.getValue())
                        .eq(ClothesSocialFollow::getSourceId, dto.getSocialId())
                        .eq(ClothesSocialFollow::getType, SocialTypeEnum.COLLECT.getValue())
        );
        stringObjectHashMap.put("collectState", collectState);
        Integer likeState = clothesSocialFollowMapper.selectCount(
                Wrappers.lambdaQuery(ClothesSocialFollow.class)
                        .eq(ClothesSocialFollow::getMemberId, memberId)
                        .eq(ClothesSocialFollow::getSourceType, SocialSourceTypeEnum.SOCIAL.getValue())
                        .eq(ClothesSocialFollow::getSourceId, dto.getSocialId())
                        .eq(ClothesSocialFollow::getType, SocialTypeEnum.LIKE.getValue())
        );
        stringObjectHashMap.put("likeState", likeState);
        return new FebsResponse().success().data(stringObjectHashMap);
    }
    public static void main(String[] args) {
        JSONObject jsonObject = new JSONObject();
        jsonObject.putByPath("text", "123");