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）的接口
 */
@FeignClient(name = "xdz-user", url = "${feign.user-server.url:}") // 使用服务名，Nacos 会自动发现
@Tag(name = "RPC 服务 - 会员用户")
public interface MemberUserApi {

    String PREFIX = "/member/user";

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

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

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

    @PutMapping(PREFIX + "/updateLevel")
    @Operation(summary = "更新会员用户等级")
    CommonResult<Boolean> updateUserLevel(@Valid @RequestBody Map<String, Object> updateReqVO);

    @PutMapping(PREFIX + "/updatePoint")
    @Operation(summary = "更新会员用户积分")
    CommonResult<Boolean> updateUserPoint(@Valid @RequestBody Map<String, Object> updateReqVO);

    @PostMapping(PREFIX + "/addTag")
    @Operation(summary = "添加用户标签")
    @Parameter(name = "userId", description = "用户编号", required = true, example = "1024")
    @Parameter(name = "tagId", description = "标签编号", required = true, example = "1")
    CommonResult<Boolean> addUserTag(@RequestParam("userId") Long userId, @RequestParam("tagId") Long tagId);

    @DeleteMapping(PREFIX + "/removeTag")
    @Operation(summary = "删除用户标签")
    @Parameter(name = "userId", description = "用户编号", required = true, example = "1024")
    @Parameter(name = "tagId", description = "标签编号", required = true, example = "1")
    CommonResult<Boolean> removeUserTag(@RequestParam("userId") Long userId, @RequestParam("tagId") Long tagId);

    @GetMapping(PREFIX + "/getTags")
    @Operation(summary = "获取用户标签列表")
    @Parameter(name = "userId", description = "用户编号", required = true, example = "1024")
    CommonResult<List<Long>> getUserTagIds(@RequestParam("userId") Long userId);

    @PutMapping(PREFIX + "/batchEnable")
    @Operation(summary = "批量启用会员")
    @Parameter(name = "ids", description = "用户编号列表", required = true, example = "1,2,3")
    CommonResult<Boolean> batchEnableUser(@RequestParam("ids") Collection<Long> ids);

    @PutMapping(PREFIX + "/batchDisable")
    @Operation(summary = "批量禁用会员")
    @Parameter(name = "ids", description = "用户编号列表", required = true, example = "1,2,3")
    CommonResult<Boolean> batchDisableUser(@RequestParam("ids") Collection<Long> ids);
}

