mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-08-23 13:06:48 +08:00
fix #I81YQA SqlSugar使用MySql时异常
This commit is contained in:
parent
852d52436a
commit
367158e33f
@ -47,10 +47,6 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
return Repository.GetFirst(u => u.AppSecret == modelAppKey);
|
return Repository.GetFirst(u => u.AppSecret == modelAppKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(string[] ids)
|
|
||||||
{
|
|
||||||
Repository.DeleteByIds(ids);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -9,6 +9,10 @@ using SqlSugar;
|
|||||||
|
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// SqlSugar基础类
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
public abstract class SqlSugarBaseApp<T> where T : class, new()
|
public abstract class SqlSugarBaseApp<T> where T : class, new()
|
||||||
{
|
{
|
||||||
protected ISqlSugarClient SugarClient;
|
protected ISqlSugarClient SugarClient;
|
||||||
@ -23,6 +27,16 @@ namespace OpenAuth.App
|
|||||||
SugarClient = client;
|
SugarClient = client;
|
||||||
_auth = auth;
|
_auth = auth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Delete(string[] ids)
|
||||||
|
{
|
||||||
|
Repository.DeleteByIds(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T Get(string id)
|
||||||
|
{
|
||||||
|
return SugarClient.Queryable<T>().Where("Id=@id", new {id = id}).First();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取当前登录用户的数据访问权限
|
/// 获取当前登录用户的数据访问权限
|
||||||
|
@ -96,10 +96,6 @@ namespace OpenAuth.App
|
|||||||
public ResourceApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
|
public ResourceApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Delete(string[] ids)
|
|
||||||
{
|
|
||||||
Repository.DeleteByIds(ids);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -2,18 +2,16 @@ using System;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using OpenAuth.App.Interface;
|
using OpenAuth.App.Interface;
|
||||||
using OpenAuth.App.Request;
|
using OpenAuth.App.Request;
|
||||||
using OpenAuth.App.Response;
|
using OpenAuth.App.Response;
|
||||||
using OpenAuth.Repository;
|
|
||||||
using OpenAuth.Repository.Domain;
|
using OpenAuth.Repository.Domain;
|
||||||
using OpenAuth.Repository.Interface;
|
using SqlSugar;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenAuth.App
|
namespace OpenAuth.App
|
||||||
{
|
{
|
||||||
public class SysPrinterPlanApp : BaseStringApp<SysPrinterPlan, OpenAuthDBContext>
|
public class SysPrinterPlanApp : SqlSugarBaseApp<SysPrinterPlan>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 加载列表
|
/// 加载列表
|
||||||
@ -42,9 +40,9 @@ namespace OpenAuth.App
|
|||||||
|
|
||||||
var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));
|
var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));
|
||||||
result.columnFields = columnFields;
|
result.columnFields = columnFields;
|
||||||
result.data = objs.OrderBy(u => u.Id)
|
result.data = objs.OrderByDescending(u => u.CreateTime)
|
||||||
.Skip((request.page - 1) * request.limit)
|
.Skip((request.page - 1) * request.limit)
|
||||||
.Take(request.limit).Select($"new ({propertyStr})");
|
.Take(request.limit).Select($"{propertyStr}").ToList();
|
||||||
result.count = await objs.CountAsync();
|
result.count = await objs.CountAsync();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -53,23 +51,24 @@ namespace OpenAuth.App
|
|||||||
{
|
{
|
||||||
//程序类型取入口应用的名称,可以根据自己需要调整
|
//程序类型取入口应用的名称,可以根据自己需要调整
|
||||||
var addObj = obj.MapTo<SysPrinterPlan>();
|
var addObj = obj.MapTo<SysPrinterPlan>();
|
||||||
//addObj.Time = DateTime.Now;
|
addObj.CreateTime = DateTime.Now;
|
||||||
Repository.Add(addObj);
|
addObj.CreateUser = _auth.GetUserName();
|
||||||
|
Repository.Insert(addObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Update(AddOrUpdateSysPrinterPlanReq obj)
|
public void Update(AddOrUpdateSysPrinterPlanReq obj)
|
||||||
{
|
{
|
||||||
UnitWork.Update<SysPrinterPlan>(u => u.Id == obj.Id, u => new SysPrinterPlan
|
Repository.Update(u => new SysPrinterPlan
|
||||||
{
|
{
|
||||||
Name = obj.Name,
|
Name = obj.Name,
|
||||||
SourceSql = obj.SourceSql,
|
SourceSql = obj.SourceSql,
|
||||||
PlanContent = obj.PlanContent
|
PlanContent = obj.PlanContent
|
||||||
});
|
},u => u.Id == obj.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SysPrinterPlanApp(IUnitWork<OpenAuthDBContext> unitWork,
|
public SysPrinterPlanApp(ISqlSugarClient client, IAuth auth) : base(client, auth)
|
||||||
IRepository<SysPrinterPlan, OpenAuthDBContext> repository, IAuth auth) : base(unitWork, repository, auth)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user