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

import com.red.circle.common.business.core.enums.ApprovalStatusEnum;
import com.red.circle.common.business.core.enums.DataApprovalTypeEnum;
import com.red.circle.framework.dto.PageResult;
import com.red.circle.framework.dto.ResultResponse;
import com.red.circle.other.app.inner.service.approval.ApprovalUserSettingDataClientService;
import com.red.circle.other.inner.endpoint.approval.api.ApprovalUserSettingDataClientApi;
import com.red.circle.other.inner.model.cmd.approval.ApprovalDataCmd;
import com.red.circle.other.inner.model.cmd.approval.ApprovalOpsPageQryCmd;
import com.red.circle.other.inner.model.cmd.approval.ApprovalPhotoWallApprovalTableQryCmd;
import com.red.circle.other.inner.model.cmd.approval.ProfileApprovalContentCmd;
import com.red.circle.other.inner.model.dto.approval.ApprovalUserPhotoWallDTO;
import com.red.circle.other.inner.model.dto.approval.ApprovalUserSettingDataDTO;
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/5/25
 */
@Validated
@RestController
@RequestMapping(value = ApprovalUserSettingDataClientApi.API_PREFIX, produces = MediaType.APPLICATION_JSON_VALUE)
@RequiredArgsConstructor
public class ApprovalUserSettingDataClientEndpoint implements ApprovalUserSettingDataClientApi {

  private final ApprovalUserSettingDataClientService approvalUserSettingDataClientService;

  @Override
  public ResultResponse<Void> submitApproval(ProfileApprovalContentCmd cmd) {
    approvalUserSettingDataClientService.submitApproval(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> submitApprovalBatch(List<ProfileApprovalContentCmd> cmd) {

    approvalUserSettingDataClientService.submitApprovalBatch(cmd);

    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> updateStatus(ApprovalDataCmd cmd) {
    approvalUserSettingDataClientService.updateStatus(cmd);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> saveOrUpdate(Long userId, String sysOrigin,
      DataApprovalTypeEnum approveType) {
    approvalUserSettingDataClientService.saveOrUpdate(userId, sysOrigin, approveType);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> save(Long userId, String sysOrigin, DataApprovalTypeEnum approveType,
      ApprovalStatusEnum approvalStatus) {
    approvalUserSettingDataClientService.save(userId, sysOrigin, approveType, approvalStatus);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> saveBatch(Long userId, String sysOrigin,
      List<DataApprovalTypeEnum> approveTypes) {
    approvalUserSettingDataClientService.saveBatch(userId, sysOrigin, approveTypes);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Void> incrNotPassSize(Long userId, DataApprovalTypeEnum approveType) {
    approvalUserSettingDataClientService.incrNotPassSize(userId, approveType);
    return ResultResponse.success();
  }

  @Override
  public ResultResponse<Boolean> updateStatusMachineLabel(Long userId,
      ApprovalStatusEnum approvalStatus, DataApprovalTypeEnum approveType, String label) {

    return ResultResponse.success(
        approvalUserSettingDataClientService.updateStatusMachineLabel(userId, approvalStatus,
            approveType, label)
    );
  }

  @Override
  public ResultResponse<Boolean> isPass(Long userId, DataApprovalTypeEnum approvalType) {
    return ResultResponse.success(
        approvalUserSettingDataClientService.isPass(userId, approvalType)
    );
  }

  @Override
  public ResultResponse<Boolean> isNoneOrNotPass(Long userId, DataApprovalTypeEnum approvalType) {
    return ResultResponse.success(
        approvalUserSettingDataClientService.isNoneOrNotPass(userId, approvalType)
    );
  }

  @Override
  public ResultResponse<PageResult<ApprovalUserPhotoWallDTO>> pageUserDetailsPhotoWall(
      ApprovalPhotoWallApprovalTableQryCmd query) {
    return ResultResponse.success(
        approvalUserSettingDataClientService.pageUserDetailsPhotoWall(query));
  }

  @Override
  public ResultResponse<PageResult<ApprovalUserSettingDataDTO>> listOps(
      ApprovalOpsPageQryCmd qryCmd) {
    return ResultResponse.success(approvalUserSettingDataClientService.listOps(qryCmd));
  }

}
