package com.gree.mall.manager.enums.contract;

import cn.hutool.core.util.EnumUtil;
import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import com.google.common.collect.Lists;
import com.gree.mall.manager.enums.base.BaseEnum;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.Map;

@Getter
@AllArgsConstructor(access = AccessLevel.PRIVATE)
public enum FieldTypeEnum implements BaseEnum {
    YYYYMMDD("YYYYMMDD","日期"),
    YYYYMMDDTIME("YYYYMMDDTIME","日期时间"),
    YYYY("YYYY","年"),
    MM("MM","月"),
    DD("DD","日"),
    BANK_LINK_NAME("BANK_LINK_NAME","银行户名"),
    BANK_DEPOSIT("BANK_DEPOSIT","开户行名称"),
    BANK_ACCOUNT("BANK_ACCOUNT","银行卡号"),
    CUSTOM("CUSTOM", "自定义"),
    WEBSIT_NAME("WEBSIT_NAME", "网点名称"),
    WEBSIT_ID("WEBSIT_ID", "网点编号"),
    ADDRESS("ADDRESS", "地址"),
    EMAIL("EMAIL", "邮箱"),
    TEL("TEL", "电话"),
    FAX("FAX", "传真"),
    ZIP_CODE("ZIP_CODE", "邮编"),
    ;

    @JsonValue
    @EnumValue
    private final String key;
    private final String remark;

    /**
     * 网点模板字段
     * @return
     */
    public static Map<String, Object> websitList() {
        Map<String, Object> fieldMap = EnumUtil.getNameFieldMap(FieldTypeEnum.class, "value");
        ArrayList<FieldTypeEnum> fieldTypeEnums = Lists.newArrayList(CUSTOM, YYYYMMDD, YYYYMMDDTIME, YYYY, MM, DD, WEBSIT_ID,
                WEBSIT_NAME, ADDRESS, BANK_LINK_NAME, BANK_DEPOSIT, BANK_ACCOUNT, EMAIL, TEL, FAX, ZIP_CODE);
        Map<String, Object> map = new LinkedHashMap<>();
        for (FieldTypeEnum typeEnum : fieldTypeEnums) {
            map.put(typeEnum.getKey(), fieldMap.get(typeEnum.getKey()));
        }
        return map;
    }
}
