66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
|
using Dapper;
|
|||
|
using Repository.BackendRepository.Interface;
|
|||
|
using Repository.Helper;
|
|||
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Data;
|
|||
|
using System.Linq;
|
|||
|
using System.Threading.Tasks;
|
|||
|
|
|||
|
namespace Repository.BackendRepository.Implement
|
|||
|
{
|
|||
|
public class UserInfoRepository : BackendRepository, IUserInfoRepository
|
|||
|
{
|
|||
|
public UserInfoRepository(IDatabaseHelper databaseHelper) : base(databaseHelper)
|
|||
|
{
|
|||
|
//con = databaseHelper.GetMSSqlConnection();
|
|||
|
}
|
|||
|
|
|||
|
public async Task<A> GetOneByAccountAsync<A>(string account)
|
|||
|
{
|
|||
|
A result;
|
|||
|
|
|||
|
using (IDbConnection conn = GetDbConnection())
|
|||
|
{
|
|||
|
try
|
|||
|
{
|
|||
|
var sql = $"SELECT * FROM userinfo WHERE deleted = 0 AND status = @Status AND account = @Account";
|
|||
|
|
|||
|
result = await conn.QueryFirstOrDefaultAsync<A>(sql, new { Status = 0, Account = account });
|
|||
|
}
|
|||
|
catch (Exception exception)
|
|||
|
{
|
|||
|
throw exception;
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
public A GetMyUserInfoByAccount<A>(string account)
|
|||
|
{
|
|||
|
A result;
|
|||
|
using (IDbConnection conn = GetDbConnection())
|
|||
|
{
|
|||
|
conn.Open();
|
|||
|
try
|
|||
|
{
|
|||
|
var sql = $@"SELECT a.*,b.layer FROM userinfo a
|
|||
|
left join role b on a.role_guid = b.role_guid
|
|||
|
WHERE a.deleted = 0 AND a.status = @Status AND account = @Account ";
|
|||
|
|
|||
|
result = conn.QueryFirstOrDefault<A>(sql, new { Status = 0, Account = account });
|
|||
|
}
|
|||
|
catch (Exception exception)
|
|||
|
{
|
|||
|
throw exception;
|
|||
|
}
|
|||
|
finally
|
|||
|
{
|
|||
|
conn.Close();
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|