package com.red.circle.other.inner.endpoint.material.props.api;

import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.material.DeleteBadgeCmd;
import com.red.circle.other.inner.model.cmd.material.GiveBadgeCmd;
import com.red.circle.other.inner.model.dto.material.BadgeBackpackDTO;
import com.red.circle.other.inner.model.dto.material.BadgePictureConfigDTO;
import com.red.circle.other.inner.model.dto.material.UseBadgeDTO;
import java.util.List;
import java.util.Set;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * 用户徽章背包服务.
 *
 * @author pengliang on 2023/6/3
 */
public interface BadgeBackpackClientApi {

  String API_PREFIX = "/user-badge/client";

  /**
   * 获取用户使用徽章.
   */
  @PostMapping("/listUseBadge")
  ResultResponse<List<UseBadgeDTO>> listUseBadge(
      @RequestParam("userId") Long userId,
      @RequestParam("sysOrigin") String sysOrigin,
      @RequestParam("wearBadgeId") Set<Long> wearBadgeId
  );

  /**
   * 获取用户使用徽章.
   */
  @PostMapping("/listUseBadgeBackpackByUserId")
  ResultResponse<List<BadgeBackpackDTO>> listUseBadgeBackpackByUserId(
      @RequestParam("userId") Long userId);


  /**
   * 修改使用的徽章.
   *
   * @param userId   用户id
   * @param badgeIds 徽章id
   */
  @PostMapping("/updateUseBadge")
  ResultResponse<Void> updateUseBadge(
      @RequestParam("userId") Long userId,
      @RequestParam("badgeIds") Set<Long> badgeIds
  );

  /**
   * 卸下用户全部徽章.
   *
   * @param userId 用户id
   */
  @PostMapping("/useOffByUserId")
  ResultResponse<Void> useOffByUserId(@RequestParam("userId") Long userId);

  /**
   * 根据主键标识卸下佩戴的徽章
   *
   * @param ids 主键ID
   */
  @PostMapping("/useOffByIds")
  ResultResponse<Void> useOffByIds(@RequestBody Set<Long> ids);

  /**
   * 将一组用户徽章到期时间减少指定天数，并且将其卸下.
   *
   * @param userId     用户.
   * @param badgeIds   徽章ids
   * @param reduceDays 将有效时间减少*天.
   */
  @PostMapping("/reduceDaysAndUnUse")
  ResultResponse<Void> reduceDaysAndUnUse(
      @RequestParam("userId") Long userId,
      @RequestParam("badgeIds") Set<Long> badgeIds,
      @RequestParam("reduceDays") Integer reduceDays
  );

  /**
   * 激活-永久徽章并佩戴.
   *
   * @param userId  用户id
   * @param badgeId 徽章id
   * @return true 激活成功 ,false 激活失败
   */
  @GetMapping("/activationPermanentAndUse")
  ResultResponse<Boolean> activationPermanentAndUse(
      @RequestParam("userId") Long userId,
      @RequestParam("badgeId") Long badgeId
  );

  /**
   * 激活-临时徽章.
   *
   * @param userId  用户id
   * @param badgeId 徽章id
   * @param days    天数
   * @return true 激活成功 ,false 激活失败
   */
  @GetMapping("/activationTemporaryAndUse")
  ResultResponse<Boolean> activationTemporaryAndUse(
      @RequestParam("userId") Long userId,
      @RequestParam("badgeId") Long badgeId,
      @RequestParam("days") Integer days
  );

  /**
   * 删除指定成员的指定徽章.
   */
  @PostMapping("/deleteBadge")
  ResultResponse<Void> deleteBadge(@RequestBody DeleteBadgeCmd cmd);

  /**
   * 保存一批徽章-背包.
   */
  @PostMapping("/saveBatchBackpack")
  ResultResponse<Void> saveBatchBackpack(@RequestBody List<BadgeBackpackDTO> badges);

  /**
   * 保存徽章-背包.
   */
  @PostMapping("/saveBackpack")
  ResultResponse<Void> saveBackpack(@RequestBody BadgeBackpackDTO badge);

  /**
   * 获取一组用户正在使用徽章.
   */
  @PostMapping("/listUseNotExpireTimeByUserIds")
  ResultResponse<List<BadgeBackpackDTO>> listUseNotExpireTimeByUserIds(
      @RequestBody Set<Long> userIds);

  /**
   * 移除用户徽章.
   */
  @GetMapping("/deleteUserBadge")
  ResultResponse<Void> deleteUserBadge(@RequestParam("userId") Long userId,
      @RequestParam("badgeId") Long badgeId);

  /**
   * 移除用户徽章.
   *
   * @param userId  用户id
   * @param badgeId 徽章id
   */
  @GetMapping("/deleteBadge")
  ResultResponse<Void> deleteBadge(@RequestParam("userId") Long userId,
      @RequestParam("badgeId") Long badgeId);

  /**
   * 根据主键标识卸下佩戴的徽章.
   *
   * @param ids 主键ID
   */
  @GetMapping("/removeWearByIds")
  ResultResponse<Void> removeWearByIds(@RequestBody Set<Long> ids);

  /**
   * 查询用户徽章数据.
   */
  @GetMapping("/listBadge")
  ResultResponse<List<BadgePictureConfigDTO>> listBadge(@RequestParam("userId") Long userId,
      @RequestParam("sysOrigin") String sysOrigin);

  @GetMapping("/giveBadgePermanent")
  ResultResponse<Void> giveBadgePermanent(@RequestParam("badgeId") Long badgeId,
      @RequestParam("userId") Long userId);

  /**
   * 赠送徽章.
   */
  @PostMapping("/giveBadge")
  ResultResponse<Void> giveBadge(@RequestBody @Validated GiveBadgeCmd cmd);

}
