package com.muyu.domain.resp;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.muyu.common.core.annotation.Excel;
import com.muyu.domain.WarnRule;
import com.muyu.domain.WarnStrategy;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Tag(name = "规则列表", description = "规则列表")
public class WarnRuleResp {

    /** 策略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;

    /** 规则集合 */
    @Schema(type = "List",description = "规则集合")
    private List<WarnRule> warnRuleList;

    public static  WarnRuleResp build(WarnStrategy warnStrategy, List<WarnRule> warnRuleList){
       return WarnRuleResp.builder()
               .warnStrategyId(warnStrategy.getWarnStrategyId())
               .strategyName(warnStrategy.getStrategyName())
               .messageTemplateId(warnStrategy.getMessageTemplateId())
               .vehicleTypeId(warnStrategy.getVehicleTypeId())
               .warnRuleList(warnRuleList)
               .build();
    }

}
