You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

127 lines
3.9 KiB

using System.Collections.Generic;
using System.Threading.Tasks;
using Znyc.Cloudcar.Admin.Commons.Core.App;
using Znyc.Cloudcar.Admin.Commons.Mapping;
using Znyc.Cloudcar.Admin.Security.Dtos;
using Znyc.Cloudcar.Admin.Security.Entitys;
using Znyc.Cloudcar.Admin.Security.IServices;
namespace Znyc.Cloudcar.Admin.Security.Application
{
/// <summary>
/// </summary>
public class UserApp
{
private readonly IRoleService roleService = App.GetService<IRoleService>();
private readonly IAdminUserService service = App.GetService<IAdminUserService>();
private readonly IAdminUserLogOnService userLogOnService = App.GetService<IAdminUserLogOnService>();
/// <summary>
/// 获取所有用户信息
/// </summary>
/// <returns></returns>
public IEnumerable<AdminUserEntity> GetAll()
{
return service.GetAll();
}
/// <summary>
/// 根据用户账号查询用户信息
/// </summary>
/// <param name="userName"></param>
/// <returns></returns>
public async Task<AdminUserEntity> GetByUserName(string userName)
{
return await service.GetByUserName(userName);
}
/// <summary>
/// 根据第三方OpenId查询用户信息
/// </summary>
/// <param name="openIdType">第三方类型</param>
/// <param name="openId">OpenId值</param>
/// <returns></returns>
public UserOutputDto GetUserOutDtoByOpenId(string openIdType, string openId)
{
return service.GetUserByOpenId(openIdType, openId).MapTo<UserOutputDto>();
}
/// <summary>
/// 根据第三方OpenId查询用户信息
/// </summary>
/// <param name="openIdType">第三方类型</param>
/// <param name="openId">OpenId值</param>
/// <returns></returns>
public AdminUserEntity GetUserByOpenId(string openIdType, string openId)
{
return service.GetUserByOpenId(openIdType, openId);
}
/// <summary>
/// 更新用户
/// </summary>
/// <param name="user">用户信息</param>
/// <returns></returns>
public bool UpdateUser(AdminUserEntity user)
{
return service.Update(user, user.Id);
}
/// <summary>
/// 根据用户ID获取头像
/// </summary>
/// <param name="userid">用户ID</param>
/// <returns></returns>
public string GetHeadIconById(long userId)
{
AdminUserEntity user = service.Get(userId);
if (user != null)
{
return user.HeadIcon;
}
return "";
}
/// <summary>
/// 查询用户信息
/// </summary>
/// <param name="id">用户Id</param>
/// <returns></returns>
public AdminUserEntity GetUserById(long id)
{
return service.Get(id);
}
/// <summary>
/// 根据用户id和第三方类型查询
/// </summary>
/// <param name="userId"></param>
/// <param name="openIdType"></param>
/// <returns></returns>
public UserOpenIdsEntity GetUserOpenIdById(long userId, string openIdType)
{
return service.GetUserOpenIdByuserId(openIdType, userId);
}
/// <summary>
/// 根据微信统一ID(UnionID)查询用户
/// </summary>
/// <param name="unionId">UnionID</param>
/// <returns></returns>
public AdminUserEntity GetUserByUnionId(string unionId)
{
return service.GetUserByUnionId(unionId);
}
/// <summary>
/// 统计用户数
/// </summary>
/// <returns></returns>
public long GetCountTotal()
{
return service.GetCountByWhere("1=1");
}
}
}