package com.yueqian.xingyun.sc.vo.purchase.receive;

import com.lframework.starter.common.utils.StringUtil;
import com.lframework.starter.web.core.utils.ApplicationUtil;
import com.yueqian.xingyun.sc.entity.ReceiveSheet;
import com.yueqian.xingyun.sc.service.purchase.ReceiveSheetService;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;

@Data
public class UpdateReceiveSheetVo extends CreateReceiveSheetVo {

  private static final long serialVersionUID = 1L;

  /**
   * 收货单ID
   */
  @Schema(description = "收货单ID", requiredMode = Schema.RequiredMode.REQUIRED)
  @NotBlank(message = "收货单ID不能为空！")
  private String id;

  @Override
  public void validate() {

    ReceiveSheetService receiveSheetService = ApplicationUtil.getBean(ReceiveSheetService.class);
    ReceiveSheet receiveSheet = receiveSheetService.getById(this.getId());

    this.validate(!StringUtil.isBlank(receiveSheet.getPurchaseOrderId()));
  }
}
