|
|
|
@ -22,10 +22,11 @@ import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
public class MenuController extends BaseController {
|
|
|
|
|
//实例化model
|
|
|
|
|
MenuModel model =new MenuModel();
|
|
|
|
|
MenuModel model = new MenuModel();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:获取指定节点ID的信息
|
|
|
|
@ -35,9 +36,8 @@ public class MenuController extends BaseController {
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@IsNumericInterface({"menu_id"})
|
|
|
|
|
public void selectSingle(int menu_id)
|
|
|
|
|
{
|
|
|
|
|
Map<String,Object> map= model.selectSingle(menu_id);
|
|
|
|
|
public void selectSingle(int menu_id) {
|
|
|
|
|
Map<String, Object> map = model.selectSingle(menu_id);
|
|
|
|
|
renderJson(map);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -49,10 +49,9 @@ public class MenuController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
public void selectAll()
|
|
|
|
|
{
|
|
|
|
|
List<Record> dt= model.selectAll();
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt,dt.size()));
|
|
|
|
|
public void selectAll() {
|
|
|
|
|
List<Record> dt = model.selectAll();
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt, dt.size()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -65,10 +64,9 @@ public class MenuController extends BaseController {
|
|
|
|
|
@IsNumericInterface({"parent_id"})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@EmptyInterface({"parent_id"})
|
|
|
|
|
public void selectChildAsync(int parent_id)
|
|
|
|
|
{
|
|
|
|
|
List<Record> dt= model.selectChildAsync(parent_id);
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt,dt.size()));
|
|
|
|
|
public void selectChildAsync(int parent_id) {
|
|
|
|
|
List<Record> dt = model.selectChildAsync(parent_id);
|
|
|
|
|
renderJson(CommonUtil.renderJsonForLayUI(dt, dt.size()));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -78,52 +76,24 @@ public class MenuController extends BaseController {
|
|
|
|
|
* 时间:2018-12-22
|
|
|
|
|
*/
|
|
|
|
|
@Before({GET.class})
|
|
|
|
|
public void selectMenuByPerson()
|
|
|
|
|
{
|
|
|
|
|
public void selectMenuByPerson() {
|
|
|
|
|
//当前登录的人员
|
|
|
|
|
int identity_id=Integer.parseInt(getCookie("identity_id").trim());
|
|
|
|
|
String person_id=getCookie("person_id").trim();
|
|
|
|
|
Page<Record> page= model.selectMenuByPerson(identity_id);
|
|
|
|
|
if(page!=null && page.getList().size()>0)
|
|
|
|
|
{
|
|
|
|
|
int identity_id = Integer.parseInt(getCookie("identity_id").trim());
|
|
|
|
|
Page<Record> page = model.selectMenuByPerson(identity_id);
|
|
|
|
|
if (page != null && page.getList().size() > 0) {
|
|
|
|
|
List<IFayTreeNode> list = new ArrayList<>();
|
|
|
|
|
for(int i=0;i<page.getList().size();i++)
|
|
|
|
|
{
|
|
|
|
|
Record r=page.getList().get(i);
|
|
|
|
|
MenuBean m = new MenuBean(r.getStr("menu_id"),r.getStr("parent_id"),r.getStr("menu_name"),
|
|
|
|
|
r.getStr("url"),r.getStr("type"));
|
|
|
|
|
for (int i = 0; i < page.getList().size(); i++) {
|
|
|
|
|
Record r = page.getList().get(i);
|
|
|
|
|
MenuBean m = new MenuBean(r.getStr("menu_id"), r.getStr("parent_id"), r.getStr("menu_name"),
|
|
|
|
|
r.getStr("url"), r.getStr("type"));
|
|
|
|
|
list.add(m);
|
|
|
|
|
}
|
|
|
|
|
Object data = FayTreeUtil.getTreeInJsonObject(list);
|
|
|
|
|
//如果是超级管理员,那么应该有配置菜单的功能返回,或者默认就必须有这个返回
|
|
|
|
|
renderJson(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if(identity_id==1)
|
|
|
|
|
{
|
|
|
|
|
String data="[{\"children\":[{\"children\":[{\"treeObject\":{\"nodeParentId\":\"71\",\"menu_name\":\"菜单管理\",\"menu_id\":\"73\",\"parentId\":\"71\",\"url\":\"./pages/Menu/menuList.html\"}}],\"treeObject\":{\"nodeParentId\":\"1\",\"menu_name\":\"菜单设置\",\"menu_id\":\"71\",\"parentId\":\"1\",\"url\":\"#\"}}],\"treeObject\":{\"nodeParentId\":\"-1\",\"menu_name\":\"管理员菜单\",\"menu_id\":\"1\",\"parentId\":\"-1\",\"url\":\"#\"}}]";
|
|
|
|
|
renderJson(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
List<Record> menu_list=model.selectMenuByPersonId(person_id);
|
|
|
|
|
List<IFayTreeNode> list = new ArrayList<>();
|
|
|
|
|
for(int i=0;i<menu_list.size();i++)
|
|
|
|
|
{
|
|
|
|
|
Record r=menu_list.get(i);
|
|
|
|
|
MenuBean m = new MenuBean(r.getStr("menu_id"),r.getStr("parent_id"),r.getStr("menu_name"),
|
|
|
|
|
r.getStr("url"),r.getStr("type"));
|
|
|
|
|
list.add(m);
|
|
|
|
|
}
|
|
|
|
|
Object data = FayTreeUtil.getTreeInJsonObject(list);
|
|
|
|
|
renderJson(data);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 功能:增加菜单
|
|
|
|
|
* 作者:黄海
|
|
|
|
@ -131,23 +101,19 @@ public class MenuController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@EmptyInterface({"menu_name","url","memo","identity_ids"})
|
|
|
|
|
@IsNumericInterface({"parent_id","sort_id","for_school","for_bureau"})
|
|
|
|
|
@LengthInterface({"menu_name,1,32","memo,1,255"})
|
|
|
|
|
public void AddMenu(int parent_id,int sort_id,String identity_ids,String menu_name,String url,String memo,int for_school,int for_bureau)
|
|
|
|
|
{
|
|
|
|
|
int menu_id= model.AddMenu(parent_id,sort_id,menu_name,url,memo,identity_ids,for_school,for_bureau);
|
|
|
|
|
JSONObject map=new JSONObject();
|
|
|
|
|
map.put("menu_id",menu_id);
|
|
|
|
|
if(menu_id>0)
|
|
|
|
|
{
|
|
|
|
|
map.put("message","增加成功!");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
map.put("message","增加失败!");
|
|
|
|
|
}
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true,map));
|
|
|
|
|
@EmptyInterface({"menu_name", "url", "memo", "identity_ids"})
|
|
|
|
|
@IsNumericInterface({"parent_id", "sort_id", "for_school", "for_bureau"})
|
|
|
|
|
@LengthInterface({"menu_name,1,32", "memo,1,255"})
|
|
|
|
|
public void AddMenu(int parent_id, int sort_id, String identity_ids, String menu_name, String url, String memo, int for_school, int for_bureau) {
|
|
|
|
|
int menu_id = model.AddMenu(parent_id, sort_id, menu_name, url, memo, identity_ids, for_school, for_bureau);
|
|
|
|
|
JSONObject map = new JSONObject();
|
|
|
|
|
map.put("menu_id", menu_id);
|
|
|
|
|
if (menu_id > 0) {
|
|
|
|
|
map.put("message", "增加成功!");
|
|
|
|
|
} else {
|
|
|
|
|
map.put("message", "增加失败!");
|
|
|
|
|
}
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, map));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -159,10 +125,9 @@ public class MenuController extends BaseController {
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@IsNumericInterface({"menu_id"})
|
|
|
|
|
public void DeleteMenu(int menu_id)
|
|
|
|
|
{
|
|
|
|
|
public void DeleteMenu(int menu_id) {
|
|
|
|
|
model.DeleteMenu(menu_id);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true,"删除成功!"));
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, "删除成功!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -173,13 +138,12 @@ public class MenuController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@EmptyInterface({"menu_name","url","memo","identity_ids"})
|
|
|
|
|
@IsNumericInterface({"menu_id","sort_id","for_school","for_bureau"})
|
|
|
|
|
@LengthInterface({"menu_name,1,32","memo,1,255"})
|
|
|
|
|
public void UpdateMenu(int menu_id,int sort_id,String menu_name,String identity_ids,String url,String memo,int for_school,int for_bureau)
|
|
|
|
|
{
|
|
|
|
|
model.UpdateMenu(menu_id,menu_name,sort_id,url,memo,identity_ids,for_school,for_bureau);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true,"修改成功!"));
|
|
|
|
|
@EmptyInterface({"menu_name", "url", "memo", "identity_ids"})
|
|
|
|
|
@IsNumericInterface({"menu_id", "sort_id", "for_school", "for_bureau"})
|
|
|
|
|
@LengthInterface({"menu_name,1,32", "memo,1,255"})
|
|
|
|
|
public void UpdateMenu(int menu_id, int sort_id, String menu_name, String identity_ids, String url, String memo, int for_school, int for_bureau) {
|
|
|
|
|
model.UpdateMenu(menu_id, menu_name, sort_id, url, memo, identity_ids, for_school, for_bureau);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, "修改成功!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -191,38 +155,31 @@ public class MenuController extends BaseController {
|
|
|
|
|
*/
|
|
|
|
|
@Before({POST.class})
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@EmptyInterface({"id","menu_ids"})
|
|
|
|
|
@EmptyInterface({"id", "menu_ids"})
|
|
|
|
|
@IsNumericInterface({"id"})
|
|
|
|
|
public void saveMenuByDutyInCharge(String id,String menu_ids)
|
|
|
|
|
{
|
|
|
|
|
BaseModel baseModel=new BaseModel();
|
|
|
|
|
List<Record> list=baseModel.getOrgTypePrincipalshipById(id);
|
|
|
|
|
if(list==null || list.size()==0)
|
|
|
|
|
{
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false,"无法获取指定ID的信息!"));
|
|
|
|
|
public void saveMenuByDutyInCharge(String id, String menu_ids) {
|
|
|
|
|
BaseModel baseModel = new BaseModel();
|
|
|
|
|
List<Record> list = baseModel.getOrgTypePrincipalshipById(id);
|
|
|
|
|
if (list == null || list.size() == 0) {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "无法获取指定ID的信息!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Record record=list.get(0);
|
|
|
|
|
int duties_id,in_charge_id;
|
|
|
|
|
int level_id=record.getInt("level");
|
|
|
|
|
if(level_id==4)
|
|
|
|
|
{
|
|
|
|
|
duties_id=record.getInt("id");
|
|
|
|
|
in_charge_id=-1;
|
|
|
|
|
}
|
|
|
|
|
else if(level_id==5)
|
|
|
|
|
{
|
|
|
|
|
duties_id=record.getInt("pId");
|
|
|
|
|
in_charge_id=record.getInt("id");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false,"输入的ID级别不是4也不是5,不是合法的职务+分管工作!"));
|
|
|
|
|
Record record = list.get(0);
|
|
|
|
|
int duties_id, in_charge_id;
|
|
|
|
|
int level_id = record.getInt("level");
|
|
|
|
|
if (level_id == 4) {
|
|
|
|
|
duties_id = record.getInt("id");
|
|
|
|
|
in_charge_id = -1;
|
|
|
|
|
} else if (level_id == 5) {
|
|
|
|
|
duties_id = record.getInt("pId");
|
|
|
|
|
in_charge_id = record.getInt("id");
|
|
|
|
|
} else {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "输入的ID级别不是4也不是5,不是合法的职务+分管工作!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
model.deleteMenuByDutyInCharge(duties_id,in_charge_id);
|
|
|
|
|
model.saveMenuByDutyInCharge(duties_id,in_charge_id,menu_ids);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true,"保存成功!"));
|
|
|
|
|
model.deleteMenuByDutyInCharge(duties_id, in_charge_id);
|
|
|
|
|
model.saveMenuByDutyInCharge(duties_id, in_charge_id, menu_ids);
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(true, "保存成功!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -235,35 +192,28 @@ public class MenuController extends BaseController {
|
|
|
|
|
@IsSysAdminInterface({"1"})
|
|
|
|
|
@EmptyInterface({"id"})
|
|
|
|
|
@IsNumericInterface({"id"})
|
|
|
|
|
public void selectMenuByDutyInCharge(String id)
|
|
|
|
|
{
|
|
|
|
|
BaseModel baseModel=new BaseModel();
|
|
|
|
|
List<Record> list=baseModel.getOrgTypePrincipalshipById(id);
|
|
|
|
|
if(list==null || list.size()==0)
|
|
|
|
|
{
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false,"无法获取指定ID的信息!"));
|
|
|
|
|
public void selectMenuByDutyInCharge(String id) {
|
|
|
|
|
BaseModel baseModel = new BaseModel();
|
|
|
|
|
List<Record> list = baseModel.getOrgTypePrincipalshipById(id);
|
|
|
|
|
if (list == null || list.size() == 0) {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "无法获取指定ID的信息!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
Record record=list.get(0);
|
|
|
|
|
int duties_id,in_charge_id;
|
|
|
|
|
int level_id=record.getInt("level");
|
|
|
|
|
if(level_id==4)
|
|
|
|
|
{
|
|
|
|
|
duties_id=record.getInt("id");
|
|
|
|
|
in_charge_id=-1;
|
|
|
|
|
}
|
|
|
|
|
else if(level_id==5)
|
|
|
|
|
{
|
|
|
|
|
duties_id=record.getInt("pId");
|
|
|
|
|
in_charge_id=record.getInt("id");
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false,"输入的ID级别不是4也不是5,不是合法的职务+分管工作!"));
|
|
|
|
|
Record record = list.get(0);
|
|
|
|
|
int duties_id, in_charge_id;
|
|
|
|
|
int level_id = record.getInt("level");
|
|
|
|
|
if (level_id == 4) {
|
|
|
|
|
duties_id = record.getInt("id");
|
|
|
|
|
in_charge_id = -1;
|
|
|
|
|
} else if (level_id == 5) {
|
|
|
|
|
duties_id = record.getInt("pId");
|
|
|
|
|
in_charge_id = record.getInt("id");
|
|
|
|
|
} else {
|
|
|
|
|
renderJson(CommonUtil.returnMessageJson(false, "输入的ID级别不是4也不是5,不是合法的职务+分管工作!"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
list= model.selectMenuByDutyInCharge(duties_id,in_charge_id);
|
|
|
|
|
Kv kv=Kv.by("success",true).set("list",list);
|
|
|
|
|
list = model.selectMenuByDutyInCharge(duties_id, in_charge_id);
|
|
|
|
|
Kv kv = Kv.by("success", true).set("list", list);
|
|
|
|
|
renderJson(kv);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|