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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.sys.SysCpCabinConfigClientService;
import com.red.circle.other.inner.endpoint.sys.api.SysCpCabinConfigClientApi;
import com.red.circle.other.inner.model.cmd.sys.SysCpCabinConfigQryCmd;
import com.red.circle.other.inner.model.dto.sys.SysCpCabinConfigDTO;
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;

/**
 * CP小屋配置
 *
 * @author zongpubin on 2024/1/29
 */
@Validated
@RestController
@RequestMapping(value = SysCpCabinConfigClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class SysCpCabinConfigClientEndpoint implements SysCpCabinConfigClientApi {

  private final SysCpCabinConfigClientService sysCpCabinConfigClientService;

  @Override
  public ResultResponse<PageResult<SysCpCabinConfigDTO>> getCpCabin(SysCpCabinConfigQryCmd query) {
    return ResultResponse.success(sysCpCabinConfigClientService.getCpCabin(query));
  }

  @Override
  public ResultResponse<Void> addCpCabin(SysCpCabinConfigDTO param) {
    sysCpCabinConfigClientService.addCpCabin(param);
    return ResultResponse.success();
  }

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

  @Override
  public ResultResponse<Void> updateCpCabin(SysCpCabinConfigDTO param) {
    sysCpCabinConfigClientService.updateCpCabin(param);
    return ResultResponse.success();
  }
}
