package com.mall.member.controller;

import com.mall.member.domain.dto.MemberCollectSubjectDto;
import com.mall.member.domain.entity.MemberCollectSubject;
import com.mall.member.domain.vo.MemberCollectSubjectVo;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import com.mall.member.service.MemberCollectSubjectService;
import com.mall.common.domain.vo.result.PageResult;
import com.mall.common.domain.vo.result.Result;
import com.mall.common.domain.vo.result.ResultCodeEnum;

import java.util.List;

/**
 * <p>
 * 会员收藏的专题活动 前端控制器
 * </p>
 *
 * @author Bunny
 * @since 2025-07-05 19:30:06
 */
@Tag(name = "会员收藏的专题活动", description = "会员收藏的专题活动相关接口")
@RestController
@RequestMapping("/api/member/member-collect-subject")
@RequiredArgsConstructor
public class MemberCollectSubjectController {

    private final MemberCollectSubjectService memberCollectSubjectService;

    @Operation(summary = "分页查询会员收藏的专题活动", description = "分页会员收藏的专题活动")
    @GetMapping("{page}/{limit}")
    public Result<PageResult<MemberCollectSubjectVo>> getMemberCollectSubjectPage(
            @Parameter(name = "page", description = "当前页", required = true)
            @PathVariable("page") Integer page,
            @Parameter(name = "limit", description = "每页记录数", required = true)
            @PathVariable("limit") Integer limit,
            MemberCollectSubjectDto dto) {
        Page<MemberCollectSubject> pageParams = new Page<>(page, limit);
        PageResult<MemberCollectSubjectVo> pageResult = memberCollectSubjectService.getMemberCollectSubjectPage(pageParams, dto);
        return Result.success(pageResult);
    }

    @Operation(summary = "添加会员收藏的专题活动", description = "添加会员收藏的专题活动")
    @PostMapping()
    public Result<String> addMemberCollectSubject(@Valid @RequestBody MemberCollectSubjectDto dto) {
            memberCollectSubjectService.addMemberCollectSubject(dto);
        return Result.success(ResultCodeEnum.ADD_SUCCESS);
    }

    @Operation(summary = "更新会员收藏的专题活动", description = "更新会员收藏的专题活动")
    @PutMapping()
    public Result<String> updateMemberCollectSubject(@Valid @RequestBody MemberCollectSubjectDto dto) {
            memberCollectSubjectService.updateMemberCollectSubject(dto);
        return Result.success(ResultCodeEnum.UPDATE_SUCCESS);
    }

    @Operation(summary = "删除会员收藏的专题活动", description = "删除会员收藏的专题活动")
    @DeleteMapping()
    public Result<String> deleteMemberCollectSubject(@RequestBody List<Long> ids) {
            memberCollectSubjectService.deleteMemberCollectSubject(ids);
        return Result.success(ResultCodeEnum.DELETE_SUCCESS);
    }
}