package com.zbf.system.domain;

import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.zbf.common.annotation.Excel;
import com.zbf.common.core.domain.BaseEntity;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.apache.poi.ss.usermodel.IndexedColors;

import java.lang.reflect.Field;

/**
 * 仓库库区对象 t_base_storage_area
 *
 * @author tony
 * @date 2024-06-16
 */
@TableName(resultMap = "com.zbf.system.mapper.TBaseStorageAreaMapper.TBaseStorageAreaResult")
public class TBaseStorageArea extends BaseEntity {
    private static final long serialVersionUID = 1L;

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

    /**
     * 库区编号
     */
    @Excel(name = "库区编号")
    private String storageAreaId;

    /**
     * 库区名称
     */
    @Excel(name = "库区名称", required = true, headerColor = IndexedColors.RED)
    private String storageAreaName;

    /**
     * 库区简称
     */
    @Excel(name = "库区简称")
    private String storageAreaShortName;

    /**
     * 拼音简称
     */
    @Excel(name = "拼音简称", required = true, headerColor = IndexedColors.RED)
    private String pyName;

    /**
     * 仓库编号
     */
    @Excel(name = "仓库编号", required = true, headerColor = IndexedColors.RED)
    private String storageId;

    /**
     * 排序
     */
    @Excel(name = "排序")
    private Long sort;

    /**
     * 库区状态
     */
    @Excel(name = "库区状态", comboDictType = "common_status")
    private Long status;

    /**
     * 选中的数据
     */
    private String[] selectIds;

    public static JSONArray getColumnsJson() {
        JSONArray columns = new JSONArray();
        Field[] fields = TBaseStorageArea.class.getDeclaredFields();
        int key = 0;
        for (Field field : fields) {
            Excel excelAnnotation = field.getAnnotation(Excel.class);
            if (excelAnnotation != null) {
                JSONObject column = new JSONObject();
                column.put("seq", key++);
                column.put("key", field.getName());
                column.put("label", excelAnnotation.name());
                column.put("visible", true);  // 假设所有列默认都是可见的
                column.put("columnName", field.getName());  // 设置列ID
                columns.put(column);
            }
        }
        return columns;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public void setStorageAreaId(String storageAreaId) {
        this.storageAreaId = storageAreaId;
    }

    public String getStorageAreaId() {
        return storageAreaId;
    }

    public void setStorageAreaName(String storageAreaName) {
        this.storageAreaName = storageAreaName;
    }

    public String getStorageAreaName() {
        return storageAreaName;
    }

    public void setStorageAreaShortName(String storageAreaShortName) {
        this.storageAreaShortName = storageAreaShortName;
    }

    public String getStorageAreaShortName() {
        return storageAreaShortName;
    }

    public void setPyName(String pyName) {
        this.pyName = pyName;
    }

    public String getPyName() {
        return pyName;
    }

    public void setStorageId(String storageId) {
        this.storageId = storageId;
    }

    public String getStorageId() {
        return storageId;
    }

    public void setSort(Long sort) {
        this.sort = sort;
    }

    public Long getSort() {
        return sort;
    }

    public void setStatus(Long status) {
        this.status = status;
    }

    public Long getStatus() {
        return status;
    }

    public String[] getSelectIds() {
        return selectIds;
    }

    public void setSelectIds(String[] selectIds) {
        this.selectIds = selectIds;
    }

    @Override
    public String toString() {
        return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
                .append("id", getId())
                .append("storageAreaId", getStorageAreaId())
                .append("storageAreaName", getStorageAreaName())
                .append("storageAreaShortName", getStorageAreaShortName())
                .append("pyName", getPyName())
                .append("storageId", getStorageId())
                .append("sort", getSort())
                .append("status", getStatus())
                .append("remark", getRemark())
                .append("createTime", getCreateTime())
                .append("createBy", getCreateBy())
                .append("updateTime", getUpdateTime())
                .append("updateBy", getUpdateBy())
                .toString();
    }
}


















