package com.muyu.domain;

import com.muyu.common.core.annotation.Excel;
import com.muyu.common.core.web.domain.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;

import java.util.function.Supplier;

/**
 * 预警策略对象 warn_strategy
 *
 * @author muyu
 * @date 2024-09-20
 */

@Data
@Setter
@Getter
@SuperBuilder
@NoArgsConstructor
@AllArgsConstructor
@TableName("warn_strategy")
public class WarnStrategy extends BaseEntity{
    private static final long serialVersionUID = 1L;

    /** 策略id */
    @Schema(type = "Long",description = "策略id")
    @TableId( type = IdType.AUTO)
    private Long warnStrategyId;

    /** 策略名称 */
    @Schema(type = "String",description = "策略名称")
    @Excel(name = "策略名称")
    private String strategyName;

    /** 报文模版id */
    @Schema(type = "Integer",description = "报文模版id")
    @Excel(name = "报文模版id")
    private Integer messageTemplateId;

    /** 车辆类型id */
    @Schema(type = "Long",description = "车辆类型id")
    @Excel(name = "车辆类型id")
    private Long vehicleTypeId;



    public static WarnStrategy updateBuilder(WarnStrategy warnStrategy, Supplier<Long> supplier) {
        return WarnStrategy.builder()
                .warnStrategyId(supplier.get())
                .vehicleTypeId(warnStrategy.getVehicleTypeId())
                .strategyName(warnStrategy.getStrategyName())
                .vehicleTypeId(warnStrategy.getVehicleTypeId())
                .messageTemplateId(warnStrategy.getMessageTemplateId())
                .build();
    }


    @Override
    public String toString() {
        return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
            .append("id", getWarnStrategyId())
            .append("vehicleTypeId", getVehicleTypeId())
            .append("strategyName", getStrategyName())
            .append("messageTemplateId", getMessageTemplateId())
            .toString();
    }
}
