1.專案Package的命名原則:
-全小寫domain命名法
package tw.lewishome.webapp.base.security;
1.類別(Class)、介面(interface)的命名原則:
public class Stringify {
// code here
}
2.介面(interface) 的命名原則:(僅提供參考)
public interface HttpRequestHeaderService {
/** Character sets that are acceptable */
Private static final String ACCEPT_CHARSET = "Accept-Charset";
}
3.介面實作(Implement) 的命名原則:(僅提供參考)
public interface HttpRequestHeaderServiceImple {
/** Character sets that are acceptable */
Private static final String ACCEPT_CHARSET = "Accept-Charset";
}
4.常變數(static final)、實體常數(instance)的命名原則:
public class Counter {
/** 最大值 */
static final int MAX_SIZE = 100;
/** 最小值 */
static final int MIN_SIZE = 100;
}
6.屬性(Field)、方法(Method)的命名原則:
public class Counter {
/** 最大值 */
int maxSize = 100;
/** 姓 */
String firstName;
/**
* Method 說明
*
* @param execution 執行參數說明
* @return boolean 回傳參數說明
* @throws java.lang.Exception
*/
public boolean addExecution(Execution execution) throws Exception {
// method code here
}
}
landingImg.css
landing.img
capLock.js
homePage.html
上面所說的命名方式是一種"慣例",也就是說不遵守慣例的話也可以編譯,程式也可以執行,但使用Lombok或 QDSL等,自動產生程式碼的套件時,依經驗偶爾會遇到問題。另一個經驗是系統執行在Windows系統(開發環境),程式檔案名稱使用大小寫是不會有問題,但換作系統執行在Linix等系統,就會產生找不到程式檔案的錯誤。
本專案前端使用Thymeleaf模板引擎,配合Spring Boot JPA作為後端基礎為
其中sample為功能分類目錄名稱(全部小寫),testPage 為html 頁面名稱(小寫開頭)。
2.Controller:(後端控制) => 接收前端使用者的請求與處理並傳遞資料的程式(URL Mapping或End point):
tw.lewishome.webapp
├── WebappApplication.java
├── ServletInitializer.java
├── SystemServletContextListener.java (系統啟動相關程序)
├── SystemApplicationListener.java (系統啟動程序)
├── SystemApplicationStartingEvent.java (系統啟動程序)
├── GlobalConstants.java (系統基礎常數定義) https://ithelp.ithome.com.tw/articles/10398567
│
├── exception (待續 Exception處理)
│ ├── GlobalExceptionHandler.java (待續 全域Exception處理)
│ ├── ControllerExceptionHandler.java (待續 Controller Exception處理)
│ └── RestControllerExceptionHandler.java (待續 Restful Exception處理)
│
├── base
│ ├── async (Async 多工) https://ithelp.ithome.com.tw/articles/10398753
│ ├── cachecaffeine (Caffeine 快取暫存處理) https://ithelp.ithome.com.tw/articles/10398777
│ ├── cacheredis (Redis 快取暫存處理) https://ithelp.ithome.com.tw/articles/10398777
│ ├── schedule (Schedule 排程作業) https://ithelp.ithome.com.tw/articles/10398729
│ ├── security (Security 設定與認證) https://ithelp.ithome.com.tw/articles/10398800
│ └── utility (工具類程式) https://ithelp.ithome.com.tw/articles/10398475
│ ├── common (一般工具類程式) https://ithelp.ithome.com.tw/articles/10398475
│ └── excelpoi (待續 Excel相關工具類程式)
│
├── database (資料庫設計與存取) https://ithelp.ithome.com.tw/articles/10398629
│ ├── audit (資料庫設計與存取)
│ └── primary (資料庫設計與存取)
│ ├── entity (資料庫設計與存取)
│ │ └── SysMenuDataEntity.java (系統選單Menu資料)
│ ├── repository
│ │ └── SysParmDataRepository.java (系統選單Menu資料存取)
│ └── service
│ └── SysParmDataService.java (系統參數資料存取)
│
└── page (new 前端URL相關控制處理)
│
├── HomePageController.java (增加URL處理程序)
│
├── PageConstants.java (前端服務處理的使用常變數)
│
├── base (new 前端服務處理使用基本物件)
│ ├── model
│ │ ├── PageAjaxResultModel.java (Ajax回傳共用物件)
│ │ ├── PageMenuItemModel.java (系統選單Menu共用物件)
│ │ ├── PageTableEditModel.java (系統Table 資料編輯相關共用物件)
│ │ ├── PageTableListModel.java (系統Table 資料清單相關共用物件)
│ │ └── PageTableButtonModel.java (系統Table 操作按鈕相關共用物件)
│ └── service (new 前端服務處理使用基本程序)
│ ├── PageController.java (前端服務處理Controller基本程式)
│ └── PageMenuService.java (取得前端系統選單Menu資料)
│
├── system (待續 前端服務處理系統設定維護與查詢 sub Menu)
│ ├── controller
│ ├── restfulapi
│ ├── model
│ └── service
│
├── general (待續 前端服務處理一般系統功能 sub Menu)
│ ├── controller
│ ├── restfulapi
│ ├── model
│ └── service
│
└── ???(待續 其他功能,通常是一組sub Menu)
├── controller
├── restfulapi
├── model
└── service
前端URL相關 Html相關文件(主要使用thymeleaf template)
src/main/resources
├── static/ (一般靜態資料)
│ ├── css
│ │ ├──landingImg.css
│ │ ├── system (待續 配合page結構)
│ │ ├── general(待續 配合page結構)
│ │ └── ???
│ │
│ ├── img
│ │ ├──landing.jpg
│ │ ├── system (待續 配合page結構)
│ │ ├── general(待續 配合page結構)
│ │ └── ???
│ │
│ └── js
│ ├── system (待續 配合page結構)
│ ├── general (待續 配合page結構)
│ └── ???
│
└── templates/ (thymeleaf template)
├── fragment (thymeleaf layout)
│ ├── layout.html (待續 共用頁面排版)
│ ├── layoutSide.html (待續 共用頁面排版side Menu)
│ ├── layoutTop.html (待續 共用頁面排版Top Menu)
│ ├── sideMenu.html (待續 共用頁面side Menu)
│ └── topMenu.html (待續 共用頁面Top Menu)
│
├── home (登入相關頁面)
│ ├── homePage.html (登入頁面)
│ └── landingPage.html (登入成功頁面)
│
├── page
│ ├── system (待續 配合page結構)
│ ├── general (待續 配合page結構)
│ └── ??? (待續 配合page結構)
│
├── report (待續 配合報表設計)
│
└── template (待續 配合文件樣板設計)