|
|
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
|
|
|
{
|
|
|
/// <summary>
|
|
|
/// 处理用户管理模块业务
|
|
|
/// </summary>
|
|
|
public class UserService : BaseService<SysEmp>, IUserService
|
|
|
{
|
|
|
private readonly IUserRepository repository;
|
|
|
|
|
|
public UserService(IUserRepository _repository) : base(_repository)
|
|
|
{
|
|
|
repository = _repository;
|
|
|
}
|
|
|
#region 用户管理
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据分页条件获取用户列表
|
|
|
/// </summary>
|
|
|
/// <param name="account"></param>
|
|
|
/// <param name="pager"></param>
|
|
|
/// <param name="direction"></param>
|
|
|
/// <param name="sort"></param>
|
|
|
/// <returns></returns>
|
|
|
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;
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据用户ID,获取用户不拥有的角色信息列表
|
|
|
/// </summary>
|
|
|
/// <param name="emp_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> fromRoleList(String emp_id)
|
|
|
{
|
|
|
return repository.fromRoleList(emp_id);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据用户ID,获取用户拥有的角色信息列表
|
|
|
/// </summary>
|
|
|
/// <param name="emp_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<KeyValueResult> toRoleList(String emp_id)
|
|
|
{
|
|
|
return repository.toRoleList(emp_id);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 根据用户ID,获取用户信息
|
|
|
/// </summary>
|
|
|
/// <param name="emp_id"></param>
|
|
|
/// <returns></returns>
|
|
|
public List<SysEmp> getUserDetail(String emp_id)
|
|
|
{
|
|
|
return repository.getUserInfoById(emp_id);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 保存用户数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int saveUserInfo(SysEmp htParams, string roles)
|
|
|
{
|
|
|
return repository.saveUserInfo(htParams, roles);
|
|
|
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 更新用户数据
|
|
|
/// </summary>
|
|
|
/// <param name="htParams"></param>
|
|
|
/// <returns></returns>
|
|
|
public int updateUserInfo(SysEmp htParams, string roles)
|
|
|
{
|
|
|
return repository.updateUserInfo(htParams, roles);
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 删除用户
|
|
|
/// </summary>
|
|
|
/// <param name="ids"></param>
|
|
|
/// <returns></returns>
|
|
|
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;
|
|
|
}
|
|
|
/// <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);
|
|
|
}
|
|
|
public int restPassWord(String userID)
|
|
|
{
|
|
|
return repository.restPassWord(userID);
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
}
|
|
|
} |