parent
d49b9c2aa3
commit
2af137ae02
@ -0,0 +1,40 @@
|
||||
package com.dsideal.resource.Test;
|
||||
|
||||
import com.dsideal.resource.Plugin.YamlProp;
|
||||
import com.dsideal.resource.ResApplication;
|
||||
import com.jfinal.kit.Prop;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.dialect.MysqlDialect;
|
||||
import com.jfinal.plugin.hikaricp.HikariCpPlugin;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class testDb {
|
||||
public static void main(String[] args) {
|
||||
//加载配置文件
|
||||
String configFile = "application_dev.yaml";
|
||||
Prop PropKit = new YamlProp(configFile);
|
||||
HikariCpPlugin masterPlugin = new HikariCpPlugin(PropKit.get("mysql.jdbcUrl"), PropKit.get("mysql.user"),
|
||||
PropKit.get("mysql.password").trim(), PropKit.get("mysql.driverClassName"));
|
||||
masterPlugin.start();
|
||||
|
||||
// 配置ActiveRecord插件
|
||||
ActiveRecordPlugin masterArp = new ActiveRecordPlugin("master", masterPlugin);
|
||||
masterArp.setDialect(new MysqlDialect());
|
||||
|
||||
//遍历sql目录下所有的sql文件
|
||||
File sqlDir;
|
||||
String basePath = ResApplication.class.getResource("/").getPath();
|
||||
sqlDir = new File(basePath + "/Sql");
|
||||
File[] sqlFiles = sqlDir.listFiles();
|
||||
for (File sqlFile : sqlFiles != null ? sqlFiles : new File[0]) {
|
||||
//只加载.sql文件
|
||||
if (sqlFile.getName().indexOf(".sql") > 0) {
|
||||
masterArp.addSqlTemplate("/Sql/" + sqlFile.getName());
|
||||
}
|
||||
}
|
||||
masterArp.start();
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1 +0,0 @@
|
||||
d
|
@ -0,0 +1,21 @@
|
||||
-- 菜单命名空间
|
||||
#namespace("menu")
|
||||
|
||||
-- 查询菜单的ids
|
||||
#sql("selectMenuForIds")
|
||||
select t1.menu_id,t1.menu_name,t1.parent_id,t1.sort_id,t1.url,t1.memo,t1.create_time,t1.update_ts,t1.level_id,
|
||||
(select count(1) from t_base_menu as t2 where t1.menu_id=t2.parent_id) as is_leaf
|
||||
from t_base_menu as t1 where t1.menu_id in
|
||||
(
|
||||
#for(x:ids)
|
||||
#(for.index == 0 ? "" : ",") #para(x)
|
||||
#end
|
||||
) order by t1.sort_id
|
||||
#end
|
||||
|
||||
-- 人员根据职务+分管工作可见的菜单
|
||||
#sql("selectMenuByPersonId")
|
||||
select distinct menu_id from t_base_principalship_menu as t1 inner join t_person_duty_charge as t2 on t1.duties_id=t2.`duties_id`
|
||||
and t1.in_charge_id=t2.`in_charge_id` where t2.person_id=? and t2.b_use=1
|
||||
#end
|
||||
#end
|
Loading…
Reference in new issue