using Estsh.Core.Dapper;
using Estsh.Core.IRepositories;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Services.IServices;
using Estsh.Core.Util;
using System.Collections;
/***************************************************************************************************
*
* 更新人:sitong.dong
* 描述:用户管理模块业务类
* 修改时间:2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Services
{
///
/// 处理用户管理模块业务
///
public class UserService : BaseService, IUserService
{
private readonly IUserRepository repository;
public UserService(IUserRepository _repository) : base(_repository)
{
repository = _repository;
}
#region 用户管理
///
/// 根据分页条件获取用户列表
///
///
///
///
///
///
public Hashtable getUserListByPage(String account, String enabled, Pager pager, String direction, String sort)
{
Hashtable result = new Hashtable();
String strWhere = " 1=1 ";
if (account != null && !account.Trim().Equals(""))
{
strWhere += " and emp.emp_no like '%" + account.Trim() + "%'";
}
if (enabled != null && !enabled.Trim().Equals(""))
{
strWhere += " and emp.enabled like '%" + enabled.Trim() + "%'";
}
String orderBy = "";
if (sort != null && !"".Equals(sort.Trim()))
{
orderBy += " emp." + typeof(SysEmp).GetEntityColumnName(sort.Trim()) + " " + direction;
}
else
{
orderBy += " emp.emp_id " + direction;
}
result = repository.getUserListByPage(pager.pageSize, pager.pageNo, strWhere, orderBy);
return result;
}
///
/// 根据用户ID,获取用户不拥有的角色信息列表
///
///
///
public List fromRoleList(String emp_id)
{
return repository.fromRoleList(emp_id);
}
///
/// 根据用户ID,获取用户拥有的角色信息列表
///
///
///
public List toRoleList(String emp_id)
{
return repository.toRoleList(emp_id);
}
///
/// 根据用户ID,获取用户信息
///
///
///
public List getUserDetail(String emp_id)
{
return repository.getUserInfoById(emp_id);
}
///
/// 保存用户数据
///
///
///
public int saveUserInfo(SysEmp htParams, string roles)
{
return repository.saveUserInfo(htParams, roles);
}
///
/// 更新用户数据
///
///
///
public int updateUserInfo(SysEmp htParams, string roles)
{
return repository.updateUserInfo(htParams, roles);
}
///
/// 删除用户
///
///
///
public int deleteUser(String ids)
{
String[] idArray = ids.Split(',');
int count = 0;
foreach (String id in idArray)
{
if (!"".Equals(id))
{
count += this.repository.deleteUser(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);
}
public int restPassWord(String userID)
{
return repository.restPassWord(userID);
}
#endregion
}
}