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 bool ShowApp { get; set; }
public bool AutoPre { get; set; }
public string VuePath { 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_time = DateTime.Now;
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
return ToResponse(UserService.InsertUser(user));
return SUCCESS(UserService.InsertUser(user));
}
/// <summary>

View File

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

View File

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

View File

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

View File

@@ -778,7 +778,22 @@ function handlePreview(row) {
open.value = true
title.value = '查看'
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

View File

@@ -26,11 +26,11 @@ namespace ZR.CodeGenerator
/// <param name="dto"></param>
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";
if (!vuePath.IsEmpty())
if (!genOptions.VuePath.IsEmpty())
{
dto.VueParentPath = vuePath;
dto.VueParentPath = genOptions.VuePath;
}
dto.GenOptions = GenerateOption(dto.GenTable);
if (dto.GenTable.SubTable != null)
@@ -82,9 +82,12 @@ namespace ZR.CodeGenerator
}
GenerateVueJs(dto);
GenerateSql(dto);
GenerateAppVueViews(replaceDto, dto);
GenerateAppVueFormViews(replaceDto, dto);
GenerateAppJs(dto);
if (genOptions.ShowApp)
{
GenerateAppVueViews(replaceDto, dto);
GenerateAppVueFormViews(replaceDto, dto);
GenerateAppJs(dto);
}
dto.ReplaceDto = replaceDto;
}

View File

@@ -61,11 +61,11 @@ namespace ZR.Repository
#endregion add
#region update
public IUpdateable<T> Updateable(T entity)
{
return Context.Updateable(entity);
}
//public IUpdateable<T> Updateable(T entity)
//{
// return Context.Updateable(entity);
//}
/// <summary>
/// 实体根据主键更新
/// </summary>
@@ -103,37 +103,6 @@ namespace ZR.Repository
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>
/// 更新指定列 egUpdate(w => w.NoticeId == model.NoticeId, it => new SysNotice(){ Update_time = DateTime.Now, Title = "通知标题" });
/// </summary>
@@ -160,14 +129,6 @@ namespace ZR.Repository
throw;
}
}
public IStorageable<T> Storageable(T t)
{
return Context.Storageable<T>(t);
}
public IStorageable<T> Storageable(List<T> t)
{
return Context.Storageable(t);
}
/// <summary>
///

View File

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

View File

@@ -8,11 +8,5 @@ namespace ZR.Service
/// <typeparam name="T"></typeparam>
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,
});
}
var storage = Storageable(langs)
var storage = Context.Storageable(langs)
.WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage();
@@ -110,7 +110,11 @@ namespace ZR.Service.System
/// <returns></returns>
public (string, object, object) ImportCommonLang(List<CommonLang> list)
{
<<<<<<< HEAD
var x = Storageable(list)
=======
var x = Context.Storageable(list)
>>>>>>> d1108700e0ad43b6bfea3f9a79bbb14799a2d29c
.WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage();
x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分;

View File

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

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.4 KiB