package com.red.circle.console.adapter.app.approval;


import com.red.circle.common.business.core.enums.ApprovalStatusEnum;
import com.red.circle.common.business.core.enums.DataApprovalTypeEnum;
import com.red.circle.console.app.service.app.approval.ApprovalPhotoWallService;
import com.red.circle.console.infra.annotations.OpsOperationReqLog;
import com.red.circle.framework.web.controller.BaseController;
import com.red.circle.other.inner.model.cmd.user.ApprovalContentCmd;
import com.red.circle.other.inner.model.cmd.user.ApprovalPhotoWallCmd;
import java.util.List;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 照片墙审批
 *
 * @author pengliang on 2020/9/22
 */
@RestController
@RequestMapping("/approval/photo/wall")
@AllArgsConstructor
public class ApprovalPhotoWallRestController extends BaseController {

  private final ApprovalPhotoWallService approvalPhotoWallService;

  @OpsOperationReqLog("照片墙审批-通过")
  @PostMapping("/pass")
  public void approvalPass(@RequestBody List<ApprovalContentCmd> params) {

    approvalPhotoWallService.approval(new ApprovalPhotoWallCmd()
        .setParams(params)
        .setApprovalUserId(getReqUserId())
        .setApprovalStatus(ApprovalStatusEnum.PASS.name())
        .setApprovalType(DataApprovalTypeEnum.PHOTO_WALL.name()));
  }

  @OpsOperationReqLog("照片墙审批-不通过")
  @PostMapping("/not/pass")
  public void approvalNotPass(@RequestBody List<ApprovalContentCmd> params) {
    approvalPhotoWallService.approval(new ApprovalPhotoWallCmd()
        .setParams(params)
        .setApprovalUserId(getReqUserId())
        .setApprovalStatus(ApprovalStatusEnum.NOT_PASS.name())
        .setApprovalType(DataApprovalTypeEnum.PHOTO_WALL.name()));
  }
}
