package com.qiaoba.module.generator.entity;

import com.qiaoba.common.base.enums.BaseEnum;
import com.qiaoba.common.base.util.ArrayUtil;
import com.qiaoba.module.generator.constant.GenConstants;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.List;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2023/7/3 9:40
 */
@Data
@NoArgsConstructor
public class Generator implements Serializable {

    private GeneratorTable table;

    private List<GeneratorTableColumn> columns;

    private List<GeneratorTableColumn> queryColumns;

    private GeneratorTableColumn pkColumn;

    public boolean isBaseColumn(String column) {
        return ArrayUtil.contains(GenConstants.BASE_ENTITY, column);
    }

    public boolean isQueryColumn(String isQuery) {
        return BaseEnum.YES.getCode().equals(isQuery);
    }

    public boolean isPk(String isPk) {
        return BaseEnum.YES.getCode().equals(isPk);
    }

    public Generator(GeneratorTable table, List<GeneratorTableColumn> columns) {
        this.table = table;
        this.columns = columns;
    }
}
