优化部门显示
This commit is contained in:
parent
06eab586b9
commit
57cde9c15d
File diff suppressed because one or more lines are too long
|
|
@ -15,6 +15,7 @@
|
||||||
*/
|
*/
|
||||||
package com.smallchill.common.config;
|
package com.smallchill.common.config;
|
||||||
|
|
||||||
|
import com.smallchill.common.intercept.DefaultSelectFactory;
|
||||||
import com.smallchill.common.plugins.GlobalPlugin;
|
import com.smallchill.common.plugins.GlobalPlugin;
|
||||||
import com.smallchill.core.constant.Cst;
|
import com.smallchill.core.constant.Cst;
|
||||||
import com.smallchill.core.interfaces.IConfig;
|
import com.smallchill.core.interfaces.IConfig;
|
||||||
|
|
@ -52,6 +53,9 @@ public class WebConfig implements IConfig {
|
||||||
//设定grid工厂类
|
//设定grid工厂类
|
||||||
me.setDefaultGridFactory(new JqGridFactory());
|
me.setDefaultGridFactory(new JqGridFactory());
|
||||||
|
|
||||||
|
//设定select工厂类
|
||||||
|
me.setDefaultSelectFactory(new DefaultSelectFactory());
|
||||||
|
|
||||||
//设定shiro工厂类
|
//设定shiro工厂类
|
||||||
me.setDefaultShiroFactory(new DefaultShiroFactroy());
|
me.setDefaultShiroFactory(new DefaultShiroFactroy());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ public class SelectDeptIntercept extends QueryInterceptor {
|
||||||
|
|
||||||
public void queryBefore(AopContext ac) {
|
public void queryBefore(AopContext ac) {
|
||||||
if (ShiroKit.lacksRole(ConstShiro.ADMINISTRATOR)) {
|
if (ShiroKit.lacksRole(ConstShiro.ADMINISTRATOR)) {
|
||||||
String depts = ShiroKit.getUser().getDeptId() + "," + ShiroKit.getUser().getSubDepts();
|
String depts = ShiroKit.getUser().getSuperDepts() + "," + ShiroKit.getUser().getDeptId() + "," + ShiroKit.getUser().getSubDepts();
|
||||||
String condition = "where id in (" + StrKit.removeSuffix(depts, ",") + ")";
|
String condition = "where id in (" + StrKit.removeSuffix(depts, ",") + ")";
|
||||||
ac.setCondition(condition);
|
ac.setCondition(condition);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ public class ShiroUser implements Serializable {
|
||||||
private String name;// 姓名
|
private String name;// 姓名
|
||||||
private List<String> roleList;// 角色集
|
private List<String> roleList;// 角色集
|
||||||
private String roles;// 角色集
|
private String roles;// 角色集
|
||||||
|
private Object superDepts;// 上级部门集合
|
||||||
private Object subDepts;// 子部门集合
|
private Object subDepts;// 子部门集合
|
||||||
private Object subRoles;// 子角色集合
|
private Object subRoles;// 子角色集合
|
||||||
private Object subUsers;// 子账号集合
|
private Object subUsers;// 子账号集合
|
||||||
|
|
@ -55,18 +56,36 @@ public class ShiroUser implements Serializable {
|
||||||
this.roleList = roleList;
|
this.roleList = roleList;
|
||||||
this.roles = CollectionKit.join(roleList.toArray(), ",");
|
this.roles = CollectionKit.join(roleList.toArray(), ",");
|
||||||
|
|
||||||
// 递归查找子部门id集合
|
// 递归查找上级部门id集合
|
||||||
String deptSql;
|
String superDeptSql;
|
||||||
String subDepts = null;
|
String superDepts = null;
|
||||||
if (Func.isOracle()) {
|
if (Func.isOracle()) {
|
||||||
deptSql = "select wm_concat(ID) subDepts from (select ID,PID,SIMPLENAME from TFW_DEPT start with ID in (#{join(deptIds)}) connect by prior ID=PID order by ID) a where a.ID not in (#{join(deptIds)})";
|
superDeptSql = "select wm_concat(ID) subDepts from (select ID,PID,SIMPLENAME from TFW_DEPT start with ID in (#{join(deptIds)}) connect by prior PID=ID order by ID) a where a.ID not in (#{join(deptIds)})";
|
||||||
subDepts = Db.queryStr(deptSql, Paras.create().set("deptIds", deptId.toString().split(",")));
|
superDepts = Db.queryStr(superDeptSql, Paras.create().set("deptIds", deptId.toString().split(",")));
|
||||||
} else {
|
} else {
|
||||||
String[] arr = deptId.toString().split(",");
|
String[] arr = deptId.toString().split(",");
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
for (String deptid : arr) {
|
for (String deptid : arr) {
|
||||||
deptSql = "select queryChildren(#{deptid},'tfw_dept') as subdepts";
|
superDeptSql = "select queryParent(#{deptid},'tfw_dept') as superdepts";
|
||||||
String str = Db.queryStr(deptSql, Paras.create().set("deptid", deptid));
|
String str = Db.queryStr(superDeptSql, Paras.create().set("deptid", deptid));
|
||||||
|
sb.append(str).append(",");
|
||||||
|
}
|
||||||
|
superDepts = StrKit.removeSuffix(sb.toString(), ",");
|
||||||
|
}
|
||||||
|
this.superDepts = superDepts;
|
||||||
|
|
||||||
|
// 递归查找子部门id集合
|
||||||
|
String subDeptSql;
|
||||||
|
String subDepts = null;
|
||||||
|
if (Func.isOracle()) {
|
||||||
|
subDeptSql = "select wm_concat(ID) subDepts from (select ID,PID,SIMPLENAME from TFW_DEPT start with ID in (#{join(deptIds)}) connect by prior ID=PID order by ID) a where a.ID not in (#{join(deptIds)})";
|
||||||
|
subDepts = Db.queryStr(subDeptSql, Paras.create().set("deptIds", deptId.toString().split(",")));
|
||||||
|
} else {
|
||||||
|
String[] arr = deptId.toString().split(",");
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
for (String deptid : arr) {
|
||||||
|
subDeptSql = "select queryChildren(#{deptid},'tfw_dept') as subdepts";
|
||||||
|
String str = Db.queryStr(subDeptSql, Paras.create().set("deptid", deptid));
|
||||||
sb.append(str).append(",");
|
sb.append(str).append(",");
|
||||||
}
|
}
|
||||||
subDepts = StrKit.removeSuffix(sb.toString(), ",");
|
subDepts = StrKit.removeSuffix(sb.toString(), ",");
|
||||||
|
|
@ -167,6 +186,14 @@ public class ShiroUser implements Serializable {
|
||||||
this.deptName = deptName;
|
this.deptName = deptName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Object getSuperDepts() {
|
||||||
|
return superDepts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuperDepts(Object superDepts) {
|
||||||
|
this.superDepts = superDepts;
|
||||||
|
}
|
||||||
|
|
||||||
public Object getSubDepts() {
|
public Object getSubDepts() {
|
||||||
return subDepts;
|
return subDepts;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,6 @@ import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
import com.smallchill.core.constant.Const;
|
import com.smallchill.core.constant.Const;
|
||||||
import com.smallchill.core.constant.ConstShiro;
|
import com.smallchill.core.constant.ConstShiro;
|
||||||
import com.smallchill.core.constant.Cst;
|
|
||||||
import com.smallchill.core.exception.NoPermissionException;
|
import com.smallchill.core.exception.NoPermissionException;
|
||||||
import com.smallchill.core.exception.NoUserException;
|
import com.smallchill.core.exception.NoUserException;
|
||||||
import com.smallchill.core.interfaces.IQuery;
|
import com.smallchill.core.interfaces.IQuery;
|
||||||
|
|
@ -314,7 +313,7 @@ public class BladeController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected Object paginate(String source){
|
protected Object paginate(String source){
|
||||||
return basepage(null, source, Cst.me().getDefaultPageFactory());
|
return basepage(null, source, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -332,7 +331,7 @@ public class BladeController {
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
protected Object paginate(String slaveName, String source){
|
protected Object paginate(String slaveName, String source){
|
||||||
return basepage(slaveName, source, Cst.me().getDefaultPageFactory());
|
return basepage(slaveName, source, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -120,11 +120,6 @@ public class Cst {
|
||||||
*/
|
*/
|
||||||
private ICURD defaultCURDFactory = new CURDInterceptor();
|
private ICURD defaultCURDFactory = new CURDInterceptor();
|
||||||
|
|
||||||
/**
|
|
||||||
* 默认分页工厂类
|
|
||||||
*/
|
|
||||||
private IQuery defaultPageFactory = new QueryInterceptor();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 默认查询工厂类
|
* 默认查询工厂类
|
||||||
*/
|
*/
|
||||||
|
|
@ -281,14 +276,6 @@ public class Cst {
|
||||||
this.defaultCURDFactory = defaultCURDFactory;
|
this.defaultCURDFactory = defaultCURDFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IQuery getDefaultPageFactory() {
|
|
||||||
return defaultPageFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setDefaultPageFactory(IQuery defaultPageFactory) {
|
|
||||||
this.defaultPageFactory = defaultPageFactory;
|
|
||||||
}
|
|
||||||
|
|
||||||
public IQuery getDefaultQueryFactory() {
|
public IQuery getDefaultQueryFactory() {
|
||||||
return defaultQueryFactory;
|
return defaultQueryFactory;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -214,28 +214,6 @@ public class Db {
|
||||||
return getDbManager().queryListStr(sqlTemplate, paras);
|
return getDbManager().queryListStr(sqlTemplate, paras);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询aop返回单条数据
|
|
||||||
* @param sqlTemplate
|
|
||||||
* @param paras
|
|
||||||
* @param ac
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static Map selectOne(String sqlTemplate, Map<String, Object> param, AopContext ac) {
|
|
||||||
return getDbManager().selectOne(sqlTemplate, param, ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**查询aop返回多条数据
|
|
||||||
* @param sqlTemplate
|
|
||||||
* @param paras
|
|
||||||
* @param ac
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("rawtypes")
|
|
||||||
public static List<Map> selectList(String sqlTemplate, Map<String, Object> param, AopContext ac) {
|
|
||||||
return getDbManager().selectList(sqlTemplate, param, ac);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询aop返回单条数据
|
/** 查询aop返回单条数据
|
||||||
* @param sqlTemplate
|
* @param sqlTemplate
|
||||||
* @param paras
|
* @param paras
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ import org.beetl.sql.core.SQLManager;
|
||||||
import org.beetl.sql.core.SQLReady;
|
import org.beetl.sql.core.SQLReady;
|
||||||
|
|
||||||
import com.smallchill.core.aop.AopContext;
|
import com.smallchill.core.aop.AopContext;
|
||||||
import com.smallchill.core.constant.Cst;
|
|
||||||
import com.smallchill.core.interfaces.ILoader;
|
import com.smallchill.core.interfaces.ILoader;
|
||||||
import com.smallchill.core.interfaces.IQuery;
|
import com.smallchill.core.interfaces.IQuery;
|
||||||
import com.smallchill.core.plugins.connection.ConnectionPlugin;
|
import com.smallchill.core.plugins.connection.ConnectionPlugin;
|
||||||
|
|
@ -283,26 +282,6 @@ public class DbManager {
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 查询aop返回单条数据
|
|
||||||
* @param sqlTemplate
|
|
||||||
* @param paras
|
|
||||||
* @param ac
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public Map selectOne(String sqlTemplate, Map<String, Object> param, AopContext ac) {
|
|
||||||
return selectOne(sqlTemplate, param, ac, Cst.me().getDefaultQueryFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**查询aop返回多条数据
|
|
||||||
* @param sqlTemplate
|
|
||||||
* @param paras
|
|
||||||
* @param ac
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public List<Map> selectList(String sqlTemplate, Map<String, Object> param, AopContext ac) {
|
|
||||||
return selectList(sqlTemplate, param, ac, Cst.me().getDefaultQueryFactory());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 查询aop返回单条数据
|
/** 查询aop返回单条数据
|
||||||
* @param sqlTemplate
|
* @param sqlTemplate
|
||||||
* @param paras
|
* @param paras
|
||||||
|
|
|
||||||
|
|
@ -167,7 +167,7 @@ public class CacheController extends BaseController {
|
||||||
List<Map<String, Object>> dict = CacheKit.get(DICT_CACHE, DICT_COMBO + code,
|
List<Map<String, Object>> dict = CacheKit.get(DICT_CACHE, DICT_COMBO + code,
|
||||||
new ILoader() {
|
new ILoader() {
|
||||||
public Object load() {
|
public Object load() {
|
||||||
return Db.selectList("select num as \"id\",name as \"text\" from TFW_DICT where code=#{code} and num>0", Paras.create().set("code", code), new AopContext());
|
return Db.selectList("select num as \"id\",name as \"text\" from TFW_DICT where code=#{code} and num>0", Paras.create().set("code", code));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -251,7 +251,7 @@ public class CacheController extends BaseController {
|
||||||
List<Map<String, Object>> diy = CacheKit.get(DIY_CACHE, DIY_SELECT + source,
|
List<Map<String, Object>> diy = CacheKit.get(DIY_CACHE, DIY_SELECT + source,
|
||||||
new ILoader() {
|
new ILoader() {
|
||||||
public Object load() {
|
public Object load() {
|
||||||
return Db.selectList(Md.getSql(source), map, new AopContext());
|
return Db.selectList(Md.getSql(source), map);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
@ -310,7 +310,7 @@ public class CacheController extends BaseController {
|
||||||
List<Map<String, Object>> dict = CacheKit.get(DICT_CACHE, DICT_CODE + id,
|
List<Map<String, Object>> dict = CacheKit.get(DICT_CACHE, DICT_CODE + id,
|
||||||
new ILoader() {
|
new ILoader() {
|
||||||
public Object load() {
|
public Object load() {
|
||||||
return Db.selectList("select CODE from TFW_DICT where id=#{id}",Paras.create().set("id", id), new AopContext());
|
return Db.selectList("select CODE from TFW_DICT where id=#{id}",Paras.create().set("id", id));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return json(dict);
|
return json(dict);
|
||||||
|
|
|
||||||
|
|
@ -63,17 +63,18 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function zTreeBeforeClick(treeId, treeNode, clickFlag) {
|
function zTreeBeforeClick(treeId, treeNode, clickFlag) {
|
||||||
var id=treeNode.id;
|
@ if(shiro.hasRole("administrator")) {
|
||||||
if(id==""){
|
var id=treeNode.id;
|
||||||
exwhere="";
|
if(id==""){
|
||||||
searchGrid();
|
exwhere="";
|
||||||
return;
|
searchGrid();
|
||||||
}
|
return;
|
||||||
else{
|
}
|
||||||
exwhere="{\"pId_equal\":\""+id+"\",\"or_id_equal\":\""+id+"\"}";
|
else{
|
||||||
searchGrid();
|
exwhere="{\"pId_equal\":\""+id+"\",\"or_id_equal\":\""+id+"\"}";
|
||||||
}
|
searchGrid();
|
||||||
|
}
|
||||||
|
@ }
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user