using Estsh.Core.Dapper; using Estsh.Core.IRepositories; using Estsh.Core.IServices; using Estsh.Core.Models; using Estsh.Core.Util; using System.Collections; /*************************************************************************************************** * * 更新人:sitong.dong * 描述:部门管理 * 修改时间:2022.06.22 * 修改日志:系统迭代升级 * **************************************************************************************************/ namespace Estsh.Core.Services { /// /// 菜单业务处理类 /// public class DeptService : BaseService, IDeptService { private readonly IDeptRepository repository; public DeptService(IDeptRepository _repository) : base(_repository) { repository = _repository; } /// /// 根据分页条件获取分页菜单数据 /// /// /// /// /// /// public Hashtable getDeptListByPage(string deptName, string enabled, Pager pager, String direction, String sort) { Hashtable result = new Hashtable(); String strWhere = " 1=1 "; if (deptName != null && !deptName.Trim().Equals("")) { strWhere += " and dept_name like '%" + deptName.Trim() + "%'"; } if (enabled != null && !enabled.Trim().Equals("")) { strWhere += " and enabled = '" + enabled + "'"; } String orderBy = ""; if (sort != null && !"".Equals(sort.Trim())) { orderBy += typeof(SysDept).GetEntityColumnName(sort.Trim()) + " " + direction; } else { orderBy += typeof(SysDept).GetEntityColumnName("deptId") + " " + direction; } result = repository.getListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy); return result; } /// /// 保存菜单数据 /// /// /// public int saveDept(SysDept dept) { return repository.saveDept(dept); } /// /// 更新菜单数据 /// /// /// public int updateDept(SysDept dept) { return repository.updateDept(dept); } /// /// 查看详情 /// /// /// public List getDept(String deptId) { deptId = typeof(SysDept).GetEntityColumnName("deptId") + " = " + deptId; List deptList = repository.getList(deptId, ""); return deptList; } /// /// 删除菜单 /// /// /// public int deleteDept(String ids) { String[] idArray = ids.Split(','); int count = 0; foreach (String id in idArray) { if (!"".Equals(id)) { count += this.repository.deleteDept(id); } } return count; } /// /// 启用 /// /// /// public int EnableData(String ids) { ids = ids.Substring(0, ids.Length - 1); return this.repository.EnableData(ids); } /// /// 禁用 /// /// /// public int DisableData(String ids) { ids = ids.Substring(0, ids.Length - 1); return this.repository.DisableData(ids); } } }