package com.muyu.rule.common.domain.resp;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.muyu.rule.common.domain.RuleEngine;
import com.muyu.rule.common.domain.RuleEngineVersion;
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 org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.List;

/**
 * @Author：张承志
 * @Package：com.muyu.etl.common.domain.resp
 * @Project：cloud-etl
 * @name：EtlRuleResp
 * @Date：2024/8/21 21:57
 */
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Tag(name = "规则信息相应对象", description = "负责规则信息查询的响应结果")
public class EtlRuleResp {


    /**
     *主键
     */
    @TableId(value = "id" , type = IdType.AUTO)
    private Long id ;

    /** 规则名称 */
    private String name ;

    /** 引擎编码  */
    private String code;


    /** 规则作用域 */
    private String regionName;

    /** 状态 0正常 1停用 */
    private String status ;

    /** 是否激活 */
    private String open ;

    /** 规则引擎描述 */
    private String ruleDesc;


    @Schema(description = "创建人", defaultValue = "muyu", type = "String")
    private String createBy;




    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Schema(description = "创建时间", defaultValue = "2024-8-1 0:22:36", type = "Date")
    private Date createTime;


    List<RuleEngineVersion> versionList;


public static EtlRuleResp  etlRuleRespBuilder(RuleEngine etlRule){

    return  EtlRuleResp.builder()
            .id(etlRule.getId())
            .code(etlRule.getCode())
            .name(etlRule.getName())
            .status(etlRule.getStatus())
            .open(etlRule.getOpen())
            .regionName(etlRule.getRegionName())
            .ruleDesc(etlRule.getRuleDesc())
            .createBy(etlRule.getCreateBy())
            .createTime(etlRule.getCreateTime()).build();



}

}
