package com.xindazhou.business.api.member;

import com.xindazhou.framework.common.pojo.CommonResult;
import com.xindazhou.framework.common.pojo.PageResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;
import java.util.Collection;
import java.util.List;
import java.util.Map;

/**
 * 会员标签 Feign 客户端
 * 用于调用用户服务（xdz-user-server）的接口
 *
 * @author xindazhou
 */
@FeignClient(name = "xdz-user-server", url = "${feign.user-server.url:}")  // 支持配置 URL，如果不配置则使用 Nacos 服务发现
@Tag(name = "RPC 服务 - 会员标签")
public interface MemberTagApi {

    String PREFIX = "/admin-api/member/tag";

    @GetMapping(PREFIX + "/page")
    @Operation(summary = "获得会员标签分页")
    CommonResult<PageResult<Map<String, Object>>> getTagPage(@SpringQueryMap Map<String, Object> pageVO);

    @GetMapping(PREFIX + "/get")
    @Operation(summary = "获得会员标签")
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
    CommonResult<Map<String, Object>> getMemberTag(@RequestParam("id") Long id);

    @GetMapping(PREFIX + "/list-all-simple")
    @Operation(summary = "获取会员标签精简信息列表")
    CommonResult<List<Map<String, Object>>> getSimpleTagList();

    @GetMapping(PREFIX + "/list")
    @Operation(summary = "获得会员标签列表")
    @Parameter(name = "ids", description = "编号列表", required = true, example = "1024,2048")
    CommonResult<List<Map<String, Object>>> getMemberTagList(@RequestParam("ids") Collection<Long> ids);

    @PostMapping(PREFIX + "/create")
    @Operation(summary = "创建会员标签")
    CommonResult<Long> createTag(@Valid @RequestBody Map<String, Object> createReqVO);

    @PutMapping(PREFIX + "/update")
    @Operation(summary = "更新会员标签")
    CommonResult<Boolean> updateTag(@Valid @RequestBody Map<String, Object> updateReqVO);

    @DeleteMapping(PREFIX + "/delete")
    @Operation(summary = "删除会员标签")
    @Parameter(name = "id", description = "编号", required = true)
    CommonResult<Boolean> deleteTag(@RequestParam("id") Long id);
}

