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.BeautifulNumberQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberApplyQryCmd;
import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberCmd;
import com.red.circle.other.inner.model.dto.user.BeautifulNumberDTO;
import com.red.circle.other.inner.model.dto.user.UserBeautifulNumberApplyDTO;
import com.red.circle.other.app.inner.service.user.user.UserBeautifulNumberClientService;
import com.red.circle.other.inner.endpoint.user.user.api.UserBeautifulNumberApplyClientApi;
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/13
 */
@Validated
@RestController
@RequestMapping(value = UserBeautifulNumberApplyClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class UserBeautifulNumberClientEndpoint implements UserBeautifulNumberApplyClientApi {

  private final UserBeautifulNumberClientService userBeautifulNumberApplyClientService;


  @Override
  public ResultResponse<PageResult<UserBeautifulNumberApplyDTO>> pageBeautifulNumberApply(
      UserBeautifulNumberApplyQryCmd query) {
    return ResultResponse.success(
        userBeautifulNumberApplyClientService.pageBeautifulNumberApply(query));
  }

  @Override
  public ResultResponse<Void> handleApply(Long id, Integer state, String remark) {
    userBeautifulNumberApplyClientService.handleApply(id, state, remark);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<Void> updateBeautifulNumber(UserBeautifulNumberCmd cmd) {
    userBeautifulNumberApplyClientService.updateBeautifulNumber(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> addBeautifulNumber(UserBeautifulNumberCmd cmd) {
    userBeautifulNumberApplyClientService.addBeautifulNumber(cmd);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<PageResult<BeautifulNumberDTO>> pageBeautifulNumber(
      BeautifulNumberQryCmd query) {
    return ResultResponse.success(userBeautifulNumberApplyClientService.pageBeautifulNumber(query));
  }

  @Override
  public ResultResponse<Void> deleteBeautifulNumber(Long id) {
    userBeautifulNumberApplyClientService.deleteBeautifulNumber(id);
    return ResultResponse.success();
  }
}
