mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-04-05 17:38:01 +08:00
调整User为SysUser、Resource为SysResource
This commit is contained in:
parent
839256e8bb
commit
2a2d83d026
@ -52,7 +52,7 @@ namespace OpenAuth.App
|
||||
else
|
||||
{
|
||||
service = _normalAuthStrategy;
|
||||
service.User = _unitWork.FirstOrDefault<User>(u => u.Account == username);
|
||||
service.User = _unitWork.FirstOrDefault<SysUser>(u => u.Account == username);
|
||||
}
|
||||
|
||||
return new AuthStrategyContext(service);
|
||||
|
@ -34,7 +34,7 @@ namespace OpenAuth.App
|
||||
this._strategy = strategy;
|
||||
}
|
||||
|
||||
public User User
|
||||
public SysUser User
|
||||
{
|
||||
get { return _strategy.User; }
|
||||
}
|
||||
@ -54,7 +54,7 @@ namespace OpenAuth.App
|
||||
get { return _strategy.Roles; }
|
||||
}
|
||||
|
||||
public List<Resource> Resources
|
||||
public List<SysResource> Resources
|
||||
{
|
||||
get { return _strategy.Resources; }
|
||||
}
|
||||
|
@ -30,10 +30,10 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 普通用户授权策略
|
||||
/// </summary>
|
||||
public class NormalAuthStrategy : SqlSugarBaseApp<User>, IAuthStrategy
|
||||
public class NormalAuthStrategy : SqlSugarBaseApp<SysUser>, IAuthStrategy
|
||||
{
|
||||
|
||||
protected User _user;
|
||||
protected SysUser _user;
|
||||
|
||||
private List<string> _userRoleIds; //用户角色GUID
|
||||
private DbExtension _dbExtension;
|
||||
@ -79,14 +79,14 @@ namespace OpenAuth.App
|
||||
get { return SugarClient.Queryable<Role>().Where(u => _userRoleIds.Contains(u.Id)).ToList(); }
|
||||
}
|
||||
|
||||
public List<Resource> Resources
|
||||
public List<SysResource> Resources
|
||||
{
|
||||
get
|
||||
{
|
||||
var resourceIds = SugarClient.Queryable<Relevance>().Where(
|
||||
u =>
|
||||
u.Key == Define.ROLERESOURCE && _userRoleIds.Contains(u.FirstId)).Select(u => u.SecondId).ToList();
|
||||
return SugarClient.Queryable<Resource>().Where(u => resourceIds.Contains(u.Id)).ToList();
|
||||
return SugarClient.Queryable<SysResource>().Where(u => resourceIds.Contains(u.Id)).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@ -97,7 +97,7 @@ namespace OpenAuth.App
|
||||
var orgids = SugarClient.Queryable<Relevance>().Where(
|
||||
u =>u.FirstId == _user.Id && u.Key == Define.USERORG).Select(u => u.SecondId).ToList();
|
||||
return SugarClient.Queryable<SysOrg>().Where(org =>orgids.Contains(org.Id))
|
||||
.LeftJoin<User>((org, user) => org.ChairmanId ==user.Id)
|
||||
.LeftJoin<SysUser>((org, user) => org.ChairmanId ==user.Id)
|
||||
.Select((org,user)=>new OrgView
|
||||
{
|
||||
Id = org.Id.SelectAll(),
|
||||
@ -106,7 +106,7 @@ namespace OpenAuth.App
|
||||
}
|
||||
}
|
||||
|
||||
public User User
|
||||
public SysUser User
|
||||
{
|
||||
get { return _user; }
|
||||
set
|
||||
|
@ -31,9 +31,9 @@ namespace OpenAuth.App
|
||||
/// <para>超级管理员权限</para>
|
||||
/// <para>超级管理员使用guid.empty为ID,可以根据需要修改</para>
|
||||
/// </summary>
|
||||
public class SystemAuthStrategy : SqlSugarBaseApp<User>, IAuthStrategy
|
||||
public class SystemAuthStrategy : SqlSugarBaseApp<SysUser>, IAuthStrategy
|
||||
{
|
||||
protected User _user;
|
||||
protected SysUser _user;
|
||||
private DbExtension _dbExtension;
|
||||
|
||||
public List<ModuleView> Modules
|
||||
@ -54,15 +54,15 @@ namespace OpenAuth.App
|
||||
get { return SugarClient.Queryable<ModuleElement>().ToList(); }
|
||||
}
|
||||
|
||||
public List<Resource> Resources
|
||||
public List<SysResource> Resources
|
||||
{
|
||||
get { return SugarClient.Queryable<Resource>().ToList(); }
|
||||
get { return SugarClient.Queryable<SysResource>().ToList(); }
|
||||
}
|
||||
|
||||
public List<OrgView> Orgs
|
||||
{
|
||||
get { return SugarClient.Queryable<SysOrg>()
|
||||
.LeftJoin<User>((org, user) => org.ChairmanId ==user.Id)
|
||||
.LeftJoin<SysUser>((org, user) => org.ChairmanId ==user.Id)
|
||||
.Select((org,user)=>new OrgView
|
||||
{
|
||||
Id = org.Id.SelectAll(),
|
||||
@ -70,7 +70,7 @@ namespace OpenAuth.App
|
||||
}).ToList(); }
|
||||
}
|
||||
|
||||
public User User
|
||||
public SysUser User
|
||||
{
|
||||
get { return _user; }
|
||||
set //禁止外部设置
|
||||
@ -94,7 +94,7 @@ namespace OpenAuth.App
|
||||
public SystemAuthStrategy(ISqlSugarClient client,DbExtension dbExtension) : base(client, null)
|
||||
{
|
||||
_dbExtension = dbExtension;
|
||||
_user = new User
|
||||
_user = new SysUser
|
||||
{
|
||||
Account = Define.SYSTEM_USERNAME,
|
||||
Name = "超级管理员",
|
||||
|
@ -2,7 +2,7 @@
|
||||
* @Author: yubaolee <yubaolee@163.com> | ahfu~ <954478625@qq.com>
|
||||
* @Date: 2024-12-13 16:55:17
|
||||
* @Description: 工作流实例表操作
|
||||
* @LastEditTime: 2025-02-13 17:26:19
|
||||
* @LastEditTime: 2025-02-19 11:43:24
|
||||
* Copyright (c) 2024 by yubaolee | ahfu~ , All Rights Reserved.
|
||||
*/
|
||||
|
||||
@ -592,141 +592,135 @@ namespace OpenAuth.App
|
||||
var user = _auth.GetCurrentUser();
|
||||
//行转列专用SQL
|
||||
string groupConcatSql = $@" ( SELECT GROUP_CONCAT(Account SEPARATOR ',')
|
||||
FROM `User`
|
||||
FROM `SysUser`
|
||||
WHERE fi.MakerList like concat('%', Id, '%') ) ";
|
||||
//sqlserver的行转列需要特殊处理
|
||||
if (SugarClient.CurrentConnectionConfig.DbType == DbType.SqlServer)
|
||||
if(SugarClient.CurrentConnectionConfig.DbType == DbType.SqlServer)
|
||||
{
|
||||
groupConcatSql = $@" STUFF((
|
||||
SELECT ',' + Account
|
||||
FROM [User]
|
||||
FROM [SysUser]
|
||||
WHERE fi.MakerList LIKE '%' + Id + '%'
|
||||
FOR XML PATH(''), TYPE).value('.', 'NVARCHAR(MAX)'), 1, 1, '') ";
|
||||
}
|
||||
else if (SugarClient.CurrentConnectionConfig.DbType == DbType.Oracle)
|
||||
{
|
||||
groupConcatSql = $@" (select listagg(""Account"", ',') within group (order by ""Account"")
|
||||
from ""User""
|
||||
where fi.""MakerList"" like '%' || ""Id"" || '%') ";
|
||||
groupConcatSql = $@" (select listagg(Account, ',') within group (order by Account)
|
||||
from SysUser
|
||||
where fi.MakerList like '%' || Id || '%') ";
|
||||
}
|
||||
|
||||
string sql = String.Empty;
|
||||
|
||||
if (request.type == "wait") //待办事项(即需要我处理的流程)
|
||||
{
|
||||
sql = $@"
|
||||
SELECT {"fi." + Quote("Id")},
|
||||
{"fi." + Quote("CreateUserName")},
|
||||
{"fi." + Quote("ActivityName")},
|
||||
{"fi." + Quote("CreateDate")},
|
||||
{"fi." + Quote("CustomName")},
|
||||
{"fi." + Quote("Code")},
|
||||
{"fi." + Quote("Description")},
|
||||
{"fi." + Quote("IsFinish")},
|
||||
SELECT fi.Id,
|
||||
fi.CreateUserName,
|
||||
fi.ActivityName,
|
||||
fi.CreateDate,
|
||||
fi.CustomName,
|
||||
fi.Code,
|
||||
fi.Description,
|
||||
fi.IsFinish,
|
||||
CASE
|
||||
WHEN {"fi." + Quote("MakerList")} = '1' THEN '所有人'
|
||||
WHEN {"fi." + Quote("MakerList")} = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS {Quote("MakerList")}
|
||||
FROM {Quote("FlowInstance")} fi
|
||||
JOIN (
|
||||
SELECT {"fith." + Quote("Id")}
|
||||
FROM {Quote("FlowInstance")} fith
|
||||
WHERE ({"fith." + Quote("MakerList")} = '1' or {"fith." + Quote("MakerList")} LIKE '%{user.User.Id}%')
|
||||
and ({"fith." + Quote("IsFinish")} = {FlowInstanceStatus.Running} or {"fith." + Quote("IsFinish")} = {FlowInstanceStatus.Rejected})
|
||||
and not exists (
|
||||
SELECT 1
|
||||
FROM {Quote("FlowApprover")}
|
||||
WHERE {"fith." + Quote("Id")} = {Quote("InstanceId")}
|
||||
and {"fith." + Quote("ActivityId")} = {Quote("ActivityId")}
|
||||
and {Quote("Status")} = 0
|
||||
)
|
||||
UNION
|
||||
SELECT {"fa." + Quote("InstanceId")}
|
||||
FROM {Quote("FlowApprover")} fa
|
||||
WHERE {"fa." + Quote("Status")} = 0
|
||||
AND {"fa." + Quote("ApproverId")} = '{user.User.Id}'
|
||||
) UniqueInstanceIds
|
||||
ON {"fi." + Quote("Id")} = {"UniqueInstanceIds." + Quote("Id")}
|
||||
";
|
||||
WHEN fi.MakerList = '1' THEN '所有人'
|
||||
WHEN fi.MakerList = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS MakerList
|
||||
FROM FlowInstance fi
|
||||
JOIN (SELECT fith.Id
|
||||
FROM FlowInstance fith
|
||||
WHERE (MakerList = '1' or MakerList LIKE '%{user.User.Id}%')
|
||||
and (fith.IsFinish = {FlowInstanceStatus.Running} or fith.IsFinish = {FlowInstanceStatus.Rejected})
|
||||
and not exists (select 1
|
||||
from flowapprover
|
||||
where fith.Id = InstanceId
|
||||
and fith.ActivityId = ActivityId
|
||||
and Status = 0)
|
||||
UNION
|
||||
SELECT fa.InstanceId
|
||||
FROM FlowApprover fa
|
||||
WHERE fa.Status = 0
|
||||
AND fa.ApproverId = '{user.User.Id}') UniqueInstanceIds
|
||||
ON fi.Id = UniqueInstanceIds.Id";
|
||||
}
|
||||
else if (request.type == "disposed") //已办事项(即我参与过的流程)
|
||||
{
|
||||
sql = $@"
|
||||
SELECT {"fi." + Quote("Id")},
|
||||
{"fi." + Quote("CreateUserName")},
|
||||
{"fi." + Quote("ActivityName")},
|
||||
{"fi." + Quote("CreateDate")},
|
||||
{"fi." + Quote("CustomName")},
|
||||
{"fi." + Quote("Code")},
|
||||
{"fi." + Quote("Description")},
|
||||
{"fi." + Quote("IsFinish")},
|
||||
CASE
|
||||
WHEN {"fi." + Quote("MakerList")} = '1' THEN '所有人'
|
||||
WHEN {"fi." + Quote("MakerList")} = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS {Quote("MakerList")}
|
||||
FROM {Quote("FlowInstance")} fi
|
||||
JOIN (
|
||||
SELECT {"fith." + Quote("InstanceId")}
|
||||
FROM {Quote("FlowInstanceOperationHistory")} fith
|
||||
WHERE {"fith." + Quote("CreateUserId")} = '{user.User.Id}'
|
||||
UNION
|
||||
SELECT {"fa." + Quote("InstanceId")}
|
||||
FROM {Quote("FlowApprover")} fa
|
||||
WHERE {"fa." + Quote("Status")} <> 0
|
||||
AND {"fa." + Quote("ApproverId")} = '{user.User.Id}'
|
||||
) UniqueInstanceIds
|
||||
ON {"fi." + Quote("Id")} = {"UniqueInstanceIds." + Quote("InstanceId")}
|
||||
";
|
||||
SELECT fi.Id,
|
||||
fi.CreateUserName,
|
||||
fi.ActivityName,
|
||||
fi.CreateDate,
|
||||
fi.CustomName,
|
||||
fi.Code,
|
||||
fi.Description,
|
||||
fi.IsFinish,
|
||||
CASE
|
||||
WHEN fi.MakerList = '1' THEN '所有人'
|
||||
WHEN fi.MakerList = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS MakerList
|
||||
FROM FlowInstance fi
|
||||
JOIN (SELECT fith.InstanceId
|
||||
FROM FlowInstanceOperationHistory fith
|
||||
WHERE fith.CreateUserId = '{user.User.Id}'
|
||||
UNION
|
||||
SELECT fa.InstanceId
|
||||
FROM FlowApprover fa
|
||||
WHERE fa.Status <> 0
|
||||
AND fa.ApproverId = '{user.User.Id}') UniqueInstanceIds
|
||||
ON fi.Id = UniqueInstanceIds.InstanceId
|
||||
";
|
||||
}
|
||||
else //我的流程(我创建的及知会我的)
|
||||
{
|
||||
sql = $@"
|
||||
SELECT {"fi." + Quote("Id")},
|
||||
{"fi." + Quote("CreateUserName")},
|
||||
{"fi." + Quote("ActivityName")},
|
||||
{"fi." + Quote("CreateDate")},
|
||||
{"fi." + Quote("CustomName")},
|
||||
{"fi." + Quote("Code")},
|
||||
{"fi." + Quote("Description")},
|
||||
{"fi." + Quote("IsFinish")},
|
||||
CASE
|
||||
WHEN {"fi." + Quote("MakerList")} = '1' THEN '所有人'
|
||||
WHEN {"fi." + Quote("MakerList")} = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS {Quote("MakerList")}
|
||||
FROM {Quote("FlowInstance")} fi
|
||||
JOIN (
|
||||
SELECT {Quote("Id")} as {Quote("InstanceId")}
|
||||
FROM {Quote("FlowInstance")}
|
||||
WHERE {Quote("CreateUserId")} = '{user.User.Id}'
|
||||
UNION
|
||||
SELECT DISTINCT {Quote("FirstId")} as {Quote("InstanceId")}
|
||||
FROM {Quote("Relevance")} rel
|
||||
INNER JOIN {Quote("FlowInstance")} flow ON {"rel." + Quote("FirstId")} = {"flow." + Quote("Id")} and {"flow." + Quote("IsFinish")} = 1
|
||||
WHERE {Quote("Key")} = '{Define.INSTANCE_NOTICE_USER}'
|
||||
AND {Quote("SecondId")} = '{user.User.Id}'
|
||||
UNION
|
||||
SELECT DISTINCT {"a." + Quote("FirstId")} as {Quote("InstanceId")}
|
||||
FROM {Quote("Relevance")} a
|
||||
INNER JOIN (
|
||||
SELECT {Quote("SecondId")} as {Quote("RoleId")}
|
||||
FROM {Quote("Relevance")}
|
||||
WHERE {Quote("Key")} = 'UserRole'
|
||||
AND {Quote("FirstId")} = '{user.User.Id}'
|
||||
) b ON {"a." + Quote("SecondId")} = {"b." + Quote("RoleId")}
|
||||
INNER JOIN {Quote("FlowInstance")} flow ON {"a." + Quote("FirstId")} = {"flow." + Quote("Id")} and {"flow." + Quote("IsFinish")} = 1
|
||||
WHERE {"a." + Quote("Key")} = '{Define.INSTANCE_NOTICE_ROLE}'
|
||||
) UniqueInstanceIds
|
||||
ON {"fi." + Quote("Id")} = {"UniqueInstanceIds." + Quote("InstanceId")}
|
||||
";
|
||||
SELECT fi.Id,
|
||||
fi.CreateUserName,
|
||||
fi.ActivityName,
|
||||
fi.CreateDate,
|
||||
fi.CustomName,
|
||||
fi.Code,
|
||||
fi.Description,
|
||||
fi.IsFinish,
|
||||
CASE
|
||||
WHEN fi.MakerList = '1' THEN '所有人'
|
||||
WHEN fi.MakerList = '00000000-0000-0000-0000-000000000000' THEN 'System'
|
||||
ELSE {groupConcatSql}
|
||||
END AS MakerList
|
||||
FROM FlowInstance fi
|
||||
JOIN (select Id as InstanceId
|
||||
from FlowInstance
|
||||
where CreateUserId = '{user.User.Id}'
|
||||
union
|
||||
select distinct FirstId as InstanceId
|
||||
from Relevance rel
|
||||
inner join FlowInstance flow on rel.FirstId = flow.Id and flow.IsFinish = 1
|
||||
where `Key` = '{Define.INSTANCE_NOTICE_USER}'
|
||||
and SecondId = '{user.User.Id}'
|
||||
union
|
||||
select distinct a.FirstId as InstanceId
|
||||
from Relevance a
|
||||
inner join (select SecondId as RoleId
|
||||
from Relevance
|
||||
where `Key` = 'UserRole'
|
||||
and FirstId = '{user.User.Id}') b on a.SecondId = b.RoleId
|
||||
inner join FlowInstance flow on a.FirstId = flow.Id and flow.IsFinish = 1
|
||||
where a.`Key` = '{Define.INSTANCE_NOTICE_ROLE}') UniqueInstanceIds
|
||||
ON fi.Id = UniqueInstanceIds.InstanceId
|
||||
";
|
||||
}
|
||||
|
||||
switch (SugarClient.CurrentConnectionConfig.DbType)
|
||||
{
|
||||
case DbType.SqlServer:
|
||||
sql = sql.Replace("`Key`", "[Key]");
|
||||
sql = sql.Replace("from dual", "");
|
||||
break;
|
||||
case DbType.Oracle:
|
||||
sql = sql.Replace("`Key`", "\"KEY\"");
|
||||
break;
|
||||
}
|
||||
|
||||
var finalQuery = SugarClient.SqlQueryable<FlowInstance>(sql)
|
||||
@ -738,18 +732,6 @@ namespace OpenAuth.App
|
||||
|
||||
return result;
|
||||
}
|
||||
string Quote(string name)
|
||||
{
|
||||
switch (SugarClient.CurrentConnectionConfig.DbType)
|
||||
{
|
||||
case DbType.SqlServer:
|
||||
return $"[{name}]";
|
||||
case DbType.Oracle:
|
||||
return $"\"{name}\"";
|
||||
default:
|
||||
return $"`{name}`";
|
||||
}
|
||||
}
|
||||
|
||||
public List<FlowInstanceOperationHistory> QueryHistories(QueryFlowInstanceHistoryReq request)
|
||||
{
|
||||
|
@ -31,11 +31,11 @@ namespace OpenAuth.App
|
||||
|
||||
List<Role> Roles { get; }
|
||||
|
||||
List<Resource> Resources { get; }
|
||||
List<SysResource> Resources { get; }
|
||||
|
||||
List<OrgView> Orgs { get; }
|
||||
|
||||
User User
|
||||
SysUser User
|
||||
{
|
||||
get;set;
|
||||
}
|
||||
|
@ -14,13 +14,13 @@ namespace OpenAuth.App
|
||||
/// <summary>
|
||||
/// 分类管理
|
||||
/// </summary>
|
||||
public class ResourceApp:SqlSugarBaseApp<Resource>
|
||||
public class ResourceApp:SqlSugarBaseApp<SysResource>
|
||||
{
|
||||
private RevelanceManagerApp _revelanceApp;
|
||||
|
||||
public void Add(AddOrUpdateResReq resource)
|
||||
{
|
||||
var obj = resource.MapTo<Resource>();
|
||||
var obj = resource.MapTo<SysResource>();
|
||||
CaculateCascade(obj);
|
||||
obj.CreateTime = DateTime.Now;
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
@ -32,7 +32,7 @@ namespace OpenAuth.App
|
||||
public void Update(AddOrUpdateResReq obj)
|
||||
{
|
||||
var user = _auth.GetCurrentUser().User;
|
||||
Repository.Update(u => new Resource
|
||||
Repository.Update(u => new SysResource
|
||||
{
|
||||
Name = obj.Name,
|
||||
Disable = obj.Disable,
|
||||
@ -51,10 +51,10 @@ namespace OpenAuth.App
|
||||
},u => u.Id == obj.Id);
|
||||
}
|
||||
|
||||
public IEnumerable<Resource> LoadForRole(string appId, string roleId)
|
||||
public IEnumerable<SysResource> LoadForRole(string appId, string roleId)
|
||||
{
|
||||
var elementIds = _revelanceApp.Get(Define.ROLERESOURCE, true, roleId);
|
||||
return SugarClient.Queryable<Resource>().Where(u => elementIds.Contains(u.Id) && (appId == null || appId =="" || u.AppId == appId)).ToArray();
|
||||
return SugarClient.Queryable<SysResource>().Where(u => elementIds.Contains(u.Id) && (appId == null || appId =="" || u.AppId == appId)).ToArray();
|
||||
}
|
||||
|
||||
public async Task<TableData> Load(QueryResourcesReq request)
|
||||
|
@ -16,11 +16,11 @@ namespace OpenAuth.App.SSO
|
||||
{
|
||||
|
||||
//这个地方使用IRepository<User> 而不使用UserManagerApp是防止循环依赖
|
||||
public IRepository<User,OpenAuthDBContext> _app;
|
||||
public IRepository<SysUser,OpenAuthDBContext> _app;
|
||||
private ICacheContext _cacheContext;
|
||||
private AppManager _appInfoService;
|
||||
|
||||
public LoginParse( AppManager infoService, ICacheContext cacheContext, IRepository<User,OpenAuthDBContext> userApp)
|
||||
public LoginParse( AppManager infoService, ICacheContext cacheContext, IRepository<SysUser,OpenAuthDBContext> userApp)
|
||||
{
|
||||
_appInfoService = infoService;
|
||||
_cacheContext = cacheContext;
|
||||
@ -40,10 +40,10 @@ namespace OpenAuth.App.SSO
|
||||
// throw new Exception("应用不存在");
|
||||
// }
|
||||
//获取用户信息
|
||||
User userInfo = null;
|
||||
SysUser sysUserInfo = null;
|
||||
if (model.Account == Define.SYSTEM_USERNAME)
|
||||
{
|
||||
userInfo = new User
|
||||
sysUserInfo = new SysUser
|
||||
{
|
||||
Id = Guid.Empty.ToString(),
|
||||
Account = Define.SYSTEM_USERNAME,
|
||||
@ -53,19 +53,19 @@ namespace OpenAuth.App.SSO
|
||||
}
|
||||
else
|
||||
{
|
||||
userInfo = _app.FirstOrDefault(u =>u.Account == model.Account);
|
||||
sysUserInfo = _app.FirstOrDefault(u =>u.Account == model.Account);
|
||||
}
|
||||
|
||||
if (userInfo == null)
|
||||
if (sysUserInfo == null)
|
||||
{
|
||||
throw new Exception("用户不存在");
|
||||
}
|
||||
if (userInfo.Password != model.Password)
|
||||
if (sysUserInfo.Password != model.Password)
|
||||
{
|
||||
throw new Exception("密码错误");
|
||||
}
|
||||
|
||||
if (userInfo.Status != 0)
|
||||
if (sysUserInfo.Status != 0)
|
||||
{
|
||||
throw new Exception("账号状态异常,可能已停用");
|
||||
}
|
||||
@ -73,7 +73,7 @@ namespace OpenAuth.App.SSO
|
||||
var currentSession = new UserAuthSession
|
||||
{
|
||||
Account = model.Account,
|
||||
Name = userInfo.Name,
|
||||
Name = sysUserInfo.Name,
|
||||
Token = Guid.NewGuid().ToString().GetHashCode().ToString("x"),
|
||||
AppKey = model.AppKey,
|
||||
CreateTime = DateTime.Now
|
||||
|
@ -63,10 +63,10 @@ namespace OpenAuth.App
|
||||
/// <param name="message"></param>
|
||||
public void SendMsgTo(string userId, string message)
|
||||
{
|
||||
User user = null;
|
||||
SysUser sysUser = null;
|
||||
if (userId == Guid.Empty.ToString())
|
||||
{
|
||||
user = new User
|
||||
sysUser = new SysUser
|
||||
{
|
||||
Name = Define.SYSTEM_USERNAME,
|
||||
Id = userId
|
||||
@ -74,17 +74,17 @@ namespace OpenAuth.App
|
||||
}
|
||||
else
|
||||
{
|
||||
user = UnitWork.FirstOrDefault<User>(u => u.Id == userId);
|
||||
sysUser = UnitWork.FirstOrDefault<SysUser>(u => u.Id == userId);
|
||||
}
|
||||
if (user == null)
|
||||
if (sysUser == null)
|
||||
{
|
||||
_logger.LogError($"未能找到用户{userId},不能给该用户发送消息");
|
||||
return;
|
||||
}
|
||||
Repository.Add(new SysMessage
|
||||
{
|
||||
ToId = user.Id,
|
||||
ToName = user.Name,
|
||||
ToId = sysUser.Id,
|
||||
ToName = sysUser.Name,
|
||||
TypeName = "系统消息",
|
||||
TypeId ="SYS_MSG",
|
||||
FromId = Guid.Empty.ToString(),
|
||||
|
@ -50,11 +50,11 @@ namespace OpenAuth.App.Test
|
||||
|
||||
private async Task AddOrUpdate()
|
||||
{
|
||||
var repository = _autofacServiceProvider.GetService<IRepository<User,OpenAuthDBContext>>();
|
||||
var repository = _autofacServiceProvider.GetService<IRepository<SysUser,OpenAuthDBContext>>();
|
||||
|
||||
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
|
||||
var user = new User
|
||||
var user = new SysUser
|
||||
{
|
||||
Account = account,
|
||||
Name = account
|
||||
|
@ -49,14 +49,14 @@ namespace OpenAuth.App.Test
|
||||
public void SetObj()
|
||||
{
|
||||
var app = _autofacServiceProvider.GetService<ICacheContext>();
|
||||
app.Set("user:info", new User
|
||||
app.Set("user:info", new SysUser
|
||||
{
|
||||
Name = "测试",
|
||||
Account ="Test",
|
||||
BizCode = "0.1.1"
|
||||
}, DateTime.Now.AddDays(1));
|
||||
|
||||
var result = app.Get<User>("user:info");
|
||||
var result = app.Get<SysUser>("user:info");
|
||||
Console.WriteLine($"redis结果:{JsonHelper.Instance.Serialize(result)}");
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ namespace OpenAuth.App.Test
|
||||
{
|
||||
var app = _autofacServiceProvider.GetService<ICacheContext>();
|
||||
|
||||
var result = app.Get<User>("noexistkey");
|
||||
var result = app.Get<SysUser>("noexistkey");
|
||||
Console.WriteLine($"redis结果:{JsonHelper.Instance.Serialize(result)}");
|
||||
}
|
||||
|
||||
|
@ -61,14 +61,14 @@ namespace OpenAuth.App.Request
|
||||
[Required(ErrorMessage = "请为用户分配机构")]
|
||||
public string OrganizationIds { get; set; }
|
||||
|
||||
public static implicit operator UpdateUserReq(User user)
|
||||
public static implicit operator UpdateUserReq(SysUser sysUser)
|
||||
{
|
||||
return user.MapTo<UpdateUserReq>();
|
||||
return sysUser.MapTo<UpdateUserReq>();
|
||||
}
|
||||
|
||||
public static implicit operator User(UpdateUserReq view)
|
||||
public static implicit operator SysUser(UpdateUserReq view)
|
||||
{
|
||||
return view.MapTo<User>();
|
||||
return view.MapTo<SysUser>();
|
||||
}
|
||||
|
||||
public UpdateUserReq()
|
||||
|
@ -76,14 +76,14 @@ namespace OpenAuth.App.Response
|
||||
|
||||
public string OrganizationIds { get; set; }
|
||||
|
||||
public static implicit operator UserView(User user)
|
||||
public static implicit operator UserView(SysUser sysUser)
|
||||
{
|
||||
return user.MapTo<UserView>();
|
||||
return sysUser.MapTo<UserView>();
|
||||
}
|
||||
|
||||
public static implicit operator User(UserView view)
|
||||
public static implicit operator SysUser(UserView view)
|
||||
{
|
||||
return view.MapTo<User>();
|
||||
return view.MapTo<SysUser>();
|
||||
}
|
||||
|
||||
public UserView()
|
||||
|
@ -14,17 +14,17 @@ using OpenAuth.Repository.Domain;
|
||||
using OpenAuth.Repository.Interface;
|
||||
namespace OpenAuth.App
|
||||
{
|
||||
public class UserManagerApp : BaseStringApp<User,OpenAuthDBContext>
|
||||
public class UserManagerApp : BaseStringApp<SysUser,OpenAuthDBContext>
|
||||
{
|
||||
private RevelanceManagerApp _revelanceApp;
|
||||
private OrgManagerApp _orgManagerApp;
|
||||
public UserManagerApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<User,OpenAuthDBContext> repository,
|
||||
public UserManagerApp(IUnitWork<OpenAuthDBContext> unitWork, IRepository<SysUser,OpenAuthDBContext> repository,
|
||||
RevelanceManagerApp app,IAuth auth, OrgManagerApp orgManagerApp) : base(unitWork, repository, auth)
|
||||
{
|
||||
_revelanceApp = app;
|
||||
_orgManagerApp = orgManagerApp;
|
||||
}
|
||||
public User GetByAccount(string account)
|
||||
public SysUser GetByAccount(string account)
|
||||
{
|
||||
return Repository.FirstOrDefault(u => u.Account == account);
|
||||
}
|
||||
@ -35,13 +35,13 @@ namespace OpenAuth.App
|
||||
public async Task<TableData> Load(QueryUserListReq request)
|
||||
{
|
||||
var loginUser = _auth.GetCurrentUser();
|
||||
IQueryable<User> query = UnitWork.Find<User>(null);
|
||||
IQueryable<SysUser> query = UnitWork.Find<SysUser>(null);
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
query = UnitWork.Find<User>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
|
||||
query = UnitWork.Find<SysUser>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
|
||||
}
|
||||
var userOrgs = from user in query
|
||||
join user2 in UnitWork.Find<User>(null)
|
||||
join user2 in UnitWork.Find<SysUser>(null)
|
||||
on user.ParentId equals user2.Id into tempuser
|
||||
from u in tempuser.DefaultIfEmpty()
|
||||
join relevance in UnitWork.Find<Relevance>(u => u.Key == "UserOrg")
|
||||
@ -113,13 +113,13 @@ namespace OpenAuth.App
|
||||
/// </summary>
|
||||
public async Task<TableResp<UserView>> LoadAll(QueryUserListReq request)
|
||||
{
|
||||
IQueryable<User> query = UnitWork.Find<User>(null);
|
||||
IQueryable<SysUser> query = UnitWork.Find<SysUser>(null);
|
||||
if (!string.IsNullOrEmpty(request.key))
|
||||
{
|
||||
query = UnitWork.Find<User>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
|
||||
query = UnitWork.Find<SysUser>(u => u.Name.Contains(request.key) || u.Account.Contains(request.key));
|
||||
}
|
||||
var userOrgs = from user in query
|
||||
join user2 in UnitWork.Find<User>(null)
|
||||
join user2 in UnitWork.Find<SysUser>(null)
|
||||
on user.ParentId equals user2.Id into tempuser
|
||||
from u in tempuser.DefaultIfEmpty()
|
||||
join relevance in UnitWork.Find<Relevance>(u => u.Key == "UserOrg")
|
||||
@ -179,13 +179,13 @@ namespace OpenAuth.App
|
||||
request.ValidationEntity(u => new {u.Account,u.Name, u.OrganizationIds});
|
||||
if (string.IsNullOrEmpty(request.OrganizationIds))
|
||||
throw new Exception("请为用户分配机构");
|
||||
User requser = request;
|
||||
SysUser requser = request;
|
||||
requser.CreateId = _auth.GetCurrentUser().User.Id;
|
||||
UnitWork.ExecuteWithTransaction(() =>
|
||||
{
|
||||
if (string.IsNullOrEmpty(request.Id))
|
||||
{
|
||||
if (UnitWork.Any<User>(u => u.Account == request.Account))
|
||||
if (UnitWork.Any<SysUser>(u => u.Account == request.Account))
|
||||
{
|
||||
throw new Exception("用户账号已存在");
|
||||
}
|
||||
@ -199,7 +199,7 @@ namespace OpenAuth.App
|
||||
}
|
||||
else
|
||||
{
|
||||
UnitWork.Update<User>(u => u.Id == request.Id, u => new User
|
||||
UnitWork.Update<SysUser>(u => u.Id == request.Id, u => new SysUser
|
||||
{
|
||||
Account = requser.Account,
|
||||
BizCode = requser.BizCode,
|
||||
@ -210,7 +210,7 @@ namespace OpenAuth.App
|
||||
});
|
||||
if (!string.IsNullOrEmpty(requser.Password)) //密码为空的时候,不做修改
|
||||
{
|
||||
UnitWork.Update<User>(u => u.Id == request.Id, u => new User
|
||||
UnitWork.Update<SysUser>(u => u.Id == request.Id, u => new SysUser
|
||||
{
|
||||
Password = requser.Password
|
||||
});
|
||||
@ -232,7 +232,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
UnitWork.Delete<Relevance>(u =>(u.Key == Define.USERROLE || u.Key == Define.USERORG)
|
||||
&& ids.Contains(u.FirstId));
|
||||
UnitWork.Delete<User>(u => ids.Contains(u.Id));
|
||||
UnitWork.Delete<SysUser>(u => ids.Contains(u.Id));
|
||||
UnitWork.Save();
|
||||
});
|
||||
}
|
||||
@ -242,7 +242,7 @@ namespace OpenAuth.App
|
||||
/// <param name="request"></param>
|
||||
public void ChangePassword(ChangePasswordReq request)
|
||||
{
|
||||
Repository.Update(u => u.Account == request.Account, user => new User
|
||||
Repository.Update(u => u.Account == request.Account, user => new SysUser
|
||||
{
|
||||
Password = request.Password
|
||||
});
|
||||
@ -256,7 +256,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
var users = from userRole in UnitWork.Find<Relevance>(u =>
|
||||
u.SecondId == request.roleId && u.Key == Define.USERROLE)
|
||||
join user in UnitWork.Find<User>(null) on userRole.FirstId equals user.Id into temp
|
||||
join user in UnitWork.Find<SysUser>(null) on userRole.FirstId equals user.Id into temp
|
||||
from c in temp.Where(u =>u.Id != null)
|
||||
select c;
|
||||
return new TableData
|
||||
@ -274,7 +274,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
var users = from userOrg in UnitWork.Find<Relevance>(u =>
|
||||
u.SecondId == request.orgId && u.Key == Define.USERORG)
|
||||
join user in UnitWork.Find<User>(null) on userOrg.FirstId equals user.Id into temp
|
||||
join user in UnitWork.Find<SysUser>(null) on userOrg.FirstId equals user.Id into temp
|
||||
from c in temp.Where(u =>u.Id != null)
|
||||
select c;
|
||||
return new TableData
|
||||
@ -293,7 +293,7 @@ namespace OpenAuth.App
|
||||
{
|
||||
throw new Exception("不能修改超级管理员信息");
|
||||
}
|
||||
Repository.Update(u => u.Account == request.Account, user => new User
|
||||
Repository.Update(u => u.Account == request.Account, user => new SysUser
|
||||
{
|
||||
Name = request.Name,
|
||||
Sex = request.Sex
|
||||
@ -349,7 +349,7 @@ namespace OpenAuth.App
|
||||
sql = sql.Replace("`Key`", "\"Key\"");
|
||||
}
|
||||
|
||||
var users = UnitWork.FromSql<User>(sql);
|
||||
var users = UnitWork.FromSql<SysUser>(sql);
|
||||
return users.Select(u=>u.Id).ToList();
|
||||
}
|
||||
}
|
||||
|
@ -78,12 +78,12 @@ namespace OpenAuth.IdentityServer
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private User GetUserById(string id)
|
||||
private SysUser GetUserById(string id)
|
||||
{
|
||||
User user;
|
||||
SysUser sysUser;
|
||||
if (id == Define.SYSTEM_USERNAME)
|
||||
{
|
||||
user = new User
|
||||
sysUser = new SysUser
|
||||
{
|
||||
Account = Define.SYSTEM_USERNAME,
|
||||
Id = Define.SYSTEM_USERNAME,
|
||||
@ -92,10 +92,10 @@ namespace OpenAuth.IdentityServer
|
||||
}
|
||||
else
|
||||
{
|
||||
user = UserManager.Get(id);
|
||||
sysUser = UserManager.Get(id);
|
||||
}
|
||||
|
||||
return user;
|
||||
return sysUser;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ namespace OpenAuth.IdentityServer.Quickstart.Account
|
||||
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
User user;
|
||||
SysUser sysUser;
|
||||
if (model.Username == Define.SYSTEM_USERNAME && model.Password == Define.SYSTEM_USERPWD)
|
||||
{
|
||||
user = new User
|
||||
sysUser = new SysUser
|
||||
{
|
||||
Account = Define.SYSTEM_USERNAME,
|
||||
Password = Define.SYSTEM_USERPWD,
|
||||
@ -119,12 +119,12 @@ namespace OpenAuth.IdentityServer.Quickstart.Account
|
||||
}
|
||||
else
|
||||
{
|
||||
user = _userManager.GetByAccount(model.Username);
|
||||
sysUser = _userManager.GetByAccount(model.Username);
|
||||
}
|
||||
|
||||
if (user != null &&(user.Password ==model.Password))
|
||||
if (sysUser != null &&(sysUser.Password ==model.Password))
|
||||
{
|
||||
if (user.Status != 0) //判断用户状态
|
||||
if (sysUser.Status != 0) //判断用户状态
|
||||
{
|
||||
await _events.RaiseAsync(new UserLoginFailureEvent(model.Username, "invalid user status"));
|
||||
ModelState.AddModelError(string.Empty, "user.status must be 0");
|
||||
@ -132,7 +132,7 @@ namespace OpenAuth.IdentityServer.Quickstart.Account
|
||||
return View(err);
|
||||
}
|
||||
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(user.Account, user.Id, user.Account));
|
||||
await _events.RaiseAsync(new UserLoginSuccessEvent(sysUser.Account, sysUser.Id, sysUser.Account));
|
||||
|
||||
// only set explicit expiration here if user chooses "remember me".
|
||||
// otherwise we rely upon expiration configured in cookie middleware.
|
||||
@ -147,7 +147,7 @@ namespace OpenAuth.IdentityServer.Quickstart.Account
|
||||
};
|
||||
|
||||
// issue authentication cookie with subject ID and username
|
||||
await HttpContext.SignInAsync(user.Id, user.Account, props);
|
||||
await HttpContext.SignInAsync(sysUser.Id, sysUser.Account, props);
|
||||
|
||||
if (context != null)
|
||||
{
|
||||
|
@ -112,8 +112,7 @@ namespace OpenAuth.Mvc
|
||||
IsAutoCloseConnection = true,
|
||||
MoreSettings=new ConnMoreSettings() {
|
||||
PgSqlIsAutoToLower = false,//增删查改支持驼峰表
|
||||
PgSqlIsAutoToLowerCodeFirst = false, // 建表建驼峰表。5.1.3.30
|
||||
IsAutoToUpper=false //禁用自动转成大写表
|
||||
PgSqlIsAutoToLowerCodeFirst = false // 建表建驼峰表。5.1.3.30
|
||||
}
|
||||
}, db => { db.Aop.OnLogExecuting = (sql, pars) => { logger.LogInformation(sql); }; });
|
||||
return sqlSugar;
|
||||
|
@ -1,111 +1,102 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源表
|
||||
/// </summary>
|
||||
[Table("Resource")]
|
||||
public partial class Resource : TreeEntity
|
||||
{
|
||||
public Resource()
|
||||
{
|
||||
this.Name= string.Empty;
|
||||
this.SortNo= 0;
|
||||
this.Description= string.Empty;
|
||||
this.AppId= string.Empty;
|
||||
this.AppName= string.Empty;
|
||||
this.TypeName= string.Empty;
|
||||
this.TypeId= string.Empty;
|
||||
this.CreateTime= DateTime.Now;
|
||||
this.CreateUserId= string.Empty;
|
||||
this.CreateUserName= string.Empty;
|
||||
this.UpdateTime= DateTime.Now;
|
||||
this.UpdateUserId= string.Empty;
|
||||
this.UpdateUserName= string.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 排序号
|
||||
/// </summary>
|
||||
[Description("排序号")]
|
||||
public int SortNo { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
[Description("描述")]
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// 资源所属应用ID
|
||||
/// </summary>
|
||||
[Description("资源所属应用ID")]
|
||||
[Browsable(false)]
|
||||
public string AppId { get; set; }
|
||||
/// <summary>
|
||||
/// 所属应用名称
|
||||
/// </summary>
|
||||
[Description("所属应用名称")]
|
||||
public string AppName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
[Description("分类名称")]
|
||||
public string TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类ID
|
||||
/// </summary>
|
||||
[Description("分类ID")]
|
||||
[Browsable(false)]
|
||||
public string TypeId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否可用
|
||||
/// </summary>
|
||||
[Description("是否可用")]
|
||||
public bool Disable { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Description("创建时间")]
|
||||
public System.DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人ID
|
||||
/// </summary>
|
||||
[Description("创建人ID")]
|
||||
[Browsable(false)]
|
||||
public string CreateUserId { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Description("创建人")]
|
||||
public string CreateUserName { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新时间
|
||||
/// </summary>
|
||||
[Description("最后更新时间")]
|
||||
public System.DateTime? UpdateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新人ID
|
||||
/// </summary>
|
||||
[Description("最后更新人ID")]
|
||||
[Browsable(false)]
|
||||
public string UpdateUserId { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新人
|
||||
/// </summary>
|
||||
[Description("最后更新人")]
|
||||
public string UpdateUserName { get; set; }
|
||||
}
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 资源表
|
||||
/// </summary>
|
||||
[Table("SysResource")]
|
||||
public partial class SysResource : TreeEntity
|
||||
{
|
||||
public SysResource()
|
||||
{
|
||||
this.Name= string.Empty;
|
||||
this.SortNo= 0;
|
||||
this.Description= string.Empty;
|
||||
this.AppId= string.Empty;
|
||||
this.AppName= string.Empty;
|
||||
this.TypeName= string.Empty;
|
||||
this.TypeId= string.Empty;
|
||||
this.CreateTime= DateTime.Now;
|
||||
this.CreateUserId= string.Empty;
|
||||
this.CreateUserName= string.Empty;
|
||||
this.UpdateTime= DateTime.Now;
|
||||
this.UpdateUserId= string.Empty;
|
||||
this.UpdateUserName= string.Empty;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 排序号
|
||||
/// </summary>
|
||||
[Description("排序号")]
|
||||
public int SortNo { get; set; }
|
||||
/// <summary>
|
||||
/// 描述
|
||||
/// </summary>
|
||||
[Description("描述")]
|
||||
public string Description { get; set; }
|
||||
/// <summary>
|
||||
/// 资源所属应用ID
|
||||
/// </summary>
|
||||
[Description("资源所属应用ID")]
|
||||
[Browsable(false)]
|
||||
public string AppId { get; set; }
|
||||
/// <summary>
|
||||
/// 所属应用名称
|
||||
/// </summary>
|
||||
[Description("所属应用名称")]
|
||||
public string AppName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
[Description("分类名称")]
|
||||
public string TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类ID
|
||||
/// </summary>
|
||||
[Description("分类ID")]
|
||||
[Browsable(false)]
|
||||
public string TypeId { get; set; }
|
||||
/// <summary>
|
||||
/// 是否可用
|
||||
/// </summary>
|
||||
[Description("是否可用")]
|
||||
public bool Disable { get; set; }
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[Description("创建时间")]
|
||||
public System.DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人ID
|
||||
/// </summary>
|
||||
[Description("创建人ID")]
|
||||
[Browsable(false)]
|
||||
public string CreateUserId { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Description("创建人")]
|
||||
public string CreateUserName { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新时间
|
||||
/// </summary>
|
||||
[Description("最后更新时间")]
|
||||
public System.DateTime? UpdateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新人ID
|
||||
/// </summary>
|
||||
[Description("最后更新人ID")]
|
||||
[Browsable(false)]
|
||||
public string UpdateUserId { get; set; }
|
||||
/// <summary>
|
||||
/// 最后更新人
|
||||
/// </summary>
|
||||
[Description("最后更新人")]
|
||||
public string UpdateUserName { get; set; }
|
||||
}
|
||||
}
|
@ -1,95 +1,95 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户基本信息表
|
||||
/// </summary>
|
||||
[Table("User")]
|
||||
public partial class User : StringEntity
|
||||
{
|
||||
public User()
|
||||
{
|
||||
this.Account= string.Empty;
|
||||
this.Password= string.Empty;
|
||||
this.Name= string.Empty;
|
||||
this.Sex= 0;
|
||||
this.Status= 0;
|
||||
this.BizCode= string.Empty;
|
||||
this.CreateTime= DateTime.Now;
|
||||
this.CreateId= string.Empty;
|
||||
this.TypeName= string.Empty;
|
||||
this.TypeId= string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录帐号
|
||||
/// </summary>
|
||||
[Description("用户登录帐号")]
|
||||
public string Account { get; set; }
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
[Description("密码")]
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// 用户姓名
|
||||
/// </summary>
|
||||
[Description("用户姓名")]
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
[Description("性别")]
|
||||
public int Sex { get; set; }
|
||||
/// <summary>
|
||||
/// 用户状态
|
||||
/// </summary>
|
||||
[Description("用户状态")]
|
||||
public int Status { get; set; }
|
||||
/// <summary>
|
||||
/// 业务对照码
|
||||
/// </summary>
|
||||
[Description("业务对照码")]
|
||||
public string BizCode { get; set; }
|
||||
/// <summary>
|
||||
/// 经办时间
|
||||
/// </summary>
|
||||
[Description("经办时间")]
|
||||
public System.DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Description("创建人")]
|
||||
public string CreateId { get; set; }
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
[Description("分类名称")]
|
||||
public string TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类ID
|
||||
/// </summary>
|
||||
[Description("分类ID")]
|
||||
public string TypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 直接上级
|
||||
/// </summary>
|
||||
[Description("直接上级")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
// <autogenerated>
|
||||
// This code was generated by a CodeSmith Template.
|
||||
//
|
||||
// DO NOT MODIFY contents of this file. Changes to this
|
||||
// file will be lost if the code is regenerated.
|
||||
// Author:Yubao Li
|
||||
// </autogenerated>
|
||||
//------------------------------------------------------------------------------
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using OpenAuth.Repository.Core;
|
||||
|
||||
namespace OpenAuth.Repository.Domain
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户基本信息表
|
||||
/// </summary>
|
||||
[Table("SysUser")]
|
||||
public partial class SysUser : StringEntity
|
||||
{
|
||||
public SysUser()
|
||||
{
|
||||
this.Account= string.Empty;
|
||||
this.Password= string.Empty;
|
||||
this.Name= string.Empty;
|
||||
this.Sex= 0;
|
||||
this.Status= 0;
|
||||
this.BizCode= string.Empty;
|
||||
this.CreateTime= DateTime.Now;
|
||||
this.CreateId= string.Empty;
|
||||
this.TypeName= string.Empty;
|
||||
this.TypeId= string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录帐号
|
||||
/// </summary>
|
||||
[Description("用户登录帐号")]
|
||||
public string Account { get; set; }
|
||||
/// <summary>
|
||||
/// 密码
|
||||
/// </summary>
|
||||
[Description("密码")]
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// 用户姓名
|
||||
/// </summary>
|
||||
[Description("用户姓名")]
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// 性别
|
||||
/// </summary>
|
||||
[Description("性别")]
|
||||
public int Sex { get; set; }
|
||||
/// <summary>
|
||||
/// 用户状态
|
||||
/// </summary>
|
||||
[Description("用户状态")]
|
||||
public int Status { get; set; }
|
||||
/// <summary>
|
||||
/// 业务对照码
|
||||
/// </summary>
|
||||
[Description("业务对照码")]
|
||||
public string BizCode { get; set; }
|
||||
/// <summary>
|
||||
/// 经办时间
|
||||
/// </summary>
|
||||
[Description("经办时间")]
|
||||
public System.DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[Description("创建人")]
|
||||
public string CreateId { get; set; }
|
||||
/// <summary>
|
||||
/// 分类名称
|
||||
/// </summary>
|
||||
[Description("分类名称")]
|
||||
public string TypeName { get; set; }
|
||||
/// <summary>
|
||||
/// 分类ID
|
||||
/// </summary>
|
||||
[Description("分类ID")]
|
||||
public string TypeId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 直接上级
|
||||
/// </summary>
|
||||
[Description("直接上级")]
|
||||
public string ParentId { get; set; }
|
||||
|
||||
}
|
||||
}
|
@ -7,9 +7,9 @@ namespace OpenAuth.Repository.Domain
|
||||
/// </summary>
|
||||
public static class UserExt
|
||||
{
|
||||
public static void CheckPassword(this User user, string password)
|
||||
public static void CheckPassword(this SysUser sysUser, string password)
|
||||
{
|
||||
if (user.Password != password)
|
||||
if (sysUser.Password != password)
|
||||
{
|
||||
throw new Exception("密码错误");
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using Infrastructure.Extensions;
|
||||
using Infrastructure.Utilities;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Logging;
|
||||
@ -106,6 +107,24 @@ namespace OpenAuth.Repository
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//如果数据库是Oracle,则将所有表名和字段名转换为大写
|
||||
if (Database.ProviderName == "Oracle.EntityFrameworkCore")
|
||||
{
|
||||
foreach (var entity in modelBuilder.Model.GetEntityTypes())
|
||||
{
|
||||
entity.SetTableName(entity.GetTableName().ToUpper());
|
||||
// 将所有属性映射到大写列名
|
||||
foreach (var property in entity.GetProperties())
|
||||
{
|
||||
var storeObject = StoreObjectIdentifier.Create(entity, StoreObjectType.Table);
|
||||
if (storeObject.HasValue)
|
||||
{
|
||||
property.SetColumnName(property.GetColumnName(storeObject.Value).ToUpper());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public virtual DbSet<Application> Applications { get; set; }
|
||||
@ -120,9 +139,9 @@ namespace OpenAuth.Repository
|
||||
public virtual DbSet<ModuleElement> ModuleElements { get; set; }
|
||||
public virtual DbSet<SysOrg> Orgs { get; set; }
|
||||
public virtual DbSet<Relevance> Relevances { get; set; }
|
||||
public virtual DbSet<Resource> Resources { get; set; }
|
||||
public virtual DbSet<SysResource> Resources { get; set; }
|
||||
public virtual DbSet<Role> Roles { get; set; }
|
||||
public virtual DbSet<User> Users { get; set; }
|
||||
public virtual DbSet<SysUser> Users { get; set; }
|
||||
public virtual DbSet<UploadFile> UploadFiles { get; set; }
|
||||
public virtual DbSet<SysPrinterPlan> SysPrinterPlans { get; set; }
|
||||
public virtual DbSet<FrmLeaveReq> FrmLeaveReqs { get; set; }
|
||||
|
@ -21,7 +21,7 @@ namespace OpenAuth.Repository.Test
|
||||
var account = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
Console.WriteLine(account);
|
||||
|
||||
dbcontext.Users.Add(new User
|
||||
dbcontext.Users.Add(new SysUser
|
||||
{
|
||||
Account = account,
|
||||
Name = account,
|
||||
@ -83,10 +83,10 @@ namespace OpenAuth.Repository.Test
|
||||
|
||||
Console.WriteLine(account);
|
||||
|
||||
var repository = _autofacServiceProvider.GetService<IRepository<User,OpenAuthDBContext>>();
|
||||
var repository = _autofacServiceProvider.GetService<IRepository<SysUser,OpenAuthDBContext>>();
|
||||
|
||||
//新增
|
||||
repository.Add(new User
|
||||
repository.Add(new SysUser
|
||||
{
|
||||
Account = account,
|
||||
Name = account,
|
||||
@ -105,7 +105,7 @@ namespace OpenAuth.Repository.Test
|
||||
Assert.NotNull(newuser);
|
||||
|
||||
//批量修改
|
||||
repository.Update(u => u.Id == id, u =>new User{ Name = account});
|
||||
repository.Update(u => u.Id == id, u =>new SysUser{ Name = account});
|
||||
newuser = repository.FirstOrDefault(u => u.Name == account);
|
||||
Assert.NotNull(newuser);
|
||||
|
||||
|
@ -52,7 +52,7 @@ namespace OpenAuth.Repository.Test
|
||||
}
|
||||
";
|
||||
|
||||
var query = sugarClient.Queryable<User>().GenerateFilter("c",json);
|
||||
var query = sugarClient.Queryable<SysUser>().GenerateFilter("c",json);
|
||||
Console.WriteLine(query.ToSqlString());
|
||||
|
||||
Console.WriteLine(JsonHelper.Instance.Serialize(query.ToList()));
|
||||
@ -100,7 +100,7 @@ namespace OpenAuth.Repository.Test
|
||||
|
||||
var sugarClient = _autofacServiceProvider.GetService<ISqlSugarClient>();
|
||||
|
||||
var query = sugarClient.Queryable<User>().GenerateFilter("c",queryObject);
|
||||
var query = sugarClient.Queryable<SysUser>().GenerateFilter("c",queryObject);
|
||||
Console.WriteLine(query.ToSqlString());
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ namespace OpenAuth.Repository.Test
|
||||
}
|
||||
|
||||
//如果没有插入成功,表示事务发生了回滚
|
||||
Assert.IsFalse(unitWork.Any<User>( u=>u.Id == account));
|
||||
Assert.IsFalse(unitWork.Any<SysUser>( u=>u.Id == account));
|
||||
|
||||
}
|
||||
|
||||
@ -60,7 +60,7 @@ namespace OpenAuth.Repository.Test
|
||||
/// </summary>
|
||||
private void AddAndUpdate(string account, IUnitWork<OpenAuthDBContext> unitWork)
|
||||
{
|
||||
var user = new User
|
||||
var user = new SysUser
|
||||
{
|
||||
Id = account,
|
||||
Account = account,
|
||||
@ -78,7 +78,7 @@ namespace OpenAuth.Repository.Test
|
||||
|
||||
unitWork.Save();
|
||||
|
||||
unitWork.Update<User>(u => u.Id == account, u => new User
|
||||
unitWork.Update<SysUser>(u => u.Id == account, u => new SysUser
|
||||
{
|
||||
Account = "Trans2_" + user.Account
|
||||
});
|
||||
@ -90,7 +90,7 @@ namespace OpenAuth.Repository.Test
|
||||
{
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
|
||||
|
||||
var users = unitWork.Find<User>(u => u.Account.Contains("test"));
|
||||
var users = unitWork.Find<SysUser>(u => u.Account.Contains("test"));
|
||||
foreach (var user in users)
|
||||
{
|
||||
user.Name = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss");
|
||||
@ -105,12 +105,12 @@ namespace OpenAuth.Repository.Test
|
||||
public void MultiUpdate2()
|
||||
{
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
|
||||
var users = unitWork.Find<User>(null).ToList();
|
||||
var users = unitWork.Find<SysUser>(null).ToList();
|
||||
unitWork.ExecuteWithTransaction(()=>
|
||||
{
|
||||
foreach (var req in users)
|
||||
{
|
||||
unitWork.Update<User>(u =>u.Id == req.Id, user => new User
|
||||
unitWork.Update<SysUser>(u =>u.Id == req.Id, user => new SysUser
|
||||
{
|
||||
Name = "user_" + DateTime.Now.ToString("yyyy_MM_dd HH:mm:ss")
|
||||
});
|
||||
|
@ -23,7 +23,7 @@ namespace OpenAuth.Repository.Test
|
||||
public void ExecProcedure()
|
||||
{
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
|
||||
var users = unitWork.ExecProcedure<User>("sp_alluser");
|
||||
var users = unitWork.ExecProcedure<SysUser>("sp_alluser");
|
||||
Console.WriteLine(JsonHelper.Instance.Serialize(users));
|
||||
}
|
||||
|
||||
@ -37,7 +37,7 @@ namespace OpenAuth.Repository.Test
|
||||
var unitWork = _autofacServiceProvider.GetService<IUnitWork<OpenAuthDBContext>>();
|
||||
var param = new MySqlParameter("keyword", SqlDbType.NVarChar);
|
||||
param.Value = "test%";
|
||||
var users = unitWork.ExecProcedure<User>("sp_alluser", new []{param});
|
||||
var users = unitWork.ExecProcedure<SysUser>("sp_alluser", new []{param});
|
||||
Console.WriteLine(JsonHelper.Instance.Serialize(users));
|
||||
}
|
||||
|
||||
|
@ -273,9 +273,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// 获取登录用户的所有可访问的资源
|
||||
/// </summary>
|
||||
[HttpGet]
|
||||
public Response<List<Resource>> GetResources()
|
||||
public Response<List<SysResource>> GetResources()
|
||||
{
|
||||
var result = new Response<List<Resource>>();
|
||||
var result = new Response<List<SysResource>>();
|
||||
try
|
||||
{
|
||||
result.Result = _authStrategyContext.Resources;
|
||||
|
@ -87,9 +87,9 @@ namespace OpenAuth.WebApi.Controllers
|
||||
/// <param name="appId">应用ID</param>
|
||||
/// <param name="firstId">角色ID</param>
|
||||
[HttpGet]
|
||||
public Response<List<Resource>> LoadForRole(string appId, string firstId)
|
||||
public Response<List<SysResource>> LoadForRole(string appId, string firstId)
|
||||
{
|
||||
var result = new Response<List<Resource>>();
|
||||
var result = new Response<List<SysResource>>();
|
||||
try
|
||||
{
|
||||
result.Result = _app.LoadForRole(appId, firstId).ToList();
|
||||
|
Loading…
Reference in New Issue
Block a user