ow
This commit is contained in:
commit
f05d2d215f
678 files changed
+73865
No files matched your search
@@ -0,0 +1,114 @@
|
||||
|
||||
using CloudBuilder.Core.Authorization;
|
||||
using CloudBuilder.Core.DatabaseAccessor.Entity;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
namespace CloudBuilder.Security.Entity
|
||||
{
|
||||
[TypeScript]
|
||||
[Table("security_user_web_login")]
|
||||
public class SecurityUserWebLoginEntity : EntityBase<SecurityUserWebLoginEntityKey>
|
||||
{
|
||||
|
||||
public SecurityUserWebLoginEntity()
|
||||
{
|
||||
}
|
||||
|
||||
[Column("host_ip")]
|
||||
public string? HostIp { get; set; }
|
||||
[Column("host_user_agent")]
|
||||
public string? HostUserAgent { get; set; }
|
||||
[Column("login_time")]
|
||||
public DateTime LoginTime { get; set; }
|
||||
[Column("logout_time")]
|
||||
public Nullable<DateTime> LogoutTime { get; set; }
|
||||
[Column("refresh_token")]
|
||||
public string RefreshToken { get; set; }
|
||||
[Column("refresh_token_refreshed_time")]
|
||||
public DateTime RefreshTokenRefreshedTime { get; set; }
|
||||
[Column("session_id")]
|
||||
public string SessionId { get; set; }
|
||||
[Column("username")]
|
||||
public string Username { get; set; }
|
||||
|
||||
public const string HOST_IP = "HostIp";
|
||||
public const string HOST_USER_AGENT = "HostUserAgent";
|
||||
public const string LOGIN_TIME = "LoginTime";
|
||||
public const string LOGOUT_TIME = "LogoutTime";
|
||||
public const string REFRESH_TOKEN = "RefreshToken";
|
||||
public const string REFRESH_TOKEN_REFRESHED_TIME = "RefreshTokenRefreshedTime";
|
||||
public const string SESSION_ID = "SessionId";
|
||||
public const string USERNAME = "Username";
|
||||
|
||||
public const string DB_NAME_SECURITY_USER_WEB_LOGIN = "security_user_web_login";
|
||||
public const string DB_NAME_FIELDS="host_ip,host_user_agent,login_time,logout_time,refresh_token,refresh_token_refreshed_time,session_id,username";
|
||||
|
||||
public const string DB_HOST_IP = "host_ip";
|
||||
public const string DB_HOST_USER_AGENT = "host_user_agent";
|
||||
public const string DB_LOGIN_TIME = "login_time";
|
||||
public const string DB_LOGOUT_TIME = "logout_time";
|
||||
public const string DB_REFRESH_TOKEN = "refresh_token";
|
||||
public const string DB_REFRESH_TOKEN_REFRESHED_TIME = "refresh_token_refreshed_time";
|
||||
public const string DB_SESSION_ID = "session_id";
|
||||
public const string DB_USERNAME = "username";
|
||||
|
||||
|
||||
public static SecurityUserWebLoginEntity GetInstance()
|
||||
{
|
||||
return new SecurityUserWebLoginEntity();
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SecurityUserWebLoginEntity source)
|
||||
{
|
||||
CopyFrom(source, true);
|
||||
}
|
||||
|
||||
public virtual void CopyFrom(SecurityUserWebLoginEntity source, bool includeSystemFields)
|
||||
{
|
||||
if (source == null)
|
||||
{
|
||||
throw new NullReferenceException("Source entity is null.");
|
||||
}
|
||||
|
||||
this.HostIp = source.HostIp;
|
||||
this.HostUserAgent = source.HostUserAgent;
|
||||
this.LoginTime = source.LoginTime;
|
||||
this.LogoutTime = source.LogoutTime;
|
||||
this.RefreshToken = source.RefreshToken;
|
||||
this.RefreshTokenRefreshedTime = source.RefreshTokenRefreshedTime;
|
||||
this.SessionId = source.SessionId;
|
||||
this.Username = source.Username;
|
||||
|
||||
if (includeSystemFields)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public override string GetSelectFrom()
|
||||
{
|
||||
return $" select {DB_NAME_FIELDS} from { DB_NAME_SECURITY_USER_WEB_LOGIN} ";
|
||||
}
|
||||
|
||||
public override string GetSelectCountFrom(string sqlWhere)
|
||||
{
|
||||
return $" select count(*) from { DB_NAME_SECURITY_USER_WEB_LOGIN} where 1=1 {sqlWhere}";
|
||||
}
|
||||
|
||||
public override string GetSelectTopFrom(int limit, int start,string orderby,string orderbytag, string sqlWhere)
|
||||
{
|
||||
if (string.IsNullOrEmpty(orderbytag) || orderbytag.Trim() != "desc") orderbytag = "asc";
|
||||
if (string.IsNullOrEmpty(orderby) || !DB_NAME_FIELDS.Contains(orderby)) orderby = DB_SESSION_ID ;
|
||||
int offset = limit * (start - 1);
|
||||
return $" select {DB_NAME_FIELDS} from (select {DB_NAME_FIELDS} ,row_number() over(order by {orderby} {orderbytag}) as num from { DB_NAME_SECURITY_USER_WEB_LOGIN} where 1=1 {sqlWhere} ) a where num> {offset} LIMIT {offset},{limit} ";
|
||||
}
|
||||
|
||||
public SecurityUserWebLoginEntity Clone()
|
||||
{
|
||||
SecurityUserWebLoginEntity result = new SecurityUserWebLoginEntity();
|
||||
result.CopyFrom(this);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user