Merge commit 'd1108700e0ad43b6bfea3f9a79bbb14799a2d29c'

This commit is contained in:
SimpleJouer
2023-08-16 15:31:25 +08:00
18 changed files with 73 additions and 96 deletions

View File

@@ -82,6 +82,7 @@ namespace Infrastructure
public class Gen public class Gen
{ {
public bool ShowApp { get; set; }
public bool AutoPre { get; set; } public bool AutoPre { get; set; }
public string VuePath { get; set; } public string VuePath { get; set; }
public string Author { get; set; } public string Author { get; set; }

View File

@@ -93,9 +93,10 @@ namespace ZR.Admin.WebApi.Controllers.System
} }
user.Create_by = HttpContext.GetName(); user.Create_by = HttpContext.GetName();
user.Create_time = DateTime.Now;
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password); user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
return ToResponse(UserService.InsertUser(user)); return SUCCESS(UserService.InsertUser(user));
} }
/// <summary> /// <summary>

View File

@@ -68,27 +68,30 @@ namespace ZR.Admin.WebApi.Extensions
private static void SetSugarAop(SqlSugarClient db, IocConfig iocConfig, ICacheService cache) private static void SetSugarAop(SqlSugarClient db, IocConfig iocConfig, ICacheService cache)
{ {
var config = db.GetConnectionScope(iocConfig.ConfigId).CurrentConnectionConfig; var config = db.GetConnectionScope(iocConfig.ConfigId).CurrentConnectionConfig;
var showDbLog = AppSettings.Get<bool>("ShowDbLog");
string configId = config.ConfigId; string configId = config.ConfigId;
db.GetConnectionScope(configId).Aop.OnLogExecuting = (sql, pars) => db.GetConnectionScope(configId).Aop.OnLogExecuting = (sql, pars) =>
{ {
string log = $"【db{configId} SQL语句】{UtilMethods.GetSqlString(config.DbType, sql, pars)}\n"; if (showDbLog)
if (sql.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
{ {
logger.Info(log); string log = $"【db{configId} SQL语句】{UtilMethods.GetSqlString(config.DbType, sql, pars)}\n";
} if (sql.TrimStart().StartsWith("SELECT", StringComparison.OrdinalIgnoreCase))
else if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase)) {
{ logger.Info(log);
logger.Warn(log); }
} else if (sql.StartsWith("UPDATE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("INSERT", StringComparison.OrdinalIgnoreCase))
else if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("TRUNCATE", StringComparison.OrdinalIgnoreCase)) {
{ logger.Warn(log);
logger.Error(log); }
} else if (sql.StartsWith("DELETE", StringComparison.OrdinalIgnoreCase) || sql.StartsWith("TRUNCATE", StringComparison.OrdinalIgnoreCase))
else {
{ logger.Error(log);
log = $"【db{configId} SQL语句】dbo.{sql} {string.Join(", ", pars.Select(x => x.ParameterName + " = " + GetParsValue(x)))};\n"; }
logger.Info(log); else
{
log = $"【db{configId} SQL语句】dbo.{sql} {string.Join(", ", pars.Select(x => x.ParameterName + " = " + GetParsValue(x)))};\n";
logger.Info(log);
}
} }
}; };
db.GetConnectionScope(configId).Aop.OnError = (ex) => db.GetConnectionScope(configId).Aop.OnError = (ex) =>

View File

@@ -33,6 +33,7 @@
"Expire": 1440 //jwt登录过期时间 "Expire": 1440 //jwt登录过期时间
}, },
"InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks" ], //自动注入类 "InjectClass": [ "ZR.Repository", "ZR.Service", "ZR.Tasks" ], //自动注入类
"ShowDbLog": true,//是否打印db日志
"InitDb": false, //是否初始化db "InitDb": false, //是否初始化db
"DemoMode": false, //是否演示模式 "DemoMode": false, //是否演示模式
"Upload": { "Upload": {
@@ -64,7 +65,10 @@
}, },
//代码生成配置 //代码生成配置
"gen": { "gen": {
"autoPre": true, //自动去除表前缀 //是否显示移动端代码生成
"showApp": false,
//自动去除表前缀
"autoPre": true,
"author": "admin", "author": "admin",
"tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)", "tablePrefix": "sys_", //"表前缀(生成类名不会包含表前缀,多个用逗号分隔)",
"vuePath": "", //前端代码存储路径egD:\Work\ZRAdmin-Vue3 "vuePath": "", //前端代码存储路径egD:\Work\ZRAdmin-Vue3

View File

@@ -117,7 +117,7 @@ $end
$if(null != genTable.SubTableName && "" != genTable.SubTableName) $if(null != genTable.SubTableName && "" != genTable.SubTableName)
return Context.InsertNav(model).Include(s1 => s1.${genTable.SubTable.ClassName}Nav).ExecuteReturnEntity(); return Context.InsertNav(model).Include(s1 => s1.${genTable.SubTable.ClassName}Nav).ExecuteReturnEntity();
$else $else
return Insertable(model).IgnoreColumns(true).ExecuteReturnEntity(); return Context.Insertable(model).ExecuteReturnEntity();
$end $end
} }

View File

@@ -778,7 +778,22 @@ function handlePreview(row) {
open.value = true open.value = true
title.value = '查看' title.value = '查看'
opertype.value = 3 opertype.value = 3
form.value = row form.value = { ...row }
}
$end
$if(replaceDto.ShowBtnImport)
// 导入数据成功处理
const handleFileSuccess = (response) => {
const { item1, item2 } = response.data
var error = ''
item2.forEach((item) => {
error += item.storageMessage + ','
})
proxy.${alert}alert(item1 + '<p>' + error + '</p>', '导入结果', {
dangerouslyUseHTMLString: true
})
getList()
} }
$end $end

View File

@@ -26,11 +26,11 @@ namespace ZR.CodeGenerator
/// <param name="dto"></param> /// <param name="dto"></param>
public static void Generate(GenerateDto dto) public static void Generate(GenerateDto dto)
{ {
var vuePath = AppSettings.GetConfig("gen:vuePath"); var genOptions = AppSettings.Get<Gen>("gen");
dto.VueParentPath = dto.VueVersion == 3 ? "ZRAdmin-vue" : "ZR.Vue"; dto.VueParentPath = dto.VueVersion == 3 ? "ZRAdmin-vue" : "ZR.Vue";
if (!vuePath.IsEmpty()) if (!genOptions.VuePath.IsEmpty())
{ {
dto.VueParentPath = vuePath; dto.VueParentPath = genOptions.VuePath;
} }
dto.GenOptions = GenerateOption(dto.GenTable); dto.GenOptions = GenerateOption(dto.GenTable);
if (dto.GenTable.SubTable != null) if (dto.GenTable.SubTable != null)
@@ -82,9 +82,12 @@ namespace ZR.CodeGenerator
} }
GenerateVueJs(dto); GenerateVueJs(dto);
GenerateSql(dto); GenerateSql(dto);
GenerateAppVueViews(replaceDto, dto); if (genOptions.ShowApp)
GenerateAppVueFormViews(replaceDto, dto); {
GenerateAppJs(dto); GenerateAppVueViews(replaceDto, dto);
GenerateAppVueFormViews(replaceDto, dto);
GenerateAppJs(dto);
}
dto.ReplaceDto = replaceDto; dto.ReplaceDto = replaceDto;
} }

View File

@@ -61,11 +61,11 @@ namespace ZR.Repository
#endregion add #endregion add
#region update #region update
public IUpdateable<T> Updateable(T entity) //public IUpdateable<T> Updateable(T entity)
{ //{
return Context.Updateable(entity); // return Context.Updateable(entity);
} //}
/// <summary> /// <summary>
/// 实体根据主键更新 /// 实体根据主键更新
/// </summary> /// </summary>
@@ -103,37 +103,6 @@ namespace ZR.Repository
return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand(); return Context.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
} }
public int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where)
{
return client.Updateable(entity).UpdateColumns(expression).Where(where).ExecuteCommand();
}
/// <summary>
///
/// </summary>
/// <param name="entity"></param>
/// <param name="list"></param>
/// <param name="isNull">默认为true</param>
/// <returns></returns>
public int Update(T entity, List<string> list = null, bool isNull = true)
{
list ??= new List<string>()
{
"Create_By",
"Create_time"
};
return Context.Updateable(entity).IgnoreColumns(isNull).IgnoreColumns(list.ToArray()).ExecuteCommand();
}
//public bool Update(List<T> entity)
//{
// var result = base.Context.Ado.UseTran(() =>
// {
// base.Context.Updateable(entity).ExecuteCommand();
// });
// return result.IsSuccess;
//}
/// <summary> /// <summary>
/// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" }); /// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" });
/// </summary> /// </summary>
@@ -160,14 +129,6 @@ namespace ZR.Repository
throw; throw;
} }
} }
public IStorageable<T> Storageable(T t)
{
return Context.Storageable<T>(t);
}
public IStorageable<T> Storageable(List<T> t)
{
return Context.Storageable(t);
}
/// <summary> /// <summary>
/// ///

View File

@@ -19,7 +19,6 @@ namespace ZR.Repository
#endregion add #endregion add
#region update #region update
IUpdateable<T> Updateable(T entity);
int Update(T entity, bool ignoreNullColumns = false); int Update(T entity, bool ignoreNullColumns = false);
/// <summary> /// <summary>
@@ -32,13 +31,9 @@ namespace ZR.Repository
int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where); int Update(T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
int Update(SqlSugarClient client, T entity, Expression<Func<T, object>> expression, Expression<Func<T, bool>> where);
int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns); int Update(Expression<Func<T, bool>> where, Expression<Func<T, T>> columns);
#endregion update #endregion update
IStorageable<T> Storageable(T t);
IStorageable<T> Storageable(List<T> t);
DbResult<bool> UseTran(Action action); DbResult<bool> UseTran(Action action);
DbResult<bool> UseTran(SqlSugarClient client, Action action); DbResult<bool> UseTran(SqlSugarClient client, Action action);

View File

@@ -8,11 +8,5 @@ namespace ZR.Service
/// <typeparam name="T"></typeparam> /// <typeparam name="T"></typeparam>
public class BaseService<T> : BaseRepository<T> where T : class, new() public class BaseService<T> : BaseRepository<T> where T : class, new()
{ {
//public IBaseRepository<T> baseRepository;
//public BaseService(IBaseRepository<T> repository)
//{
// this.baseRepository = repository ?? throw new ArgumentNullException(nameof(repository));
//}
} }
} }

View File

@@ -82,7 +82,7 @@ namespace ZR.Service.System
LangName = item.LangName, LangName = item.LangName,
}); });
} }
var storage = Storageable(langs) var storage = Context.Storageable(langs)
.WhereColumns(it => new { it.LangKey, it.LangCode }) .WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage(); .ToStorage();
@@ -110,7 +110,11 @@ namespace ZR.Service.System
/// <returns></returns> /// <returns></returns>
public (string, object, object) ImportCommonLang(List<CommonLang> list) public (string, object, object) ImportCommonLang(List<CommonLang> list)
{ {
<<<<<<< HEAD
var x = Storageable(list) var x = Storageable(list)
=======
var x = Context.Storageable(list)
>>>>>>> d1108700e0ad43b6bfea3f9a79bbb14799a2d29c
.WhereColumns(it => new { it.LangKey, it.LangCode }) .WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage(); .ToStorage();
x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分; x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分;

View File

@@ -28,7 +28,7 @@ namespace ZR.Service.System.IService
/// </summary> /// </summary>
/// <param name="sysUser"></param> /// <param name="sysUser"></param>
/// <returns></returns> /// <returns></returns>
public long InsertUser(SysUser sysUser); public SysUser InsertUser(SysUser sysUser);
/// <summary> /// <summary>
/// 修改用户信息 /// 修改用户信息

View File

@@ -700,7 +700,7 @@ namespace ZR.Service
} }
//Insert(menuList); //Insert(menuList);
var x = Storageable(menuList) var x = Context.Storageable(menuList)
.SplitInsert(it => !it.Any()) .SplitInsert(it => !it.Any())
.SplitUpdate(it => !it.Any()) .SplitUpdate(it => !it.Any())
.WhereColumns(it => new { it.MenuName, it.ParentId }) .WhereColumns(it => new { it.MenuName, it.ParentId })

View File

@@ -1,6 +1,5 @@
using Infrastructure.Attribute; using Infrastructure.Attribute;
using SqlSugar; using SqlSugar;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using ZR.Model.System; using ZR.Model.System;
using ZR.Service.System.IService; using ZR.Service.System.IService;
@@ -20,15 +19,14 @@ namespace ZR.Service.System
public void InsertUserPost(SysUser user) public void InsertUserPost(SysUser user)
{ {
// 新增用户与岗位管理 // 新增用户与岗位管理
List<SysUserPost> list = new List<SysUserPost>(); List<SysUserPost> list = new();
foreach (var item in user.PostIds) foreach (var item in user.PostIds)
{ {
list.Add(new SysUserPost() { PostId = item, UserId = user.UserId }); list.Add(new SysUserPost() { PostId = item, UserId = user.UserId });
} }
Insert(list); InsertRange(list);
} }
/// <summary> /// <summary>
/// 查询用户岗位集合 /// 查询用户岗位集合
/// </summary> /// </summary>

View File

@@ -105,16 +105,14 @@ namespace ZR.Service
/// </summary> /// </summary>
/// <param name="sysUser"></param> /// <param name="sysUser"></param>
/// <returns></returns> /// <returns></returns>
public long InsertUser(SysUser sysUser) public SysUser InsertUser(SysUser sysUser)
{ {
sysUser.Create_time = DateTime.Now; sysUser.UserId = Insertable(sysUser).ExecuteReturnIdentity();
long userId = Insertable(sysUser).ExecuteReturnIdentity();
sysUser.UserId = userId;
//新增用户角色信息 //新增用户角色信息
UserRoleService.InsertUserRole(sysUser); UserRoleService.InsertUserRole(sysUser);
//新增用户岗位信息 //新增用户岗位信息
UserPostService.InsertUserPost(sysUser); UserPostService.InsertUserPost(sysUser);
return userId; return sysUser;
} }
/// <summary> /// <summary>

View File

@@ -7,8 +7,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="7.0.0" />
<PackageReference Include="NLog" Version="5.2.0" /> <PackageReference Include="NLog" Version="5.2.0" />
<PackageReference Include="Quartz" Version="3.6.2" /> <PackageReference Include="Quartz" Version="3.7.0" />
<PackageReference Include="Quartz.Serialization.Json" Version="3.6.2" /> <PackageReference Include="Quartz.Serialization.Json" Version="3.7.0" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB