This commit is contained in:
zhuangqian 2016-11-10 11:21:36 +08:00
parent be96918921
commit 90337d5f0f
13 changed files with 67 additions and 18 deletions

View File

@ -341,7 +341,7 @@ public class CacheController extends BladeController {
String pid = "";
List<Map> record = Db.selectList("select PID from TFW_ROLE where id in (" + roleId + ")");
for (Map p : record) {
if (!Func.isEmpty(p.get("PID"))) {
if (!Func.isEmpty(p.get("PID")) && Func.toInt(p.get("PID")) > 0) {
pid += p.get("PID").toString() + ",";
}
}

View File

@ -132,6 +132,10 @@ public class RoleController extends BaseController{
@RequestMapping(KEY_SAVE)
public AjaxResult save() {
Role role = mapping(PREFIX, Role.class);
Object pid = role.getPid();
if (null == pid) {
role.setPid(0);
}
boolean temp = service.save(role);
if (temp) {
CacheKit.removeAll(ROLE_CACHE);

View File

@ -73,7 +73,8 @@ public class ZTreeController extends BladeController {
String [] arr = val.split(",");
for(Map<String, Object> map : list){
for(String v : arr){
if(Func.toStr(map.get(key)).equals(v) && !v.equals("0")){
//if(Func.toStr(map.get(key)).equals(v) && !v.equals("0")){
if(Func.toStr(map.get(key)).equals(v)){
map.put("checked", "true");
}
}
@ -97,7 +98,7 @@ public class ZTreeController extends BladeController {
final Map<String, Object> modelOrMap = params;
List<Map<String, Object>> list = CacheKit.get(DICT_CACHE, DICT_ZTREE_LIST + type,
List<Map<String, Object>> list = CacheKit.get(getCacheName(type), DICT_ZTREE_LIST + type,
new ILoader() {
public Object load() {
return Db.selectList(sqlSource, modelOrMap);
@ -147,13 +148,27 @@ public class ZTreeController extends BladeController {
} else if (type.equals("dept")) {
sql = "select ID as \"id\",PID as \"pId\",SIMPLENAME as \"name\",(case when (pId=0 or pId is null) then 'true' else 'false' end) \"open\" from TFW_DEPT";
} else if (type.equals("role")) {
sql = "select ID as \"id\",0 as \"pId\",NAME as \"name\",(case when (pId=0 or pId is null) then 'true' else 'false' end) \"open\" from TFW_ROLE";
sql = "select ID as \"id\",PID as \"pId\",NAME as \"name\",(case when (pId=0 or pId is null) then 'true' else 'false' end) \"open\" from TFW_ROLE";
} else {
sql = Md.getSql(source);
}
return sql;
}
private String getCacheName(String type){
String cacheName = DICT_CACHE;
if (type.equals("user")) {
cacheName = USER_CACHE;
} else if (type.equals("dept")) {
cacheName = DEPT_CACHE;
} else if (type.equals("role")) {
cacheName = ROLE_CACHE;
} else {
cacheName = DIY_CACHE;
}
return cacheName;
}
private IQuery getIntercept(String type) {
IQuery intercept = Cst.me().getDefaultQueryFactory();
if (type.indexOf("dict") >= 0) {

View File

@ -4,6 +4,6 @@ select d.*,(select name from tfw_dict where id=d.pId) PNAME from tfw_dict d
diy
===
select 0 as "id", 0 as "pId",'top' as "name" from dual
select 0 as "id", 0 as "pId",'top' as "name",'true' as "open" from dual
union
select ID as "id", pId as "pId",name as "name" from TFW_DICT
select ID as "id", pId as "pId",name as "name",'false' as "open" from TFW_DICT

View File

@ -1,3 +1,9 @@
list
===
select r.*,d.simpleName DEPTNAME,(select name from tfw_role where id=r.pId) PNAME from tfw_role r left join tfw_dept d on r.deptId=d.id
select r.*,d.simpleName DEPTNAME,(select name from tfw_role where id=r.pId) PNAME from tfw_role r left join tfw_dept d on r.deptId=d.id
diy
===
select 0 as "id", 0 as "pId",'top' as "name",'true' as "open" from dual
union
select ID as "id", pId as "pId",name as "name",(case when (pId=0 or pId is null) then 'true' else 'false' end) as "open" from TFW_ROLE

View File

@ -4,6 +4,6 @@ select d.*,(select name from tfw_dict where id=d.pId) PNAME from tfw_dict d
diy
===
select 0 as "id", 0 as "pId",'top' as "name" from dual
select 0 as "id", 0 as "pId",'top' as "name",'true' as "open" from dual
union
select ID as "id", pId as "pId",name as "name" from TFW_DICT
select ID as "id", pId as "pId",name as "name",'false' as "open" from TFW_DICT

View File

@ -1,3 +1,9 @@
list
===
select r.*,d.simpleName DEPTNAME,(select name from tfw_role where id=r.pId) PNAME from tfw_role r left join tfw_dept d on r.deptId=d.id
select r.*,d.simpleName DEPTNAME,(select name from tfw_role where id=r.pId) PNAME from tfw_role r left join tfw_dept d on r.deptId=d.id
diy
===
select 0 as "id", 0 as "pId",'top' as "name",'true' as "open" from dual
union
select ID as "id", pId as "pId",name as "name",(case when (pId=0 or pId is null) then 'true' else 'false' end) as "open" from TFW_ROLE

View File

@ -1,7 +1,11 @@
package ${packageName}.service.impl;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.smallchill.core.base.service.BaseService;
import com.smallchill.core.plugins.dao.Md;
import com.smallchill.core.toolbox.Paras;
import ${packageName}.model.${modelName};
import ${packageName}.service.${modelName}Service;
@ -12,4 +16,10 @@ import ${packageName}.service.${modelName}Service;
${"@"}Service
public class ${modelName}ServiceImpl extends BaseService<${modelName}> implements ${modelName}Service{
${"@"}Override
${"@"}SuppressWarnings("unchecked")
public Map<String, Object> findOne(Object id) {
return Md.selectUnique("${lowerModelName}.findOne", Paras.create().set("id", id), Map.class);
}
}

View File

@ -1,5 +1,7 @@
package ${packageName}.service;
import java.util.Map;
import com.smallchill.core.base.service.IService;
import ${packageName}.model.${modelName};
@ -8,5 +10,7 @@ import ${packageName}.model.${modelName};
* ${func.getTime()}
*/
public interface ${modelName}Service extends IService<${modelName}>{
Map<String, Object> findOne(Object id);
}

View File

@ -1,3 +1,7 @@
list
===
select * from ${tableName}
select * from ${tableName}
findOne
===
select * from ${tableName} where ${pkName} = #{id}

View File

@ -4,10 +4,10 @@
<!-- 表单 -->
@ var _table="tfw_role";
@ var _col=[
@ {name:"排序",index:"num",type:"text",newline:true,length:3},
@ {name:"上级角色",index:"pid", type:"selectRole",value:pId!,newline:false,length:3},
@ {name:"排序",index:"num",type:"number",newline:true,length:3},
@ {name:"上级角色",index:"pid", type:"opentreeDiyRole",source:"role.diy",check:"radio",value:pId!0,newline:false,length:3},
@ {name:"角色名称",index:"name", type:"text",newline:true,length:3,required:"required"},
@ {name:"所在部门",index:"deptid", type:"selectDept",newline:false,length:3},
@ {name:"所在部门",index:"deptid", type:"selectDept",newline:false,length:3,required:"required"},
@ {name:"别名",index:"tips", type:"text",newline:true,length:8,required:"required"}
@ ];
@ include("/common/_curd/_add.html",{"col":_col,"table":_table}){}

View File

@ -5,10 +5,10 @@
@ var _table="tfw_role";
@ var _key="id";
@ var _col=[
@ {name:"排序",index:"num",type:"text",newline:true,length:3},
@ {name:"上级角色",index:"pid", type:"selectRole",newline:false,length:3},
@ {name:"排序",index:"num",type:"number",newline:true,length:3},
@ {name:"上级角色",index:"pid", type:"opentreeDiyRole",source:"role.diy",check:"radio",newline:false,length:3},
@ {name:"角色名称",index:"name", type:"text",newline:true,length:3,required:"required"},
@ {name:"所在部门",index:"deptid", type:"selectDept",newline:false,length:3},
@ {name:"所在部门",index:"deptid", type:"selectDept",newline:false,length:3,required:"required"},
@ {name:"别名",index:"tips", type:"text",newline:true,length:8,required:"required"}
@ ];
@ include("/common/_curd/_edit.html",{"col":_col,"table":_table,"key":_key}){}

View File

@ -94,7 +94,7 @@ var exwhere;
this.open(url + split + ids, ids);
return;
}
if (this.alias == "remove") {
if (this.alias == "remove" || this.alias == "del") {
if (rows == 0) {
layer_alert('请选择一条数据!', "warn");
return;