|
|
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
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 菜单业务处理类
|
|
|
/// </summary>
|
|
|
public class DeptService : BaseService<SysDept>, IDeptService
|
|
|
{
|
|
|
private readonly IDeptRepository repository;
|
|
|
public DeptService(IDeptRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取分页菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="DeptName"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveDept(SysDept dept)
|
|
|
{
|
|
|
return repository.saveDept(dept);
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新菜单数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateDept(SysDept dept)
|
|
|
{
|
|
|
return repository.updateDept(dept);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 查看详情
|
|
|
/// </summary>
|
|
|
/// <param name="ruid"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<SysDept> getDept(String deptId)
|
|
|
{
|
|
|
deptId = typeof(SysDept).GetEntityColumnName("deptId") + " = " + deptId;
|
|
|
List<SysDept> deptList = repository.getList(deptId, "");
|
|
|
return deptList;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除菜单
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
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;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 启用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int EnableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.EnableData(ids);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 禁用
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
public int DisableData(String ids)
|
|
|
{
|
|
|
ids = ids.Substring(0, ids.Length - 1);
|
|
|
return this.repository.DisableData(ids);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
} |