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

import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.approval.ApprovalDynamicClientService;
import com.red.circle.other.inner.endpoint.dynamic.api.ApprovalDynamicClientApi;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicCmd;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicContentCmd;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDynamicQryCmd;
import com.red.circle.other.inner.model.dto.approval.ApprovalDynamicDTO;
import java.util.Set;
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 zongpubin on 2024/1/19
 */
@Validated
@RestController
@RequestMapping(value = ApprovalDynamicClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ApprovalDynamicClientEndpoint implements ApprovalDynamicClientApi {

  private final ApprovalDynamicClientService approvalDynamicClientService;

  @Override
  public ResultResponse<PageResult<ApprovalDynamicDTO>> pageApprovalDynamic(ApprovalDynamicQryCmd query) {
    return ResultResponse.success(approvalDynamicClientService.pageApprovalDynamic(query));
  }

  @Override
  public ResultResponse<Void> approvalPass(Set<Long> ids) {
    approvalDynamicClientService.approvalPass(ids);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> approvalNotPass(ApprovalDynamicCmd approvalDynamicCmd) {
    approvalDynamicClientService.approvalNotPass(approvalDynamicCmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> save(ApprovalDynamicContentCmd cmd) {
    approvalDynamicClientService.save(cmd);
    return ResultResponse.success();
  }
}
