调整User为SysUser、Resource为SysResource

This commit is contained in:
yubaolee
2025-02-19 12:44:42 +08:00
parent 839256e8bb
commit 2a2d83d026
27 changed files with 417 additions and 426 deletions

View File

@@ -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; }
}
}

View File

@@ -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; }
}
}

View File

@@ -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("密码错误");
}

View File

@@ -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; }

View File

@@ -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);

View File

@@ -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());
}
}

View File

@@ -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")
});

View File

@@ -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));
}