為了快速開發(fā), 我做了這個(gè)框架, 可以使用注解開發(fā)菜單頁面, 風(fēng)格統(tǒng)一, 也可以單獨(dú)寫頁面, 展示獨(dú)特的內(nèi)容.
閑話不多說, 先上項(xiàng)目地址和圖片, 喜歡的可以下載下來研究研究.
Git地址:https://github.com/huhuanan/m
固定的后臺(tái)樣式, 由于沒有美工, 只能先湊合一下了.
簡要說明
- 后臺(tái)框架是自己寫的, 沒有使用目前流行的框架, 僅使用了一些工具jar.
- 框架是比較老舊的WebProject模式, 個(gè)人覺得比較通俗易懂.
- 后臺(tái)框架是JAVA語言, 僅支持一個(gè)Mysql數(shù)據(jù)庫.
- 使用的開發(fā)工具是MyEclipse CI 2018.8.0
- 后臺(tái)頁面是單頁面模式, 使用的是iView樣式.
先說這么多吧, 文件下載完后開始配置, 讓它運(yùn)行起來看看效果.
1. 文件目錄, 建議放到MyEclipse的Workspaces目錄下
2. 使用MyEclipse導(dǎo)入項(xiàng)目
3. 項(xiàng)目結(jié)構(gòu) (導(dǎo)入后需要修改項(xiàng)目jre配置)
- 紅框內(nèi)的是我寫的框架源文件, 最好不要改,后續(xù)我會(huì)持續(xù)更新.
- src文件夾里是配置文件和測(cè)試用的main方法.
- web是網(wǎng)站根目錄, web/custom文件夾下是自定義樣式和js的文件.
- 項(xiàng)目使用JDK1.8和Tomcat8.5.
4. 配置文件和創(chuàng)建數(shù)據(jù)庫
修改src/dbconfig.properties的數(shù)據(jù)庫鏈接地址
創(chuàng)建數(shù)據(jù)庫 (不用創(chuàng)建表, 配置table_schema會(huì)自動(dòng)創(chuàng)建表和插入默認(rèn)數(shù)據(jù))
CREATE SCHEMA mdb CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci;
5. 運(yùn)行
部署運(yùn)行Tomcat就可以看到效果了
訪問http://127.0.0.1/admin
默認(rèn) 用戶名admin 密碼123456
框架有很多開發(fā)便利的功能
- 列表和編輯頁面可以用注解編寫
@ActionFormMeta(title="管理員組信息",
rows={
@FormRowMeta(fields={
@FormFieldMeta(field = "model.oid", type = FormFieldType.HIDDEN),
@FormFieldMeta(title="名稱",field="model.name",type=FormFieldType.TEXT,hint="請(qǐng)輸入名稱",span=16),
@FormFieldMeta(title="排序",titleWidth=80,field="model.sort",type=FormFieldType.INT,hint="請(qǐng)輸入排序",span=8)
}),
@FormRowMeta(fields={@FormFieldMeta(title="描述", field = "model.description", type = FormFieldType.TEXTAREA,rows=5,hint="請(qǐng)輸入描述")})
},
buttons={
@FormButtonMeta(title = "保存", url = "action/manageAdminGroup/doSave",success=FormSuccessMethod.REFRESH_OTHER)
},
others={
@FormOtherMeta(title = "菜單權(quán)限", url = "action/manageGroupMenuLink/toList?method=groupMenuLinkData",
linkField=@LinkFieldMeta(field="params[adminGroup.oid]",valueField="model.oid")
)
}
)
public ActionResult toEdit() throws Exception{
if(null!=model&&!StringUtil.isSpace(model.getOid())){
model=ModelQueryUtil.getModel(model);
}
return getFormResult(this,ActionFormPage.EDIT);
}
/**
* 查詢列表
* @return
*/
@ActionTableMeta(dataUrl = "action/manageAdminGroup/adminGroupData",
modelClass="manage.model.AdminGroup",
searchField="name,description",searchHint="請(qǐng)輸入名稱或者描述",
cols = {
@ActionTableColMeta(field = "oid", title = "",type=TableColType.INDEX),
@ActionTableColMeta(field = "name", title = "名稱", width=130,sort=true,initSort=TableColSort.DESC),
@ActionTableColMeta(field = "description", title = "描述", width=200),
@ActionTableColMeta(field = "sort", title = "排序", width=100,align="left"),
@ActionTableColMeta(field = "status", title = "狀態(tài)",type=TableColType.STATUS,power="manage_system_power",dictionaryType="status",align="center"),
@ActionTableColMeta(field = "oid",title="操作",width=220,align="center",buttons={
@ButtonMeta(title="修改", event = ButtonEvent.MODAL,modalWidth=700, url = "action/manageAdminGroup/toEdit",
params={@ParamMeta(name = "model.oid", field="oid")},success=SuccessMethod.REFRESH,style=ButtonStyle.NORMAL,
power="manage_system_power"
),
@ButtonMeta(title="菜單權(quán)限", event = ButtonEvent.MODAL,modalWidth=800, url = "action/manageGroupMenuLink/setGroupMenuPage",
params={@ParamMeta(name = "model.adminGroup.oid", field="oid")}, style=ButtonStyle.NONE,
power="manage_system_power"
),
@ButtonMeta(title="操作權(quán)限", event = ButtonEvent.MODAL,modalWidth=350, url = "action/manageAdminGroupPower/setAdminGroupPowerPage",
params={@ParamMeta(name = "model.adminGroup.oid", field="oid")}, style=ButtonStyle.NONE,success=SuccessMethod.MUST_REFRESH,
power="manage_system_power"
),
})
},
querys = {
@QueryMeta(field = "name", name = "名稱", type = QueryType.TEXT, hint="請(qǐng)輸入名稱", likeMode=true),
@QueryMeta(field = "description", name = "描述", type = QueryType.TEXT, hint="請(qǐng)輸入描述", likeMode=true)
},
buttons = {
@ButtonMeta(title="新增", event = ButtonEvent.MODAL,modalWidth=700, url = "action/manageAdminGroup/toEdit",
success=SuccessMethod.REFRESH,style=ButtonStyle.NORMAL,
power="manage_system_power"
)
}
)
public JSONMessage adminGroupData(){
return getListDataResult(null);
}
點(diǎn)篩選可以篩選查詢
- 接口也可以使用注解編寫, 可在后臺(tái)調(diào)試
@DocumentMeta(
method=@DocumentMethodMeta(title="獲取數(shù)據(jù)字典",description=""),
params={@DocumentParamMeta(name="model.type",description="數(shù)據(jù)字典類型",type=FieldType.STRING,length=20,notnull=true)
}
)
public JSONMessage getDict(){
JSONMessage result=new JSONMessage();
try {
result.push("list", DictionaryUtil.get(model.getType()));
result.push("code", 0);
} catch (Exception e) {
result.push("code", 1);
result.push("msg", e.getMessage());
if(RuntimeData.getDebug()) e.printStackTrace();
}
return result;
}
數(shù)據(jù)庫操作可根據(jù)對(duì)象來執(zhí)行
//插入一個(gè)model 還有更新和刪除
ModelUpdateUtil.insertModel(model);
//更新指定屬性 還有根據(jù)條件更新一批數(shù)據(jù)
ModelUpdateUtil.updateModel(model,new String[]{"name","value","sort"});
//根據(jù)model的注解檢查model屬性 還有根據(jù)屬性組合判斷唯一的方法
ModelCheckUtil.check(model);
//查詢返回List<model>
ModelQueryList.getModelList(DictionaryData.class,
new String[]{"oid","name"},
null,
QueryCondition.eq("status", "0")
);
還要很多很多功能, 以后會(huì)慢慢講解, 有興趣的可以關(guān)注我, 或者加我微信.
想了解哪些方面的功能, 也可以加我微信, 我會(huì)提前編輯文章.
后續(xù)我會(huì)在源碼上做個(gè)小例子, 讓大家可以更快的了解開發(fā)的便利.