package com.yueqian.xingyun.sc.bo.stock.warning;

import com.lframework.starter.web.core.bo.BaseBo;
import com.lframework.starter.web.core.utils.ApplicationUtil;
import com.yueqian.xingyun.sc.entity.ProductStockWarningNotify;
import com.lframework.starter.web.inner.entity.SysNotifyGroup;
import com.lframework.starter.web.inner.service.system.SysNotifyGroupService;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
public class GetProductStockWarningNotifyBo extends BaseBo<ProductStockWarningNotify> {

  /**
   * 消息通知组ID
   */
  @Schema(description = "消息通知组ID")
  private String id;

  /**
   * 消息通知组名称
   */
  @Schema(description = "消息通知组名称")
  private String name;

  /**
   * 消息通知组状态
   */
  @Schema(description = "消息通知组状态")
  private Boolean available;

  public GetProductStockWarningNotifyBo(ProductStockWarningNotify dto) {
    super(dto);
  }

  @Override
  protected void afterInit(ProductStockWarningNotify dto) {
    SysNotifyGroupService sysNotifyGroupService = ApplicationUtil.getBean(
        SysNotifyGroupService.class);

    SysNotifyGroup sysNotifyGroup = sysNotifyGroupService.findById(dto.getNotifyGroupId());
    this.id = sysNotifyGroup.getId();
    this.name = sysNotifyGroup.getName();
    this.available = sysNotifyGroup.getAvailable();
  }
}
