package com.red.circle.other.app.inner.endpoint.user.user;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.inner.model.cmd.user.FriendshipCardQryCmd;
import com.red.circle.other.inner.model.cmd.user.SysUserFriendshipCardConfigCmd;
import com.red.circle.other.inner.model.cmd.user.SysUserFriendshipCardConfigQryCmd;
import com.red.circle.other.inner.model.dto.user.FriendshipCardDTO;
import com.red.circle.other.inner.model.dto.user.SysUserFriendshipCardConfigDTO;
import com.red.circle.other.app.inner.service.user.user.FriendshipCardClientService;
import com.red.circle.other.inner.endpoint.user.user.api.FriendshipCardClientApi;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 用户友谊关系卡.
 *
 * @author pengliang on 2023/10/17
 */
@Validated
@RestController
@RequestMapping(value = FriendshipCardClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class FriendshipCardClientEndpoint implements FriendshipCardClientApi {

  private final FriendshipCardClientService friendshipCardClientService;

  @Override
  public ResultResponse<List<FriendshipCardDTO>> listByCondition(Long sendUserId,
      Long acceptUserId) {
    return ResultResponse.success(
        friendshipCardClientService.listByCondition(sendUserId, acceptUserId));
  }

  @Override
  public ResultResponse<List<FriendshipCardDTO>> listByCondition(FriendshipCardQryCmd qryCmd) {
    return ResultResponse.success(
        friendshipCardClientService.listByCondition(qryCmd.getSendUserId(),
            qryCmd.getAcceptUserIds()));
  }

  @Override
  public ResultResponse<Void> updateBatchById(List<FriendshipCardDTO> dto) {
    friendshipCardClientService.updateBatchById(dto);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<PageResult<SysUserFriendshipCardConfigDTO>> pageConfig(
      SysUserFriendshipCardConfigQryCmd query) {
    return ResultResponse.success(friendshipCardClientService.pageConfig(query));
  }

  @Override
  public ResultResponse<Void> updateConfig(SysUserFriendshipCardConfigCmd param) {
    friendshipCardClientService.updateConfig(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> addConfig(SysUserFriendshipCardConfigCmd param) {
    friendshipCardClientService.addConfig(param);
    return ResultResponse.success();
  }

}
