package com.ruoyi.cron.vo;

import cn.hutool.core.collection.ListUtil;
import cn.hutool.crypto.SecureUtil;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;

import java.lang.reflect.Method;
import java.util.List;

@Data
public class CronTaskVo {

  @Setter(AccessLevel.NONE)
  private String id;

  private int order;

  private int group;

  private String name;


  private List<String> params = ListUtil.list(true);

  @Setter(AccessLevel.NONE)
  private String methodName;

  @JsonIgnore
  private Object bean;

  @JsonIgnore
  private Class<?> cls;

  @JsonIgnore
  private Method method;

  public void setMethod(Method method) {
    this.method =method;
    this.id = id(method);
    this.methodName = method.getName();
  }

  public static String id(Method method) {
    return SecureUtil.md5(method.toString());
  }




}
