JavaWeb CURD 一鍵生成

本文將給您介紹 AppAdmin 後臺管理系統開發框架。 
AppAdmin後臺管理系統開發框架是一套Java開發的整合了當前衆多比較流行的Java後臺開發框架的系統,使用H5響應式佈局。 
整合了 spring + springMVC + hibernate (JPA) + shiro + ehcache 等框架,功能包括基本的系統管理、權限、角色、存儲(oss、本地、ftp)、緩存、站內信、smtp郵件發送、微信公衆號開發、富文本內容使用文件存儲的統一實現等等衆多模塊,持續更新開發中。

主流技術框架

  • Spring 
    • Spring是一個開源框架,Spring是於2003 年興起的一個輕量級的Java 開發框架,由OP)。簡單來說,Spring是一個分層的JavaSE/EEfull-stack(一站式) 輕量級開源框架。
  • SpringMVC 
    • Spring MVC屬於SpringFrameWork的後續產品,已經融合在Spring Web Flow裏面。Spring 框架提供了構建 Web 應用程序的全功能 MVC 模塊。使用 Spring 可插入的 MVC 架構,從而在使用Spring進行WEB開發時,可以選擇使用Spring的SpringMVC框架或集成其他MVC開發框架,如Struts1,Struts2等。
  • JPA(Hiberntea) 
    • JPA全稱Java Persistence API。JPA通過JDK 5.0註解或XML描述對象-關係表的映射關係,並將運行期的實體對象持久化到數據庫中。
    • JPA是需要Provider來實現其功能的,Hibernate就是JPA Provider中很強的一個,應該說無人能出其右。從功能上來說,JPA就是Hibernate功能的一個子集。Hibernate 從3.2開始,就開始兼容JPA。Hibernate3.2獲得了Sun TCK的JPA(Java Persistence API) 兼容認證。
    • 只要熟悉Hibernate或者其他ORM框架,在使用JPA時會發現其實非常容易上手。例如實體對象的狀態,在Hibernate有自由、持久、遊離三種,JPA裏有new,managed,detached,removed,明眼人一看就知道,這些狀態都是一一對應的。再如flush方法,都是對應的,而其他的再如說Query query = manager.createQuery(sql),它在Hibernate裏寫法上是session,而在JPA中變成了manager,所以從Hibernate到JPA的代價應該是非常小的。
    • 在ORM的領域中,看來JPA已經是王道,規範就是規範。在各大廠商的支持下,JPA的使用開始變得廣泛。
  • C3P0數據源 
    • 這是一個開源的JDBC連接池,它實現了數據源和JNDI綁定,支持JDBC3規範和JDBC2的標準擴展。目前使用它的開源項目有Hibernate,Spring等。
  • Freemarker 
    • FreeMarker是一款模板引擎: 即一種基於模板和要改變的數據, 並用來生成輸出文本(HTML網頁、電子郵件、配置文件、源代碼等)的通用工具。 它不是面向最終用戶的,而是一個Java類庫,是一款程序員可以嵌入他們所開發產品的組件。
    • FreeMarker是免費的,基於Apache許可證2.0版本發佈。其模板編寫爲FreeMarker Template Language(FTL),屬於簡單、專用的語言。需要準備數據在真實編程語言中來顯示,比如數據庫查詢和業務運算, 之後模板顯示已經準備好的數據。在模板中,主要用於如何展現數據, 而在模板之外注意於要展示什麼數據。
  • Jetty服務器 
    • Jetty 是一個開源的servlet容器,它爲基於Java的web容器,例如JSP和servlet提供運行環境。Jetty是使用Java語言編寫的,它的API以一組JAR包的形式發佈。開發人員可以將Jetty容器實例化成一個對象,可以迅速爲一些獨立運行(stand-alone)的Java應用提供網絡和web連接。
  • Apache Shiro 
    • 這是一個強大易用的 Java 安全框架,提供了認證、授權、加密和會話管理功能,可爲任何應用提供安全保障-從命令行應用、移動應用到大型網絡及企業應用。
  • JCaptcha 
    • 這是一個開源的用來生成圖形驗證碼的 Java 開源組件,使用起來也是非常的簡單方便。
  • JackSon Json 
    • 這是一個 Java 用來處理 JSON 格式數據的類庫,性能非常好。
  • EhCache 
    • EhCache 是一個純Java的進程內緩存框架,具有快速、精幹等特點,是Hibernate中默認的CacheProvider。
  • MemoryCache 
    • MemoryCache 是一個使用內存作爲緩存的技術。
  • dom4j 
    • dom4j是一個Java的XML API,是jdom的升級品,用來讀寫XML文件的。dom4j是一個十分優秀的JavaXML API,具有性能優異、功能強大和極其易使用的特點,它的性能超過sun公司官方的dom技術,同時它也是一個開放源代碼的軟件,可以在SourceForge上找到它。在IBM developerWorks上面還可以找到一篇文章,對主流的Java XML API進行的性能、功能和易用性的評測,所以可以知道dom4j無論在哪個方面都是非常出色的。如今可以看到越來越多的Java軟件都在使用dom4j來讀寫XML,特別值得一提的是連Sun的JAXM也在用dom4j。這已經是必須使用的jar包, Hibernate也用它來讀寫配置文件。
  • POI 
    • Apache POI是Apache軟件基金會的開放源碼函式庫,POI提供API給Java程序對Microsoft Office格式檔案讀和寫的功能。
  • xstream 
    • Xstream是一種OXMapping 技術,是用來處理XML文件序列化的框架,在將javaBean序列化,或將XML文件反序列化的時候,不需要其它輔助類和映射文件,使得XML序列化不再繁瑣。

技術特色

  • 配置註解化、properties化、xml化 
    • 系統中有的配置通過properties文件實現【數據庫、定時任務等】,有的配置通過xml實現【系統業務設置】,其他的框架機制上的配置則通過註解實現【控制器、業務層、數據訪問層、實體類等】。
  • JPA Criteria查詢封裝 
    • 總所周知,使用Hibernate查詢有很多種方式,可以使用Hibernate提供的HQL(hibernate query language)語言,還可以使用JPA標準的JPQL(Java Persistence Query Language)語言,還可以使用原生的數據庫SQL語言。
    • SQL在效率、統計、需要使用特殊技巧的時候起到了很大的作用,但是相對比較難寫。
    • HQL和JPQL類似,只是JPQL是標準,HQL是Hibernate查詢語言,所以倆者之間選擇JPQL,在遇到一些稍微複雜的問題時可以使用JPQL查詢。
    • 此外,系統中85%以上都是使用JPA提供的另外一套查詢機制,Criteria查詢方式。這種方式的特點是完全面向對象的查詢,即使純粹沒有學過任何類SQL語言的開發者,只要Java學得好,面向對象的思想夠深,看懂Criteria查詢是很簡單的。
    • 高度抽取公用方法,查詢,篩選,排序,分頁等機制全部使用公用方法支持。通過泛型機制、配合少量反射技術實現公用方法的類型嚴格檢測。
  • 系統存儲插件化 
    • 系統中當前支持三大中存儲方式的實現,即本地存儲、FTP存儲、阿里雲(OSS)存儲。
    • 三大存儲方式都通過插件化開發,系統啓動過程中,可通過後臺存儲插件相關功能處隨時修改存儲方式。
    • 本地存儲是默認方式。阿里雲存儲只需要您自行申請到OSS接口,將相關信息配置到後臺即可,FTP存儲同理。
  • 高度模塊化、子系統化 
    • 系統中分公用模塊、業務子模塊(buzz包下分類),比如微信模塊、開發工具模塊、演示實體模塊等。
  • CURD生成(開發利器) 
    • 開發工具模塊支持自定義實體名字、是否分頁、是否可批量刪除、是否樹形實體、可以配置實體的屬性(名字、類型、是否必須、是否支持搜索、是否支持字段排序、是否唯一)等。然後一鍵生成從後臺到前臺的所有代碼文件、頁面文件。
    • 支持字符串、整數、長整數、日期、布爾、枚舉、部分關聯類型、BigDecimal、以及自定義類型等屬性類型,關聯類型當前支持select方式、search方式實現。
    • 生成功能可支持分頁、curd、字段排序搜索、頁面驗證、後臺驗證、ajax驗證等等功能。
    • 此外,開發模塊高度二次開發化,使用主題開發方式,只要您的技術夠好或者更好,支持自定義模板主題,生成您自己的主題頁面。
  • Excel報表視圖基類實現 
    • 當您再需要導出excel的時候,只需要簡單的返回一個excel視圖,配置好您要導出的實體的字段列表,字段列長(可選)即可立即實現excel報表導出功能了。
  • 豐富的工具類 
    • Freemarker模板操作工具類
    • Http請求工具類
    • 圖片處理工具類
    • JackSon處理工具類
    • MemoryCache工具類
    • RSA加密工具類
    • WebUtils工具類【操作cookie等】
  • 多方面安全 
    • 自動實現Token機制
    • Shiro權限控制
    • resource等資源訪問控制

代碼片段

  • 屬性篩選封裝Filter類
public class Filter implements Serializable {
    /**
     * 運算符
     */
    public enum Operator {
        /** 等於 */
        eq,
        /** 不等於 */
        ne,
        /** 大於 */
        gt, greaterThan,
        /** 小於 */
        lt, lessThan,
        /** 大於等於 */
        ge, greaterThanOrEqualTo,
        /** 小於等於 */
        le, lessThanOrEqualTo,
        /** 相似 */
        like,
        /** 包含 */
        in,
        /** 爲Null */
        isNull,
        /** 不爲Null */
        isNotNull;
    }

    /** 默認是否忽略大小寫 */
    private static final boolean DEFAULT_IGNORE_CASE = false;

    /** 屬性 */
    private String property;

    /** 運算符 */
    private Operator operator;

    /** 值 */
    private Object value;

    /** 標識值value是否是另外一個屬性的名稱 */
    private Boolean isValuePropery = false;

    /** 是否忽略大小寫(僅針對value爲String類型情況有效) */
    private Boolean ignoreCase = DEFAULT_IGNORE_CASE;

    /**
     * 初始化一個新創建的Filter對象
     */
    private Filter() {
    }

    /**
     * 初始化一個新創建的Filter對象(使用Object value)
     * 
     * @param property
     *            屬性
     * @param operator
     *            運算符
     * @param isValuePropery
     *            value是否是屬性
     * @param value
     *            值
     */
    private Filter(String property, Operator operator, Object value, boolean isValuePropery) {
        this.property = property;
        this.operator = operator;
        this.value = value;
        this.isValuePropery = isValuePropery;
    }

    /**
     * 初始化一個新創建的Filter對象(使用Object value)
     * 
     * @param property
     *            屬性
     * @param operator
     *            運算符
     * @param value
     *            值
     * @param isValuePropery
     *            value是否是屬性
     * @param ignoreCase
     *            忽略大小寫
     */
    private Filter(String property, Operator operator, Object value, boolean isValuePropery, boolean ignoreCase) {
        this.property = property;
        this.operator = operator;
        this.value = value;
        this.ignoreCase = ignoreCase;
        this.isValuePropery = isValuePropery;
    }
}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • BaseDaoImpl中的addRestrictions方法
protected void addRestrictions(CriteriaQuery<T> criteriaQuery, List<Filter> filters) {
        if (criteriaQuery == null || filters == null || filters.isEmpty()) {
            return;
        }
        Root<T> root = getRoot(criteriaQuery);
        if (root == null) {
            return;
        }
        CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
        Predicate restrictions = criteriaQuery.getRestriction() != null ? criteriaQuery.getRestriction() : criteriaBuilder.conjunction();
        for (Filter filter : filters) {
            if (filter == null || StringUtils.isEmpty(filter.getProperty())) {
                continue;
            }
            if (filter.getOperator() == Operator.eq && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase() && filter.getValue() instanceof String) {
                    if (filter.valueIsPropery()) {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(criteriaBuilder.lower(root.<String> get(filter.getProperty())), criteriaBuilder.lower(root.<String> get(filter.getComparePropery()))));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(criteriaBuilder.lower(root.<String> get(filter.getProperty())), ((String) filter.getValue()).toLowerCase()));
                    }
                } else {
                    if (filter.valueIsPropery()) {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get(filter.getProperty()), root.get(filter.getComparePropery())));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.equal(root.get(filter.getProperty()), filter.getValue()));
                    }
                }
            } else if (filter.getOperator() == Operator.ne && filter.getValue() != null) {
                if (filter.getIgnoreCase() != null && filter.getIgnoreCase() && filter.getValue() instanceof String) {
                    if (filter.valueIsPropery()) {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.notEqual(criteriaBuilder.lower(root.<String> get(filter.getProperty())), criteriaBuilder.lower(root.<String> get(filter.getComparePropery()))));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.notEqual(criteriaBuilder.lower(root.<String> get(filter.getProperty())), ((String) filter.getValue()).toLowerCase()));
                    }
                } else {
                    if (filter.valueIsPropery()) {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.notEqual(root.get(filter.getProperty()), root.get(filter.getComparePropery())));
                    } else {
                        restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.notEqual(root.get(filter.getProperty()), filter.getValue()));
                    }
                }
            } else if (filter.getOperator() == Operator.gt && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.gt(root.<Number> get(filter.getProperty()), root.<Number> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.gt(root.<Number> get(filter.getProperty()), (Number) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.greaterThan && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThan(root.<Date> get(filter.getProperty()), root.<Date> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThan(root.<Date> get(filter.getProperty()), (Date) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.lt && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lt(root.<Number> get(filter.getProperty()), root.<Number> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lt(root.<Number> get(filter.getProperty()), (Number) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.lessThan && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThan(root.<Date> get(filter.getProperty()), root.<Date> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThan(root.<Date> get(filter.getProperty()), (Date) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.ge && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.ge(root.<Number> get(filter.getProperty()), root.<Number> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.ge(root.<Number> get(filter.getProperty()), (Number) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.greaterThanOrEqualTo && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(root.<Date> get(filter.getProperty()), root.<Date> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.greaterThanOrEqualTo(root.<Date> get(filter.getProperty()), (Date) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.le && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.le(root.<Number> get(filter.getProperty()), root.<Number> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.le(root.<Number> get(filter.getProperty()), (Number) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.lessThanOrEqualTo && filter.getValue() != null) {
                if (filter.valueIsPropery()) {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(root.<Date> get(filter.getProperty()), root.<Date> get(filter.getComparePropery())));
                } else {
                    restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.lessThanOrEqualTo(root.<Date> get(filter.getProperty()), (Date) filter.getValue()));
                }
            } else if (filter.getOperator() == Operator.like && filter.getValue() != null && filter.getValue() instanceof String) {
                restrictions = criteriaBuilder.and(restrictions, criteriaBuilder.like(root.<String> get(filter.getProperty()), (String) filter.getValue()));
            } else if (filter.getOperator() == Operator.in && filter.getValue() != null) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).in((Collection<?>) filter.getValue()));
            } else if (filter.getOperator() == Operator.isNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNull());
            } else if (filter.getOperator() == Operator.isNotNull) {
                restrictions = criteriaBuilder.and(restrictions, root.get(filter.getProperty()).isNotNull());
            }
        }
        criteriaQuery.where(restrictions);
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85
  • 86
  • 87
  • 88
  • 89
  • 90
  • 91
  • 92
  • 93
  • 94
  • 95
  • 96
  • 97
  • 98
  • 99
  • 100
  • 101
  • 102
  • FilePlugin
public class FilePlugin extends StoragePlugin implements ServletContextAware {

    /** servletContext */
    private ServletContext servletContext;

    public void setServletContext(ServletContext servletContext) {
        this.servletContext = servletContext;
    }

    @Override
    public String getName() {
        return "本地文件存儲";
    }

    @Override
    public String getVersion() {
        return "1.0";
    }

    @Override
    public String getAuthor() {
        return "APP";
    }

    @Override
    public String getSiteUrl() {
        return "http://";
    }

    @Override
    public String getInstallUrl() {
        return "file/install.jhtml";
    }

    @Override
    public String getUninstallUrl() {
        return "file/uninstall.jhtml";
    }

    @Override
    public String getSettingUrl() {
        return "file/setting.jhtml";
    }

    @Override
    public void upload(String path, File file, String contentType) {
        File destFile = new File(servletContext.getRealPath(path));
        try {
            FileUtils.moveFile(file, destFile);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    @Override
    public String getUrl(String path) {
        Setting setting = SettingUtils.get();
        return setting.getSiteUrl() + path;
    }

    @Override
    public List<FileInfo> browser(String path) {
        Setting setting = SettingUtils.get();
        List<FileInfo> fileInfos = new ArrayList<FileInfo>();
        File directory = new File(servletContext.getRealPath(path));
        if (directory.exists() && directory.isDirectory()) {
            for (File file : directory.listFiles()) {
                FileInfo fileInfo = new FileInfo();
                fileInfo.setName(file.getName());
                fileInfo.setUrl(setting.getSiteUrl() + path + file.getName());
                fileInfo.setIsDirectory(file.isDirectory());
                fileInfo.setSize(file.length());
                fileInfo.setLastModified(new Date(file.lastModified()));
                fileInfos.add(fileInfo);
            }
        }
        return fileInfos;
    }

}
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • WeiXinConfig中的refreshAccessToken方法
/***
     * 刷新 AccessToken
     */
    public void refreshAccessToken() {
        if (accessTokenRefreshingFlag.compareAndSet(false, true)) {
            try {
                // 記錄上一次 AccessToken 刷新時間
                long lastWeixinAccessTokenStartTime = weixinAccessTokenStartTime;
                // 設置新的 AccessToken 開始時間
                this.weixinAccessTokenStartTime = System.currentTimeMillis();
                // 刷新
                Map<String, Object> jsonMap = WeiXinHttpUtils.getJson(WeiXinURL.get_accessTokenUrl, this, null, null);
                if (jsonMap.containsKey("access_token")) {
                    // example: {"access_token":"ACCESS_TOKEN","expires_in":7200}
                    this.accessToken = jsonMap.get("access_token").toString().trim();
                    if (jsonMap.containsKey("expires_in")) {
                        this.expireTime = (Integer) jsonMap.get("expires_in") * 1000;
                    }
                    log.info("WeiXinConfig.refreshAccessToken() info. jsonMap = " + jsonMap.toString());
                } else if (jsonMap.containsKey("errcode")) {
                    // example: {"errcode":40013,"errmsg":"invalid appid"}
                    log.error("WeiXinConfig.refreshAccessToken() error. jsonMap = " + jsonMap.toString());
                    this.weixinAccessTokenStartTime = lastWeixinAccessTokenStartTime;
                } else {
                    // unknown
                    log.error("WeiXinConfig.refreshAccessToken() unknown error. jsonMap = " + jsonMap.toString());
                    this.weixinAccessTokenStartTime = lastWeixinAccessTokenStartTime;
                }
            } finally {
                accessTokenRefreshingFlag.set(false);
            }
        }
    }
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33

系統展示

高大上的登錄界面

登錄頁

開發工具基本配置

開發工具基本配置

CURD屬性配置

CURD屬性配置

CURD一鍵生成

CURD一鍵生成

角色編輯

角色編輯

微信設置

微信設置

微信狀態查看

微信狀態查看

樹形演示實體

樹形實體列表

管理員列表

管理員列表

存儲插件列表

存儲插件列表

二維碼生成

二維碼生成

以上僅僅是部分功能,很多列表頁面比較類似就不重複了。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章