This commit is contained in:
lwh 2023-04-04 18:15:13 +08:00
commit d3d65603ac
893 changed files with 67147 additions and 0 deletions

18
.gitignore vendored Normal file
View File

@ -0,0 +1,18 @@
# Build and Release Folders
bin-debug/
bin-release/
[Oo]bj/
[Bb]in/
# Other files and folders
.settings/
# Executables
*.swf
*.air
*.ipa
*.apk
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.

63
ARW-net/.gitattributes vendored Normal file
View File

@ -0,0 +1,63 @@
###############################################################################
# Set default behavior to automatically normalize line endings.
###############################################################################
* text=auto
###############################################################################
# Set default behavior for command prompt diff.
#
# This is need for earlier builds of msysgit that does not have it on by
# default for csharp files.
# Note: This is only used by command line
###############################################################################
#*.cs diff=csharp
###############################################################################
# Set the merge driver for project and solution files
#
# Merging from the command prompt will add diff markers to the files if there
# are conflicts (Merging from VS is not affected by the settings below, in VS
# the diff markers are never inserted). Diff markers may cause the following
# file extensions to fail to load in VS. An alternative would be to treat
# these files as binary and thus will always conflict and require user
# intervention with every merge. To do so, just uncomment the entries below
###############################################################################
#*.sln merge=binary
#*.csproj merge=binary
#*.vbproj merge=binary
#*.vcxproj merge=binary
#*.vcproj merge=binary
#*.dbproj merge=binary
#*.fsproj merge=binary
#*.lsproj merge=binary
#*.wixproj merge=binary
#*.modelproj merge=binary
#*.sqlproj merge=binary
#*.wwaproj merge=binary
###############################################################################
# behavior for image files
#
# image files are treated as binary by default.
###############################################################################
#*.jpg binary
#*.png binary
#*.gif binary
###############################################################################
# diff behavior for common document formats
#
# Convert binary document formats to text before diffing them. This feature
# is only available from the command line. Turn it on by uncommenting the
# entries below.
###############################################################################
#*.doc diff=astextplain
#*.DOC diff=astextplain
#*.docx diff=astextplain
#*.DOCX diff=astextplain
#*.dot diff=astextplain
#*.DOT diff=astextplain
#*.pdf diff=astextplain
#*.PDF diff=astextplain
#*.rtf diff=astextplain
#*.RTF diff=astextplain

273
ARW-net/.gitignore vendored Normal file
View File

@ -0,0 +1,273 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
# User-specific files
*.suo
*.user
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
# Build results
[Dd]ebug/
[Dd]ebugPublic/
[Rr]elease/
[Rr]eleases/
x64/
x86/
bld/
[Bb]in/
[Oo]bj/
[Ll]og/
# Visual Studio 2015 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
#wwwroot/
# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
# NUNIT
*.VisualState.xml
TestResult.xml
# Build Results of an ATL Project
[Dd]ebugPS/
[Rr]eleasePS/
dlldata.c
# DNX
project.lock.json
project.fragment.lock.json
artifacts/
*_i.c
*_p.c
*_i.h
*.ilk
*.meta
*.obj
*.pch
*.pdb
*.pgc
*.pgd
*.rsp
*.sbr
*.tlb
*.tli
*.tlh
*.tmp
*.tmp_proj
*.log
*.vspscc
*.vssscc
.builds
*.pidb
*.svclog
*.scc
# Chutzpah Test files
_Chutzpah*
# Visual C++ cache files
ipch/
*.aps
*.ncb
*.opendb
*.opensdf
*.sdf
*.cachefile
*.VC.db
*.VC.VC.opendb
# Visual Studio profiler
*.psess
*.vsp
*.vspx
*.sap
# TFS 2012 Local Workspace
$tf/
# Guidance Automation Toolkit
*.gpState
# ReSharper is a .NET coding add-in
_ReSharper*/
*.[Rr]e[Ss]harper
*.DotSettings.user
# JustCode is a .NET coding add-in
.JustCode
# TeamCity is a build add-in
_TeamCity*
# DotCover is a Code Coverage Tool
*.dotCover
# NCrunch
_NCrunch_*
.*crunch*.local.xml
nCrunchTemp_*
# MightyMoose
*.mm.*
AutoTest.Net/
# Web workbench (sass)
.sass-cache/
# Installshield output folder
[Ee]xpress/
# DocProject is a documentation generator add-in
DocProject/buildhelp/
DocProject/Help/*.HxT
DocProject/Help/*.HxC
DocProject/Help/*.hhc
DocProject/Help/*.hhk
DocProject/Help/*.hhp
DocProject/Help/Html2
DocProject/Help/html
# Click-Once directory
publish/
# Publish Web Output
*.[Pp]ublish.xml
*.azurePubxml
# TODO: Comment the next line if you want to checkin your web deploy settings
# but database connection strings (with potential passwords) will be unencrypted
#*.pubxml
*.publishproj
# Microsoft Azure Web App publish settings. Comment the next line if you want to
# checkin your Azure Web App publish settings, but sensitive information contained
# in these scripts will be unencrypted
PublishScripts/
# NuGet Packages
*.nupkg
# The packages folder can be ignored because of Package Restore
**/packages/*
# except build/, which is used as an MSBuild target.
!**/packages/build/
# Uncomment if necessary however generally it will be regenerated when needed
#!**/packages/repositories.config
# NuGet v3's project.json files produces more ignoreable files
*.nuget.props
*.nuget.targets
# Microsoft Azure Build Output
csx/
*.build.csdef
# Microsoft Azure Emulator
ecf/
rcf/
# Windows Store app package directories and files
AppPackages/
BundleArtifacts/
Package.StoreAssociation.xml
_pkginfo.txt
# Visual Studio cache files
# files ending in .cache can be ignored
*.[Cc]ache
# but keep track of directories ending in .cache
!*.[Cc]ache/
# Others
ClientBin/
~$*
*~
*.dbmdl
*.dbproj.schemaview
*.jfm
*.pfx
*.publishsettings
node_modules/
orleans.codegen.cs
# Since there are multiple workflows, uncomment next line to ignore bower_components
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
#bower_components/
# RIA/Silverlight projects
Generated_Code/
# Backup & report files from converting an old project file
# to a newer Visual Studio version. Backup files are not needed,
# because we have git ;-)
_UpgradeReport_Files/
Backup*/
UpgradeLog*.XML
UpgradeLog*.htm
# SQL Server files
*.mdf
*.ldf
# Business Intelligence projects
*.rdl.data
*.bim.layout
*.bim_*.settings
# Microsoft Fakes
FakesAssemblies/
# GhostDoc plugin setting file
*.GhostDoc.xml
# Node.js Tools for Visual Studio
.ntvs_analysis.dat
# Visual Studio 6 build log
*.plg
# Visual Studio 6 workspace options file
*.opt
# Visual Studio LightSwitch build output
**/*.HTMLClient/GeneratedArtifacts
**/*.DesktopClient/GeneratedArtifacts
**/*.DesktopClient/ModelManifest.xml
**/*.Server/GeneratedArtifacts
**/*.Server/ModelManifest.xml
_Pvt_Extensions
# Paket dependency manager
.paket/paket.exe
paket-files/
# FAKE - F# Make
.fake/
# JetBrains Rider
.idea/
*.sln.iml
# CodeRush
.cr/
# Python Tools for Visual Studio (PTVS)
__pycache__/
*.pyc
/ZR.Admin.WebApi/appsettings.Stage.json
/CodeGenerate
/ZR.Admin.WebApi/appsettings.Production.json
/ZR.Admin.WebApi/wwwroot/uploads
/ZR.Admin.WebApi/wwwroot/Generatecode
/ZR.Admin.WebApi/wwwroot/export
/ZR.Vue/src/views/business/Gendemo.vue
/ZR.Admin.WebApi/Properties/launchSettings.json
/ZR.Admin.WebApi/ZRAdmin.xml
/ZR.Admin.WebApi/DataProtection
/Quartz.NET.WindowsService
/ZRAdmin-vue

10
ARW-net/.net_run.bat Normal file
View File

@ -0,0 +1,10 @@
"age": 10,
"classId": "1547502470350114800",
"className": "1班",
"sex": "1",
"studentDescribe": "<p>啊实打实大苏打实打实实打实上的</p>",
"studentId": 1548629251954184200,
"studentImg": "/url",
"studentName": "张思1",
"studentService": [{service_name: "特殊服务", service_price: "999"}],
"studentTag": "a,v,c"

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>ARW.CodeGenerator</AssemblyName>
<RootNamespace>ARW.CodeGenerator</RootNamespace>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
<ProjectReference Include="..\ARW.Common\ARW.Common.csproj" />
<ProjectReference Include="..\ARW.Model\ARW.Model.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JinianNet.JNTemplate" Version="2.3.0" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.21" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,52 @@
namespace ARW.CodeGenerator
{
public class CodeGenerateOption
{
/// <summary>
/// 项目命名空间
/// </summary>
public string BaseNamespace { get; set; }
/// <summary>
/// 下级命名空间
/// </summary>
public string SubNamespace { get; set; }
/// <summary>
/// 数据实体命名空间
/// </summary>
public string ModelsNamespace { get; set; }
/// <summary>
/// 输入输出数据实体名称空间
/// </summary>
public string DtosNamespace { get; set; }
/// <summary>
/// 仓储接口命名空间
/// </summary>
public string IRepositoriesNamespace { get; set; }
/// <summary>
/// 仓储实现名称空间
/// </summary>
public string RepositoriesNamespace { get; set; }
/// <summary>
/// 服务接口命名空间
/// </summary>
public string IServicsNamespace { get; set; }
/// <summary>
/// 服务接口实现命名空间
/// </summary>
public string ServicesNamespace { get; set; }
/// <summary>
/// Api控制器命名空间
/// </summary>
public string ApiControllerNamespace { get; set; }
/// <summary>
/// 去掉的表头字符
/// </summary>
public string ReplaceTableNameStr { get; set; }
/// <summary>
/// 要生数据的表,用“,”分割
/// </summary>
//public string TableList { get; set; }
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Linq;
using System.Text;
using ARW.Model.System.Generate;
namespace ARW.CodeGenerator
{
/// <summary>
/// 代码生成模板
/// </summary>
public class CodeGenerateTemplate
{
//模板调用
public static string QueryExp(string propertyName, string queryType)
{
if (queryType.Equals("EQ"))
{
return $"it => it.{ propertyName} == parm.{propertyName})";
}
if (queryType.Equals("GTE"))
{
return $"it => it.{ propertyName} >= parm.{propertyName})";
}
if (queryType.Equals("GT"))
{
return $"it => it.{ propertyName} > parm.{propertyName})";
}
if (queryType.Equals("LT"))
{
return $"it => it.{ propertyName} < parm.{propertyName})";
}
if (queryType.Equals("LTE"))
{
return $"it => it.{ propertyName} <= parm.{propertyName})";
}
if (queryType.Equals("NE"))
{
return $"it => it.{ propertyName} != parm.{propertyName})";
}
if (queryType.Equals("ARWKE"))
{
return $"it => it.{ propertyName}.Contains(parm.{propertyName}))";
}
return $"it => it.{ propertyName} == parm.{propertyName})";
}
}
}

View File

@ -0,0 +1,582 @@
using Infrastructure;
using Infrastructure.Extensions;
using JinianNet.JNTemplate;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ARW.CodeGenerator.Model;
using ARW.Model.System.Generate;
namespace ARW.CodeGenerator
{
/// <summary>
/// 代码生成器
/// </remarks>
/// </summary>
public class CodeGeneratorTool
{
/// <summary>
/// 代码生成器配置
/// </summary>
private static CodeGenerateOption _option = new CodeGenerateOption();
/// <summary>
/// 代码生成器入口方法
/// </summary>
/// <param name="dto"></param>
public static void Generate(GenerateDto dto)
{
_option.BaseNamespace = dto.GenTable.BaseNameSpace;
_option.SubNamespace = dto.GenTable.ModuleName.FirstUpperCase();
_option.DtosNamespace = _option.BaseNamespace + "Model";
_option.ModelsNamespace = _option.BaseNamespace + "Model";
_option.RepositoriesNamespace = _option.BaseNamespace + "Repository";
_option.IRepositoriesNamespace = _option.BaseNamespace + "Repository";
_option.IServicsNamespace = _option.BaseNamespace + "Service";
_option.ServicesNamespace = _option.BaseNamespace + "Service";
_option.ApiControllerNamespace = _option.BaseNamespace + "Admin.WebApi";
var vuePath = AppSettings.GetConfig("gen:vuePath");
dto.VueParentPath = dto.VueVersion == 3 ? "ARWAdmin-vue" : "ARW.Vue";
if (!vuePath.IsEmpty())
{
dto.VueParentPath = vuePath;
}
dto.GenOptions = _option;
string PKName = "Id";
string PKType = "int";
ReplaceDto replaceDto = new()
{
ModelTypeName = dto.GenTable.ClassName,//表名对应C# 实体类名
PermissionPrefix = dto.GenTable?.Options?.PermissionPrefix,
Author = dto.GenTable.FunctionAuthor,
ShowBtnAdd = dto.GenTable.Options.CheckedBtn.Any(f => f == 1),
ShowBtnEdit = dto.GenTable.Options.CheckedBtn.Any(f => f == 2),
ShowBtnDelete = dto.GenTable.Options.CheckedBtn.Any(f => f == 3),
ShowBtnExport = dto.GenTable.Options.CheckedBtn.Any(f => f == 4),
ShowBtnView = dto.GenTable.Options.CheckedBtn.Any(f => f == 5)
};
//循环表字段信息
foreach (GenTableColumn dbFieldInfo in dto.GenTable.Columns.OrderBy(x => x.Sort))
{
if (dbFieldInfo.IsPk || dbFieldInfo.IsIncrement)
{
PKName = dbFieldInfo.CsharpField;
PKType = dbFieldInfo.CsharpType;
}
if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_IMAGE_UPLOAD) || dbFieldInfo.HtmlType.Equals(GenConstants.HTML_FILE_UPLOAD))
{
replaceDto.UploadFile = 1;
}
dbFieldInfo.CsharpFieldFl = dbFieldInfo.CsharpField.FirstLowerCase();
}
replaceDto.PKName = PKName;
replaceDto.PKType = PKType;
replaceDto.FistLowerPk = PKName.FirstLowerCase();
InitJntTemplate(dto, replaceDto);
GenerateModels(replaceDto, dto);
GenerateRepository(replaceDto, dto);
GenerateService(replaceDto, dto);
GenerateControllers(replaceDto, dto);
if (dto.VueVersion == 3)
{
GenerateVue3Views(replaceDto, dto);
}
else
{
replaceDto.VueViewListHtml = GenerateVueTableList();
replaceDto.VueQueryFormHtml = GenerateVueQueryForm();
replaceDto.VueViewFormHtml = GenerateCurdForm();
GenerateVueViews(replaceDto, dto);
}
GenerateVueJs(replaceDto, dto);
GenerateSql(replaceDto, dto);
if (dto.IsPreview) return;
foreach (var item in dto.GenCodes)
{
item.Path = Path.Combine(dto.GenCodePath, item.Path);
FileHelper.WriteAndSave(item.Path, item.Content);
}
}
#region
/// <summary>
/// 生成实体类Model
/// </summary>
/// <param name="generateDto"></param>
/// <param name="replaceDto">替换实体</param>
private static void GenerateModels(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tpl = FileHelper.ReadJtTemplate("TplModel.txt");
var tplDto = FileHelper.ReadJtTemplate("TplDto.txt");
string fullPath = Path.Combine(_option.ModelsNamespace, "Models", _option.SubNamespace, replaceDto.ModelTypeName + ".cs");
string fullPathDto = Path.Combine(_option.ModelsNamespace, "Dto", _option.SubNamespace, $"{replaceDto.ModelTypeName}Dto.cs");
generateDto.GenCodes.Add(new GenCode(1, "Model.cs", fullPath, tpl.Render()));
generateDto.GenCodes.Add(new GenCode(2, "Dto.cs", fullPathDto, tplDto.Render()));
}
/// <summary>
/// 生成Repository层代码文件
/// </summary>
/// <param name="generateDto"></param>
/// <param name="replaceDto">替换实体</param>
private static void GenerateRepository(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tpl = FileHelper.ReadJtTemplate("TplRepository.txt");
var result = tpl.Render();
var fullPath = Path.Combine(_option.RepositoriesNamespace, _option.SubNamespace, $"{replaceDto.ModelTypeName}Repository.cs");
generateDto.GenCodes.Add(new GenCode(3, "Repository.cs", fullPath, result));
}
/// <summary>
/// 生成Service文件
/// </summary>
private static void GenerateService(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tpl = FileHelper.ReadJtTemplate("TplService.txt");
var tpl2 = FileHelper.ReadJtTemplate("TplIService.txt");
var result = tpl.Render();
var result2 = tpl2.Render();
var fullPath = Path.Combine(_option.ServicesNamespace, _option.SubNamespace, $"{replaceDto.ModelTypeName}Service.cs");
var fullPath2 = Path.Combine(_option.IServicsNamespace, _option.SubNamespace, $"I{_option.SubNamespace}Service", $"I{replaceDto.ModelTypeName}Service.cs");
generateDto.GenCodes.Add(new GenCode(4, "Service.cs", fullPath, result));
generateDto.GenCodes.Add(new GenCode(4, "IService.cs", fullPath2, result2));
}
/// <summary>
/// 生成控制器ApiControllers文件
/// </summary>
private static void GenerateControllers(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tpl = FileHelper.ReadJtTemplate("TplControllers.txt");
tpl.Set("QueryCondition", replaceDto.QueryCondition);
var result = tpl.Render();
var fullPath = Path.Combine(_option.ApiControllerNamespace, "Controllers", _option.SubNamespace, $"{replaceDto.ModelTypeName}Controller.cs");
generateDto.GenCodes.Add(new GenCode(5, "Controller.cs", fullPath, result));
}
/// <summary>
/// 生成Vue页面
private static void GenerateVueViews(ReplaceDto replaceDto, GenerateDto generateDto)
{
string fileName = string.Empty;
switch (generateDto.GenTable.TplCategory)
{
case "tree":
fileName = "TplTreeVue.txt";
break;
case "crud":
fileName = "TplVue.txt";
break;
case "subNav":
fileName = "TplVue.txt";
break;
case "subNavMore":
fileName = "TplVue.txt";
break;
case "select":
fileName = "TplVueSelect.txt";
break;
default:
break;
}
var tpl = FileHelper.ReadJtTemplate(fileName);
tpl.Set("vueQueryFormHtml", replaceDto.VueQueryFormHtml);
tpl.Set("VueViewFormContent", replaceDto.VueViewFormHtml);//添加、修改表单
tpl.Set("VueViewListContent", replaceDto.VueViewListHtml);//查询 table列
var result = tpl.Render();
var fullPath = Path.Combine(generateDto.VueParentPath, "src", "views", generateDto.GenTable.ModuleName.FirstLowerCase(), $"{generateDto.GenTable.BusinessName.FirstUpperCase()}.vue");
generateDto.GenCodes.Add(new GenCode(6, "index.vue", fullPath, result));
}
/// <summary>
/// vue3
/// </summary>
/// <param name="replaceDto"></param>
/// <param name="generateDto"></param>
private static void GenerateVue3Views(ReplaceDto replaceDto, GenerateDto generateDto)
{
string fileName = generateDto.GenTable.TplCategory switch
{
"tree" => "TreeVue.txt",
"crud" => "Vue.txt",
//case "select":
// fileName = "TplVueSelect.txt";
// break;
_ => "Vue.txt",
};
fileName = Path.Combine("v3", fileName);
var tpl = FileHelper.ReadJtTemplate(fileName);
tpl.Set("treeCode", generateDto.GenTable?.Options?.TreeCode?.FirstLowerCase());
tpl.Set("treeName", generateDto.GenTable?.Options?.TreeName?.FirstLowerCase());
tpl.Set("treeParentCode", generateDto.GenTable?.Options?.TreeParentCode?.FirstLowerCase());
tpl.Set("options", generateDto.GenTable?.Options);
var result = tpl.Render();
var fullPath = Path.Combine(generateDto.VueParentPath, "src", "views", generateDto.GenTable.ModuleName.FirstLowerCase(), $"{generateDto.GenTable.BusinessName.FirstUpperCase()}.vue");
generateDto.GenCodes.Add(new GenCode(16, "index.vue", fullPath, result));
}
/// <summary>
/// 生成vue页面api
/// </summary>
/// <param name="replaceDto"></param>
/// <param name="generateDto"></param>
/// <returns></returns>
public static void GenerateVueJs(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tpl = FileHelper.ReadJtTemplate("TplVueApi.txt");
var result = tpl.Render();
string fileName;
if (generateDto.VueVersion == 3)
{
fileName = generateDto.GenTable.BusinessName.ToLower() + ".js";
}
else
{
fileName = generateDto.GenTable.BusinessName.FirstLowerCase() + ".js";
}
string fullPath = Path.Combine(generateDto.VueParentPath, "src", "api", generateDto.GenTable.ModuleName.FirstLowerCase(), fileName);
generateDto.GenCodes.Add(new GenCode(7, "api.js", fullPath, result));
}
/// <summary>
/// 生成SQL
/// </summary>
/// <param name="replaceDto"></param>
/// <param name="generateDto"></param>
public static void GenerateSql(ReplaceDto replaceDto, GenerateDto generateDto)
{
var tempName = "";
switch (generateDto.DbType)
{
case 0:
tempName = "MySqlTemplate";
break;
case 1:
tempName = "SqlTemplate";
break;
default:
break;
}
var tpl = FileHelper.ReadJtTemplate($"{tempName}.txt");
tpl.Set("parentId", generateDto.GenTable?.Options?.ParentMenuId ?? 0);
var result = tpl.Render();
string fullPath = Path.Combine(generateDto.GenCodePath, "sql", generateDto.GenTable.BusinessName + ".sql");
generateDto.GenCodes.Add(new GenCode(8, "sql", fullPath, result));
}
/// <summary>
/// 生成vue页面查询form
/// </summary>
/// <returns></returns>
public static string GenerateVueQueryForm()
{
var tpl = FileHelper.ReadJtTemplate("QueryForm.txt");
var result = tpl.Render();
return result;
}
/// <summary>
/// 生成vue页面table
/// </summary>
/// <returns></returns>
public static string GenerateVueTableList()
{
var tpl = FileHelper.ReadJtTemplate("TableList.txt");
var result = tpl.Render();
return result;
}
/// <summary>
/// 生成vue表单
/// </summary>
/// <returns></returns>
public static string GenerateCurdForm()
{
var tpl = FileHelper.ReadJtTemplate("CurdForm.txt");
var result = tpl.Render();
return result;
}
#endregion
#region
/// <summary>
/// 如果有前缀替换将前缀替换成空,替换下划线"_"为空再将首字母大写
/// 表名转换成C#类名
/// </summary>
/// <param name="tableName"></param>
/// <returns></returns>
public static string GetClassName(string tableName)
{
bool autoRemovePre = AppSettings.GetAppConfig(GenConstants.Gen_autoPre, false);
string tablePrefix = AppSettings.GetAppConfig<string>(GenConstants.Gen_tablePrefix);
if (!string.IsNullOrEmpty(tablePrefix) && autoRemovePre)
{
string[] prefixList = tablePrefix.Split(",", StringSplitOptions.RemoveEmptyEntries);
for (int i = 0; i < prefixList.Length; i++)
{
if (!string.IsNullOrEmpty(prefixList[i].ToString()))
{
tableName = tableName.Replace(prefixList[i], "", StringComparison.OrdinalIgnoreCase);
}
}
}
return tableName.UnderScoreToCamelCase();
}
/// <summary>
/// 获取前端标签名
/// </summary>
/// <param name="columnDescription"></param>
/// <param name="columnName"></param>
/// <returns></returns>
public static string GetLabelName(string columnDescription, string columnName)
{
return string.IsNullOrEmpty(columnDescription) ? columnName : columnDescription;
}
/// <summary>
/// 首字母转小写,模板使用(勿删)
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static string FirstLowerCase(string str)
{
try
{
return string.IsNullOrEmpty(str) ? str : str.Substring(0, 1).ToLower() + str[1..];
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return "";
}
}
/// <summary>
/// 获取C# 类型
/// </summary>
/// <param name="sDatatype"></param>
/// <returns></returns>
public static string GetCSharpDatatype(string sDatatype)
{
sDatatype = sDatatype.ToLower();
string sTempDatatype = sDatatype switch
{
"int" or "number" or "integer" or "smallint" => "int",
"bigint" => "long",
"tinyint" => "byte",
"numeric" or "real" or "float" => "float",
"decimal" or "numer(8,2)" or "numeric" => "decimal",
"bit" => "bool",
"date" or "datetime" or "datetime2" or "smalldatetime" or "timestamp" => "DateTime",
"money" or "smallmoney" => "decimal",
_ => "string",
};
return sTempDatatype;
}
public static bool IsNumber(string tableDataType)
{
string[] arr = new string[] { "int", "long" };
return arr.Any(f => f.Contains(GetCSharpDatatype(tableDataType)));
}
#endregion
#region
/// <summary>
/// 初始化表信息
/// </summary>
/// <param name="dbName"></param>
/// <param name="userName"></param>
/// <param name="tableName"></param>
/// <param name="desc"></param>
/// <returns></returns>
public static GenTable InitTable(string dbName, string userName, string tableName, string desc)
{
GenTable genTable = new()
{
DbName = dbName,
BaseNameSpace = "ARW.",//导入默认命名空间前缀
ModuleName = "business",//导入默认模块名
ClassName = GetClassName(tableName).FirstUpperCase(),
BusinessName = tableName.UnderScoreToCamelCase().FirstUpperCase(),
FunctionAuthor = AppSettings.GetConfig(GenConstants.Gen_author),
TableName = tableName,
TableComment = desc,
FunctionName = desc,
Create_by = userName,
Options = new Options()
{
SortType = "asc",
CheckedBtn = new int[] { 1, 2, 3 }
}
};
genTable.Options.PermissionPrefix = $"{genTable.ModuleName.ToLower()}:{genTable.ClassName.ToLower()}";//权限
return genTable;
}
/// <summary>
/// 初始化列属性字段数据
/// </summary>
/// <param name="genTable"></param>
/// <param name="dbColumnInfos"></param>
public static List<GenTableColumn> InitGenTableColumn(GenTable genTable, List<DbColumnInfo> dbColumnInfos)
{
List<GenTableColumn> genTableColumns = new();
foreach (var column in dbColumnInfos)
{
genTableColumns.Add(InitColumnField(genTable, column));
}
return genTableColumns;
}
/// <summary>
/// 初始化表字段数据
/// </summary>
/// <param name="genTable"></param>
/// <param name="column"></param>
/// <returns></returns>
private static GenTableColumn InitColumnField(GenTable genTable, DbColumnInfo column)
{
GenTableColumn genTableColumn = new()
{
ColumnName = column.DbColumnName.FirstLowerCase(),
ColumnComment = column.ColumnDescription,
IsPk = column.IsPrimarykey,
ColumnType = column.DataType,
TableId = genTable.TableId,
TableName = genTable.TableName,
CsharpType = GetCSharpDatatype(column.DataType),
CsharpField = column.DbColumnName.ConvertToPascal("_"),
IsRequired = !column.IsNullable,
IsIncrement = column.IsIdentity,
Create_by = genTable.Create_by,
Create_time = DateTime.Now,
IsInsert = !column.IsIdentity || GenConstants.inputDtoNoField.Any(f => f.Contains(column.DbColumnName, StringComparison.OrdinalIgnoreCase)),//非自增字段都需要插入
IsEdit = true,
IsQuery = false,
HtmlType = GenConstants.HTML_INPUT,
};
if (GenConstants.imageFiled.Any(f => column.DbColumnName.ToLower().Contains(f.ToLower())))
{
genTableColumn.HtmlType = GenConstants.HTML_IMAGE_UPLOAD;
}
else if (GenConstants.COLUMNTYPE_TIME.Any(f => genTableColumn.CsharpType.ToLower().Contains(f.ToLower())))
{
genTableColumn.HtmlType = GenConstants.HTML_DATETIME;
}
else if (GenConstants.radioFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)) ||
GenConstants.radioFiled.Any(f => column.DbColumnName.StartsWith(f, StringComparison.OrdinalIgnoreCase)))
{
genTableColumn.HtmlType = GenConstants.HTML_RADIO;
}
else if (GenConstants.selectFiled.Any(f => column.DbColumnName == f) ||
GenConstants.selectFiled.Any(f => column.DbColumnName.EndsWith(f, StringComparison.OrdinalIgnoreCase)))
{
genTableColumn.HtmlType = GenConstants.HTML_SELECT;
}
else if (column.Length > 500)
{
genTableColumn.HtmlType = GenConstants.HTML_TEXTAREA;
}
//编辑字段
if (column.IsIdentity || column.IsPrimarykey || GenConstants.COLUMNNAME_NOT_EDIT.Any(f => column.DbColumnName.Contains(f)))
{
genTableColumn.IsEdit = false;
}
//列表字段
if (!GenConstants.COLUMNNAME_NOT_ARWST.Any(f => column.DbColumnName.Contains(f) && !column.IsPrimarykey))
{
genTableColumn.IsList = true;
}
//时间类型初始化between范围查询
if (genTableColumn.CsharpType == GenConstants.TYPE_DATE)
{
genTableColumn.QueryType = "BETWEEN";
}
return genTableColumn;
}
#endregion
/// <summary>
/// 初始化Jnt模板
/// </summary>
/// <param name="dto"></param>
/// <param name="replaceDto"></param>
private static void InitJntTemplate(GenerateDto dto, ReplaceDto replaceDto)
{
Engine.Current.Clean();
dto.GenTable.Columns = dto.GenTable.Columns.OrderBy(x => x.Sort).ToList();
bool showCustomInput = dto.GenTable.Columns.Any(f => f.HtmlType.Equals(GenConstants.HTML_CUSTOM_INPUT, StringComparison.OrdinalIgnoreCase));
//jnt模板引擎全局变量
Engine.Configure((options) =>
{
options.TagPrefix = "${";
options.TagSuffix = "}";
options.TagFlag = '$';
options.OutMode = OutMode.Auto;
//options.DisableeLogogram = true;//禁用简写
options.Data.Set("refs", "$");//特殊标签替换
options.Data.Set("t", "$");//特殊标签替换
options.Data.Set("modal", "$");//特殊标签替换
options.Data.Set("index", "$");//特殊标签替换
options.Data.Set("confirm", "$");//特殊标签替换
options.Data.Set("nextTick", "$");
options.Data.Set("replaceDto", replaceDto);
options.Data.Set("options", dto.GenOptions);
options.Data.Set("genTable", dto.GenTable);
//options.Data.Set("btns", dto.CheckedBtn);
options.Data.Set("showCustomInput", showCustomInput);
options.Data.Set("tool", new CodeGeneratorTool());
options.Data.Set("codeTool", new CodeGenerateTemplate());
options.EnableCache = true;
//...其它数据
});
}
#region
/// <summary>
/// 模板用
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool CheckInputDtoNoField(string str)
{
return GenConstants.inputDtoNoField.Any(f => f.Contains(str, StringComparison.OrdinalIgnoreCase));
}
public static bool CheckTree(GenTable genTable, string csharpField)
{
return (genTable.TplCategory.Equals("tree", StringComparison.OrdinalIgnoreCase) && genTable?.Options?.TreeParentCode != null && csharpField.Equals(genTable?.Options?.TreeParentCode));
}
#endregion
}
}

View File

@ -0,0 +1,70 @@
using Infrastructure;
using Infrastructure.Extensions;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
namespace ARW.CodeGenerator
{
/// <summary>
/// 代码生成数据库连接
/// </summary>
public class DbProvider
{
protected static SqlSugarClient CodeDb;
/// <summary>
/// 获取动态连接字符串
/// </summary>
/// <param name="dbName">数据库名</param>
/// <returns></returns>
public SqlSugarClient GetSugarDbContext(string dbName = "")
{
string connStr = AppSettings.GetConfig(GenConstants.Gen_conn);
int dbType = AppSettings.GetAppConfig(GenConstants.Gen_conn_dbType, 0);
if (!string.IsNullOrEmpty(dbName))
{
string replaceStr = GetValue(connStr, "Database=", ";");
string replaceStr2 = GetValue(connStr, "Initial Catalog=", ";");
if (replaceStr.IsNotEmpty())
{
connStr = connStr.Replace(replaceStr, dbName, StringComparison.OrdinalIgnoreCase);
}
if (replaceStr2.IsNotEmpty())
{
connStr = connStr.Replace(replaceStr2, dbName, StringComparison.OrdinalIgnoreCase);
}
}
var db = new SqlSugarClient(new List<ConnectionConfig>()
{
new ConnectionConfig(){
ConnectionString = connStr,
DbType = (DbType)dbType,
IsAutoCloseConnection = true,//开启自动释放模式和EF原理一样
InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
},
});
CodeDb = db;
return db;
}
/// <summary>
/// 获得字符串中开始和结束字符串中间得值
/// </summary>
/// <param name="str">字符串</param>
/// <param name="s">开始</param>
/// <param name="e">结束</param>
/// <returns></returns>
public static string GetValue(string str, string s, string e)
{
Regex rg = new Regex("(?<=(" + s + "))[.\\s\\S]*?(?=(" + e + "))", RegexOptions.Multiline | RegexOptions.Singleline);
return rg.Match(str).Value;
}
}
}

View File

@ -0,0 +1,190 @@
using JinianNet.JNTemplate;
using System;
using System.IO;
using System.IO.Compression;
using System.Runtime.InteropServices;
namespace ARW.CodeGenerator
{
public class FileHelper
{
/// <summary>
/// 创建文件夹
/// </summary>
/// <param name="path"></param>
/// <returns></returns>
public static bool CreateDirectory(string path)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
path = path.Replace("\\", "/").Replace("//", "/");
}
try
{
if (!Directory.Exists(path))
{
DirectoryInfo info = Directory.CreateDirectory(path);
Console.WriteLine("不存在创建文件夹" + info);
}
}
catch (Exception ex)
{
Console.WriteLine($"创建文件夹出错了,{ex.Message}");
return false;
}
return true;
}
/// <summary>
/// 写文件
/// </summary>
/// <param name="path">完整路径带扩展名的</param>
/// <param name="content"></param>
public static void WriteAndSave(string path, string content)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
path = path.Replace("\\", "/").Replace("//", "/");
}
if (!Directory.Exists(Path.GetDirectoryName(path)))
{
Directory.CreateDirectory(Path.GetDirectoryName(path));
}
Console.WriteLine("写入文件:" + path);
try
{
//实例化一个文件流--->与写入文件相关联
using var fs = new FileStream(path, FileMode.Create, FileAccess.Write);
//实例化一个StreamWriter-->与fs相关联
using var sw = new StreamWriter(fs);
//开始写入
sw.Write(content);
//清空缓冲区
sw.Flush();
//关闭流
sw.Close();
fs.Close();
}
catch (Exception ex)
{
Console.WriteLine("写入文件出错了:" + ex.Message);
}
}
/// <summary>
/// 从代码模板中读取内容
/// </summary>
/// <param name="templateName">模板名称应包括文件扩展名称。比如template.txt</param>
/// <returns></returns>
public static string ReadTemplate(string tplName)
{
string path = Environment.CurrentDirectory;
string fullName = Path.Combine(path, "wwwroot", "CodeGenTemplate", tplName);
Console.WriteLine("开始读取模板=" + fullName);
string temp = fullName;
string str = "";
if (!File.Exists(temp))
{
return str;
}
StreamReader sr = null;
try
{
sr = new StreamReader(temp);
str = sr.ReadToEnd(); // 读取文件
}
catch (Exception ex)
{
Console.WriteLine($"读取模板出错了{ex.Message}");
}
sr?.Close();
sr?.Dispose();
return str;
}
public static ITemplate ReadJtTemplate(string tplName)
{
string path = Environment.CurrentDirectory;
string fullName = Path.Combine(path, "wwwroot", "CodeGenTemplate", tplName);
if (File.Exists(fullName))
{
return Engine.LoadTemplate(fullName);
}
return null;
}
/// <summary>
/// 压缩代码
/// </summary>
/// <param name="zipPath"></param>
/// <param name="genCodePath"></param>
/// <param name="zipFileName">压缩后的文件名</param>
/// <returns></returns>
public static bool ZipGenCode(string zipPath, string genCodePath,string zipFileName)
{
if (string.IsNullOrEmpty(zipPath)) return false;
try
{
CreateDirectory(genCodePath);
string zipFileFullName = Path.Combine(zipPath, zipFileName);
if (File.Exists(zipFileFullName))
{
File.Delete(zipFileFullName);
}
ZipFile.CreateFromDirectory(genCodePath, zipFileFullName);
DeleteDirectory(genCodePath);
return true;
}
catch (Exception ex)
{
Console.WriteLine("压缩文件出错。" + ex.Message);
return false;
}
}
/// <summary>
/// 删除指定目录下的所有文件及文件夹(保留目录)
/// </summary>
/// <param name="file">文件目录</param>
public static void DeleteDirectory(string file)
{
try
{
//判断文件夹是否还存在
if (Directory.Exists(file))
{
DirectoryInfo fileInfo = new DirectoryInfo(file);
//去除文件夹的只读属性
fileInfo.Attributes = FileAttributes.Normal & FileAttributes.Directory;
foreach (string f in Directory.GetFileSystemEntries(file))
{
if (File.Exists(f))
{
//去除文件的只读属性
File.SetAttributes(file, FileAttributes.Normal);
//如果有子文件删除文件
File.Delete(f);
}
else
{
//循环递归删除子文件夹
DeleteDirectory(f);
}
}
//删除空文件夹
Directory.Delete(file);
}
}
catch (Exception ex) // 异常处理
{
Console.WriteLine("代码生成异常" + ex.Message);
}
}
}
}

View File

@ -0,0 +1,144 @@

namespace ARW.CodeGenerator
{
/// <summary>
/// 代码生成常量
/// </summary>
public class GenConstants
{
public static string Gen_conn = "gen:conn";
public static string Gen_conn_dbType = "gen:dbType";
public static string Gen_author = "gen:author";
public static string Gen_autoPre = "gen:autoPre";
public static string Gen_tablePrefix = "gen:tablePrefix";
/// <summary>
/// InputDto输入实体是不包含字段
/// </summary>
public static readonly string[] inputDtoNoField = new string[] { "createTime", "updateTime", "addtime", "create_time", "update_time" };
/// <summary>
/// 图片字段
/// </summary>
public static readonly string[] imageFiled = new string[] { "icon", "img", "image", "url", "pic", "photo", "avatar" };
/// <summary>
/// 下拉框字段
/// </summary>
public static readonly string[] selectFiled = new string[] { "status", "type", "state", "sex", "gender" };
/// <summary>
/// 单选按钮字段
/// </summary>
public static readonly string[] radioFiled = new string[] { "status", "state", "is"};
/** 单表(增删改查) */
public static string TPL_CRUD = "crud";
/** 树表(增删改查) */
public static string TPL_TREE = "tree";
/** 主子表(增删改查) */
public static string TPL_SUB = "sub";
/** 树编码字段 */
public static string TREE_CODE = "treeCode";
/** 树父编码字段 */
public static string TREE_PARENT_CODE = "treeParentCode";
/** 树名称字段 */
public static string TREE_NAME = "treeName";
/** 上级菜单ID字段 */
public static string PARENT_MENU_ID = "parentMenuId";
/** 上级菜单名称字段 */
public static string PARENT_MENU_NAME = "parentMenuName";
/** 数据库字符串类型 */
public static string[] COLUMNTYPE_STR = { "char", "varchar", "nvarchar", "varchar2" };
/** 数据库文本类型 */
public static string[] COLUMNTYPE_TEXT = { "tinytext", "text", "mediumtext", "longtext" };
/** 数据库时间类型 */
public static string[] COLUMNTYPE_TIME = { "datetime", "time", "date", "timestamp" };
/** 页面不需要编辑字段 */
public static string[] COLUMNNAME_NOT_EDIT = { "id", "create_by", "create_time", "delFlag" };
/** 页面不需要显示的列表字段 */
public static string[] COLUMNNAME_NOT_ARWST = { "create_by", "create_time", "delFlag", "update_by",
"update_time" , "password"};
/** 页面不需要查询字段 */
public static string[] COLUMNNAME_NOT_QUERY = { "id", "create_by", "create_time", "delFlag", "update_by",
"update_time", "remark" };
/** Entity基类字段 */
public static string[] BASE_ENTITY = { "createBy", "createTime", "updateBy", "updateTime", "remark" };
/** Tree基类字段 */
public static string[] TREE_ENTITY = { "parentName", "parentId", "orderNum", "ancestors", "children" };
/** 文本框 */
public static string HTML_INPUT = "input";
/** 数字框 */
public static string HTML_INPUT_NUMBER = "inputNumber";
/** 文本域 */
public static string HTML_TEXTAREA = "textarea";
/** 下拉框 */
public static string HTML_SELECT = "select";
/** 单选框 */
public static string HTML_RADIO = "radio";
/** 复选框 */
public static string HTML_CHECKBOX = "checkbox";
/** 日期控件 */
public static string HTML_DATETIME = "datetime";
/** 图片上传控件 */
public static string HTML_IMAGE_UPLOAD = "imageUpload";
/** 文件上传控件 */
public static string HTML_FILE_UPLOAD = "fileUpload";
/** 富文本控件 */
public static string HTML_EDITOR = "editor";
// 自定义排序
public static string HTML_SORT = "sort";
/// <summary>
/// 自定义输入框
/// </summary>
public static string HTML_CUSTOM_INPUT = "customInput";
//颜色选择器
public static string HTML_COLORPICKER = "colorPicker";
//switch开关
public static string HTML_SWITCH { get; set; }
/** 字符串类型 */
public static string TYPE_STRING = "string";
/** 整型 */
public static string TYPE_INT = "int";
/** 长整型 */
public static string TYPE_LONG = "long";
/** 浮点型 */
public static string TYPE_DOUBLE = "Double";
/** 时间类型 */
public static string TYPE_DATE = "DateTime";
/** 模糊查询 */
public static string QUERY_ARWKE = "ARWKE";
/** 需要 */
public static string REQUIRE = "1";
}
}

View File

@ -0,0 +1,71 @@
using System.Collections.Generic;
using ARW.Model.System.Generate;
namespace ARW.CodeGenerator.Model
{
public class GenerateDto
{
/// <summary>
/// vue版本
/// </summary>
public int VueVersion { get; set; }
public long TableId { get; set; }
/// <summary>
/// 是否预览代码
/// </summary>
public bool IsPreview { get; set; }
/// <summary>
/// 生成代码的数据库类型 0、mysql 1、sqlserver
/// </summary>
public int DbType { get; set; }
/// <summary>
/// 生成的按钮功能
/// </summary>
public int[] CheckedBtn { get; set; } = System.Array.Empty<int>();
public GenTable GenTable { get; set; }
public CodeGenerateOption GenOptions { get; set; }
#region
/// <summary>
/// 代码模板预览存储路径存放
/// </summary>
public List<GenCode> GenCodes { get; set; } = new List<GenCode>();
/// <summary>
/// 代码生成路径
/// </summary>
public string GenCodePath { get; set; } = string.Empty;
/// <summary>
/// 代码生成压缩包路径
/// </summary>
public string ZipPath { get; set; }
/// <summary>
/// 代码生成压缩包名称
/// </summary>
public string ZipFileName { get; set; }
/// <summary>
/// 生成代码方式0zip压缩包 1自定义路径
/// </summary>
public string GenType { get; set; }
public string GenPath { get; set; } = "";
/// <summary>
/// vue代码路径
/// </summary>
public string VueParentPath { get; set; }
#endregion
}
public class GenCode
{
public int Type { get; set; }
public string Title { get; set; }
public string Path { get; set; }
public string Content { get; set; }
public GenCode(int type, string title, string path, string content)
{
Type = type;
Title = title;
Path = path;
Content = content;
}
}
}

View File

@ -0,0 +1,59 @@
using System;
namespace ARW.CodeGenerator.Model
{
public class ReplaceDto
{
/// <summary>
/// 主键字段
/// </summary>
public string PKName { get; set; }
/// <summary>
/// 首字母小写主键
/// </summary>
public string FistLowerPk{ get; set; }
/// <summary>
/// 主键类型
/// </summary>
public string PKType { get; set; }
/// <summary>
/// 控制器权限
/// </summary>
public string PermissionPrefix { get; set; }
/// <summary>
/// C#类名
/// </summary>
public string ModelTypeName { get; set; }
//vue、api
//public string VueViewFormResetHtml { get; set; }
/// <summary>
/// 前端列表查询html
/// </summary>
public string VueViewListHtml { get; set; }
/// <summary>
/// 前端添加、编辑表格html
/// </summary>
public string VueViewFormHtml { get; set; }
/// <summary>
/// 前端搜索表单html
/// </summary>
public string VueQueryFormHtml { get; set; }
/// <summary>
/// 查询条件
/// </summary>
public string QueryCondition { get; set; } = "";
public bool ShowBtnExport { get; set; }
public bool ShowBtnAdd { get; set; }
public bool ShowBtnEdit { get; set; }
public bool ShowBtnDelete { get; set; }
public bool ShowBtnView { get; set; }
/// <summary>
/// 上传URL data
/// </summary>
//public string VueUploadUrl { get; set; }
public int UploadFile { get; set; } = 0;
public string Author { get; set; }
public string AddTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
}
}

View File

@ -0,0 +1,68 @@
using SqlSugar;
using System.Collections.Generic;
using System.Linq;
using ARW.Model;
namespace ARW.CodeGenerator.Service
{
public class CodeGeneraterService : DbProvider
{
/// <summary>
/// 获取所有数据库名
/// </summary>
/// <returns></returns>
public List<string> GetAllDataBases()
{
var db = GetSugarDbContext();
var templist = db.DbMaintenance.GetDataBaseList(db);
return templist;
}
/// <summary>
/// 获取所有表
/// </summary>
/// <param name="dbName"></param>
/// <param name="tableName"></param>
/// <param name="pager"></param>
/// <returns></returns>
public List<DbTableInfo> GetAllTables(string dbName, string tableName, PagerInfo pager)
{
var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
if (!string.IsNullOrEmpty(tableName))
{
tableList = tableList.Where(f => f.Name.ToLower().Contains(tableName.ToLower())).ToList();
}
//tableList = tableList.Where(f => !new string[] { "gen", "sys_" }.Contains(f.Name)).ToList();
pager.TotalNum = tableList.Count;
return tableList.Skip(pager.PageSize * (pager.PageNum - 1)).Take(pager.PageSize).OrderBy(f => f.Name).ToList();
}
/// <summary>
/// 获取单表数据
/// </summary>
/// <param name="dbName"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public DbTableInfo GetTableInfo(string dbName, string tableName)
{
var tableList = GetSugarDbContext(dbName).DbMaintenance.GetTableInfoList(true);
if (!string.IsNullOrEmpty(tableName))
{
return tableList.Where(f => f.Name.Equals(tableName, System.StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
}
return null;
}
/// <summary>
/// 获取列信息
/// </summary>
/// <param name="dbName"></param>
/// <param name="tableName"></param>
/// <returns></returns>
public List<DbColumnInfo> GetColumnInfo(string dbName, string tableName)
{
return GetSugarDbContext(dbName).DbMaintenance.GetColumnInfosByTableName(tableName, true);
}
}
}

View File

@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>ARW.Common</AssemblyName>
<RootNamespace>ARW.Common</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Aliyun.OSS.SDK.NetCore" Version="2.13.0" />
<PackageReference Include="CSRedisCore" Version="3.8.3" />
<PackageReference Include="EPPlus" Version="6.0.5" />
<PackageReference Include="MailKit" Version="3.3.0" />
<PackageReference Include="Microsoft.Extensions.Caching.Memory" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Infrastructure\Infrastructure.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,67 @@
using Aliyun.OSS;
using Aliyun.OSS.Common;
using Infrastructure;
using System;
using System.IO;
namespace ARW.Common
{
public class AliyunOssHelper
{
static string accessKeyId = AppSettings.GetConfig("AARWYUN_OSS:KEY");
static string accessKeySecret = AppSettings.GetConfig("AARWYUN_OSS:SECRET");
static string endpoint = AppSettings.GetConfig("AARWYUN_OSS:REGIONID");
static string bucketName1 = AppSettings.GetConfig("AARWYUN_OSS:bucketName");
/// <summary>
/// 上传到阿里云
/// </summary>
/// <param name="filestreams"></param>
/// <param name="dirPath">存储路径 eg upload/2020/01/01/xxx.png</param>
/// <param name="bucketName">存储桶 如果为空默认取配置文件</param>
public static System.Net.HttpStatusCode PutObjectFromFile(Stream filestreams, string dirPath, string bucketName = "")
{
OssClient client = new(endpoint, accessKeyId, accessKeySecret);
if (string.IsNullOrEmpty(bucketName)) { bucketName = bucketName1; }
try
{
dirPath = dirPath.Replace("\\", "/");
PutObjectResult putObjectResult = client.PutObject(bucketName, dirPath, filestreams);
// Console.WriteLine("Put object:{0} succeeded", directory);
return putObjectResult.HttpStatusCode;
}
catch (OssException ex)
{
Console.WriteLine("Failed with error code: {0}; Error info: {1}. \nRequestID:{2}\tHostID:{3}",
ex.ErrorCode, ex.Message, ex.RequestId, ex.HostId);
}
catch (Exception ex)
{
Console.WriteLine("Failed with error info: {0}", ex.Message);
}
return System.Net.HttpStatusCode.BadRequest;
}
/// <summary>
/// 删除资源
/// </summary>
/// <param name="dirPath"></param>
/// <param name="bucketName"></param>
/// <returns></returns>
public static System.Net.HttpStatusCode DeleteFile(string dirPath, string bucketName = "")
{
if (string.IsNullOrEmpty(bucketName)) { bucketName = bucketName1; }
try
{
OssClient client = new(endpoint, accessKeyId, accessKeySecret);
DeleteObjectResult putObjectResult = client.DeleteObject(bucketName, dirPath);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
return System.Net.HttpStatusCode.BadRequest;
}
}
}

View File

@ -0,0 +1,111 @@
using Microsoft.Extensions.Caching.Memory;
using System;
namespace ARW.Common
{
public class CacheHelper
{
public static MemoryCache Cache { get; set; }
static CacheHelper()
{
Cache = new MemoryCache(new MemoryCacheOptions
{
//SizeLimit = 1024
});
}
/// <summary>
/// 获取缓存
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="key"></param>
/// <returns></returns>
public static T GetCache<T>(string key) where T : class
{
if (key == null)
throw new ArgumentNullException(nameof(key));
//return Cache.Get(key) as T; //或者
return Cache.Get<T>(key);
}
/// <summary>
/// 获取缓存
/// </summary>
/// <param name="CacheKey"></param>
/// <returns></returns>
public static object GetCache(string CacheKey)
{
return Cache.Get<object>(CacheKey);
}
public static object Get(string CacheKey)
{
return Cache.Get(CacheKey);
}
/// <summary>
/// 设置缓存,永久缓存
/// </summary>
/// <param name="CacheKey">key</param>
/// <param name="objObject">值</param>
public static object SetCache(string CacheKey, object objObject)
{
return Cache.Set(CacheKey, objObject);
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="CacheKey">key</param>
/// <param name="objObject">值</param>
/// <param name="Timeout">过期时间(分钟)</param>
public static object SetCache(string CacheKey, object objObject, int Timeout)
{
return Cache.Set(CacheKey, objObject, DateTime.Now.AddMinutes(Timeout));
}
/// <summary>
/// 设置缓存(秒)
/// </summary>
/// <param name="CacheKey">key</param>
/// <param name="objObject">值</param>
/// <param name="Timeout">过期时间(秒)</param>
public static void SetCaches(string CacheKey, object objObject, int Timeout)
{
Cache.Set(CacheKey, objObject, DateTime.Now.AddSeconds(Timeout));
}
/// <summary>
/// 设置缓存
/// </summary>
/// <param name="CacheKey">key</param>
/// <param name="objObject">值</param>
/// <param name="absoluteExpiration">过期时间</param>
/// <param name="slidingExpiration">过期时间间隔</param>
public static object SetCache(string CacheKey, object objObject, DateTime absoluteExpiration, TimeSpan slidingExpiration)
{
return Cache.Set(CacheKey, objObject, absoluteExpiration);
}
/// <summary>
/// 设定绝对的过期时间
/// </summary>
/// <param name="CacheKey"></param>
/// <param name="objObject"></param>
/// <param name="Seconds">超过多少秒后过期</param>
public static void SetCacheDateTime(string CacheKey, object objObject, long Seconds)
{
Cache.Set(CacheKey, objObject, DateTime.Now.AddSeconds(Seconds));
}
/// <summary>
/// 删除缓存
/// </summary>
/// <param name="key">key</param>
public static void Remove(string key)
{
Cache.Remove(key);
}
}
}

View File

@ -0,0 +1,17 @@
using CSRedis;
using Infrastructure;
namespace ARW.Common.Cache
{
public class RedisServer
{
public static CSRedisClient Cache;
public static CSRedisClient Session;
public static void Initalize()
{
Cache = new CSRedisClient(AppSettings.GetConfig("RedisServer:Cache"));
Session = new CSRedisClient(AppSettings.GetConfig("RedisServer:Session"));
}
}
}

View File

@ -0,0 +1,829 @@
/// <summary>
/// 类说明HttpHelper类用来实现Http访问Post或者Get方式的直接访问带Cookie的带证书的等方式可以设置代理
/// 重要提示:请不要自行修改本类,如果因为你自己修改后将无法升级到新版本。如果确实有什么问题请到官方网站提建议,
/// 我们一定会及时修改
/// 编码日期2011-09-20
/// 编 码 人:苏飞
/// 联系方式361983679
/// 官方网址http://www.sufeinet.com/thread-3-1-1.html
/// 修改日期2018-11-06
/// 版 本 号1.9.9
/// </summary>
using System;
using System.Collections.Generic;
using System.Text;
using System.Net;
using System.IO;
using System.Text.RegularExpressions;
using System.IO.Compression;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Linq;
using System.Net.Cache;
namespace ARW.Common
{
/// <summary>
/// Http连接操作帮助类
/// </summary>
public class CrawlerHelper
{
#region
//默认的编码
private Encoding encoding = Encoding.Default;
//Post数据编码
private Encoding postencoding = Encoding.Default;
//HttpWebRequest对象用来发起请求
private HttpWebRequest request = null;
//获取影响流的数据对象
private HttpWebResponse response = null;
//设置本地的出口ip和端口
private IPEndPoint _IPEndPoint = null;
#endregion
#region Public
/// <summary>
/// 根据相传入的数据,得到相应页面数据
/// </summary>
/// <param name="item">参数类对象</param>
/// <returns>返回HttpResult类型</returns>
public HttpResult GetHtml(HttpItem item)
{
//返回参数
HttpResult result = new HttpResult();
try
{
//准备参数
SetRequest(item);
}
catch (Exception ex)
{
//配置参数时出错
return new HttpResult() { Cookie = string.Empty, Header = null, Html = ex.Message, StatusDescription = "配置参数时出错:" + ex.Message };
}
try
{
//请求数据
using (response = (HttpWebResponse)request.GetResponse())
{
GetData(item, result);
}
}
catch (WebException ex)
{
if (ex.Response != null)
{
using (response = (HttpWebResponse)ex.Response)
{
GetData(item, result);
}
}
else
{
result.Html = ex.Message;
}
}
catch (Exception ex)
{
result.Html = ex.Message;
}
if (item.IsToLower) result.Html = result.Html.ToLower();
//重置requestresponse为空
if (item.IsReset)
{
request = null;
response = null;
}
return result;
}
#endregion
#region GetData
/// <summary>
/// 获取数据的并解析的方法
/// </summary>
/// <param name="item"></param>
/// <param name="result"></param>
private void GetData(HttpItem item, HttpResult result)
{
if (response == null)
{
return;
}
#region base
//获取StatusCode
result.StatusCode = response.StatusCode;
//获取StatusDescription
result.StatusDescription = response.StatusDescription;
//获取Headers
result.Header = response.Headers;
//获取最后访问的URl
result.ResponseUri = response.ResponseUri.ToString();
//获取CookieCollection
if (response.Cookies != null) result.CookieCollection = response.Cookies;
//获取set-cookie
if (response.Headers["set-cookie"] != null) result.Cookie = response.Headers["set-cookie"];
#endregion
#region byte
//处理网页Byte
byte[] ResponseByte = GetByte();
#endregion
#region Html
if (ResponseByte != null && ResponseByte.Length > 0)
{
//设置编码
SetEncoding(item, result, ResponseByte);
//得到返回的HTML
result.Html = encoding.GetString(ResponseByte);
}
else
{
//没有返回任何Html代码
result.Html = string.Empty;
}
#endregion
}
/// <summary>
/// 设置编码
/// </summary>
/// <param name="item">HttpItem</param>
/// <param name="result">HttpResult</param>
/// <param name="ResponseByte">byte[]</param>
private void SetEncoding(HttpItem item, HttpResult result, byte[] ResponseByte)
{
//是否返回Byte类型数据
if (item.ResultType == ResultType.Byte) result.ResultByte = ResponseByte;
//从这里开始我们要无视编码了
if (encoding == null)
{
Match meta = Regex.Match(Encoding.Default.GetString(ResponseByte), "<meta[^<]*charset=([^<]*)[\"']", RegexOptions.IgnoreCase);
string c = string.Empty;
if (meta != null && meta.Groups.Count > 0)
{
c = meta.Groups[1].Value.ToLower().Trim();
}
if (c.Length > 2)
{
try
{
encoding = Encoding.GetEncoding(c.Replace("\"", string.Empty).Replace("'", "").Replace(";", "").Replace("iso-8859-1", "gbk").Trim());
}
catch
{
if (string.IsNullOrEmpty(response.CharacterSet))
{
encoding = Encoding.UTF8;
}
else
{
encoding = Encoding.GetEncoding(response.CharacterSet);
}
}
}
else
{
if (string.IsNullOrEmpty(response.CharacterSet))
{
encoding = Encoding.UTF8;
}
else
{
encoding = Encoding.GetEncoding(response.CharacterSet);
}
}
}
}
/// <summary>
/// 提取网页Byte
/// </summary>
/// <returns></returns>
private byte[] GetByte()
{
byte[] ResponseByte = null;
using (MemoryStream _stream = new MemoryStream())
{
//GZIIP处理
if (response.ContentEncoding != null && response.ContentEncoding.Equals("gzip", StringComparison.InvariantCultureIgnoreCase))
{
//开始读取流并设置编码方式
new GZipStream(response.GetResponseStream(), CompressionMode.Decompress).CopyTo(_stream, 10240);
}
else
{
//开始读取流并设置编码方式
response.GetResponseStream().CopyTo(_stream, 10240);
}
//获取Byte
ResponseByte = _stream.ToArray();
}
return ResponseByte;
}
#endregion
#region SetRequest
/// <summary>
/// 为请求准备参数
/// </summary>
///<param name="item">参数列表</param>
private void SetRequest(HttpItem item)
{
// 验证证书
SetCer(item);
if (item.IPEndPoint != null)
{
_IPEndPoint = item.IPEndPoint;
//设置本地的出口ip和端口
request.ServicePoint.BindIPEndPointDelegate = new BindIPEndPoint(BindIPEndPointCallback);
}
//设置Header参数
if (item.Header != null && item.Header.Count > 0) foreach (string key in item.Header.AllKeys)
{
request.Headers.Add(key, item.Header[key]);
}
// 设置代理
SetProxy(item);
if (item.ProtocolVersion != null) request.ProtocolVersion = item.ProtocolVersion;
request.ServicePoint.Expect100Continue = item.Expect100Continue;
//请求方式Get或者Post
request.Method = item.Method;
request.Timeout = item.Timeout;
request.KeepAlive = item.KeepAlive;
request.ReadWriteTimeout = item.ReadWriteTimeout;
if (!string.IsNullOrWhiteSpace(item.Host))
{
request.Host = item.Host;
}
if (item.IfModifiedSince != null) request.IfModifiedSince = Convert.ToDateTime(item.IfModifiedSince);
//Accept
request.Accept = item.Accept;
//ContentType返回类型
request.ContentType = item.ContentType;
//UserAgent客户端的访问类型包括浏览器版本和操作系统信息
request.UserAgent = item.UserAgent;
// 编码
encoding = item.Encoding;
//设置安全凭证
request.Credentials = item.ICredentials;
//设置Cookie
SetCookie(item);
//来源地址
request.Referer = item.Referer;
//是否执行跳转功能
request.AllowAutoRedirect = item.Allowautoredirect;
if (item.MaximumAutomaticRedirections > 0)
{
request.MaximumAutomaticRedirections = item.MaximumAutomaticRedirections;
}
//设置Post数据
SetPostData(item);
//设置最大连接
if (item.Connectionlimit > 0) request.ServicePoint.ConnectionLimit = item.Connectionlimit;
}
/// <summary>
/// 设置证书
/// </summary>
/// <param name="item"></param>
private void SetCer(HttpItem item)
{
if (!string.IsNullOrWhiteSpace(item.CerPath))
{
//这一句一定要写在创建连接的前面。使用回调的方法进行证书验证。
ServicePointManager.ServerCertificateValidationCallback = new System.Net.Security.RemoteCertificateValidationCallback(CheckValidationResult);
//初始化对像并设置请求的URL地址
request = (HttpWebRequest)WebRequest.Create(item.URL);
SetCerList(item);
//将证书添加到请求里
request.ClientCertificates.Add(new X509Certificate(item.CerPath));
}
else
{
//初始化对像并设置请求的URL地址
request = (HttpWebRequest)WebRequest.Create(item.URL);
SetCerList(item);
}
}
/// <summary>
/// 设置多个证书
/// </summary>
/// <param name="item"></param>
private void SetCerList(HttpItem item)
{
if (item.ClentCertificates != null && item.ClentCertificates.Count > 0)
{
foreach (X509Certificate c in item.ClentCertificates)
{
request.ClientCertificates.Add(c);
}
}
}
/// <summary>
/// 设置Cookie
/// </summary>
/// <param name="item">Http参数</param>
private void SetCookie(HttpItem item)
{
if (!string.IsNullOrEmpty(item.Cookie)) request.Headers[HttpRequestHeader.Cookie] = item.Cookie;
//设置CookieCollection
if (item.ResultCookieType == ResultCookieType.CookieCollection)
{
request.CookieContainer = new CookieContainer();
if (item.CookieCollection != null && item.CookieCollection.Count > 0)
request.CookieContainer.Add(item.CookieCollection);
}
}
/// <summary>
/// 设置Post数据
/// </summary>
/// <param name="item">Http参数</param>
private void SetPostData(HttpItem item)
{
//验证在得到结果时是否有传入数据
if (!request.Method.Trim().ToLower().Contains("get"))
{
if (item.PostEncoding != null)
{
postencoding = item.PostEncoding;
}
byte[] buffer = null;
//写入Byte类型
if (item.PostDataType == PostDataType.Byte && item.PostdataByte != null && item.PostdataByte.Length > 0)
{
//验证在得到结果时是否有传入数据
buffer = item.PostdataByte;
}//写入文件
else if (item.PostDataType == PostDataType.FilePath && !string.IsNullOrWhiteSpace(item.Postdata))
{
StreamReader r = new StreamReader(item.Postdata, postencoding);
buffer = postencoding.GetBytes(r.ReadToEnd());
r.Close();
} //写入字符串
else if (!string.IsNullOrWhiteSpace(item.Postdata))
{
buffer = postencoding.GetBytes(item.Postdata);
}
if (buffer != null)
{
request.ContentLength = buffer.Length;
request.GetRequestStream().Write(buffer, 0, buffer.Length);
}
else
{
request.ContentLength = 0;
}
}
}
/// <summary>
/// 设置代理
/// </summary>
/// <param name="item">参数对象</param>
private void SetProxy(HttpItem item)
{
bool isIeProxy = false;
if (!string.IsNullOrWhiteSpace(item.ProxyIp))
{
isIeProxy = item.ProxyIp.ToLower().Contains("ieproxy");
}
if (!string.IsNullOrWhiteSpace(item.ProxyIp) && !isIeProxy)
{
//设置代理服务器
if (item.ProxyIp.Contains(":"))
{
string[] plist = item.ProxyIp.Split(':');
WebProxy myProxy = new WebProxy(plist[0].Trim(), Convert.ToInt32(plist[1].Trim()));
//建议连接
myProxy.Credentials = new NetworkCredential(item.ProxyUserName, item.ProxyPwd);
//给当前请求对象
request.Proxy = myProxy;
}
else
{
WebProxy myProxy = new WebProxy(item.ProxyIp, false);
//建议连接
myProxy.Credentials = new NetworkCredential(item.ProxyUserName, item.ProxyPwd);
//给当前请求对象
request.Proxy = myProxy;
}
}
else if (isIeProxy)
{
//设置为IE代理
}
else
{
request.Proxy = item.WebProxy;
}
}
#endregion
#region private main
/// <summary>
/// 回调验证证书问题
/// </summary>
/// <param name="sender">流对象</param>
/// <param name="certificate">证书</param>
/// <param name="chain">X509Chain</param>
/// <param name="errors">SslPolicyErrors</param>
/// <returns>bool</returns>
private bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }
/// <summary>
/// 通过设置这个属性可以在发出连接的时候绑定客户端发出连接所使用的IP地址。
/// </summary>
/// <param name="servicePoint"></param>
/// <param name="remoteEndPoint"></param>
/// <param name="retryCount"></param>
/// <returns></returns>
private IPEndPoint BindIPEndPointCallback(ServicePoint servicePoint, IPEndPoint remoteEndPoint, int retryCount)
{
return _IPEndPoint;//端口号
}
#endregion
}
#region public calss
/// <summary>
/// Http请求参考类
/// </summary>
public class HttpItem
{
/// <summary>
/// 请求URL必须填写
/// </summary>
public string URL { get; set; }
string _Method = "GET";
/// <summary>
/// 请求方式默认为GET方式,当为POST方式时必须设置Postdata的值
/// </summary>
public string Method
{
get { return _Method; }
set { _Method = value; }
}
int _Timeout = 100000;
/// <summary>
/// 默认请求超时时间
/// </summary>
public int Timeout
{
get { return _Timeout; }
set { _Timeout = value; }
}
int _ReadWriteTimeout = 30000;
/// <summary>
/// 默认写入Post数据超时间
/// </summary>
public int ReadWriteTimeout
{
get { return _ReadWriteTimeout; }
set { _ReadWriteTimeout = value; }
}
/// <summary>
/// 设置Host的标头信息
/// </summary>
public string Host { get; set; }
Boolean _KeepAlive = true;
/// <summary>
/// 获取或设置一个值,该值指示是否与 Internet 资源建立持久性连接默认为true。
/// </summary>
public Boolean KeepAlive
{
get { return _KeepAlive; }
set { _KeepAlive = value; }
}
string _Accept = "text/html, application/xhtml+xml, */*";
/// <summary>
/// 请求标头值 默认为text/html, application/xhtml+xml, */*
/// </summary>
public string Accept
{
get { return _Accept; }
set { _Accept = value; }
}
string _ContentType = "text/html";
/// <summary>
/// 请求返回类型默认 text/html
/// </summary>
public string ContentType
{
get { return _ContentType; }
set { _ContentType = value; }
}
string _UserAgent = "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)";
/// <summary>
/// 客户端访问信息默认Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)
/// </summary>
public string UserAgent
{
get { return _UserAgent; }
set { _UserAgent = value; }
}
/// <summary>
/// 返回数据编码默认为NUll,可以自动识别,一般为utf-8,gbk,gb2312
/// </summary>
public Encoding Encoding { get; set; }
private PostDataType _PostDataType = PostDataType.String;
/// <summary>
/// Post的数据类型
/// </summary>
public PostDataType PostDataType
{
get { return _PostDataType; }
set { _PostDataType = value; }
}
/// <summary>
/// Post请求时要发送的字符串Post数据
/// </summary>
public string Postdata { get; set; }
/// <summary>
/// Post请求时要发送的Byte类型的Post数据
/// </summary>
public byte[] PostdataByte { get; set; }
/// <summary>
/// Cookie对象集合
/// </summary>
public CookieCollection CookieCollection { get; set; }
/// <summary>
/// 请求时的Cookie
/// </summary>
public string Cookie { get; set; }
/// <summary>
/// 来源地址,上次访问地址
/// </summary>
public string Referer { get; set; }
/// <summary>
/// 证书绝对路径
/// </summary>
public string CerPath { get; set; }
/// <summary>
/// 设置代理对象不想使用IE默认配置就设置为Null而且不要设置ProxyIp
/// </summary>
public WebProxy WebProxy { get; set; }
private Boolean isToLower = false;
/// <summary>
/// 是否设置为全文小写,默认为不转化
/// </summary>
public Boolean IsToLower
{
get { return isToLower; }
set { isToLower = value; }
}
private Boolean allowautoredirect = false;
/// <summary>
/// 支持跳转页面,查询结果将是跳转后的页面,默认是不跳转
/// </summary>
public Boolean Allowautoredirect
{
get { return allowautoredirect; }
set { allowautoredirect = value; }
}
private int connectionlimit = 1024;
/// <summary>
/// 最大连接数
/// </summary>
public int Connectionlimit
{
get { return connectionlimit; }
set { connectionlimit = value; }
}
/// <summary>
/// 代理Proxy 服务器用户名
/// </summary>
public string ProxyUserName { get; set; }
/// <summary>
/// 代理 服务器密码
/// </summary>
public string ProxyPwd { get; set; }
/// <summary>
/// 代理 服务IP,如果要使用IE代理就设置为ieproxy
/// </summary>
public string ProxyIp { get; set; }
private ResultType resulttype = ResultType.String;
/// <summary>
/// 设置返回类型String和Byte
/// </summary>
public ResultType ResultType
{
get { return resulttype; }
set { resulttype = value; }
}
private WebHeaderCollection header = new WebHeaderCollection();
/// <summary>
/// header对象
/// </summary>
public WebHeaderCollection Header
{
get { return header; }
set { header = value; }
}
/// <summary>
// 获取或设置用于请求的 HTTP 版本。返回结果:用于请求的 HTTP 版本。默认为 System.Net.HttpVersion.Version11。
/// </summary>
public Version ProtocolVersion { get; set; }
private Boolean _expect100continue = false;
/// <summary>
/// 获取或设置一个 System.Boolean 值,该值确定是否使用 100-Continue 行为。如果 POST 请求需要 100-Continue 响应,则为 true否则为 false。默认值为 true。
/// </summary>
public Boolean Expect100Continue
{
get { return _expect100continue; }
set { _expect100continue = value; }
}
/// <summary>
/// 设置509证书集合
/// </summary>
public X509CertificateCollection ClentCertificates { get; set; }
/// <summary>
/// 设置或获取Post参数编码,默认的为Default编码
/// </summary>
public Encoding PostEncoding { get; set; }
private ResultCookieType _ResultCookieType = ResultCookieType.String;
/// <summary>
/// Cookie返回类型,默认的是只返回字符串类型
/// </summary>
public ResultCookieType ResultCookieType
{
get { return _ResultCookieType; }
set { _ResultCookieType = value; }
}
private ICredentials _ICredentials = CredentialCache.DefaultCredentials;
/// <summary>
/// 获取或设置请求的身份验证信息。
/// </summary>
public ICredentials ICredentials
{
get { return _ICredentials; }
set { _ICredentials = value; }
}
/// <summary>
/// 设置请求将跟随的重定向的最大数目
/// </summary>
public int MaximumAutomaticRedirections { get; set; }
private DateTime? _IfModifiedSince = null;
/// <summary>
/// 获取和设置IfModifiedSince默认为当前日期和时间
/// </summary>
public DateTime? IfModifiedSince
{
get { return _IfModifiedSince; }
set { _IfModifiedSince = value; }
}
#region ip-port
private IPEndPoint _IPEndPoint = null;
/// <summary>
/// 设置本地的出口ip和端口
/// </summary>]
/// <example>
///item.IPEndPoint = new IPEndPoint(IPAddress.Parse("192.168.1.1"),80);
/// </example>
public IPEndPoint IPEndPoint
{
get { return _IPEndPoint; }
set { _IPEndPoint = value; }
}
#endregion
private bool _isReset = false;
/// <summary>
/// 是否重置request,response的值默认不重置当设置为True时request,response将被设置为Null
/// </summary>
public bool IsReset
{
get { return _isReset; }
set { _isReset = value; }
}
}
/// <summary>
/// Http返回参数类
/// </summary>
public class HttpResult
{
/// <summary>
/// Http请求返回的Cookie
/// </summary>
public string Cookie { get; set; }
/// <summary>
/// Cookie对象集合
/// </summary>
public CookieCollection CookieCollection { get; set; }
private string _html = string.Empty;
/// <summary>
/// 返回的String类型数据 只有ResultType.String时才返回数据其它情况为空
/// </summary>
public string Html
{
get { return _html; }
set { _html = value; }
}
/// <summary>
/// 返回的Byte数组 只有ResultType.Byte时才返回数据其它情况为空
/// </summary>
public byte[] ResultByte { get; set; }
/// <summary>
/// header对象
/// </summary>
public WebHeaderCollection Header { get; set; }
/// <summary>
/// 返回状态说明
/// </summary>
public string StatusDescription { get; set; }
/// <summary>
/// 返回状态码,默认为OK
/// </summary>
public HttpStatusCode StatusCode { get; set; }
/// <summary>
/// 最后访问的URl
/// </summary>
public string ResponseUri { get; set; }
/// <summary>
/// 获取重定向的URl
/// </summary>
public string RedirectUrl
{
get
{
try
{
if (Header != null && Header.Count > 0)
{
if (Header.AllKeys.Any(k => k.ToLower().Contains("location")))
{
string baseurl = Header["location"].ToString().Trim();
string locationurl = baseurl.ToLower();
if (!string.IsNullOrWhiteSpace(locationurl))
{
bool b = locationurl.StartsWith("http://") || locationurl.StartsWith("https://");
if (!b)
{
baseurl = new Uri(new Uri(ResponseUri), baseurl).AbsoluteUri;
}
}
return baseurl;
}
}
}
catch { }
return string.Empty;
}
}
}
/// <summary>
/// 返回类型
/// </summary>
public enum ResultType
{
/// <summary>
/// 表示只返回字符串 只有Html有数据
/// </summary>
String,
/// <summary>
/// 表示返回字符串和字节流 ResultByte和Html都有数据返回
/// </summary>
Byte
}
/// <summary>
/// Post的数据格式默认为string
/// </summary>
public enum PostDataType
{
/// <summary>
/// 字符串类型这时编码Encoding可不设置
/// </summary>
String,
/// <summary>
/// Byte类型需要设置PostdataByte参数的值编码Encoding可设置为空
/// </summary>
Byte,
/// <summary>
/// 传文件Postdata必须设置为文件的绝对路径必须设置Encoding的值
/// </summary>
FilePath
}
/// <summary>
/// Cookie返回类型
/// </summary>
public enum ResultCookieType
{
/// <summary>
/// 只返回字符串类型的Cookie
/// </summary>
String,
/// <summary>
/// CookieCollection格式的Cookie集合同时也返回String类型的cookie
/// </summary>
CookieCollection
}
#endregion
}

View File

@ -0,0 +1,156 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using OfficeOpenXml;
namespace ARW.Common
{
public class ExcelHelper<T> where T : new()
{
/// <summary>
/// 导入数据
/// </summary>
/// <param name="stream"></param>
/// <returns></returns>
public static IEnumerable<T> ImportData(Stream stream)
{
using ExcelPackage package = new(stream);
ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//读取第1个sheet
//获取表格的列数和行数
int colStart = worksheet.Dimension.Start.Column;
int colEnd = worksheet.Dimension.End.Column;
int rowStart = worksheet.Dimension.Start.Row;
int rowEnd = worksheet.Dimension.End.Row;
//int rowCount = worksheet.Dimension.Rows;
//int ColCount = worksheet.Dimension.Columns;
List<T> resultList = new();
List<PropertyInfo> propertyInfos = new();// new(typeof(T).GetProperties());
Dictionary<string, int> dictHeader = new();
for (int i = colStart; i < colEnd; i++)
{
var name = worksheet.Cells[rowStart, i].Value.ToString();
dictHeader[name] = i;
PropertyInfo propertyInfo = MapPropertyInfo(name);
if (propertyInfo != null)
{
propertyInfos.Add(propertyInfo);
}
}
for (int row = rowStart + 1; row <= rowEnd; row++)
{
T result = new();
foreach (PropertyInfo p in propertyInfos)
{
try
{
ExcelRange cell = worksheet.Cells[row, dictHeader[p.Name]];
if (cell.Value == null)
{
continue;
}
switch (p.PropertyType.Name.ToLower())
{
case "string":
p.SetValue(result, cell.GetValue<string>());
break;
case "int16":
p.SetValue(result, cell.GetValue<short>()); break;
case "int32":
p.SetValue(result, cell.GetValue<int>()); break;
case "int64":
p.SetValue(result, cell.GetValue<long>()); break;
case "decimal":
p.SetValue(result, cell.GetValue<decimal>());
break;
case "double":
p.SetValue(result, cell.GetValue<double>()); break;
case "datetime":
p.SetValue(result, cell.GetValue<DateTime>()); break;
case "boolean":
p.SetValue(result, cell.GetValue<bool>()); break;
case "char":
p.SetValue(result, cell.GetValue<string>()); break;
default:
break;
}
}
catch (KeyNotFoundException ex)
{
Console.WriteLine("未找到该列将继续循环," + ex.Message);
continue;
}
}
resultList.Add(result);
}
return resultList;
}
/// <summary>
/// 查找Excel列名对应的实体属性
/// </summary>
/// <param name="columnName"></param>
/// <returns></returns>
public static PropertyInfo MapPropertyInfo(string columnName)
{
PropertyInfo[] propertyList = GetProperties(typeof(T));
PropertyInfo propertyInfo = propertyList.Where(p => p.Name == columnName).FirstOrDefault();
if (propertyInfo != null)
{
return propertyInfo;
}
else
{
foreach (PropertyInfo tempPropertyInfo in propertyList)
{
System.ComponentModel.DescriptionAttribute[] attributes = (System.ComponentModel.DescriptionAttribute[])tempPropertyInfo.GetCustomAttributes(typeof(System.ComponentModel.DescriptionAttribute), false);
if (attributes.Length > 0)
{
if (attributes[0].Description == columnName)
{
return tempPropertyInfo;
}
}
}
}
return null;
}
/// <summary>
/// 得到类里面的属性集合
/// </summary>
/// <param name="type"></param>
/// <param name="columns"></param>
/// <returns></returns>
public static PropertyInfo[] GetProperties(Type type, string[] columns = null)
{
PropertyInfo[] properties = null;
properties = type.GetProperties();
if (columns != null && columns.Length > 0)
{
// 按columns顺序返回属性
var columnPropertyList = new List<PropertyInfo>();
foreach (var column in columns)
{
var columnProperty = properties.Where(p => p.Name == column).FirstOrDefault();
if (columnProperty != null)
{
columnPropertyList.Add(columnProperty);
}
}
return columnPropertyList.ToArray();
}
else
{
return properties;
}
}
}
}

View File

@ -0,0 +1,174 @@
using Infrastructure;
using MailKit.Net.Smtp;
using MimeKit;
using MimeKit.Text;
using System;
using System.Collections.Generic;
using System.IO;
namespace ARW.Common
{
public class MailHelper
{
/// <summary>
/// 发送人邮箱
/// </summary>
public string FromEmail { get; set; } = "";
/// <summary>
/// 发送人密码
/// </summary>
public string FromPwd { get; set; } = "";
/// <summary>
/// 发送协议
/// </summary>
public string Smtp { get; set; } = "smtp.qq.com";
/// <summary>
/// 协议端口
/// </summary>
public int Port { get; set; } = 587;
/// <summary>
/// 邮件签名
/// </summary>
public string Signature { get; set; }
/// <summary>
/// 是否使用SSL协议
/// </summary>
public bool UseSsl { get; set; } = false;
private readonly MailOptions mailOptions = new();
public MailHelper()
{
AppSettings.Bind("MailOptions", mailOptions);
FromEmail = mailOptions.From;
Smtp = mailOptions.Smtp;
FromPwd = mailOptions.Password;
Port = mailOptions.Port;
}
public MailHelper(string fromEmail, string smtp, int port, string fromPwd)
{
FromEmail = fromEmail;
Smtp = smtp;
FromPwd = fromPwd;
Port = port;
}
public MailHelper(string fromEmail, string fromPwd)
{
FromEmail = fromEmail;
FromPwd = fromPwd;
}
/// <summary>
/// 发送一个
/// </summary>
/// <param name="toAddress"></param>
/// <param name="subject"></param>
/// <param name="text"></param>
/// <param name="path"></param>
public void SendMail(string toAddress, string subject, string text, string path = "", string html = "")
{
IEnumerable<MailboxAddress> mailboxes = new List<MailboxAddress>() {
new MailboxAddress(toAddress, toAddress)
};
SendMail(mailboxes, subject, text, path, html);
}
/// <summary>
/// 发送多个邮箱
/// </summary>
/// <param name="toAddress"></param>
/// <param name="subject"></param>
/// <param name="text"></param>
/// <param name="path"></param>
public void SendMail(string[] toAddress, string subject, string text, string path = "", string html = "")
{
IList<MailboxAddress> mailboxes = new List<MailboxAddress>() { };
foreach (var item in toAddress)
{
mailboxes.Add(new MailboxAddress(item, item));
}
SendMail(mailboxes, subject, text, path, html);
}
/// <summary>
/// 发送邮件
/// </summary>
/// <param name="toAddress"></param>
/// <param name="subject">主题</param>
/// <param name="text"></param>
/// <param name="path">附件url地址</param>
/// <param name="html">网页HTML内容</param>
private void SendMail(IEnumerable<MailboxAddress> toAddress, string subject, string text, string path = "", string html = "")
{
MimeMessage message = new MimeMessage();
//发件人
message.From.Add(new MailboxAddress(FromEmail, FromEmail));
//收件人
message.To.AddRange(toAddress);
message.Subject = subject;
message.Date = DateTime.Now;
//创建附件Multipart
Multipart multipart = new Multipart("mixed");
var alternative = new MultipartAlternative();
//html内容
if (!string.IsNullOrEmpty(html))
{
var Html = new TextPart(TextFormat.Html)
{
Text = html
};
alternative.Add(Html);
}
//文本内容
//if (!string.IsNullOrEmpty(text))
//{
var plain = new TextPart(TextFormat.Plain)
{
Text = text + "\r\n\n\n" + mailOptions.Signature
};
alternative.Add(plain);
//}
//附件
if (!string.IsNullOrEmpty(path))
{
string[] files = path.Split(",");
foreach (var file in files)
{
MimePart attachment = new()
{
Content = new MimeContent(File.OpenRead(file), ContentEncoding.Default),
//读取文件,只能用绝对路径
ContentDisposition = new ContentDisposition(ContentDisposition.Attachment),
ContentTransferEncoding = ContentEncoding.Base64,
//文件名字
FileName = Path.GetFileName(path)
};
alternative.Add(attachment);
}
}
multipart.Add(alternative);
//赋值邮件内容
message.Body = multipart;
//开始发送
using var client = new SmtpClient();
client.ServerCertificateValidationCallback = (s, c, h, e) => true;
//Smtp服务器
//client.Connect("smtp.qq.com", 587, false);
client.Connect(Smtp, Port, true);
//登录,发送
//特别说明对于服务器端的中文相应Exception中有编码问题显示乱码了
client.Authenticate(FromEmail, FromPwd);
client.Send(message);
//断开
client.Disconnect(true);
Console.WriteLine($"发送邮件成功{DateTime.Now}");
}
}
}

117
ARW-net/ARW.Common/Tools.cs Normal file
View File

@ -0,0 +1,117 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
namespace ARW.Common
{
public class Tools
{
/// <summary>
/// 要分割的字符串 eg: 1,3,10,00
/// </summary>
/// <param name="str"></param>
/// <param name="split">分割的字符串</param>
/// <returns></returns>
public static long[] SpitLongArrary(string str, char split = ',')
{
if (string.IsNullOrEmpty(str)) { return Array.Empty<long>(); }
str = str.TrimStart(split).TrimEnd(split);
string[] strIds = str.Split(split, (char)StringSplitOptions.RemoveEmptyEntries);
long[] infoIdss = Array.ConvertAll(strIds, s => long.Parse(s));
return infoIdss;
}
public static int[] SpitIntArrary(string str, char split = ',')
{
if (string.IsNullOrEmpty(str)) { return Array.Empty<int>(); }
string[] strIds = str.Split(split, (char)StringSplitOptions.RemoveEmptyEntries);
int[] infoIdss = Array.ConvertAll(strIds, s => int.Parse(s));
return infoIdss;
}
/// <summary>
/// 根据日期获取星期几
/// </summary>
public static string GetWeekByDate(DateTime dt)
{
var day = new[] { "星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六" };
return day[Convert.ToInt32(dt.DayOfWeek.ToString("d"))];
}
/// <summary>
/// 得到这个月的第几周
/// </summary>
/// <param name="daytime">年月日</param>
/// <returns>传递过来的时间是第几周</returns>
public static int GetWeekNumInMonth(DateTime daytime)
{
int dayInMonth = daytime.Day;
//本月第一天
DateTime firstDay = daytime.AddDays(1 - daytime.Day);
//本月第一天是周几
int weekday = (int)firstDay.DayOfWeek == 0 ? 7 : (int)firstDay.DayOfWeek;
//本月第一周有几天
int firstWeekEndDay = 7 - (weekday - 1);
//当前日期和第一周之差
int diffday = dayInMonth - firstWeekEndDay;
diffday = diffday > 0 ? diffday : 1;
//当前是第几周,如果整除7就减一天
int weekNumInMonth = ((diffday % 7) == 0
? (diffday / 7 - 1)
: (diffday / 7)) + 1 + (dayInMonth > firstWeekEndDay ? 1 : 0);
return weekNumInMonth;
}
/// <summary>
/// 判断一个字符串是否为url
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
public static bool IsUrl(string str)
{
try
{
string Url = @"^http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?$";
return Regex.IsMatch(str, Url);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
return false;
}
}
/// <summary>
/// 计算密码强度
/// </summary>
/// <param name="password">密码字符串</param>
/// <returns></returns>
public static bool PasswordStrength(string password)
{
//空字符串强度值为0
if (string.IsNullOrEmpty(password)) return false;
//字符统计
int iNum = 0, iLtt = 0, iSym = 0;
foreach (char c in password)
{
if (c >= '0' && c <= '9') iNum++;
else if (c >= 'a' && c <= 'z') iLtt++;
else if (c >= 'A' && c <= 'Z') iLtt++;
else iSym++;
}
if (iLtt == 0 && iSym == 0) return false; //纯数字密码
if (iNum == 0 && iLtt == 0) return false; //纯符号密码
if (iNum == 0 && iSym == 0) return false; //纯字母密码
if (password.Length >= 6 && password.Length < 16) return true;//长度不大于6的密码
if (iLtt == 0) return true; //数字和符号构成的密码
if (iSym == 0) return true; //数字和字母构成的密码
if (iNum == 0) return true; //字母和符号构成的密码
return true; //由数字、字母、符号构成的密码
}
}
}

View File

@ -0,0 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AssemblyName>ARW.Model</AssemblyName>
<RootNamespace>ARW.Model</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="EPPlus" Version="6.0.5" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="SqlSugar.MySqlConnectorCore" Version="5.10.3.1" />
<PackageReference Include="SqlSugarCoreNoDrive" Version="5.1.3.21" />
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Enum\" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 申请
/// </summary>
public class ApplyDto
{
public long SenderGuId { get; set; }
public long ReceiverGuId { get; set; }
public string Postscript { get; set; }
public string Reply { get; set; }
public bool IsGroup { get; set; }
}
/// <summary>
/// 查询对象
/// </summary>
public class ApplyQueryDto : PagerInfo
{
public long? UserGuId { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat.ChatGPT
{
/// <summary>
/// Chat GPT传输对象
/// </summary>
public class CahtGPTDto
{
public long SenderGuId { get; set; }
public long ReceiverGuId { get; set; }
public string Content { get; set; }
}
/// <summary>
/// 查询对象
/// </summary>
public class ChatGPTQueryDto : PagerInfo
{
public long? UserGuId { get; set; }
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 聊天记录
/// </summary>
public class ChatLogDto
{
public string ChatLogType { get; set; }
public long SenderGuId { get; set; }
public long ReceiverGuId { get; set; }
public string ChatLogContent { get; set; }
}
public class ChatLogQueryDto : PagerInfo
{
public string ChatLogType { get; set; }
public long? UserGuId { get; set; }
public long? FriendsGuId { get; set; }
public string ChatLogContent { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 登录用户信息存储
/// </summary>
public class ChatUserDto
{
public int ChatUserId { get; set; }
public long ChatUserGuid { get; set; }
public string ChatUserNickName { get; set; }
public string ChatUserName { get; set; }
public string ChatUserImg { get; set; }
public int? Age { get; set; }
public string Sex { get; set; }
public string Password { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public int? Status { get; set; }
}
/// <summary>
/// 查询对象
/// </summary>
public class ChatUserQueryDto : PagerInfo
{
public string ChatUserName { get; set; }
public string ChatUserNickName { get; set; }
public int? ChatUserStatus { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 查找好友
/// </summary>
public class FindFriendsDto
{
public string FriendName { get; set; }
}
/// <summary>
/// 修改备注
/// </summary>
public class UpdateNoteDto
{
public long UserGuId { get; set; }
public string Note { get; set; }
}
}

View File

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 好友
/// </summary>
public class FriendsDto
{
public long UserGuId { get; set; }
public long FriendsGuId { get; set; }
public string FriendsNote { get; set; }
public string Reply { get; set; }
public bool IsAgree { get; set; }
}
public class FriendsQueryDto : PagerInfo
{
public long? UserGuId { get; set; }
}
}

View File

@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.Chat
{
/// <summary>
/// 群聊
/// </summary>
public class GroupDto
{
public long GroupGuId { get; set; }
public string GroupName { get; set; }
public string GroupImg { get; set; }
public long UserGuId { get; set; }
}
public class GroupQueryDto : PagerInfo
{
public long? UserGuId { get; set; }
}
public class GroupUserDto
{
public long GroupManagerGuId { get; set; }
public long UserGuId { get; set; }
public string Reply { get; set; }
public bool IsAgree { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Dto.Business
{
/// <summary>
/// 输入对象
/// </summary>
public class ClassDto
{
public long ClassId { get; set; }
[Required(ErrorMessage = "班级名称不能为空")]
public string ClassName { get; set; }
}
/// <summary>
/// 查询对象
/// </summary>
public class ClassQueryDto : PagerInfo
{
public long? ClassId { get; set; }
public string ClassName { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
namespace ARW.Model.Dto.Business.Crawler
{
/// <summary>
/// 查询对象
/// </summary>
public class CrawlQueryDto : PagerInfo
{
public string Name { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Dto.Business.Product
{
/// <summary>
/// 产品类型输入对象
/// </summary>
public class ProductTypeDto
{
[Required(ErrorMessage = "产品类型Id不能为空")]
public long ProductTypeId { get; set; }
[Required(ErrorMessage = "产品类型不能为空")]
public string ProductTypeName { get; set; }
public long ParentId { get; set; }
}
/// <summary>
/// 产品类型查询对象
/// </summary>
public class ProductTypeQueryDto : PagerInfo
{
}
}

View File

@ -0,0 +1,58 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
namespace ARW.Model.Dto.Business
{
/// <summary>
/// 输入对象
/// </summary>
public class StudentDto
{
/// <summary>
/// 学生Id
/// </summary>
public long StudentId { get; set; }
public long ClassId { get; set; }
public string DictType { get; set; }
public string StudentName { get; set; }
public string Sex { get; set; }
public int? Age { get; set; }
public string StudentImg { get; set; }
public string StudentTag { get; set; }
public Service[] StudentService { get; set; }
public string StudentDescribe { get; set; }
}
/// <summary>
/// 查询对象
/// </summary>
public class StudentQueryDto : PagerInfo
{
/// <summary>
/// 学生ID
/// </summary>
public long? StudentId { get; set; }
/// <summary>
/// 班级ID
/// </summary>
public long? ClassId { get; set; }
/// <summary>
/// 类型ID
/// </summary>
public string DictType { get; set; }
/// <summary>
/// 学生名称
/// </summary>
public string StudentName { get; set; }
}
}

View File

@ -0,0 +1,40 @@
using System;
using Newtonsoft.Json;
using SqlSugar;
using OfficeOpenXml.Attributes;
namespace ARW.Model.Models.Business
{
[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
public class BusinessBase
{
[SugarColumn(IsOnlyIgnoreUpdate = true,IsNullable = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateBy")]
[EpplusIgnore]
public string Create_by { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true, IsNullable = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateTime")]
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime Create_time { get; set; } = DateTime.Now;
[JsonIgnore]
[JsonProperty(propertyName: "UpdateBy")]
[SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true)]
[EpplusIgnore]
public string Update_by { get; set; }
//[JsonIgnore]
[SugarColumn(IsOnlyIgnoreInsert = true, IsNullable = true)]//设置后插入数据不会有此字段
[JsonProperty(propertyName: "UpdateTime")]
[EpplusIgnore]
public DateTime? Update_time { get; set; }
[JsonProperty(propertyName: "IsDelete")]
[SugarColumn(IsNullable = true)]
[EpplusIgnore]
public bool IsDelete { get; set; }
}
}

View File

@ -0,0 +1,62 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat
{
[SugarTable("tb_chat_apply")]
public class Apply : BusinessBase
{
/// <summary>
/// 发起人id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnDescription = "发起人id", ColumnName = "sender_guid")]
public long SenderGuId { get; set; }
/// <summary>
/// 接收人id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnDescription = "接收人id",ColumnName = "receiver_guid")]
public long ReceiverGuId { get; set; }
/// <summary>
/// 附言
/// </summary>
[SugarColumn(ColumnDescription = "附言", IsNullable = true, ColumnName = "postscript")]
public string Postscript { get; set; }
/// <summary>
/// 回复
/// </summary>
[SugarColumn(ColumnDescription = "回复", IsNullable = true, ColumnName = "reply")]
public string Reply { get; set; }
/// <summary>
/// 是否同意
/// </summary>
[SugarColumn(ColumnDescription = "是否同意", IsNullable = true, ColumnName = "isAgree")]
public bool? IsAgree { get; set; }
/// <summary>
/// 是否群申请
/// </summary>
[SugarColumn(ColumnDescription = "是否群申请", IsNullable = true, ColumnName = "isGroupApply")]
public bool? IsGroupApply { get; set; }
/// <summary>
/// 是否已读
/// </summary>
[SugarColumn(ColumnDescription = "是否已读", ColumnName = "isRead")]
public bool IsRead { get; set; }
}
}

View File

@ -0,0 +1,66 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat.ChatGPT
{
[SugarTable("tb_chat_gpt_log")]
public class ChatGPTLog : BusinessBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "chat_gpt_log_id")]
public int ChatGptLogId { get; set; }
/// <summary>
/// 聊天记录id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "chat_gpt_log_guid")]
public long ChatGptLogGuId { get; set; }
/// <summary>
/// 发送人guid(外键)
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnDescription = "发送人guid(外键)", ColumnName = "sender_guid")]
public long SenderGuId { get; set; }
/// <summary>
/// 接收人guid(外键)
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnDescription = "接收人guid(外键)", ColumnName = "receiver_guid")]
public long ReceiverGuId { get; set; }
/// <summary>
/// 发送时间
/// </summary>
[SugarColumn(ColumnDescription = "发送时间", ColumnName = "chat_gpt_log_send_time")]
public DateTime ChatGptLogSendTime { get; set; }
/// <summary>
/// 内容
/// </summary>
[SugarColumn(ColumnDescription = "内容", ColumnDataType = "text", ColumnName = "chat_gpt_log_content")]
public string ChatGptLogContent { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注", IsNullable = true, ColumnName = "chat_gpt_log_name")]
public string Remark { get; set; }
/// <summary>
/// 是否已读
/// </summary>
[SugarColumn(ColumnDescription = "是否已读", ColumnName = "isRead")]
public bool IsRead { get; set; }
}
}

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,82 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat
{
[SugarTable("tb_chat_user")]
public class ChatUser : BusinessBase
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "chat_user_id")]
public int ChatUserId { get; set; }
/// <summary>
/// 用户id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "chat_user_guid")]
public long ChatUserGuId { get; set; }
/// <summary>
/// 用户名
/// </summary>
[SugarColumn(ColumnDescription = "用户名", ColumnName = "chat_user_name")]
public string ChatUserName { get; set; }
/// <summary>
/// 密码
/// </summary>
[JsonIgnore]
[EpplusIgnore]
public string Password { get; set; }
/// <summary>
/// 昵称
/// </summary>
[SugarColumn(ColumnDescription = "昵称", ColumnName = "chat_user_nickname")]
public string ChatUserNickName { get; set; }
/// <summary>
/// 性别(1:男2:女)
/// </summary>
[SugarColumn(Length = 1, ColumnDescription = "性别(1:男2:女)", IsNullable = true, ColumnName = "chat_user_sex")]
public string Sex { get; set; }
/// <summary>
/// 年龄
/// </summary>
[SugarColumn(ColumnDescription = "年龄", IsNullable = true, ColumnName = "chat_user_age")]
public int? Age { get; set; }
/// <summary>
/// 用户图片(路径)
/// </summary>
[SugarColumn(ColumnDescription = "用户头像", IsNullable = true, ColumnName = "chat_user_img")]
public string ChatUserImg { get; set; }
/// <summary>
/// 电话号码
/// </summary>
[SugarColumn(ColumnDescription = "电话号码", IsNullable = true, ColumnName = "chat_user_phone")]
public string Phone { get; set; }
/// <summary>
/// 邮箱
/// </summary>
[SugarColumn(ColumnDescription = "邮箱", IsNullable = true, ColumnName = "chat_user_email")]
public string Email { get; set; }
/// <summary>
/// 登录状态(1,在线 | 0,离线)
/// </summary>
[SugarColumn(ColumnDescription = "登录状态(1,在线 | 0,离线)", ColumnName = "chat_user_status")]
public int? Status { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat
{
[SugarTable("tb_chat_friends")]
public class Friends : BusinessBase
{
/// <summary>
/// 用户id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName = "uesr_guid")]
public long UserGuId { get; set; }
/// <summary>
/// 好友id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName = "friends_guid")]
public long FriendsGuId { get; set; }
/// <summary>
/// 备注
/// </summary>
[SugarColumn(ColumnDescription = "备注", IsNullable = true, ColumnName = "friends_note")]
public string FriendsNote { get; set; }
}
}

View File

@ -0,0 +1,43 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat
{
[SugarTable("tb_chat_group")]
public class Group : BusinessBase
{
/// <summary>
/// 群聊id
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "group_id")]
public int GroupId { get; set; }
/// <summary>
/// 群聊guid
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "group_guid")]
public long GroupGuId { get; set; }
/// <summary>
/// 群名称
/// </summary>
[SugarColumn(ColumnName = "group_name", ColumnDescription = "群名称")]
public string GroupName { get; set; }
/// <summary>
/// 群头像
/// </summary>
[SugarColumn(ColumnDescription = "群头像", IsNullable = true, ColumnName = "group_img")]
public string GroupImg { get; set; }
}
}

View File

@ -0,0 +1,44 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Chat
{
[SugarTable("tb_chat_group_user")]
public class GroupUser : BusinessBase
{
/// <summary>
/// 群聊id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName = "group_guid",ColumnDescription = "群guid(外键)")]
public long GroupGuId { get; set; }
/// <summary>
/// 用户id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnName = "user_guid", ColumnDescription = "用户guid(外键)")]
public long UserGuId { get; set; }
/// <summary>
/// 是否群主
/// </summary>
[SugarColumn(ColumnName = "isgroup_manager", ColumnDescription = "是否为群主")]
public bool IsGroupManager { get; set; }
/// <summary>
/// 是否群主
/// </summary>
[SugarColumn(ColumnName = "IsRead", ColumnDescription = "是否已读")]
public bool IsRead { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business
{
[SugarTable("tb_class")]
public class Class : BusinessBase
{
/// <summary>
/// 班级Id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "class_id")]
public long ClassId { get; set; }
/// <summary>
/// 班级名称
/// </summary>
[SugarColumn(ColumnDescription = "班级名称",ColumnName = "class_name")]
public string ClassName { get; set; }
}
}

View File

@ -0,0 +1,66 @@
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Crawler
{
[SugarTable("crawl")]
public class Crawl: BusinessBase
{
[SugarColumn(IsPrimaryKey = true,IsIdentity =true)]
public int Id { get; set; }
[SugarColumn(ColumnDescription = "名称", IsNullable = true)]
public string Name { get; set; }
[SugarColumn(ColumnDescription = "简介", IsNullable = true)]
public string Intro { get; set; }
[SugarColumn(ColumnDescription = "图片", IsNullable = true)]
public string Cover { get; set; }
[SugarColumn(ColumnDescription = "链接", IsNullable = true)]
public string Link { get; set; }
[SugarColumn(ColumnDescription = "类型", IsNullable = true)]
public string Type { get; set; }
[SugarColumn(ColumnDescription = "上传时间", IsNullable = true)]
public DateTime PublishTime { get; set; }
[JsonIgnore]
[SugarColumn(IsIgnore = true)]
public List<Resource> DownResources { get; set; }
[SugarColumn(ColumnDescription = "下载资源", IsNullable = true)]
public string Resources
{
get
{
if (this.DownResources != null)
{
return JToken.FromObject(this.DownResources).ToString();
}
else
{
return "[]";
}
}
}
}
public class Resource
{
public string Description { get; set; }
public string Link { get; set; }
}
}

View File

@ -0,0 +1,40 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business.Product
{
[SugarTable("tb_product_type")]
public class ProductType : BusinessBase
{
/// <summary>
/// 班级Id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "product_type_id")]
public long ProductTypeId{ get; set; }
/// <summary>
/// 班级名称
/// </summary>
[SugarColumn(ColumnDescription = "产品类型",ColumnName = "product_type_name")]
public string ProductTypeName { get; set; }
/// <summary>
/// 父级Id
/// </summary>
[SugarColumn(ColumnDescription = "父级Id", IsNullable = true, ColumnName = "parent_id")]
public long ParentId { get; set; }
/// <summary>
/// 子级内容
/// </summary>
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[SugarColumn(IsIgnore = true)]
public List<ProductType> Children { get; set; }
}
}

View File

@ -0,0 +1,83 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.Models.Business
{
[SugarTable("tb_student")]
public class Student : BusinessBase
{
/// <summary>
/// 学生id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true, ColumnName = "student_id")]
public long StudentId { get; set; }
/// <summary>
/// 班级guid(外键)
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(ColumnDescription = "班级guid(外键)", ColumnName = "class_guid")]
public long ClassId { get; set; }
/// <summary>
/// 字典类型(外键)
/// </summary>
[SugarColumn(ColumnDescription = "字典类型(外键)", IsNullable = true, ColumnName = "dictType")]
public string DictType { get; set; }
/// <summary>
/// 学生名称
/// </summary>
[SugarColumn(ColumnDescription = "学生名称", IsNullable = true, ColumnName = "student_name")]
public string StudentName { get; set; }
/// <summary>
/// 性别(1:男2:女)
/// </summary>
[SugarColumn(Length = 1, ColumnDescription = "性别(1:男2:女)", IsNullable = true, ColumnName = "student_sex")]
public string Sex { get; set; }
/// <summary>
/// 年龄
/// </summary>
[SugarColumn(ColumnDescription = "年龄", IsNullable = true, ColumnName = "student_age")]
public int? Age { get; set; }
/// <summary>
/// 学生图片(路径)
/// </summary>
[SugarColumn(ColumnDescription = "学生图片", IsNullable = true, ColumnName = "student_img")]
public string StudentImg { get; set; }
/// <summary>
/// 学生标签(单个字段,以","分开)
/// </summary>
[SugarColumn(ColumnDescription = "学生标签", IsNullable = true, ColumnName = "student_tag")]
public string StudentTag { get; set; }
/// <summary>
/// 学生服务(json)
/// </summary>
[SugarColumn(ColumnDescription = "学生服务", ColumnDataType = "text", IsNullable = true, ColumnName = "student_service", IsJson = true)]
public Service[] StudentService { get; set; }
/// <summary>
/// 学生描述(富文本)
/// </summary>
[SugarColumn(ColumnDescription = "学生描述", ColumnDataType = "text", IsNullable = true, ColumnName = "student_describe")]
public string StudentDescribe { get; set; }
}
public class Service
{
public string service_name { get; set; }
public string service_price { get; set; }
}
}

View File

@ -0,0 +1,48 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model
{
/// <summary>
/// 分页参数
/// </summary>
public class PagedInfo<T>
{
/// <summary>
/// 每页行数
/// </summary>
public int PageSize { get; set; } = 10;
/// <summary>
/// 当前页
/// </summary>
public int PageIndex { get; set; } = 1;
/// <summary>
/// 总记录数
/// </summary>
public int TotalNum { get; set; }
/// <summary>
/// 总页数
/// </summary>
public int TotalPage
{
get
{
if (TotalNum > 0)
{
return TotalNum % this.PageSize == 0 ? TotalNum / this.PageSize : TotalNum / this.PageSize + 1;
}
else
{
return 0;
}
}
set { }
}
public List<T> Result { get; set; }
public Dictionary<string, object> Extra { get; set; } = new Dictionary<string, object>();
public PagedInfo()
{
}
}
}

View File

@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model
{
public class PagerInfo
{
/// <summary>
/// 当前页码
/// </summary>
public int PageNum { get; set; }
public int PageSize { get; set; }
/// <summary>
/// 总记录数
/// </summary>
public int TotalNum { get; set; }
/// <summary>
/// 总页码
/// </summary>
/// <summary>
/// 总页数
/// </summary>
public int TotalPage
{
get
{
return TotalNum > 0 ? TotalNum % PageSize == 0 ? TotalNum / PageSize : TotalNum / PageSize + 1 : 0;
}
}
/// <summary>
/// 排序字段
/// </summary>
public string Sort { get; set; } = string.Empty;
/// <summary>
/// 排序类型,前端传入的是"ascending""descending"
/// </summary>
public string SortType { get; set; } = string.Empty;
public PagerInfo()
{
PageNum = 1;
PageSize = 10;
}
public PagerInfo(int page = 1, int pageSize = 20)
{
PageNum = page;
PageSize = pageSize;
}
}
}

View File

@ -0,0 +1,60 @@
using System;
using System.Collections.Generic;
using SqlSugar;
using OfficeOpenXml.Attributes;
using Newtonsoft.Json;
namespace ARW.Model.Models
{
/// <summary>
/// 多语言配置,数据实体对象
///
/// @author
///
/// @date 2022-05-06
/// </summary>
[Tenant("0")]
[SugarTable("sys_common_lang")]
public class CommonLang
{
/// <summary>
/// 描述 : id
/// 空值 : false
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[EpplusTableColumn(Header = "id")]
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
/// <summary>
/// 描述 : 语言code
/// 空值 : false
/// </summary>
[EpplusTableColumn(Header = "语言code")]
[SugarColumn(ColumnName = "lang_code")]
public string LangCode { get; set; }
/// <summary>
/// 描述 : 语言key
/// 空值 : true
/// </summary>
[EpplusTableColumn(Header = "语言key")]
[SugarColumn(ColumnName = "lang_key")]
public string LangKey { get; set; }
/// <summary>
/// 描述 : 名称
/// 空值 : false
/// </summary>
[EpplusTableColumn(Header = "名称")]
[SugarColumn(ColumnName = "lang_name")]
public string LangName { get; set; }
/// <summary>
/// 描述 : 添加时间
/// 空值 : true
/// </summary>
[EpplusTableColumn(Header = "添加时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime? Addtime { get; set; }
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
namespace ARW.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; }
}
}

View File

@ -0,0 +1,81 @@
using System.Collections.Generic;
using ARW.Model.System.Generate;
namespace ARW.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; }
/// <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; }
}
}

View File

@ -0,0 +1,30 @@
using System.ComponentModel.DataAnnotations;
namespace ARW.Model.System.Dto
{
public class LoginBodyDto
{
/// <summary>
/// 用户名
/// </summary>
[Required(ErrorMessage = "用户名不能为空")]
public string Username { get; set; }
/// <summary>
/// 用户密码
/// </summary>
[Required(ErrorMessage = "密码不能为空")]
public string Password { get; set; }
/**
*
*/
public string Code { get; set; }
/**
*
*/
public string Uuid { get; set; } = "";
public string LoginIP { get; set; }
}
}

View File

@ -0,0 +1,92 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace ARW.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不能为空")]
public int MenuId { get; set; }
public string MenuName { get; set; }
/// <summary>
/// 父菜单ID
/// </summary>
public long? parentId { get; set; }
/// <summary>
/// 显示顺序
/// </summary>
public int orderNum { get; set; }
/// <summary>
/// 路由地址
/// </summary>
public string path { get; set; } = "#";
/// <summary>
/// 组件路径
/// </summary>
public string component { get; set; }
/// <summary>
/// 是否缓存1缓存 0不缓存
/// </summary>
[Required(ErrorMessage = "是否缓存不能为空")]
public string isCache { get; set; }
/// <summary>
/// 是否外链 1、是 0、否
/// </summary>
public string 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>
public string perms { get; set; }
/// <summary>
/// 菜单图标
/// </summary>
public string icon { get; set; } = string.Empty;
/// <summary>
/// 翻译key
/// </summary>
public string MenuNameKey { get; set; }
}
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);
}
}
}
}

View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace ARW.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; }
/**
*
*/
public string Code { get; set; }
/**
*
*/
public string Uuid { get; set; } = "";
}
}

View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace ARW.Model.System.Dto
{
public class RoleUserQueryDto : PagerInfo
{
public long RoleId { get; set; }
public string UserName { get; set; }
}
public class RoleUsersCreateDto
{
/// <summary>
/// 描述 : 角色id
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "角色id")]
[Required(ErrorMessage = "roleId 不能为空")]
public long RoleId { get; set; }
/// <summary>
/// 描述 : 用户编码 [1,2,3,4]
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "用户编码 [1,2,3,4]")]
public List<long> UserIds { get; set; }
}
}

View File

@ -0,0 +1,30 @@
using System;
namespace ARW.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; }
}
}

View File

@ -0,0 +1,87 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.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>
/// 描述 : 存储文件名
/// 空值 : true
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 描述 : 文件存储地址 eg/uploads/20220202
/// 空值 : true
/// </summary>
public string FileUrl { get; set; }
/// <summary>
/// 描述 : 仓库位置 eg/uploads
/// 空值 : true
/// </summary>
public string StorePath { get; set; }
/// <summary>
/// 描述 : 文件大小
/// 空值 : true
/// </summary>
public string FileSize { get; set; }
/// <summary>
/// 描述 : 文件扩展名
/// 空值 : true
/// </summary>
public string FileExt { get; set; }
/// <summary>
/// 描述 : 创建人
/// 空值 : true
/// </summary>
public string Create_by { get; set; }
/// <summary>
/// 描述 : 上传时间
/// 空值 : true
/// </summary>
public DateTime? Create_time { get; set; }
/// <summary>
/// 描述 : 存储类型
/// 空值 : true
/// </summary>
public int? StoreType { get; set; }
/// <summary>
/// 描述 : 访问路径
/// 空值 : true
/// </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; }
}
}

View File

@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.Text;
using ARW.Model.System;
namespace ARW.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; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using ARW.Model.Models;
namespace ARW.Model.System.Dto
{
/// <summary>
/// 通知公告表输入对象
/// </summary>
public class SysNoticeDto
{
public int NoticeId { get; set; }
public string NoticeTitle { get; set; }
public string NoticeType { get; set; }
public string NoticeContent { get; set; }
public string Status { get; set; }
public string Remark { get; set; }
}
/// <summary>
/// 通知公告表查询对象
/// </summary>
public class SysNoticeQueryDto : PagerInfo
{
public string NoticeTitle { get; set; }
public string NoticeType { get; set; }
public string CreateBy { get; set; }
public string Status { get; set; }
}
}

View File

@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Text;
using ARW.Model.System;
namespace ARW.Model.System.Dto
{
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; }
}
}

View File

@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;
using ARW.Model.System;
namespace ARW.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 string Status { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Text;
using ARW.Model.System;
namespace ARW.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; }
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System.Dto
{
public class SysdictDataDto
{
public string DictType { get; set; }
public string ColumnName { get; set; }
public List<SysDictData> List { get; set; }
}
}

View File

@ -0,0 +1,233 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace ARW.Model.System.Dto
{
public class TasksQueryDto
{
/// <summary>
/// 描述 : 查询字符串
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "查询字符串")]
public string QueryText { get; set; }
}
/// <summary>
/// 添加任务
/// </summary>
public class TasksCreateDto
{
/// <summary>
/// 描述 : 任务名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务名称")]
[Required(ErrorMessage = "任务名称不能为空")]
public string Name { get; set; }
/// <summary>
/// 描述 : 任务分组
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务分组")]
[Required(ErrorMessage = "任务分组不能为空")]
public string JobGroup { get; set; }
/// <summary>
/// 描述 : 运行时间表达式
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "运行时间表达式")]
public string Cron { get; set; }
/// <summary>
/// 描述 : 程序集名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "程序集名称")]
//[Required(ErrorMessage = "程序集名称不能为空")]
public string AssemblyName { get; set; }
/// <summary>
/// 描述 : 任务所在类
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务所在类")]
//[Required(ErrorMessage = "任务所在类不能为空")]
public string ClassName { get; set; }
/// <summary>
/// 描述 : 任务描述
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "任务描述")]
public string Remark { get; set; }
/// <summary>
/// 描述 : 开始时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "开始时间")]
public DateTime? BeginTime { get; set; }
/// <summary>
/// 描述 : 结束时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "结束时间")]
public DateTime? EndTime { get; set; }
/// <summary>
/// 描述 : 触发器类型0、simple 1、cron
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "触发器类型0、simple 1、cron")]
public int TriggerType { get; set; }
/// <summary>
/// 描述 : 执行间隔时间(单位:秒)
/// 空值 : False
/// 默认 : 0
/// </summary>
[Display(Name = "执行间隔时间(单位:秒)")]
public int IntervalSecond { get; set; }
/// <summary>
/// 描述 : 传入参数
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "传入参数")]
public string JobParams { get; set; }
public string ApiUrl { get; set; }
/// <summary>
/// 1、程序集任务 2、apiUrl任务
/// </summary>
public int TaskType { get; set; }
}
/// <summary>
/// 更新任务
/// </summary>
public class TasksUpdateDto
{
/// <summary>
/// 描述 : UID
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "UID")]
[Required(ErrorMessage = "UID不能为空")]
public string ID { get; set; }
/// <summary>
/// 描述 : 任务名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务名称")]
[Required(ErrorMessage = "任务名称不能为空")]
public string Name { get; set; }
/// <summary>
/// 描述 : 任务分组
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务分组")]
[Required(ErrorMessage = "任务分组不能为空")]
public string JobGroup { get; set; }
/// <summary>
/// 描述 : 运行时间表达式
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "运行时间表达式")]
public string Cron { get; set; }
/// <summary>
/// 描述 : 程序集名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "程序集名称")]
[Required(ErrorMessage = "程序集名称不能为空")]
public string AssemblyName { get; set; }
/// <summary>
/// 描述 : 任务所在类
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务所在类")]
[Required(ErrorMessage = "任务所在类不能为空")]
public string ClassName { get; set; }
/// <summary>
/// 描述 : 任务描述
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "任务描述")]
public string Remark { get; set; }
/// <summary>
/// 描述 : 开始时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "开始时间")]
public DateTime? BeginTime { get; set; }
/// <summary>
/// 描述 : 结束时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "结束时间")]
public DateTime? EndTime { get; set; }
/// <summary>
/// 描述 : 触发器类型0、simple 1、cron
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "触发器类型0、simple 1、cron")]
public int TriggerType { get; set; }
/// <summary>
/// 描述 : 执行间隔时间(单位:秒)
/// 空值 : False
/// 默认 : 0
/// </summary>
[Display(Name = "执行间隔时间(单位:秒)")]
public int IntervalSecond { get; set; }
/// <summary>
/// 描述 : 传入参数
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "传入参数")]
public string JobParams { get; set; }
public string ApiUrl { get; set; }
/// <summary>
/// 1、程序集任务 2、apiUrl任务
/// </summary>
public int TaskType { get; set; }
}
}

View File

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System.Dto
{
public class TasksLogQueryDto
{
/// <summary>
/// 描述 : 查询字符串
/// 空值 : False
/// 默认 :
/// </summary>
//[Display(Name = "查询字符串")]
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
{
}
}

View File

@ -0,0 +1,109 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System.Generate
{
/// <summary>
/// 代码生成表
/// </summary>
[SqlSugar.SugarTable("gen_table")]
[SqlSugar.Tenant("0")]
public class GenTable : SysBase
{
/// <summary>
/// 表id
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int TableId { get; set; }
/// <summary>
/// 数据库名
/// </summary>
public string DbName { get; set; }
/// <summary>
/// 表名
/// </summary>
public string TableName { get; set; }
/// <summary>
/// 表描述
/// </summary>
public string TableComment { get; set; }
/// <summary>
/// 关联父表的表名
/// </summary>
public string SubTableName { get; set; }
/// <summary>
/// 本表关联父表的外键名
/// </summary>
public string SubTableFkName { get; set; }
/// <summary>
/// csharp类名
/// </summary>
public string ClassName { get; set; }
/// <summary>
/// 使用的模板crud单表操作 tree树表操作 sub主子表操作
/// </summary>
public string TplCategory { get; set; }
/// <summary>
/// 基本命名空间前缀
/// </summary>
public string BaseNameSpace { get; set; }
/// <summary>
/// 生成模块名
/// </summary>
public string ModuleName { get; set; }
/// <summary>
/// 生成业务名
/// </summary>
public string BusinessName { get; set; }
/// <summary>
/// 生成功能名
/// </summary>
public string FunctionName { get; set; }
/// <summary>
/// 生成作者名
/// </summary>
public string FunctionAuthor { get; set; }
/// <summary>
/// 生成代码方式0zip压缩包 1自定义路径
/// </summary>
public string GenType { get; set; }
public string GenPath { get; set; }
/// <summary>
/// 其他生成选项
/// </summary>
[SqlSugar.SugarColumn(IsJson = true, ColumnDataType = "nvarchar(4000)")]
public Options Options { get; set; }
#region
/** 表列信息 */
[SqlSugar.SugarColumn(IsIgnore = true)]
public List<GenTableColumn> Columns { get; set; }
/// <summary>
/// 字表信息
/// </summary>
[SqlSugar.SugarColumn(IsIgnore = true)]
public GenTable SubTable { get; set; }
#endregion
}
public class Options
{
public long ParentMenuId { get; set; } = 0;
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;
}
}

View File

@ -0,0 +1,131 @@
using SqlSugar;
using System;
using System.Linq;
namespace ARW.Model.System.Generate
{
/// <summary>
/// 代码生成表字段
/// </summary>
[SugarTable("gen_table_column")]
[Tenant("0")]
public class GenTableColumn : SysBase
{
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public int ColumnId { get; set; }
/// <summary>
/// 导入代码生成表列名 首字母转了小写
/// </summary>
public string ColumnName { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public int TableId { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]
public string TableName { get; set; }
/// <summary>
/// 列说明
/// </summary>
public string ColumnComment { get; set; } = string.Empty;
/// <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>
/// 显示类型(文本框、文本域、下拉框、复选框、单选框、日期控件)
/// </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; } = "";
#region
[SugarColumn(IsIgnore = true)]
public string RequiredStr
{
get
{
string[] arr = new string[] { "int", "long" };
return (!IsRequired && (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; set; }
/// <summary>
/// 前端 只读字段
/// </summary>
[SugarColumn(IsIgnore = true)]
public string DisabledStr
{
get
{
return (((!IsInsert && !IsEdit) || IsPk) && !IsRequired) ? " :disabled=\"true\"" : "";
}
}
#endregion
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 登录用户信息存储
/// </summary>
public class LoginUser
{
public long UserId { get; set; }
public long DeptId { get; set; }
public string UserName { get; set; }
/// <summary>
/// 角色集合
/// </summary>
public List<string> RoleIds { get; set; }
/// <summary>
/// 角色集合(数据权限过滤使用)
/// </summary>
public List<SysRole> Roles { get; set; }
/// <summary>
/// 权限集合
/// </summary>
public List<string> Permissions { get; set; } = new List<string>();
public LoginUser()
{
}
public LoginUser(SysUser user, List<SysRole> roles, List<string> permissions)
{
UserId = user.UserId;
UserName = user.UserName;
DeptId = user.DeptId;
Roles = roles;
RoleIds = roles.Select(f => f.RoleKey).ToList();
Permissions = permissions;
}
}
}

View File

@ -0,0 +1,65 @@
//using Dapper.Contrib.Extensions;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;
using OfficeOpenXml.Attributes;
namespace ARW.Model.System
{
[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
public class SysBase
{
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateBy")]
[EpplusIgnore]
public string Create_by { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateTime")]
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime Create_time { get; set; } = DateTime.Now;
[JsonIgnore]
[JsonProperty(propertyName: "UpdateBy")]
[SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusIgnore]
public string Update_by { get; set; }
//[JsonIgnore]
[SugarColumn(IsOnlyIgnoreInsert = true)]//设置后插入数据不会有此字段
[JsonProperty(propertyName: "UpdateTime")]
[EpplusIgnore]
public DateTime? Update_time { get; set; }
public string Remark { get; set; }
/// <summary>
/// 搜索时间起始时间
/// </summary>
/// <summary>
/// Write需穿一个bool值false时insertupdate等操作会忽略此列和Computed的作用差不多看了源码也没发现与Computed有什么不一样的地方有了解的朋友可以赐教下哈
/// ExplicitKey指定此列为主键不自动增长类型例如guidExplicitKey与Key地区别下面会详细讲
/// Key指定此列为主键自动增长主键可忽略忽略后默认查找
/// [Computed]计算属性打上此标签对象地insertupdate等操作会忽略此列
/// </summary>
[SugarColumn(IsIgnore = true)]
[JsonIgnore]
[EpplusIgnore]
public DateTime? BeginTime { get; set; }
/// <summary>
/// 用于搜索使用
/// </summary>
[SugarColumn(IsIgnore = true)]
[JsonIgnore]
[EpplusIgnore]
public DateTime? EndTime { get; set; }
[JsonProperty(propertyName: "IsDelete")]
[SugarColumn(IsNullable = true)]
[EpplusIgnore]
public bool IsDelete { get; set; }
}
}

View File

@ -0,0 +1,46 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 参数配置,数据实体对象
///
/// @author zhaorui
/// @date 2021-09-29
/// </summary>
[SugarTable("sys_config")]
[Tenant("0")]
public class SysConfig: SysBase
{
/// <summary>
/// 描述 :
/// 空值 :False
/// </summary>
[SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int ConfigId { get; set; }
/// <summary>
/// 描述 :
/// 空值 :True
/// </summary>
public string ConfigName { get; set; }
/// <summary>
/// 描述 :
/// 空值 :True
/// </summary>
public string ConfigKey { get; set; }
/// <summary>
/// 描述 :
/// 空值 :True
/// </summary>
public string ConfigValue { get; set; }
/// <summary>
/// 描述 :
/// 空值 :True
/// </summary>
public string ConfigType { get; set; }
}
}

View File

@ -0,0 +1,58 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 部门表
/// </summary>
[SugarTable("sys_dept")]
[Tenant("0")]
public class SysDept: SysBase
{
/** 部门ID */
[SqlSugar.SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public long DeptId { get; set; }
/** 父部门ID */
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; }
/** 部门状态:0正常,1停用 */
public string Status { get; set; }
/// <summary>
/// 删除标志0代表存在 2代表删除
/// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true)]
public string DelFlag { get; set; }
/** 父部门名称 */
//[SugarColumn(IsIgnore = true)]
//public string ParentName { get; set; }
/// <summary>
/// 子菜单
/// </summary>
public List<SysDept> children = new List<SysDept>();
}
}

View File

@ -0,0 +1,31 @@
//using Dapper.Contrib.Extensions;
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;
namespace ARW.Model.System
{
/// <summary>
/// 字典数据表
/// </summary>
[Tenant("0")]
[SugarTable("sys_dict_data")]
public class SysDictData: SysBase
{
//[Key]
/// <summary>
/// 字典主键
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//主键并且自增 string不能设置自增
public long DictCode{ get; set; }
public int DictSort { get; set; }
public string DictLabel { get; set; }
public string DictValue { get; set; }
public string DictType { get; set; }
public string CssClass { get; set; } = string.Empty;
public string ListClass { get; set; } = string.Empty;
public string IsDefault { get; set; }
public string Status { get; set; }
}
}

View File

@ -0,0 +1,36 @@
using OfficeOpenXml.Attributes;
using SqlSugar;
namespace ARW.Model.System
{
/// <summary>
/// 字典类型表
/// </summary>
[SugarTable("sys_dict_type")]
[Tenant("0")]
public class SysDictType : SysBase
{
/// <summary>
/// 字典主键
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//主键并且自增 string不能设置自增
public long DictId { get; set; }
/// <summary>
/// 字典名称
/// </summary>
public string DictName { get; set; }
/// <summary>
/// 字典类型
/// </summary>
public string DictType { get; set; }
/// <summary>
/// 状态 0、正常 1、停用
/// </summary>
[EpplusIgnore]
public string Status { get; set; }
/// <summary>
/// 系统内置 Y是 N否
/// </summary>
public string Type { get; set; }
}
}

View File

@ -0,0 +1,90 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
[Tenant("0")]
[SugarTable("sys_file")]
public class SysFile
{
/// <summary>
/// 描述 : 自增id
/// 空值 : false
/// </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>
/// 描述 : 存储文件名
/// 空值 : true
/// </summary>
public string FileName { get; set; }
/// <summary>
/// 描述 : 文件存储地址 eg/uploads/20220202
/// 空值 : true
/// </summary>
public string FileUrl { get; set; }
/// <summary>
/// 描述 : 仓库位置 eg/uploads
/// 空值 : true
/// </summary>
public string StorePath { get; set; }
/// <summary>
/// 描述 : 文件大小
/// 空值 : true
/// </summary>
public string FileSize { get; set; }
/// <summary>
/// 描述 : 文件扩展名
/// 空值 : true
/// </summary>
public string FileExt { get; set; }
/// <summary>
/// 描述 : 创建人
/// 空值 : true
/// </summary>
public string Create_by { get; set; }
/// <summary>
/// 描述 : 上传时间
/// 空值 : true
/// </summary>
public DateTime? Create_time { get; set; }
/// <summary>
/// 描述 : 存储类型
/// 空值 : true
/// </summary>
public int? StoreType { get; set; }
/// <summary>
/// 描述 : 访问路径
/// 空值 : true
/// </summary>
public string AccessUrl { get; set; }
[JsonProperty(propertyName: "IsDelete")]
[SugarColumn(IsNullable = true)]
public bool IsDelete { 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;
}
}
}

View File

@ -0,0 +1,64 @@
//using Dapper.Contrib.Extensions;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
namespace ARW.Model.System
{
/// <summary>
/// sys_logininfor 表
/// </summary>
[SugarTable("sys_logininfor")]
[Tenant("0")]
public class SysLogininfor
{
//[Key]
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long infoId { get; set; }
/// <summary>
/// 用户账号
/// </summary>
public string userName { get; set; }
/// <summary>
/// 登录状态 0成功 1失败
/// </summary>
[SugarColumn(Length = 1)]
public string status { get; set; }
/// <summary>
/// 登录IP地址
/// </summary>
public string ipaddr { get; set; }
/// <summary>
/// 登录地点
/// </summary>
public string loginLocation { get; set; }
/// <summary>
/// 浏览器类型
/// </summary>
public string browser { get; set; }
/** 操作系统 */
//@Excel(name = "操作系统")
public string os { get; set; }
/// <summary>
/// 提示消息
/// </summary>
public string msg { get; set; }
/// <summary>
/// 访问时间
/// </summary>
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime loginTime { get; set; } = DateTime.Now;
[SugarColumn(IsIgnore = true)]
public DateTime? BeginTime { get; set; }
[SugarColumn(IsIgnore = true)]
public DateTime? EndTime { get; set; }
}
}

View File

@ -0,0 +1,107 @@
using SqlSugar;
using System.Collections.Generic;
namespace ARW.Model.System
{
/// <summary>
/// Sys_menu表
/// </summary>
[SugarTable("sys_menu")]
[Tenant("0")]
public class SysMenu : SysBase
{
/// <summary>
/// 菜单ID
/// </summary>
//[Key]//非自动增长主键时使用ExplicitKey
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long MenuId { get; set; }
/// <summary>
/// 菜单名称
/// </summary>
public string MenuName { get; set; }
/// <summary>
/// 父菜单ID
/// </summary>
public long parentId { get; set; }
/// <summary>
/// 显示顺序
/// </summary>
public int orderNum { get; set; }
/// <summary>
/// 路由地址
/// </summary>
public string path { get; set; } = "#";
/// <summary>
/// 组件路径
/// </summary>
[SugarColumn(IsNullable = true)]
public string component { get; set; }
/// <summary>
/// 是否缓存1缓存 0不缓存
/// </summary>
public string isCache { get; set; }
/// <summary>
/// 是否外链 1、是 0、否
/// </summary>
public string isFrame { get; set; }
/// <summary>
/// 类型M目录 C菜单 F按钮 L链接
/// </summary>
public string menuType { get; set; }
/// <summary>
/// 显示状态0显示 1隐藏
/// </summary>
public string visible { get; set; }
/// <summary>
/// 菜单状态0正常 1停用
/// </summary>
public string status { get; set; }
/// <summary>
/// 权限字符串
/// </summary>
[SugarColumn(IsNullable = true)]
public string perms { get; set; }
/// <summary>
/// 菜单图标
/// </summary>
[SugarColumn(IsNullable = true)]
public string icon { get; set; } = string.Empty;
/// <summary>
/// 菜单名key
/// </summary>
[SugarColumn(ColumnName = "menuName_key", IsNullable = true)]
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;
}
}
}
}

View File

@ -0,0 +1,47 @@
using System;
using System.Collections.Generic;
using SqlSugar;
namespace ARW.Model.System
{
/// <summary>
/// 通知公告表,数据实体对象
///
/// @author zr
/// @date 2021-12-15
/// </summary>
[SugarTable("sys_notice")]
[Tenant(0)]
public class SysNotice : SysBase
{
/// <summary>
/// 描述 : 公告ID
/// 空值 : true
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "notice_id")]
public int NoticeId { get; set; }
/// <summary>
/// 描述 : 公告标题
/// 空值 : true
/// </summary>
[SugarColumn(ColumnName = "notice_title")]
public string NoticeTitle { get; set; }
/// <summary>
/// 描述 : 公告类型 (1通知 2公告)
/// 空值 : true
/// </summary>
[SugarColumn(ColumnName = "notice_type")]
public string NoticeType { get; set; }
/// <summary>
/// 描述 : 公告内容
/// 空值 : true
/// </summary>
[SugarColumn(ColumnName = "notice_content")]
public string NoticeContent { get; set; }
/// <summary>
/// 描述 : 公告状态 (0正常 1关闭)
/// 空值 : true
/// </summary>
public string Status { get; set; }
}
}

View File

@ -0,0 +1,92 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
using OfficeOpenXml.Attributes;
namespace ARW.Model.System
{
[SugarTable("sys_oper_log")]
[Tenant("0")]
public class SysOperLog
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long OperId { get; set; }
/** 操作模块 */
//@Excel(name = "操作模块")
[SugarColumn(IsNullable = true)]
public string title { get; set; }
/** 业务类型0其它 1新增 2修改 3删除 */
//@Excel(name = "业务类型", readConverterExp = "0=其它,1=新增,2=修改,3=删除,4=授权,5=导出,6=导入,7=强退,8=生成代码,9=清空数据")
public int businessType { get; set; }
/** 业务类型数组 */
[SugarColumn(IsIgnore = true)]
public int[] businessTypes { get; set; }
/** 请求方法 */
//@Excel(name = "请求方法")
[SugarColumn(IsNullable = true)]
public string method { get; set; }
/** 请求方式 */
//@Excel(name = "请求方式")
public string requestMethod { get; set; }
/** 操作类别0其它 1后台用户 2手机端用户 */
//@Excel(name = "操作类别", readConverterExp = "0=其它,1=后台用户,2=手机端用户")
public int operatorType { get; set; }
/** 操作人员 */
//@Excel(name = "操作人员")
[SugarColumn(IsNullable = true)]
public string operName { get; set; }
/** 部门名称 */
//@Excel(name = "部门名称")
[SugarColumn(IsNullable = true)]
public string deptName { get; set; }
/** 请求url */
//@Excel(name = "请求地址")
public string operUrl { get; set; }
/** 操作地址 */
//@Excel(name = "操作地址")
public string operIp { get; set; }
/** 操作地点 */
//@Excel(name = "操作地点")
public string operLocation { get; set; }
/** 请求参数 */
//@Excel(name = "请求参数")
public string operParam { get; set; }
/** 返回参数 */
//@Excel(name = "返回参数")
public string jsonResult { get; set; }
/** 操作状态0正常 1异常 */
//@Excel(name = "状态", readConverterExp = "0=正常,1=异常")
public int status { get; set; }
/// <summary>
/// 错误消息
/// </summary>
[EpplusTableColumn(Header = "错误消息")]
public string errorMsg { get; set; }
/// <summary>
/// 操作时间
/// </summary>
[EpplusTableColumn(Header = "操作时间", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime? operTime { get; set; }
/// <summary>
/// 操作用时
/// </summary>
public long Elapsed { get; set; }
}
}

View File

@ -0,0 +1,22 @@
using OfficeOpenXml.Attributes;
using SqlSugar;
namespace ARW.Model.System
{
[SugarTable("sys_post")]
[Tenant("0")]
public class SysPost : SysBase
{
/// <summary>
/// 岗位Id
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long PostId { get; set; }
public string PostCode { get; set; }
public string PostName { get; set; }
[EpplusIgnore]
public int PostSort { get; set; }
[EpplusIgnore]
public string Status { get; set; }
}
}

View File

@ -0,0 +1,94 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.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>
public string RoleName { get; set; }
/// <summary>
/// 角色权限
/// </summary>
public string RoleKey { get; set; }
/// <summary>
/// 角色排序
/// </summary>
public int RoleSort { get; set; }
/// <summary>
/// 帐号状态0正常 1停用
/// </summary>
public string Status { get; set; }
/// <summary>
/// 删除标志0代表存在 2代表删除
/// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true, IsOnlyIgnoreUpdate = true)]
public string DelFlag { get; set; }
/// <summary>
/// 数据范围1全部数据权限 2自定数据权限 3本部门数据权限 4本部门及以下数据权限
/// </summary>
public string DataScope { get; set; }
/// <summary>
/// 菜单树选择项是否关联显示
/// </summary>
[SugarColumn(ColumnName = "menu_check_strictly")]
public bool MenuCheckStrictly { get; set; }
/// <summary>
/// 部门树选择项是否关联显示
/// </summary>
[SugarColumn(ColumnName = "dept_check_strictly")]
public bool DeptCheckStrictly { get; set; }
/// <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;
}
}
}

View File

@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
[SqlSugar.SugarTable("sys_role_dept")]
[SqlSugar.Tenant(0)]
public class SysRoleDept
{
public long RoleId { get; set; }
public long DeptId { get; set; }
}
}

View File

@ -0,0 +1,25 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 角色菜单
/// </summary>
[SugarTable("sys_role_menu")]
[Tenant("0")]
public class SysRoleMenu
{
[JsonProperty("roleId")]
[SugarColumn(IsPrimaryKey = true)]
public long Role_id { get; set; }
[JsonProperty("menuId")]
[SugarColumn(IsPrimaryKey = true)]
public long Menu_id { get; set; }
public DateTime Create_time { get; set; }
public string Create_by { get; set; }
}
}

View File

@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;
namespace ARW.Model.System
{
/// <summary>
/// 角色部门
/// </summary>
[SugarTable("sys_role_post")]
[Tenant("0")]
public class SysRolePost
{
public long RoleId { get; set; }
public long DeptId { get; set; }
}
}

View File

@ -0,0 +1,54 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 任务日志
/// </summary>
[SugarTable("sys_tasks_log")]
[Tenant("0")]
public class SysTasksLog
{
/// <summary>
/// 日志Id
/// </summary>
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsIdentity = true, IsPrimaryKey = true)]
public long JobLogId { get; set; }
/// <summary>
/// 任务Id
/// </summary>
public string JobId { get; set; }
public string JobName { get; set; }
public string JobGroup { get; set; }
/// <summary>
/// 执行状态0正常 1失败
/// </summary>
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; }
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime CreateTime { get; set; }
/// <summary>
/// 执行用时,毫秒
/// </summary>
//[SqlSugar.SugarColumn(IsIgnore = true)]
public double Elapsed { get; set; }
}
}

View File

@ -0,0 +1,170 @@
using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace ARW.Model.System
{
///<summary>
///计划任务
///</summary>
[SugarTable("sys_tasks")]
[Tenant("0")]
public class SysTasksQz
{
public SysTasksQz()
{
}
/// <summary>
/// 描述 : UID
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "UID")]
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true,IsIdentity =true)]
public int ID { get; set; }
/// <summary>
/// 描述 : 任务名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务名称")]
public string Name { get; set; }
/// <summary>
/// 描述 : 任务分组
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务分组")]
public string JobGroup { get; set; }
/// <summary>
/// 描述 : 运行时间表达式
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "运行时间表达式")]
public string Cron { get; set; }
/// <summary>
/// 描述 : 程序集名称
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "程序集名称")]
public string AssemblyName { get; set; }
/// <summary>
/// 描述 : 任务所在类
/// 空值 : False
/// 默认 :
/// </summary>
[Display(Name = "任务所在类")]
public string ClassName { get; set; }
/// <summary>
/// 描述 : 任务描述
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "任务描述")]
public string Remark { get; set; }
/// <summary>
/// 描述 : 执行次数
/// 空值 : False
/// 默认 : 0
/// </summary>
[Display(Name = "执行次数")]
public int RunTimes { get; set; }
/// <summary>
/// 描述 : 开始时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "开始时间")]
public DateTime? BeginTime { get; set; }
/// <summary>
/// 描述 : 结束时间
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "结束时间")]
public DateTime? EndTime { get; set; }
/// <summary>
/// 描述 : 触发器类型0、simple 1、cron
/// 空值 : False
/// 默认 : 1
/// </summary>
[Display(Name = "触发器类型0、simple 1、cron")]
public int TriggerType { get; set; }
/// <summary>
/// 描述 : 执行间隔时间(单位:秒)
/// 空值 : False
/// 默认 : 0
/// </summary>
[Display(Name = "执行间隔时间(单位:秒)")]
public int IntervalSecond { get; set; }
/// <summary>
/// 描述 : 是否启动
/// 空值 : False
/// 默认 : 0
/// </summary>
[Display(Name = "是否启动")]
public bool IsStart { get; set; }
/// <summary>
/// 描述 : 传入参数
/// 空值 : True
/// 默认 :
/// </summary>
[Display(Name = "传入参数")]
public string JobParams { get; set; }
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateBy")]
public string Create_by { get; set; }
/// <summary>
/// 描述 : 创建时间
/// 空值 : False
/// 默认 :
/// </summary>
//[Display(Name = "创建时间")]
[SugarColumn(IsOnlyIgnoreUpdate = true)]//设置后修改不会有此字段
[JsonProperty(propertyName: "CreateTime")]
public DateTime Create_time { get; set; } = DateTime.Now;
[JsonIgnore]
[JsonProperty(propertyName: "UpdateBy")]
[SugarColumn(IsOnlyIgnoreInsert = true)]
public string Update_by { get; set; }
[SugarColumn(IsOnlyIgnoreInsert = true)]//设置后插入数据不会有此字段
[JsonProperty(propertyName: "UpdateTime")]
public DateTime Update_time { get; set; } = DateTime.Now;
/// <summary>
/// 最后运行时间
/// </summary>
public DateTime? LastRunTime { get; set; }
/// <summary>
/// api执行地址
/// </summary>
public string ApiUrl { get; set; }
/// <summary>
/// 任务类型 1程序集2网络请求
/// </summary>
public int TaskType { get; set; }
}
}

View File

@ -0,0 +1,144 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.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; }
//[Duplication]//校验模板类该列数据是否重复
public string UserName { get; set; }
public string NickName { get; set; }
/// <summary>
/// '用户类型00系统用户',
/// </summary>
//[JsonProperty(propertyName: "userType")]
//public string User_type { get; set; } = "";
[SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusIgnore]
public string Avatar { get; set; }
public string Email { get; set; }
//[JsonIgnore]
[EpplusIgnore]
public string Password { get; set; }
/// <summary>
/// 手机号
/// </summary>
public string Phonenumber { get; set; }
/// <summary>
/// 用户性别0男 1女 2未知
/// </summary>
public string Sex { get; set; }
/// <summary>
/// 帐号状态0正常 1停用
/// </summary>
[EpplusIgnore]
public string Status { get; set; }
/// <summary>
/// 删除标志0代表存在 2代表删除
/// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true)]
public string DelFlag { get; set; }
/// <summary>
/// 最后登录IP
/// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true)]
public string LoginIP { get; set; }
/// <summary>
/// 最后登录时间
/// </summary>
[SugarColumn(IsOnlyIgnoreInsert = true)]
[EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
public DateTime LoginDate { get; set; }
/// <summary>
/// 部门Id
/// </summary>
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)]
[EpplusIgnore]
public long[] RoleIds { get; set; }
/// <summary>
/// 岗位集合
/// </summary>
[SugarColumn(IsIgnore = true)]
[EpplusIgnore]
public int[] PostIds { get; set; }
[SugarColumn(IsIgnore = true)]
[EpplusIgnore]
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
}
}

View File

@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
using System.Text;
using SqlSugar;
namespace ARW.Model.System
{
/// <summary>
/// 用户岗位
/// </summary>
[SugarTable("sys_user_post")]
[Tenant("0")]
public class SysUserPost
{
public long UserId { get; set; }
public long PostId { get; set; }
}
}

View File

@ -0,0 +1,21 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
/// <summary>
/// 用户角色关联表 用户N-1 角色
/// </summary>
[SqlSugar.SugarTable("sys_user_role")]
[Tenant("0")]
public class SysUserRole
{
[SqlSugar.SugarColumn(ColumnName = "user_id", IsPrimaryKey = true)]
public long UserId { get; set; }
[SqlSugar.SugarColumn(ColumnName = "role_id", IsPrimaryKey = true)]
public long RoleId { get; set; }
}
}

View File

@ -0,0 +1,75 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.Model.System
{
public class UserConstants
{
/**
*
*/
public static string SYS_USER = "SYS_USER";
/** 正常状态 */
public static string NORMAL = "0";
/** 异常状态 */
public static string EXCEPTION = "1";
/** 用户封禁状态 */
public static string USER_DISABLE = "1";
/** 角色封禁状态 */
public static string ROLE_DISABLE = "1";
/** 部门正常状态 */
public static string DEPT_NORMAL = "0";
/** 部门停用状态 */
public static string DEPT_DISABLE = "1";
/** 字典正常状态 */
public static string DICT_NORMAL = "0";
/** 是否为系统默认(是) */
public static string YES = "Y";
/** 是否菜单外链(是) */
public static string YES_FRAME = "1";
/** 是否菜单外链(否) */
public static string NO_FRAME = "0";
/** 菜单类型(目录) */
public static string TYPE_DIR = "M";
/** 菜单类型(菜单) */
public static string TYPE_MENU = "C";
/** 菜单类型(按钮) */
public static string TYPE_BUTTON = "F";
/** 菜单类型(链接) */
//public static string TYPE_ARWNK = "L";
/** Layout组件标识 */
public static string LAYOUT = "Layout";
/** ParentView组件标识 */
public static string PARENT_VIEW = "ParentView";
/** InnerLink组件标识 */
public static string INNER_ARWNK = "InnerLink";
/** 校验返回结果码 */
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://";
}
}

View File

@ -0,0 +1,13 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARW.Model.System.Vo
{
public class LangVo
{
}
}

View File

@ -0,0 +1,70 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
namespace ARW.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 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)
{
Title = title;
Icon = icon;
NoCache = noCache;
}
public Meta(string title, string icon, bool noCache, string titleKey, string path)
{
Title = title;
Icon = icon;
NoCache = noCache;
TitleKey = titleKey;
Link = path;
}
}
}

View File

@ -0,0 +1,58 @@
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Text;
using ARW.Model.System;
namespace ARW.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 TreeSelectVo() { }
public TreeSelectVo(SysMenu menu)
{
Id = menu.MenuId;
Label = menu.MenuName;
//menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); java写法
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; }
}
}

View File

@ -0,0 +1,37 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
namespace ARW.Model.Vo.Chat
{
public class ChatApplyRequestVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long SenderGuId { get; set; }
public string SenderName { get; set; }
public string SenderImg { get; set; }
public string Postscript { get; set; }
public string Reply { get; set; }
public DateTime SendTime { get; set; }
public bool? IsAgree { get; set; }
public bool? IsGroupApply { get; set; }
public bool? IsRead { get; set; }
}
}

View File

@ -0,0 +1,128 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
using ARW.Model.Models.Business.Chat.ChatGPT;
using ARW.Model.Models.Business.Chat;
namespace ARW.Model.Vo.Chat.ChatGPT
{
public class ChatGPTLogVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long ReceiverGuId { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long SenderGuId { get; set; }
public string ChatGptLogContent { get; set; }
public DateTime ChatGptLogSendTime { get; set; }
}
//public class ChatGPTLogListVo
//{
// [JsonConverter(typeof(ValueToStringConverter))]
// public long SenderGuId { get; set; }
// [JsonConverter(typeof(ValueToStringConverter))]
// public long ReceiverGuId { get; set; }
// public string ChatGPTLogContent { get; set; }
// public string ChatGPTLogSendTime { get; set; }
// public FriendsVo ChatGPTUserObject
// {
// get
// {
// //var sex = "";
// //if (this.Sex == "1")
// //{
// // sex = "男";
// //}
// //else
// //{
// // sex = "女";
// //}
// return new FriendsVo
// {
// FriendGuId = this.ChatGPTUserGuId,
// FriendName = this.ChatGPTUserName,
// FriendNickName = this.ChatGPTUserNickName,
// FriendImg = this.ChatGPTUserImg,
// Sex = this.Sex,
// Age = this.Age,
// Phone = this.Phone,
// Email = this.Email,
// FriendNote = this.FriendNote,
// IsRead = this.IsRead,
// };
// }
// set { }
// }
// public GroupListVo GroupObject
// {
// get
// {
// return new GroupListVo
// {
// GroupGuId = this.GroupGuId,
// GroupName = this.GroupName,
// GroupImg = this.GroupImg,
// GroupIsRead = this.GroupIsRead,
// };
// }
// set { }
// }
// public bool IsRead { get; set; }
// [JsonIgnore]
// [JsonConverter(typeof(ValueToStringConverter))]
// public long GroupGuId { get; set; }
// [JsonIgnore]
// public string GroupName { get; set; }
// [JsonIgnore]
// public string GroupImg { get; set; }
// [JsonIgnore]
// public bool GroupIsRead { get; set; }
// [JsonIgnore]
// [JsonConverter(typeof(ValueToStringConverter))]
// public long ChatGPTUserGuId { get; set; }
// [JsonIgnore]
// public string ChatGPTUserName { get; set; }
// [JsonIgnore]
// public string ChatGPTUserNickName { get; set; }
// [JsonIgnore]
// public string ChatGPTUserImg { get; set; }
// [JsonIgnore]
// public string Sex { get; set; }
// [JsonIgnore]
// public int Age { get; set; }
// [JsonIgnore]
// public string Phone { get; set; }
// [JsonIgnore]
// public string Email { get; set; }
// [JsonIgnore]
// public string FriendNote { get; set; }
//}
}

View File

@ -0,0 +1,129 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
using ARW.Model.Models.Business.Chat;
namespace ARW.Model.Vo.Chat
{
public class ChatLogVo
{
public string ChatLogType { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long SenderGuId { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long ReceiverGuId { get; set; }
public string ChatLogContent { get; set; }
public DateTime ChatLogSendTime { get; set; }
public ChatUser Sender{ get; set; }
}
public class ChatLogListVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long SenderGuId { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long ReceiverGuId { get; set; }
public string ChatLogContent { get; set; }
public string ChatLogSendTime { get; set; }
public FriendsVo ChatUserObject
{
get
{
//var sex = "";
//if (this.Sex == "1")
//{
// sex = "男";
//}
//else
//{
// sex = "女";
//}
return new FriendsVo
{
FriendGuId = this.ChatUserGuId,
FriendName = this.ChatUserName,
FriendNickName = this.ChatUserNickName,
FriendImg = this.ChatUserImg,
Sex = this.Sex,
Age = this.Age,
Phone = this.Phone,
Email = this.Email,
FriendNote = this.FriendNote,
IsRead = this.IsRead,
};
}
set { }
}
public GroupListVo GroupObject
{
get
{
return new GroupListVo
{
GroupGuId = this.GroupGuId,
GroupName = this.GroupName,
GroupImg = this.GroupImg,
GroupIsRead = this.GroupIsRead,
};
}
set { }
}
public bool IsRead { get; set; }
[JsonIgnore]
[JsonConverter(typeof(ValueToStringConverter))]
public long GroupGuId { get; set; }
[JsonIgnore]
public string GroupName { get; set; }
[JsonIgnore]
public string GroupImg { get; set; }
[JsonIgnore]
public bool GroupIsRead { get; set; }
[JsonIgnore]
[JsonConverter(typeof(ValueToStringConverter))]
public long ChatUserGuId { get; set; }
[JsonIgnore]
public string ChatUserName { get; set; }
[JsonIgnore]
public string ChatUserNickName { get; set; }
[JsonIgnore]
public string ChatUserImg { get; set; }
[JsonIgnore]
public string Sex { get; set; }
[JsonIgnore]
public int Age { get; set; }
[JsonIgnore]
public string Phone { get; set; }
[JsonIgnore]
public string Email { get; set; }
[JsonIgnore]
public string FriendNote { get; set; }
}
}

View File

@ -0,0 +1,38 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
namespace ARW.Model.Vo.Chat
{
public class ChatUserVo
{
public int ChatUserId { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long ChatUserGuId { get; set; }
public string ChatUserName { get; set; }
public string ChatUserNickName { get; set; }
public string ChatUserImg { get; set; }
public string Sex { get; set; }
public int? Age { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public int? Status { get;set; }
}
}

View File

@ -0,0 +1,43 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
namespace ARW.Model.Vo.Chat
{
public class FriendsVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long FriendGuId { get; set; }
public string FriendName { get; set; }
public string FriendNickName { get; set; }
public string FriendImg { get; set; }
public string FriendNote { get; set; }
public DateTime CreateTime { get; set; }
public string Sex { get; set; }
public int? Age { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public int? Status { get; set; }
public bool IsRead { get; set; }
}
}

View File

@ -0,0 +1,44 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
using ARW.Model.Models.Business.Chat;
namespace ARW.Model.Vo.Chat
{
public class GroupVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long GroupGuId { get; set; }
public string GroupName { get; set; }
public string GroupImg { get; set; }
public int GroupNum { get; set; }
public ChatUser GroupUserList { get; set; }
public DateTime CreateTime { get; set; }
}
public class GroupListVo
{
[JsonConverter(typeof(ValueToStringConverter))]
public long GroupGuId { get; set; }
public string GroupName { get; set; }
public string GroupImg { get; set; }
public bool GroupIsRead { get; set; }
}
}

View File

@ -0,0 +1,51 @@
using Newtonsoft.Json;
using OfficeOpenXml.Attributes;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ARW.Model.Models.Business;
using ARW.Model.Models.Business.Crawler;
using Newtonsoft.Json.Linq;
namespace ARW.Model.Vo.Crawler
{
public class CrawlVo
{
public long Id { get; set; }
public string Name { get; set; }
public string Intro { get; set; }
public string Cover { get; set; }
public string Link { get; set; }
public string Type { get; set; }
public DateTime PublishTime { get; set; }
[JsonIgnore]
public List<Resource> DownResources { get; set; }
public string Resources
{
get
{
if (this.DownResources != null)
{
return JToken.FromObject(this.DownResources).ToString();
}
else
{
return "[]";
}
}
}
}
}

View File

@ -0,0 +1,23 @@
using Newtonsoft.Json;
using SqlSugar;
using System.Collections.Generic;
namespace ARW.Model.Vo
{
public class ProductTypeVo
{
[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsTreeKey = true)]
public long ProductTypeId { get; set; }
[JsonConverter(typeof(ValueToStringConverter))]
public long ParentId { get; set; }
public string ProductTypeName { get; set; }
[JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
[SugarColumn(IsIgnore = true)]
public List<ProductTypeVo> Children { get; set; }
}
}

Some files were not shown because too many files have changed in this diff Show More