package cn.cerc.mis.other;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

public enum BookVersion {
    // 服务商
    ctService("admin"),
    // 专业版
    ctProfession("professional"),
    // 标准版
    ctStandard("standard"),
    // 基础版
    ctBasic("base"),
    // 旗舰版
    ctUltimate("ultimate"),
    // 普及版
    ctFree("free"),
    // 高级版
    ctAdvanced("advanced"),
    // ERP
    erp("erp"),
    // 所有版本, 仅权限判断专用，后须移除！
    ctAll("ctAll");

    private String code;

    BookVersion(String code) {
        this.code = code;
    }

    public String getVersionList() {
        String versions;
        switch (this) {
            case ctService:
                versions = "0,";
                break;
            case ctFree:
                versions = "5,";
                break;
            case ctBasic:
                versions = "5,3,";
                break;
            case ctStandard:
                versions = "5,3,2,";
                break;
            case ctProfession:
                versions = "5,3,2,1,";
                break;
            case ctAdvanced:
                versions = "5,3,2,1,6,";
                break;
            case ctUltimate:
                versions = "5,3,2,1,6,4,";
                break;
            case erp:
                versions = "7,";
                break;
            default:
                versions = null;
                break;
        }
        return versions;
    }

    public int getType(BookVersion version) {
        return version.ordinal();
    }

    public String getCode() {
        return this.code;
    }

    /**
     * 根据角标获取版本号
     */
    public static Map<Integer, String> getIndex() {
        Map<Integer, String> items = new LinkedHashMap<>();
        for (BookVersion k : BookVersion.values()) {
            if (k == ctAll) {
                continue;
            }
            items.put(k.ordinal(), k.getCode());
        }
        return items;
    }

    public static void main(String[] args) throws JsonProcessingException {
        Map<Integer, String> items = BookVersion.getIndex();
        System.out.println(new ObjectMapper().writeValueAsString(items));
    }

}
@@ -137,34 +137,8 @@
 r;%0A%0A
-import java.util.HashMap;%0A
 impo
@@ -188,16 +188,32 @@
 l.Map;%0A%0A
+/**%0A * %E5%B8%90%E5%A5%97%E7%89%88%E6%9C%AC%0A */%0A
 public e
@@ -239,13 +239,29 @@
    /
-/ %E6%9C%8D%E5%8A%A1%E5%95%86
+**%0A     * %E6%9C%8D%E5%8A%A1%E5%95%86%0A     */
 %0A   
@@ -285,18 +285,35 @@
 %22),%0A
+%0A
     /
-/ %E4%B8%93%E4%B8%9A%E7%89%88
+**%0A     * %E4%B8%93%E4%B8%9A%E7%89%88%0A     */
 %0A   
@@ -347,18 +347,35 @@
 %22),%0A
+%0A
     /
-/ %E6%A0%87%E5%87%86%E7%89%88
+**%0A     * %E6%A0%87%E5%87%86%E7%89%88%0A     */
 %0A   
@@ -403,18 +403,35 @@
 %22),%0A
+%0A
     /
-/ %E5%9F%BA%E7%A1%80%E7%89%88
+**%0A     * %E5%9F%BA%E7%A1%80%E7%89%88%0A     */
 %0A   
@@ -452,18 +452,35 @@
 %22),%0A
+%0A
     /
-/ %E6%97%97%E8%88%B0%E7%89%88
+**%0A     * %E6%97%97%E8%88%B0%E7%89%88%0A     */
 %0A   
@@ -508,19 +508,36 @@
 %22),%0A
+%0A
     /
-/
+**%0A     *
  %E6%99%AE%E5%8F%8A%E7%89%88%0A
+     */%0A
     
@@ -556,19 +556,36 @@
 %22),%0A
+%0A
     /
-/
+**%0A     *
  %E9%AB%98%E7%BA%A7%E7%89%88%0A
+     */%0A
     
@@ -612,18 +612,35 @@
 %22),%0A
+%0A
     /
-/ ERP
+**%0A     * ERP%0A     */
 %0A   
@@ -656,14 +656,23 @@
 %22),%0A
+%0A
     /
-/
+**%0A     *
  %E6%89%80%E6%9C%89%E7%89%88
@@ -688,16 +688,24 @@
 %E7%94%A8%EF%BC%8C%E5%90%8E%E9%A1%BB%E7%A7%BB%E9%99%A4%EF%BC%81%0A
+     */%0A
     ctAl

Update BookVersion.java