:recycle:代码重构
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public class BaseService<T> : BaseRepository<T> where T : class, new()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
/// <summary>
|
||||
/// API授权判断
|
||||
/// </summary>
|
||||
public class ActionPermissionFilter : ActionFilterAttribute//, IAsyncActionFilter
|
||||
{
|
||||
private NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// 权限字符串,例如 system:user:view
|
||||
/// </summary>
|
||||
public string Permission { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 角色字符串,例如 common,admin
|
||||
/// </summary>
|
||||
public string RolePermi { get; set; } = string.Empty;
|
||||
private bool HasPermi { get; set; }
|
||||
public ActionPermissionFilter() { }
|
||||
public ActionPermissionFilter(string permission)
|
||||
{
|
||||
Permission = permission;
|
||||
HasPermi = !string.IsNullOrEmpty(Permission);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 执行Action前校验是否有权限访问
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="next"></param>
|
||||
/// <returns></returns>
|
||||
public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
TokenModel info = JwtUtil.GetLoginUser(context.HttpContext);
|
||||
|
||||
if (info != null && info?.UserId > 0)
|
||||
{
|
||||
long userId = info.UserId;
|
||||
List<string> perms = CacheService.GetUserPerms(GlobalConstant.UserPermKEY + userId);
|
||||
List<string> rolePerms = info.RoleIds;
|
||||
|
||||
if (perms == null)
|
||||
{
|
||||
var sysPermissionService = App.GetService<ISysPermissionService>();
|
||||
perms = sysPermissionService.GetMenuPermission(new SysUser() { UserId = userId });
|
||||
|
||||
CacheService.SetUserPerms(GlobalConstant.UserPermKEY + userId, perms);
|
||||
}
|
||||
|
||||
if (perms.Exists(f => f.Equals(GlobalConstant.AdminPerm)))
|
||||
{
|
||||
HasPermi = true;
|
||||
}
|
||||
else if (rolePerms.Exists(f => f.Equals(GlobalConstant.AdminRole)))
|
||||
{
|
||||
HasPermi = true;
|
||||
}
|
||||
else if (!string.IsNullOrEmpty(Permission))
|
||||
{
|
||||
HasPermi = perms.Exists(f => f.ToLower() == Permission.ToLower());
|
||||
}
|
||||
if (!HasPermi && !string.IsNullOrEmpty(RolePermi))
|
||||
{
|
||||
HasPermi = info.RoleIds.Contains(RolePermi);
|
||||
}
|
||||
bool isDemoMode = AppSettings.GetAppConfig("DemoMode", false);
|
||||
var url = context.HttpContext.Request.Path;
|
||||
//演示公开环境屏蔽权限
|
||||
string[] denyPerms = new string[] { "update", "add", "remove", "add", "edit", "delete", "import", "run", "start", "stop", "clear", "send", "export", "upload", "common", "gencode", "reset", "forceLogout", "batchLogout" };
|
||||
if (isDemoMode && denyPerms.Any(f => Permission.Contains(f, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
context.Result = new JsonResult(new { code = (int)ResultCode.FORBIDDEN, msg = "演示模式 , 不允许操作" });
|
||||
}
|
||||
if (!HasPermi && !Permission.Equals("common"))
|
||||
{
|
||||
logger.Info($"用户{info.UserName}没有权限访问{url},当前权限[{Permission}]");
|
||||
JsonResult result = new(new ApiResult()
|
||||
{
|
||||
Code = (int)ResultCode.FORBIDDEN,
|
||||
Msg = $"你当前没有权限[{Permission}]访问,请联系管理员",
|
||||
Data = url
|
||||
})
|
||||
{
|
||||
ContentType = "application/json",
|
||||
};
|
||||
context.Result = result;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnActionExecutionAsync(context, next);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using IPTools.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using NLog;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
public class GlobalActionMonitor : ActionFilterAttribute
|
||||
{
|
||||
static readonly Logger logger = LogManager.GetCurrentClassLogger();
|
||||
private readonly ISysOperLogService OperLogService;
|
||||
public GlobalActionMonitor(ISysOperLogService operLogService)
|
||||
{
|
||||
OperLogService = operLogService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Action请求前
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
/// <param name="next"></param>
|
||||
/// <returns></returns>
|
||||
public override Task OnActionExecutionAsync(ActionExecutingContext context, ActionExecutionDelegate next)
|
||||
{
|
||||
string msg = string.Empty;
|
||||
var values = context.ModelState.Values;
|
||||
foreach (var item in values)
|
||||
{
|
||||
foreach (var err in item.Errors)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
msg += " | ";
|
||||
}
|
||||
|
||||
msg += err.ErrorMessage;
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(msg))
|
||||
{
|
||||
logger.Info($"请求参数错误,{msg}");
|
||||
ApiResult response = new()
|
||||
{
|
||||
Code = (int)ResultCode.PARAM_ERROR,
|
||||
Msg = msg
|
||||
};
|
||||
context.Result = new JsonResult(response);
|
||||
}
|
||||
return base.OnActionExecutionAsync(context, next);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// OnActionExecuted是在Action中的代码执行之后运行的方法。
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public override void OnResultExecuted(ResultExecutedContext context)
|
||||
{
|
||||
if (context.ActionDescriptor is not ControllerActionDescriptor controllerActionDescriptor) return;
|
||||
|
||||
//获得注解信息
|
||||
LogAttribute logAttribute = GetLogAttribute(controllerActionDescriptor);
|
||||
if (logAttribute == null) return;
|
||||
|
||||
try
|
||||
{
|
||||
string method = context.HttpContext.Request.Method.ToUpper();
|
||||
// 获取当前的用户
|
||||
string userName = context.HttpContext.GetName() ?? context.HttpContext.Request.Headers["userName"];
|
||||
string jsonResult = string.Empty;
|
||||
if (context.Result is ContentResult result && result.ContentType == "application/json")
|
||||
{
|
||||
jsonResult = result.Content.Replace("\r\n", "").Trim();
|
||||
}
|
||||
if (context.Result is JsonResult result2)
|
||||
{
|
||||
jsonResult = result2.Value?.ToString();
|
||||
}
|
||||
//获取当前执行方法的类名
|
||||
//string className = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.Name;
|
||||
//获取当前成员的名称
|
||||
//string methodName = System.Reflection.MethodBase.GetCurrentMethod().Name;
|
||||
string controller = context.RouteData.Values["Controller"].ToString();
|
||||
string action = context.RouteData.Values["Action"].ToString();
|
||||
|
||||
string ip = HttpContextExtension.GetClientUserIp(context.HttpContext);
|
||||
var ip_info = IpTool.Search(ip);
|
||||
|
||||
SysOperLog sysOperLog = new()
|
||||
{
|
||||
Status = 0,
|
||||
OperName = userName,
|
||||
OperIp = ip,
|
||||
OperUrl = HttpContextExtension.GetRequestUrl(context.HttpContext),
|
||||
RequestMethod = method,
|
||||
JsonResult = jsonResult,
|
||||
OperLocation = HttpContextExtension.GetIpInfo(ip),
|
||||
Method = controller + "." + action + "()",
|
||||
//Elapsed = _stopwatch.ElapsedMilliseconds,
|
||||
OperTime = DateTime.Now,
|
||||
OperParam = HttpContextExtension.GetRequestValue(context.HttpContext, method)
|
||||
};
|
||||
|
||||
if (logAttribute != null)
|
||||
{
|
||||
sysOperLog.Title = logAttribute?.Title;
|
||||
sysOperLog.BusinessType = (int)logAttribute.BusinessType;
|
||||
sysOperLog.OperParam = logAttribute.IsSaveRequestData ? sysOperLog.OperParam : "";
|
||||
sysOperLog.JsonResult = logAttribute.IsSaveResponseData ? sysOperLog.JsonResult : "";
|
||||
}
|
||||
|
||||
LogEventInfo ei = new(NLog.LogLevel.Info, "GlobalActionMonitor", "");
|
||||
|
||||
ei.Properties["jsonResult"] = !HttpMethods.IsGet(method) ? jsonResult : "";
|
||||
ei.Properties["requestParam"] = sysOperLog.OperParam;
|
||||
ei.Properties["user"] = userName;
|
||||
logger.Log(ei);
|
||||
|
||||
OperLogService.InsertOperlog(sysOperLog);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.Error(ex, $"记录操作日志出错了#{ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private LogAttribute GetLogAttribute(ControllerActionDescriptor controllerActionDescriptor)
|
||||
{
|
||||
var attribute = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true)
|
||||
.FirstOrDefault(a => a.GetType().Equals(typeof(LogAttribute)));
|
||||
|
||||
return attribute as LogAttribute;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.Controllers;
|
||||
using Microsoft.AspNetCore.Mvc.Filters;
|
||||
using ZR.Common;
|
||||
|
||||
//本命名空间暂时先不改,改动比较大2023年9月2日
|
||||
namespace ZR.Admin.WebApi.Filters
|
||||
{
|
||||
/// <summary>
|
||||
/// 授权校验访问
|
||||
/// 如果跳过授权登录在Action 或controller加上 AllowAnonymousAttribute
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All)]
|
||||
public class VerifyAttribute : Attribute, IAuthorizationFilter
|
||||
{
|
||||
/// <summary>
|
||||
/// 只判断token是否正确,不判断权限
|
||||
/// 如果需要判断权限的在Action上加上ApiActionPermission属性标识权限类别,ActionPermissionFilter作权限处理
|
||||
/// </summary>
|
||||
/// <param name="context"></param>
|
||||
public void OnAuthorization(AuthorizationFilterContext context)
|
||||
{
|
||||
var noNeedCheck = false;
|
||||
if (context.ActionDescriptor is ControllerActionDescriptor controllerActionDescriptor)
|
||||
{
|
||||
noNeedCheck = controllerActionDescriptor.MethodInfo.GetCustomAttributes(inherit: true)
|
||||
.Any(a => a.GetType().Equals(typeof(AllowAnonymousAttribute)));
|
||||
}
|
||||
|
||||
if (noNeedCheck) return;
|
||||
|
||||
string ip = HttpContextExtension.GetClientUserIp(context.HttpContext);
|
||||
string url = context.HttpContext.Request.Path;
|
||||
var isAuthed = context.HttpContext.User.Identity.IsAuthenticated;
|
||||
string osType = context.HttpContext.Request.Headers["os"];
|
||||
//使用jwt token校验2020-11-21
|
||||
TokenModel loginUser = JwtUtil.GetLoginUser(context.HttpContext);
|
||||
if (loginUser != null)
|
||||
{
|
||||
var nowTime = DateTime.UtcNow;
|
||||
TimeSpan ts = loginUser.ExpireTime - nowTime;
|
||||
|
||||
//Console.WriteLine($"jwt到期剩余:{ts.TotalMinutes}分,{ts.TotalSeconds}秒");
|
||||
|
||||
var CK = "token_" + loginUser.UserId;
|
||||
if (!CacheHelper.Exists(CK) && ts.TotalMinutes < 5)
|
||||
{
|
||||
var newToken = JwtUtil.GenerateJwtToken(JwtUtil.AddClaims(loginUser));
|
||||
|
||||
CacheHelper.SetCache(CK, CK, 1);
|
||||
//移动端不加下面这个获取不到自定义Header
|
||||
if (osType != null)
|
||||
{
|
||||
context.HttpContext.Response.Headers.Add("Access-Control-Expose-Headers", "X-Refresh-Token");
|
||||
}
|
||||
context.HttpContext.Response.Headers.Add("X-Refresh-Token", newToken);
|
||||
}
|
||||
}
|
||||
if (loginUser == null || !isAuthed)
|
||||
{
|
||||
string msg = $"请求访问[{url}]失败,无法访问系统资源";
|
||||
//logger.Info(msg);
|
||||
|
||||
context.Result = new JsonResult(new ApiResult((int)ResultCode.DENY, msg));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
global using Newtonsoft.Json;
|
||||
global using SqlSugar;
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
||||
global using Infrastructure.Extensions;
|
||||
@@ -0,0 +1,12 @@
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 基础服务定义
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
public interface IBaseService<T> : IBaseRepository<T> where T : class, new()
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Model;
|
||||
using IPTools.Core;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Http.Features;
|
||||
using NLog;
|
||||
using System.Text.Encodings.Web;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
using textJson = System.Text.Json;
|
||||
|
||||
namespace ZR.ServiceCore.Middleware
|
||||
{
|
||||
/// <summary>
|
||||
/// 全局异常处理中间件
|
||||
/// 调用 app.UseMiddlewareGlobalExceptionMiddleware>();
|
||||
/// </summary>
|
||||
public class GlobalExceptionMiddleware
|
||||
{
|
||||
private readonly RequestDelegate next;
|
||||
private readonly ISysOperLogService SysOperLogService;
|
||||
|
||||
static readonly Logger Logger = LogManager.GetCurrentClassLogger();
|
||||
|
||||
public GlobalExceptionMiddleware(RequestDelegate next, ISysOperLogService sysOperLog)
|
||||
{
|
||||
this.next = next;
|
||||
this.SysOperLogService = sysOperLog;
|
||||
}
|
||||
|
||||
public async Task Invoke(HttpContext context)
|
||||
{
|
||||
try
|
||||
{
|
||||
await next(context);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await HandleExceptionAsync(context, ex);
|
||||
}
|
||||
}
|
||||
|
||||
private async Task HandleExceptionAsync(HttpContext context, Exception ex)
|
||||
{
|
||||
NLog.LogLevel logLevel = NLog.LogLevel.Info;
|
||||
int code = (int)ResultCode.GLOBAL_ERROR;
|
||||
string msg;
|
||||
string error = string.Empty;
|
||||
//自定义异常
|
||||
if (ex is CustomException customException)
|
||||
{
|
||||
code = customException.Code;
|
||||
msg = customException.Message;
|
||||
error = customException.LogMsg;
|
||||
}
|
||||
else if (ex is ArgumentException)//参数异常
|
||||
{
|
||||
code = (int)ResultCode.PARAM_ERROR;
|
||||
msg = ex.Message;
|
||||
}
|
||||
else
|
||||
{
|
||||
msg = "服务器好像出了点问题,请联系系统管理员...";
|
||||
error = $"{ex.Message}";
|
||||
logLevel = NLog.LogLevel.Error;
|
||||
context.Response.StatusCode = 500;
|
||||
}
|
||||
var options = new textJson.JsonSerializerOptions
|
||||
{
|
||||
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
|
||||
PropertyNamingPolicy = textJson.JsonNamingPolicy.CamelCase,
|
||||
WriteIndented = true
|
||||
};
|
||||
|
||||
ApiResult apiResult = new(code, msg);
|
||||
string responseResult = textJson.JsonSerializer.Serialize(apiResult, options);
|
||||
string ip = HttpContextExtension.GetClientUserIp(context);
|
||||
var ip_info = IpTool.Search(ip);
|
||||
|
||||
SysOperLog sysOperLog = new()
|
||||
{
|
||||
Status = 1,
|
||||
OperIp = ip,
|
||||
OperUrl = HttpContextExtension.GetRequestUrl(context),
|
||||
RequestMethod = context.Request.Method,
|
||||
JsonResult = responseResult,
|
||||
ErrorMsg = string.IsNullOrEmpty(error) ? msg : error,
|
||||
OperName = HttpContextExtension.GetName(context),
|
||||
OperLocation = ip_info.Province + " " + ip_info.City,
|
||||
OperTime = DateTime.Now,
|
||||
OperParam = HttpContextExtension.GetRequestValue(context, context.Request.Method)
|
||||
};
|
||||
var endpoint = GetEndpoint(context);
|
||||
if (endpoint != null)
|
||||
{
|
||||
var logAttribute = endpoint.Metadata.GetMetadata<LogAttribute>();
|
||||
if (logAttribute != null)
|
||||
{
|
||||
sysOperLog.BusinessType = (int)logAttribute.BusinessType;
|
||||
sysOperLog.Title = logAttribute?.Title;
|
||||
sysOperLog.OperParam = logAttribute.IsSaveRequestData ? sysOperLog.OperParam : "";
|
||||
sysOperLog.JsonResult = logAttribute.IsSaveResponseData ? sysOperLog.JsonResult : "";
|
||||
}
|
||||
}
|
||||
LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error)
|
||||
{
|
||||
Exception = ex,
|
||||
Message = error
|
||||
};
|
||||
ei.Properties["status"] = 1;//走正常返回都是通过走GlobalExceptionFilter不通过
|
||||
ei.Properties["jsonResult"] = responseResult;
|
||||
ei.Properties["requestParam"] = sysOperLog.OperParam;
|
||||
ei.Properties["user"] = sysOperLog.OperName;
|
||||
|
||||
Logger.Log(ei);
|
||||
context.Response.ContentType = "text/json;charset=utf-8";
|
||||
await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8);
|
||||
|
||||
string errorMsg = $"> 操作人:{sysOperLog.OperName}" +
|
||||
$"\n> 操作地区:{sysOperLog.OperIp}({sysOperLog.OperLocation})" +
|
||||
$"\n> 操作模块:{sysOperLog.Title}" +
|
||||
$"\n> 操作地址:{sysOperLog.OperUrl}" +
|
||||
$"\n> 错误信息:{msg}\n\n> {error}";
|
||||
|
||||
SysOperLogService.InsertOperlog(sysOperLog);
|
||||
WxNoticeHelper.SendMsg("系统出错", errorMsg, "", WxNoticeHelper.MsgType.markdown);
|
||||
}
|
||||
|
||||
public static Endpoint GetEndpoint(HttpContext context)
|
||||
{
|
||||
if (context == null)
|
||||
{
|
||||
throw new ArgumentNullException(nameof(context));
|
||||
}
|
||||
|
||||
return context.Features.Get<IEndpointFeature>()?.Endpoint;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章表
|
||||
/// </summary>
|
||||
[SugarTable("article", "文章管理")]
|
||||
[Tenant("0")]
|
||||
public class Article
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public int Cid { get; set; }
|
||||
/// <summary>
|
||||
/// 文章标题
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "文章标题", Length = 254, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// 发布时间
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "发布时间")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true, ColumnDescription = "更新时间")]
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 文章内容
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "文章内容", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string Content { get; set; }
|
||||
/// <summary>
|
||||
/// 作者名
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "作者名", Length = 20, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string AuthorName { get; set; }
|
||||
/// <summary>
|
||||
/// 发布者用户id
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "发布者用户id", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public long UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 文章状态 1、发布 2、草稿
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "文章状态 1、发布 2、草稿", Length = 20)]
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 编辑器类型 markdown,html
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "编辑器类型markdown,html", ColumnName = "fmt_type", Length = 20, IsNullable = true)]
|
||||
public string FmtType { get; set; }
|
||||
/// <summary>
|
||||
/// 文章标签eg:Net5,java
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "文章标签", Length = 20)]
|
||||
public string Tags { get; set; }
|
||||
/// <summary>
|
||||
/// 点击量
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "点击量", DefaultValue = "0")]
|
||||
public int Hits { get; set; }
|
||||
[SugarColumn(ColumnDescription = "目录id", ColumnName = "category_Id")]
|
||||
public int CategoryId { get; set; }
|
||||
/// <summary>
|
||||
/// 封面地址
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "封面地址", Length = 255)]
|
||||
public string CoverUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 是否公开 1、公开 0、不公开
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDescription = "是否公开 1、公开 0、不公开", DefaultValue = "0")]
|
||||
public int IsPublic { get; set; }
|
||||
|
||||
[Navigate(NavigateType.OneToOne, nameof(CategoryId), nameof(ArticleCategory.CategoryId))] //自定义关系映射
|
||||
public ArticleCategory ArticleCategoryNav { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章目录
|
||||
/// </summary>
|
||||
[SugarTable("articleCategory", "文章目录")]
|
||||
[Tenant("0")]
|
||||
public class ArticleCategory
|
||||
{
|
||||
/// <summary>
|
||||
/// 目录id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "category_id")]
|
||||
public int CategoryId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnDescription = "目录名", Length = 20, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string Name { get; set; }
|
||||
public int? ParentId { get; set; }
|
||||
[SugarColumn(ColumnDescription = "创建时间", ColumnName = "create_time")]
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<ArticleCategory> Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ZR.Model.Models
|
||||
{
|
||||
/// <summary>
|
||||
/// 多语言配置,数据实体对象
|
||||
/// </summary>
|
||||
[Tenant("0")]
|
||||
[SugarTable("sys_common_lang", "多语言配置表")]
|
||||
public class CommonLang
|
||||
{
|
||||
/// <summary>
|
||||
/// id
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 语言code
|
||||
/// </summary>
|
||||
[DisplayName("语言code")]
|
||||
[SugarColumn(ColumnName = "lang_code", Length = 10, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string LangCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 语言key
|
||||
/// </summary>
|
||||
[DisplayName("语言key")]
|
||||
[SugarColumn(ColumnName = "lang_key", Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string LangKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
[DisplayName("名称")]
|
||||
[SugarColumn(ColumnName = "lang_name", Length = 2000, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string LangName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 添加时间
|
||||
/// </summary>
|
||||
[DisplayName("添加时间")]
|
||||
public DateTime? Addtime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章目录输入对象
|
||||
/// </summary>
|
||||
public class ArticleCategoryDto
|
||||
{
|
||||
[Required(ErrorMessage = "目录id不能为空")]
|
||||
public int CategoryId { get; set; }
|
||||
[Required(ErrorMessage = "目录名不能为空")]
|
||||
public string Name { get; set; }
|
||||
public DateTime? CreateTime { get; set; }
|
||||
public int? ParentId { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文章目录查询对象
|
||||
/// </summary>
|
||||
public class ArticleCategoryQueryDto : PagerInfo
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class ArticleQueryDto : PagerInfo
|
||||
{
|
||||
public long? UserId { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string Title { get; set; }
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 输入输出对象
|
||||
/// </summary>
|
||||
public class ArticleDto
|
||||
{
|
||||
[Required(ErrorMessage = "Cid不能为空")]
|
||||
public int Cid { get; set; }
|
||||
[Required(ErrorMessage = "文章标题不能为空")]
|
||||
public string Title { get; set; }
|
||||
[Required(ErrorMessage = "文章内容不能为空")]
|
||||
public string Content { get; set; }
|
||||
|
||||
public long? UserId { get; set; }
|
||||
|
||||
public string Status { get; set; }
|
||||
|
||||
public string FmtType { get; set; }
|
||||
|
||||
public string Tags { get; set; }
|
||||
|
||||
public int? Hits { get; set; }
|
||||
|
||||
public int? CategoryId { get; set; }
|
||||
|
||||
public DateTime? CreateTime { get; set; }
|
||||
|
||||
public DateTime? UpdateTime { get; set; }
|
||||
|
||||
public string AuthorName { get; set; }
|
||||
|
||||
public string CoverUrl { get; set; }
|
||||
|
||||
public ArticleCategory ArticleCategoryNav { get; set; }
|
||||
public string[] TagList { get; set; }
|
||||
public int IsPublic { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 多语言配置输入对象
|
||||
/// </summary>
|
||||
public class CommonLangDto
|
||||
{
|
||||
//[Required(ErrorMessage = "id不能为空")]
|
||||
public long Id { get; set; }
|
||||
//[Required(ErrorMessage = "语言code不能为空")]
|
||||
public string LangCode { get; set; }
|
||||
public string LangKey { get; set; }
|
||||
//[Required(ErrorMessage = "名称不能为空")]
|
||||
public string LangName { get; set; }
|
||||
public List<CommonLangDto> LangList { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 多语言配置查询对象
|
||||
/// </summary>
|
||||
public class CommonLangQueryDto : PagerInfo
|
||||
{
|
||||
public string LangCode { get; set; }
|
||||
public string LangKey { get; set; }
|
||||
public DateTime? BeginAddtime { get; set; }
|
||||
public DateTime? EndAddtime { get; set; }
|
||||
public int ShowMode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class GenTableDto
|
||||
{
|
||||
public int TableId { get; set; }
|
||||
public string TableName { get; set; }
|
||||
public string TableComment { get; set; }
|
||||
public string SubTableName { get; set; }
|
||||
public string SubTableFkName { get; set; }
|
||||
public string ClassName { get; set; }
|
||||
public string TplCategory { get; set; }
|
||||
public string BaseNameSpace { get; set; }
|
||||
public string ModuleName { get; set; }
|
||||
public string BusinessName { get; set; }
|
||||
public string FunctionName { get; set; }
|
||||
public string FunctionAuthor { get; set; }
|
||||
public string GenType { get; set; }
|
||||
public string GenPath { get; set; }
|
||||
//public string PermissionPrefix { get; set; }
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 额外参数
|
||||
/// </summary>
|
||||
public Options Params { get; set; }
|
||||
public List<GenTableColumnDto> Columns { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 额外参数
|
||||
/// ****注意里面参数统一首字母小写*****
|
||||
/// </summary>
|
||||
public class Params
|
||||
{
|
||||
public string TreeCode { get; set; }
|
||||
public string TreeName { get; set; }
|
||||
public string TreeParentCode { get; set; }
|
||||
public int? ParentMenuId { get; set; }
|
||||
public string SortField { get; set; }
|
||||
public string SortType { get; set; }
|
||||
/// <summary>
|
||||
/// 额外参数字符串
|
||||
/// </summary>
|
||||
public string CheckedBtn { get; set; }
|
||||
public string PermissionPrefix { get; set; }
|
||||
}
|
||||
public class GenTableColumnDto
|
||||
{
|
||||
public int ColumnId { get; set; }
|
||||
public int TableId { get; set; }
|
||||
public string ColumnComment { get; set; }
|
||||
public string CsharpType { get; set; }
|
||||
public string CsharpField { get; set; }
|
||||
public bool IsInsert { get; set; }
|
||||
public bool IsEdit { get; set; }
|
||||
public bool IsList { get; set; }
|
||||
public bool IsQuery { get; set; }
|
||||
public bool IsSort { get; set; }
|
||||
public bool IsRequired { get; set; }
|
||||
public bool IsExport { get; set; }
|
||||
/// <summary>
|
||||
/// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
|
||||
/// </summary>
|
||||
public string HtmlType { get; set; }
|
||||
/// <summary>
|
||||
/// 查询类型(等于、不等于、大于、小于、范围)
|
||||
/// </summary>
|
||||
public string QueryType { get; set; } = "EQ";
|
||||
public int Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
public string DictType { get; set; }
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Remark { get; set; }
|
||||
/// <summary>
|
||||
/// 自动填充类型
|
||||
/// </summary>
|
||||
public int? AutoFillType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class LockUserDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public string ClientId { get; set; }
|
||||
public string ConnnectionId { get; set; }
|
||||
public string Reason { get; set; }
|
||||
public int Time { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class LoginBodyDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "用户名不能为空")]
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户密码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "密码不能为空")]
|
||||
public string Password { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一标识
|
||||
/// </summary>
|
||||
public string Uuid { get; set; } = "";
|
||||
public string LoginIP { get; set; }
|
||||
public string ClientId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class MenuDto
|
||||
{
|
||||
//{"parentId":0,"menuName":"aaa","icon":"documentation","menuType":"M","orderNum":999,"visible":0,"status":0,"path":"aaa"}
|
||||
[Required(ErrorMessage = "菜单id不能为空")]
|
||||
[ExcelColumn(Name = "菜单id")]
|
||||
public int MenuId { get; set; }
|
||||
[ExcelColumn(Name = "菜单名")]
|
||||
public string MenuName { get; set; }
|
||||
/// <summary>
|
||||
/// 父菜单ID
|
||||
/// </summary>
|
||||
public long? ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示顺序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路由地址
|
||||
/// </summary>
|
||||
[ExcelColumn(Name = "路由地址")]
|
||||
public string Path { get; set; } = "#";
|
||||
|
||||
/// <summary>
|
||||
/// 组件路径
|
||||
/// </summary>
|
||||
[ExcelColumn(Name = "组件地址")]
|
||||
public string Component { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否缓存(1缓存 0不缓存)
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "是否缓存不能为空")]
|
||||
[ExcelColumn(Name = "是否缓存")]
|
||||
public int IsCache { get; set; }
|
||||
/// <summary>
|
||||
/// 是否外链 1、是 0、否
|
||||
/// </summary>
|
||||
public int IsFrame { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 类型(M目录 C菜单 F按钮 L链接)
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "菜单类型不能为空")]
|
||||
public string MenuType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示状态(0显示 1隐藏)
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "显示状态不能为空")]
|
||||
public string Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "菜单状态不能为空")]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 权限字符串
|
||||
/// </summary>
|
||||
[ExcelColumn(Name = "权限字符串")]
|
||||
public string Perms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单图标
|
||||
/// </summary>
|
||||
public string Icon { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 翻译key
|
||||
/// </summary>
|
||||
public string MenuNameKey { get; set; }
|
||||
public List<MenuDto> Children { get; set; } = new List<MenuDto>();
|
||||
}
|
||||
|
||||
public class MenuQueryDto
|
||||
{
|
||||
public string MenuName { get; set; }
|
||||
public string Visible { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string MenuTypeIds { get; set; } = string.Empty;
|
||||
public int? ParentId { get; set; }
|
||||
public string[] MenuTypeIdArr
|
||||
{
|
||||
get
|
||||
{
|
||||
return MenuTypeIds?.Split(',', StringSplitOptions.RemoveEmptyEntries);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class RegisterDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "用户名不能为空")]
|
||||
public string Username { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户密码
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "密码不能为空")]
|
||||
public string Password { get; set; }
|
||||
[Required(ErrorMessage = "确认密码不能为空")]
|
||||
public string ConfirmPassword { get; set; }
|
||||
/// <summary>
|
||||
/// 验证码
|
||||
/// </summary>
|
||||
public string Code { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 唯一标识
|
||||
/// </summary>
|
||||
public string Uuid { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 头像
|
||||
/// </summary>
|
||||
public string Photo { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using SqlSugar.DbConvert;
|
||||
using ZR.Model.System.Enums;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class RoleMenuExportDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 一级目录名
|
||||
/// </summary>
|
||||
[ExcelColumn(Name = "菜单", Width = 50)]
|
||||
public string MenuName { get; set; }
|
||||
//[ExcelColumn(Name = "菜单名", Width = 20)]
|
||||
//public string MenuName1 { get; set; }
|
||||
//[ExcelColumn(Name = "权限按钮", Width = 20)]
|
||||
//public string MenuName2 { get; set; }
|
||||
[ExcelColumn(Name = "路径", Width = 20)]
|
||||
public string Path { get; set; }
|
||||
[ExcelColumn(Name = "组件名", Width = 20)]
|
||||
public string Component { get; set; }
|
||||
[ExcelColumn(Name = "权限字符", Width = 20)]
|
||||
public string Perms { get; set; }
|
||||
[ExcelColumn(Name = "菜单类型")]
|
||||
public MenuType MenuType { get; set; }
|
||||
[ExcelColumn(Name = "菜单状态")]
|
||||
public MenuStatus Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class RoleUserQueryDto : PagerInfo
|
||||
{
|
||||
public long RoleId { get; set; }
|
||||
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
|
||||
public class RoleUsersCreateDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色id
|
||||
/// </summary>
|
||||
[Display(Name = "角色id")]
|
||||
[Required(ErrorMessage = "roleId 不能为空")]
|
||||
public long RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户编码 [1,2,3,4]
|
||||
/// </summary>
|
||||
[Display(Name = "用户编码 [1,2,3,4]")]
|
||||
public List<long> UserIds { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class ScanDto
|
||||
{
|
||||
public string Uuid { get; set; }
|
||||
public string State { get; set; }
|
||||
public string DeviceId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using MiniExcelLibs.Attributes;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据差异日志查询对象
|
||||
/// </summary>
|
||||
public class SqlDiffLogQueryDto : PagerInfo
|
||||
{
|
||||
public string TableName { get; set; }
|
||||
public string DiffType { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public DateTime? BeginAddTime { get; set; }
|
||||
public DateTime? EndAddTime { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据差异日志输入输出对象
|
||||
/// </summary>
|
||||
public class SqlDiffLogDto
|
||||
{
|
||||
[Required(ErrorMessage = "主键不能为空")]
|
||||
[ExcelColumn(Name = "主键")]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long PId { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "表名")]
|
||||
public string TableName { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "业务数据内容")]
|
||||
public string BusinessData { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "差异类型")]
|
||||
public string DiffType { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "执行sql语句")]
|
||||
public string Sql { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "变更前数据")]
|
||||
public string BeforeData { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "变更后数据")]
|
||||
public string AfterData { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "操作用户名")]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "AddTime", Format = "yyyy-MM-dd HH:mm:ss")]
|
||||
public DateTime? AddTime { get; set; }
|
||||
|
||||
[ExcelColumn(Name = "数据库配置id")]
|
||||
public string ConfigId { get; set; }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数配置输入对象模型
|
||||
/// </summary>
|
||||
public class SysConfigDto
|
||||
{
|
||||
public int ConfigId { get; set; }
|
||||
public string ConfigName { get; set; }
|
||||
public string ConfigKey { get; set; }
|
||||
public string ConfigValue { get; set; }
|
||||
public string ConfigType { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 参数配置查询对象模型
|
||||
/// </summary>
|
||||
public class SysConfigQueryDto : PagerInfo
|
||||
{
|
||||
public string ConfigName { get; set; }
|
||||
public string ConfigKey { get; set; }
|
||||
public string ConfigValue { get; set; }
|
||||
public string ConfigType { get; set; }
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysDeptQueryDto : PagerInfo
|
||||
{
|
||||
public int? Status { get; set; }
|
||||
public int? DelFlag { get; set; }
|
||||
public string DeptName { get; set; }
|
||||
}
|
||||
public class SysDeptDto : SysBase
|
||||
{
|
||||
public long DeptId { get; set; }
|
||||
|
||||
public long ParentId { get; set; }
|
||||
|
||||
public string Ancestors { get; set; }
|
||||
|
||||
public string DeptName { get; set; }
|
||||
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
public string Leader { get; set; }
|
||||
|
||||
public string Phone { get; set; }
|
||||
|
||||
public string Email { get; set; }
|
||||
|
||||
public int Status { get; set; }
|
||||
|
||||
public int DelFlag { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysDictTypeDto
|
||||
{
|
||||
public long DictId { get; set; }
|
||||
/// <summary>
|
||||
/// 字典名称
|
||||
/// </summary>
|
||||
public string DictName { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
[Required(ErrorMessage = "字典类型不能为空")]
|
||||
[RegularExpression(pattern: "^[a-z][a-z0-9_]*$", ErrorMessage = "字典类型必须以字母开头,且字典类型只能由小写字母或加下划线还有数字组成")]
|
||||
public string DictType { get; set; }
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 系统内置 Y是 N否
|
||||
/// </summary>
|
||||
public string Type { get; set; }
|
||||
/// <summary>
|
||||
/// 自定义sql
|
||||
/// </summary>
|
||||
public string CustomSql { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件存储输入对象
|
||||
/// </summary>
|
||||
public class SysFileDto
|
||||
{
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 文件原名
|
||||
/// </summary>
|
||||
public string RealName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件类型
|
||||
/// </summary>
|
||||
public string FileType { get; set; }
|
||||
/// <summary>
|
||||
/// 存储文件名
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件存储地址 eg:/uploads/20220202
|
||||
/// </summary>
|
||||
public string FileUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库位置 eg:/uploads
|
||||
/// </summary>
|
||||
public string StorePath { get; set; }
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public string FileSize { get; set; }
|
||||
/// <summary>
|
||||
/// 文件扩展名
|
||||
/// </summary>
|
||||
public string FileExt { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string Create_by { get; set; }
|
||||
/// <summary>
|
||||
/// 上传时间
|
||||
/// </summary>
|
||||
public DateTime? Create_time { get; set; }
|
||||
/// <summary>
|
||||
/// 存储类型
|
||||
/// </summary>
|
||||
public int? StoreType { get; set; }
|
||||
/// <summary>
|
||||
/// 访问路径
|
||||
/// </summary>
|
||||
public string AccessUrl { get; set; }
|
||||
|
||||
public SysFileDto() { }
|
||||
public SysFileDto(string originFileName, string fileName, string ext, string fileSize, string storePath, string accessUrl, string create_by)
|
||||
{
|
||||
StorePath = storePath;
|
||||
RealName = originFileName;
|
||||
FileName = fileName;
|
||||
FileExt = ext;
|
||||
FileSize = fileSize;
|
||||
AccessUrl = accessUrl;
|
||||
Create_by = create_by;
|
||||
Create_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
public class SysFileQueryDto : PagerInfo
|
||||
{
|
||||
public DateTime? BeginCreate_time { get; set; }
|
||||
public DateTime? EndCreate_time { get; set; }
|
||||
public int? StoreType { get; set; }
|
||||
public long? FileId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysLogininfoDto : SysBase
|
||||
{
|
||||
public int PageNum { get; set; }
|
||||
/// <summary>
|
||||
/// IP 地址
|
||||
/// </summary>
|
||||
public string Ipaddr { get; set; }
|
||||
/// <summary>
|
||||
/// 登录状态 0成功 1失败
|
||||
/// </summary>
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
/// <summary>
|
||||
/// 通知公告表输入对象
|
||||
/// </summary>
|
||||
public class SysNoticeDto
|
||||
{
|
||||
public int NoticeId { get; set; }
|
||||
[Required]
|
||||
public string NoticeTitle { get; set; }
|
||||
public int NoticeType { get; set; }
|
||||
public string NoticeContent { get; set; }
|
||||
public int Status { get; set; }
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 通知公告表查询对象
|
||||
/// </summary>
|
||||
public class SysNoticeQueryDto : PagerInfo
|
||||
{
|
||||
public string NoticeTitle { get; set; }
|
||||
public int? NoticeType { get; set; }
|
||||
public string CreateBy { get; set; }
|
||||
public int? Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysOperLogQueryDto : PagerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作人员
|
||||
/// </summary>
|
||||
public string OperName { get; set; }
|
||||
/// <summary>
|
||||
/// 业务类型 0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据
|
||||
/// </summary>
|
||||
public int BusinessType { get; set; } = -1;
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int Status { get; set; } = -1;
|
||||
/// <summary>
|
||||
/// 操作模块
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
/// </summary>
|
||||
public string OperParam { get; set; }
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
|
||||
public class SysOperLogDto : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 页码
|
||||
/// </summary>
|
||||
public int PageNum { get; set; }
|
||||
public int PageSize { get; set; }
|
||||
/// <summary>
|
||||
/// 操作人员
|
||||
/// </summary>
|
||||
public string OperName { get; set; }
|
||||
/// <summary>
|
||||
/// 业务类型 0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据
|
||||
/// </summary>
|
||||
public int BusinessType { get; set; } = -1;
|
||||
/// <summary>
|
||||
/// 状态
|
||||
/// </summary>
|
||||
public int Status { get; set; } = -1;
|
||||
/// <summary>
|
||||
/// 操作模块
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
/// </summary>
|
||||
public string OperParam { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysRoleDto : SysBase
|
||||
{
|
||||
public long RoleId { get; set; }
|
||||
/// <summary>
|
||||
/// 要添加的菜单集合
|
||||
/// </summary>
|
||||
public List<long> MenuIds { get; set; } = new List<long>();
|
||||
public string RoleName { get; set; }
|
||||
public string RoleKey { get; set; }
|
||||
public int RoleSort { get; set; }
|
||||
public int Status { get; set; }
|
||||
public int DataScope { get; set; }
|
||||
public int[] DeptIds { get; set; }
|
||||
/// <summary>
|
||||
/// 减少菜单集合
|
||||
/// </summary>
|
||||
public List<long> DelMenuIds { get; set; } = new List<long>();
|
||||
public bool MenuCheckStrictly { get; set; }
|
||||
public bool DeptCheckStrictly { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysRoleMenuDto
|
||||
{
|
||||
public long RoleId { get; set; }
|
||||
/// <summary>
|
||||
/// 角色分配菜单
|
||||
/// </summary>
|
||||
public List<long> MenuIds { get; set; } = new List<long>();
|
||||
public string RoleName { get; set; }
|
||||
public string RoleKey { get; set; }
|
||||
public string Create_by { get; set; }
|
||||
public DateTime Create_time{ get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysUserDto
|
||||
{
|
||||
public long UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public string Phonenumber { get; set; }
|
||||
/// <summary>
|
||||
/// 用户性别(0男 1女 2未知)
|
||||
/// </summary>
|
||||
public int Sex { get; set; }
|
||||
public string Password { get; set; }
|
||||
}
|
||||
|
||||
public class SysUserQueryDto
|
||||
{
|
||||
public long? UserId { get; set; }
|
||||
public string UserName { get; set; }
|
||||
public string NickName { get; set; }
|
||||
public string Email { get; set; }
|
||||
public string Remark { get; set; }
|
||||
public string Phonenumber { get; set; }
|
||||
/// <summary>
|
||||
/// 用户性别(0男 1女 2未知)
|
||||
/// </summary>
|
||||
public int Sex { get; set; }
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
public int Status { get; set; }
|
||||
public long DeptId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class SysdictDataDto
|
||||
{
|
||||
public string DictType { get; set; }
|
||||
public string ColumnName { get; set; }
|
||||
public List<SysDictData> List { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class TasksQueryDto : PagerInfo
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询字符串
|
||||
/// </summary>
|
||||
[Display(Name = "查询字符串")]
|
||||
public string QueryText { get; set; }
|
||||
public int? TaskType { get; set; }
|
||||
public int? TriggerType { get; set; }
|
||||
public int? IsStart { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加任务
|
||||
/// </summary>
|
||||
public class TasksCreateDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务id
|
||||
/// </summary>
|
||||
[Display(Name = "任务id")]
|
||||
//[Required(ErrorMessage = "任务不能为空")]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务名称
|
||||
/// </summary>
|
||||
[Display(Name = "任务名称")]
|
||||
[Required(ErrorMessage = "任务名称不能为空")]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务分组
|
||||
/// </summary>
|
||||
[Display(Name = "任务分组")]
|
||||
[Required(ErrorMessage = "任务分组不能为空")]
|
||||
public string JobGroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行时间表达式
|
||||
/// </summary>
|
||||
[Display(Name = "运行时间表达式")]
|
||||
public string Cron { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序集名称
|
||||
/// </summary>
|
||||
[Display(Name = "程序集名称")]
|
||||
public string AssemblyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务所在类
|
||||
/// </summary>
|
||||
[Display(Name = "任务所在类")]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务描述
|
||||
/// </summary>
|
||||
[Display(Name = "任务描述")]
|
||||
public string Remark { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[Display(Name = "开始时间")]
|
||||
public DateTime? BeginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[Display(Name = "结束时间")]
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 触发器类型(0、simple 1、cron)
|
||||
/// </summary>
|
||||
[Display(Name = "触发器类型(0、simple 1、cron)")]
|
||||
public int TriggerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行间隔时间(单位:秒)
|
||||
/// </summary>
|
||||
[Display(Name = "执行间隔时间(单位:秒)")]
|
||||
public int IntervalSecond { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 传入参数
|
||||
/// </summary>
|
||||
[Display(Name = "传入参数")]
|
||||
public string JobParams { get; set; }
|
||||
public string ApiUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 1、程序集任务 2、apiUrl任务 3、SQL语句
|
||||
/// </summary>
|
||||
public int TaskType { get; set; }
|
||||
/// <summary>
|
||||
/// SQL文本
|
||||
/// </summary>
|
||||
public string SqlText { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 网络请求方式
|
||||
/// </summary>
|
||||
public string RequestMethod { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System.Dto
|
||||
{
|
||||
public class TasksLogQueryDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询字符串
|
||||
/// </summary>
|
||||
public string Name{ get; set; }
|
||||
public string JobName { get; set; }
|
||||
public string JobId { get; set; }
|
||||
public string JobGroup { get; set; }
|
||||
public string Status { get; set; }
|
||||
public DateTime? BeginTime { get; set; }
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
|
||||
public class TasksLogDto
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ZR.Model.System.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单状态(0正常 1停用)
|
||||
/// </summary>
|
||||
public enum MenuStatus
|
||||
{
|
||||
[Description("正常")]
|
||||
正常 = 0,
|
||||
[Description("停用")]
|
||||
停用 = 1,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ZR.Model.System.Enums
|
||||
{
|
||||
/// <summary>
|
||||
/// M目录 C菜单 F按钮 L链接
|
||||
/// </summary>
|
||||
public enum MenuType
|
||||
{
|
||||
[Description("目录")]
|
||||
M,
|
||||
[Description("菜单")]
|
||||
C,
|
||||
[Description("按钮")]
|
||||
F,
|
||||
[Description("链接")]
|
||||
L
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System.Generate
|
||||
{
|
||||
/// <summary>
|
||||
/// 代码生成表
|
||||
/// </summary>
|
||||
[SugarTable("gen_table", "代码生成表")]
|
||||
[Tenant("0")]
|
||||
public class GenTable : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 表id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long TableId { get; set; }
|
||||
/// <summary>
|
||||
/// 数据库名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50)]
|
||||
public string DbName { get; set; }
|
||||
/// <summary>
|
||||
/// 表名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 150)]
|
||||
public string TableName { get; set; }
|
||||
/// <summary>
|
||||
/// 表描述
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 150)]
|
||||
public string TableComment { get; set; }
|
||||
/// <summary>
|
||||
/// 关联父表的表名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 150)]
|
||||
public string SubTableName { get; set; }
|
||||
/// <summary>
|
||||
/// 本表关联父表的外键名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 150)]
|
||||
public string SubTableFkName { get; set; }
|
||||
/// <summary>
|
||||
/// csharp类名
|
||||
/// </summary>
|
||||
public string ClassName { get; set; }
|
||||
/// <summary>
|
||||
/// 使用的模板(crud单表操作 tree树表操作 sub主子表操作)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, DefaultValue = "crud")]
|
||||
public string TplCategory { get; set; }
|
||||
/// <summary>
|
||||
/// 基本命名空间前缀
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string BaseNameSpace { get; set; }
|
||||
/// <summary>
|
||||
/// 生成模块名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50)]
|
||||
public string ModuleName { get; set; }
|
||||
/// <summary>
|
||||
/// 生成业务名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50)]
|
||||
public string BusinessName { get; set; }
|
||||
/// <summary>
|
||||
/// 生成功能名
|
||||
/// </summary>
|
||||
public string FunctionName { get; set; }
|
||||
/// <summary>
|
||||
/// 生成作者名
|
||||
/// </summary>
|
||||
public string FunctionAuthor { get; set; }
|
||||
/// <summary>
|
||||
/// 生成代码方式(0zip压缩包 1自定义路径)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1, DefaultValue = "0")]
|
||||
public string GenType { get; set; }
|
||||
/// <summary>
|
||||
/// 代码生成保存路径
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 200, DefaultValue = "/")]
|
||||
public string GenPath { get; set; }
|
||||
/// <summary>
|
||||
/// 其他生成选项
|
||||
/// </summary>
|
||||
[SugarColumn(IsJson = true)]
|
||||
public Options Options { get; set; }
|
||||
|
||||
#region 表额外字段
|
||||
/// <summary>
|
||||
/// 表列信息
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<GenTableColumn> Columns { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字表信息
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public GenTable SubTable { get; set; }
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class Options
|
||||
{
|
||||
public long ParentMenuId { get; set; }
|
||||
public string SortType { get; set; } = "asc";
|
||||
public string SortField { get; set; } = string.Empty;
|
||||
public string TreeCode { get; set; } = string.Empty;
|
||||
public string TreeName { get; set; } = string.Empty;
|
||||
public string TreeParentCode { get; set; } = string.Empty;
|
||||
public string PermissionPrefix { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 额外参数字符串
|
||||
/// </summary>
|
||||
public int[] CheckedBtn { get; set; } = new int[] { 1, 2, 3 };
|
||||
/// <summary>
|
||||
/// 列大小 12,24
|
||||
/// </summary>
|
||||
public int ColNum { get; set; } = 12;
|
||||
/// <summary>
|
||||
/// 是否生成仓储层
|
||||
/// </summary>
|
||||
public int GenerateRepo { get; set; }
|
||||
/// <summary>
|
||||
/// 自动生成菜单
|
||||
/// </summary>
|
||||
public bool GenerateMenu { get; set; }
|
||||
/// <summary>
|
||||
/// 操作按钮样式
|
||||
/// </summary>
|
||||
public int OperBtnStyle { get; set; } = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Linq;
|
||||
|
||||
namespace ZR.Model.System.Generate
|
||||
{
|
||||
/// <summary>
|
||||
/// 代码生成表字段
|
||||
/// </summary>
|
||||
[SugarTable("gen_table_column", "代码生成表字段")]
|
||||
[Tenant("0")]
|
||||
public class GenTableColumn : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 列id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public long ColumnId { get; set; }
|
||||
/// <summary>
|
||||
/// 导入代码生成表列名 首字母转了小写
|
||||
/// </summary>
|
||||
public string ColumnName { get; set; }
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public long TableId { get; set; }
|
||||
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public string TableName { get; set; }
|
||||
/// <summary>
|
||||
/// 列说明
|
||||
/// </summary>
|
||||
private string columnComment;
|
||||
public string ColumnComment
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.IsNullOrEmpty(columnComment) ? CsharpField : columnComment;
|
||||
}
|
||||
set
|
||||
{
|
||||
columnComment = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 数据库列类型
|
||||
/// </summary>
|
||||
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public string ColumnType { get; set; }
|
||||
/// <summary>
|
||||
/// C#类型
|
||||
/// </summary>
|
||||
public string CsharpType { get; set; }
|
||||
/// <summary>
|
||||
/// C# 字段名 首字母大写
|
||||
/// </summary>
|
||||
public string CsharpField { get; set; }
|
||||
/// <summary>
|
||||
/// 是否主键(1是)
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public bool IsPk { get; set; }
|
||||
/// <summary>
|
||||
/// 是否必填(1是)
|
||||
/// </summary>
|
||||
public bool IsRequired { get; set; }
|
||||
/// <summary>
|
||||
/// 是否自增(1是)
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true)]
|
||||
public bool IsIncrement { get; set; }
|
||||
/// <summary>
|
||||
/// 是否插入(1是)
|
||||
/// </summary>
|
||||
public bool IsInsert { get; set; }
|
||||
/// <summary>
|
||||
/// 是否需要编辑(1是)
|
||||
/// </summary>
|
||||
public bool IsEdit { get; set; }
|
||||
/// <summary>
|
||||
/// 是否显示列表(1是)
|
||||
/// </summary>
|
||||
public bool IsList { get; set; }
|
||||
/// <summary>
|
||||
/// 是否查询(1是)
|
||||
/// </summary>
|
||||
public bool IsQuery { get; set; }
|
||||
/// <summary>
|
||||
/// 是否排序(1是)
|
||||
/// </summary>
|
||||
public bool IsSort { get; set; }
|
||||
/// <summary>
|
||||
/// 是否导出(1是)
|
||||
/// </summary>
|
||||
public bool IsExport { get; set; }
|
||||
/// <summary>
|
||||
/// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
|
||||
/// </summary>
|
||||
public string HtmlType { get; set; }
|
||||
/// <summary>
|
||||
/// 查询类型(等于、不等于、大于、小于、范围)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "EQ")]
|
||||
public string QueryType { get; set; } = "EQ";
|
||||
public int Sort { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
public string DictType { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 自动填充类型 1、添加 2、编辑 3、添加编辑
|
||||
/// </summary>
|
||||
public int AutoFillType { get; set; }
|
||||
|
||||
#region 额外字段
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string RequiredStr
|
||||
{
|
||||
get
|
||||
{
|
||||
string[] arr = new string[] { "int", "long" };
|
||||
return (!IsRequired && HtmlType != "selectMulti" && (arr.Any(f => f.Contains(CsharpType))) || typeof(DateTime).Name == CsharpType) ? "?" : "";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 前端排序字符串
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string SortStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return IsSort ? " sortable" : "";
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// C# 字段名 首字母小写,用于前端
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string CsharpFieldFl
|
||||
{
|
||||
get
|
||||
{
|
||||
return CsharpField[..1].ToLower() + CsharpField[1..];
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 前端 只读字段
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string DisabledStr
|
||||
{
|
||||
get
|
||||
{
|
||||
return ((IsPk) && !IsRequired) ? " :disabled=\"true\"" : "";
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SugarTable("SqlDiffLog", "数据差异日志")]
|
||||
[Tenant("0")]
|
||||
public class SqlDiffLog
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long PId { get; set; }
|
||||
/// <summary>
|
||||
/// 表名
|
||||
/// </summary>
|
||||
public string TableName { get; set; }
|
||||
/// <summary>
|
||||
/// 业务数据内容
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 4000)]
|
||||
public string BusinessData { get; set; }
|
||||
/// <summary>
|
||||
/// 差异类型insert,update,delete
|
||||
/// </summary>
|
||||
public string DiffType { get; set; }
|
||||
/// <summary>
|
||||
/// 执行sql语句
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string Sql { get; set; }
|
||||
/// <summary>
|
||||
/// 变更前数据
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string BeforeData { get; set; }
|
||||
/// <summary>
|
||||
/// 变更后数据
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string AfterData { get; set; }
|
||||
/// <summary>
|
||||
/// 操作用户名
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
public DateTime AddTime { get; set; }
|
||||
/// <summary>
|
||||
/// 数据库配置id
|
||||
/// </summary>
|
||||
public string ConfigId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
//[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
|
||||
public class SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true, Length = 64, IsNullable = true)]
|
||||
[JsonProperty(propertyName: "CreateBy")]
|
||||
[ExcelIgnore]
|
||||
public string Create_by { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true)]
|
||||
[JsonProperty(propertyName: "CreateTime")]
|
||||
[ExcelColumn(Format = "yyyy-MM-dd HH:mm:ss")]
|
||||
public DateTime Create_time { get; set; } = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// 更新人
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
[JsonProperty(propertyName: "UpdateBy")]
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true, Length = 64, IsNullable = true)]
|
||||
[ExcelIgnore]
|
||||
public string Update_by { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 更新时间
|
||||
/// </summary>
|
||||
//[JsonIgnore]
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true)]
|
||||
[JsonProperty(propertyName: "UpdateTime")]
|
||||
[ExcelIgnore]
|
||||
public DateTime? Update_time { get; set; }
|
||||
[SugarColumn(Length = 500)]
|
||||
public string Remark { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数配置,数据实体对象
|
||||
///
|
||||
/// @author mr.zhao
|
||||
/// @date 2021-09-29
|
||||
/// </summary>
|
||||
[SugarTable("sys_config", "配置表")]
|
||||
[Tenant("0")]
|
||||
public class SysConfig : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public int ConfigId { get; set; }
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string ConfigName { get; set; }
|
||||
/// <summary>
|
||||
/// 参数键名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string ConfigKey { get; set; }
|
||||
/// <summary>
|
||||
/// 参数键值
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 500)]
|
||||
public string ConfigValue { get; set; }
|
||||
/// <summary>
|
||||
/// 系统内置(Y是 N否)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1)]
|
||||
public string ConfigType { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门表
|
||||
/// </summary>
|
||||
[SugarTable("sys_dept", "部门配置表")]
|
||||
[Tenant("0")]
|
||||
public class SysDept : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
public long DeptId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父部门ID
|
||||
/// </summary>
|
||||
public long ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 祖级列表
|
||||
/// </summary>
|
||||
public string Ancestors { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门名称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 30, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DeptName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示顺序
|
||||
/// </summary>
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 负责人
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 30)]
|
||||
public string Leader { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 联系电话
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 11)]
|
||||
public string Phone { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 邮箱
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50)]
|
||||
public string Email { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门状态:0正常,1停用
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除标志(0代表存在 2代表删除)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int DelFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 子菜单
|
||||
/// </summary>
|
||||
public List<SysDept> children = new();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据表
|
||||
/// </summary>
|
||||
[Tenant("0")]
|
||||
[SugarTable("sys_dict_data", "字典数据表")]
|
||||
public class SysDictData : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典编码
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long DictCode { get; set; }
|
||||
/// <summary>
|
||||
/// 字典排序
|
||||
/// </summary>
|
||||
public int DictSort { get; set; }
|
||||
/// <summary>
|
||||
/// 字典标签
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DictLabel { get; set; }
|
||||
/// <summary>
|
||||
/// 字典键值
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DictValue { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DictType { get; set; }
|
||||
/// <summary>
|
||||
/// 样式属性(其他样式扩展)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string CssClass { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 表格回显样式
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string ListClass { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 是否默认(Y是 N否)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1, DefaultValue = "N")]
|
||||
public string IsDefault { get; set; }
|
||||
/// <summary>
|
||||
/// 状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1)]
|
||||
public string Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典类型表
|
||||
/// </summary>
|
||||
[SugarTable("sys_dict_type", "字典类型表")]
|
||||
[SugarIndex("index_dict_type", nameof(DictType), OrderByType.Asc, true)]
|
||||
[Tenant("0")]
|
||||
public class SysDictType : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典主键
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long DictId { get; set; }
|
||||
/// <summary>
|
||||
/// 字典名称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DictName { get; set; }
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string DictType { get; set; }
|
||||
/// <summary>
|
||||
/// 状态 0、正常 1、停用
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1, DefaultValue = "0")]
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 系统内置 Y是 N否
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1, DefaultValue = "N")]
|
||||
public string Type { get; set; }
|
||||
/// <summary>
|
||||
/// 自定义sql
|
||||
/// </summary>
|
||||
public string CustomSql { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[Tenant("0")]
|
||||
[SugarTable("sys_file", "文件存储表")]
|
||||
public class SysFile
|
||||
{
|
||||
/// <summary>
|
||||
/// 自增id
|
||||
/// </summary>
|
||||
[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 文件原名
|
||||
/// </summary>
|
||||
public string RealName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件类型
|
||||
/// </summary>
|
||||
public string FileType { get; set; }
|
||||
/// <summary>
|
||||
/// 存储文件名
|
||||
/// </summary>
|
||||
public string FileName { get; set; }
|
||||
/// <summary>
|
||||
/// 文件存储地址 eg:/uploads/20220202
|
||||
/// </summary>
|
||||
public string FileUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 仓库位置 eg:/uploads
|
||||
/// </summary>
|
||||
public string StorePath { get; set; }
|
||||
/// <summary>
|
||||
/// 文件大小
|
||||
/// </summary>
|
||||
public string FileSize { get; set; }
|
||||
/// <summary>
|
||||
/// 文件扩展名
|
||||
/// </summary>
|
||||
public string FileExt { get; set; }
|
||||
/// <summary>
|
||||
/// 创建人
|
||||
/// </summary>
|
||||
public string Create_by { get; set; }
|
||||
/// <summary>
|
||||
/// 上传时间
|
||||
/// </summary>
|
||||
public DateTime? Create_time { get; set; }
|
||||
/// <summary>
|
||||
/// 存储类型
|
||||
/// </summary>
|
||||
public int? StoreType { get; set; }
|
||||
/// <summary>
|
||||
/// 访问路径
|
||||
/// </summary>
|
||||
public string AccessUrl { get; set; }
|
||||
|
||||
public SysFile() { }
|
||||
public SysFile(string originFileName, string fileName, string ext, string fileSize, string storePath, string create_by)
|
||||
{
|
||||
StorePath = storePath;
|
||||
RealName = originFileName;
|
||||
FileName = fileName;
|
||||
FileExt = ext;
|
||||
FileSize = fileSize;
|
||||
Create_by = create_by;
|
||||
Create_time = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// sys_logininfor 表
|
||||
/// </summary>
|
||||
[SugarTable("sys_logininfor", "登录日志表")]
|
||||
[Tenant("0")]
|
||||
public class SysLogininfor
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long InfoId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户账号
|
||||
/// </summary>
|
||||
public string UserName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录状态 0成功 1失败
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1, DefaultValue = "0")]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录IP地址
|
||||
/// </summary>
|
||||
public string Ipaddr { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 登录地点
|
||||
/// </summary>
|
||||
public string LoginLocation { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 浏览器类型
|
||||
/// </summary>
|
||||
public string Browser { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 操作系统
|
||||
/// </summary>
|
||||
public string Os { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 提示消息
|
||||
/// </summary>
|
||||
public string Msg { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 访问时间
|
||||
/// </summary>
|
||||
public DateTime LoginTime { get; set; } = DateTime.Now;
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public DateTime? BeginTime { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public DateTime? EndTime { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,113 @@
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// Sys_menu表
|
||||
/// </summary>
|
||||
[SugarTable("sys_menu", "系统菜单表")]
|
||||
[Tenant("0")]
|
||||
public class SysMenu : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long MenuId { get; set; }
|
||||
/// <summary>
|
||||
/// 菜单名称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 50, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string MenuName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 父菜单ID
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public long ParentId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 显示顺序
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int OrderNum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 路由地址
|
||||
/// </summary>
|
||||
public string Path { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// 组件路径
|
||||
/// </summary>
|
||||
public string Component { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否缓存(1缓存 0不缓存)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0", ColumnDataType = "int")]
|
||||
public string IsCache { get; set; }
|
||||
/// <summary>
|
||||
/// 是否外链 1、是 0、否
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0", ColumnDataType = "int")]
|
||||
public string IsFrame { get; set; } = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 类型(M目录 C菜单 F按钮 L链接)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 1)]
|
||||
public string MenuType { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 显示状态(0显示 1隐藏)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public string Visible { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public string Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 权限字符串
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100)]
|
||||
public string Perms { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 菜单图标
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "#")]
|
||||
public string Icon { get; set; } = string.Empty;
|
||||
/// <summary>
|
||||
/// 菜单名key
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "menuName_key")]
|
||||
public string MenuNameKey { get; set; }
|
||||
/// <summary>
|
||||
/// 子菜单
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public List<SysMenu> Children { get; set; } = new List<SysMenu>();
|
||||
/// <summary>
|
||||
/// 子菜单个数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int SubNum { get; set; }
|
||||
/// <summary>
|
||||
/// 是否包含子节点,前端用
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public bool HasChildren
|
||||
{
|
||||
get
|
||||
{
|
||||
return SubNum > 0 || Children.Count > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 通知公告表
|
||||
///
|
||||
/// @author zr
|
||||
/// @date 2021-12-15
|
||||
/// </summary>
|
||||
[SugarTable("sys_notice", "通知公告表")]
|
||||
[Tenant(0)]
|
||||
public class SysNotice : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 公告ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "notice_id")]
|
||||
public int NoticeId { get; set; }
|
||||
/// <summary>
|
||||
/// 公告标题
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "notice_title", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string NoticeTitle { get; set; }
|
||||
/// <summary>
|
||||
/// 公告类型 (1通知 2公告)
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "notice_type", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int NoticeType { get; set; }
|
||||
/// <summary>
|
||||
/// 公告内容
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "notice_content", ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string NoticeContent { get; set; }
|
||||
/// <summary>
|
||||
/// 公告状态 (0正常 1关闭)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SugarTable("sys_oper_log", "操作日志表")]
|
||||
[Tenant("0")]
|
||||
public class SysOperLog
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long OperId { get; set; }
|
||||
/// <summary>
|
||||
/// 操作模块
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务类型(0其它 1新增 2修改 3删除 4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int BusinessType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 业务类型数组
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[ExcelIgnore]
|
||||
public int[] BusinessTypes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方法
|
||||
/// </summary>
|
||||
public string Method { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求方式
|
||||
/// </summary>
|
||||
public string RequestMethod { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作类别(0其它 1后台用户 2手机端用户)
|
||||
/// </summary>
|
||||
//@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户")
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int OperatorType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作人员
|
||||
/// </summary>
|
||||
public string OperName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求url
|
||||
/// </summary>
|
||||
public string OperUrl { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作地址
|
||||
/// </summary>
|
||||
public string OperIp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作地点
|
||||
/// </summary>
|
||||
public string OperLocation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 请求参数
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 4000)]
|
||||
public string OperParam { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 返回参数
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnDataType = StaticConfig.CodeFirst_BigString)]
|
||||
public string JsonResult { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作状态(0正常 1异常)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息
|
||||
/// </summary>
|
||||
public string ErrorMsg { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 操作时间
|
||||
/// </summary>
|
||||
public DateTime? OperTime { get; set; }
|
||||
/// <summary>
|
||||
/// 操作用时
|
||||
/// </summary>
|
||||
public long Elapsed { get; set; }
|
||||
public string DeptName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SugarTable("sys_post", "岗位表")]
|
||||
[Tenant("0")]
|
||||
public class SysPost : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 岗位Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long PostId { get; set; }
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string PostCode { get; set; }
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string PostName { get; set; }
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int PostSort { get; set; }
|
||||
[SugarColumn(Length = 1)]
|
||||
public string Status { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色表 sys_role
|
||||
/// </summary>
|
||||
[SugarTable("sys_role", "角色表")]
|
||||
[Tenant("0")]
|
||||
public class SysRole : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色ID
|
||||
/// </summary>
|
||||
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
|
||||
public long RoleId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色名称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 30, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string RoleName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色权限
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 100, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string RoleKey { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 角色排序
|
||||
/// </summary>
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int RoleSort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 帐号状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除标志(0代表存在 2代表删除)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int DelFlag { get; set; }
|
||||
/// <summary>
|
||||
/// 数据范围(1:全部数据权限 2:自定数据权限 3:本部门数据权限 4:本部门及以下数据权限))
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "1")]
|
||||
public int DataScope { get; set; }
|
||||
/// <summary>
|
||||
/// 菜单树选择项是否关联显示
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "menu_check_strictly")]
|
||||
public bool MenuCheckStrictly { get; set; } = true;
|
||||
/// <summary>
|
||||
/// 部门树选择项是否关联显示
|
||||
/// </summary>
|
||||
[SugarColumn(ColumnName = "dept_check_strictly")]
|
||||
public bool DeptCheckStrictly { get; set; } = true;
|
||||
/// <summary>
|
||||
/// 菜单组
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public long[] MenuIds { get; set; }
|
||||
/// <summary>
|
||||
/// 部门组(数据权限)
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public long[] DeptIds { get; set; }
|
||||
/// <summary>
|
||||
/// 用户个数
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public int UserNum { get; set; }
|
||||
|
||||
public SysRole() { }
|
||||
|
||||
public SysRole(long roleId)
|
||||
{
|
||||
RoleId = roleId;
|
||||
}
|
||||
|
||||
public bool IsAdmin()
|
||||
{
|
||||
return IsAdmin(RoleId);
|
||||
}
|
||||
|
||||
public static bool IsAdmin(long roleId)
|
||||
{
|
||||
return 1 == roleId;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
[SugarTable("sys_role_dept", "角色部门")]
|
||||
[Tenant(0)]
|
||||
public class SysRoleDept
|
||||
{
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL, IsPrimaryKey = true)]
|
||||
public long RoleId { get; set; }
|
||||
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL, IsPrimaryKey = true)]
|
||||
public long DeptId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 角色菜单
|
||||
/// </summary>
|
||||
[SugarTable("sys_role_menu", "角色菜单")]
|
||||
[Tenant("0")]
|
||||
public class SysRoleMenu : SysBase
|
||||
{
|
||||
[JsonProperty("roleId")]
|
||||
[SugarColumn(IsPrimaryKey = true, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public long Role_id { get; set; }
|
||||
[JsonProperty("menuId")]
|
||||
[SugarColumn(IsPrimaryKey = true, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public long Menu_id { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
///<summary>
|
||||
///计划任务
|
||||
///</summary>
|
||||
[SugarTable("sys_tasks", "计划任务表")]
|
||||
[Tenant("0")]
|
||||
public class SysTasks : SysBase
|
||||
{
|
||||
public SysTasks()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 任务id
|
||||
/// </summary>
|
||||
[Display(Name = "任务id")]
|
||||
//[JsonConverter(typeof(ValueToStringConverter))]
|
||||
[SugarColumn(IsPrimaryKey = true)]
|
||||
public string ID { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务名称
|
||||
/// </summary>
|
||||
[Display(Name = "任务名称")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string Name { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务分组
|
||||
/// </summary>
|
||||
[Display(Name = "任务分组")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string JobGroup { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 运行时间表达式
|
||||
/// </summary>
|
||||
[Display(Name = "运行时间表达式")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string Cron { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 程序集名称
|
||||
/// </summary>
|
||||
[Display(Name = "程序集名称")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string AssemblyName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 任务所在类
|
||||
/// </summary>
|
||||
[Display(Name = "任务所在类")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string ClassName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行次数
|
||||
/// </summary>
|
||||
[Display(Name = "执行次数")]
|
||||
[SugarColumn(DefaultValue = "0", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int RunTimes { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 开始时间
|
||||
/// </summary>
|
||||
[Display(Name = "开始时间")]
|
||||
public DateTime? BeginTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 结束时间
|
||||
/// </summary>
|
||||
[Display(Name = "结束时间")]
|
||||
public DateTime? EndTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 触发器类型(0、simple 1、cron)
|
||||
/// 默认 : 1
|
||||
/// </summary>
|
||||
[Display(Name = "触发器类型(0、simple 1、cron)")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int TriggerType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 执行间隔时间(单位:秒)
|
||||
/// 默认 : 0
|
||||
/// </summary>
|
||||
[Display(Name = "执行间隔时间(单位:秒)")]
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int IntervalSecond { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否启动
|
||||
/// </summary>
|
||||
[Display(Name = "是否启动")]
|
||||
[SugarColumn(DefaultValue = "0", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public int IsStart { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 传入参数
|
||||
/// </summary>
|
||||
[Display(Name = "传入参数")]
|
||||
public string JobParams { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后运行时间
|
||||
/// </summary>
|
||||
public DateTime? LastRunTime { get; set; }
|
||||
/// <summary>
|
||||
/// api执行地址
|
||||
/// </summary>
|
||||
public string ApiUrl { get; set; }
|
||||
/// <summary>
|
||||
/// 任务类型 1、程序集 2、网络请求 3、SQL语句
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "1")]
|
||||
public int TaskType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// SQL语句
|
||||
/// </summary>
|
||||
public string SqlText { get; set; }
|
||||
/// <summary>
|
||||
/// 网络请求方式
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 20)]
|
||||
public string RequestMethod { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
using SqlSugar;
|
||||
using System;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 任务日志
|
||||
/// </summary>
|
||||
[SugarTable("sys_tasks_log", "任务日志表")]
|
||||
[Tenant("0")]
|
||||
public class SysTasksLog
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志Id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public long JobLogId { get; set; }
|
||||
/// <summary>
|
||||
/// 任务Id
|
||||
/// </summary>
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string JobId { get; set; }
|
||||
/// <summary>
|
||||
/// 任务名
|
||||
/// </summary>
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string JobName { get; set; }
|
||||
/// <summary>
|
||||
/// 任务分组
|
||||
/// </summary>
|
||||
[SugarColumn(ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string JobGroup { get; set; }
|
||||
/// <summary>
|
||||
/// 执行状态(0正常 1失败)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public string Status { get; set; }
|
||||
/// <summary>
|
||||
/// 异常
|
||||
/// </summary>
|
||||
public string Exception { get; set; }
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public string JobMessage { get; set; }
|
||||
/// <summary>
|
||||
/// 调用目标字符串
|
||||
/// </summary>
|
||||
public string InvokeTarget { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
/// <summary>
|
||||
/// 执行用时,毫秒
|
||||
/// </summary>
|
||||
//[SqlSugar.SugarColumn(IsIgnore = true)]
|
||||
public double Elapsed { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
using MiniExcelLibs.Attributes;
|
||||
using Newtonsoft.Json;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户表
|
||||
/// </summary>
|
||||
[SugarTable("sys_user", "用户表")]
|
||||
[Tenant("0")]
|
||||
public class SysUser : SysBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户id
|
||||
/// </summary>
|
||||
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
|
||||
public long UserId { get; set; }
|
||||
/// <summary>
|
||||
/// 登录用户名
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 30, ColumnDescription = "用户账号", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string UserName { get; set; }
|
||||
/// <summary>
|
||||
/// 用户昵称
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 30, ColumnDescription = "用户昵称", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string NickName { get; set; }
|
||||
/// <summary>
|
||||
/// 用户类型(00系统用户)
|
||||
/// </summary>
|
||||
[SugarColumn(Length = 2, ColumnDescription = "用户类型(00系统用户)", DefaultValue = "00")]
|
||||
public string UserType { get; set; } = "00";
|
||||
//[SugarColumn(IsOnlyIgnoreInsert = true)]
|
||||
public string Avatar { get; set; }
|
||||
[SugarColumn(Length = 50, ColumnDescription = "用户邮箱")]
|
||||
public string Email { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
[ExcelIgnore]
|
||||
[SugarColumn(Length = 100, ColumnDescription = "密码", ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public string Password { get; set; }
|
||||
/// <summary>
|
||||
/// 手机号
|
||||
/// </summary>
|
||||
public string Phonenumber { get; set; }
|
||||
/// <summary>
|
||||
/// 用户性别(0男 1女 2未知)
|
||||
/// </summary>
|
||||
public int Sex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 帐号状态(0正常 1停用)
|
||||
/// </summary>
|
||||
[ExcelIgnore]
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int Status { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 删除标志(0代表存在 2代表删除)
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public int DelFlag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后登录IP
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true)]
|
||||
public string LoginIP { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 最后登录时间
|
||||
/// </summary>
|
||||
[SugarColumn(IsOnlyIgnoreInsert = true)]
|
||||
[ExcelColumn(Name = "登录日期", Format = "yyyy-MM-dd HH:mm:ss")]
|
||||
public DateTime? LoginDate { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 部门Id
|
||||
/// </summary>
|
||||
[SugarColumn(DefaultValue = "0")]
|
||||
public long DeptId { get; set; }
|
||||
|
||||
#region 表额外字段
|
||||
public bool IsAdmin()
|
||||
{
|
||||
return IsAdmin(UserId);
|
||||
}
|
||||
public static bool IsAdmin(long userId)
|
||||
{
|
||||
return 1 == userId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 拥有角色个数
|
||||
/// </summary>
|
||||
//[SugarColumn(IsIgnore = true)]
|
||||
//public int RoleNum { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string DeptName { get; set; }
|
||||
/// <summary>
|
||||
/// 角色id集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[ExcelIgnore]
|
||||
public long[] RoleIds { get; set; }
|
||||
/// <summary>
|
||||
/// 岗位集合
|
||||
/// </summary>
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[ExcelIgnore]
|
||||
public int[] PostIds { get; set; }
|
||||
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
[ExcelIgnore]
|
||||
public List<SysRole> Roles { get; set; }
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string WelcomeMessage
|
||||
{
|
||||
get
|
||||
{
|
||||
int now = DateTime.Now.Hour;
|
||||
|
||||
if (now > 0 && now <= 6)
|
||||
{
|
||||
return "午夜好";
|
||||
}
|
||||
else if (now > 6 && now <= 11)
|
||||
{
|
||||
return "早上好";
|
||||
}
|
||||
else if (now > 11 && now <= 14)
|
||||
{
|
||||
return "中午好";
|
||||
}
|
||||
else if (now > 14 && now <= 18)
|
||||
{
|
||||
return "下午好";
|
||||
}
|
||||
else
|
||||
{
|
||||
return "晚上好";
|
||||
}
|
||||
}
|
||||
}
|
||||
[SugarColumn(IsIgnore = true)]
|
||||
public string WelcomeContent { get; set; }
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户岗位
|
||||
/// </summary>
|
||||
[SugarTable("sys_user_post", "用户与岗位关联表")]
|
||||
[Tenant("0")]
|
||||
public class SysUserPost
|
||||
{
|
||||
[SugarColumn(IsPrimaryKey = true, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public long UserId { get; set; }
|
||||
[SugarColumn(IsPrimaryKey = true, ExtendedAttribute = ProteryConstant.NOTNULL)]
|
||||
public long PostId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using SqlSugar;
|
||||
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 用户角色关联表 用户N-1 角色
|
||||
/// </summary>
|
||||
[SugarTable("sys_user_role", "用户和角色关联表")]
|
||||
[Tenant("0")]
|
||||
public class SysUserRole
|
||||
{
|
||||
[SugarColumn(ColumnName = "user_id", IsPrimaryKey = true)]
|
||||
public long UserId { get; set; }
|
||||
|
||||
[SugarColumn(ColumnName = "role_id", IsPrimaryKey = true)]
|
||||
public long RoleId { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
namespace ZR.Model.System
|
||||
{
|
||||
public class UserConstants
|
||||
{
|
||||
/// <summary>
|
||||
/// 平台内系统用户的唯一标志
|
||||
/// </summary>
|
||||
public static string SYS_USER = "SYS_USER";
|
||||
|
||||
/// <summary>
|
||||
/// 正常状态
|
||||
/// </summary>
|
||||
public static string NORMAL = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 异常状态
|
||||
/// </summary>
|
||||
public static string EXCEPTION = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 用户封禁状态
|
||||
/// </summary>
|
||||
public static string USER_DISABLE = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 角色封禁状态
|
||||
/// </summary>
|
||||
public static string ROLE_DISABLE = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 部门正常状态
|
||||
/// </summary>
|
||||
public static int DEPT_NORMAL = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 部门停用状态
|
||||
/// </summary>
|
||||
public static string DEPT_DISABLE = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 字典正常状态
|
||||
/// </summary>
|
||||
public static string DICT_NORMAL = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 是否为系统默认(是)
|
||||
/// </summary>
|
||||
public static string YES = "Y";
|
||||
|
||||
/// <summary>
|
||||
/// 是否菜单外链(是)
|
||||
/// </summary>
|
||||
public static string YES_FRAME = "1";
|
||||
|
||||
/// <summary>
|
||||
/// 是否菜单外链(否)
|
||||
/// </summary>
|
||||
public static string NO_FRAME = "0";
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型(目录)
|
||||
/// </summary>
|
||||
public static string TYPE_DIR = "M";
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型(菜单)
|
||||
/// </summary>
|
||||
public static string TYPE_MENU = "C";
|
||||
|
||||
/// <summary>
|
||||
/// 菜单类型(按钮)
|
||||
/// </summary>
|
||||
public static string TYPE_BUTTON = "F";
|
||||
|
||||
///// <summary>
|
||||
///// 菜单类型(链接)
|
||||
///// </summary>
|
||||
//public static string TYPE_LINK = "L";
|
||||
|
||||
/// <summary>
|
||||
/// Layout组件标识
|
||||
/// </summary>
|
||||
public static string LAYOUT = "Layout";
|
||||
|
||||
/// <summary>
|
||||
/// ParentView组件标识
|
||||
/// </summary>
|
||||
public static string PARENT_VIEW = "ParentView";
|
||||
|
||||
/// <summary>
|
||||
/// InnerLink组件标识
|
||||
/// </summary>
|
||||
public static string INNER_LINK = "InnerLink";
|
||||
|
||||
/// <summary>
|
||||
/// 校验返回结果码
|
||||
/// </summary>
|
||||
public static string UNIQUE = "0";
|
||||
public static string NOT_UNIQUE = "1";
|
||||
|
||||
/// <summary>
|
||||
/// http请求
|
||||
/// </summary>
|
||||
public static string HTTP = "http://";
|
||||
|
||||
/// <summary>
|
||||
/// https请求
|
||||
/// </summary>
|
||||
public static string HTTPS = "https://";
|
||||
/// <summary>
|
||||
/// www主域
|
||||
/// </summary>
|
||||
public static string WWW = "www.";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ZR.Model.System.Vo
|
||||
{
|
||||
/// <summary>
|
||||
/// 路由展示
|
||||
/// </summary>
|
||||
public class RouterVo
|
||||
{
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool AlwaysShow { get; set; }
|
||||
private string component;
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public bool Hidden { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Path { get; set; }
|
||||
public string Redirect { get; set; }
|
||||
public Meta Meta { get; set; }
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public List<RouterVo> Children { get; set; }
|
||||
public string Component { get => component; set => component = value; }
|
||||
}
|
||||
|
||||
public class Meta
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置该路由在侧边栏和面包屑中展示的名字
|
||||
/// </summary>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// 设置该路由的图标,对应路径src/assets/icons/svg
|
||||
/// </summary>
|
||||
public string Icon { get; set; }
|
||||
/// <summary>
|
||||
/// 设置为true,则不会被 <keep-alive>缓存
|
||||
/// </summary>
|
||||
public bool NoCache { get; set; }
|
||||
public string TitleKey { get; set; } = string.Empty;
|
||||
public string Link { get; set; } = string.Empty;
|
||||
public int IsNew { get; set; }
|
||||
|
||||
public Meta(string title, string icon)
|
||||
{
|
||||
Title = title;
|
||||
Icon = icon;
|
||||
}
|
||||
public Meta(string title, string icon, string path)
|
||||
{
|
||||
Title = title;
|
||||
Icon = icon;
|
||||
Link = path;
|
||||
}
|
||||
public Meta(string title, string icon, bool noCache, string titleKey, string path, DateTime addTime)
|
||||
{
|
||||
Title = title;
|
||||
Icon = icon;
|
||||
NoCache = noCache;
|
||||
TitleKey = titleKey;
|
||||
if (!string.IsNullOrEmpty(path) && (path.StartsWith(UserConstants.HTTP) || path.StartsWith(UserConstants.HTTPS)))
|
||||
{
|
||||
Link = path;
|
||||
}
|
||||
if (addTime != DateTime.MinValue)
|
||||
{
|
||||
TimeSpan ts = DateTime.Now - addTime;
|
||||
if (ts.Days < 7)
|
||||
{
|
||||
IsNew = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
namespace ZR.Model.System.Vo
|
||||
{
|
||||
/// <summary>
|
||||
/// Treeselect树结构实体类
|
||||
/// </summary>
|
||||
public class TreeSelectVo
|
||||
{
|
||||
/// <summary>
|
||||
/// 节点Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 节点名称
|
||||
/// </summary>
|
||||
public string Label { get; set; }
|
||||
public string Status { get; set; }
|
||||
public string MenuType { get; set; }
|
||||
|
||||
public TreeSelectVo() { }
|
||||
|
||||
public TreeSelectVo(SysMenu menu)
|
||||
{
|
||||
Id = menu.MenuId;
|
||||
Label = menu.MenuName;
|
||||
Status = menu.Status;
|
||||
MenuType = menu.MenuType;
|
||||
|
||||
List<TreeSelectVo> child = new List<TreeSelectVo>();
|
||||
foreach (var item in menu.Children)
|
||||
{
|
||||
child.Add(new TreeSelectVo(item));
|
||||
}
|
||||
|
||||
Children = child;
|
||||
}
|
||||
|
||||
public TreeSelectVo(SysDept dept)
|
||||
{
|
||||
Id = dept.DeptId;
|
||||
Label = dept.DeptName;
|
||||
|
||||
//menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); java写法
|
||||
List<TreeSelectVo> child = new List<TreeSelectVo>();
|
||||
foreach (var item in dept.children)
|
||||
{
|
||||
child.Add(new TreeSelectVo(item));
|
||||
}
|
||||
|
||||
Children = child;
|
||||
}
|
||||
|
||||
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
|
||||
public List<TreeSelectVo> Children { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
public enum ProteryConstant
|
||||
{
|
||||
NOTNULL = 0
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文章目录Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleCategoryService : BaseService<ArticleCategory>, IArticleCategoryService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询文章目录列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<ArticleCategory> GetList(ArticleCategoryQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<ArticleCategory>();
|
||||
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询文章目录树列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public List<ArticleCategory> GetTreeList(ArticleCategoryQueryDto parm)
|
||||
{
|
||||
//开始拼装查询条件
|
||||
var predicate = Expressionable.Create<ArticleCategory>();
|
||||
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
|
||||
var response = Queryable().Where(predicate.ToExpression())
|
||||
.ToTree(it => it.Children, it => it.ParentId, 0);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加文章目录
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public int AddArticleCategory(ArticleCategory parm)
|
||||
{
|
||||
var response = Insert(parm, it => new
|
||||
{
|
||||
it.Name,
|
||||
it.CreateTime,
|
||||
it.ParentId,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IArticleService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class ArticleService : BaseService<Article>, IArticleService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询文章管理列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<ArticleDto> GetList(ArticleQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<Article>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), m => m.Title.Contains(parm.Title));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status);
|
||||
|
||||
//搜索条件查询语法参考Sqlsugar
|
||||
var response = Queryable()
|
||||
.Includes(x => x.ArticleCategoryNav) //填充子对象
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderBy(x => x.CreateTime, OrderByType.Desc)
|
||||
.ToPage<Article, ArticleDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询我的文章列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<ArticleDto> GetMyList(ArticleQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<Article>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Title), m => m.Title.Contains(parm.Title));
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.Status), m => m.Status == parm.Status);
|
||||
predicate = predicate.AndIF(parm.BeginTime != null, m => m.CreateTime >= parm.BeginTime);
|
||||
predicate = predicate.AndIF(parm.EndTime != null, m => m.CreateTime <= parm.EndTime);
|
||||
predicate = predicate.And(m => m.UserId == parm.UserId);
|
||||
|
||||
var response = Queryable()
|
||||
.Includes(x => x.ArticleCategoryNav)
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<Article, ArticleDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改文章管理
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateArticle(Article model)
|
||||
{
|
||||
var response = Update(w => w.Cid == model.Cid, it => new Article()
|
||||
{
|
||||
Title = model.Title,
|
||||
Content = model.Content,
|
||||
Status = model.Status,
|
||||
Tags = model.Tags,
|
||||
UpdateTime = DateTime.Now,
|
||||
CoverUrl = model.CoverUrl,
|
||||
CategoryId = model.CategoryId,
|
||||
FmtType = model.FmtType,
|
||||
IsPublic = model.IsPublic,
|
||||
});
|
||||
return response;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using System;
|
||||
using ZR.Common;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
public class CacheService
|
||||
{
|
||||
private readonly static string CK_verifyScan = "verifyScan_";
|
||||
#region 用户权限 缓存
|
||||
public static List<string> GetUserPerms(string key)
|
||||
{
|
||||
return (List<string>)CacheHelper.GetCache(key);
|
||||
//return RedisServer.Cache.Get<List<string>>(key).ToList();
|
||||
}
|
||||
|
||||
public static void SetUserPerms(string key, object data)
|
||||
{
|
||||
CacheHelper.SetCache(key, data);
|
||||
//RedisServer.Cache.Set(key, data);
|
||||
}
|
||||
public static void RemoveUserPerms(string key)
|
||||
{
|
||||
CacheHelper.Remove(key);
|
||||
//RedisServer.Cache.Del(key);
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static object SetScanLogin(string key, Dictionary<string, object> val)
|
||||
{
|
||||
var ck = CK_verifyScan + key;
|
||||
|
||||
return CacheHelper.SetCache(ck,val , 1);
|
||||
}
|
||||
public static object GetScanLogin(string key)
|
||||
{
|
||||
var ck = CK_verifyScan + key;
|
||||
return CacheHelper.Get(ck);
|
||||
}
|
||||
public static void RemoveScanLogin(string key)
|
||||
{
|
||||
var ck = CK_verifyScan + key;
|
||||
CacheHelper.Remove(ck);
|
||||
}
|
||||
|
||||
public static void SetLockUser(string key, long val, int time)
|
||||
{
|
||||
var CK = "lock_user_" + key;
|
||||
|
||||
CacheHelper.SetCache(CK, val, time);
|
||||
}
|
||||
|
||||
public static long GetLockUser(string key)
|
||||
{
|
||||
var CK = "lock_user_" + key;
|
||||
|
||||
if (CacheHelper.Get(CK) is long t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 多语言配置Service业务层处理
|
||||
///
|
||||
/// @author zr
|
||||
/// @date 2022-05-06
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ICommonLangService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class CommonLangService : BaseService<CommonLang>, ICommonLangService
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
|
||||
/// <summary>
|
||||
/// 查询多语言配置列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<CommonLang> GetList(CommonLangQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<CommonLang>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage(parm);
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 行转列
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public dynamic GetListToPivot(CommonLangQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<CommonLang>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPivotList(it => it.LangCode, it => it.LangKey, it => it.Max(f => f.LangName));
|
||||
return response;
|
||||
}
|
||||
|
||||
public List<CommonLang> GetLangList(CommonLangQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<CommonLang>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
|
||||
//predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
|
||||
var response = Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.ToList();
|
||||
return response;
|
||||
}
|
||||
|
||||
public void StorageCommonLang(CommonLangDto parm)
|
||||
{
|
||||
List<CommonLang> langs = new();
|
||||
foreach (var item in parm.LangList)
|
||||
{
|
||||
langs.Add(new CommonLang()
|
||||
{
|
||||
Addtime = DateTime.Now,
|
||||
LangKey = parm.LangKey,
|
||||
LangCode = item.LangCode,
|
||||
LangName = item.LangName,
|
||||
});
|
||||
}
|
||||
var storage = Context.Storageable(langs)
|
||||
.WhereColumns(it => new { it.LangKey, it.LangCode })
|
||||
.ToStorage();
|
||||
|
||||
storage.AsInsertable.ExecuteReturnSnowflakeIdList();//执行插入
|
||||
storage.AsUpdateable.UpdateColumns(it => new { it.LangName }).ExecuteCommand();//执行修改
|
||||
}
|
||||
|
||||
public Dictionary<string, object> SetLang(List<CommonLang> msgList)
|
||||
{
|
||||
Dictionary<string, object> dic = new();
|
||||
|
||||
foreach (var item in msgList)
|
||||
{
|
||||
if (!dic.ContainsKey(item.LangKey))
|
||||
{
|
||||
dic.Add(item.LangKey, item.LangName);
|
||||
}
|
||||
}
|
||||
return dic;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 导入多语言设置
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) ImportCommonLang(List<CommonLang> list)
|
||||
{
|
||||
var x = Context.Storageable(list)
|
||||
.WhereColumns(it => new { it.LangKey, it.LangCode })
|
||||
.ToStorage();
|
||||
x.AsInsertable.ExecuteReturnSnowflakeIdList();//插入可插入部分;
|
||||
x.AsUpdateable.UpdateColumns(it => new { it.LangName }).ExecuteCommand();
|
||||
|
||||
string msg = $"插入{x.InsertList.Count} 更新{x.UpdateList.Count} 错误数据{x.ErrorList.Count} 不计算数据{x.IgnoreList.Count} 删除数据{x.DeleteList.Count} 总共{x.TotalList.Count}";
|
||||
|
||||
//输出错误信息
|
||||
foreach (var item in x.ErrorList)
|
||||
{
|
||||
Console.WriteLine("错误" + item.StorageMessage);
|
||||
}
|
||||
foreach (var item in x.IgnoreList)
|
||||
{
|
||||
Console.WriteLine("忽略" + item.StorageMessage);
|
||||
}
|
||||
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,274 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Generate;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 代码生成表
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class GenTableService : BaseService<GenTable>, IGenTableService
|
||||
{
|
||||
private IGenTableColumnService GenTableColumnService;
|
||||
public GenTableService(IGenTableColumnService genTableColumnService)
|
||||
{
|
||||
GenTableColumnService = genTableColumnService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除表
|
||||
/// </summary>
|
||||
/// <param name="tableIds">需要删除的表id</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableByIds(long[] tableIds)
|
||||
{
|
||||
Delete(f => tableIds.Contains(f.TableId));
|
||||
return GenTableColumnService.DeleteGenTableColumn(tableIds);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除表根据表名
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableByTbName(string tableName)
|
||||
{
|
||||
return Delete(f => f.TableName == tableName) ? 1 : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表信息
|
||||
/// </summary>
|
||||
/// <param name="tableId"></param>
|
||||
/// <returns></returns>
|
||||
public GenTable GetGenTableInfo(long tableId)
|
||||
{
|
||||
GenTable info = GetId(tableId);
|
||||
if (info != null)
|
||||
{
|
||||
info.Columns = GenTableColumnService.GenTableColumns(tableId);
|
||||
if (!info.SubTableName.IsEmpty())
|
||||
{
|
||||
info.SubTable = Queryable().Where(f => f.TableName == info.SubTableName).First();
|
||||
info.SubTable.Columns = GenTableColumnService.GenTableColumns(info.SubTable.TableId);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有代码生成表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<GenTable> GetGenTableAll()
|
||||
{
|
||||
return GetAll();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询代码生成表信息
|
||||
/// </summary>
|
||||
/// <param name="genTable"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<GenTable> GetGenTables(GenTable genTable, PagerInfo pagerInfo)
|
||||
{
|
||||
var predicate = Expressionable.Create<GenTable>();
|
||||
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
|
||||
|
||||
return GetPages(predicate.ToExpression(), pagerInfo, x => x.TableId, OrderByType.Desc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入代码生成表
|
||||
/// </summary>
|
||||
/// <param name="table"></param>
|
||||
/// <returns></returns>
|
||||
public int ImportGenTable(GenTable table)
|
||||
{
|
||||
table.Create_time = DateTime.Now;
|
||||
//导入前删除现有表
|
||||
//DeleteGenTableByIds(new long[] { table.TableId });
|
||||
DeleteGenTableByTbName(table.TableName);
|
||||
|
||||
return Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表数据
|
||||
/// </summary>
|
||||
/// <param name="tableNames"></param>
|
||||
/// <returns></returns>
|
||||
public List<GenTable> SelectDbTableListByNamess(string[] tableNames)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public int UpdateGenTable(GenTable genTable)
|
||||
{
|
||||
var db = Context;
|
||||
genTable.Update_time = db.GetDate();
|
||||
return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步数据库
|
||||
/// </summary>
|
||||
/// <param name="tableId">表id</param>
|
||||
/// <param name="genTable"></param>
|
||||
/// <param name="dbTableColumns">数据库表最新列初始化信息集合</param>
|
||||
public bool SynchDb(long tableId, GenTable genTable, List<GenTableColumn> dbTableColumns)
|
||||
{
|
||||
List<string> tableColumnNames = genTable.Columns.Select(f => f.ColumnName).ToList();//老列明
|
||||
List<string> dbTableColumneNames = dbTableColumns.Select(f => f.ColumnName).ToList();//新列明
|
||||
|
||||
List<GenTableColumn> insertColumns = new();
|
||||
List<GenTableColumn> updateColumns = new();
|
||||
foreach (var column in dbTableColumns)
|
||||
{
|
||||
if (!tableColumnNames.Contains(column.ColumnName))
|
||||
{
|
||||
insertColumns.Add(column);
|
||||
}
|
||||
else
|
||||
{
|
||||
GenTableColumn prevColumn = genTable.Columns.Find(f => f.ColumnName == column.ColumnName);
|
||||
column.ColumnId = prevColumn.ColumnId;
|
||||
column.IsEdit = prevColumn.IsEdit;
|
||||
column.AutoFillType = prevColumn.AutoFillType;
|
||||
column.Sort = prevColumn.Sort;
|
||||
column.IsExport = prevColumn.IsExport;
|
||||
column.IsSort = prevColumn.IsSort;
|
||||
column.Update_time = DateTime.Now;
|
||||
column.Update_by = genTable.Update_by;
|
||||
if (column.IsList)
|
||||
{
|
||||
column.DictType = prevColumn.DictType;
|
||||
column.QueryType = prevColumn.QueryType;
|
||||
}
|
||||
//不同步列说明
|
||||
//if (column.ColumnComment.IsEmpty())
|
||||
//{
|
||||
// column.ColumnComment = prevColumn.ColumnComment;
|
||||
//}
|
||||
updateColumns.Add(column);
|
||||
}
|
||||
}
|
||||
bool result = UseTran2(() =>
|
||||
{
|
||||
if (insertColumns.Count > 0)
|
||||
{
|
||||
GenTableColumnService.Insert(insertColumns);
|
||||
}
|
||||
if (updateColumns.Count > 0)
|
||||
{
|
||||
GenTableColumnService.UpdateGenTableColumn(updateColumns);
|
||||
}
|
||||
|
||||
List<GenTableColumn> delColumns = genTable.Columns.FindAll(column => !dbTableColumneNames.Contains(column.ColumnName));
|
||||
if (delColumns != null && delColumns.Count > 0)
|
||||
{
|
||||
GenTableColumnService.Delete(delColumns.Select(f => f.ColumnId).ToList());
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 代码生成表列
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class GenTableColumnService : BaseService<GenTableColumn>, IGenTableColumnService
|
||||
{
|
||||
/// <summary>
|
||||
/// 删除表字段
|
||||
/// </summary>
|
||||
/// <param name="tableId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableColumn(long tableId)
|
||||
{
|
||||
return Deleteable().Where(f => new long[] { tableId }.Contains(f.TableId)).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据表id批量删除表字段
|
||||
/// </summary>
|
||||
/// <param name="tableId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableColumn(long[] tableId)
|
||||
{
|
||||
return Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据表名删除字段
|
||||
/// </summary>
|
||||
/// <param name="tableName"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteGenTableColumnByTableName(string tableName)
|
||||
{
|
||||
return Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取表所有字段
|
||||
/// </summary>
|
||||
/// <param name="tableId"></param>
|
||||
/// <returns></returns>
|
||||
public List<GenTableColumn> GenTableColumns(long tableId)
|
||||
{
|
||||
return Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入表字段
|
||||
/// </summary>
|
||||
/// <param name="tableColumn"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertGenTableColumn(List<GenTableColumn> tableColumn)
|
||||
{
|
||||
return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量更新表字段
|
||||
/// </summary>
|
||||
/// <param name="tableColumn"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateGenTableColumn(List<GenTableColumn> tableColumn)
|
||||
{
|
||||
return Context.Updateable(tableColumn)
|
||||
.WhereColumns(it => new { it.ColumnId })
|
||||
.UpdateColumns(it => new
|
||||
{
|
||||
it.ColumnComment,
|
||||
it.CsharpField,
|
||||
it.CsharpType,
|
||||
it.IsQuery,
|
||||
it.IsEdit,
|
||||
it.IsInsert,
|
||||
it.IsList,
|
||||
it.QueryType,
|
||||
it.HtmlType,
|
||||
it.IsRequired,
|
||||
it.Sort,
|
||||
it.Update_time,
|
||||
it.DictType,
|
||||
it.Update_by,
|
||||
it.Remark,
|
||||
it.IsSort,//
|
||||
it.IsExport,
|
||||
it.AutoFillType,
|
||||
})
|
||||
.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface IArticleCategoryService : IBaseService<ArticleCategory>
|
||||
{
|
||||
PagedInfo<ArticleCategory> GetList(ArticleCategoryQueryDto parm);
|
||||
List<ArticleCategory> GetTreeList(ArticleCategoryQueryDto parm);
|
||||
int AddArticleCategory(ArticleCategory parm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface IArticleService : IBaseService<Article>
|
||||
{
|
||||
PagedInfo<ArticleDto> GetList(ArticleQueryDto parm);
|
||||
PagedInfo<ArticleDto> GetMyList(ArticleQueryDto parm);
|
||||
/// <summary>
|
||||
/// 修改文章管理
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateArticle(Article model);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.Dto;
|
||||
using ZR.Model.Models;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 多语言配置service接口
|
||||
///
|
||||
/// @author zr
|
||||
/// @date 2022-05-06
|
||||
/// </summary>
|
||||
public interface ICommonLangService : IBaseService<CommonLang>
|
||||
{
|
||||
PagedInfo<CommonLang> GetList(CommonLangQueryDto parm);
|
||||
List<CommonLang> GetLangList(CommonLangQueryDto parm);
|
||||
dynamic GetListToPivot(CommonLangQueryDto parm);
|
||||
void StorageCommonLang(CommonLangDto parm);
|
||||
Dictionary<string, object> SetLang(List<CommonLang> msgList);
|
||||
|
||||
(string, object, object) ImportCommonLang(List<CommonLang> list);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface IGenTableService : IBaseService<GenTable>
|
||||
{
|
||||
List<GenTable> SelectDbTableListByNamess(string[] tableNames);
|
||||
|
||||
int ImportGenTable(GenTable tables);
|
||||
|
||||
int DeleteGenTableByIds(long[] tableIds);
|
||||
int DeleteGenTableByTbName(string tableName);
|
||||
PagedInfo<GenTable> GetGenTables(GenTable genTable, PagerInfo pagerInfo);
|
||||
GenTable GetGenTableInfo(long tableId);
|
||||
bool SynchDb(long tableId, GenTable genTable, List<GenTableColumn> genTableColumns);
|
||||
List<GenTable> GetGenTableAll();
|
||||
int UpdateGenTable(GenTable genTable);
|
||||
}
|
||||
|
||||
public interface IGenTableColumnService : IBaseService<GenTableColumn>
|
||||
{
|
||||
int InsertGenTableColumn(List<GenTableColumn> tableColumn);
|
||||
|
||||
int DeleteGenTableColumn(long tableId);
|
||||
int DeleteGenTableColumn(long[] tableIds);
|
||||
int DeleteGenTableColumnByTableName(string tableName);
|
||||
List<GenTableColumn> GenTableColumns(long tableId);
|
||||
int UpdateGenTableColumn(List<GenTableColumn> tableColumn);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据差异日志service接口
|
||||
/// </summary>
|
||||
public interface ISqlDiffLogService : IBaseService<SqlDiffLog>
|
||||
{
|
||||
PagedInfo<SqlDiffLogDto> GetList(SqlDiffLogQueryDto parm);
|
||||
|
||||
SqlDiffLog GetInfo(long PId);
|
||||
|
||||
SqlDiffLog AddSqlDiffLog(SqlDiffLog parm);
|
||||
|
||||
int UpdateSqlDiffLog(SqlDiffLog parm);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数配置service接口
|
||||
///
|
||||
/// @author mr.zhao
|
||||
/// @date 2021-09-29
|
||||
/// </summary>
|
||||
public interface ISysConfigService : IBaseService<SysConfig>
|
||||
{
|
||||
SysConfig GetSysConfigByKey(string key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Vo;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysDeptService : IBaseService<SysDept>
|
||||
{
|
||||
List<SysDept> GetSysDepts(SysDeptQueryDto dept);
|
||||
string CheckDeptNameUnique(SysDept dept);
|
||||
int InsertDept(SysDept dept);
|
||||
int UpdateDept(SysDept dept);
|
||||
void UpdateDeptChildren(long deptId, string newAncestors, string oldAncestors);
|
||||
List<SysDept> GetChildrenDepts(List<SysDept> depts, long deptId);
|
||||
List<SysDept> BuildDeptTree(List<SysDept> depts);
|
||||
List<TreeSelectVo> BuildDeptTreeSelect(List<SysDept> depts);
|
||||
List<SysRoleDept> SelectRoleDeptByRoleId(long roleId);
|
||||
|
||||
List<long> SelectRoleDepts(long roleId);
|
||||
bool DeleteRoleDeptByRoleId(long roleId);
|
||||
int InsertRoleDepts(SysRole role);
|
||||
}
|
||||
|
||||
public interface ISysRoleDeptService : IBaseService<SysRoleDept>
|
||||
{
|
||||
List<SysRoleDept> SelectRoleDeptByRoleId(long roleId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysDictDataService : IBaseService<SysDictData>
|
||||
{
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
|
||||
public List<SysDictData> SelectDictDataByType(string dictType);
|
||||
public List<SysDictData> SelectDictDataByTypes(string[] dictTypes);
|
||||
public SysDictData SelectDictDataById(long dictCode);
|
||||
public long InsertDictData(SysDictData dict);
|
||||
public long UpdateDictData(SysDictData dict);
|
||||
public int DeleteDictDataByIds(long[] dictCodes);
|
||||
int UpdateDictDataType(string old_dictType, string new_dictType);
|
||||
List<SysDictData> SelectDictDataByCustomSql(SysDictType sysDictType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public interface ISysDictService
|
||||
{
|
||||
public List<SysDictType> GetAll();
|
||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 校验字典类型称是否唯一
|
||||
/// </summary>
|
||||
/// <param name="dictType">字典类型</param>
|
||||
/// <returns></returns>
|
||||
public string CheckDictTypeUnique(SysDictType dictType);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典数据信息
|
||||
/// </summary>
|
||||
/// <param name="dictIds"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictTypeByIds(long[] dictIds);
|
||||
|
||||
/// <summary>
|
||||
/// 插入字典类型
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public long InsertDictType(SysDictType sysDictType);
|
||||
|
||||
/// <summary>
|
||||
/// 修改字典类型
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDictType(SysDictType sysDictType);
|
||||
|
||||
/// <summary>
|
||||
/// 获取字典信息
|
||||
/// </summary>
|
||||
/// <param name="dictId"></param>
|
||||
/// <returns></returns>
|
||||
SysDictType GetInfo(long dictId);
|
||||
|
||||
List<SysDictData> SelectDictDataByCustomSql(string dictType);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.Models;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysFileService : IBaseService<SysFile>
|
||||
{
|
||||
Task<long> InsertFile(SysFile file);
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件
|
||||
/// </summary>
|
||||
/// <param name="fileDir"></param>
|
||||
/// <param name="fileName"></param>
|
||||
/// <param name="formFile"></param>
|
||||
/// <param name="rootPath"></param>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns>文件对象</returns>
|
||||
Task<SysFile> SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile);
|
||||
|
||||
Task<SysFile> SaveFileToAliyun(SysFile file, IFormFile formFile);
|
||||
/// <summary>
|
||||
/// 按时间来创建文件夹
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="byTimeStore"></param>
|
||||
/// <returns>eg: 2020/11/3</returns>
|
||||
string GetdirPath(string path = "", bool byTimeStore = true);
|
||||
|
||||
/// <summary>
|
||||
/// 取文件名的MD5值(16位)
|
||||
/// </summary>
|
||||
/// <param name="str">文件名,不包括扩展名</param>
|
||||
/// <returns></returns>
|
||||
string HashFileName(string str = null);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
using Infrastructure;
|
||||
using System;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysLoginService : IBaseService<SysLogininfor>
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
/// <param name="loginBody"></param>
|
||||
/// <param name="logininfor"></param>
|
||||
/// <returns></returns>
|
||||
public SysUser Login(LoginBodyDto loginBody, SysLogininfor logininfor);
|
||||
|
||||
/// <summary>
|
||||
/// 查询操作日志
|
||||
/// </summary>
|
||||
/// <param name="logininfoDto"></param>
|
||||
/// <param name="pager">分页</param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysLogininfor> GetLoginLog(SysLogininfor logininfoDto, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 记录登录日志
|
||||
/// </summary>
|
||||
/// <param name="sysLogininfor"></param>
|
||||
/// <returns></returns>
|
||||
public void AddLoginInfo(SysLogininfor sysLogininfor);
|
||||
|
||||
/// <summary>
|
||||
/// 清空登录日志
|
||||
/// </summary>
|
||||
public void TruncateLogininfo();
|
||||
|
||||
/// <summary>
|
||||
/// 删除登录日志
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteLogininforByIds(long[] ids);
|
||||
|
||||
void CheckLockUser(string userName);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Vo;
|
||||
using ZR.Model.System.Generate;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysMenuService : IBaseService<SysMenu>
|
||||
{
|
||||
//List<SysMenu> SelectMenuList(long userId);
|
||||
|
||||
List<SysMenu> SelectMenuList(MenuQueryDto menu, long userId);
|
||||
List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId);
|
||||
|
||||
SysMenu GetMenuByMenuId(int menuId);
|
||||
List<SysMenu> GetMenusByMenuId(int menuId, long userId);
|
||||
long AddMenu(SysMenu menu);
|
||||
|
||||
long EditMenu(SysMenu menu);
|
||||
|
||||
int DeleteMenuById(int menuId);
|
||||
|
||||
string CheckMenuNameUnique(SysMenu menu);
|
||||
|
||||
int ChangeSortMenu(MenuDto menuDto);
|
||||
|
||||
bool HasChildByMenuId(long menuId);
|
||||
|
||||
List<SysMenu> SelectMenuTreeByUserId(long userId);
|
||||
|
||||
//List<SysMenu> SelectMenuPermsListByUserId(long userId);
|
||||
|
||||
List<string> SelectMenuPermsByUserId(long userId);
|
||||
|
||||
//bool CheckMenuExistRole(long menuId);
|
||||
|
||||
List<RouterVo> BuildMenus(List<SysMenu> menus);
|
||||
|
||||
List<TreeSelectVo> BuildMenuTreeSelect(List<SysMenu> menus);
|
||||
|
||||
void AddSysMenu(GenTable genTableInfo, string permPrefix, bool showEdit, bool showExport, bool showImport);
|
||||
List<SysMenu> SelectTreeMenuListByRoles(MenuQueryDto menu, List<long> roles);
|
||||
List<RoleMenuExportDto> SelectRoleMenuListByRole(MenuQueryDto menu, int roleId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色菜单
|
||||
/// </summary>
|
||||
public interface ISysRoleMenuService : IBaseService<SysRoleMenu>
|
||||
{
|
||||
bool CheckMenuExistRole(long menuId);
|
||||
/// <summary>
|
||||
/// 根据角色获取菜单id
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
List<SysRoleMenu> SelectRoleMenuByRoleId(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户所有角色获取菜单
|
||||
/// </summary>
|
||||
/// <param name="roleIds"></param>
|
||||
/// <returns></returns>
|
||||
List<SysRoleMenu> SelectRoleMenuByRoleIds(long[] roleIds);
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入用户菜单
|
||||
/// </summary>
|
||||
/// <param name="sysRoleMenus"></param>
|
||||
/// <returns></returns>
|
||||
int AddRoleMenu(List<SysRoleMenu> sysRoleMenus);
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色与菜单关联
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
int DeleteRoleMenuByRoleId(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色指定菜单
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="menuIds"></param>
|
||||
/// <returns></returns>
|
||||
bool DeleteRoleMenuByRoleIdMenuIds(long roleId, long[] menuIds);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
/// <summary>
|
||||
/// 通知公告表service接口
|
||||
///
|
||||
/// @author zr
|
||||
/// @date 2021-12-15
|
||||
/// </summary>
|
||||
public interface ISysNoticeService : IBaseService<SysNotice>
|
||||
{
|
||||
List<SysNotice> GetSysNotices();
|
||||
|
||||
PagedInfo<SysNotice> GetPageList(SysNoticeQueryDto parm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysOperLogService
|
||||
{
|
||||
public void InsertOperlog(SysOperLog operLog);
|
||||
|
||||
/// <summary>
|
||||
/// 查询系统操作日志集合
|
||||
/// </summary>
|
||||
/// <param name="operLog">操作日志对象</param>
|
||||
/// <returns>操作日志集合</returns>
|
||||
public PagedInfo<SysOperLog> SelectOperLogList(SysOperLogQueryDto operLog);
|
||||
|
||||
/// <summary>
|
||||
/// 清空操作日志
|
||||
/// </summary>
|
||||
public void CleanOperLog();
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除系统操作日志
|
||||
/// </summary>
|
||||
/// <param name="operIds">需要删除的操作日志ID</param>
|
||||
/// <returns>结果</returns>
|
||||
public int DeleteOperLogByIds(long[] operIds);
|
||||
|
||||
/// <summary>
|
||||
/// 查询操作日志详细
|
||||
/// </summary>
|
||||
/// <param name="operId">操作ID</param>
|
||||
/// <returns>操作日志对象</returns>
|
||||
public SysOperLog SelectOperLogById(long operId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysPermissionService
|
||||
{
|
||||
public List<string> GetRolePermission(SysUser user);
|
||||
public List<string> GetMenuPermission(SysUser user);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysPostService : IBaseService<SysPost>
|
||||
{
|
||||
string CheckPostNameUnique(SysPost sysPost);
|
||||
string CheckPostCodeUnique(SysPost sysPost);
|
||||
List<SysPost> GetAll();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,143 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysRoleService : IBaseService<SysRole>
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据条件分页查询角色数据
|
||||
/// </summary>
|
||||
/// <param name="role">角色信息</param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns>角色数据集合信息</returns>
|
||||
public PagedInfo<SysRole> SelectRoleList(SysRole role, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 查询所有角色
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<SysRole> SelectRoleAll();
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户查询
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysRole> SelectRolePermissionByUserId(long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 通过角色ID查询角色
|
||||
/// </summary>
|
||||
/// <param name="roleId">角色ID</param>
|
||||
/// <returns>角色对象信息</returns>
|
||||
public SysRole SelectRoleById(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除角色信息
|
||||
/// </summary>
|
||||
/// <param name="roleIds">需要删除的角色ID</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteRoleByRoleId(long[] roleIds);
|
||||
|
||||
/// <summary>
|
||||
/// 更改角色权限状态
|
||||
/// </summary>
|
||||
/// <param name="roleDto"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateRoleStatus(SysRole roleDto);
|
||||
|
||||
/// <summary>
|
||||
/// 校验角色权限是否唯一
|
||||
/// </summary>
|
||||
/// <param name="sysRole">角色信息</param>
|
||||
/// <returns></returns>
|
||||
public string CheckRoleKeyUnique(SysRole sysRole);
|
||||
|
||||
/// <summary>
|
||||
/// 校验角色是否允许操作
|
||||
/// </summary>
|
||||
/// <param name="role"></param>
|
||||
public void CheckRoleAllowed(SysRole role);
|
||||
|
||||
/// <summary>
|
||||
/// 新增保存角色信息
|
||||
/// </summary>
|
||||
/// <param name="sysRole">角色信息</param>
|
||||
/// <returns></returns>
|
||||
public long InsertRole(SysRole sysRole);
|
||||
|
||||
/// <summary>
|
||||
/// 通过角色ID删除角色和菜单关联
|
||||
/// </summary>
|
||||
/// <param name="roleId">角色ID</param>
|
||||
/// <returns></returns>
|
||||
public int DeleteRoleMenuByRoleId(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 授权数据范围
|
||||
/// </summary>
|
||||
/// <param name="role"></param>
|
||||
/// <returns></returns>
|
||||
bool AuthDataScope(SysRoleDto role);
|
||||
#region Service
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 新增角色菜单信息
|
||||
/// </summary>
|
||||
/// <param name="sysRoleDto"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertRoleMenu(SysRoleDto sysRoleDto);
|
||||
|
||||
/// <summary>
|
||||
/// 判断是否是管理员
|
||||
/// </summary>
|
||||
/// <param name="userid"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsAdmin(long userid);
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色菜单id集合
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public List<long> SelectUserRoleMenus(long roleId);
|
||||
List<long> SelectRoleMenuByRoleIds(long[] roleIds);
|
||||
/// <summary>
|
||||
/// 获取用户角色列表
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysRole> SelectUserRoleListByUserId(long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户权限集合
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<long> SelectUserRoles(long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户权限字符串集合
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> SelectUserRoleKeys(long userId);
|
||||
|
||||
public List<string> SelectUserRoleNames(long userId);
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 修改保存角色信息
|
||||
/// </summary>
|
||||
/// <param name="sysRole">角色信息</param>
|
||||
/// <returns></returns>
|
||||
public int UpdateRole(SysRole sysRole);
|
||||
|
||||
int UpdateSysRole(SysRole sysRole);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System.Threading.Tasks;
|
||||
using ZR.Model.System;
|
||||
using ZR.Repository;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysTasksLogService : IBaseService<SysTasksLog>
|
||||
{
|
||||
/// <summary>
|
||||
/// 记录任务执行日志
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
//public int AddTaskLog(string jobId);
|
||||
Task<SysTasksLog> AddTaskLog(string jobId, SysTasksLog tasksLog);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysTasksQzService : IBaseService<SysTasks>
|
||||
{
|
||||
PagedInfo<SysTasks> SelectTaskList(TasksQueryDto parm);
|
||||
//SysTasksQz GetId(object id);
|
||||
int AddTasks(SysTasks parm);
|
||||
int UpdateTasks(SysTasks parm);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysUserPostService
|
||||
{
|
||||
public void InsertUserPost(SysUser user);
|
||||
|
||||
public List<long> GetUserPostsByUserId(long userId);
|
||||
|
||||
public string GetPostsStrByUserId(long userId);
|
||||
bool Delete(long userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysUserRoleService : IBaseService<SysUserRole>
|
||||
{
|
||||
public int CountUserRoleByRoleId(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户角色
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteUserRoleByUserId(int userId);
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除角色对应用户
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <param name="userIds"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteRoleUserByUserIds(long roleId, List<long> userIds);
|
||||
|
||||
/// <summary>
|
||||
/// 添加用户角色
|
||||
/// </summary>
|
||||
/// <param name="sysUsers"></param>
|
||||
/// <returns></returns>
|
||||
public int AddUserRole(List<SysUserRole> sysUsers);
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户数据根据角色id
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysUser> GetSysUsersByRoleId(long roleId);
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户数据根据角色id
|
||||
/// </summary>
|
||||
/// <param name="roleUserQueryDto"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysUser> GetSysUsersByRoleId(RoleUserQueryDto roleUserQueryDto);
|
||||
|
||||
/// <summary>
|
||||
/// 获取尚未指派的用户数据根据角色id
|
||||
/// </summary>
|
||||
/// <param name="roleUserQueryDto"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysUser> GetExcludedSysUsersByRoleId(RoleUserQueryDto roleUserQueryDto);
|
||||
|
||||
/// <summary>
|
||||
/// 新增用户角色信息
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertUserRole(SysUser user);
|
||||
|
||||
/// <summary>
|
||||
/// 新增加角色用户
|
||||
/// </summary>
|
||||
/// <param name="roleUsersCreateDto"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertRoleUser(RoleUsersCreateDto roleUsersCreateDto);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
|
||||
namespace ZR.Service.System.IService
|
||||
{
|
||||
public interface ISysUserService : IBaseService<SysUser>
|
||||
{
|
||||
public PagedInfo<SysUser> SelectUserList(SysUserQueryDto user, PagerInfo pager);
|
||||
|
||||
/// <summary>
|
||||
/// 通过用户ID查询用户
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public SysUser SelectUserById(long userId);
|
||||
|
||||
/// <summary>
|
||||
/// 校验用户名称是否唯一
|
||||
/// </summary>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public string CheckUserNameUnique(string userName);
|
||||
|
||||
/// <summary>
|
||||
/// 新增保存用户信息
|
||||
/// </summary>
|
||||
/// <param name="sysUser"></param>
|
||||
/// <returns></returns>
|
||||
public SysUser InsertUser(SysUser sysUser);
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户信息
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateUser(SysUser user);
|
||||
|
||||
public int ChangeUser(SysUser user);
|
||||
|
||||
/// <summary>
|
||||
/// 重置密码
|
||||
/// </summary>
|
||||
/// <param name="userid"></param>
|
||||
/// <param name="password"></param>
|
||||
/// <returns></returns>
|
||||
public int ResetPwd(long userid, string password);
|
||||
|
||||
public int ChangeUserStatus(SysUser user);
|
||||
|
||||
/// <summary>
|
||||
/// 删除用户
|
||||
/// </summary>
|
||||
/// <param name="userid"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteUser(long userid);
|
||||
|
||||
/// <summary>
|
||||
/// 修改用户头像
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdatePhoto(SysUser user);
|
||||
|
||||
/// <summary>
|
||||
/// 注册
|
||||
/// </summary>
|
||||
/// <param name="dto"></param>
|
||||
/// <returns></returns>
|
||||
SysUser Register(RegisterDto dto);
|
||||
void CheckUserAllowed(SysUser user);
|
||||
void CheckUserDataScope(long userid, long loginUserId);
|
||||
|
||||
/// <summary>
|
||||
/// 导入
|
||||
/// </summary>
|
||||
/// <param name="users"></param>
|
||||
/// <returns></returns>
|
||||
(string, object, object) ImportUsers(List<SysUser> users);
|
||||
|
||||
SysUser Login(LoginBodyDto user);
|
||||
|
||||
void UpdateLoginInfo(LoginBodyDto user, long userId);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,294 @@
|
||||
using Infrastructure.Extensions;
|
||||
using MiniExcelLibs;
|
||||
using SqlSugar.IOC;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 种子数据处理
|
||||
/// </summary>
|
||||
public class SeedDataService
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化用户数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitUserData(List<SysUser> data)
|
||||
{
|
||||
data.ForEach(x =>
|
||||
{
|
||||
x.Password = "E10ADC3949BA59ABBE56E057F20F883E";
|
||||
});
|
||||
var db = DbScoped.SugarScope;
|
||||
db.Ado.BeginTran();
|
||||
//db.Ado.ExecuteCommand("SET IDENTITY_INSERT sys_user ON");
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.SplitError(x => x.Item.UserName.IsEmpty(), "用户名不能为空")
|
||||
.SplitError(x => !Tools.CheckUserName(x.Item.UserName), "用户名不符合规范")
|
||||
.WhereColumns(it => it.UserId)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.OffIdentity().ExecuteCommand();//插入可插入部分;
|
||||
//db.Ado.ExecuteCommand("SET IDENTITY_INSERT sys_user OFF");
|
||||
db.Ado.CommitTran();
|
||||
|
||||
string msg = $"[用户数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitMenuData(List<SysMenu> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.MenuId)//如果不是主键可以这样实现(多字段it=>new{it.x1,it.x2})
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.OffIdentity().ExecuteCommand();//插入可插入部分;
|
||||
|
||||
string msg = $"[菜单数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 角色菜单数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitRoleMenuData(List<SysRoleMenu> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => new { it.Menu_id, it.Role_id })
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();//插入可插入部分;
|
||||
|
||||
string msg = $"[角色菜单] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化部门数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitDeptData(List<SysDept> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.DeptId)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.OffIdentity().ExecuteCommand();
|
||||
|
||||
string msg = $"[部门数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
public (string, object, object) InitPostData(List<SysPost> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.PostCode)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[岗位数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
public (string, object, object) InitRoleData(List<SysRole> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.RoleKey)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.OffIdentity().ExecuteCommand();
|
||||
|
||||
string msg = $"[角色数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
public (string, object, object) InitUserRoleData(List<SysUserRole> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => new { it.RoleId, it.UserId })
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[用户角色] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 系统配置
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitConfigData(List<SysConfig> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.ConfigKey)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[系统配置] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitDictType(List<SysDictType> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.DictType)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[字典管理] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 字典数据
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitDictData(List<SysDictData> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => new { it.DictType, it.DictValue })
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[字典数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文章目录
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitArticleCategoryData(List<ArticleCategory> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.Name)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.OffIdentity().ExecuteCommand();
|
||||
|
||||
string msg = $"[字典数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 任务
|
||||
/// </summary>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public (string, object, object) InitTaskData(List<SysTasks> data)
|
||||
{
|
||||
var db = DbScoped.SugarScope;
|
||||
var x = db.Storageable(data)
|
||||
.SplitInsert(it => it.NotAny())
|
||||
.WhereColumns(it => it.Name)
|
||||
.ToStorage();
|
||||
var result = x.AsInsertable.ExecuteCommand();
|
||||
|
||||
string msg = $"[任务数据] 插入{x.InsertList.Count} 错误数据{x.ErrorList.Count} 总共{x.TotalList.Count}";
|
||||
return (msg, x.ErrorList, x.IgnoreList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 初始化种子数据
|
||||
/// </summary>
|
||||
/// <param name="path"></param>
|
||||
/// <param name="clean"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> InitSeedData(string path, bool clean)
|
||||
{
|
||||
List<string> result = new();
|
||||
|
||||
var db = DbScoped.SugarScope;
|
||||
if (clean)
|
||||
{
|
||||
db.DbMaintenance.TruncateTable<SysRoleDept>();
|
||||
db.DbMaintenance.TruncateTable<SysRoleMenu>();
|
||||
db.DbMaintenance.TruncateTable<SysMenu>();
|
||||
db.DbMaintenance.TruncateTable<SysRole>();
|
||||
db.DbMaintenance.TruncateTable<SysUser>();
|
||||
db.DbMaintenance.TruncateTable<SysDept>();
|
||||
db.DbMaintenance.TruncateTable<SysPost>();
|
||||
}
|
||||
|
||||
var sysUser = MiniExcel.Query<SysUser>(path, sheetName: "user").ToList();
|
||||
var result1 = InitUserData(sysUser);
|
||||
result.Add(result1.Item1);
|
||||
|
||||
var sysPost = MiniExcel.Query<SysPost>(path, sheetName: "post").ToList();
|
||||
var result2 = InitPostData(sysPost);
|
||||
result.Add(result2.Item1);
|
||||
|
||||
var sysRole = MiniExcel.Query<SysRole>(path, sheetName: "role").ToList();
|
||||
var result3 = InitRoleData(sysRole);
|
||||
result.Add(result3.Item1);
|
||||
|
||||
var sysUserRole = MiniExcel.Query<SysUserRole>(path, sheetName: "user_role").ToList();
|
||||
var result4 = InitUserRoleData(sysUserRole);
|
||||
result.Add(result4.Item1);
|
||||
|
||||
var sysMenu = MiniExcel.Query<SysMenu>(path, sheetName: "menu").ToList();
|
||||
var result5 = InitMenuData(sysMenu);
|
||||
result.Add(result5.Item1);
|
||||
|
||||
var sysConfig = MiniExcel.Query<SysConfig>(path, sheetName: "config").ToList();
|
||||
var result6 = InitConfigData(sysConfig);
|
||||
result.Add(result6.Item1);
|
||||
|
||||
var sysRoleMenu = MiniExcel.Query<SysRoleMenu>(path, sheetName: "role_menu").ToList();
|
||||
var result7 = InitRoleMenuData(sysRoleMenu);
|
||||
result.Add(result7.Item1);
|
||||
|
||||
var sysDict = MiniExcel.Query<SysDictType>(path, sheetName: "dict_type").ToList();
|
||||
var result8 = InitDictType(sysDict);
|
||||
result.Add(result8.Item1);
|
||||
|
||||
var sysDictData = MiniExcel.Query<SysDictData>(path, sheetName: "dict_data").ToList();
|
||||
var result9 = InitDictData(sysDictData);
|
||||
result.Add(result9.Item1);
|
||||
|
||||
var sysDept = MiniExcel.Query<SysDept>(path, sheetName: "dept").ToList();
|
||||
var result10 = InitDeptData(sysDept);
|
||||
result.Add(result10.Item1);
|
||||
|
||||
var sysArticleCategory = MiniExcel.Query<ArticleCategory>(path, sheetName: "article_category").ToList();
|
||||
var result11 = InitArticleCategoryData(sysArticleCategory);
|
||||
result.Add(result11.Item1);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 数据差异日志Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISqlDiffLogService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SqlDiffLogService : BaseService<SqlDiffLog>, ISqlDiffLogService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询数据差异日志列表
|
||||
/// </summary>
|
||||
/// <param name="parm"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SqlDiffLogDto> GetList(SqlDiffLogQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<SqlDiffLog>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.TableName), it => it.TableName == parm.TableName);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.DiffType), it => it.DiffType == parm.DiffType);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.UserName), it => it.UserName == parm.UserName);
|
||||
predicate = predicate.AndIF(parm.BeginAddTime == null, it => it.AddTime >= DateTime.Now.ToShortDateString().ParseToDateTime());
|
||||
predicate = predicate.AndIF(parm.BeginAddTime != null, it => it.AddTime >= parm.BeginAddTime);
|
||||
predicate = predicate.AndIF(parm.EndAddTime != null, it => it.AddTime <= parm.EndAddTime);
|
||||
var response = Queryable()
|
||||
//.OrderBy("PId desc")
|
||||
.Where(predicate.ToExpression())
|
||||
.ToPage<SqlDiffLog, SqlDiffLogDto>(parm);
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="PId"></param>
|
||||
/// <returns></returns>
|
||||
public SqlDiffLog GetInfo(long PId)
|
||||
{
|
||||
var response = Queryable()
|
||||
.Where(x => x.PId == PId)
|
||||
.First();
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加数据差异日志
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public SqlDiffLog AddSqlDiffLog(SqlDiffLog model)
|
||||
{
|
||||
return Context.Insertable(model).ExecuteReturnEntity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改数据差异日志
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateSqlDiffLog(SqlDiffLog model)
|
||||
{
|
||||
//var response = Update(w => w.PId == model.PId, it => new SqlDiffLog()
|
||||
//{
|
||||
// TableName = model.TableName,
|
||||
// BusinessData = model.BusinessData,
|
||||
// DiffType = model.DiffType,
|
||||
// Sql = model.Sql,
|
||||
// BeforeData = model.BeforeData,
|
||||
// AfterData = model.AfterData,
|
||||
// UserName = model.UserName,
|
||||
// AddTime = model.AddTime,
|
||||
// ConfigId = model.ConfigId,
|
||||
//});
|
||||
//return response;
|
||||
return Update(model, true);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Infrastructure.Attribute;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 参数配置Service业务层处理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysConfigService : BaseService<SysConfig>, ISysConfigService
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
|
||||
public SysConfig GetSysConfigByKey(string key)
|
||||
{
|
||||
return Queryable().First(f => f.ConfigKey == key);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,297 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Vo;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 部门管理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDeptService : BaseService<SysDept>, ISysDeptService
|
||||
{
|
||||
public ISysRoleDeptService RoleDeptRepository;
|
||||
public SysDeptService(ISysRoleDeptService roleDeptRepository)
|
||||
{
|
||||
RoleDeptRepository = roleDeptRepository;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询部门管理数据
|
||||
/// </summary>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDept> GetSysDepts(SysDeptQueryDto dept)
|
||||
{
|
||||
var predicate = Expressionable.Create<SysDept>();
|
||||
predicate = predicate.And(it => it.DelFlag == 0);
|
||||
predicate = predicate.AndIF(dept.DeptName.IfNotEmpty(), it => it.DeptName.Contains(dept.DeptName));
|
||||
predicate = predicate.AndIF(dept.Status != null, it => it.Status == dept.Status);
|
||||
|
||||
var response = GetList(predicate.ToExpression());
|
||||
|
||||
return response;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验部门名称是否唯一
|
||||
/// </summary>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
public string CheckDeptNameUnique(SysDept dept)
|
||||
{
|
||||
long deptId = dept.DeptId == 0 ? -1L : dept.DeptId;
|
||||
SysDept info = GetFirst(it => it.DeptName == dept.DeptName && it.ParentId == dept.ParentId);
|
||||
if (info != null && info.DeptId != deptId)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 新增保存部门信息
|
||||
/// </summary>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertDept(SysDept dept)
|
||||
{
|
||||
SysDept info = GetFirst(it => it.DeptId == dept.ParentId);
|
||||
//如果父节点不为正常状态,则不允许新增子节点
|
||||
if (info != null && UserConstants.DEPT_NORMAL != info?.Status)
|
||||
{
|
||||
throw new CustomException("部门停用,不允许新增");
|
||||
}
|
||||
dept.Ancestors = "";
|
||||
if (info != null)
|
||||
{
|
||||
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
|
||||
}
|
||||
return Add(dept);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改保存部门信息
|
||||
/// </summary>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDept(SysDept dept)
|
||||
{
|
||||
SysDept newParentDept = GetFirst(it => it.DeptId == dept.ParentId);
|
||||
SysDept oldDept = GetFirst(m => m.DeptId == dept.DeptId);
|
||||
if (newParentDept != null && oldDept != null)
|
||||
{
|
||||
string newAncestors = newParentDept.Ancestors + "," + newParentDept.DeptId;
|
||||
string oldAncestors = oldDept.Ancestors;
|
||||
dept.Ancestors = newAncestors;
|
||||
UpdateDeptChildren(dept.DeptId, newAncestors, oldAncestors);
|
||||
}
|
||||
int result = Context.Updateable(dept).ExecuteCommand();
|
||||
if (UserConstants.DEPT_NORMAL.Equals(dept.Status) && dept.Ancestors.IfNotEmpty()
|
||||
&& !"0".Equals(dept.Ancestors))
|
||||
{
|
||||
// 如果该部门是启用状态,则启用该部门的所有上级部门
|
||||
UpdateParentDeptStatusNormal(dept);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改该部门的父级部门状态
|
||||
/// </summary>
|
||||
/// <param name="dept">当前部门</param>
|
||||
private void UpdateParentDeptStatusNormal(SysDept dept)
|
||||
{
|
||||
long[] depts = Tools.SpitLongArrary(dept.Ancestors);
|
||||
dept.Status = 0;
|
||||
dept.Update_time = DateTime.Now;
|
||||
|
||||
Update(dept, it => new { it.Update_by, it.Update_time, it.Status }, f => depts.Contains(f.DeptId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改子元素关系
|
||||
/// </summary>
|
||||
/// <param name="deptId">被修改的部门ID</param>
|
||||
/// <param name="newAncestors">新的父ID集合</param>
|
||||
/// <param name="oldAncestors">旧的父ID集合</param>
|
||||
public void UpdateDeptChildren(long deptId, string newAncestors, string oldAncestors)
|
||||
{
|
||||
List<SysDept> children = GetChildrenDepts(GetSysDepts(new SysDeptQueryDto()), deptId);
|
||||
|
||||
foreach (var child in children)
|
||||
{
|
||||
string ancestors = child.Ancestors.ReplaceFirst(oldAncestors, newAncestors);
|
||||
long[] ancestorsArr = Tools.SpitLongArrary(ancestors).Distinct().ToArray();
|
||||
child.Ancestors = string.Join(",", ancestorsArr);
|
||||
}
|
||||
if (children.Any())
|
||||
{
|
||||
Context.Updateable(children).WhereColumns(f => new { f.DeptId })
|
||||
.UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有子部门
|
||||
/// </summary>
|
||||
/// <param name="depts"></param>
|
||||
/// <param name="deptId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDept> GetChildrenDepts(List<SysDept> depts, long deptId)
|
||||
{
|
||||
return depts.FindAll(delegate (SysDept item)
|
||||
{
|
||||
long[] pid = Tools.SpitLongArrary(item.Ancestors);
|
||||
return pid.Contains(deptId);
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建前端所需要树结构
|
||||
/// </summary>
|
||||
/// <param name="depts">部门列表</param>
|
||||
/// <returns></returns>
|
||||
public List<SysDept> BuildDeptTree(List<SysDept> depts)
|
||||
{
|
||||
List<SysDept> returnList = new List<SysDept>();
|
||||
List<long> tempList = depts.Select(f => f.DeptId).ToList();
|
||||
foreach (var dept in depts)
|
||||
{
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.Contains(dept.ParentId))
|
||||
{
|
||||
RecursionFn(depts, dept);
|
||||
returnList.Add(dept);
|
||||
}
|
||||
}
|
||||
|
||||
if (!returnList.Any())
|
||||
{
|
||||
returnList = depts;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建前端所需下拉树结构
|
||||
/// </summary>
|
||||
/// <param name="depts"></param>
|
||||
/// <returns></returns>
|
||||
public List<TreeSelectVo> BuildDeptTreeSelect(List<SysDept> depts)
|
||||
{
|
||||
List<SysDept> menuTrees = BuildDeptTree(depts);
|
||||
List<TreeSelectVo> treeMenuVos = new List<TreeSelectVo>();
|
||||
foreach (var item in menuTrees)
|
||||
{
|
||||
treeMenuVos.Add(new TreeSelectVo(item));
|
||||
}
|
||||
return treeMenuVos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归列表
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="t"></param>
|
||||
private void RecursionFn(List<SysDept> list, SysDept t)
|
||||
{
|
||||
//得到子节点列表
|
||||
List<SysDept> childList = GetChildList(list, t);
|
||||
t.children = childList;
|
||||
foreach (var item in childList)
|
||||
{
|
||||
if (GetChildList(list, item).Count() > 0)
|
||||
{
|
||||
RecursionFn(list, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 递归获取子菜单
|
||||
/// </summary>
|
||||
/// <param name="list">所有菜单</param>
|
||||
/// <param name="dept"></param>
|
||||
/// <returns></returns>
|
||||
private List<SysDept> GetChildList(List<SysDept> list, SysDept dept)
|
||||
{
|
||||
return list.Where(p => p.ParentId == dept.DeptId).ToList();
|
||||
}
|
||||
|
||||
#region 角色部门
|
||||
|
||||
/// <summary>
|
||||
/// 根据角色获取菜单id
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysRoleDept> SelectRoleDeptByRoleId(long roleId)
|
||||
{
|
||||
return RoleDeptRepository.SelectRoleDeptByRoleId(roleId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取角色部门id集合
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public List<long> SelectRoleDepts(long roleId)
|
||||
{
|
||||
var list = SelectRoleDeptByRoleId(roleId);
|
||||
|
||||
return list.Select(x => x.DeptId).Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除角色部门数据
|
||||
/// </summary>
|
||||
/// <param name="roleId"></param>
|
||||
/// <returns></returns>
|
||||
public bool DeleteRoleDeptByRoleId(long roleId)
|
||||
{
|
||||
return RoleDeptRepository.Delete(f => f.RoleId == roleId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量插入角色部门
|
||||
/// </summary>
|
||||
/// <param name="role"></param>
|
||||
/// <returns></returns>
|
||||
public int InsertRoleDepts(SysRole role)
|
||||
{
|
||||
int rows = 1;
|
||||
List<SysRoleDept> list = new();
|
||||
foreach (var item in role.DeptIds)
|
||||
{
|
||||
list.Add(new SysRoleDept() { DeptId = item, RoleId = role.RoleId });
|
||||
}
|
||||
if (list.Count > 0)
|
||||
{
|
||||
rows = RoleDeptRepository.Insert(list);
|
||||
}
|
||||
return rows;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 角色部门
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysRoleDeptService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysRoleDeptService : BaseService<SysRoleDept>, ISysRoleDeptService
|
||||
{
|
||||
public List<SysRoleDept> SelectRoleDeptByRoleId(long roleId)
|
||||
{
|
||||
return GetList(it => it.RoleId == roleId).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,148 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Common;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典数据类
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDictDataService : BaseService<SysDictData>, ISysDictDataService
|
||||
{
|
||||
/// <summary>
|
||||
/// 查询字典数据
|
||||
/// </summary>
|
||||
/// <param name="dictData"></param>
|
||||
/// <param name="pagerInfo"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysDictData> SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
|
||||
{
|
||||
//return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
|
||||
var exp = Expressionable.Create<SysDictData>();
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel));
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status);
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType);
|
||||
return GetPages(exp.ToExpression(), pagerInfo);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类型查询
|
||||
/// </summary>
|
||||
/// <param name="dictType"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataByType(string dictType)
|
||||
{
|
||||
string CK = $"SelectDictDataByType_{dictType}";
|
||||
|
||||
var list = Queryable()
|
||||
.WithCache(CK, 60 * 10)
|
||||
.Where(f => f.Status == "0" && f.DictType == dictType)
|
||||
.OrderBy(it => it.DictSort)
|
||||
.ToList();
|
||||
|
||||
return list;
|
||||
}
|
||||
public List<SysDictData> SelectDictDataByTypes(string[] dictTypes)
|
||||
{
|
||||
string CK = $"SelectDictDataByTypes_{dictTypes}";
|
||||
|
||||
var list = Queryable()
|
||||
.WithCache(CK, 60 * 30)
|
||||
.Where(f => f.Status == "0" && dictTypes.Contains(f.DictType))
|
||||
.OrderBy(it => it.DictSort)
|
||||
.ToList();
|
||||
|
||||
return list;
|
||||
}
|
||||
/// <summary>
|
||||
/// 根据字典数据ID查询信息
|
||||
/// </summary>
|
||||
/// <param name="dictCode"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictData SelectDictDataById(long dictCode)
|
||||
{
|
||||
string CK = $"SelectDictDataByCode_{dictCode}";
|
||||
if (CacheHelper.GetCache(CK) is not SysDictData list)
|
||||
{
|
||||
list = GetFirst(f => f.DictCode == dictCode);
|
||||
CacheHelper.SetCache(CK, list, 5);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入数据
|
||||
/// </summary>
|
||||
/// <param name="dict"></param>
|
||||
/// <returns></returns>
|
||||
public long InsertDictData(SysDictData dict)
|
||||
{
|
||||
return Insertable(dict).ExecuteReturnBigIdentity();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改数据
|
||||
/// </summary>
|
||||
/// <param name="dict"></param>
|
||||
/// <returns></returns>
|
||||
public long UpdateDictData(SysDictData dict)
|
||||
{
|
||||
var result = Update(w => w.DictCode == dict.DictCode, it => new SysDictData()
|
||||
{
|
||||
Remark = dict.Remark,
|
||||
Update_time = DateTime.Now,
|
||||
DictSort = dict.DictSort,
|
||||
DictLabel = dict.DictLabel,
|
||||
DictValue = dict.DictValue,
|
||||
Status = dict.Status,
|
||||
CssClass = dict.CssClass,
|
||||
ListClass = dict.ListClass
|
||||
});
|
||||
|
||||
CacheHelper.Remove($"SelectDictDataByCode_{dict.DictCode}");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典数据信息
|
||||
/// </summary>
|
||||
/// <param name="dictCodes"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictDataByIds(long[] dictCodes)
|
||||
{
|
||||
return Delete(dictCodes);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 同步修改字典类型
|
||||
/// </summary>
|
||||
/// <param name="old_dictType">旧字典类型</param>
|
||||
/// <param name="new_dictType">新字典类型</param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDictDataType(string old_dictType, string new_dictType)
|
||||
{
|
||||
//只更新DictType字段根据where条件
|
||||
return Context.Updateable<SysDictData>()
|
||||
.SetColumns(t => new SysDictData() { DictType = new_dictType })
|
||||
.Where(f => f.DictType == old_dictType)
|
||||
.ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类型查询自定义sql
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataByCustomSql(SysDictType sysDictType)
|
||||
{
|
||||
return Context.Ado.SqlQuery<SysDictData>(sysDictType?.CustomSql).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,139 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 字典类型
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysDictService : BaseService<SysDictType>, ISysDictService
|
||||
{
|
||||
private ISysDictDataService DictDataService;
|
||||
|
||||
public SysDictService(ISysDictDataService dictDataRepository)
|
||||
{
|
||||
this.DictDataService = dictDataRepository;
|
||||
}
|
||||
public List<SysDictType> GetAll()
|
||||
{
|
||||
return Queryable().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询字段类型列表
|
||||
/// </summary>
|
||||
/// <param name="dictType">实体模型</param>
|
||||
/// <param name="pager"></param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysDictType> SelectDictTypeList(SysDictType dictType, PagerInfo pager)
|
||||
{
|
||||
var exp = Expressionable.Create<SysDictType>();
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName));
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status);
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType.Contains(dictType.DictType));
|
||||
exp.AndIF(!string.IsNullOrEmpty(dictType.Type), it => it.Type.Equals(dictType.Type));
|
||||
|
||||
return GetPages(exp.ToExpression(), pager, f => f.DictId, OrderByType.Desc);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验字典类型称是否唯一
|
||||
/// </summary>
|
||||
/// <param name="dictType">字典类型</param>
|
||||
/// <returns></returns>
|
||||
public string CheckDictTypeUnique(SysDictType dictType)
|
||||
{
|
||||
SysDictType sysDictType = GetFirst(f => f.DictType == dictType.DictType);
|
||||
if (sysDictType != null && sysDictType.DictId != dictType.DictId)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量删除字典数据信息
|
||||
/// </summary>
|
||||
/// <param name="dictIds"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteDictTypeByIds(long[] dictIds)
|
||||
{
|
||||
int sysCount = Count(s => s.Type == "Y" && dictIds.Contains(s.DictId));
|
||||
if (sysCount > 0) { throw new CustomException($"删除失败Id: 系统内置参数不能删除!"); }
|
||||
foreach (var dictId in dictIds)
|
||||
{
|
||||
SysDictType dictType = GetFirst(x => x.DictId == dictId);
|
||||
if (DictDataService.Count(f => f.DictType == dictType.DictType) > 0)
|
||||
{
|
||||
throw new CustomException($"{dictType.DictName}已分配,不能删除");
|
||||
}
|
||||
}
|
||||
int count = Context.Deleteable<SysDictType>().In(dictIds).ExecuteCommand();
|
||||
//if (count > 0)
|
||||
//{
|
||||
// DictUtils.clearDictCache();
|
||||
//}
|
||||
return count;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 插入字典类型
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public long InsertDictType(SysDictType sysDictType)
|
||||
{
|
||||
return InsertReturnBigIdentity(sysDictType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改字典类型
|
||||
/// </summary>
|
||||
/// <param name="sysDictType"></param>
|
||||
/// <returns></returns>
|
||||
public int UpdateDictType(SysDictType sysDictType)
|
||||
{
|
||||
SysDictType oldDict = GetFirst(x => x.DictId == sysDictType.DictId);
|
||||
if (sysDictType.DictType != oldDict.DictType)
|
||||
{
|
||||
//同步修改 dict_data表里面的DictType值
|
||||
DictDataService.UpdateDictDataType(oldDict.DictType, sysDictType.DictType);
|
||||
}
|
||||
return Context.Updateable(sysDictType).IgnoreColumns(it => new { sysDictType.Create_by }).ExecuteCommand();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取字典信息
|
||||
/// </summary>
|
||||
/// <param name="dictId"></param>
|
||||
/// <returns></returns>
|
||||
public SysDictType GetInfo(long dictId)
|
||||
{
|
||||
return GetFirst(f => f.DictId == dictId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据字典类型查询自定义sql
|
||||
/// </summary>
|
||||
/// <param name="dictType"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysDictData> SelectDictDataByCustomSql(string dictType)
|
||||
{
|
||||
var dictInfo = Queryable()
|
||||
.Where(f => f.DictType == dictType).First();
|
||||
if (dictInfo == null || !dictInfo.CustomSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return DictDataService.SelectDictDataByCustomSql(dictInfo);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Enums;
|
||||
using Infrastructure.Model;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Options;
|
||||
using System.Net;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 文件管理
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysFileService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysFileService : BaseService<SysFile>, ISysFileService
|
||||
{
|
||||
private string domainUrl = AppSettings.GetConfig("ALIYUN_OSS:domainUrl");
|
||||
private readonly ISysConfigService SysConfigService;
|
||||
private OptionsSetting OptionsSetting;
|
||||
public SysFileService(ISysConfigService sysConfigService, IOptions<OptionsSetting> options)
|
||||
{
|
||||
SysConfigService = sysConfigService;
|
||||
OptionsSetting = options.Value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 存储本地
|
||||
/// </summary>
|
||||
/// <param name="fileDir">存储文件夹</param>
|
||||
/// <param name="rootPath">存储根目录</param>
|
||||
/// <param name="fileName">自定文件名</param>
|
||||
/// <param name="formFile">上传的文件流</param>
|
||||
/// <param name="userName"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SysFile> SaveFileToLocal(string rootPath, string fileName, string fileDir, string userName, IFormFile formFile)
|
||||
{
|
||||
string fileExt = Path.GetExtension(formFile.FileName);
|
||||
fileName = (fileName.IsEmpty() ? HashFileName() : fileName) + fileExt;
|
||||
|
||||
string filePath = GetdirPath(fileDir);
|
||||
string finalFilePath = Path.Combine(rootPath, filePath, fileName);
|
||||
double fileSize = Math.Round(formFile.Length / 1024.0, 2);
|
||||
|
||||
if (!Directory.Exists(Path.GetDirectoryName(finalFilePath)))
|
||||
{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(finalFilePath));
|
||||
}
|
||||
|
||||
using (var stream = new FileStream(finalFilePath, FileMode.Create))
|
||||
{
|
||||
await formFile.CopyToAsync(stream);
|
||||
}
|
||||
string uploadUrl = OptionsSetting.Upload.UploadUrl;
|
||||
string accessPath = string.Concat(uploadUrl, "/", filePath.Replace("\\", "/"), "/", fileName);
|
||||
SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", filePath, userName)
|
||||
{
|
||||
StoreType = (int)StoreType.LOCAL,
|
||||
FileType = formFile.ContentType,
|
||||
FileUrl = finalFilePath.Replace("\\", "/"),
|
||||
AccessUrl = accessPath
|
||||
};
|
||||
file.Id = await InsertFile(file);
|
||||
return file;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 上传文件到阿里云
|
||||
/// </summary>
|
||||
/// <param name="file"></param>
|
||||
/// <param name="formFile"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<SysFile> SaveFileToAliyun(SysFile file, IFormFile formFile)
|
||||
{
|
||||
file.FileName = (file.FileName.IsEmpty() ? HashFileName() : file.FileName) + file.FileExt;
|
||||
file.StorePath = GetdirPath(file.StorePath);
|
||||
string finalPath = Path.Combine(file.StorePath, file.FileName);
|
||||
HttpStatusCode statusCode = AliyunOssHelper.PutObjectFromFile(formFile.OpenReadStream(), finalPath, "");
|
||||
if (statusCode != HttpStatusCode.OK) return file;
|
||||
|
||||
file.StorePath = file.StorePath;
|
||||
file.FileUrl = finalPath;
|
||||
file.AccessUrl = string.Concat(domainUrl, "/", file.StorePath.Replace("\\", "/"), "/", file.FileName);
|
||||
file.Id = await InsertFile(file);
|
||||
|
||||
return file;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取文件存储目录
|
||||
/// </summary>
|
||||
/// <param name="storePath"></param>
|
||||
/// <param name="byTimeStore">是否按年月日存储</param>
|
||||
/// <returns></returns>
|
||||
public string GetdirPath(string storePath = "", bool byTimeStore = true)
|
||||
{
|
||||
DateTime date = DateTime.Now;
|
||||
string timeDir = date.ToString("yyyy/MMdd");
|
||||
|
||||
if (!string.IsNullOrEmpty(storePath))
|
||||
{
|
||||
timeDir = Path.Combine(storePath, timeDir);
|
||||
}
|
||||
return timeDir;
|
||||
}
|
||||
|
||||
public string HashFileName(string str = null)
|
||||
{
|
||||
if (string.IsNullOrEmpty(str))
|
||||
{
|
||||
str = Guid.NewGuid().ToString();
|
||||
}
|
||||
return BitConverter.ToString(MD5.HashData(Encoding.Default.GetBytes(str)), 4, 8).Replace("-", "");
|
||||
}
|
||||
|
||||
public Task<long> InsertFile(SysFile file)
|
||||
{
|
||||
try
|
||||
{
|
||||
return Insertable(file).ExecuteReturnSnowflakeIdAsync();//单条插入返回雪花ID;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("存储图片失败" + ex.Message);
|
||||
throw new Exception(ex.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
using Infrastructure;
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using UAParser;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Repository;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 登录
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysLoginService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysLoginService : BaseService<SysLogininfor>, ISysLoginService
|
||||
{
|
||||
private readonly ISysUserService SysUserService;
|
||||
private readonly IHttpContextAccessor httpContextAccessor;
|
||||
|
||||
public SysLoginService(ISysUserService sysUserService, IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
SysUserService = sysUserService;
|
||||
this.httpContextAccessor = httpContextAccessor;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 登录验证
|
||||
/// </summary>
|
||||
/// <param name="logininfor"></param>
|
||||
/// <param name="loginBody"></param>
|
||||
/// <returns></returns>
|
||||
public SysUser Login(LoginBodyDto loginBody, SysLogininfor logininfor)
|
||||
{
|
||||
if (loginBody.Password.Length != 32)
|
||||
{
|
||||
loginBody.Password = NETCore.Encrypt.EncryptProvider.Md5(loginBody.Password);
|
||||
}
|
||||
SysUser user = SysUserService.Login(loginBody);
|
||||
logininfor.UserName = loginBody.Username;
|
||||
logininfor.Status = "1";
|
||||
logininfor.LoginTime = DateTime.Now;
|
||||
logininfor.Ipaddr = loginBody.LoginIP;
|
||||
|
||||
ClientInfo clientInfo = httpContextAccessor.HttpContext.GetClientInfo();
|
||||
logininfor.Browser = clientInfo.ToString();
|
||||
logininfor.Os = clientInfo.OS.ToString();
|
||||
|
||||
if (user == null || user.UserId <= 0)
|
||||
{
|
||||
logininfor.Msg = "用户名或密码错误";
|
||||
AddLoginInfo(logininfor);
|
||||
throw new CustomException(ResultCode.LOGIN_ERROR, logininfor.Msg);
|
||||
}
|
||||
if (user.Status == 1)
|
||||
{
|
||||
logininfor.Msg = "该用户已禁用";
|
||||
AddLoginInfo(logininfor);
|
||||
throw new CustomException(ResultCode.LOGIN_ERROR, logininfor.Msg);
|
||||
}
|
||||
|
||||
logininfor.Status = "0";
|
||||
logininfor.Msg = "登录成功";
|
||||
AddLoginInfo(logininfor);
|
||||
SysUserService.UpdateLoginInfo(loginBody, user.UserId);
|
||||
return user;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询登录日志
|
||||
/// </summary>
|
||||
/// <param name="logininfoDto"></param>
|
||||
/// <param name="pager">分页</param>
|
||||
/// <returns></returns>
|
||||
public PagedInfo<SysLogininfor> GetLoginLog(SysLogininfor logininfoDto, PagerInfo pager)
|
||||
{
|
||||
//logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
|
||||
//logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
|
||||
|
||||
var exp = Expressionable.Create<SysLogininfor>();
|
||||
|
||||
exp.AndIF(logininfoDto.BeginTime == null, it => it.LoginTime >= DateTime.Now.ToShortDateString().ParseToDateTime());
|
||||
exp.AndIF(logininfoDto.BeginTime != null, it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
|
||||
exp.AndIF(logininfoDto.Ipaddr.IfNotEmpty(), f => f.Ipaddr == logininfoDto.Ipaddr);
|
||||
exp.AndIF(logininfoDto.UserName.IfNotEmpty(), f => f.UserName.Contains(logininfoDto.UserName));
|
||||
exp.AndIF(logininfoDto.Status.IfNotEmpty(), f => f.Status == logininfoDto.Status);
|
||||
var query = Queryable().Where(exp.ToExpression())
|
||||
.OrderBy(it => it.InfoId, OrderByType.Desc);
|
||||
|
||||
return query.ToPage(pager);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 记录登录日志
|
||||
/// </summary>
|
||||
/// <param name="sysLogininfor"></param>
|
||||
/// <returns></returns>
|
||||
public void AddLoginInfo(SysLogininfor sysLogininfor)
|
||||
{
|
||||
Insert(sysLogininfor);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 清空登录日志
|
||||
/// </summary>
|
||||
public void TruncateLogininfo()
|
||||
{
|
||||
Truncate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除登录日志
|
||||
/// </summary>
|
||||
/// <param name="ids"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteLogininforByIds(long[] ids)
|
||||
{
|
||||
return Delete(ids);
|
||||
}
|
||||
|
||||
public void CheckLockUser(string userName)
|
||||
{
|
||||
var lockTimeStamp = CacheService.GetLockUser(userName);
|
||||
var lockTime = DateTimeHelper.ToLocalTimeDateBySeconds(lockTimeStamp);
|
||||
var ts = lockTime - DateTime.Now;
|
||||
|
||||
if (lockTimeStamp > 0 && ts.TotalSeconds > 0)
|
||||
{
|
||||
throw new CustomException(ResultCode.LOGIN_ERROR, $"你的账号已被锁,剩余{Math.Round(ts.TotalMinutes, 0)}分钟");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,712 @@
|
||||
using Infrastructure.Attribute;
|
||||
using Infrastructure.Extensions;
|
||||
using SqlSugar;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ZR.Common;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Model.System.Enums;
|
||||
using ZR.Model.System.Generate;
|
||||
using ZR.Model.System.Vo;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service
|
||||
{
|
||||
/// <summary>
|
||||
/// 菜单
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysMenuService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysMenuService : BaseService<SysMenu>, ISysMenuService
|
||||
{
|
||||
public ISysRoleService SysRoleService;
|
||||
|
||||
public SysMenuService(ISysRoleService sysRoleService)
|
||||
{
|
||||
SysRoleService = sysRoleService;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有菜单数(菜单管理)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> SelectTreeMenuList(MenuQueryDto menu, long userId)
|
||||
{
|
||||
if (menu.ParentId != null)
|
||||
{
|
||||
return GetMenusByMenuId(menu.ParentId.ParseToInt(), userId);
|
||||
}
|
||||
List<SysMenu> menuList = BuildMenuTree(SelectMenuList(menu, userId));
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有菜单列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> SelectMenuList(MenuQueryDto menu, long userId)
|
||||
{
|
||||
List<SysMenu> menuList;
|
||||
if (SysRoleService.IsAdmin(userId))
|
||||
{
|
||||
menuList = SelectMenuList(menu);
|
||||
}
|
||||
else
|
||||
{
|
||||
var userRoles = SysRoleService.SelectUserRoles(userId);
|
||||
menuList = SelectMenuListByRoles(menu, userRoles);
|
||||
}
|
||||
return menuList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取菜单详情
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public SysMenu GetMenuByMenuId(int menuId)
|
||||
{
|
||||
return GetFirst(it => it.MenuId == menuId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据菜单id获取菜单列表
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> GetMenusByMenuId(int menuId, long userId)
|
||||
{
|
||||
var menuExpression = Expressionable.Create<SysMenu>();
|
||||
menuExpression.And(c => c.ParentId == menuId);
|
||||
|
||||
if (!SysRoleService.IsAdmin(userId))
|
||||
{
|
||||
var userRoles = SysRoleService.SelectUserRoles(userId);
|
||||
var roleMenus = Context.Queryable<SysRoleMenu>()
|
||||
.Where(r => userRoles.Contains(r.Role_id)).Select(s => s.Menu_id).ToList();
|
||||
|
||||
menuExpression.And(c => roleMenus.Contains(c.MenuId));
|
||||
}
|
||||
var list = GetList(menuExpression.ToExpression()).OrderBy(f => f.OrderNum).ToList();
|
||||
Context.ThenMapper(list, item =>
|
||||
{
|
||||
item.SubNum = Context.Queryable<SysMenu>().SetContext(x => x.ParentId, () => item.MenuId, item).Count;
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加菜单
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
public long AddMenu(SysMenu menu)
|
||||
{
|
||||
menu.Create_time = DateTime.Now;
|
||||
return InsertReturnBigIdentity(menu);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑菜单
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
public long EditMenu(SysMenu menu)
|
||||
{
|
||||
menu.Icon = string.IsNullOrEmpty(menu.Icon) ? "" : menu.Icon;
|
||||
return Update(menu, false);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除菜单管理信息
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public int DeleteMenuById(int menuId)
|
||||
{
|
||||
return Delete(menuId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 校验菜单名称是否唯一
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
public string CheckMenuNameUnique(SysMenu menu)
|
||||
{
|
||||
long menuId = menu.MenuId == 0 ? -1 : menu.MenuId;
|
||||
SysMenu info = GetFirst(it => it.MenuName == menu.MenuName && it.ParentId == menu.ParentId);
|
||||
|
||||
//if (info != null && menuId != info.menuId && menu.menuName.Equals(info.menuName))
|
||||
//{
|
||||
// return UserConstants.NOT_UNIQUE;
|
||||
//}
|
||||
if (info != null && info.MenuId != menu.MenuId)
|
||||
{
|
||||
return UserConstants.NOT_UNIQUE;
|
||||
}
|
||||
return UserConstants.UNIQUE;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 菜单排序
|
||||
/// </summary>
|
||||
/// <param name="menuDto"></param>
|
||||
/// <returns></returns>
|
||||
public int ChangeSortMenu(MenuDto menuDto)
|
||||
{
|
||||
return Update(new SysMenu() { MenuId = menuDto.MenuId, OrderNum = menuDto.OrderNum }, it => new { it.OrderNum });
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否存在菜单子节点
|
||||
/// </summary>
|
||||
/// <param name="menuId"></param>
|
||||
/// <returns></returns>
|
||||
public bool HasChildByMenuId(long menuId)
|
||||
{
|
||||
return Count(it => it.ParentId == menuId) > 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取左边导航栏菜单树
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> SelectMenuTreeByUserId(long userId)
|
||||
{
|
||||
MenuQueryDto dto = new() { Status = "0", MenuTypeIds = "M,C" };
|
||||
if (SysRoleService.IsAdmin(userId))
|
||||
{
|
||||
return SelectTreeMenuList(dto);
|
||||
}
|
||||
else
|
||||
{
|
||||
List<long> roleIds = SysRoleService.SelectUserRoles(userId);
|
||||
return SelectTreeMenuListByRoles(dto, roleIds);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 查询精确到按钮的操作权限
|
||||
/// </summary>
|
||||
/// <param name="userId"></param>
|
||||
/// <returns></returns>
|
||||
public List<string> SelectMenuPermsByUserId(long userId)
|
||||
{
|
||||
var menus = Context.Queryable<SysMenu, SysRoleMenu, SysUserRole, SysRole>((m, rm, ur, r) => new JoinQueryInfos(
|
||||
JoinType.Left, m.MenuId == rm.Menu_id,
|
||||
JoinType.Left, rm.Role_id == ur.RoleId,
|
||||
JoinType.Left, ur.RoleId == r.RoleId
|
||||
))
|
||||
.WithCache(60 * 10)
|
||||
.Where((m, rm, ur, r) => m.Status == "0" && r.Status == 0 && ur.UserId == userId)
|
||||
.Select((m, rm, ur, r) => m).ToList();
|
||||
var menuList = menus.Where(f => !string.IsNullOrEmpty(f.Perms));
|
||||
|
||||
return menuList.Select(x => x.Perms).Distinct().ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户查询系统菜单列表
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="roles">用户角色集合</param>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> SelectTreeMenuListByRoles(MenuQueryDto menu, List<long> roles)
|
||||
{
|
||||
var roleMenus = Context.Queryable<SysRoleMenu>()
|
||||
.Where(r => roles.Contains(r.Role_id))
|
||||
.Select(f => f.Menu_id).Distinct().ToList();
|
||||
|
||||
return Queryable()
|
||||
.Where(c => roleMenus.Contains(c.MenuId))
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), (c) => c.MenuName.Contains(menu.MenuName))
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), (c) => c.Visible == menu.Visible)
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), (c) => c.Status == menu.Status)
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), c => menu.MenuTypeIdArr.Contains(c.MenuType))
|
||||
.OrderBy((c) => new { c.ParentId, c.OrderNum })
|
||||
.Select(c => c)
|
||||
.ToTree(it => it.Children, it => it.ParentId, 0);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户查询系统菜单列表
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <param name="roleId">用户角色</param>
|
||||
/// <returns></returns>
|
||||
public List<RoleMenuExportDto> SelectRoleMenuListByRole(MenuQueryDto menu, int roleId)
|
||||
{
|
||||
var menuIds = Context.Queryable<SysRoleMenu>()
|
||||
.Where(r => r.Role_id == roleId)
|
||||
.Select(f => f.Menu_id).Distinct().ToList();
|
||||
|
||||
return Context.Queryable<SysMenu>()
|
||||
.InnerJoin<SysMenu>((t1, t2) => t1.MenuId == t2.ParentId)
|
||||
.InnerJoin<SysMenu>((t1, t2, t3) => t2.MenuId == t3.ParentId)
|
||||
.Where((t1, t2, t3) => menuIds.Contains(t1.MenuId))
|
||||
.Select((t1, t2, t3) => new RoleMenuExportDto()
|
||||
{
|
||||
MenuName = $"{t1.MenuName}->{t2.MenuName}->{t3.MenuName}",
|
||||
Path = t2.Path,
|
||||
Component = t2.Component,
|
||||
Perms = t3.Perms,
|
||||
MenuType = (MenuType)(object)t3.MenuType,
|
||||
Status = (MenuStatus)(object)t3.Status
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有菜单
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private List<SysMenu> SelectMenuList(MenuQueryDto menu)
|
||||
{
|
||||
var menuExp = Expressionable.Create<SysMenu>();
|
||||
menuExp.AndIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName));
|
||||
menuExp.AndIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible);
|
||||
menuExp.AndIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status);
|
||||
menuExp.AndIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.MenuType));
|
||||
menuExp.AndIF(menu.ParentId != null, it => it.ParentId == menu.ParentId);
|
||||
|
||||
return Queryable()
|
||||
.Where(menuExp.ToExpression())
|
||||
.OrderBy(it => new { it.ParentId, it.OrderNum })
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据用户查询系统菜单列表
|
||||
/// </summary>
|
||||
/// <param name="sysMenu"></param>
|
||||
/// <param name="roles">用户角色集合</param>
|
||||
/// <returns></returns>
|
||||
private List<SysMenu> SelectMenuListByRoles(MenuQueryDto sysMenu, List<long> roles)
|
||||
{
|
||||
var roleMenus = Context.Queryable<SysRoleMenu>()
|
||||
.Where(r => roles.Contains(r.Role_id));
|
||||
|
||||
return Queryable()
|
||||
.InnerJoin(roleMenus, (c, j) => c.MenuId == j.Menu_id)
|
||||
.Where((c, j) => c.Status == "0")
|
||||
.WhereIF(!string.IsNullOrEmpty(sysMenu.MenuName), (c, j) => c.MenuName.Contains(sysMenu.MenuName))
|
||||
.WhereIF(!string.IsNullOrEmpty(sysMenu.Visible), (c, j) => c.Visible == sysMenu.Visible)
|
||||
.OrderBy((c, j) => new { c.ParentId, c.OrderNum })
|
||||
.Select(c => c)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取所有菜单(菜单管理)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<SysMenu> SelectTreeMenuList(MenuQueryDto menu)
|
||||
{
|
||||
int parentId = menu.ParentId != null ? (int)menu.ParentId : 0;
|
||||
|
||||
var list = Queryable()
|
||||
.WithCache(60 * 10)
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.Visible == menu.Visible)
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.Status == menu.Status)
|
||||
.WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.MenuType))
|
||||
.WhereIF(menu.ParentId != null, it => it.ParentId == menu.ParentId)
|
||||
.OrderBy(it => new { it.ParentId, it.OrderNum })
|
||||
.ToTree(it => it.Children, it => it.ParentId, parentId);
|
||||
|
||||
return list;
|
||||
}
|
||||
#region 方法
|
||||
|
||||
///// <summary>
|
||||
///// 根据父节点的ID获取所有子节点
|
||||
///// </summary>
|
||||
///// <param name="list">分类表</param>
|
||||
///// <param name="parentId">传入的父节点ID</param>
|
||||
///// <returns></returns>
|
||||
//public List<SysMenu> GetChildPerms(List<SysMenu> list, int parentId)
|
||||
//{
|
||||
// List<SysMenu> returnList = new List<SysMenu>();
|
||||
// var data = list.FindAll(f => f.parentId == parentId);
|
||||
|
||||
// foreach (var item in data)
|
||||
// {
|
||||
// RecursionFn(list, item);
|
||||
|
||||
// returnList.Add(item);
|
||||
// }
|
||||
// return returnList;
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 递归列表
|
||||
/// </summary>
|
||||
/// <param name="list"></param>
|
||||
/// <param name="t"></param>
|
||||
private void RecursionFn(List<SysMenu> list, SysMenu t)
|
||||
{
|
||||
//得到子节点列表
|
||||
List<SysMenu> childList = GetChildList(list, t);
|
||||
t.Children = childList;
|
||||
foreach (var item in childList)
|
||||
{
|
||||
if (GetChildList(list, item).Count() > 0)
|
||||
{
|
||||
RecursionFn(list, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 递归获取子菜单
|
||||
/// </summary>
|
||||
/// <param name="list">所有菜单</param>
|
||||
/// <param name="sysMenu"></param>
|
||||
/// <returns></returns>
|
||||
private List<SysMenu> GetChildList(List<SysMenu> list, SysMenu sysMenu)
|
||||
{
|
||||
return list.Where(p => p.ParentId == sysMenu.MenuId).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取路由侧边栏,动态生成
|
||||
/// </summary>
|
||||
/// <param name="menus"></param>
|
||||
/// <returns></returns>
|
||||
public List<RouterVo> BuildMenus(List<SysMenu> menus)
|
||||
{
|
||||
List<RouterVo> routers = new();
|
||||
if (menus == null) return routers;
|
||||
|
||||
foreach (var menu in menus)
|
||||
{
|
||||
RouterVo router = new()
|
||||
{
|
||||
Hidden = "1".Equals(menu.Visible),
|
||||
Name = GetRouteName(menu),
|
||||
Path = GetRoutePath(menu),
|
||||
Component = GetComponent(menu),
|
||||
Meta = new Meta(menu.MenuName, menu.Icon, "1".Equals(menu.IsCache), menu.MenuNameKey, menu.Path, menu.Create_time)
|
||||
};
|
||||
|
||||
List<SysMenu> cMenus = menu.Children;
|
||||
//是目录并且有子菜单
|
||||
if (cMenus != null && cMenus.Count > 0 && UserConstants.TYPE_DIR.Equals(menu.MenuType))
|
||||
{
|
||||
router.AlwaysShow = true;
|
||||
router.Redirect = "noRedirect";
|
||||
router.Children = BuildMenus(cMenus);
|
||||
}
|
||||
else if (IsMeunFrame(menu))
|
||||
{
|
||||
router.Meta = null;
|
||||
List<RouterVo> childrenList = new();
|
||||
RouterVo children = new()
|
||||
{
|
||||
Path = menu.Path,
|
||||
Component = menu.Component,
|
||||
Name = string.IsNullOrEmpty(menu.Path) ? "" : menu.Path.ToLower(),
|
||||
Meta = new Meta(menu.MenuName, menu.Icon, "1".Equals(menu.IsCache), menu.MenuNameKey, menu.Path, menu.Create_time)
|
||||
};
|
||||
childrenList.Add(children);
|
||||
router.Children = childrenList;
|
||||
}
|
||||
else if (menu.ParentId == 0 && IsInnerLink(menu))
|
||||
{
|
||||
router.Meta = new Meta(menu.MenuName, menu.Icon);
|
||||
router.Path = "/";
|
||||
List<RouterVo> childrenList = new();
|
||||
RouterVo children = new();
|
||||
string routerPath = InnerLinkReplaceEach(menu.Path);
|
||||
children.Path = routerPath;
|
||||
children.Component = UserConstants.INNER_LINK;
|
||||
children.Name = routerPath.ToLower();
|
||||
children.Meta = new Meta(menu.MenuName, menu.Icon, menu.Path);
|
||||
childrenList.Add(children);
|
||||
router.Children = childrenList;
|
||||
}
|
||||
routers.Add(router);
|
||||
}
|
||||
|
||||
return routers;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建前端所需要下拉树结构
|
||||
/// </summary>
|
||||
/// <param name="menus">菜单列表</param>
|
||||
/// <returns>下拉树结构列表</returns>
|
||||
public List<SysMenu> BuildMenuTree(List<SysMenu> menus)
|
||||
{
|
||||
List<SysMenu> returnList = new();
|
||||
List<long> tempList = menus.Select(f => f.MenuId).ToList();
|
||||
|
||||
foreach (var menu in menus)
|
||||
{
|
||||
// 如果是顶级节点, 遍历该父节点的所有子节点
|
||||
if (!tempList.Contains(menu.ParentId))
|
||||
{
|
||||
RecursionFn(menus, menu);
|
||||
returnList.Add(menu);
|
||||
}
|
||||
}
|
||||
if (!returnList.Any())
|
||||
{
|
||||
returnList = menus;
|
||||
}
|
||||
return returnList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 构建前端所需要下拉树结构
|
||||
/// </summary>
|
||||
/// <param name="menus"></param>
|
||||
/// <returns></returns>
|
||||
public List<TreeSelectVo> BuildMenuTreeSelect(List<SysMenu> menus)
|
||||
{
|
||||
List<SysMenu> menuTrees = BuildMenuTree(menus);
|
||||
List<TreeSelectVo> treeMenuVos = new List<TreeSelectVo>();
|
||||
foreach (var item in menuTrees)
|
||||
{
|
||||
treeMenuVos.Add(new TreeSelectVo(item));
|
||||
}
|
||||
return treeMenuVos;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取路由名称
|
||||
/// </summary>
|
||||
/// <param name="menu">菜单信息</param>
|
||||
/// <returns>路由名称</returns>
|
||||
public string GetRouteName(SysMenu menu)
|
||||
{
|
||||
string routerName = menu.Path.ToLower();
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (IsMeunFrame(menu))
|
||||
{
|
||||
routerName = string.Empty;
|
||||
}
|
||||
return routerName;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取路由路径
|
||||
/// </summary>
|
||||
/// <param name="menu">菜单信息</param>
|
||||
/// <returns>路由地址</returns>
|
||||
public string GetRoutePath(SysMenu menu)
|
||||
{
|
||||
string routerPath = menu.Path;
|
||||
// 内链打开外网方式
|
||||
if (menu.ParentId != 0 && IsInnerLink(menu))
|
||||
{
|
||||
routerPath = InnerLinkReplaceEach(routerPath);
|
||||
}
|
||||
// 非外链并且是一级目录(类型为目录)
|
||||
if (0 == menu.ParentId && UserConstants.TYPE_DIR.Equals(menu.MenuType)
|
||||
&& UserConstants.NO_FRAME.Equals(menu.IsFrame))
|
||||
{
|
||||
routerPath = "/" + menu.Path;
|
||||
}
|
||||
else if (IsMeunFrame(menu))// 非外链并且是一级目录(类型为菜单)
|
||||
{
|
||||
routerPath = "/";
|
||||
}
|
||||
return routerPath;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取组件名称
|
||||
/// </summary>
|
||||
/// <param name="menu"></param>
|
||||
/// <returns></returns>
|
||||
public string GetComponent(SysMenu menu)
|
||||
{
|
||||
string component = UserConstants.LAYOUT;
|
||||
if (!string.IsNullOrEmpty(menu.Component) && !IsMeunFrame(menu))
|
||||
{
|
||||
component = menu.Component;
|
||||
}
|
||||
else if (menu.Component.IsEmpty() && menu.ParentId != 0 && IsInnerLink(menu))
|
||||
{
|
||||
component = UserConstants.INNER_LINK;
|
||||
}
|
||||
else if (string.IsNullOrEmpty(menu.Component) && IsParentView(menu))
|
||||
{
|
||||
component = UserConstants.PARENT_VIEW;
|
||||
}
|
||||
return component;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为菜单内部跳转
|
||||
/// </summary>
|
||||
/// <param name="menu">菜单信息</param>
|
||||
/// <returns></returns>
|
||||
public bool IsMeunFrame(SysMenu menu)
|
||||
{
|
||||
return menu.ParentId == 0 && UserConstants.TYPE_MENU.Equals(menu.MenuType)
|
||||
&& menu.IsFrame.Equals(UserConstants.NO_FRAME);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为内链组件
|
||||
/// </summary>
|
||||
/// <param name="menu">菜单信息</param>
|
||||
/// <returns>结果</returns>
|
||||
public bool IsInnerLink(SysMenu menu)
|
||||
{
|
||||
return menu.IsFrame.Equals(UserConstants.NO_FRAME) && Tools.IsUrl(menu.Path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否为parent_view组件
|
||||
/// </summary>
|
||||
/// <param name="menu">菜单信息</param>
|
||||
/// <returns></returns>
|
||||
public bool IsParentView(SysMenu menu)
|
||||
{
|
||||
return menu.ParentId != 0 && UserConstants.TYPE_DIR.Equals(menu.MenuType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 内链域名特殊字符替换
|
||||
/// </summary>
|
||||
/// <param name = "path" ></ param >
|
||||
/// < returns ></ returns >
|
||||
public string InnerLinkReplaceEach(string path)
|
||||
{
|
||||
return path.IsNotEmpty() ? path
|
||||
.Replace(UserConstants.HTTP, "")
|
||||
.Replace(UserConstants.HTTPS, "")
|
||||
.Replace(UserConstants.WWW, "")
|
||||
.Replace(".", "/") : path;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
public void AddSysMenu(GenTable genTableInfo, string permPrefix, bool showEdit, bool showExport, bool showImport)
|
||||
{
|
||||
var menu = GetFirst(f => f.MenuName == genTableInfo.FunctionName);
|
||||
if (menu is null)
|
||||
{
|
||||
menu = new()
|
||||
{
|
||||
MenuName = genTableInfo.FunctionName,
|
||||
ParentId = genTableInfo.Options.ParentMenuId,
|
||||
OrderNum = 0,
|
||||
Path = genTableInfo.BusinessName,
|
||||
Component = $"{genTableInfo.ModuleName.FirstLowerCase()}/{genTableInfo.BusinessName}",
|
||||
Perms = $"{permPrefix}:list",
|
||||
IsCache = "1",
|
||||
MenuType = "C",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "icon1",
|
||||
Create_by = "system",
|
||||
};
|
||||
menu.MenuId = AddMenu(menu);
|
||||
}
|
||||
|
||||
List<SysMenu> menuList = new();
|
||||
|
||||
SysMenu menuQuery = new()
|
||||
{
|
||||
MenuName = "查询",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 1,
|
||||
Perms = $"{permPrefix}:query",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
SysMenu menuAdd = new()
|
||||
{
|
||||
MenuName = "新增",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 2,
|
||||
Perms = $"{permPrefix}:add",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
SysMenu menuDel = new()
|
||||
{
|
||||
MenuName = "删除",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 3,
|
||||
Perms = $"{permPrefix}:delete",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
|
||||
SysMenu menuEdit = new()
|
||||
{
|
||||
MenuName = "修改",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 4,
|
||||
Perms = $"{permPrefix}:edit",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
|
||||
SysMenu menuExport = new()
|
||||
{
|
||||
MenuName = "导出",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 5,
|
||||
Perms = $"{permPrefix}:export",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
|
||||
SysMenu menuImport = new()
|
||||
{
|
||||
MenuName = "导入",
|
||||
ParentId = menu.MenuId,
|
||||
OrderNum = 5,
|
||||
Perms = $"{permPrefix}:import",
|
||||
MenuType = "F",
|
||||
Visible = "0",
|
||||
Status = "0",
|
||||
Icon = "",
|
||||
};
|
||||
|
||||
menuList.Add(menuQuery);
|
||||
menuList.Add(menuAdd);
|
||||
menuList.Add(menuDel);
|
||||
if (showEdit)
|
||||
{
|
||||
menuList.Add(menuEdit);
|
||||
}
|
||||
if (showExport)
|
||||
{
|
||||
menuList.Add(menuExport);
|
||||
}
|
||||
if (showImport)
|
||||
{
|
||||
menuList.Add(menuImport);
|
||||
}
|
||||
//Insert(menuList);
|
||||
|
||||
var x = Context.Storageable(menuList)
|
||||
.SplitInsert(it => !it.Any())
|
||||
.SplitUpdate(it => !it.Any())
|
||||
.WhereColumns(it => new { it.MenuName, it.ParentId })
|
||||
.ToStorage();
|
||||
x.AsInsertable.ExecuteCommand();//插入可插入部分;
|
||||
x.AsUpdateable.ExecuteCommand();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
using Infrastructure.Attribute;
|
||||
using SqlSugar;
|
||||
using System.Collections.Generic;
|
||||
using ZR.Model;
|
||||
using ZR.Model.System;
|
||||
using ZR.Model.System.Dto;
|
||||
using ZR.Service.System.IService;
|
||||
|
||||
namespace ZR.Service.System
|
||||
{
|
||||
/// <summary>
|
||||
/// 通知公告表Service业务层处理
|
||||
///
|
||||
/// @author zr
|
||||
/// @date 2021-12-15
|
||||
/// </summary>
|
||||
[AppService(ServiceType = typeof(ISysNoticeService), ServiceLifetime = LifeTime.Transient)]
|
||||
public class SysNoticeService : BaseService<SysNotice>, ISysNoticeService
|
||||
{
|
||||
#region 业务逻辑代码
|
||||
|
||||
/// <summary>
|
||||
/// 查询系统通知
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<SysNotice> GetSysNotices()
|
||||
{
|
||||
var predicate = Expressionable.Create<SysNotice>();
|
||||
|
||||
predicate = predicate.And(m => m.Status == 0);
|
||||
return Queryable()
|
||||
.Where(predicate.ToExpression())
|
||||
.OrderByDescending(f => f.Create_time)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public PagedInfo<SysNotice> GetPageList(SysNoticeQueryDto parm)
|
||||
{
|
||||
var predicate = Expressionable.Create<SysNotice>();
|
||||
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.NoticeTitle), m => m.NoticeTitle.Contains(parm.NoticeTitle));
|
||||
predicate = predicate.AndIF(parm.NoticeType != null, m => m.NoticeType == parm.NoticeType);
|
||||
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.CreateBy), m => m.Create_by.Contains(parm.CreateBy) || m.Update_by.Contains(parm.CreateBy));
|
||||
predicate = predicate.AndIF(parm.Status != null, m => m.Status == parm.Status);
|
||||
var response = GetPages(predicate.ToExpression(), parm);
|
||||
return response;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user