123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel.Composition;
- using System.Linq;
- using System.Text;
- using PMS.DBService.SysManager;
- using PMS.Interface.SysManager;
- using QWPlatform.IService;
- using QWPlatform.SystemLibrary.Utils;
- using QWPlatform.SystemLibrary;
- using System.Data;
- using PMS.BusinessModels.SysManager;
- namespace PMS.BusinessService.SysManager
- {
- /// <summary>
- /// 创 建 人:王海洋
- /// 创建日期:2018-12-7
- /// 功能描述:系统模块业务层
- /// </summary>
- public class XTMKBuiness : ISystemModule
- {
- //数据服务
- private XTMKService db_sysMenu = DataServiceBase.Instance<XTMKService>();
- #region 系统模块基础操作
- //根据用户id获取对应的菜单目录
- public string GetTreeMenu(List<string> roleids, bool isAdmin)
- {
- var list = db_sysMenu.GetSysMenus(roleids, isAdmin);
- return Strings.ObjectToJson(list, true);
- }
- //获取easyui treeGridView
- public string GetTreeGridView()
- {
- var dt = db_sysMenu.GetList();
- var column = new string[] { "ID", "上级ID", "名称", "地址", "启用", "图标", "序号", "备注", "首页" };
- return dt.ToEasyUITreeGridJson("ID", "上级ID", null, column, "");
- //return dt.ToJson();
- }
- //获取module信息
- public DataTable GetModuleInfo(int id)
- {
- return db_sysMenu.GetInfoById(id);
- }
- //获取EasyuiTreejson
- public string GetEasyUIJson()
- {
- var dt = db_sysMenu.GetList();
- return dt.ToEasyUITreeJson("ID", "名称", "上级ID", null, "");
- }
- //保存
- public bool SaveInfo(form_menu_model model)
- {
- var emodel = new PMS.EntityModels.SysManager.XTMKModel();
- emodel.MC = model.name;
- emodel.DZ = model.address;
- emodel.QY = model.GetIsActive ? 1 : 0;
- emodel.TB = model.icons;
- emodel.XH = model.ordnum;
- emodel.BZ = model.remark;
- emodel.SY = model.ishome == "on" ? 1 : 0;
- if (model.parentid > 0)
- {//设置为上级ID
- emodel.SJID = model.parentid;
- }
- if (model.id > 0)
- {//存在ID,说明是编辑
- emodel.ID = model.id;
- return db_sysMenu.Update(emodel) > 0;
- }
- else
- {//不存在ID,需要创建一个新记录
- return db_sysMenu.Add(emodel) > 0;
- }
- }
- //检查数据库是否重复名称
- public bool CheckNameExists(string name, int id)
- {
- return db_sysMenu.CheckNameExists(name, id);
- }
- //删除模块
- public bool DeleteModule(int id)
- {
- var model = new EntityModels.SysManager.XTMKModel();
- model.ID = id;
- return db_sysMenu.Delete(model) > 0;
- }
- #endregion
- #region 系统模块授权操作
- //根据ID查询已授权的功能列表
- public DataTable GetButtonListByID(int id)
- {
- return this.db_sysMenu.SelectButtonsByMid(id);
- }
- //对模块分配按钮
- public bool AuthButtons(int id, string buttonids, string group)
- {
- if (!string.IsNullOrEmpty(buttonids))
- {
- group = group.Trim();
- var btns = buttonids.Split(',');
- int orderNum = 0;
- foreach (var bid in btns)
- {
- if (!string.IsNullOrEmpty(bid))
- {//按钮id不为空
- int buttonId = 0;
- if (int.TryParse(bid, out buttonId))
- {
- orderNum++;
- //同一个模块,同一个按钮,同一个分组不能重复
- bool r = db_sysMenu.CheckModuleButtonExists(id, group, buttonId);
- if (!r)
- {//只有不存在时才添加该按钮
- db_sysMenu.AddModuleButton(id, group, buttonId, orderNum);
- }
- }//end if
- }//end if
- }
- return true;
- }
- return false;
- }
- //移除指定模块的授权功能
- public bool RemoveAuthButtons(string ids)
- {
- if (!string.IsNullOrEmpty(ids))
- {//检查是否为空
- var mids = ids.Split(',');
- foreach (var id in mids)
- {
- if (!string.IsNullOrEmpty(id))
- {//id不为空,删除
- int mid = 0;
- if (int.TryParse(id, out mid))
- {
- db_sysMenu.RemoveModuleButton(mid);
- }
- }
- }
- return true;
- }
- return false;
- }
- //获取所有的模块授权(已启用的模块)
- public string GetActiveTreemenu()
- {
- //获取模块的列表
- var dt = db_sysMenu.GetMenuActiveList();
- return dt.ToEasyUITreeJson("ID", "名称", "上级ID", null, null);
- }
- #endregion
- }
- }
|