package com.red.circle.order.inner.endpoint;

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.order.inner.endpoint.api.PayApplicationClientApi;
import com.red.circle.order.inner.model.cmd.SysPayApplicationCommodityCmd;
import com.red.circle.order.inner.model.cmd.SysPayApplicationCommodityQryCmd;
import com.red.circle.order.inner.model.dto.SysPayApplicationCommodityDTO;
import com.red.circle.order.inner.model.dto.SysPayApplicationDTO;
import com.red.circle.order.inner.service.PayApplicationClientService;
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/11/3
 */
@Validated
@RestController
@RequestMapping(value = PayApplicationClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class PayApplicationClientEndpoint implements PayApplicationClientApi {

  private final PayApplicationClientService payApplicationClientService;


  @Override
  public ResultResponse<List<SysPayApplicationDTO>> listApplication() {
    return ResultResponse.success(payApplicationClientService.listApplication());
  }

  @Override
  public ResultResponse<Void> addApplication(SysPayApplicationDTO param) {
    payApplicationClientService.addApplication(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> updateApplication(SysPayApplicationDTO param) {
    payApplicationClientService.updateApplication(param);
    return ResultResponse.success();
  }


  @Override
  public ResultResponse<PageResult<SysPayApplicationCommodityDTO>> pageCommodity(
      SysPayApplicationCommodityQryCmd query) {
    return ResultResponse.success(payApplicationClientService.pageCommodity(query));
  }

  @Override
  public ResultResponse<Void> addOrUpdateCommodity(SysPayApplicationCommodityCmd param) {
    payApplicationClientService.addOrUpdateCommodity(param);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> switchShelf(Long id, Boolean shelf) {
    payApplicationClientService.switchShelf(id, shelf);
    return ResultResponse.success();
  }

}
