diff --git a/README.md b/README.md
index fae192b729ea295e5a31713650af1d1871655e44..0e90a62842ab641ac27eae3ae7ac2eaa11cc7c85 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,5 @@
- ZRAdmin.NET鍚庡彴绠$悊绯荤粺
-鍩轰簬.NET5/.NET6 + vue2.x/vue3.x鍓嶅悗绔垎绂荤殑.net蹇熷紑鍙戞鏋
+ ZR.Admin.NET鍚庡彴绠$悊绯荤粺
+鍩轰簬.NET5/.NET6/.Net7 + vue2.x/vue3.x鍓嶅悗绔垎绂荤殑.net蹇熷紑鍙戞鏋
@@ -34,14 +34,15 @@
| 浠撳簱 | Github | Gitee |
| ----------- | ---------------------------------------------------------------- | ---------------------------------------------------------------- |
| Vue2 + Net5 | | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZrAdminNetCore/) |
-| Vue2 + Net6 | [鍏嬮殕/涓嬭浇](https://github.com/izhaorui/ZrAdmin.NET/tree/net6.0) | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZrAdminNetCore/tree/net6.0/) |
-| Vue3 | [鍏嬮殕/涓嬭浇](https://github.com/izhaorui/ZRAdminVue) | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZRAdmin-vue)
+| Vue2 + Net6(鍋滄洿) | [鍏嬮殕/涓嬭浇](https://github.com/izhaorui/ZrAdmin.NET/tree/net6.0) | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZrAdminNetCore/tree/net6.0/) |
+| Vue3 | | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZRAdmin-vue) |
+| Net7 | | [鍏嬮殕/涓嬭浇](https://gitee.com/izory/ZrAdminNetCore/tree/net7.0/) |
## 馃崄鍓嶇鎶鏈
Vue鐗堝墠绔妧鏈爤 锛氬熀浜巚ue2.x/vue3.x銆乿uex銆乿ue-router 銆乿ue-cli 銆乤xios銆 element-ui銆乪chats銆乮18n鍥介檯鍖栫瓑锛屽墠绔噰鐢╲scode宸ュ叿寮鍙
## 馃崁鍚庣鎶鏈
-- 鏍稿績妗嗘灦锛.Net5.0/.Net6.0 + Web API + sqlsugar + swagger + signalR + IpRateLimit + Quartz.net + Redis
+- 鏍稿績妗嗘灦锛.Net5.0/.Net6.0/.Net7.0 + Web API + sqlsugar + swagger + signalR + IpRateLimit + Quartz.net + Redis
- 瀹氭椂璁″垝浠诲姟锛歈uartz.Net缁勪欢锛屾敮鎸佹墽琛岀▼搴忛泦鎴栬卙ttp缃戠粶璇锋眰
- 瀹夊叏鏀寔锛氳繃婊ゅ櫒(鏁版嵁鏉冮檺杩囨护)銆丼ql娉ㄥ叆銆佽姹備吉閫
- 鏃ュ織绠$悊锛歂Log銆佺櫥褰曟棩蹇椼佹搷浣滄棩蹇椼佸畾鏃朵换鍔℃棩蹇
@@ -66,16 +67,16 @@ Vue鐗堝墠绔妧鏈爤 锛氬熀浜巚ue2.x/vue3.x銆乿uex銆乿ue-router 銆乿ue-cli 銆乤
8. 鐧诲綍鏃ュ織锛氱郴缁熺櫥褰曟棩蹇楄褰曟煡璇㈠寘鍚櫥褰曞紓甯搞
9. 绯荤粺鎺ュ彛锛氫娇鐢 swagger 鐢熸垚鐩稿叧 api 鎺ュ彛鏂囨。銆
10. 鏈嶅姟鐩戞帶锛氱洃瑙嗗綋鍓嶇郴缁 CPU銆佸唴瀛樸佺鐩樸佸爢鏍堢瓑鐩稿叧淇℃伅銆
-11. 鍦ㄧ嚎鏋勫缓鍣細鎷栧姩琛ㄥ崟鍏冪礌鐢熸垚鐩稿簲鐨 VUE 浠g爜銆
+11. 鍦ㄧ嚎鏋勫缓鍣細鎷栧姩琛ㄥ崟鍏冪礌鐢熸垚鐩稿簲鐨 VUE 浠g爜(浠呮敮鎸乿ue2)銆
12. 浠诲姟绯荤粺锛氬熀浜 Quartz.NET锛屽彲浠ュ湪绾匡紙娣诲姞銆佷慨鏀广佸垹闄ゃ佹墜鍔ㄦ墽琛)浠诲姟璋冨害鍖呭惈鎵ц缁撴灉鏃ュ織銆
13. 鏂囩珷绠$悊锛氬彲浠ュ啓鏂囩珷璁板綍銆
-14. 浠g爜鐢熸垚锛氬彲浠ヤ竴閿敓鎴愬墠鍚庣浠g爜(.cs銆.vue銆.js銆乻ql绛)鏀寔涓嬭浇锛岃嚜瀹氫箟閰嶇疆鍓嶇灞曠ず鎺т欢銆佽寮鍙戞洿蹇嵎楂樻晥銆
+14. 浠g爜鐢熸垚锛氬彲浠ヤ竴閿敓鎴愬墠鍚庣浠g爜(.cs銆.vue銆.js銆.sql绛)鏀寔涓嬭浇锛岃嚜瀹氫箟閰嶇疆鍓嶇灞曠ず鎺т欢銆佽寮鍙戞洿蹇嵎楂樻晥锛堝彶涓婃渶寮猴級銆
15. 鍙傛暟绠$悊锛氬绯荤粺鍔ㄦ侀厤缃父鐢ㄥ弬鏁般
16. 鍙戦侀偖浠讹細鍙互瀵瑰涓敤鎴疯繘琛屽彂閫侀偖浠躲
17. 鏂囦欢绠$悊锛氬彲浠ヨ繘琛屼笂浼犳枃浠剁鐞嗭紝鐩墠鏀寔涓婁紶鍒版湰鍦般侀樋閲屼簯銆
18. 閫氱煡绠$悊锛氱郴缁熼氱煡鍏憡淇℃伅鍙戝竷缁存姢锛屼娇鐢 signalr 瀹炵幇瀵圭敤鎴峰疄鏃堕氱煡銆
19. 璐﹀彿娉ㄥ唽锛氬彲浠ユ敞鍐岃处鍙风櫥褰曠郴缁熴
-20. 澶氳瑷绠$悊锛氭敮鎸侀潤鎬併佸悗绔姩鎬侀厤缃浗闄呭寲銆傜洰鍓嶅彧鏀寔涓佽嫳銆佺箒浣
+20. 澶氳瑷绠$悊锛氭敮鎸侀潤鎬併佸悗绔姩鎬侀厤缃浗闄呭寲銆傜洰鍓嶅彧鏀寔涓佽嫳銆佺箒浣(浠呮敮鎸乿ue3)
## 馃嵒椤圭洰缁撴瀯
@@ -146,6 +147,7 @@ Vue鐗堝墠绔妧鏈爤 锛氬熀浜巚ue2.x/vue3.x銆乿uex銆乿ue-router 銆乿ue-cli 銆乤
- 馃憠Ruoyi.vue锛歔Ruoyi](http://www.ruoyi.vip/)
- 馃憠SqlSugar锛歔SqlSugar](https://gitee.com/dotnetchina/SqlSugar)
- 馃憠vue-element-admin锛歔vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
+- 馃憠Meiam.System锛歔Meiam.System](https://github.com/91270/Meiam.System)
## 馃巰鎹愯禒
濡傛灉浣犺寰楄繖涓」鐩府鍔╁埌浜嗕綘锛屼綘鍙互璇蜂綔鑰呭枬鏉挅鍟¤〃绀洪紦鍔 鈽曪笍
diff --git a/ZR.Admin.WebApi/Controllers/BaseController.cs b/ZR.Admin.WebApi/Controllers/BaseController.cs
index 2038e6ab2e70a11266718722cad4d07145e6ba56..cada36daad8e46cde3ee1598be10829f5304db3c 100644
--- a/ZR.Admin.WebApi/Controllers/BaseController.cs
+++ b/ZR.Admin.WebApi/Controllers/BaseController.cs
@@ -2,12 +2,14 @@
using Infrastructure.Model;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Mvc;
+using MiniExcelLibs;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
-using OfficeOpenXml;
using System;
using System.Collections.Generic;
using System.IO;
+using System.Web;
+using ff = System.IO;
namespace ZR.Admin.WebApi.Controllers
{
@@ -53,6 +55,21 @@ namespace ZR.Admin.WebApi.Controllers
return ToResponse(GetApiResult(resultCode, msg));
}
+ ///
+ /// 瀵煎嚭Excel
+ ///
+ /// 瀹屾暣鏂囦欢璺緞
+ /// 甯︽墿灞曟枃浠跺悕
+ ///
+ protected IActionResult ExportExcel(string path, string fileName)
+ {
+ //IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
+ //string fileDir = Path.Combine(webHostEnvironment.WebRootPath, path, fileName);
+
+ var stream = ff.File.OpenRead(path); //鍒涘缓鏂囦欢娴
+ return File(stream, "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", HttpUtility.UrlEncode(fileName));
+ }
+
#region 鏂规硶
///
@@ -112,25 +129,20 @@ namespace ZR.Admin.WebApi.Controllers
///
///
protected string ExportExcel(List list, string sheetName, string fileName)
+ {
+ return ExportExcelMini(list, sheetName, fileName).Item1;
+ }
+
+ protected (string, string) ExportExcelMini(List list, string sheetName, string fileName)
{
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
- string sFileName = $"{fileName}{DateTime.Now:MMddHHmmss}.xlsx";
- string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
- //璋冭瘯妯″紡闇瑕佸姞涓
- ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
- Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
- using (ExcelPackage package = new(new FileInfo(newFileName)))
- {
- // 娣诲姞worksheet
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(sheetName);
- //鍗曞厓鏍艰嚜鍔ㄩ傚簲澶у皬
- worksheet.Cells.Style.ShrinkToFit = true;
- //鍏ㄩ儴瀛楁瀵煎嚭
- worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
- package.Save();
- }
+ string sFileName = $"{fileName}{DateTime.Now:MM-dd-HHmmss}.xlsx";
+ string fullPath = Path.Combine(webHostEnvironment.WebRootPath, "export", sFileName);
+
+ Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
- return sFileName;
+ MiniExcel.SaveAs(fullPath, list, sheetName: sheetName);
+ return (sFileName, fullPath);
}
///
@@ -146,23 +158,12 @@ namespace ZR.Admin.WebApi.Controllers
IWebHostEnvironment webHostEnvironment = (IWebHostEnvironment)App.ServiceProvider.GetService(typeof(IWebHostEnvironment));
string sFileName = $"{fileName}妯℃澘.xlsx";
string newFileName = Path.Combine(webHostEnvironment.WebRootPath, "importTemplate", sFileName);
- //璋冭瘯妯″紡闇瑕佸姞涓
- ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
+
if (!Directory.Exists(newFileName))
{
Directory.CreateDirectory(Path.GetDirectoryName(newFileName));
}
- using (ExcelPackage package = new(new FileInfo(newFileName)))
- {
- // 娣诲姞worksheet
- ExcelWorksheet worksheet = package.Workbook.Worksheets.Add(fileName);
- //鍗曞厓鏍艰嚜鍔ㄩ傚簲澶у皬
- worksheet.Cells.Style.ShrinkToFit = true;
- //鍏ㄩ儴瀛楁瀵煎嚭
- worksheet.Cells.LoadFromCollection(list, true, OfficeOpenXml.Table.TableStyles.Light13);
- package.SaveAs(stream);
- }
-
+ MiniExcel.SaveAs(newFileName, list);
return sFileName;
}
}
diff --git a/ZR.Admin.WebApi/Controllers/CommonController.cs b/ZR.Admin.WebApi/Controllers/CommonController.cs
index 3c549e53dd055816345acd0e275a842862d4f9d5..16d597528a1e6554739f73af9abbbf450116428c 100644
--- a/ZR.Admin.WebApi/Controllers/CommonController.cs
+++ b/ZR.Admin.WebApi/Controllers/CommonController.cs
@@ -16,6 +16,7 @@ using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model.System;
+using ZR.Model.System.Dto;
using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers
@@ -47,7 +48,7 @@ namespace ZR.Admin.WebApi.Controllers
public IActionResult Index()
{
return Ok("鐪嬪埌杩欓噷椤甸潰璇存槑浣犲凡缁忔垚鍔熷惎鍔ㄤ簡鏈」鐩:)\n\n" +
- "濡傛灉瑙夊緱椤圭洰鏈夌敤锛屾墦璧忎綔鑰呭枬鏉挅鍟′綔涓哄鍔盶n鈽涒槢http://www.izhaorui.cn/doc\n");
+ "濡傛灉瑙夊緱椤圭洰鏈夌敤锛屾墦璧忎綔鑰呭枬鏉挅鍟′綔涓哄鍔盶n鈽涒槢http://www.izhaorui.cn/doc/support.html\n");
}
///
@@ -88,44 +89,55 @@ namespace ZR.Admin.WebApi.Controllers
///
/// 瀛樺偍鏂囦欢
///
- ///
- /// 瀛樺偍鐩綍
- /// 鑷畾涔夋枃浠跺悕
+ /// 鑷畾涔夋枃浠跺悕
/// 涓婁紶绫诲瀷1銆佷繚瀛樺埌鏈湴 2銆佷繚瀛樺埌闃块噷浜
///
[HttpPost()]
[Verify]
[ActionPermissionFilter(Permission = "common")]
- public async Task UploadFile([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "", StoreType storeType = StoreType.LOCAL)
+ public async Task UploadFile([FromForm] UploadDto uploadDto, StoreType storeType = StoreType.LOCAL)
{
+ IFormFile formFile = uploadDto.File;
if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "涓婁紶鏂囦欢涓嶈兘涓虹┖");
SysFile file = new();
string fileExt = Path.GetExtension(formFile.FileName);//鏂囦欢鍚庣紑
double fileSize = Math.Round(formFile.Length / 1024.0, 2);//鏂囦欢澶у皬KB
- string[] NotAllowedFileExtensions = new string[] { ".bat", ".exe", ".jar", ".js" };
- int MaxContentLength = 15;
- if (NotAllowedFileExtensions.Contains(fileExt))
+
+ if (OptionsSetting.Upload.NotAllowedExt.Contains(fileExt))
{
return ToResponse(ResultCode.CUSTOM_ERROR, "涓婁紶澶辫触锛屾湭缁忓厑璁镐笂浼犵被鍨");
}
+ if (uploadDto.FileNameType == 1)
+ {
+ uploadDto.FileName = Path.GetFileNameWithoutExtension(formFile.FileName);
+ }
+ else if (uploadDto.FileNameType == 3)
+ {
+ uploadDto.FileName = SysFileService.HashFileName();
+ }
switch (storeType)
{
case StoreType.LOCAL:
string savePath = Path.Combine(WebHostEnvironment.WebRootPath);
- if (fileDir.IsEmpty())
+ if (uploadDto.FileDir.IsEmpty())
{
- fileDir = AppSettings.App(new string[] { "Upload", "localSavePath" });
+ uploadDto.FileDir = OptionsSetting.Upload.LocalSavePath;
}
- file = await SysFileService.SaveFileToLocal(savePath, fileName, fileDir, HttpContext.GetName(), formFile);
+ file = await SysFileService.SaveFileToLocal(savePath, uploadDto.FileName, uploadDto.FileDir, HttpContext.GetName(), formFile);
break;
case StoreType.REMOTE:
break;
case StoreType.ALIYUN:
- if ((fileSize / 1024) > MaxContentLength)
+ int AlimaxContentLength = OptionsSetting.ALIYUN_OSS.MaxSize;
+ if (OptionsSetting.ALIYUN_OSS.REGIONID.IsEmpty())
{
- return ToResponse(ResultCode.CUSTOM_ERROR, "涓婁紶鏂囦欢杩囧ぇ锛屼笉鑳借秴杩 " + MaxContentLength + " MB");
+ return ToResponse(ResultCode.CUSTOM_ERROR, "閰嶇疆鏂囦欢缂哄け");
}
- file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, HttpContext.GetName())
+ if ((fileSize / 1024) > AlimaxContentLength)
+ {
+ return ToResponse(ResultCode.CUSTOM_ERROR, "涓婁紶鏂囦欢杩囧ぇ锛屼笉鑳借秴杩 " + AlimaxContentLength + " MB");
+ }
+ file = new(formFile.FileName, uploadDto.FileName, fileExt, fileSize + "kb", uploadDto.FileDir, HttpContext.GetName())
{
StoreType = (int)StoreType.ALIYUN,
FileType = formFile.ContentType
@@ -149,47 +161,23 @@ namespace ZR.Admin.WebApi.Controllers
});
}
+ #endregion
+ }
+
+ public class UploadDto
+ {
///
- /// 瀛樺偍鏂囦欢鍒伴樋閲屼簯(宸插純鐢)
+ /// 鑷畾鏂囦欢鍚
///
- ///
- /// 鑷畾涔夋枃浠跺悕
- /// 涓婁紶鏂囦欢澶硅矾寰
- ///
- [HttpPost]
- [Verify]
- [ActionPermissionFilter(Permission = "common")]
- public async Task UploadFileAliyun([FromForm(Name = "file")] IFormFile formFile, string fileName = "", string fileDir = "")
- {
- if (formFile == null) throw new CustomException(ResultCode.PARAM_ERROR, "涓婁紶鏂囦欢涓嶈兘涓虹┖");
- string fileExt = Path.GetExtension(formFile.FileName);//鏂囦欢鍚庣紑
- double fileSize = Math.Round(formFile.Length / 1024.0, 2);//鏂囦欢澶у皬KB
- string[] NotAllowedFileExtensions = new string[] { ".bat", ".exe", ".jar", ".js" };
- int MaxContentLength = 15;
- if (NotAllowedFileExtensions.Contains(fileExt))
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, "涓婁紶澶辫触锛屾湭缁忓厑璁镐笂浼犵被鍨");
- }
- if ((fileSize / 1024) > MaxContentLength)
- {
- return ToResponse(ResultCode.CUSTOM_ERROR, "涓婁紶鏂囦欢杩囧ぇ锛屼笉鑳借秴杩 " + MaxContentLength + " MB");
- }
- SysFile file = new(formFile.FileName, fileName, fileExt, fileSize + "kb", fileDir, HttpContext.GetName())
- {
- StoreType = (int)StoreType.ALIYUN,
- FileType = formFile.ContentType
- };
- file = await SysFileService.SaveFileToAliyun(file, formFile);
-
- if (file.Id <= 0) { return ToResponse(ApiResult.Error("闃块噷浜戣繛鎺ュけ璐")); }
-
- return SUCCESS(new
- {
- url = file.AccessUrl,
- fileName = file.FileName,
- fileId = file.Id.ToString()
- });
- }
- #endregion
+ public string FileName { get; set; }
+ ///
+ /// 瀛樺偍鐩綍
+ ///
+ public string FileDir { get; set; }
+ ///
+ /// 鏂囦欢鍚嶇敓鎴愮被鍨 1 鍘熸枃浠跺悕 2 鑷畾涔 3 鑷姩鐢熸垚
+ ///
+ public int FileNameType { get; set; }
+ public IFormFile File { get; set; }
}
}
diff --git a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs
index 75621ad44de7c8c360de3981159bca90b618bdec..3030b56c4c7746ea420ad5ac3a002f03848f4ba0 100644
--- a/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/CodeGeneratorController.cs
@@ -94,7 +94,7 @@ namespace ZR.Admin.WebApi.Controllers
//鏌ヨ鍘熻〃鏁版嵁锛岄儴鍒嗗瓧娈垫槧灏勫埌浠g爜鐢熸垚琛ㄥ瓧娈
var rows = GenTableService.GetGenTables(new GenTable() { TableName = tableName }, pagerInfo);
- return SUCCESS(rows);
+ return SUCCESS(rows, "MM鏈坉d鏃 HH:mm");
}
///
@@ -227,9 +227,11 @@ namespace ZR.Admin.WebApi.Controllers
[ActionPermissionFilter(Permission = "tool:gen:preview")]
public IActionResult Preview(long tableId = 0, int VueVersion = 0)
{
- GenerateDto dto = new();
- dto.TableId = tableId;
- dto.VueVersion = VueVersion;
+ GenerateDto dto = new()
+ {
+ TableId = tableId,
+ VueVersion = VueVersion
+ };
if (dto == null || dto.TableId <= 0)
{
throw new CustomException(ResultCode.CUSTOM_ERROR, "璇锋眰鍙傛暟涓虹┖");
diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
index b7b8c3e000b73ddd26eaa12ea262541fba0d1491..56cd88565882db39b35c0c5ed8c4e99ac24102c8 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysDictDataController.cs
@@ -76,6 +76,10 @@ namespace ZR.Admin.WebApi.Controllers.System
ColumnName = dic.ColumnName,
List = list.FindAll(f => f.DictType == dic.DictType)
};
+ if (dic.DictType.StartsWith("cus_") || dic.DictType.StartsWith("sql_"))
+ {
+ vo.List = SysDictService.SelectDictDataByCustomSql(dic.DictType);
+ }
dataVos.Add(vo);
}
return SUCCESS(dataVos);
diff --git a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
index 8c7389baf0126c94578f4a9269fd27c5929d105b..f70cb3cdd3bd923ed122431acd1eff8d2f69198e 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysDictTypeController.cs
@@ -1,6 +1,7 @@
锘縰sing Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure.Model;
+using Mapster;
using Microsoft.AspNetCore.Mvc;
using System;
using ZR.Admin.WebApi.Extensions;
@@ -8,6 +9,7 @@ using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
using ZR.Model.System;
+using ZR.Model.System.Dto;
using ZR.Service.System.IService;
namespace ZR.Admin.WebApi.Controllers.System
@@ -56,13 +58,14 @@ namespace ZR.Admin.WebApi.Controllers.System
///
/// 娣诲姞瀛楀吀绫诲瀷
///
- ///
+ ///
///
[ActionPermissionFilter(Permission = "system:dict:add")]
[Log(Title = "瀛楀吀鎿嶄綔", BusinessType = BusinessType.INSERT)]
[HttpPost("edit")]
- public IActionResult Add([FromBody] SysDictType dict)
+ public IActionResult Add([FromBody] SysDictTypeDto dto)
{
+ SysDictType dict = dto.Adapt();
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
{
return ToResponse(ApiResult.Error($"鏂板瀛楀吀'{dict.DictName}'澶辫触锛屽瓧鍏哥被鍨嬪凡瀛樺湪"));
@@ -75,14 +78,15 @@ namespace ZR.Admin.WebApi.Controllers.System
///
/// 淇敼瀛楀吀绫诲瀷
///
- ///
+ ///
///
[ActionPermissionFilter(Permission = "system:dict:edit")]
[Log(Title = "瀛楀吀鎿嶄綔", BusinessType = BusinessType.UPDATE)]
[Route("edit")]
[HttpPut]
- public IActionResult Edit([FromBody] SysDictType dict)
+ public IActionResult Edit([FromBody] SysDictTypeDto dto)
{
+ SysDictType dict = dto.Adapt();
if (UserConstants.NOT_UNIQUE.Equals(SysDictService.CheckDictTypeUnique(dict)))
{
return ToResponse(ApiResult.Error($"淇敼瀛楀吀'{dict.DictName}'澶辫触锛屽瓧鍏哥被鍨嬪凡瀛樺湪"));
diff --git a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
index ee5bb7a84e1d19f3cf7993dab010cbcf20a6e417..fab6993ea527e36b0ba5000451a6e85f38fca118 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysLoginController.cs
@@ -155,7 +155,24 @@ namespace ZR.Admin.WebApi.Controllers.System
SysConfig sysConfig = sysConfigService.GetSysConfigByKey("sys.account.captchaOnOff");
var captchaOff = sysConfig?.ConfigValue ?? "0";
- var code = SecurityCodeHelper.GetRandomEnDigitalText(4);
+ var length = AppSettings.GetAppConfig("CaptchaOptions:length", 4);
+ var code = SecurityCodeHelper.GetRandomEnDigitalText(length);
+ byte[] imgByte = GenerateCaptcha(captchaOff, code);
+ string base64Str = Convert.ToBase64String(imgByte);
+ CacheHelper.SetCache(uuid, code);
+ var obj = new { captchaOff, uuid, img = base64Str };// File(stream, "image/png")
+
+ return ToJson(1, obj);
+ }
+
+ ///
+ /// 鐢熸垚鍥剧墖楠岃瘉鐮
+ ///
+ ///
+ ///
+ ///
+ private byte[] GenerateCaptcha(string captchaOff, string code)
+ {
byte[] imgByte;
if (captchaOff == "1")
{
@@ -173,11 +190,8 @@ namespace ZR.Admin.WebApi.Controllers.System
{
imgByte = SecurityCodeHelper.GetEnDigitalCodeByte(code);//鑻辨枃瀛楁瘝鍔犳暟瀛
}
- string base64Str = Convert.ToBase64String(imgByte);
- CacheHelper.SetCache(uuid, code);
- var obj = new { uuid, img = base64Str };// File(stream, "image/png")
- return ToJson(1, obj);
+ return imgByte;
}
///
@@ -192,13 +206,13 @@ namespace ZR.Admin.WebApi.Controllers.System
ClientInfo clientInfo = context.GetClientInfo();
SysLogininfor sysLogininfor = new()
{
- browser = clientInfo.Device.Family,
- os = clientInfo.OS.ToString(),
- ipaddr = ipAddr,
- userName = context.GetName(),
- loginLocation = ip_info.Province + "-" + ip_info.City
+ Browser = clientInfo.ToString(),
+ Os = clientInfo.OS.ToString(),
+ Ipaddr = ipAddr,
+ UserName = context.GetName(),
+ LoginLocation = ip_info?.Province + "-" + ip_info?.City
};
-
+
return sysLogininfor;
}
diff --git a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
index 7281ead620b816c1651e595d2ff4c42dc131f89b..48f8063d01cc2c82cb1cdaeafc54f060a527a49d 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysMenuController.cs
@@ -21,13 +21,16 @@ namespace ZR.Admin.WebApi.Controllers.System
{
private readonly ISysRoleService sysRoleService;
private readonly ISysMenuService sysMenuService;
+ private readonly ISysRoleMenuService sysRoleMenuService;
public SysMenuController(
ISysRoleService sysRoleService,
- ISysMenuService sysMenuService)
+ ISysMenuService sysMenuService,
+ ISysRoleMenuService sysRoleMenuService)
{
this.sysRoleService = sysRoleService;
this.sysMenuService = sysMenuService;
+ this.sysRoleMenuService = sysRoleMenuService;
}
///
@@ -63,7 +66,8 @@ namespace ZR.Admin.WebApi.Controllers.System
[ActionPermissionFilter(Permission = "system:menu:query")]
public IActionResult GetMenuList(int menuId = 0)
{
- return SUCCESS(sysMenuService.GetMenusByMenuId(menuId), "yyyy-MM-dd HH:mm:ss");
+ long userId = HttpContext.GetUId();
+ return SUCCESS(sysMenuService.GetMenusByMenuId(menuId, userId), "yyyy-MM-dd HH:mm:ss");
}
///
@@ -106,11 +110,11 @@ namespace ZR.Admin.WebApi.Controllers.System
.NameMatchingStrategy(NameMatchingStrategy.IgnoreCase);//蹇界暐瀛楁鍚嶇О鐨勫ぇ灏忓啓;//蹇界暐闄や互涓婇厤缃殑鎵鏈夊瓧娈
var modal = menuDto.Adapt(config).ToUpdate(HttpContext);
- if (UserConstants.YES_FRAME.Equals(modal.isFrame) && !modal.path.StartsWith("http"))
+ if (UserConstants.YES_FRAME.Equals(modal.IsFrame) && !modal.Path.StartsWith("http"))
{
return ToResponse(ApiResult.Error($"淇敼鑿滃崟'{modal.MenuName}'澶辫触锛屽湴鍧蹇呴』浠ttp(s)://寮澶"));
}
- if (modal.MenuId.Equals(modal.parentId))
+ if (modal.MenuId.Equals(modal.ParentId))
{
return ToResponse(ApiResult.Error($"淇敼鑿滃崟'{modal.MenuName}'澶辫触锛屼笂绾ц彍鍗曚笉鑳介夋嫨鑷繁"));
}
@@ -141,7 +145,7 @@ namespace ZR.Admin.WebApi.Controllers.System
{
return ToResponse(ApiResult.Error($"鏂板鑿滃崟'{menu.MenuName}'澶辫触锛岃彍鍗曞悕绉板凡瀛樺湪"));
}
- if (UserConstants.YES_FRAME.Equals(menu.isFrame) && !menu.path.StartsWith("http"))
+ if (UserConstants.YES_FRAME.Equals(menu.IsFrame) && !menu.Path.StartsWith("http"))
{
return ToResponse(ApiResult.Error($"鏂板鑿滃崟'{menu.MenuName}'澶辫触锛屽湴鍧蹇呴』浠ttp(s)://寮澶"));
}
@@ -166,7 +170,7 @@ namespace ZR.Admin.WebApi.Controllers.System
{
return ToResponse(ResultCode.CUSTOM_ERROR, "瀛樺湪瀛愯彍鍗,涓嶅厑璁稿垹闄");
}
- if (sysMenuService.CheckMenuExistRole(menuId))
+ if (sysRoleMenuService.CheckMenuExistRole(menuId))
{
return ToResponse(ResultCode.CUSTOM_ERROR, "鑿滃崟宸插垎閰,涓嶅厑璁稿垹闄");
}
@@ -189,7 +193,7 @@ namespace ZR.Admin.WebApi.Controllers.System
MenuDto MenuDto = new()
{
MenuId = id,
- orderNum = value
+ OrderNum = value
};
if (MenuDto == null) { return ToResponse(ApiResult.Error(101, "璇锋眰鍙傛暟閿欒")); }
diff --git a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
index 7e6372dae9b944fa08e271fc2f4b9720bf730906..8ca9734235c7ba6db50cdf8a2a621018442c5189 100644
--- a/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/SysUserController.cs
@@ -2,17 +2,21 @@ using Infrastructure.Attribute;
using Infrastructure.Enums;
using Infrastructure.Model;
using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
+using MiniExcelLibs;
+using SqlSugar;
using System.Collections.Generic;
-using System.IO;
+using System.Linq;
+using System.Web;
using ZR.Admin.WebApi.Extensions;
using ZR.Admin.WebApi.Filters;
using ZR.Common;
using ZR.Model;
using ZR.Model.System;
using ZR.Service.System.IService;
-
+using ff = System.IO;
namespace ZR.Admin.WebApi.Controllers.System
{
///
@@ -26,17 +30,18 @@ namespace ZR.Admin.WebApi.Controllers.System
private readonly ISysRoleService RoleService;
private readonly ISysPostService PostService;
private readonly ISysUserPostService UserPostService;
-
+ private readonly IWebHostEnvironment WebHostEnvironment;
public SysUserController(
ISysUserService userService,
ISysRoleService roleService,
ISysPostService postService,
- ISysUserPostService userPostService)
+ ISysUserPostService userPostService, IWebHostEnvironment webHostEnvironment)
{
UserService = userService;
RoleService = roleService;
PostService = postService;
UserPostService = userPostService;
+ WebHostEnvironment = webHostEnvironment;
}
///
@@ -95,7 +100,10 @@ namespace ZR.Admin.WebApi.Controllers.System
{
return ToResponse(ApiResult.Error($"鏂板鐢ㄦ埛 '{user.UserName}'澶辫触锛岀櫥褰曡处鍙峰凡瀛樺湪"));
}
-
+ if (!Tools.CheckUserName(user.UserName))
+ {
+ return ToResponse(ApiResult.Error($"鐢ㄦ埛鍚嶈浣跨敤瀛楁瘝寮澶村彲鍖呭惈澶у皬鍐欏瓧姣嶆暟瀛梍-"));
+ }
user.Create_by = HttpContext.GetName();
user.Password = NETCore.Encrypt.EncryptProvider.Md5(user.Password);
@@ -175,14 +183,20 @@ namespace ZR.Admin.WebApi.Controllers.System
/// 浣跨敤IFromFile蹇呴』浣跨敤name灞炴у惁鍒欒幏鍙栦笉鍒版枃浠
///
[HttpPost("importData")]
- [Log(Title = "鐢ㄦ埛瀵煎叆", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = false)]
+ [Log(Title = "鐢ㄦ埛瀵煎叆", BusinessType = BusinessType.IMPORT, IsSaveRequestData = false, IsSaveResponseData = true)]
[ActionPermissionFilter(Permission = "system:user:import")]
public IActionResult ImportData([FromForm(Name = "file")] IFormFile formFile)
{
- IEnumerable users = ExcelHelper.ImportData(formFile.OpenReadStream());
+ //List users = (List)ExcelHelper.ImportData(formFile.OpenReadStream());
+ List users = new();
+ using (var stream = formFile.OpenReadStream())
+ {
+ users = stream.Query().ToList();
+ }
- //TODO 涓氬姟閫昏緫,鑷鎻掑叆鏁版嵁鍒癲b
- return SUCCESS(users);
+ string msg = UserService.ImportUsers(users);
+
+ return ToResponse(Infrastructure.ResultCode.SUCCESS, msg);
}
///
@@ -194,11 +208,11 @@ namespace ZR.Admin.WebApi.Controllers.System
[AllowAnonymous]
public IActionResult ImportTemplateExcel()
{
- List user = new List();
- MemoryStream stream = new MemoryStream();
+ string fileDir = ff.Path.Combine(WebHostEnvironment.WebRootPath, "importTemplate", "user.xlsx");
+
+ var stream = ff.File.OpenRead(fileDir); //鍒涘缓鏂囦欢娴
- string sFileName = DownloadImportTemplate(user, stream, "鐢ㄦ埛鍒楄〃");
- return File(stream.ToArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", $"{sFileName}");
+ return File(stream, "text/plain", "user.xlsx");
}
///
@@ -213,9 +227,8 @@ namespace ZR.Admin.WebApi.Controllers.System
{
var list = UserService.SelectUserList(user, new PagerInfo(1, 10000));
- //璋冭瘯妯″紡闇瑕佸姞涓
- string sFileName = ExportExcel(list.Result, "user", "鐢ㄦ埛鍒楄〃");
- return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
+ var result = ExportExcelMini(list.Result, "user", "鐢ㄦ埛鍒楄〃");
+ return ExportExcel(result.Item2, result.Item1);
}
}
}
diff --git a/ZR.Admin.WebApi/Controllers/System/TasksController.cs b/ZR.Admin.WebApi/Controllers/System/TasksController.cs
index cbabbb0c696283554d597cb84137dd6cffb5eae1..fa85010ed77144daa1787e11117fe83e3281774e 100644
--- a/ZR.Admin.WebApi/Controllers/System/TasksController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/TasksController.cs
@@ -14,7 +14,6 @@ using ZR.Model.System.Dto;
using ZR.Model.System;
using ZR.Service.System.IService;
using ZR.Tasks;
-using Snowflake.Core;
using Infrastructure.Extensions;
namespace ZR.Admin.WebApi.Controllers
@@ -43,17 +42,18 @@ namespace ZR.Admin.WebApi.Controllers
///
[HttpGet("list")]
[ActionPermissionFilter(Permission = "monitor:job:list")]
- public IActionResult Query([FromQuery] TasksQueryDto parm, [FromQuery] PagerInfo pager)
+ public IActionResult ListTask([FromQuery] TasksQueryDto parm, [FromQuery] PagerInfo pager)
{
//寮濮嬫嫾瑁呮煡璇㈡潯浠
- var predicate = Expressionable.Create();
+ var predicate = Expressionable.Create();
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.QueryText),
m => m.Name.Contains(parm.QueryText) ||
m.JobGroup.Contains(parm.QueryText) ||
m.AssemblyName.Contains(parm.QueryText));
+ predicate.AndIF(parm.TaskType != null, m => m.TaskType == parm.TaskType);
- var response = _tasksQzService.GetPages(predicate.ToExpression(), pager, f => f.IsStart, OrderByType.Desc);
+ var response = _tasksQzService.GetPages(predicate.ToExpression(), pager);
return SUCCESS(response, TIME_FORMAT_FULL);
}
@@ -95,15 +95,18 @@ namespace ZR.Admin.WebApi.Controllers
{
throw new CustomException($"鍦板潃涓嶈兘涓虹┖");
}
+ if (string.IsNullOrEmpty(parm.SqlText) && parm.TaskType == 3)
+ {
+ throw new CustomException($"sql璇彞涓嶈兘涓虹┖");
+ }
if (parm.TaskType == 1 && (parm.AssemblyName.IsEmpty() || parm.ClassName.IsEmpty()))
{
throw new CustomException($"绋嬪簭闆嗘垨鑰呯被鍚嶄笉鑳戒负绌");
}
//浠 Dto 鏄犲皠鍒 瀹炰綋
- var tasksQz = parm.Adapt().ToCreate();
- var worker = new IdWorker(1, 1);
+ var tasksQz = parm.Adapt().ToCreate();
tasksQz.Create_by = HttpContext.GetName();
- tasksQz.ID = worker.NextId().ToString();
+ tasksQz.ID = SnowFlakeSingle.Instance.NextId().ToString();
return SUCCESS(_tasksQzService.AddTasks(tasksQz));
}
@@ -115,7 +118,7 @@ namespace ZR.Admin.WebApi.Controllers
[HttpPost("update")]
[ActionPermissionFilter(Permission = "monitor:job:edit")]
[Log(Title = "淇敼浠诲姟", BusinessType = BusinessType.UPDATE)]
- public async Task Update([FromBody] TasksUpdateDto parm)
+ public async Task Update([FromBody] TasksCreateDto parm)
{
//鍒ゆ柇鏄惁宸茬粡瀛樺湪
if (_tasksQzService.Any(m => m.Name == parm.Name && m.ID != parm.ID))
@@ -135,16 +138,12 @@ namespace ZR.Admin.WebApi.Controllers
{
throw new CustomException($"api鍦板潃涓嶈兘涓虹┖");
}
- if (parm.ApiUrl.IfNotEmpty() && parm.TaskType == 2)
- {
- parm.AssemblyName = "ZR.Tasks";
- parm.ClassName = "TaskScheduler.Job_HttpRequest";
- }
+
if (tasksQz.IsStart)
{
throw new CustomException($"璇ヤ换鍔℃鍦ㄨ繍琛屼腑锛岃鍏堝仠姝㈠湪鏇存柊");
}
- var model = parm.Adapt();
+ var model = parm.Adapt();
model.Update_by = HttpContextExtension.GetName(HttpContext);
int response = _tasksQzService.UpdateTasks(model);
if (response > 0)
diff --git a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
index f66d19e08bd7891b0703b7c2b4306dda1f36a16e..189a1f5ac5ff639df3e695860c0ff297872239f8 100644
--- a/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
+++ b/ZR.Admin.WebApi/Controllers/System/monitor/SysLogininforController.cs
@@ -87,7 +87,7 @@ namespace ZR.Admin.WebApi.Controllers.monitor
logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
var exp = Expressionable.Create()
- .And(it => it.loginTime >= logininfoDto.BeginTime && it.loginTime <= logininfoDto.EndTime);
+ .And(it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
var list = sysLoginService.Queryable().Where(exp.ToExpression())
.ToList();
diff --git a/ZR.Admin.WebApi/Extensions/DbExtension.cs b/ZR.Admin.WebApi/Extensions/DbExtension.cs
index 8c1eeaf6150b05f6d22dae598a1bf0b9911734a1..5a75256324729e959f7ec3f53ee81138c6e41198 100644
--- a/ZR.Admin.WebApi/Extensions/DbExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/DbExtension.cs
@@ -97,7 +97,7 @@ namespace ZR.Admin.WebApi.Extensions
var user = JwtUtil.GetLoginUser(App.HttpContext);
if (user == null) return;
//绠$悊鍛樹笉杩囨护
- if (user.RoleIds.Any(f => f.Equals("admin"))) return;
+ if (user.RoleIds.Any(f => f.Equals(GlobalConstant.AdminRole))) return;
var db = DbScoped.SugarScope.GetConnectionScope(configId);
foreach (var role in user.Roles.OrderBy(f => f.DataScope))
{
diff --git a/ZR.Admin.WebApi/Extensions/EntityExtension.cs b/ZR.Admin.WebApi/Extensions/EntityExtension.cs
index 7b4c11fc925f9aa9a899aa1041c507756c08efcb..d2071a98ed87b5ae2f3bb87810820f08d5344ce7 100644
--- a/ZR.Admin.WebApi/Extensions/EntityExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/EntityExtension.cs
@@ -1,5 +1,4 @@
锘縰sing Microsoft.AspNetCore.Http;
-using Snowflake.Core;
using System;
namespace ZR.Admin.WebApi.Extensions
diff --git a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
index dea415d72bc90a81a98de554a85f5afa76d56d6b..9625325632bea60ab55c5c446d61dff10c86cf50 100644
--- a/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/HttpContextExtension.cs
@@ -1,4 +1,6 @@
-锘縰sing Microsoft.AspNetCore.Authentication;
+锘縰sing Infrastructure;
+using Infrastructure.Extensions;
+using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Http;
using System;
@@ -63,12 +65,23 @@ namespace ZR.Admin.WebApi.Extensions
return Regex.IsMatch(ip, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$");
}
+ ///
+ /// 鑾峰彇鐧诲綍鐢ㄦ埛id
+ ///
+ ///
+ ///
public static long GetUId(this HttpContext context)
{
var uid = context.User.FindFirstValue(ClaimTypes.PrimarySid);
return !string.IsNullOrEmpty(uid) ? long.Parse(uid) : 0;
}
+
+ ///
+ /// 鑾峰彇鐧诲綍鐢ㄦ埛鍚
+ ///
+ ///
+ ///
public static string GetName(this HttpContext context)
{
var uid = context.User?.Identity?.Name;
@@ -76,10 +89,15 @@ namespace ZR.Admin.WebApi.Extensions
return uid;
}
+ ///
+ /// 鍒ゆ柇鏄惁鏄鐞嗗憳
+ ///
+ ///
+ ///
public static bool IsAdmin(this HttpContext context)
{
- long id = GetUId(context);
- return id == 1;
+ var userName = GetName(context);
+ return userName == GlobalConstant.AdminRole;
}
///
@@ -126,7 +144,10 @@ namespace ZR.Admin.WebApi.Extensions
{
return context != null ? context.Request.Path.Value : "";
}
-
+ public static string GetQueryString(this HttpContext context)
+ {
+ return context != null ? context.Request.QueryString.Value : "";
+ }
///
/// 璁剧疆璇锋眰鍙傛暟
///
@@ -134,21 +155,25 @@ namespace ZR.Admin.WebApi.Extensions
///
public static void GetRequestValue(this HttpContext context, SysOperLog operLog)
{
- string reqMethod = operLog.requestMethod;
+ string reqMethod = operLog.RequestMethod;
string param;
- if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod))
+ if (HttpMethods.IsPost(reqMethod) || HttpMethods.IsPut(reqMethod) || HttpMethods.IsDelete(reqMethod))
{
context.Request.Body.Seek(0, SeekOrigin.Begin);
using var reader = new StreamReader(context.Request.Body, Encoding.UTF8);
//闇瑕佷娇鐢ㄥ紓姝ユ柟寮忔墠鑳借幏鍙
param = reader.ReadToEndAsync().Result;
+ if (param.IsEmpty())
+ {
+ param = GetQueryString(context);
+ }
}
else
{
- param = context.Request.QueryString.Value.ToString();
+ param = GetQueryString(context);
}
- operLog.operParam = param;
+ operLog.OperParam = param;
}
}
diff --git a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs
index 13598a42bc62145554cf630a01b2a4e60bf2b8d1..823009742fa9b9923134ab39fa4938a7b82ff565 100644
--- a/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/SwaggerExtension.cs
@@ -27,8 +27,7 @@ namespace ZR.Admin.WebApi.Extensions
var url = $"{httpReq.Scheme}://{httpReq.Host.Value}";
var referer = httpReq.Headers["Referer"].ToString();
if (referer.Contains(GlobalConstant.DevApiProxy))
- url = referer.Substring(0,
- referer.IndexOf(GlobalConstant.DevApiProxy, StringComparison.InvariantCulture) + GlobalConstant.DevApiProxy.Length - 1);
+ url = referer[..(referer.IndexOf(GlobalConstant.DevApiProxy, StringComparison.InvariantCulture) + GlobalConstant.DevApiProxy.Length - 1)];
swaggerDoc.Servers =
new List
{
diff --git a/ZR.Admin.WebApi/Extensions/TasksExtension.cs b/ZR.Admin.WebApi/Extensions/TasksExtension.cs
index 018a19c115b21f214d49b0a8f37d6090b152a6f5..f2971b9a5685375af07d0c10822e4c762ac0f1d7 100644
--- a/ZR.Admin.WebApi/Extensions/TasksExtension.cs
+++ b/ZR.Admin.WebApi/Extensions/TasksExtension.cs
@@ -3,8 +3,6 @@ using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Quartz.Spi;
using System;
-using System.Threading.Tasks;
-using ZR.Service.System.IService;
using ZR.Tasks;
namespace ZR.Admin.WebApi.Extensions
@@ -38,7 +36,7 @@ namespace ZR.Admin.WebApi.Extensions
ITaskSchedulerServer _schedulerServer = App.GetRequiredService();
//var tasks = _tasksQzService.GetList(m => m.IsStart);
- var tasks = SqlSugar.IOC.DbScoped.SugarScope.Queryable().Where(m => m.IsStart).ToList();
+ var tasks = SqlSugar.IOC.DbScoped.SugarScope.Queryable().Where(m => m.IsStart).ToList();
//绋嬪簭鍚姩鍚庢敞鍐屾墍鏈夊畾鏃朵换鍔
foreach (var task in tasks)
diff --git a/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs b/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs
index 19efe966ba3793a93062aa2636296227bcf7f1f3..01a5fc15bae99ddd727c34ff66023a3f7bcede1e 100644
--- a/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs
+++ b/ZR.Admin.WebApi/Filters/GlobalActionMonitor.cs
@@ -101,31 +101,31 @@ namespace ZR.Admin.WebApi.Filters
SysOperLog sysOperLog = new()
{
- status = 0,
- operName = userName,
- operIp = ip,
- operUrl = HttpContextExtension.GetRequestUrl(context.HttpContext),
- requestMethod = method,
- jsonResult = jsonResult,
- operLocation = ip_info.Province + " " + ip_info.City,
- method = controller + "." + action + "()",
+ Status = 0,
+ OperName = userName,
+ OperIp = ip,
+ OperUrl = HttpContextExtension.GetRequestUrl(context.HttpContext),
+ RequestMethod = method,
+ JsonResult = jsonResult,
+ OperLocation = ip_info.Province + " " + ip_info.City,
+ Method = controller + "." + action + "()",
//Elapsed = _stopwatch.ElapsedMilliseconds,
- operTime = DateTime.Now
+ OperTime = DateTime.Now
};
HttpContextExtension.GetRequestValue(context.HttpContext, sysOperLog);
if (logAttribute != null)
{
- sysOperLog.title = logAttribute?.Title;
- sysOperLog.businessType = (int)logAttribute?.BusinessType;
- sysOperLog.operParam = logAttribute.IsSaveRequestData ? sysOperLog.operParam : "";
- sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : "";
+ sysOperLog.Title = logAttribute?.Title;
+ sysOperLog.BusinessType = (int)logAttribute?.BusinessType;
+ sysOperLog.OperParam = logAttribute.IsSaveRequestData ? sysOperLog.OperParam : "";
+ sysOperLog.JsonResult = logAttribute.IsSaveResponseData ? sysOperLog.JsonResult : "";
}
LogEventInfo ei = new(LogLevel.Info, "GlobalActionMonitor", "");
ei.Properties["jsonResult"] = !HttpMethods.IsGet(method) ? jsonResult : "";
- ei.Properties["requestParam"] = sysOperLog.operParam;
+ ei.Properties["requestParam"] = sysOperLog.OperParam;
ei.Properties["user"] = userName;
logger.Log(ei);
diff --git a/ZR.Admin.WebApi/Framework/JwtUtil.cs b/ZR.Admin.WebApi/Framework/JwtUtil.cs
index 590b615287df1bec22d8766027ebe1406479343a..92c1ea190b791be91a21d1d1609ae090876f08c1 100644
--- a/ZR.Admin.WebApi/Framework/JwtUtil.cs
+++ b/ZR.Admin.WebApi/Framework/JwtUtil.cs
@@ -132,7 +132,7 @@ namespace ZR.Admin.WebApi.Framework
var userData = jwtToken.FirstOrDefault(x => x.Type == ClaimTypes.UserData).Value;
var loginUser = JsonConvert.DeserializeObject(userData);
var permissions = CacheService.GetUserPerms(GlobalConstant.UserPermKEY + loginUser?.UserId);
- if (loginUser?.UserName == "admin")
+ if (loginUser?.UserName == GlobalConstant.AdminRole)
{
permissions = new List() { GlobalConstant.AdminPerm };
}
diff --git a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
index cdc619ae83651e14abe2898084c7a3d78b17d229..b0a1d2285401e313f0e76ae5a7a918dd60679866 100644
--- a/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
+++ b/ZR.Admin.WebApi/Middleware/GlobalExceptionMiddleware.cs
@@ -10,6 +10,7 @@ using System.Text.Encodings.Web;
using System.Text.Json;
using System.Threading.Tasks;
using ZR.Admin.WebApi.Extensions;
+using ZR.Common;
using ZR.Model.System;
using ZR.Service.System.IService;
@@ -83,15 +84,15 @@ namespace ZR.Admin.WebApi.Middleware
SysOperLog sysOperLog = new()
{
- status = 1,
- operIp = ip,
- operUrl = HttpContextExtension.GetRequestUrl(context),
- requestMethod = context.Request.Method,
- jsonResult = responseResult,
- errorMsg = string.IsNullOrEmpty(error) ? msg : error,
- operName = context.User.Identity.Name,
- operLocation = ip_info.Province + " " + ip_info.City,
- operTime = DateTime.Now
+ Status = 1,
+ OperIp = ip,
+ OperUrl = HttpContextExtension.GetRequestUrl(context),
+ RequestMethod = context.Request.Method,
+ JsonResult = responseResult,
+ ErrorMsg = string.IsNullOrEmpty(error) ? msg : error,
+ OperName = context.User.Identity.Name,
+ OperLocation = ip_info.Province + " " + ip_info.City,
+ OperTime = DateTime.Now
};
HttpContextExtension.GetRequestValue(context, sysOperLog);
var endpoint = GetEndpoint(context);
@@ -100,10 +101,10 @@ namespace ZR.Admin.WebApi.Middleware
var logAttribute = endpoint.Metadata.GetMetadata();
if (logAttribute != null)
{
- sysOperLog.businessType = (int)logAttribute?.BusinessType;
- sysOperLog.title = logAttribute?.Title;
- sysOperLog.operParam = logAttribute.IsSaveRequestData ? sysOperLog.operParam : "";
- sysOperLog.jsonResult = logAttribute.IsSaveResponseData ? sysOperLog.jsonResult : "";
+ sysOperLog.BusinessType = (int)logAttribute?.BusinessType;
+ sysOperLog.Title = logAttribute?.Title;
+ sysOperLog.OperParam = logAttribute.IsSaveRequestData ? sysOperLog.OperParam : "";
+ sysOperLog.JsonResult = logAttribute.IsSaveResponseData ? sysOperLog.JsonResult : "";
}
}
LogEventInfo ei = new(logLevel, "GlobalExceptionMiddleware", error)
@@ -113,13 +114,13 @@ namespace ZR.Admin.WebApi.Middleware
};
ei.Properties["status"] = 1;//璧版甯歌繑鍥為兘鏄氳繃璧癎lobalExceptionFilter涓嶉氳繃
ei.Properties["jsonResult"] = responseResult;
- ei.Properties["requestParam"] = sysOperLog.operParam;
+ ei.Properties["requestParam"] = sysOperLog.OperParam;
ei.Properties["user"] = HttpContextExtension.GetName(context);
Logger.Log(ei);
context.Response.ContentType = "text/json;charset=utf-8";
await context.Response.WriteAsync(responseResult, System.Text.Encoding.UTF8);
-
+ WxNoticeHelper.SendMsg("绯荤粺鍑洪敊", sysOperLog.ErrorMsg);
SysOperLogService.InsertOperlog(sysOperLog);
}
diff --git a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
index 33f4e7295c0bda36f11a8a95333cd5c5da78bd99..98066fdeee9305d4fa1e0c158c30925780f14c9f 100644
--- a/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
+++ b/ZR.Admin.WebApi/ZR.Admin.WebApi.csproj
@@ -14,19 +14,18 @@
-
-
+
+
-
-
-
-
-
-
+
+
+
+
+
@@ -58,7 +57,9 @@
+
+
diff --git a/ZR.Admin.WebApi/appsettings.json b/ZR.Admin.WebApi/appsettings.json
index 33712f769a54cd8dde7240dd2c331b16b4e692f9..ce2fdd6c5e7700c816bbb3609fc4b43bce254bd6 100644
--- a/ZR.Admin.WebApi/appsettings.json
+++ b/ZR.Admin.WebApi/appsettings.json
@@ -8,7 +8,7 @@
},
"ConnectionStrings": {
"conn_db": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=sa;Password=zradmin123;Initial Catalog=ZrAdmin;Integrated Security=SSPI", //鍏朵粬杩炴帴瀛楃涓茶鐪嬪畼鏂规枃妗
- "conn_db_type": "1" //鏁版嵁搴撶被鍨 MySql = 0, SqlServer = 1
+ "conn_db_type": "1" //鏁版嵁搴撶被鍨 MySql = 0, SqlServer = 1, Oracle = 3
},
"urls": "http://localhost:8888", //椤圭洰鍚姩url锛屽鏋滄敼鍔ㄧ鍙e墠绔搴攄evServer涔熼渶瑕佽繘琛屼慨鏀
"corsUrls": "http://localhost:8887", //璺ㄥ煙鍦板潃锛堝墠绔惎鍔ㄩ」鐩紝鍓嶅悗绔垎绂诲崟鐙儴缃查渶瑕佽缃級锛屽涓敤","闅斿紑
@@ -20,16 +20,26 @@
},
"DemoMode": false, //鏄惁婕旂ず妯″紡
"Upload": {
- "UploadUrl": "http://localhost:8888", //鏈湴瀛樺偍璧勬簮璁块棶璺緞
- "localSavePath": "uploads" //鏈湴涓婁紶榛樿鏂囦欢瀛樺偍鐩綍 wwwroot/uploads
+ "uploadUrl": "http://localhost:8888", //鏈湴瀛樺偍璧勬簮璁块棶璺緞
+ "localSavePath": "uploads", //鏈湴涓婁紶榛樿鏂囦欢瀛樺偍鐩綍 wwwroot/uploads
+ "maxSize": 15, //涓婁紶鏂囦欢澶у皬闄愬埗 15M
+ "notAllowedExt": [ ".bat", ".exe", ".jar", ".js" ]
},
//闃块噷浜戝瓨鍌ㄩ厤缃
"ALIYUN_OSS": {
- "REGIONID": "cn-hangzhou",
+ "REGIONID": "", //eg锛歝n-hangzhou
"KEY": "XX",
"SECRET": "XX",
"bucketName": "bucketName",
- "domainUrl": "http://xxx.xxx.com" //璁块棶璧勬簮鍩熷悕
+ "domainUrl": "http://xxx.xxx.com", //璁块棶璧勬簮鍩熷悕
+ "maxSize": 100 //涓婁紶鏂囦欢澶у皬闄愬埗 100M
+ },
+ //浼佷笟寰俊閫氱煡閰嶇疆
+ "WxCorp": {
+ "AgentID": "",
+ "CorpID": "",
+ "CorpSecret": "",
+ "SendUser": "@all"
},
"gen": {
"conn": "Data Source=LAPTOP-STKF2M8H\\SQLEXPRESS;User ID=sa;Password=zradmin123;Initial Catalog=ZrAdmin;Integrated Security=SSPI",
@@ -62,7 +72,7 @@
"RealIpHeader": "X-Real-IP",
"ClientIdHeader": "X-ClientId",
"HttpStatusCode": 429,
- "EndpointWhitelist": [ "post:/system/dict/data/types", "*:/msghub/negotiate", "*:/LogOut" ],
+ "EndpointWhitelist": [ "post:/system/dict/data/types", "*:/msghub/negotiate", "*:/LogOut", "*:/common/uploadfile" ],
"QuotaExceededResponse": {
"Content": "{{\"code\":429,\"msg\":\"璁块棶杩囦簬棰戠箒锛岃绋嶅悗閲嶈瘯\"}}",
"ContentType": "application/json",
@@ -77,14 +87,7 @@
"Limit": 5
},
{
- "Endpoint": "post:*",
- //鏃堕棿娈碉紝鏍煎紡锛歿鏁板瓧}{鍗曚綅}锛涘彲浣跨敤鍗曚綅锛歴, m, h, d
- "Period": "3s",
- "Limit": 1
- },
- {
- "Endpoint": "put:*",
- //鏃堕棿娈碉紝鏍煎紡锛歿鏁板瓧}{鍗曚綅}锛涘彲浣跨敤鍗曚綅锛歴, m, h, d
+ "Endpoint": "((post)|(put)):*",
"Period": "3s",
"Limit": 1
}
@@ -94,5 +97,9 @@
"IpRules": [
]
}
+ },
+ //楠岃瘉鐮侀厤缃
+ "CaptchaOptions": {
+ "length": 4//楠岃瘉鐮侀暱搴
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
index 51d5983363c872585892ad662fe54166105392f3..a33e04e79f8d0a9f5bd50a173aed2aeb4f3d2760 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplControllers.txt
@@ -144,16 +144,39 @@ $if(replaceDto.ShowBtnExport)
/// 瀵煎嚭${genTable.FunctionName}
///
///
- [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.EXPORT, IsSaveResponseData = false)]
+ [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.EXPORT)]
[HttpGet("export")]
[ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:export")]
public IActionResult Export([FromQuery] ${replaceDto.ModelTypeName}QueryDto parm)
{
- parm.PageSize = 10000;
+ parm.PageSize = 100000;
var list = _${replaceDto.ModelTypeName}Service.GetList(parm).Result;
+ if (list == null || list.Count <= 0)
+ {
+ return ToResponse(ResultCode.FAIL, "娌℃湁瑕佸鍑虹殑鏁版嵁");
+ }
+ var result = ExportExcelMini(list, "${genTable.FunctionName}", "${genTable.FunctionName}");
+ return ExportExcel(result.Item2, result.Item1);
+ }
+$end
+
+$if(replaceDto.ShowBtnTruncate)
+ ///
+ /// 娓呯┖${genTable.FunctionName}
+ ///
+ ///
+ [Log(Title = "${genTable.FunctionName}", BusinessType = BusinessType.CLEAN)]
+ [ActionPermissionFilter(Permission = "${replaceDto.PermissionPrefix}:delete")]
+ [HttpDelete("clean")]
+ public ApiResult Clear()
+ {
+ if (!HttpContextExtension.IsAdmin(HttpContext))
+ {
+ return ApiResult.Error("鎿嶄綔澶辫触");
+ }
+ _${replaceDto.ModelTypeName}Service.Truncate${replaceDto.ModelTypeName}();
- string sFileName = ExportExcel(list, "${replaceDto.ModelTypeName}", "${genTable.FunctionName}");
- return SUCCESS(new { path = "/export/" + sFileName, fileName = sFileName });
+ return ToJson(1);
}
$end
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt
index f697b72ae874ad5e9e8c7498819cf0f1c3efff91..d3c37fb2931e57a364f62632ec442b1314043c2c 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplDto.txt
@@ -3,36 +3,63 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using ${options.ModelsNamespace}.Dto;
using ${options.ModelsNamespace}.Models;
+$if(replaceDto.ShowBtnExport)
+using MiniExcelLibs.Attributes;
+$end
namespace ${options.DtosNamespace}.Dto
{
///
- /// ${genTable.FunctionName}杈撳叆瀵硅薄
+ /// ${genTable.FunctionName}鏌ヨ瀵硅薄
///
- public class ${replaceDto.ModelTypeName}Dto
+ public class ${replaceDto.ModelTypeName}QueryDto : PagerInfo
{
$foreach(item in genTable.Columns)
-$if((item.IsInsert || item.IsEdit || item.IsPk || item.IsIncrement))
-$if(item.IsRequired)
- [Required(ErrorMessage = "${item.ColumnComment}涓嶈兘涓虹┖")]
+$if(item.IsQuery)
+$if(item.htmlType == "datetime")
+ public DateTime? Begin$item.CsharpField { get; set; }
+ public DateTime? End$item.CsharpField { get; set; }
+$elseif(item.htmlType == "selectMulti")
+ public ${item.CsharpType}[] $item.CsharpField { get; set; }
+$else
+ public $item.CsharpType$if(item.CsharpType != "string")?$end $item.CsharpField { get; set; }
$end
- public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; }
$end
$end
}
///
- /// ${genTable.FunctionName}鏌ヨ瀵硅薄
+ /// ${genTable.FunctionName}杈撳叆杈撳嚭瀵硅薄
///
- public class ${replaceDto.ModelTypeName}QueryDto : PagerInfo
+ public class ${replaceDto.ModelTypeName}Dto
{
$foreach(item in genTable.Columns)
-$if(item.IsQuery && item.htmlType == "datetime")
- public DateTime? Begin$item.CsharpField { get; set; }
- public DateTime? End$item.CsharpField { get; set; }
-$elseif(item.IsQuery)
- public $item.CsharpType$if(item.CsharpType != "string")?$end $item.CsharpField { get; set; }
+$if(item.IsRequired)
+ [Required(ErrorMessage = "${item.ColumnComment}涓嶈兘涓虹┖")]
+$end
+$if(replaceDto.ShowBtnExport)
+$if(item.IsExport)
+ [ExcelColumn(Name = "$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}"$if(item.CsharpType == "DateTime"), Format = "yyyy-MM-dd HH:mm:ss"$end)]
+$else
+ [ExcelIgnore]
+$end
+$end
+ public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; }
+
+$end
+
+$if(genTable.TplCategory == "subNav" && genTable.SubTable != null)
+$if(replaceDto.ShowBtnExport)
+ [ExcelIgnore]
+$end
+ public ${genTable.SubTable.ClassName} ${genTable.SubTable.ClassName} { get; set; }
+$end
+
+$if(genTable.TplCategory == "subNavMore" && genTable.SubTable != null)
+$if(replaceDto.ShowBtnExport)
+ [ExcelIgnore]
$end
+ public List<${genTable.SubTable.ClassName}> ${genTable.SubTable.ClassName} { get; set; }
$end
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt
index f30aecd2f8de9b122d82aa95ce248014c604ea5b..bc227965a3694eac0975b06b650dcc67ccfa9c92 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplIService.txt
@@ -14,7 +14,7 @@ namespace ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNam
///
public interface I${replaceDto.ModelTypeName}Service : IBaseService<${replaceDto.ModelTypeName}>
{
- PagedInfo<${replaceDto.ModelTypeName}> GetList(${replaceDto.ModelTypeName}QueryDto parm);
+ PagedInfo<${replaceDto.ModelTypeName}Dto> GetList(${replaceDto.ModelTypeName}QueryDto parm);
$if(genTable.TplCategory == "tree")
List<${replaceDto.ModelTypeName}> GetTreeList(${replaceDto.ModelTypeName}QueryDto parm);
@@ -22,5 +22,7 @@ $end
int Add${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} parm);
int Update${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} parm);
+
+ void Truncate${replaceDto.ModelTypeName}();
}
}
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt
index b779e2afef89f487a6093996595f69feca741875..bd81ff1e2fe373006b8eeb993aab687bdf6b810c 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplModel.txt
@@ -1,7 +1,6 @@
锘縰sing System;
-using System.Collections.Generic;
using SqlSugar;
-using OfficeOpenXml.Attributes;
+using System.Collections.Generic;
namespace ${options.ModelsNamespace}.Models
{
@@ -17,11 +16,8 @@ namespace ${options.ModelsNamespace}.Models
$foreach(item in genTable.Columns)
///
/// 鎻忚堪 :${item.ColumnComment} ${item.Remark}
- /// 绌哄 :$if(item.IsRequired == "True") false $else true $end
+ /// 绌哄 :$if(item.IsRequired == "True")false${else}true${end}
///
-$if(replaceDto.ShowBtnExport)
- [EpplusTableColumn(Header = "$if(item.ColumnComment == "")${item.CsharpField}${else}${item.ColumnComment}${end}"$if(item.CsharpType == "DateTime"), NumberFormat = "yyyy-MM-dd HH:mm:ss"$end)]
-$end
$if(item.IsPk || item.IsIncrement)
[SugarColumn(IsPrimaryKey = ${item.IsPk.ToString().ToLower()}, IsIdentity = ${item.IsIncrement.ToString().ToLower()}$if(item.CsharpField.ToLower() != item.ColumnName.ToLower()), ColumnName = "$item.ColumnName"$end)]
$elseif(item.CsharpField.ToLower() != item.ColumnName.ToLower())
@@ -30,8 +26,8 @@ $end
public $item.CsharpType$item.RequiredStr $item.CsharpField { get; set; }
${end}
-$if(genTable.TplCategory == "tree")
+$if(genTable.TplCategory == "tree")
[SugarColumn(IsIgnore = true)]
public List<${replaceDto.ModelTypeName}> Children { get; set; }
$end
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt
index ce428f3ca510beba43e59c0cac50f16bfd7b3148..c744b4b7327bf8aef64eb792104eb20ce2160e1c 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplService.txt
@@ -1,13 +1,15 @@
锘縰sing System;
using SqlSugar;
-using System.Collections.Generic;
-using Infrastructure;
using Infrastructure.Attribute;
using ${options.ModelsNamespace};
using ${options.ModelsNamespace}.Dto;
using ${options.ModelsNamespace}.Models;
using ${options.IRepositoriesNamespace};
using ${options.IServicsNamespace}.${options.SubNamespace}.I${options.SubNamespace}Service;
+using System.Linq;
+$if(genTable.TplCategory == "tree")
+using System.Collections.Generic;
+$end
namespace ${options.ServicesNamespace}.${options.SubNamespace}
{
@@ -20,12 +22,6 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
[AppService(ServiceType = typeof(I${replaceDto.ModelTypeName}Service), ServiceLifetime = LifeTime.Transient)]
public class ${replaceDto.ModelTypeName}Service : BaseService<${replaceDto.ModelTypeName}>, I${replaceDto.ModelTypeName}Service
{
- private readonly ${replaceDto.ModelTypeName}Repository _${replaceDto.ModelTypeName}Repository;
- public ${replaceDto.ModelTypeName}Service(${replaceDto.ModelTypeName}Repository repository)
- {
- _${replaceDto.ModelTypeName}Repository = repository;
- }
-
#region 涓氬姟閫昏緫浠g爜
///
@@ -33,7 +29,7 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
///
///
///
- public PagedInfo<${replaceDto.ModelTypeName}> GetList(${replaceDto.ModelTypeName}QueryDto parm)
+ public PagedInfo<${replaceDto.ModelTypeName}Dto> GetList(${replaceDto.ModelTypeName}QueryDto parm)
{
//寮濮嬫嫾瑁呮煡璇㈡潯浠
var predicate = Expressionable.Create<${replaceDto.ModelTypeName}>();
@@ -41,7 +37,9 @@ namespace ${options.ServicesNamespace}.${options.SubNamespace}
//鎼滅储鏉′欢鏌ヨ璇硶鍙傝僑qlsugar
$foreach(column in genTable.Columns)
$if(column.IsQuery)
-$if(column.CsharpType == "string")
+$if(column.HtmlType == "selectMulti")
+ predicate = predicate.AndIF(parm.${column.CsharpField} != null, it => parm.${column.CsharpField}.Contains(it.${column.CsharpField}));
+$elseif(column.CsharpType == "string")
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.${column.CsharpField}), ${codeTool.QueryExp(column.CsharpField, column.QueryType)};
$elseif(column.CsharpType == "DateTime")
predicate = predicate.AndIF(parm.Begin${column.CsharpField} == null, it => it.${column.CsharpField} >= DateTime.Now.AddDays(-1));
@@ -51,16 +49,15 @@ $elseif(column.CsharpType == "int" || column.CsharpType == "long")
$end
$end
$end
- var response = _${replaceDto.ModelTypeName}Repository
- .Queryable()
+ var response = Queryable()
$if(null != genTable.SubTableName && "" != genTable.SubTableName)
.Includes(it => it.${genTable.SubTable.ClassName}.MappingField(z => z.${genTable.SubTableFkName}, () => it.${replaceDto.PKName}))
$end
$if(genTable.Options.SortField != "" && genTable.Options.SortField != null)
- .OrderBy("${genTable.Options.SortField} ${genTable.Options.SortType}")
+ //.OrderBy("${genTable.Options.SortField} ${genTable.Options.SortType}")
$end
.Where(predicate.ToExpression())
- .ToPage(parm);
+ .ToPage<${replaceDto.ModelTypeName}, ${replaceDto.ModelTypeName}Dto>(parm);
return response;
}
@@ -87,12 +84,14 @@ $end
$end
$end
- var response = _${replaceDto.ModelTypeName}Repository.Queryable().Where(predicate.ToExpression())
+ var response = Queryable()
+ .Where(predicate.ToExpression())
.ToTree(it => it.Children, it => it.${genTable.Options.TreeParentCode}, 0);
return response;
}
$end
+
///
/// 娣诲姞${genTable.FunctionName}
///
@@ -100,7 +99,7 @@ $end
///
public int Add${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} parm)
{
- var response = _${replaceDto.ModelTypeName}Repository.Insert(parm, it => new
+ var response = Insert(parm, it => new
{
${foreach(item in genTable.Columns)}
$if((item.IsInsert))
@@ -118,7 +117,7 @@ ${end}
///
public int Update${replaceDto.ModelTypeName}(${replaceDto.ModelTypeName} parm)
{
- var response = _${replaceDto.ModelTypeName}Repository.Update(w => w.${replaceDto.PKName} == parm.${replaceDto.PKName}, it => new ${replaceDto.ModelTypeName}()
+ var response = Update(w => w.${replaceDto.PKName} == parm.${replaceDto.PKName}, it => new ${replaceDto.ModelTypeName}()
{
$foreach(item in genTable.Columns)
$if((item.IsEdit))
@@ -128,6 +127,15 @@ ${end}
});
return response;
}
+
+ ///
+ /// 娓呯┖${genTable.FunctionName}
+ ///
+ ///
+ public void Truncate${replaceDto.ModelTypeName}()
+ {
+ Truncate();
+ }
#endregion
}
}
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
index 48d25b9213e88d157361da12f6e2c932417e878e..1e1678fc155c40f636c7920d59ec9cde948dc941 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/TplVueApi.txt
@@ -1,4 +1,10 @@
锘縤mport request from '@/utils/request'
+$if(replaceDto.SelectMulti == 1)
+import QS from 'qs'
+$end
+$if(replaceDto.ShowBtnExport)
+import { downFile } from '@/utils/request'
+$end
/**
* ${genTable.functionName}鍒嗛〉鏌ヨ
@@ -9,6 +15,11 @@ export function list${genTable.BusinessName}(query) {
url: '${genTable.ModuleName}/${genTable.BusinessName}/list',
method: 'get',
params: query,
+$if(replaceDto.SelectMulti == 1)
+ paramsSerializer: function (params) {
+ return QS.stringify(params, { indices: false })
+ }
+$end
})
}
@@ -72,15 +83,19 @@ export function del${genTable.BusinessName}(pid) {
})
}
-// 瀵煎嚭${genTable.functionName}
-export function export${genTable.BusinessName}(query) {
+// 娓呯┖${genTable.functionName}
+export function clear${genTable.BusinessName}() {
return request({
- url: '${genTable.ModuleName}/${genTable.BusinessName}/export',
- method: 'get',
- params: query
+ url: '${genTable.ModuleName}/${genTable.BusinessName}/clean',
+ method: 'delete'
})
}
+// 瀵煎嚭${genTable.functionName}
+export async function export${genTable.BusinessName}(query) {
+ await downFile('${genTable.ModuleName}/${genTable.BusinessName}/export', { ...query })
+}
+
$if(showCustomInput)
//鎺掑簭
export function changeSort(data) {
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
index dc05b23a4921736102eac4fc4ad8bfe35d77e6fb..7a73901fa63d4c6c7249c305932dce570a1874c6 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/TreeVue.txt
@@ -7,34 +7,43 @@
* @LastEditTime: (${replaceDto.AddTime})
-->
-
-
-
+
+
$foreach(column in genTable.Columns)
$set(labelName = "")
$set(columnName = "")
$set(numLabel = "")
-$if(column.IsQuery == true)
- $set(columnName = column.CsharpFieldFl)
- $if(column.ColumnComment != "")
- $set(labelName = column.ColumnComment)
- $else
- $set(labelName = column.CsharpFieldFl)
- $end
- $if(column.CsharpType == "int" || column.CsharpType == "long")
- $set(numLabel = ".number")
- $end
+$set(columnName = column.CsharpFieldFl)
+$if(column.ColumnComment != "")
+$set(labelName = column.ColumnComment)
+$else
+$set(labelName = column.CsharpFieldFl)
+$end
+$if(column.CsharpType == "int" || column.CsharpType == "long")
+$set(numLabel = ".number")
+$end
$if(column.HtmlType == "datetime")
-
+
+
-$elseif(column.HtmlType == "select" || column.HtmlType == "radio")
+$elseif(column.HtmlType == "select" || column.HtmlType == "radio" || column.HtmlType == "selectMulti")
-
-
+
+
+ {{ item.dictLabel }}
+ {{ item.dictValue }}
+
$else
@@ -89,8 +98,7 @@ $end
@selection-change="handleSelectionChange"
:default-expand-all="isExpandAll"
row-key="${tool.FirstLowerCase(genTable.Options.TreeCode)}"
- :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
- >
+ :tree-props="{ children: 'children', hasChildren: 'hasChildren' }">
$foreach(column in genTable.Columns)
$set(labelName = "")
@@ -125,9 +133,9 @@ $elseif(column.HtmlType == "checkbox" || column.HtmlType == "select" || column.H
$if(column.HtmlType == "checkbox")
-
+
$else
-
+
$end
@@ -233,7 +241,7 @@ $elseif(column.HtmlType == "radio")
- {{item.dictLabel}}
+ {{item.dictLabel}}
@@ -249,11 +257,11 @@ $elseif(column.HtmlType == "editor")
-$elseif(column.HtmlType == "select")
+$elseif(column.HtmlType == "select" || column.HtmlType == "selectMulti")
-
-
+
+
@@ -261,7 +269,7 @@ $elseif(column.HtmlType == "checkbox")
- {{item.dictLabel}}
+ {{item.dictLabel}}
@@ -288,7 +296,7 @@ $end
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
index 94ce0971f99cd91f49176a9749145f3cbf0b187c..e444b90df50231c1512acf62d71424279e66192d 100644
--- a/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
+++ b/ZR.Admin.WebApi/wwwroot/CodeGenTemplate/v3/Vue.txt
@@ -27,20 +27,23 @@ $if(column.HtmlType == "datetime")
-$elseif(column.HtmlType == "select" || column.HtmlType == "radio")
+$elseif(column.HtmlType == "select" || column.HtmlType == "radio" || column.HtmlType == "selectMulti")
-
-
+
+
+ {{ item.dictLabel }}
+ {{ item.dictValue }}
+
$elseif(column.HtmlType == "radio")
@@ -84,6 +87,13 @@ $if(replaceDto.ShowBtnDelete)
$end
+$if(replaceDto.ShowBtnTruncate)
+
+
+ 娓呯┖
+
+
+$end
$if(replaceDto.ShowBtnExport)
@@ -91,13 +101,12 @@ $if(replaceDto.ShowBtnExport)
$end
-
+
-
$foreach(column in genTable.Columns)
$set(labelName = "")
$set(checkboxHtml = "")
@@ -113,7 +122,7 @@ $set(labelName = column.CsharpFieldFl)
$end
$if(column.IsList == true)
$if(column.HtmlType == "customInput" && column.IsPk == false)
-
+
{{scope.row.${columnName}}}
$elseif(column.HtmlType == "imageUpload")
-
+
-$elseif(column.HtmlType == "checkbox" || column.HtmlType == "select" || column.HtmlType == "radio")
-
+$elseif(column.HtmlType == "checkbox" || column.HtmlType == "select" || column.HtmlType == "radio" || column.HtmlType == "selectMulti")
+
$if(column.HtmlType == "checkbox")
@@ -142,7 +151,7 @@ $end
$else
-
+
$end
$end
$end
@@ -193,7 +202,7 @@ $else
$if(column.HtmlType == "inputNumber" || column.HtmlType == "customInput")
-
+
$elseif(column.HtmlType == "datetime")
@@ -234,7 +243,7 @@ $elseif(column.HtmlType == "editor")
-$elseif(column.HtmlType == "select")
+$elseif(column.HtmlType == "select" || column.HtmlType == "selectMulti")
@@ -270,60 +279,44 @@ $end
-
\ No newline at end of file
diff --git a/ZR.Admin.WebApi/wwwroot/importTemplate/user.xlsx b/ZR.Admin.WebApi/wwwroot/importTemplate/user.xlsx
new file mode 100644
index 0000000000000000000000000000000000000000..a8a2b77f8efa2d778abfe437fc1a3746052acf71
Binary files /dev/null and b/ZR.Admin.WebApi/wwwroot/importTemplate/user.xlsx differ
diff --git a/ZR.CodeGenerator/CodeGeneratorTool.cs b/ZR.CodeGenerator/CodeGeneratorTool.cs
index 30a4a4d6e41ff33e8851290a09c44e66c27f0c07..e35e003eeda813ca73e49d8e8896475be666f8b5 100644
--- a/ZR.CodeGenerator/CodeGeneratorTool.cs
+++ b/ZR.CodeGenerator/CodeGeneratorTool.cs
@@ -59,7 +59,8 @@ namespace ZR.CodeGenerator
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)
+ ShowBtnView = dto.GenTable.Options.CheckedBtn.Any(f => f == 5),
+ ShowBtnTruncate = dto.GenTable.Options.CheckedBtn.Any(f => f == 6),
};
//寰幆琛ㄥ瓧娈典俊鎭
@@ -74,6 +75,10 @@ namespace ZR.CodeGenerator
{
replaceDto.UploadFile = 1;
}
+ if (dbFieldInfo.HtmlType.Equals(GenConstants.HTML_SELECT_MULTI))
+ {
+ replaceDto.SelectMulti = 1;
+ }
dbFieldInfo.CsharpFieldFl = dbFieldInfo.CsharpField.FirstLowerCase();
}
@@ -83,7 +88,6 @@ namespace ZR.CodeGenerator
InitJntTemplate(dto, replaceDto);
GenerateModels(replaceDto, dto);
- GenerateRepository(replaceDto, dto);
GenerateService(replaceDto, dto);
GenerateControllers(replaceDto, dto);
if (dto.VueVersion == 3)
@@ -98,6 +102,10 @@ namespace ZR.CodeGenerator
GenerateVueViews(replaceDto, dto);
}
+ if (dto.GenTable.Options.GenerateRepo == 1)
+ {
+ GenerateRepository(replaceDto, dto);
+ }
GenerateVueJs(replaceDto, dto);
GenerateSql(replaceDto, dto);
@@ -234,6 +242,7 @@ namespace ZR.CodeGenerator
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));
}
+
///
/// 鐢熸垚vue椤甸潰api
///
@@ -248,7 +257,7 @@ namespace ZR.CodeGenerator
string fileName;
if (generateDto.VueVersion == 3)
{
- fileName = generateDto.GenTable.BusinessName.ToLower() + ".js";
+ fileName = generateDto.GenTable.BusinessName.ToLower() + ".js";//vue3 api寮曠敤鐩墠鍙兘灏忓啓
}
else
{
@@ -257,7 +266,6 @@ namespace ZR.CodeGenerator
string fullPath = Path.Combine(generateDto.VueParentPath, "src", "api", generateDto.GenTable.ModuleName.FirstLowerCase(), fileName);
generateDto.GenCodes.Add(new GenCode(7, "api.js", fullPath, result));
-
}
///
@@ -302,7 +310,7 @@ namespace ZR.CodeGenerator
///
public static string GenerateVueTableList()
{
- return JnHelper.ReadTemplate(CodeTemplateDir, "TableList.txt").Render();
+ return JnHelper.ReadTemplate(CodeTemplateDir, "TableList.txt").Render();
}
///
@@ -362,7 +370,7 @@ namespace ZR.CodeGenerator
{
try
{
- return string.IsNullOrEmpty(str) ? str : str.Substring(0, 1).ToLower() + str[1..];
+ return string.IsNullOrEmpty(str) ? str : str[..1].ToLower() + str[1..];
}
catch (Exception ex)
{
@@ -476,6 +484,7 @@ namespace ZR.CodeGenerator
IsInsert = !column.IsIdentity || GenConstants.inputDtoNoField.Any(f => f.Contains(column.DbColumnName, StringComparison.OrdinalIgnoreCase)),//闈炶嚜澧炲瓧娈甸兘闇瑕佹彃鍏
IsEdit = true,
IsQuery = false,
+ IsExport = true,
HtmlType = GenConstants.HTML_INPUT,
};
@@ -529,7 +538,7 @@ namespace ZR.CodeGenerator
///
private static void InitJntTemplate(GenerateDto dto, ReplaceDto replaceDto)
{
- //Engine.Current.Clean();
+ 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妯℃澘寮曟搸鍏ㄥ眬鍙橀噺
diff --git a/ZR.CodeGenerator/GenConstants.cs b/ZR.CodeGenerator/GenConstants.cs
index 5384f8a67507b3f5606190028f0a335093f66dba..83a35e495ffb1be068f4e4c1054cfed80a15d777 100644
--- a/ZR.CodeGenerator/GenConstants.cs
+++ b/ZR.CodeGenerator/GenConstants.cs
@@ -91,6 +91,10 @@ namespace ZR.CodeGenerator
/** 涓嬫媺妗 */
public static string HTML_SELECT = "select";
+ ///
+ /// 涓嬫媺澶氶
+ ///
+ public static string HTML_SELECT_MULTI = "selectMulti";
/** 鍗曢夋 */
public static string HTML_RADIO = "radio";
diff --git a/ZR.CodeGenerator/Model/ReplaceDto.cs b/ZR.CodeGenerator/Model/ReplaceDto.cs
index e61cfd1edf21a58087be1a4d18897716496095cf..4ff77dbca75b46c8c4c666bdfb7198208870f246 100644
--- a/ZR.CodeGenerator/Model/ReplaceDto.cs
+++ b/ZR.CodeGenerator/Model/ReplaceDto.cs
@@ -48,11 +48,16 @@ namespace ZR.CodeGenerator.Model
public bool ShowBtnEdit { get; set; }
public bool ShowBtnDelete { get; set; }
public bool ShowBtnView { get; set; }
+ public bool ShowBtnTruncate { get; set; }
///
/// 涓婁紶URL data
///
//public string VueUploadUrl { get; set; }
public int UploadFile { get; set; } = 0;
+ ///
+ /// 鏄惁鏈変笅鎷夊閫夋
+ ///
+ public int SelectMulti { get; set; }
public string Author { get; set; }
public string AddTime { get; set; } = DateTime.Now.ToString("yyyy-MM-dd");
}
diff --git a/ZR.CodeGenerator/ZR.CodeGenerator.csproj b/ZR.CodeGenerator/ZR.CodeGenerator.csproj
index 953bf9632d794bf8c2c81da41a08e025b75d4348..e4d57c90efecd3fd661feebafc6f0a93ec2c30b7 100644
--- a/ZR.CodeGenerator/ZR.CodeGenerator.csproj
+++ b/ZR.CodeGenerator/ZR.CodeGenerator.csproj
@@ -11,7 +11,7 @@
-
-
+
+
diff --git a/ZR.Common/ExcelHelper.cs b/ZR.Common/ExcelHelper.cs
index d40a98a57a16a3d09e9598b0d20a722a1c56fa35..309b725774df058c249a78c0a80e9d7dbecb18d7 100644
--- a/ZR.Common/ExcelHelper.cs
+++ b/ZR.Common/ExcelHelper.cs
@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
-using OfficeOpenXml;
+
namespace ZR.Common
{
public class ExcelHelper where T : new()
@@ -13,84 +13,84 @@ namespace ZR.Common
///
///
///
- public static IEnumerable ImportData(Stream stream)
- {
- using ExcelPackage package = new(stream);
- ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
- ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//璇诲彇绗1涓猻heet
- //鑾峰彇琛ㄦ牸鐨勫垪鏁板拰琛屾暟
+ //public static IEnumerable ImportData(Stream stream)
+ //{
+ // using ExcelPackage package = new(stream);
+ // //ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
+ // ExcelWorksheet worksheet = package.Workbook.Worksheets[0];//璇诲彇绗1涓猻heet
+ // //鑾峰彇琛ㄦ牸鐨勫垪鏁板拰琛屾暟
- 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;
+ // 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 resultList = new();
- List propertyInfos = new();// new(typeof(T).GetProperties());
- Dictionary dictHeader = new();
- for (int i = colStart; i < colEnd; i++)
- {
- var name = worksheet.Cells[rowStart, i].Value.ToString();
- dictHeader[name] = i;
+ // List resultList = new();
+ // List propertyInfos = new();// new(typeof(T).GetProperties());
+ // Dictionary 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();
+ // 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());
- break;
- case "int16":
- p.SetValue(result, cell.GetValue()); break;
- case "int32":
- p.SetValue(result, cell.GetValue()); break;
- case "int64":
- p.SetValue(result, cell.GetValue()); break;
- case "decimal":
- p.SetValue(result, cell.GetValue());
- break;
- case "double":
- p.SetValue(result, cell.GetValue()); break;
- case "datetime":
- p.SetValue(result, cell.GetValue()); break;
- case "boolean":
- p.SetValue(result, cell.GetValue()); break;
- case "char":
- p.SetValue(result, cell.GetValue()); break;
- default:
- break;
- }
- }
- catch (KeyNotFoundException ex)
- {
- Console.WriteLine("鏈壘鍒拌鍒楀皢缁х画寰幆锛" + ex.Message);
- continue;
- }
- }
- resultList.Add(result);
- }
+ // 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());
+ // break;
+ // case "int16":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "int32":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "int64":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "decimal":
+ // p.SetValue(result, cell.GetValue());
+ // break;
+ // case "double":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "datetime":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "boolean":
+ // p.SetValue(result, cell.GetValue()); break;
+ // case "char":
+ // p.SetValue(result, cell.GetValue()); break;
+ // default:
+ // break;
+ // }
+ // }
+ // catch (KeyNotFoundException ex)
+ // {
+ // Console.WriteLine("鏈壘鍒拌鍒楀皢缁х画寰幆锛" + ex.Message);
+ // continue;
+ // }
+ // }
+ // resultList.Add(result);
+ // }
- return resultList;
- }
+ // return resultList;
+ //}
///
/// 鏌ユ壘Excel鍒楀悕瀵瑰簲鐨勫疄浣撳睘鎬
diff --git a/ZR.Common/Tools.cs b/ZR.Common/Tools.cs
index 053802cf4da4f6fb77947c8a36aa1947656b8c2a..f049dda804526756a78973055a12385cc9e24bd9 100644
--- a/ZR.Common/Tools.cs
+++ b/ZR.Common/Tools.cs
@@ -81,6 +81,20 @@ namespace ZR.Common
}
}
+ public static bool CheckUserName(string str)
+ {
+ try
+ {
+ string rg = @"^[a-z][a-z0-9-_]*$";
+ return Regex.IsMatch(str, rg);
+ }
+ catch (Exception ex)
+ {
+ Console.WriteLine(ex.Message);
+ return false;
+ }
+ }
+
///
/// 璁$畻瀵嗙爜寮哄害
///
diff --git a/ZR.Common/WxNoticeHelper.cs b/ZR.Common/WxNoticeHelper.cs
new file mode 100644
index 0000000000000000000000000000000000000000..0f7fa3a190cff8c7eeeb843a1953b2deddc028e5
--- /dev/null
+++ b/ZR.Common/WxNoticeHelper.cs
@@ -0,0 +1,157 @@
+锘縰sing Infrastructure;
+using System.Collections.Generic;
+using System.Text.Json;
+
+namespace ZR.Common
+{
+ public class WxNoticeHelper
+ {
+ //CorpID 浼佷笟ID
+ //AGENTID 搴旂敤鐨処D
+ //Secret 搴旂敤鐨処D瀵瑰簲鐨勫瘑閽
+ private static readonly string AGENTID = AppSettings.App(new string[] { "WxCorp", "AgentID" });
+ private static readonly string CORPID = AppSettings.App(new string[] { "WxCorp", "CorpID" });
+ private static readonly string CORPSECRET = AppSettings.App(new string[] { "WxCorp", "CorpSecret" });
+ private static readonly string SEND_USER = AppSettings.App(new string[] { "WxCorp", "SendUser" });
+ private static readonly string SendUrl = "https://qyapi.weixin.qq.com/cgi-bin/message/send";
+ private static readonly string GetTokenUrl = "https://qyapi.weixin.qq.com/cgi-bin/gettoken";
+
+ ///
+ /// 娑堟伅绫诲瀷
+ ///
+ public enum MsgType { markdown, text, textcard, interactive_taskcard }
+
+ ///
+ /// 鍙戦佹秷鎭叕鍏辨ā鏉挎柟娉
+ ///
+ /// 寰俊寰俊濂藉弸id锛岄粯璁all鍙戠粰鎵鏈夊叧娉ㄨ搴旂敤鐨勭敤鎴
+ /// 鏍囬
+ /// 鍐呭
+ /// 娑堟伅绫诲瀷
+ ///
+ public static (int, string) SendMsg(string title, string content, string toUser = "", MsgType msgType = MsgType.text)
+ {
+ if (string.IsNullOrEmpty(toUser))
+ {
+ toUser = SEND_USER;
+ }
+ if (string.IsNullOrEmpty(title))
+ {
+ return (0, "title涓嶈兘涓虹┖");
+ }
+ if (string.IsNullOrEmpty(CORPID))
+ {
+ return (0, "璇峰畬鎴愪紒涓氬井淇¢氱煡閰嶇疆");
+ }
+ GetTokenResult tokenResult = GetAccessToken();
+
+ if (tokenResult == null || tokenResult.errcode != 0)
+ {
+ return (0, tokenResult?.errmsg);
+ }
+
+ Dictionary dic = null;
+ switch (msgType)
+ {
+ case MsgType.markdown:
+ dic = GetMarkdown(title, content, toUser);
+ break;
+ case MsgType.text:
+ dic = GetText(title, content, toUser);
+ break;
+ case MsgType.textcard:
+ break;
+ case MsgType.interactive_taskcard:
+ break;
+ default:
+ dic = GetText(title, content, toUser);
+ break;
+ }
+ string postData = JsonSerializer.Serialize(dic);
+ string msgUrl = $"{SendUrl}?access_token={tokenResult.access_token}";
+
+ //杩斿洖缁撴灉
+ //{"errcode":0,"errmsg":"ok","invaliduser":""}
+ string msgResult = HttpHelper.HttpPost(msgUrl, postData, "contentType/json");
+ GetTokenResult getTokenResult = JsonSerializer.Deserialize(msgResult);
+
+ return (getTokenResult?.errcode == 0 ? 100 : 0, getTokenResult?.errmsg);
+ }
+ public static (int, string) SendMsg(string title, string content, string toUser)
+ {
+ return SendMsg(title, content, toUser, MsgType.markdown);
+ }
+
+ ///
+ /// 鑾峰彇璁块棶token
+ ///
+ ///
+ /// {"errcode":0,"errmsg":"ok","access_token":"iCbcfE1OjfRhV0_io-CzqTNC0lnrudeW3oF5rhJKfmINaxLClLa1FoqAY_wEXtodYh_DTnrtAwZfzeb-NRXvwiOoqUTHx3i6QKLYcfBtF8y-xd5mvaeaf3e9mvTAPhmX0lkm1cLTwRLmoa1IwzgQ-QZEZcuIcntWdEMGseVYok3BwCGpC87bt6nNdgnekZdFVRp1uuaxoctDGlXpoQlQsA","expires_in":7200}
+ ///
+ private static GetTokenResult GetAccessToken()
+ {
+ string getTokenUrl = $"{GetTokenUrl}?corpid={CORPID}&corpsecret={CORPSECRET}";
+ string getTokenResult = HttpHelper.HttpGet(getTokenUrl);
+
+ GetTokenResult tokenResult = JsonSerializer.Deserialize(getTokenResult);
+ return tokenResult;
+ }
+
+ ///
+ /// 鍙戦乼ext
+ ///
+ ///
+ ///
+ ///
+ ///
+ private static Dictionary GetText(string title, string content, string toUser = "")
+ {
+ Dictionary dic = new()
+ {
+ { "msgtype", "text" },
+ { "touser", toUser },
+ { "agentid", AGENTID },
+ { "text", new Dictionary
+ {
+ { "content",$"{title}\n\n{content}"
+ }
+ }}
+ };
+ return dic;
+ }
+
+ ///
+ /// 鍙戦乵arkdown
+ ///
+ /// 瑕佸彂閫佺殑鏍囬
+ /// 鍙戦佺殑鍐呭
+ /// 鎸囧畾鎺ユ敹娑堟伅鐨勬垚鍛橈紝鎴愬憳ID鍒楄〃锛堝涓帴鏀惰呯敤鈥榺鈥欏垎闅旓紝鏈澶氭敮鎸1000涓級銆 鐗规畩鎯呭喌锛氭寚瀹氫负鈥滰all鈥濓紝鍒欏悜璇ヤ紒涓氬簲鐢ㄧ殑鍏ㄩ儴鎴愬憳鍙戦
+ ///
+ private static Dictionary GetMarkdown(string title, string content, string toUser = "")
+ {
+ Dictionary dic = new()
+ {
+ { "touser", toUser },
+ { "msgtype", "markdown" },
+ { "agentid", AGENTID },
+ { "enable_duplicate_check",1}
+ };
+
+ dic.Add("markdown", new Dictionary
+ {
+ { "content", $"**{title}**\n\n{content}" }
+ });
+ return dic;
+ }
+
+ public class GetTokenResult
+ {
+ ///
+ /// 0銆佹甯
+ ///
+ public int errcode { get; set; }
+ public string errmsg { get; set; }
+ public string access_token { get; set; }
+ }
+ }
+}
diff --git a/ZR.Common/ZR.Common.csproj b/ZR.Common/ZR.Common.csproj
index c737253c2e44ee6ebf1a623a87a1180580a2d26b..108553dd18b54356f7814b0afe2ec2ecae7bbc08 100644
--- a/ZR.Common/ZR.Common.csproj
+++ b/ZR.Common/ZR.Common.csproj
@@ -6,11 +6,11 @@
-
-
-
-
+
+
+
+
diff --git a/ZR.Model/System/CommonLang.cs b/ZR.Model/System/CommonLang.cs
index b48c7406c509753cc2b1846a5ebb4004e89b1ebd..84a0f91e525f4cae0114952e46fedb8302e214ee 100644
--- a/ZR.Model/System/CommonLang.cs
+++ b/ZR.Model/System/CommonLang.cs
@@ -1,8 +1,7 @@
-using System;
-using System.Collections.Generic;
-using SqlSugar;
-using OfficeOpenXml.Attributes;
using Newtonsoft.Json;
+using SqlSugar;
+using System;
+using System.ComponentModel;
namespace ZR.Model.Models
{
@@ -21,7 +20,6 @@ namespace ZR.Model.Models
/// 绌哄 : false
///
[JsonConverter(typeof(ValueToStringConverter))]
- [EpplusTableColumn(Header = "id")]
[SugarColumn(IsPrimaryKey = true)]
public long Id { get; set; }
@@ -29,7 +27,7 @@ namespace ZR.Model.Models
/// 鎻忚堪 : 璇█code
/// 绌哄 : false
///
- [EpplusTableColumn(Header = "璇█code")]
+ [DisplayName("璇█code")]
[SugarColumn(ColumnName = "lang_code")]
public string LangCode { get; set; }
@@ -37,7 +35,7 @@ namespace ZR.Model.Models
/// 鎻忚堪 : 璇█key
/// 绌哄 : true
///
- [EpplusTableColumn(Header = "璇█key")]
+ [DisplayName("璇█key")]
[SugarColumn(ColumnName = "lang_key")]
public string LangKey { get; set; }
@@ -45,7 +43,7 @@ namespace ZR.Model.Models
/// 鎻忚堪 : 鍚嶇О
/// 绌哄 : false
///
- [EpplusTableColumn(Header = "鍚嶇О")]
+ [DisplayName("鍚嶇О")]
[SugarColumn(ColumnName = "lang_name")]
public string LangName { get; set; }
@@ -53,7 +51,7 @@ namespace ZR.Model.Models
/// 鎻忚堪 : 娣诲姞鏃堕棿
/// 绌哄 : true
///
- [EpplusTableColumn(Header = "娣诲姞鏃堕棿", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ [DisplayName("娣诲姞鏃堕棿")]
public DateTime? Addtime { get; set; }
}
}
\ No newline at end of file
diff --git a/ZR.Model/System/Dto/GenTableDto.cs b/ZR.Model/System/Dto/GenTableDto.cs
index ba032412ff86dbe32b7b4138414e4cc1ffefa6a3..e934e609a8009faad350748104d59db3b650f661 100644
--- a/ZR.Model/System/Dto/GenTableDto.cs
+++ b/ZR.Model/System/Dto/GenTableDto.cs
@@ -59,6 +59,7 @@ namespace ZR.Model.System.Dto
public bool IsQuery { get; set; }
public bool IsSort { get; set; }
public bool IsRequired { get; set; }
+ public bool IsExport { get; set; }
///
/// 鏄剧ず绫诲瀷锛堟枃鏈銆佹枃鏈煙銆佷笅鎷夋銆佸閫夋銆佸崟閫夋銆佹棩鏈熸帶浠讹級
///
@@ -77,5 +78,4 @@ namespace ZR.Model.System.Dto
///
public string Remark { get; set; }
}
-
}
diff --git a/ZR.Model/System/Dto/MenuDto.cs b/ZR.Model/System/Dto/MenuDto.cs
index 2152c99fa96b3c6b3b4d0971c8c7aed5bf8180b7..23c3a26f3ec0c6f784b9228614962783e195cfde 100644
--- a/ZR.Model/System/Dto/MenuDto.cs
+++ b/ZR.Model/System/Dto/MenuDto.cs
@@ -1,7 +1,5 @@
锘縰sing System;
-using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using System.Text;
namespace ZR.Model.System.Dto
{
@@ -14,60 +12,60 @@ namespace ZR.Model.System.Dto
///
/// 鐖惰彍鍗旾D
///
- public long? parentId { get; set; }
+ public long? ParentId { get; set; }
///
/// 鏄剧ず椤哄簭
///
- public int orderNum { get; set; }
+ public int OrderNum { get; set; }
///
/// 璺敱鍦板潃
///
- public string path { get; set; } = "#";
+ public string Path { get; set; } = "#";
///
/// 缁勪欢璺緞
///
- public string component { get; set; }
+ public string Component { get; set; }
///
/// 鏄惁缂撳瓨锛1缂撳瓨 0涓嶇紦瀛橈級
///
[Required(ErrorMessage = "鏄惁缂撳瓨涓嶈兘涓虹┖")]
- public string isCache { get; set; }
+ public string IsCache { get; set; }
///
/// 鏄惁澶栭摼 1銆佹槸 0銆佸惁
///
- public string isFrame { get; set; }
+ public string IsFrame { get; set; }
///
/// 绫诲瀷锛圡鐩綍 C鑿滃崟 F鎸夐挳 L閾炬帴锛
///
[Required(ErrorMessage = "鑿滃崟绫诲瀷涓嶈兘涓虹┖")]
- public string menuType { get; set; }
+ public string MenuType { get; set; }
///
/// 鏄剧ず鐘舵侊紙0鏄剧ず 1闅愯棌锛
///
[Required(ErrorMessage = "鏄剧ず鐘舵佷笉鑳戒负绌")]
- public string visible { get; set; }
+ public string Visible { get; set; }
///
/// 鑿滃崟鐘舵侊紙0姝e父 1鍋滅敤锛
///
[Required(ErrorMessage = "鑿滃崟鐘舵佷笉鑳戒负绌")]
- public string status { get; set; }
+ public string Status { get; set; }
///
/// 鏉冮檺瀛楃涓
///
- public string perms { get; set; }
+ public string Perms { get; set; }
///
/// 鑿滃崟鍥炬爣
///
- public string icon { get; set; } = string.Empty;
+ public string Icon { get; set; } = string.Empty;
///
/// 缈昏瘧key
///
diff --git a/ZR.Model/System/Dto/SysDictTypeDto.cs b/ZR.Model/System/Dto/SysDictTypeDto.cs
new file mode 100644
index 0000000000000000000000000000000000000000..4a39430549851436a62dfe2af6792fc963225b0e
--- /dev/null
+++ b/ZR.Model/System/Dto/SysDictTypeDto.cs
@@ -0,0 +1,28 @@
+锘縰sing System.ComponentModel.DataAnnotations;
+
+namespace ZR.Model.System.Dto
+{
+ public class SysDictTypeDto
+ {
+ public long DictId { get; set; }
+ ///
+ /// 瀛楀吀鍚嶇О
+ ///
+ public string DictName { get; set; }
+ ///
+ /// 瀛楀吀绫诲瀷
+ ///
+ [Required(ErrorMessage = "瀛楀吀绫诲瀷涓嶈兘涓虹┖")]
+ [RegularExpression(pattern: "^[a-z][a-z0-9_]*$", ErrorMessage = "瀛楀吀绫诲瀷蹇呴』浠ュ瓧姣嶅紑澶,涓斿瓧鍏哥被鍨嬪彧鑳界敱灏忓啓瀛楁瘝鎴栧姞涓嬪垝绾胯繕鏈夋暟瀛楃粍鎴")]
+ public string DictType { get; set; }
+ public string Status { get; set; }
+ ///
+ /// 绯荤粺鍐呯疆 Y鏄 N鍚
+ ///
+ public string Type { get; set; }
+ ///
+ /// 鑷畾涔塻ql
+ ///
+ public string CustomSql { get; set; }
+ }
+}
diff --git a/ZR.Model/System/Dto/TasksDto.cs b/ZR.Model/System/Dto/TasksDto.cs
index 198f43961f03ecf0a9dab433f4a09ff3d63045b8..fb3a0b419c0a80b46b2172064ee3ae1f3d0eca6e 100644
--- a/ZR.Model/System/Dto/TasksDto.cs
+++ b/ZR.Model/System/Dto/TasksDto.cs
@@ -14,6 +14,8 @@ namespace ZR.Model.System.Dto
///
[Display(Name = "鏌ヨ瀛楃涓")]
public string QueryText { get; set; }
+ public int? TaskType { get; set; }
+ public int? TriggerType { get; set; }
}
///
@@ -22,115 +24,12 @@ namespace ZR.Model.System.Dto
public class TasksCreateDto
{
///
- /// 鎻忚堪 : 浠诲姟鍚嶇О
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "浠诲姟鍚嶇О")]
- [Required(ErrorMessage = "浠诲姟鍚嶇О涓嶈兘涓虹┖")]
- public string Name { get; set; }
-
- ///
- /// 鎻忚堪 : 浠诲姟鍒嗙粍
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "浠诲姟鍒嗙粍")]
- [Required(ErrorMessage = "浠诲姟鍒嗙粍涓嶈兘涓虹┖")]
- public string JobGroup { get; set; }
-
- ///
- /// 鎻忚堪 : 杩愯鏃堕棿琛ㄨ揪寮
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "杩愯鏃堕棿琛ㄨ揪寮")]
- public string Cron { get; set; }
-
- ///
- /// 鎻忚堪 : 绋嬪簭闆嗗悕绉
+ /// 鎻忚堪 : 浠诲姟id
/// 绌哄 : False
/// 榛樿 :
///
- [Display(Name = "绋嬪簭闆嗗悕绉")]
- //[Required(ErrorMessage = "绋嬪簭闆嗗悕绉颁笉鑳戒负绌")]
- public string AssemblyName { get; set; }
-
- ///
- /// 鎻忚堪 : 浠诲姟鎵鍦ㄧ被
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "浠诲姟鎵鍦ㄧ被")]
- //[Required(ErrorMessage = "浠诲姟鎵鍦ㄧ被涓嶈兘涓虹┖")]
- public string ClassName { get; set; }
-
- ///
- /// 鎻忚堪 : 浠诲姟鎻忚堪
- /// 绌哄 : True
- /// 榛樿 :
- ///
- [Display(Name = "浠诲姟鎻忚堪")]
- public string Remark { get; set; }
-
- ///
- /// 鎻忚堪 : 寮濮嬫椂闂
- /// 绌哄 : True
- /// 榛樿 :
- ///
- [Display(Name = "寮濮嬫椂闂")]
- public DateTime? BeginTime { get; set; }
-
- ///
- /// 鎻忚堪 : 缁撴潫鏃堕棿
- /// 绌哄 : True
- /// 榛樿 :
- ///
- [Display(Name = "缁撴潫鏃堕棿")]
- public DateTime? EndTime { get; set; }
-
- ///
- /// 鎻忚堪 : 瑙﹀彂鍣ㄧ被鍨嬶紙0銆乻imple 1銆乧ron锛
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "瑙﹀彂鍣ㄧ被鍨嬶紙0銆乻imple 1銆乧ron锛")]
- public int TriggerType { get; set; }
-
- ///
- /// 鎻忚堪 : 鎵ц闂撮殧鏃堕棿(鍗曚綅:绉)
- /// 绌哄 : False
- /// 榛樿 : 0
- ///
- [Display(Name = "鎵ц闂撮殧鏃堕棿(鍗曚綅:绉)")]
- public int IntervalSecond { get; set; }
-
- ///
- /// 鎻忚堪 : 浼犲叆鍙傛暟
- /// 绌哄 : True
- /// 榛樿 :
- ///
- [Display(Name = "浼犲叆鍙傛暟")]
- public string JobParams { get; set; }
- public string ApiUrl { get; set; }
- ///
- /// 1銆佺▼搴忛泦浠诲姟 2銆乤piUrl浠诲姟
- ///
- public int TaskType { get; set; }
- }
-
- ///
- /// 鏇存柊浠诲姟
- ///
- public class TasksUpdateDto
- {
- ///
- /// 鎻忚堪 : UID
- /// 绌哄 : False
- /// 榛樿 :
- ///
- [Display(Name = "UID")]
- [Required(ErrorMessage = "UID涓嶈兘涓虹┖")]
+ [Display(Name = "浠诲姟id")]
+ //[Required(ErrorMessage = "浠诲姟涓嶈兘涓虹┖")]
public string ID { get; set; }
///
@@ -165,7 +64,7 @@ namespace ZR.Model.System.Dto
/// 榛樿 :
///
[Display(Name = "绋嬪簭闆嗗悕绉")]
- [Required(ErrorMessage = "绋嬪簭闆嗗悕绉颁笉鑳戒负绌")]
+ //[Required(ErrorMessage = "绋嬪簭闆嗗悕绉颁笉鑳戒负绌")]
public string AssemblyName { get; set; }
///
@@ -174,7 +73,7 @@ namespace ZR.Model.System.Dto
/// 榛樿 :
///
[Display(Name = "浠诲姟鎵鍦ㄧ被")]
- [Required(ErrorMessage = "浠诲姟鎵鍦ㄧ被涓嶈兘涓虹┖")]
+ //[Required(ErrorMessage = "浠诲姟鎵鍦ㄧ被涓嶈兘涓虹┖")]
public string ClassName { get; set; }
///
@@ -226,8 +125,14 @@ namespace ZR.Model.System.Dto
public string JobParams { get; set; }
public string ApiUrl { get; set; }
///
- /// 1銆佺▼搴忛泦浠诲姟 2銆乤piUrl浠诲姟
+ /// 1銆佺▼搴忛泦浠诲姟 2銆乤piUrl浠诲姟 3銆丼QL璇彞
///
public int TaskType { get; set; }
+ public string SqlText { get; set; }
+
+ ///
+ /// 缃戠粶璇锋眰鏂瑰紡
+ ///
+ public string RequestMethod { get; set; }
}
}
diff --git a/ZR.Model/System/Generate/GenTable.cs b/ZR.Model/System/Generate/GenTable.cs
index 482ff3efaf5dea89e62b26f7d6dff70c666dd0ed..68355b38e1e406236133fe75661de48d83eb1ac7 100644
--- a/ZR.Model/System/Generate/GenTable.cs
+++ b/ZR.Model/System/Generate/GenTable.cs
@@ -74,7 +74,7 @@ namespace ZR.Model.System.Generate
///
[SqlSugar.SugarColumn(IsJson = true)]
public Options Options { get; set; }
-
+
#region 琛ㄩ澶栧瓧娈
/** 琛ㄥ垪淇℃伅 */
[SqlSugar.SugarColumn(IsIgnore = true)]
@@ -88,7 +88,7 @@ namespace ZR.Model.System.Generate
#endregion
}
- public class Options
+ public class Options
{
public long ParentMenuId { get; set; } = 0;
public string SortType { get; set; } = "asc";
@@ -96,7 +96,7 @@ namespace ZR.Model.System.Generate
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;
+ public string PermissionPrefix { get; set; } = string.Empty;
///
/// 棰濆鍙傛暟瀛楃涓
///
@@ -105,5 +105,9 @@ namespace ZR.Model.System.Generate
/// 鍒楀ぇ灏 12,24
///
public int ColNum { get; set; } = 12;
+ ///
+ /// 鏄惁鐢熸垚浠撳偍灞
+ ///
+ public int GenerateRepo { get; set; }
}
}
diff --git a/ZR.Model/System/Generate/GenTableColumn.cs b/ZR.Model/System/Generate/GenTableColumn.cs
index 72efcbd7ed562223dd72f0cac949cc2698be4278..804023c590e202ae7f88c6b7fb17d8b89dfeeeb5 100644
--- a/ZR.Model/System/Generate/GenTableColumn.cs
+++ b/ZR.Model/System/Generate/GenTableColumn.cs
@@ -75,6 +75,10 @@ namespace ZR.Model.System.Generate
///
public bool IsSort { get; set; }
///
+ /// 鏄惁瀵煎嚭锛1鏄級
+ ///
+ public bool IsExport { get; set; }
+ ///
/// 鏄剧ず绫诲瀷锛堟枃鏈銆佹枃鏈煙銆佷笅鎷夋銆佸閫夋銆佸崟閫夋銆佹棩鏈熸帶浠讹級
///
public string HtmlType { get; set; }
@@ -95,7 +99,7 @@ namespace ZR.Model.System.Generate
get
{
string[] arr = new string[] { "int", "long" };
- return (!IsRequired && (arr.Any(f => f.Contains(CsharpType))) || typeof(DateTime).Name == CsharpType) ? "?" : "";
+ return (!IsRequired && HtmlType != "selectMulti" && (arr.Any(f => f.Contains(CsharpType))) || typeof(DateTime).Name == CsharpType) ? "?" : "";
}
}
///
diff --git a/ZR.Model/System/SysBase.cs b/ZR.Model/System/SysBase.cs
index 7cb7a95df4858f511f27e16798bd175da8ab913b..21ea490d58803e42d5f4d3e9be977ebff3a3c12c 100644
--- a/ZR.Model/System/SysBase.cs
+++ b/ZR.Model/System/SysBase.cs
@@ -1,60 +1,42 @@
-锘//using Dapper.Contrib.Extensions;
+锘縰sing MiniExcelLibs.Attributes;
using Newtonsoft.Json;
-using System;
-using System.Collections.Generic;
-using System.Text;
using SqlSugar;
-using OfficeOpenXml.Attributes;
+using System;
namespace ZR.Model.System
{
- [EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
+ //[EpplusTable(PrintHeaders = true, AutofitColumns = true, AutoCalculate = true, ShowTotal = true)]
public class SysBase
{
- [SugarColumn(IsOnlyIgnoreUpdate = true)]//璁剧疆鍚庝慨鏀逛笉浼氭湁姝ゅ瓧娈
+ [SugarColumn(IsOnlyIgnoreUpdate = true)]
[JsonProperty(propertyName: "CreateBy")]
- [EpplusIgnore]
+ [ExcelIgnore]
public string Create_by { get; set; }
- [SugarColumn(IsOnlyIgnoreUpdate = true)]//璁剧疆鍚庝慨鏀逛笉浼氭湁姝ゅ瓧娈
+ [SugarColumn(IsOnlyIgnoreUpdate = true)]
[JsonProperty(propertyName: "CreateTime")]
- [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ [ExcelColumn(Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime Create_time { get; set; } = DateTime.Now;
[JsonIgnore]
[JsonProperty(propertyName: "UpdateBy")]
[SugarColumn(IsOnlyIgnoreInsert = true)]
- [EpplusIgnore]
+ [ExcelIgnore]
public string Update_by { get; set; }
//[JsonIgnore]
- [SugarColumn(IsOnlyIgnoreInsert = true)]//璁剧疆鍚庢彃鍏ユ暟鎹笉浼氭湁姝ゅ瓧娈
+ [SugarColumn(IsOnlyIgnoreInsert = true)]
[JsonProperty(propertyName: "UpdateTime")]
- [EpplusIgnore]
+ [ExcelIgnore]
public DateTime? Update_time { get; set; }
-
public string Remark { get; set; }
-
- ///
- /// 鎼滅储鏃堕棿璧峰鏃堕棿
- ///
- ///
- /// Write锛氶渶绌夸竴涓猙ool鍊硷紝false鏃秈nsert锛寀pdate绛夋搷浣滀細蹇界暐姝ゅ垪锛堝拰Computed鐨勪綔鐢ㄥ樊涓嶅锛岀湅浜嗘簮鐮佷篃娌″彂鐜颁笌Computed鏈変粈涔堜笉涓鏍风殑鍦版柟锛屾湁浜嗚В鐨勬湅鍙嬪彲浠ヨ祼鏁欎笅鍝堬級
- /// ExplicitKey锛氭寚瀹氭鍒椾负涓婚敭锛堜笉鑷姩澧為暱绫诲瀷渚嬪guid锛孍xplicitKey涓嶬ey鍦板尯鍒笅闈細璇︾粏璁诧級
- /// Key锛氭寚瀹氭鍒椾负涓婚敭锛堣嚜鍔ㄥ闀夸富閿級锛屽彲蹇界暐锛屽拷鐣ュ悗榛樿鏌ユ壘
- /// [Computed]璁$畻灞炴э紝鎵撲笂姝ゆ爣绛撅紝瀵硅薄鍦癷nsert锛寀pdate绛夋搷浣滀細蹇界暐姝ゅ垪
- ///
[SugarColumn(IsIgnore = true)]
[JsonIgnore]
- [EpplusIgnore]
+ [ExcelIgnore]
public DateTime? BeginTime { get; set; }
-
- ///
- /// 鐢ㄤ簬鎼滅储浣跨敤
- ///
[SugarColumn(IsIgnore = true)]
[JsonIgnore]
- [EpplusIgnore]
+ [ExcelIgnore]
public DateTime? EndTime { get; set; }
}
}
diff --git a/ZR.Model/System/SysDictData.cs b/ZR.Model/System/SysDictData.cs
index 34510843b5e7f288327d82543d5642cf734be5f1..a2baabcd585261164ce5a267262d6691170e624d 100644
--- a/ZR.Model/System/SysDictData.cs
+++ b/ZR.Model/System/SysDictData.cs
@@ -1,8 +1,4 @@
-锘//using Dapper.Contrib.Extensions;
-using System;
-using System.Collections.Generic;
-using System.Text;
-using SqlSugar;
+锘縰sing SqlSugar;
namespace ZR.Model.System
{
@@ -13,11 +9,10 @@ namespace ZR.Model.System
[SugarTable("sys_dict_data")]
public class SysDictData: SysBase
{
- //[Key]
///
/// 瀛楀吀涓婚敭
///
- [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//涓婚敭骞朵笖鑷 锛坰tring涓嶈兘璁剧疆鑷锛
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long DictCode{ get; set; }
public int DictSort { get; set; }
public string DictLabel { get; set; }
diff --git a/ZR.Model/System/SysDictType.cs b/ZR.Model/System/SysDictType.cs
index 744f0a41ab182ff65e39ffff6bf5d6a33ba8542c..17b07c1d3a3f9dc4c4ea61e104ff675b4220d336 100644
--- a/ZR.Model/System/SysDictType.cs
+++ b/ZR.Model/System/SysDictType.cs
@@ -1,5 +1,4 @@
-锘縰sing OfficeOpenXml.Attributes;
-using SqlSugar;
+锘縰sing SqlSugar;
namespace ZR.Model.System
{
@@ -13,7 +12,7 @@ namespace ZR.Model.System
///
/// 瀛楀吀涓婚敭
///
- [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]//涓婚敭骞朵笖鑷 锛坰tring涓嶈兘璁剧疆鑷锛
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long DictId { get; set; }
///
/// 瀛楀吀鍚嶇О
@@ -26,11 +25,14 @@ namespace ZR.Model.System
///
/// 鐘舵 0銆佹甯 1銆佸仠鐢
///
- [EpplusIgnore]
public string Status { get; set; }
///
/// 绯荤粺鍐呯疆 Y鏄 N鍚
///
public string Type { get; set; }
+ ///
+ /// 鑷畾涔塻ql
+ ///
+ public string CustomSql { get; set; }
}
}
diff --git a/ZR.Model/System/SysFile.cs b/ZR.Model/System/SysFile.cs
index 81c75bebc8954694b89c0082ab02d4ff18e3f675..f06626591f039477318fd11d1d64645245aa918f 100644
--- a/ZR.Model/System/SysFile.cs
+++ b/ZR.Model/System/SysFile.cs
@@ -1,8 +1,6 @@
锘縰sing Newtonsoft.Json;
using SqlSugar;
using System;
-using System.Collections.Generic;
-using System.Text;
namespace ZR.Model.System
{
diff --git a/ZR.Model/System/SysLogininfor.cs b/ZR.Model/System/SysLogininfor.cs
index 1350e02e3d682b8ae89111015664138ed96e0e95..9c0889e61685e868d44767e9304970c4a2fc399a 100644
--- a/ZR.Model/System/SysLogininfor.cs
+++ b/ZR.Model/System/SysLogininfor.cs
@@ -1,6 +1,4 @@
-锘//using Dapper.Contrib.Extensions;
-using OfficeOpenXml.Attributes;
-using SqlSugar;
+锘縰sing SqlSugar;
using System;
namespace ZR.Model.System
@@ -14,47 +12,46 @@ namespace ZR.Model.System
{
//[Key]
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
- public long infoId { get; set; }
+ public long InfoId { get; set; }
///
/// 鐢ㄦ埛璐﹀彿
///
- public string userName { get; set; }
+ public string UserName { get; set; }
///
/// 鐧诲綍鐘舵 0鎴愬姛 1澶辫触
///
- public string status { get; set; }
+ public string Status { get; set; }
///
/// 鐧诲綍IP鍦板潃
///
- public string ipaddr { get; set; }
+ public string Ipaddr { get; set; }
///
/// 鐧诲綍鍦扮偣
///
- public string loginLocation { get; set; }
+ public string LoginLocation { get; set; }
///
/// 娴忚鍣ㄧ被鍨
///
- public string browser { get; set; }
+ public string Browser { get; set; }
/** 鎿嶄綔绯荤粺 */
//@Excel(name = "鎿嶄綔绯荤粺")
- public string os { get; set; }
+ public string Os { get; set; }
///
/// 鎻愮ず娑堟伅
///
- public string msg { get; set; }
+ public string Msg { get; set; }
///
/// 璁块棶鏃堕棿
///
- [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
- public DateTime loginTime { get; set; } = DateTime.Now;
+ public DateTime LoginTime { get; set; } = DateTime.Now;
[SugarColumn(IsIgnore = true)]
public DateTime? BeginTime { get; set; }
[SugarColumn(IsIgnore = true)]
diff --git a/ZR.Model/System/SysMenu.cs b/ZR.Model/System/SysMenu.cs
index 61d0c4f6f9ded21b28f511151fcde6dc1da39577..6613e0a4d0900c5e5f7c17f17345311f4a4a7bdf 100644
--- a/ZR.Model/System/SysMenu.cs
+++ b/ZR.Model/System/SysMenu.cs
@@ -24,56 +24,56 @@ namespace ZR.Model.System
///
/// 鐖惰彍鍗旾D
///
- public long parentId { get; set; }
+ public long ParentId { get; set; }
///
/// 鏄剧ず椤哄簭
///
- public int orderNum { get; set; }
+ public int OrderNum { get; set; }
///
/// 璺敱鍦板潃
///
- public string path { get; set; } = "#";
+ public string Path { get; set; } = "#";
///
/// 缁勪欢璺緞
///
- public string component { get; set; }
+ public string Component { get; set; }
///
/// 鏄惁缂撳瓨锛1缂撳瓨 0涓嶇紦瀛橈級
///
- public string isCache { get; set; }
+ public string IsCache { get; set; }
///
/// 鏄惁澶栭摼 1銆佹槸 0銆佸惁
///
- public string isFrame { get; set; }
+ public string IsFrame { get; set; }
///
/// 绫诲瀷锛圡鐩綍 C鑿滃崟 F鎸夐挳 L閾炬帴锛
///
- public string menuType { get; set; }
+ public string MenuType { get; set; }
///
/// 鏄剧ず鐘舵侊紙0鏄剧ず 1闅愯棌锛
///
- public string visible { get; set; }
+ public string Visible { get; set; }
///
/// 鑿滃崟鐘舵侊紙0姝e父 1鍋滅敤锛
///
- public string status { get; set; }
+ public string Status { get; set; }
///
/// 鏉冮檺瀛楃涓
///
- public string perms { get; set; }
+ public string Perms { get; set; }
///
/// 鑿滃崟鍥炬爣
///
- public string icon { get; set; } = string.Empty;
+ public string Icon { get; set; } = string.Empty;
///
/// 鑿滃崟鍚峩ey
///
@@ -83,7 +83,7 @@ namespace ZR.Model.System
/// 瀛愯彍鍗
///
[SugarColumn(IsIgnore = true)]
- public List children { get; set; } = new List();
+ public List Children { get; set; } = new List();
///
/// 瀛愯彍鍗曚釜鏁
///
@@ -97,7 +97,7 @@ namespace ZR.Model.System
{
get
{
- return SubNum > 0 || children.Count > 0;
+ return SubNum > 0 || Children.Count > 0;
}
}
}
diff --git a/ZR.Model/System/SysNotice.cs b/ZR.Model/System/SysNotice.cs
index 47facb714dee71ebb4e5b55ed63613c57ca299d5..61703b8d5af8f46943fd09757c3f183a7879bcae 100644
--- a/ZR.Model/System/SysNotice.cs
+++ b/ZR.Model/System/SysNotice.cs
@@ -1,5 +1,3 @@
-using System;
-using System.Collections.Generic;
using SqlSugar;
using ZR.Model.System;
@@ -19,7 +17,7 @@ namespace ZR.Model.Models
/// 鎻忚堪 : 鍏憡ID
/// 绌哄 : true
///
- [SqlSugar.SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "notice_id")]
+ [SugarColumn(IsPrimaryKey = true, IsIdentity = true, ColumnName = "notice_id")]
public int NoticeId { get; set; }
///
/// 鎻忚堪 : 鍏憡鏍囬
diff --git a/ZR.Model/System/SysOperLog.cs b/ZR.Model/System/SysOperLog.cs
index bdaa0980f5dc142ded47c3986462878a1a7a8f80..233ba2625050035d7925e3fc64b7333e035c1f44 100644
--- a/ZR.Model/System/SysOperLog.cs
+++ b/ZR.Model/System/SysOperLog.cs
@@ -1,9 +1,7 @@
-锘縰sing Newtonsoft.Json;
+锘縰sing MiniExcelLibs.Attributes;
using SqlSugar;
using System;
-using System.Collections.Generic;
-using System.Text;
-using OfficeOpenXml.Attributes;
+using System.ComponentModel;
namespace ZR.Model.System
{
@@ -14,75 +12,79 @@ namespace ZR.Model.System
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public long OperId { get; set; }
/** 鎿嶄綔妯″潡 */
- //@Excel(name = "鎿嶄綔妯″潡")
- public string title { get; set; }
+ [DisplayName("鎿嶄綔妯″潡")]
+ public string Title { get; set; }
/** 涓氬姟绫诲瀷锛0鍏跺畠 1鏂板 2淇敼 3鍒犻櫎锛 */
//@Excel(name = "涓氬姟绫诲瀷", readConverterExp = "0=鍏跺畠,1=鏂板,2=淇敼,3=鍒犻櫎,4=鎺堟潈,5=瀵煎嚭,6=瀵煎叆,7=寮洪,8=鐢熸垚浠g爜,9=娓呯┖鏁版嵁")
- public int businessType { get; set; }
+ [DisplayName("涓氬姟绫诲瀷")]
+ public int BusinessType { get; set; }
/** 涓氬姟绫诲瀷鏁扮粍 */
[SugarColumn(IsIgnore = true)]
- public int[] businessTypes { get; set; }
+ [ExcelIgnore]
+ public int[] BusinessTypes { get; set; }
/** 璇锋眰鏂规硶 */
- //@Excel(name = "璇锋眰鏂规硶")
- public string method { get; set; }
+ [DisplayName("璇锋眰鏂规硶")]
+ public string Method { get; set; }
/** 璇锋眰鏂瑰紡 */
- //@Excel(name = "璇锋眰鏂瑰紡")
- public string requestMethod { get; set; }
+ [DisplayName("璇锋眰鏂瑰紡")]
+ public string RequestMethod { get; set; }
/** 鎿嶄綔绫诲埆锛0鍏跺畠 1鍚庡彴鐢ㄦ埛 2鎵嬫満绔敤鎴凤級 */
//@Excel(name = "鎿嶄綔绫诲埆", readConverterExp = "0=鍏跺畠,1=鍚庡彴鐢ㄦ埛,2=鎵嬫満绔敤鎴")
- public int operatorType { get; set; }
+ [DisplayName("鎿嶄綔绫诲埆")]
+ public int OperatorType { get; set; }
/** 鎿嶄綔浜哄憳 */
- //@Excel(name = "鎿嶄綔浜哄憳")
- public string operName { get; set; }
+ [DisplayName("鎿嶄綔浜哄憳")]
+ public string OperName { get; set; }
/** 閮ㄩ棬鍚嶇О */
- //@Excel(name = "閮ㄩ棬鍚嶇О")
- public string deptName { get; set; }
+ [DisplayName("閮ㄩ棬鍚嶇О")]
+ public string DeptName { get; set; }
/** 璇锋眰url */
- //@Excel(name = "璇锋眰鍦板潃")
- public string operUrl { get; set; }
+ [DisplayName("璇锋眰鍦板潃")]
+ public string OperUrl { get; set; }
/** 鎿嶄綔鍦板潃 */
- //@Excel(name = "鎿嶄綔鍦板潃")
- public string operIp { get; set; }
+ [DisplayName("鎿嶄綔鍦板潃")]
+ public string OperIp { get; set; }
/** 鎿嶄綔鍦扮偣 */
- //@Excel(name = "鎿嶄綔鍦扮偣")
- public string operLocation { get; set; }
+ [DisplayName("鎿嶄綔鍦扮偣")]
+ public string OperLocation { get; set; }
/** 璇锋眰鍙傛暟 */
- //@Excel(name = "璇锋眰鍙傛暟")
- public string operParam { get; set; }
+ [DisplayName("璇锋眰鍙傛暟")]
+ public string OperParam { get; set; }
/** 杩斿洖鍙傛暟 */
- //@Excel(name = "杩斿洖鍙傛暟")
- public string jsonResult { get; set; }
+ [DisplayName("杩斿洖缁撴灉")]
+ public string JsonResult { get; set; }
/** 鎿嶄綔鐘舵侊紙0姝e父 1寮傚父锛 */
- //@Excel(name = "鐘舵", readConverterExp = "0=姝e父,1=寮傚父")
- public int status { get; set; }
+ [DisplayName("鐘舵")]
+ public int Status { get; set; }
///
/// 閿欒娑堟伅
///
- [EpplusTableColumn(Header = "閿欒娑堟伅")]
- public string errorMsg { get; set; }
+ [DisplayName("閿欒娑堟伅")]
+ public string ErrorMsg { get; set; }
///
/// 鎿嶄綔鏃堕棿
///
- [EpplusTableColumn(Header = "鎿嶄綔鏃堕棿", NumberFormat = "yyyy-MM-dd HH:mm:ss")]
- public DateTime? operTime { get; set; }
+ [DisplayName("鎿嶄綔鏃堕棿")]
+ public DateTime? OperTime { get; set; }
///
/// 鎿嶄綔鐢ㄦ椂
///
+ [DisplayName("鎿嶄綔鐢ㄦ椂")]
public long Elapsed { get; set; }
}
}
diff --git a/ZR.Model/System/SysPost.cs b/ZR.Model/System/SysPost.cs
index 766cbc3f4873b3a19a0afc840d25847147ccc185..8441f26cdac7e2d0e52bb67f5695090095268d49 100644
--- a/ZR.Model/System/SysPost.cs
+++ b/ZR.Model/System/SysPost.cs
@@ -1,5 +1,4 @@
-锘縰sing OfficeOpenXml.Attributes;
-using SqlSugar;
+锘縰sing SqlSugar;
namespace ZR.Model.System
{
@@ -14,9 +13,7 @@ namespace ZR.Model.System
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; }
}
}
diff --git a/ZR.Model/System/SysTasksQz.cs b/ZR.Model/System/SysTasks.cs
similarity index 90%
rename from ZR.Model/System/SysTasksQz.cs
rename to ZR.Model/System/SysTasks.cs
index e2fdd10e26143815929abc8df6240181b625d5f0..150ca66295a7a9908e93d52db9189fd67a0931aa 100644
--- a/ZR.Model/System/SysTasksQz.cs
+++ b/ZR.Model/System/SysTasks.cs
@@ -1,9 +1,7 @@
锘縰sing Newtonsoft.Json;
using SqlSugar;
using System;
-using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
-using System.Text;
namespace ZR.Model.System
{
@@ -12,18 +10,19 @@ namespace ZR.Model.System
///
[SugarTable("sys_tasks")]
[Tenant("0")]
- public class SysTasksQz
+ public class SysTasks
{
- public SysTasksQz()
+ public SysTasks()
{
}
///
- /// 鎻忚堪 : UID
+ /// 鎻忚堪 : 浠诲姟id
/// 绌哄 : False
/// 榛樿 :
///
- [Display(Name = "UID")]
+ [Display(Name = "浠诲姟id")]
+ //[JsonConverter(typeof(ValueToStringConverter))]
[SugarColumn(IsPrimaryKey = true)]
public string ID { get; set; }
@@ -162,8 +161,17 @@ namespace ZR.Model.System
///
public string ApiUrl { get; set; }
///
- /// 浠诲姟绫诲瀷 1绋嬪簭闆2缃戠粶璇锋眰
+ /// 浠诲姟绫诲瀷 1銆佺▼搴忛泦 2銆佺綉缁滆姹 3銆丼QL璇彞
///
public int TaskType { get; set; }
+
+ ///
+ /// SQL璇彞
+ ///
+ public string SqlText { get; set; }
+ ///
+ /// 缃戠粶璇锋眰鏂瑰紡
+ ///
+ public string RequestMethod { get; set; }
}
}
diff --git a/ZR.Model/System/SysTasksLog.cs b/ZR.Model/System/SysTasksLog.cs
index a540d06c0c2e972857c2cc529fbc665896a877af..666f1ea96e0f8f1646a83093c0112438d04c1fe2 100644
--- a/ZR.Model/System/SysTasksLog.cs
+++ b/ZR.Model/System/SysTasksLog.cs
@@ -1,8 +1,5 @@
-锘縰sing OfficeOpenXml.Attributes;
-using SqlSugar;
+锘縰sing SqlSugar;
using System;
-using System.Collections.Generic;
-using System.Text;
namespace ZR.Model.System
{
@@ -41,7 +38,9 @@ namespace ZR.Model.System
///
public string InvokeTarget { get; set; }
- [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ ///
+ /// 鍒涘缓鏃堕棿
+ ///
public DateTime CreateTime { get; set; }
///
/// 鎵ц鐢ㄦ椂锛屾绉
diff --git a/ZR.Model/System/SysUser.cs b/ZR.Model/System/SysUser.cs
index 749a8ddefc359d16836a7e1094b61f364ec983e1..1520c289f37c9d89f012666256877c0da9b7aa09 100644
--- a/ZR.Model/System/SysUser.cs
+++ b/ZR.Model/System/SysUser.cs
@@ -1,5 +1,5 @@
-锘縰sing Newtonsoft.Json;
-using OfficeOpenXml.Attributes;
+锘縰sing MiniExcelLibs.Attributes;
+using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
@@ -28,12 +28,12 @@ namespace ZR.Model.System
//[JsonProperty(propertyName: "userType")]
//public string User_type { get; set; } = "";
[SugarColumn(IsOnlyIgnoreInsert = true)]
- [EpplusIgnore]
+ [ExcelIgnore]
public string Avatar { get; set; }
public string Email { get; set; }
[JsonIgnore]
- [EpplusIgnore]
+ [ExcelIgnore]
public string Password { get; set; }
///
/// 鎵嬫満鍙
@@ -47,7 +47,7 @@ namespace ZR.Model.System
///
/// 甯愬彿鐘舵侊紙0姝e父 1鍋滅敤锛
///
- [EpplusIgnore]
+ [ExcelIgnore]
public string Status { get; set; }
///
@@ -66,7 +66,7 @@ namespace ZR.Model.System
/// 鏈鍚庣櫥褰曟椂闂
///
[SugarColumn(IsOnlyIgnoreInsert = true)]
- [EpplusTableColumn(NumberFormat = "yyyy-MM-dd HH:mm:ss")]
+ [ExcelColumn(Name = "鐧诲綍鏃ユ湡", Format = "yyyy-MM-dd HH:mm:ss")]
public DateTime LoginDate { get; set; }
///
@@ -95,17 +95,17 @@ namespace ZR.Model.System
/// 瑙掕壊id闆嗗悎
///
[SugarColumn(IsIgnore = true)]
- [EpplusIgnore]
+ [ExcelIgnore]
public long[] RoleIds { get; set; }
///
/// 宀椾綅闆嗗悎
///
[SugarColumn(IsIgnore = true)]
- [EpplusIgnore]
+ [ExcelIgnore]
public int[] PostIds { get; set; }
[SugarColumn(IsIgnore = true)]
- [EpplusIgnore]
+ [ExcelIgnore]
public List Roles { get; set; }
[SugarColumn(IsIgnore = true)]
public string WelcomeMessage
diff --git a/ZR.Model/System/UserConstants.cs b/ZR.Model/System/UserConstants.cs
index 87512698ba5939a927d91be92e97ec019007dec5..7914ab2c075199c91333593c8a13c7e694329a4b 100644
--- a/ZR.Model/System/UserConstants.cs
+++ b/ZR.Model/System/UserConstants.cs
@@ -71,5 +71,9 @@ namespace ZR.Model.System
/// https璇锋眰
///
public static string HTTPS = "https://";
+ ///
+ /// www涓诲煙
+ ///
+ public static string WWW = "www.";
}
}
diff --git a/ZR.Model/System/Vo/RouterVo.cs b/ZR.Model/System/Vo/RouterVo.cs
index b48fa2f337c4cd0f327d9c355f874afd6894c544..30f982c5716a7b6721b0c97eac9d8258c3d6d842 100644
--- a/ZR.Model/System/Vo/RouterVo.cs
+++ b/ZR.Model/System/Vo/RouterVo.cs
@@ -52,19 +52,16 @@ namespace ZR.Model.System.Vo
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;
+ if (!string.IsNullOrEmpty(path) && (path.StartsWith(UserConstants.HTTP) || path.StartsWith(UserConstants.HTTPS)))
+ {
+ Link = path;
+ }
}
}
}
diff --git a/ZR.Model/System/Vo/TreeSelectVo.cs b/ZR.Model/System/Vo/TreeSelectVo.cs
index 83409c75d7a876c4cbf908ccfeaa6312170fc1b2..49a6e1b3fc8dc6d0e11f351b0756a7d9dc4d9027 100644
--- a/ZR.Model/System/Vo/TreeSelectVo.cs
+++ b/ZR.Model/System/Vo/TreeSelectVo.cs
@@ -29,7 +29,7 @@ namespace ZR.Model.Vo.System
//menu.getChildren().stream().map(TreeSelect::new).collect(Collectors.toList()); java鍐欐硶
List child = new List();
- foreach (var item in menu.children)
+ foreach (var item in menu.Children)
{
child.Add(new TreeSelectVo(item));
}
diff --git a/ZR.Model/ZR.Model.csproj b/ZR.Model/ZR.Model.csproj
index 46d4eadee02aaec5d9f908cc334cee975582c0ce..1529103a98b08f3722c65f06aa42868784e1a4f5 100644
--- a/ZR.Model/ZR.Model.csproj
+++ b/ZR.Model/ZR.Model.csproj
@@ -5,16 +5,10 @@
-
+
-
+
-
-
-
-
-
-
diff --git a/ZR.Repository/BaseRepository.cs b/ZR.Repository/BaseRepository.cs
index 16abe2701042c2ebec4a0dc803a901b50356c358..a5c3f17be5aa42c4095d403d60fcd640f9f1e34f 100644
--- a/ZR.Repository/BaseRepository.cs
+++ b/ZR.Repository/BaseRepository.cs
@@ -1,4 +1,6 @@
-锘縰sing SqlSugar;
+锘縰sing Infrastructure.Extensions;
+using Mapster;
+using SqlSugar;
using SqlSugar.IOC;
using System;
using System.Collections.Generic;
@@ -63,18 +65,34 @@ namespace ZR.Repository
{
return Context.Updateable(entity);
}
+
+ ///
+ /// 瀹炰綋鏍规嵁涓婚敭鏇存柊
+ ///
+ ///
+ ///
+ ///
public int Update(T entity, bool ignoreNullColumns = false)
{
return Context.Updateable(entity).IgnoreColumns(ignoreNullColumns).ExecuteCommand();
}
+ ///
+ /// 瀹炰綋鏍规嵁涓婚敭鏇存柊鎸囧畾瀛楁
+ /// return Update(user, t => new { t.NickName, }, true);
+ ///
+ ///
+ ///
+ ///
+ ///
public int Update(T entity, Expression> expression, bool ignoreAllNull = false)
{
return Context.Updateable(entity).UpdateColumns(expression).IgnoreColumns(ignoreAllNull).ExecuteCommand();
}
///
- /// 鏍规嵁瀹炰綋绫绘洿鏂版寚瀹氬垪 eg锛歎pdate(dept, it => new { it.Status }, f => depts.Contains(f.DeptId));鍙洿鏂癝tatus鍒楋紝鏉′欢鏄寘鍚
+ /// 鏍规嵁鎸囧畾鏉′欢鏇存柊鎸囧畾鍒 eg锛歎pdate(new SysUser(){ }, it => new { it.Status }, f => f.Userid == 1));
+ /// 鍙洿鏂癝tatus鍒楋紝鏉′欢鏄寘鍚
///
///
///
@@ -203,7 +221,10 @@ namespace ZR.Repository
{
return Context.Deleteable().ExecuteCommand();
}
-
+ public bool Truncate()
+ {
+ return Context.DbMaintenance.TruncateTable();
+ }
#endregion delete
#region query
@@ -346,11 +367,34 @@ namespace ZR.Repository
page.PageSize = parm.PageSize;
page.PageIndex = parm.PageNum;
- page.Result = source.OrderByIF(!string.IsNullOrEmpty(parm.Sort), $"{parm.Sort} {(parm.SortType.Contains("desc") ? "desc" : "asc")}")
+ page.Result = source.OrderByIF(parm.Sort.IsNotEmpty(), $"{parm.Sort.ToSqlFilter()} {(parm.SortType.Contains("desc") ? "desc" : "asc")}")
.ToPageList(parm.PageNum, parm.PageSize, ref total);
page.TotalNum = total;
return page;
}
+ ///
+ /// 杞寚瀹氬疄浣撶被Dto
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static PagedInfo ToPage(this ISugarQueryable source, PagerInfo parm)
+ {
+ var page = new PagedInfo();
+ var total = 0;
+ page.PageSize = parm.PageSize;
+ page.PageIndex = parm.PageNum;
+
+ var result = source
+ .OrderByIF(parm.Sort.IsNotEmpty(), $"{parm.Sort.ToSqlFilter()} {(parm.SortType.Contains("desc") ? "desc" : "asc")}")
+ .ToPageList(parm.PageNum, parm.PageSize, ref total);
+
+ page.TotalNum = total;
+ page.Result = result.Adapt>();
+ return page;
+ }
}
}
diff --git a/ZR.Repository/IBaseRepository.cs b/ZR.Repository/IBaseRepository.cs
index 6604d2ae887bf44df4973a38d23bceb871219bc4..25aa897094b881d8f4301e75063f65b4ba4da461 100644
--- a/ZR.Repository/IBaseRepository.cs
+++ b/ZR.Repository/IBaseRepository.cs
@@ -50,6 +50,7 @@ namespace ZR.Repository
int Delete(object[] obj);
int Delete(object id);
int DeleteTable();
+ bool Truncate();
#endregion delete
diff --git a/ZR.Repository/System/ArticleRepository.cs b/ZR.Repository/System/ArticleRepository.cs
deleted file mode 100644
index 718735ec32909b6431c68d5a3e76cb39bb776a01..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/ArticleRepository.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZR.Model.System.Dto;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 鏂囩珷绠$悊
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class ArticleRepository : BaseRepository
- {
-
- }
-
- ///
- /// 鏂囩珷鐩綍
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class ArticleCategoryRepository : BaseRepository
- {
-
- }
-}
diff --git a/ZR.Repository/System/CommonLangRepository.cs b/ZR.Repository/System/CommonLangRepository.cs
deleted file mode 100644
index 9ef5eb1392783b7d1aebf2ec7b09ed5681816d72..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/CommonLangRepository.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using Infrastructure.Attribute;
-using ZR.Repository.System;
-using ZR.Model.Models;
-
-namespace ZR.Repository
-{
- ///
- /// 澶氳瑷閰嶇疆浠撳偍
- ///
- /// @author zr
- /// @date 2022-05-06
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class CommonLangRepository : BaseRepository
- {
- #region 涓氬姟閫昏緫浠g爜
- #endregion
- }
-}
\ No newline at end of file
diff --git a/ZR.Repository/System/GenTableRepository.cs b/ZR.Repository/System/GenTableRepository.cs
deleted file mode 100644
index 018d3d6efc29163c092ee3a5491c6a49ca77117e..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/GenTableRepository.cs
+++ /dev/null
@@ -1,91 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZR.Model.System.Generate;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class GenTableRepository : BaseRepository
- {
-
- }
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class GenTableColumnRepository : BaseRepository
- {
- ///
- /// 鏍规嵁琛╥d鎵归噺鍒犻櫎琛ㄥ瓧娈
- ///
- ///
- ///
- public int DeleteGenTableColumn(long[] tableId)
- {
- return Context.Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
- }
-
- ///
- /// 鏍规嵁琛ㄥ悕鍒犻櫎瀛楁
- ///
- ///
- ///
- public int DeleteGenTableColumnByTableName(string tableName)
- {
- return Context.Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
- }
-
- ///
- /// 鑾峰彇琛ㄦ墍鏈夊瓧娈
- ///
- ///
- ///
- public List GenTableColumns(long tableId)
- {
- return Context.Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
- }
-
- ///
- /// 鎻掑叆琛ㄥ瓧娈
- ///
- ///
- ///
- public int InsertGenTableColumn(List tableColumn)
- {
- return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
- }
-
- ///
- /// 鎵归噺鏇存柊琛ㄥ瓧娈
- ///
- ///
- ///
- public int UpdateGenTableColumn(List tableColumn)
- {
- return Context.Updateable(tableColumn)
- .WhereColumns(it => new { it.ColumnId, it.TableId})
- .UpdateColumns(it => new
- {
- it.ColumnComment,
- it.CsharpField,
- it.CsharpType,
- it.IsQuery,
- it.IsEdit,
- it.IsInsert,
- it.IsList,
- it.QueryType,
- it.HtmlType,
- it.IsRequired,
- it.Sort,
- it.Update_time,
- it.DictType,
- it.Update_by,
- it.Remark,
- it.IsSort
- })
- .ExecuteCommand();
- }
- }
-}
diff --git a/ZR.Repository/System/SysConfigRepository.cs b/ZR.Repository/System/SysConfigRepository.cs
deleted file mode 100644
index 63ae19b3f694d2f36818df1c2ea7b8353ae65b39..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysConfigRepository.cs
+++ /dev/null
@@ -1,19 +0,0 @@
-using System;
-using Infrastructure.Attribute;
-using ZR.Model.System;
-
-namespace ZR.Repository
-{
- ///
- /// 鍙傛暟閰嶇疆浠撳偍鎺ュ彛鐨勫疄鐜
- ///
- /// @author zhaorui
- /// @date 2021-09-29
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysConfigRepository : BaseRepository
- {
- #region 涓氬姟閫昏緫浠g爜
- #endregion
- }
-}
\ No newline at end of file
diff --git a/ZR.Repository/System/SysDictDataRepository.cs b/ZR.Repository/System/SysDictDataRepository.cs
deleted file mode 100644
index 294e655ba1fc0fc16718ce38eea6ab2837e17fd8..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysDictDataRepository.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Model;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using ZR.Model;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 瀛楀吀鏁版嵁
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysDictDataRepository : BaseRepository
- {
- ///
- /// 瀛楀吀绫诲瀷鏁版嵁鎼滅储
- ///
- ///
- ///
- ///
- public PagedInfo SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
- {
- var exp = Expressionable.Create();
- exp.AndIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel));
- exp.AndIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status);
- exp.AndIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType);
- return GetPages(exp.ToExpression(), pagerInfo);
- }
-
- ///
- /// 鏍规嵁瀛楀吀绫诲瀷鏌ヨ
- ///
- ///
- ///
- public List SelectDictDataByType(string dictType)
- {
- return Context.Queryable().Where(f => f.Status == "0" && f.DictType == dictType)
- .OrderBy(it => it.DictSort)
- .ToList();
- }
-
- ///
- /// 鏍规嵁瀛楀吀绫诲瀷鏌ヨ
- ///
- ///
- ///
- public List SelectDictDataByTypes(string[] dictTypes)
- {
- return Context.Queryable().Where(f => f.Status == "0" && dictTypes.Contains(f.DictType))
- .OrderBy(it => it.DictSort)
- .ToList();
- }
- ///
- /// 鏂板淇濆瓨瀛楀吀鏁版嵁淇℃伅
- ///
- ///
- ///
- public long InsertDictData(SysDictData dict)
- {
- var result = Context.Insertable(dict).ExecuteReturnBigIdentity();
- return result;
- }
-
- ///
- /// 淇敼鏁版嵁
- ///
- ///
- ///
- public long UpdateDictData(SysDictData dict)
- {
- return Context.Updateable()
- .SetColumns(t => new SysDictData()
- {
- Remark = dict.Remark,
- Update_time = DateTime.Now,
- DictSort = dict.DictSort,
- DictLabel = dict.DictLabel,
- DictValue = dict.DictValue,
- Status = dict.Status,
- CssClass = dict.CssClass,
- ListClass = dict.ListClass
- })
- .Where(f => f.DictCode == dict.DictCode).ExecuteCommand();
- }
-
- ///
- /// 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅
- ///
- ///
- ///
- public int DeleteDictDataByIds(long[] dictCodes)
- {
- return Delete(dictCodes);
- }
-
- ///
- /// 鍚屾淇敼瀛楀吀绫诲瀷
- ///
- /// 鏃у瓧鍏哥被鍨
- /// 鏂板瓧鍏哥被鍨
- ///
- public int UpdateDictDataType(string old_dictType, string new_dictType)
- {
- //鍙洿鏂癉ictType瀛楁鏍规嵁where鏉′欢
- return Context.Updateable()
- .SetColumns(t => new SysDictData() { DictType = new_dictType })
- .Where(f => f.DictType == old_dictType)
- .ExecuteCommand();
- }
- }
-}
diff --git a/ZR.Repository/System/SysDictRepository.cs b/ZR.Repository/System/SysDictRepository.cs
deleted file mode 100644
index a315c7cffa434636f19b409d630857c3e3d55453..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysDictRepository.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using SqlSugar;
-using System.Collections.Generic;
-using ZR.Model;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 瀛楀吀
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysDictRepository : BaseRepository
- {
- public List GetAll()
- {
- return Context.Queryable().ToList();
- }
-
- ///
- /// 鏌ヨ瀛楁绫诲瀷鍒楄〃
- ///
- /// 瀹炰綋妯″瀷
- ///
- public PagedInfo SelectDictTypeList(SysDictType dictType, PagerInfo pager)
- {
- var exp = Expressionable.Create();
- exp.AndIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName));
- exp.AndIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status);
- exp.AndIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType.Contains(dictType.DictType));
- exp.AndIF(!string.IsNullOrEmpty(dictType.Type), it => it.Type.Equals(dictType.Type));
-
- return GetPages(exp.ToExpression(), pager, f => f.DictId, OrderByType.Desc);
- }
-
- ///
- /// 鎵归噺鍒犻櫎
- ///
- ///
- ///
- public int DeleteDictTypeByIds(long[] id)
- {
- return Context.Deleteable().In(id).ExecuteCommand();
- }
-
- ///
- /// 淇敼
- ///
- ///
- ///
- public int UpdateDictType(SysDictType dictType)
- {
- return Context.Updateable(dictType).IgnoreColumns(it => new { dictType.Create_by }).ExecuteCommand();
- }
- }
-}
diff --git a/ZR.Repository/System/SysFileRepository.cs b/ZR.Repository/System/SysFileRepository.cs
deleted file mode 100644
index 867dd5fee3757c7448b28395bcec7ea6ba4ab72e..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysFileRepository.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using System;
-using Infrastructure.Attribute;
-using ZR.Repository.System;
-using ZR.Model.Models;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 鏂囦欢瀛樺偍浠撳偍
- ///
- /// @author zz
- /// @date 2021-12-15
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysFileRepository : BaseRepository
- {
- #region 涓氬姟閫昏緫浠g爜
- #endregion
- }
-}
\ No newline at end of file
diff --git a/ZR.Repository/System/SysLogininfoRepository.cs b/ZR.Repository/System/SysLogininfoRepository.cs
deleted file mode 100644
index 55376644feb50b7fdb263f42691ab404cf17047f..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysLogininfoRepository.cs
+++ /dev/null
@@ -1,89 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Extensions;
-using System.Collections.Generic;
-using ZR.Model;
-using ZR.Model.System.Dto;
-using ZR.Model.System;
-using SqlSugar;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysLogininfoRepository : BaseRepository
- {
- ///
- /// 鏌ヨ鐧诲綍鏃ュ織
- ///
- ///
- ///
- ///
- public PagedInfo GetLoginLog(SysLogininfor logininfoDto, PagerInfo pager)
- {
- var exp = Expressionable.Create();
- exp.And(it => it.loginTime >= logininfoDto.BeginTime && it.loginTime <= logininfoDto.EndTime);
- exp.AndIF(logininfoDto.ipaddr.IfNotEmpty(), f => f.ipaddr == logininfoDto.ipaddr);
- exp.AndIF(logininfoDto.userName.IfNotEmpty(), f => f.userName.Contains(logininfoDto.userName));
- exp.AndIF(logininfoDto.status.IfNotEmpty(), f => f.status == logininfoDto.status);
- var query = Context.Queryable()
- .Where(exp.ToExpression())
- .OrderBy(it => it.infoId, OrderByType.Desc);
-
- return query.ToPage(pager);
- }
-
- ///
- /// 鐧诲綍鏃ュ織璁板綍
- ///
- ///
- ///
- public void AddLoginInfo(SysLogininfor sysLogininfor)
- {
- int result = Context.Insertable(sysLogininfor)
- .ExecuteReturnIdentity();
- }
-
- ///
- /// 娓呯┖鐧诲綍鏃ュ織
- ///
- public void TruncateLogininfo()
- {
- string sql = "truncate table sys_logininfor";
-
- Context.Ado.ExecuteCommand(sql);
- }
-
- ///
- /// 鍒犻櫎鐧诲綍鏃ュ織
- ///
- ///
- ///
- public int DeleteLogininforByIds(long[] ids)
- {
- return Context.Deleteable().In(ids).ExecuteCommand();
- }
-
- ///
- /// 鐧诲綍
- ///
- /// 鐧诲綍瀹炰綋
- ///
- public SysUser Login(LoginBodyDto user)
- {
- return Context.Queryable().First(it => it.UserName == user.Username && it.Password == user.Password);
- }
-
- ///
- /// 淇敼鐧诲綍淇℃伅
- ///
- ///
- ///
- ///
- public void UpdateLoginInfo(LoginBodyDto user, long userId)
- {
- var db = Context;
- db.Updateable(new SysUser() { LoginIP = user.LoginIP, LoginDate = db.GetDate(), UserId = userId })
- .UpdateColumns(it => new { it.LoginIP, it.LoginDate })
- .ExecuteCommand();
- }
- }
-}
diff --git a/ZR.Repository/System/SysMenuRepository.cs b/ZR.Repository/System/SysMenuRepository.cs
deleted file mode 100644
index d3d09bad1a5efa381b36a416c144d5afc938fb91..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysMenuRepository.cs
+++ /dev/null
@@ -1,198 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using ZR.Model.System.Dto;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 绯荤粺鑿滃崟
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysMenuRepository : BaseRepository
- {
- ///
- /// 鑾峰彇鎵鏈夎彍鍗曪紙鑿滃崟绠$悊锛
- ///
- ///
- public List SelectTreeMenuList(MenuQueryDto menu)
- {
- return Context.Queryable()
- .WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
- .WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
- .WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
- .WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), it => menu.MenuTypeIdArr.Contains(it.menuType))
- .OrderBy(it => new { it.parentId, it.orderNum })
- .ToTree(it => it.children, it => it.parentId, 0);
- }
-
- ///
- /// 鏍规嵁鐢ㄦ埛鏌ヨ绯荤粺鑿滃崟鍒楄〃
- ///
- ///
- /// 鐢ㄦ埛瑙掕壊闆嗗悎
- ///
- public List SelectTreeMenuListByRoles(MenuQueryDto menu, List roles)
- {
- var roleMenus = Context.Queryable()
- .Where(r => roles.Contains(r.Role_id))
- .Select(f => f.Menu_id).Distinct().ToList();
-
- return Context.Queryable()
- .Where(c => roleMenus.Contains(c.MenuId))
- .WhereIF(!string.IsNullOrEmpty(menu.MenuName), (c) => c.MenuName.Contains(menu.MenuName))
- .WhereIF(!string.IsNullOrEmpty(menu.Visible), (c) => c.visible == menu.Visible)
- .WhereIF(!string.IsNullOrEmpty(menu.Status), (c) => c.status == menu.Status)
- .WhereIF(!string.IsNullOrEmpty(menu.MenuTypeIds), c => menu.MenuTypeIdArr.Contains(c.menuType))
- .OrderBy((c) => new { c.parentId, c.orderNum })
- .Select(c => c)
- .ToTree(it => it.children, it => it.parentId, 0);
- }
-
- ///
- /// 鑾峰彇鎵鏈夎彍鍗
- ///
- ///
- public List SelectMenuList(MenuQueryDto menu)
- {
- return Context.Queryable()
- .WhereIF(!string.IsNullOrEmpty(menu.MenuName), it => it.MenuName.Contains(menu.MenuName))
- .WhereIF(!string.IsNullOrEmpty(menu.Visible), it => it.visible == menu.Visible)
- .WhereIF(!string.IsNullOrEmpty(menu.Status), it => it.status == menu.Status)
- .WhereIF(menu.ParentId != null, it => it.parentId == menu.ParentId)
- .OrderBy(it => new { it.parentId, it.orderNum })
- .ToList();
- }
-
- ///
- /// 鏍规嵁鐢ㄦ埛鏌ヨ绯荤粺鑿滃崟鍒楄〃
- ///
- ///
- /// 鐢ㄦ埛瑙掕壊闆嗗悎
- ///
- public List SelectMenuListByRoles(MenuQueryDto sysMenu, List roles)
- {
- var roleMenus = Context.Queryable()
- .Where(r => roles.Contains(r.Role_id));
-
- return Context.Queryable()
- .InnerJoin(roleMenus, (c, j) => c.MenuId == j.Menu_id)
- .Where((c, j) => c.status == "0")
- .WhereIF(!string.IsNullOrEmpty(sysMenu.MenuName), (c, j) => c.MenuName.Contains(sysMenu.MenuName))
- .WhereIF(!string.IsNullOrEmpty(sysMenu.Visible), (c, j) => c.visible == sysMenu.Visible)
- .OrderBy((c, j) => new { c.parentId, c.orderNum })
- .Select(c => c)
- .ToList();
- }
-
- ///
- /// 鑾峰彇鑿滃崟璇︽儏
- ///
- ///
- ///
- public SysMenu SelectMenuById(int menuId)
- {
- return Context.Queryable().Where(it => it.MenuId == menuId).Single();
- }
-
- ///
- /// 娣诲姞鑿滃崟
- ///
- ///
- ///
- public int AddMenu(SysMenu menu)
- {
- var Db = Context;
- menu.Create_time = Db.GetDate();
- menu.MenuId = Db.Insertable(menu).ExecuteReturnIdentity();
- return 1;
- }
-
- ///
- /// 缂栬緫鑿滃崟
- ///
- ///
- ///
- public int EditMenu(SysMenu menu)
- {
- return Context.Updateable(menu).ExecuteCommand();
- }
-
- ///
- /// 鍒犻櫎鑿滃崟
- ///
- ///
- ///
- public int DeleteMenuById(int menuId)
- {
- return Context.Deleteable().Where(it => it.MenuId == menuId).ExecuteCommand();
- }
-
- ///
- /// 鑿滃崟鎺掑簭
- ///
- /// 鑿滃崟Dto
- ///
- public int ChangeSortMenu(MenuDto menuDto)
- {
- var result = Context.Updateable(new SysMenu() { MenuId = menuDto.MenuId, orderNum = menuDto.orderNum })
- .UpdateColumns(it => new { it.orderNum }).ExecuteCommand();
- return result;
- }
-
- ///
- /// 鏌ヨ鑿滃崟鏉冮檺
- ///
- ///
- ///
- public List SelectMenuPermsByUserId(long userId)
- {
- return Context.Queryable((m, rm, ur, r) => new JoinQueryInfos(
- JoinType.Left, m.MenuId == rm.Menu_id,
- JoinType.Left, rm.Role_id == ur.RoleId,
- JoinType.Left, ur.RoleId == r.RoleId
- ))
- //.Distinct()
- .Where((m, rm, ur, r) => m.status == "0" && r.Status == "0" && ur.UserId == userId)
- .Select((m, rm, ur, r) => m).ToList();
- }
-
- ///
- /// 鏍¢獙鑿滃崟鍚嶇О鏄惁鍞竴
- ///
- ///
- ///
- public SysMenu CheckMenuNameUnique(SysMenu menu)
- {
- return Context.Queryable()
- .Where(it => it.MenuName == menu.MenuName && it.parentId == menu.parentId).Single();
- }
-
- ///
- /// 鏄惁瀛樺湪鑿滃崟瀛愯妭鐐
- ///
- ///
- ///
- public int HasChildByMenuId(long menuId)
- {
- return Context.Queryable().Where(it => it.parentId == menuId).Count();
- }
-
- #region RoleMenu
-
- ///
- /// 鏌ヨ鑿滃崟浣跨敤鏁伴噺
- ///
- ///
- ///
- public int CheckMenuExistRole(long menuId)
- {
- return Context.Queryable().Where(it => it.Menu_id == menuId).Count();
- }
-
- #endregion
- }
-}
diff --git a/ZR.Repository/System/SysNoticeRepository.cs b/ZR.Repository/System/SysNoticeRepository.cs
deleted file mode 100644
index d6ccd5c63082e57409d7074799c90b52858fc66c..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysNoticeRepository.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System;
-using Infrastructure.Attribute;
-using ZR.Repository.System;
-using ZR.Model.Models;
-
-namespace ZR.Repository.System
-{
- ///
- /// 閫氱煡鍏憡琛ㄤ粨鍌
- ///
- /// @author zr
- /// @date 2021-12-15
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysNoticeRepository : BaseRepository
- {
- #region 涓氬姟閫昏緫浠g爜
- #endregion
- }
-}
\ No newline at end of file
diff --git a/ZR.Repository/System/SysOperLogRepository.cs b/ZR.Repository/System/SysOperLogRepository.cs
deleted file mode 100644
index 3050170aabf208e02461f3a9988d8553a0b97954..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysOperLogRepository.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Extensions;
-using System.Collections.Generic;
-using ZR.Model;
-using ZR.Model.System.Dto;
-using ZR.Model.System;
-using SqlSugar;
-using Infrastructure.Model;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysOperLogRepository : BaseRepository
- {
- ///
- /// 鏌ヨ鎿嶄綔鏃ュ織
- ///
- ///
- /// 鍒嗛〉鏁版嵁
- ///
- public PagedInfo GetSysOperLog(SysOperLogDto sysOper, PagerInfo pagerInfo)
- {
- var exp = Expressionable.Create();
- exp.And(it => it.operTime >= sysOper.BeginTime && it.operTime <= sysOper.EndTime);
- exp.AndIF(sysOper.Title.IfNotEmpty(), it => it.title.Contains(sysOper.Title));
- exp.AndIF(sysOper.operName.IfNotEmpty(), it => it.operName.Contains(sysOper.operName));
- exp.AndIF(sysOper.BusinessType != -1, it => it.businessType == sysOper.BusinessType);
- exp.AndIF(sysOper.Status != -1, it => it.status == sysOper.Status);
-
- return GetPages(exp.ToExpression(), pagerInfo, x => x.OperId, OrderByType.Desc);
- }
-
- ///
- /// 娣诲姞鎿嶄綔鏃ュ織
- ///
- ///
- ///
- public void AddSysOperLog(SysOperLog sysOperLog)
- {
- Context.Insertable(sysOperLog).ExecuteCommandAsync();
- }
-
- ///
- /// 娓呯┖鏃ュ織
- ///
- public void ClearOperLog()
- {
- string sql = "truncate table sys_oper_log";
- Context.Ado.ExecuteCommand(sql);
- }
-
- ///
- /// 鍒犻櫎鎿嶄綔鏃ュ織
- ///
- ///
- ///
- public int DeleteOperLogByIds(long[] operIds)
- {
- return Context.Deleteable().In(operIds).ExecuteCommand();
- }
-
- ///
- /// 鏌ヨ鎿嶄綔鏃ュ織
- ///
- ///
- ///
- public SysOperLog SelectOperLogById(long operId)
- {
- return Context.Queryable().InSingle(operId);
- }
- }
-}
diff --git a/ZR.Repository/System/SysPostRepository.cs b/ZR.Repository/System/SysPostRepository.cs
deleted file mode 100644
index cc12aa0edc22e56bb094b45368349544a5321d91..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysPostRepository.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysPostRepository : BaseRepository
- {
- }
-}
diff --git a/ZR.Repository/System/SysRoleRepository.cs b/ZR.Repository/System/SysRoleRepository.cs
deleted file mode 100644
index 3925cb116f3f1afe17b8d02b3116d15935525ef4..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysRoleRepository.cs
+++ /dev/null
@@ -1,211 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Model;
-using SqlSugar;
-using System.Collections.Generic;
-using System.Linq;
-using ZR.Model;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 瑙掕壊鎿嶄綔绫
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysRoleRepository : BaseRepository
- {
- ///
- /// 鏌ヨ鎵鏈夎鑹叉暟鎹
- ///
- ///
- public List SelectRoleList()
- {
- return Context.Queryable()
- .Where(role => role.DelFlag == "0")
- .OrderBy(role => role.RoleSort)
- .ToList();
- }
- ///
- /// 鏍规嵁鏉′欢鍒嗛〉鏌ヨ瑙掕壊鏁版嵁
- ///
- ///
- ///
- ///
- public PagedInfo SelectRoleList(SysRole sysRole, PagerInfo pager)
- {
- var exp = Expressionable.Create();
- exp.And(role => role.DelFlag == "0");
- exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleName), role => role.RoleName.Contains(sysRole.RoleName));
- exp.AndIF(!string.IsNullOrEmpty(sysRole.Status), role => role.Status == sysRole.Status);
- exp.AndIF(!string.IsNullOrEmpty(sysRole.RoleKey), role => role.RoleKey == sysRole.RoleKey);
-
- var query = Context.Queryable()
- .Where(exp.ToExpression())
- .OrderBy(x => x.RoleSort)
- .Select((role) => new SysRole
- {
- RoleId = role.RoleId.SelectAll(),
- UserNum = SqlFunc.Subqueryable().Where(f => f.RoleId == role.RoleId).Count()
- });
-
- return query.ToPage(pager);
- }
-
- ///
- /// 鏍规嵁鐢ㄦ埛鏌ヨ
- ///
- ///
- ///
- public List SelectRolePermissionByUserId(long userId)
- {
- return Context.Queryable()
- .Where(role => role.DelFlag == "0")
- .Where(it => SqlFunc.Subqueryable().Where(s => s.UserId == userId).Any())
- .OrderBy(role => role.RoleSort)
- .ToList();
- }
-
- ///
- /// 閫氳繃瑙掕壊ID鏌ヨ瑙掕壊
- ///
- /// 瑙掕壊缂栧彿
- ///
- public SysRole SelectRoleById(long roleId)
- {
- return Context.Queryable().InSingle(roleId);
- }
-
- ///
- /// 閫氳繃瑙掕壊ID鍒犻櫎瑙掕壊
- ///
- ///
- ///
- public int DeleteRoleByRoleIds(long[] roleId)
- {
- return Context.Deleteable().In(roleId).ExecuteCommand();
- }
-
- ///
- /// 鑾峰彇鐢ㄦ埛鎵鏈夎鑹蹭俊鎭
- ///
- ///
- ///
- public List SelectUserRoleListByUserId(long userId)
- {
- return Context.Queryable((ur, r) => new JoinQueryInfos(
- JoinType.Left, ur.RoleId == r.RoleId
- )).Where((ur, r) => ur.UserId == userId)
- .Select((ur, r) => r).ToList();
- }
-
- #region 鐢ㄦ埛瑙掕壊瀵瑰簲鑿滃崟 鐢ㄦ埛N-1瑙掕壊
-
- ///
- /// 鏍规嵁瑙掕壊鑾峰彇鑿滃崟id
- ///
- ///
- ///
- public List SelectRoleMenuByRoleId(long roleId)
- {
- return Context.Queryable().Where(it => it.Role_id == roleId).ToList();
- }
-
- ///
- /// 鏍规嵁鐢ㄦ埛鎵鏈夎鑹茶幏鍙栬彍鍗
- ///
- ///
- ///
- public List SelectRoleMenuByRoleIds(long[] roleIds)
- {
- return Context.Queryable().Where(it => roleIds.Contains(it.Role_id)).ToList();
- }
-
- ///
- /// 鎵归噺鎻掑叆鐢ㄦ埛鑿滃崟
- ///
- ///
- ///
- public int AddRoleMenu(List sysRoleMenus)
- {
- return Context.Insertable(sysRoleMenus).ExecuteCommand();
- }
-
- ///
- /// 鍒犻櫎瑙掕壊涓庤彍鍗曞叧鑱
- ///
- ///
- ///
- public int DeleteRoleMenuByRoleId(long roleId)
- {
- return Context.Deleteable().Where(it => it.Role_id == roleId).ExecuteCommand();
- }
-
- #endregion
-
- ///
- /// 娣诲姞瑙掕壊
- ///
- ///
- ///
- public long InsertRole(SysRole sysRole)
- {
- sysRole.Create_time = Context.GetDate();
- return Context.Insertable(sysRole).ExecuteReturnBigIdentity();
- }
-
- ///
- /// 淇敼鐢ㄦ埛瑙掕壊
- ///
- ///
- ///
- public int UpdateSysRole(SysRole sysRole)
- {
- var db = Context;
- sysRole.Update_time = db.GetDate();
-
- return db.Updateable()
- .SetColumns(it => it.Update_time == sysRole.Update_time)
- .SetColumns(it => it.DataScope == sysRole.DataScope)
- .SetColumns(it => it.Remark == sysRole.Remark)
- .SetColumns(it => it.Update_by == sysRole.Update_by)
- //.SetColumns(it => it.MenuCheckStrictly == sysRole.MenuCheckStrictly)
- .SetColumns(it => it.DeptCheckStrictly == sysRole.DeptCheckStrictly)
- .SetColumnsIF(!string.IsNullOrEmpty(sysRole.RoleName), it => it.RoleName == sysRole.RoleName)
- .SetColumnsIF(!string.IsNullOrEmpty(sysRole.RoleKey), it => it.RoleKey == sysRole.RoleKey)
- .SetColumnsIF(sysRole.RoleSort >= 0, it => it.RoleSort == sysRole.RoleSort)
- .Where(it => it.RoleId == sysRole.RoleId)
- .ExecuteCommand();
- }
-
- ///
- /// 鏇存敼瑙掕壊鏉冮檺鐘舵
- ///
- ///
- ///
- ///
- public int UpdateRoleStatus(SysRole role)
- {
- return Context.Updateable(role).UpdateColumns(t => new { t.Status }).ExecuteCommand();
- }
-
- ///
- /// 妫鏌ヨ鑹叉潈闄愭槸鍚﹀瓨鍦
- ///
- /// 瑙掕壊鏉冮檺
- ///
- public SysRole CheckRoleKeyUnique(string roleKey)
- {
- return Context.Queryable().Where(it => it.RoleKey == roleKey).Single();
- }
-
- ///
- /// 鏍¢獙瑙掕壊鍚嶇О鏄惁鍞竴
- ///
- /// 瑙掕壊鍚嶇О
- ///
- public SysRole CheckRoleNameUnique(string roleName)
- {
- return Context.Queryable().Where(it => it.RoleName == roleName).Single();
- }
- }
-}
diff --git a/ZR.Repository/System/SysTasksQzRepository.cs b/ZR.Repository/System/SysTasksQzRepository.cs
deleted file mode 100644
index a231073182782a7bec34acd2ffd25bf9a0d3801c..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysTasksQzRepository.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysTasksQzRepository: BaseRepository
- {
- }
-}
diff --git a/ZR.Repository/System/SysUserPostRepository.cs b/ZR.Repository/System/SysUserPostRepository.cs
deleted file mode 100644
index af85023ada80fead67666d34b3e4a79fc5483d54..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysUserPostRepository.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using SqlSugar;
-using System.Collections.Generic;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 鐢ㄦ埛宀椾綅
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysUserPostRepository : BaseRepository
- {
- ///
- /// 鑾峰彇鐢ㄦ埛宀椾綅
- ///
- ///
- ///
- public List SelectPostsByUserId(long userId)
- {
- return Context.Queryable((p, up) => new JoinQueryInfos(
- JoinType.Left, up.PostId == p.PostId
- )).Where((p, up) => up.UserId == userId)
- .Select().ToList();
- }
- }
-}
diff --git a/ZR.Repository/System/SysUserRepository.cs b/ZR.Repository/System/SysUserRepository.cs
deleted file mode 100644
index 6b9fa61519e6fe94a20dd22f68697da000b80bdf..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysUserRepository.cs
+++ /dev/null
@@ -1,165 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Extensions;
-using SqlSugar;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Linq;
-using ZR.Model;
-using ZR.Model.System;
-
-namespace ZR.Repository.System
-{
- ///
- /// 鐢ㄦ埛绠$悊
- ///
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysUserRepository : BaseRepository
- {
- ///
- /// 鏍规嵁鏉′欢鍒嗛〉鏌ヨ鐢ㄦ埛鍒楄〃
- ///
- ///
- ///
- ///
- public PagedInfo SelectUserList(SysUser user, PagerInfo pager)
- {
- var exp = Expressionable.Create();
- exp.AndIF(!string.IsNullOrEmpty(user.UserName), u => u.UserName.Contains(user.UserName));
- exp.AndIF(!string.IsNullOrEmpty(user.Status), u => u.Status == user.Status);
- exp.AndIF(user.BeginTime != DateTime.MinValue && user.BeginTime != null, u => u.Create_time >= user.BeginTime);
- exp.AndIF(user.EndTime != DateTime.MinValue && user.EndTime != null, u => u.Create_time <= user.EndTime);
- exp.AndIF(!user.Phonenumber.IsEmpty(), u => u.Phonenumber == user.Phonenumber);
- exp.And(u => u.DelFlag == "0");
-
- if (user.DeptId != 0)
- {
- List depts = Context.Queryable().ToList();
-
- var newDepts = depts.FindAll(delegate (SysDept dept)
- {
- string[] parentDeptId = dept.Ancestors.Split(",", StringSplitOptions.RemoveEmptyEntries);
- return parentDeptId.Contains(user.DeptId.ToString());
- });
- string[] deptArr = newDepts.Select(x => x.DeptId.ToString()).ToArray();
- exp.AndIF(user.DeptId != 0, u => u.DeptId == user.DeptId || deptArr.Contains(u.DeptId.ToString()));
- }
- var query = Context.Queryable()
- .LeftJoin((u, dept) => u.DeptId == dept.DeptId)
- .Where(exp.ToExpression())
- .Select((u, dept) => new SysUser
- {
- UserId = u.UserId.SelectAll(),
- DeptName = dept.DeptName,
- });
-
- return query.ToPage(pager);
- }
-
- ///
- /// 閫氳繃鐢ㄦ埛ID鏌ヨ鐢ㄦ埛
- ///
- ///
- ///
- public SysUser SelectUserById(long userId)
- {
- return Context.Queryable().Filter(null, true).Where(f => f.UserId == userId).First();
- }
-
- ///
- /// 鏍¢獙鐢ㄦ埛鍚嶆槸鍚﹀瓨鍦
- ///
- ///
- ///
- public int CheckUserNameUnique(string userName)
- {
- return Context.Queryable().Where(it => it.UserName == userName).Count();
- }
-
- ///
- /// 娣诲姞鐢ㄦ埛
- ///
- ///
- ///
- public int AddUser(SysUser sysUser)
- {
- sysUser.Create_time = DateTime.Now;
- return Context.Insertable(sysUser).ExecuteReturnIdentity();
- }
-
- ///
- /// 閲嶇疆瀵嗙爜
- ///
- ///
- ///
- ///
- public int ResetPwd(long userid, string password)
- {
- return Context.Updateable(new SysUser() { UserId = userid, Password = password })
- .UpdateColumns(it => new { it.Password }).ExecuteCommand();
- }
-
- ///
- /// 鏀瑰彉鐢ㄦ埛鐘舵
- ///
- ///
- ///
- public int ChangeUserStatus(SysUser user)
- {
- return Context.Updateable(user).UpdateColumns(t => new { t.Status })
- .ExecuteCommand();
- }
-
- ///
- /// 鍒犻櫎鐢ㄦ埛(杞垹闄)
- ///
- /// 鐢ㄦ埛id
- ///
- public int DeleteUser(long userid)
- {
- return Context.Updateable(new SysUser() { UserId = userid, DelFlag = "2" })
- .UpdateColumns(t => t.DelFlag)
- .ExecuteCommand();
- }
-
- ///
- /// 淇敼鐢ㄦ埛淇℃伅
- ///
- ///
- ///
- public int UpdateUser(SysUser user)
- {
- return Context.Updateable(user)
- .UpdateColumns(t => new
- {
- t.NickName,
- t.Email,
- t.Phonenumber,
- t.DeptId,
- t.Status,
- t.Sex,
- t.PostIds,
- t.Remark,
- t.Update_by,
- t.Update_time
- })
- .IgnoreColumns(ignoreAllNullColumns: true)//蹇界暐鎵鏈変负null
- .Where(f => f.UserId == user.UserId).ExecuteCommand();
- }
-
- ///
- /// 淇敼鐢ㄦ埛澶村儚
- ///
- ///
- ///
- public int UpdatePhoto(SysUser user)
- {
- return Context.Updateable()
- .SetColumns(t => new SysUser()
- {
- Avatar = user.Avatar
- })
- .Where(f => f.UserId == user.UserId).ExecuteCommand();
- }
- }
-}
diff --git a/ZR.Repository/System/SysUserRoleRepository.cs b/ZR.Repository/System/SysUserRoleRepository.cs
deleted file mode 100644
index ec71d725f4c5820d54b86eef3ae66e2905db7d6a..0000000000000000000000000000000000000000
--- a/ZR.Repository/System/SysUserRoleRepository.cs
+++ /dev/null
@@ -1,112 +0,0 @@
-锘縰sing Infrastructure.Attribute;
-using Infrastructure.Extensions;
-using SqlSugar;
-using System.Collections.Generic;
-using ZR.Model;
-using ZR.Model.System;
-using ZR.Model.System.Dto;
-
-namespace ZR.Repository.System
-{
- [AppService(ServiceLifetime = LifeTime.Transient)]
- public class SysUserRoleRepository : BaseRepository
- {
- ///
- /// 鍒犻櫎鐢ㄦ埛瑙掕壊
- ///
- ///
- ///
- public int DeleteUserRoleByUserId(int userId)
- {
- return Context.Deleteable().Where(it => it.UserId == userId).ExecuteCommand();
- }
-
- ///
- /// 鎵归噺鍒犻櫎瑙掕壊瀵瑰簲鐢ㄦ埛
- ///
- /// 瑙掕壊id
- /// 鐢ㄦ埛id闆嗗悎
- ///
- public int DeleteRoleUserByUserIds(long roleId, List userIds)
- {
- return Context.Deleteable().Where(it => it.RoleId == roleId && userIds.Contains(it.UserId))
- .ExecuteCommand();
- }
-
- ///
- /// 娣诲姞鐢ㄦ埛瑙掕壊
- ///
- ///
- ///
- public int AddUserRole(List sysUsers)
- {
- return Context.Insertable(sysUsers).ExecuteCommand();
- }
-
- ///
- /// 鍒犻櫎瑙掕壊鍏宠仈鐨勭敤鎴
- ///
- ///
- ///
- public int DeleteUserRoleByRoleId(int roleId)
- {
- return Context.Deleteable().In(roleId).ExecuteCommand();
- }
-
- ///
- /// 鑾峰彇瑙掕壊鍒嗛厤涓暟
- ///
- ///
- ///
- public int CountUserRoleByRoleId(long roleId)
- {
- return Context.Queryable().Where(it => it.RoleId == roleId).Count();
- }
-
- ///
- /// 鑾峰彇鐢ㄦ埛鏁版嵁鏍规嵁瑙掕壊id
- ///
- ///
- ///
- public List GetSysUsersByRoleId(long roleId)
- {
- return Context.Queryable((t1, u) => new JoinQueryInfos(
- JoinType.Left, t1.UserId == u.UserId))
- .Where((t1, u) => t1.RoleId == roleId && u.DelFlag == "0")
- .Select((t1, u) => u)
- .ToList();
- }
-
- ///
- /// 鑾峰彇鐢ㄦ埛鏁版嵁鏍规嵁瑙掕壊id
- ///
- ///
- ///
- public PagedInfo GetSysUsersByRoleId(RoleUserQueryDto roleUserQueryDto)
- {
- var query = Context.Queryable((t1, u) => new JoinQueryInfos(
- JoinType.Left, t1.UserId == u.UserId))
- .Where((t1, u) => t1.RoleId == roleUserQueryDto.RoleId && u.DelFlag == "0");
- if (!string.IsNullOrEmpty(roleUserQueryDto.UserName))
- {
- query = query.Where((t1, u) => u.UserName.Contains(roleUserQueryDto.UserName));
- }
- return query.Select((t1, u) => u).ToPage(roleUserQueryDto);
- }
-
- ///
- /// 鑾峰彇灏氭湭鎸囨淳鐨勭敤鎴锋暟鎹牴鎹鑹瞚d
- ///
- ///
- ///
- public PagedInfo GetExcludedSysUsersByRoleId(RoleUserQueryDto roleUserQueryDto)
- {
- var query = Context.Queryable()
- .Where(it => it.DelFlag == "0")
- .Where(it => SqlFunc.Subqueryable().Where(s => s.UserId == it.UserId && s.RoleId == roleUserQueryDto.RoleId).NotAny())
- .WhereIF(roleUserQueryDto.UserName.IsNotEmpty(), it => it.UserName.Contains(roleUserQueryDto.UserName));
-
- return query.ToPage(roleUserQueryDto);
- }
- }
-}
diff --git a/ZR.Repository/ZR.Repository.csproj b/ZR.Repository/ZR.Repository.csproj
index 0cc8a71e2bfcd20e57734c30bb7e95bb0ca861af..70638484727c656be8fd40280dd6f7f41e1b6f9e 100644
--- a/ZR.Repository/ZR.Repository.csproj
+++ b/ZR.Repository/ZR.Repository.csproj
@@ -10,14 +10,11 @@
+
-
-
-
-
-
-
+
+
diff --git a/ZR.Service/System/ArticleCategoryService.cs b/ZR.Service/System/ArticleCategoryService.cs
index 3070624cd1f905c355979d717c98ac2eecb63215..9f33e26ea16e5b5bed8c726867dd1c98a4ec3f10 100644
--- a/ZR.Service/System/ArticleCategoryService.cs
+++ b/ZR.Service/System/ArticleCategoryService.cs
@@ -1,13 +1,10 @@
锘縰sing Infrastructure.Attribute;
using SqlSugar;
-using SqlSugar.IOC;
using System.Collections.Generic;
-using System.Linq;
using ZR.Model;
using ZR.Model.Dto;
using ZR.Model.System;
using ZR.Repository;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -18,12 +15,6 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(IArticleCategoryService), ServiceLifetime = LifeTime.Transient)]
public class ArticleCategoryService : BaseService, IArticleCategoryService
{
- private readonly ArticleCategoryRepository _ArticleCategoryRepository;
- public ArticleCategoryService(ArticleCategoryRepository repository)
- {
- _ArticleCategoryRepository = repository;
- }
-
///
/// 鏌ヨ鏂囩珷鐩綍鍒楄〃
///
@@ -35,8 +26,7 @@ namespace ZR.Service.System
var predicate = Expressionable.Create();
//鎼滅储鏉′欢鏌ヨ璇硶鍙傝僑qlsugar
- var response = _ArticleCategoryRepository
- .Queryable()
+ var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
@@ -55,7 +45,7 @@ namespace ZR.Service.System
//鎼滅储鏉′欢鏌ヨ璇硶鍙傝僑qlsugar
- var response = _ArticleCategoryRepository.Queryable().Where(predicate.ToExpression())
+ var response = Queryable().Where(predicate.ToExpression())
.ToTree(it => it.Children, it => it.ParentId, 0);
return response;
@@ -68,7 +58,7 @@ namespace ZR.Service.System
///
public int AddArticleCategory(ArticleCategory parm)
{
- var response = _ArticleCategoryRepository.Insert(parm, it => new
+ var response = Insert(parm, it => new
{
it.Name,
it.CreateTime,
diff --git a/ZR.Service/System/ArticleService.cs b/ZR.Service/System/ArticleService.cs
index 695676a83a8255903f98b97cbe26711ba75354bb..7948e3b9397dddcff9ed8f279c617617d2105eac 100644
--- a/ZR.Service/System/ArticleService.cs
+++ b/ZR.Service/System/ArticleService.cs
@@ -1,7 +1,5 @@
锘縰sing Infrastructure.Attribute;
-using SqlSugar;
using ZR.Model.System;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
diff --git a/ZR.Service/System/CommonLangService.cs b/ZR.Service/System/CommonLangService.cs
index 4abe031131220fcde92734effb8b2f9b4e6235bc..7e56122259995f92ed07851f7a489c94ba84dfc6 100644
--- a/ZR.Service/System/CommonLangService.cs
+++ b/ZR.Service/System/CommonLangService.cs
@@ -20,12 +20,6 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ICommonLangService), ServiceLifetime = LifeTime.Transient)]
public class CommonLangService : BaseService, ICommonLangService
{
- private readonly CommonLangRepository _CommonLangrepository;
- public CommonLangService(CommonLangRepository repository)
- {
- _CommonLangrepository = repository;
- }
-
#region 涓氬姟閫昏緫浠g爜
///
@@ -42,8 +36,7 @@ namespace ZR.Service.System
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
- var response = _CommonLangrepository
- .Queryable()
+ var response = Queryable()
.Where(predicate.ToExpression())
.ToPage(parm);
return response;
@@ -63,8 +56,7 @@ namespace ZR.Service.System
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
predicate = predicate.AndIF(parm.BeginAddtime != null, it => it.Addtime >= parm.BeginAddtime && it.Addtime <= parm.EndAddtime);
- var response = _CommonLangrepository
- .Queryable()
+ var response = Queryable()
.Where(predicate.ToExpression())
.ToPivotList(it => it.LangCode, it => it.LangKey, it => it.Max(f => f.LangName));
return response;
@@ -78,8 +70,7 @@ namespace ZR.Service.System
//鎼滅储鏉′欢鏌ヨ璇硶鍙傝僑qlsugar
predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangCode), it => it.LangCode == parm.LangCode);
//predicate = predicate.AndIF(!string.IsNullOrEmpty(parm.LangKey), it => it.LangKey.Contains(parm.LangKey));
- var response = _CommonLangrepository
- .Queryable()
+ var response = Queryable()
.Where(predicate.ToExpression())
.ToList();
return response;
@@ -98,7 +89,7 @@ namespace ZR.Service.System
LangName = item.LangName,
});
}
- var storage = _CommonLangrepository.Storageable(langs)
+ var storage = Storageable(langs)
.WhereColumns(it => new { it.LangKey, it.LangCode })
.ToStorage();
diff --git a/ZR.Service/System/GenTableService.cs b/ZR.Service/System/GenTableService.cs
index 6d90d278cea412e706b423e21b73922dd835c27c..b98b6cc327bf7e8504c62f2795813492702446c5 100644
--- a/ZR.Service/System/GenTableService.cs
+++ b/ZR.Service/System/GenTableService.cs
@@ -1,14 +1,11 @@
锘縰sing Infrastructure.Attribute;
using Infrastructure.Extensions;
-using Newtonsoft.Json;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
-using ZR.Common;
using ZR.Model;
using ZR.Model.System.Generate;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -19,12 +16,10 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(IGenTableService), ServiceLifetime = LifeTime.Transient)]
public class GenTableService : BaseService, IGenTableService
{
- private GenTableRepository GenTableRepository;
private IGenTableColumnService GenTableColumnService;
- public GenTableService(IGenTableColumnService genTableColumnService, GenTableRepository genTableRepository)
+ public GenTableService(IGenTableColumnService genTableColumnService)
{
GenTableColumnService = genTableColumnService;
- GenTableRepository = genTableRepository;
}
///
@@ -34,7 +29,7 @@ namespace ZR.Service.System
///
public int DeleteGenTableByIds(long[] tableIds)
{
- GenTableRepository.Delete(f => tableIds.Contains(f.TableId));
+ Delete(f => tableIds.Contains(f.TableId));
return GenTableColumnService.DeleteGenTableColumn(tableIds);
}
@@ -45,7 +40,7 @@ namespace ZR.Service.System
///
public int DeleteGenTableByTbName(string tableName)
{
- return GenTableRepository.Delete(f => f.TableName == tableName) ? 1 : 0;
+ return Delete(f => f.TableName == tableName) ? 1 : 0;
}
///
@@ -55,10 +50,10 @@ namespace ZR.Service.System
///
public GenTable GetGenTableInfo(long tableId)
{
- var info = GenTableRepository.GetId(tableId);
+ var info = GetId(tableId);
if (info != null && !info.SubTableName.IsEmpty())
{
- info.SubTable = GenTableRepository.Queryable().Where(f => f.TableName == info.SubTableName).First();
+ info.SubTable = Queryable().Where(f => f.TableName == info.SubTableName).First();
}
return info;
}
@@ -69,7 +64,7 @@ namespace ZR.Service.System
///
public List GetGenTableAll()
{
- return GenTableRepository.GetAll();
+ return GetAll();
}
///
@@ -83,7 +78,7 @@ namespace ZR.Service.System
var predicate = Expressionable.Create();
predicate = predicate.AndIF(genTable.TableName.IfNotEmpty(), it => it.TableName.Contains(genTable.TableName));
- return GenTableRepository.GetPages(predicate.ToExpression(), pagerInfo, x => x.TableId, OrderByType.Desc);
+ return GetPages(predicate.ToExpression(), pagerInfo, x => x.TableId, OrderByType.Desc);
}
///
@@ -98,7 +93,7 @@ namespace ZR.Service.System
//DeleteGenTableByIds(new long[] { table.TableId });
DeleteGenTableByTbName(table.TableName);
- return GenTableRepository.Context.Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
+ return Insertable(table).IgnoreColumns(ignoreNullColumn: true).ExecuteReturnIdentity();
}
///
@@ -113,7 +108,7 @@ namespace ZR.Service.System
public int UpdateGenTable(GenTable genTable)
{
- var db = GenTableRepository.Context;
+ var db = Context;
genTable.Update_time = db.GetDate();
return db.Updateable(genTable).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
}
@@ -154,12 +149,6 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(IGenTableColumnService), ServiceLifetime = LifeTime.Transient)]
public class GenTableColumnService : BaseService, IGenTableColumnService
{
-
- private GenTableColumnRepository GetTableColumnRepository;
- public GenTableColumnService(GenTableColumnRepository genTableColumnRepository)
- {
- GetTableColumnRepository = genTableColumnRepository;
- }
///
/// 鍒犻櫎琛ㄥ瓧娈
///
@@ -167,8 +156,9 @@ namespace ZR.Service.System
///
public int DeleteGenTableColumn(long tableId)
{
- return GetTableColumnRepository.DeleteGenTableColumn(new long[] { tableId });
+ return Deleteable().Where(f => new long[] { tableId }.Contains(f.TableId)).ExecuteCommand();
}
+
///
/// 鏍规嵁琛╥d鎵归噺鍒犻櫎琛ㄥ瓧娈
///
@@ -176,7 +166,7 @@ namespace ZR.Service.System
///
public int DeleteGenTableColumn(long[] tableId)
{
- return GetTableColumnRepository.DeleteGenTableColumn(tableId);
+ return Deleteable().Where(f => tableId.Contains(f.TableId)).ExecuteCommand();
}
///
@@ -186,7 +176,7 @@ namespace ZR.Service.System
///
public int DeleteGenTableColumnByTableName(string tableName)
{
- return GetTableColumnRepository.DeleteGenTableColumnByTableName(tableName);
+ return Deleteable().Where(f => f.TableName == tableName).ExecuteCommand();
}
///
@@ -196,7 +186,7 @@ namespace ZR.Service.System
///
public List GenTableColumns(long tableId)
{
- return GetTableColumnRepository.GenTableColumns(tableId);
+ return Queryable().Where(f => f.TableId == tableId).OrderBy(x => x.Sort).ToList();
}
///
@@ -206,7 +196,7 @@ namespace ZR.Service.System
///
public int InsertGenTableColumn(List tableColumn)
{
- return GetTableColumnRepository.InsertGenTableColumn(tableColumn);
+ return Context.Insertable(tableColumn).IgnoreColumns(x => new { x.Remark }).ExecuteCommand();
}
///
@@ -216,7 +206,29 @@ namespace ZR.Service.System
///
public int UpdateGenTableColumn(List tableColumn)
{
- return GetTableColumnRepository.UpdateGenTableColumn(tableColumn);
+ return Context.Updateable(tableColumn)
+ .WhereColumns(it => new { it.ColumnId, it.TableId })
+ .UpdateColumns(it => new
+ {
+ it.ColumnComment,
+ it.CsharpField,
+ it.CsharpType,
+ it.IsQuery,
+ it.IsEdit,
+ it.IsInsert,
+ it.IsList,
+ it.QueryType,
+ it.HtmlType,
+ it.IsRequired,
+ it.Sort,
+ it.Update_time,
+ it.DictType,
+ it.Update_by,
+ it.Remark,
+ it.IsSort,
+ it.IsExport
+ })
+ .ExecuteCommand();
}
}
}
diff --git a/ZR.Service/System/IService/ISysDeptService.cs b/ZR.Service/System/IService/ISysDeptService.cs
index aed1d61cb5c1062176ff3f52dfa76e0c4c3129f0..e587c3ef5c29c53adf3d473cdb66b7612f43df3f 100644
--- a/ZR.Service/System/IService/ISysDeptService.cs
+++ b/ZR.Service/System/IService/ISysDeptService.cs
@@ -1,9 +1,6 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Text;
+锘縰sing System.Collections.Generic;
using ZR.Model.System;
using ZR.Model.Vo.System;
-using ZR.Repository;
namespace ZR.Service.System.IService
{
@@ -23,4 +20,9 @@ namespace ZR.Service.System.IService
bool DeleteRoleDeptByRoleId(long roleId);
int InsertRoleDepts(SysRole role);
}
+
+ public interface ISysRoleDeptService : IBaseService
+ {
+ List SelectRoleDeptByRoleId(long roleId);
+ }
}
diff --git a/ZR.Service/System/IService/ISysDictDataService.cs b/ZR.Service/System/IService/ISysDictDataService.cs
index 96c81f3226795681d8294e875be47d4541a167d1..b0db87db7a81085204759f6aa0a6392ecfaf3513 100644
--- a/ZR.Service/System/IService/ISysDictDataService.cs
+++ b/ZR.Service/System/IService/ISysDictDataService.cs
@@ -1,13 +1,10 @@
-锘縰sing Infrastructure.Model;
-using System;
-using System.Collections.Generic;
-using System.Text;
+锘縰sing System.Collections.Generic;
using ZR.Model;
using ZR.Model.System;
namespace ZR.Service.System.IService
{
- public interface ISysDictDataService
+ public interface ISysDictDataService : IBaseService
{
public PagedInfo SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo);
public List SelectDictDataByType(string dictType);
@@ -16,5 +13,7 @@ namespace ZR.Service.System.IService
public long InsertDictData(SysDictData dict);
public long UpdateDictData(SysDictData dict);
public int DeleteDictDataByIds(long[] dictCodes);
+ int UpdateDictDataType(string old_dictType, string new_dictType);
+ List SelectDictDataByCustomSql(SysDictType sysDictType);
}
}
diff --git a/ZR.Service/System/IService/ISysDictService.cs b/ZR.Service/System/IService/ISysDictService.cs
index 7e4313f0a6e6bdf335edacdae26b1dc1c3c01019..331d5f7fde099f814c7e920d2a830bebced6cd56 100644
--- a/ZR.Service/System/IService/ISysDictService.cs
+++ b/ZR.Service/System/IService/ISysDictService.cs
@@ -47,5 +47,7 @@ namespace ZR.Service.System.IService
///
///
SysDictType GetInfo(long dictId);
+
+ List SelectDictDataByCustomSql(string dictType);
}
}
diff --git a/ZR.Service/System/IService/ISysMenuService.cs b/ZR.Service/System/IService/ISysMenuService.cs
index c0294eaff369d5bb718d0f227acdac5f450110b3..ebd45e5ad31e789d7f0b69c49d887e1edc69f10c 100644
--- a/ZR.Service/System/IService/ISysMenuService.cs
+++ b/ZR.Service/System/IService/ISysMenuService.cs
@@ -6,7 +6,7 @@ using ZR.Model.Vo.System;
namespace ZR.Service.System.IService
{
- public interface ISysMenuService
+ public interface ISysMenuService : IBaseService
{
//List SelectMenuList(long userId);
@@ -14,7 +14,7 @@ namespace ZR.Service.System.IService
List SelectTreeMenuList(MenuQueryDto menu, long userId);
SysMenu GetMenuByMenuId(int menuId);
- List GetMenusByMenuId(int menuId);
+ List GetMenusByMenuId(int menuId, long userId);
int AddMenu(SysMenu menu);
int EditMenu(SysMenu menu);
@@ -29,14 +29,49 @@ namespace ZR.Service.System.IService
List SelectMenuTreeByUserId(long userId);
- List SelectMenuPermsListByUserId(long userId);
+ //List SelectMenuPermsListByUserId(long userId);
List SelectMenuPermsByUserId(long userId);
- bool CheckMenuExistRole(long menuId);
+ //bool CheckMenuExistRole(long menuId);
List BuildMenus(List menus);
List BuildMenuTreeSelect(List menus);
}
+
+ ///
+ /// 瑙掕壊鑿滃崟
+ ///
+ public interface ISysRoleMenuService : IBaseService
+ {
+ bool CheckMenuExistRole(long menuId);
+ ///
+ /// 鏍规嵁瑙掕壊鑾峰彇鑿滃崟id
+ ///
+ ///
+ ///
+ List SelectRoleMenuByRoleId(long roleId);
+
+ ///
+ /// 鏍规嵁鐢ㄦ埛鎵鏈夎鑹茶幏鍙栬彍鍗
+ ///
+ ///
+ ///
+ List SelectRoleMenuByRoleIds(long[] roleIds);
+
+ ///
+ /// 鎵归噺鎻掑叆鐢ㄦ埛鑿滃崟
+ ///
+ ///
+ ///
+ int AddRoleMenu(List sysRoleMenus);
+
+ ///
+ /// 鍒犻櫎瑙掕壊涓庤彍鍗曞叧鑱
+ ///
+ ///
+ ///
+ int DeleteRoleMenuByRoleId(long roleId);
+ }
}
diff --git a/ZR.Service/System/IService/ISysRoleService.cs b/ZR.Service/System/IService/ISysRoleService.cs
index a0dd959456cac73952fd36f063db8ced4909d76d..cff824d848c5448552344cbd862c8961c94c79ab 100644
--- a/ZR.Service/System/IService/ISysRoleService.cs
+++ b/ZR.Service/System/IService/ISysRoleService.cs
@@ -137,5 +137,7 @@ namespace ZR.Service.System.IService
/// 瑙掕壊淇℃伅
///
public int UpdateRole(SysRole sysRole);
+
+ int UpdateSysRole(SysRole sysRole);
}
}
diff --git a/ZR.Service/System/IService/ISysTasksQzService.cs b/ZR.Service/System/IService/ISysTasksQzService.cs
index c081a2c5f999deeefd48e991f0b6b3c23a728620..3ba6690289a09a9298516c031dc05d5d01c53639 100644
--- a/ZR.Service/System/IService/ISysTasksQzService.cs
+++ b/ZR.Service/System/IService/ISysTasksQzService.cs
@@ -3,10 +3,10 @@ using ZR.Model.System.Dto;
namespace ZR.Service.System.IService
{
- public interface ISysTasksQzService : IBaseService
+ public interface ISysTasksQzService : IBaseService
{
//SysTasksQz GetId(object id);
- int AddTasks(SysTasksQz parm);
- int UpdateTasks(SysTasksQz parm);
+ int AddTasks(SysTasks parm);
+ int UpdateTasks(SysTasks parm);
}
}
diff --git a/ZR.Service/System/IService/ISysUserRoleService.cs b/ZR.Service/System/IService/ISysUserRoleService.cs
index eb2bb4953371aa030f7b25fa60dcc133385f0104..e9de810ca6d83807a7943a701b84c8a14d452ed6 100644
--- a/ZR.Service/System/IService/ISysUserRoleService.cs
+++ b/ZR.Service/System/IService/ISysUserRoleService.cs
@@ -1,15 +1,11 @@
-锘縰sing System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+锘縰sing System.Collections.Generic;
using ZR.Model;
-using ZR.Model.System.Dto;
using ZR.Model.System;
+using ZR.Model.System.Dto;
namespace ZR.Service.System.IService
{
- public interface ISysUserRoleService
+ public interface ISysUserRoleService : IBaseService
{
public int CountUserRoleByRoleId(long roleId);
@@ -31,7 +27,7 @@ namespace ZR.Service.System.IService
///
/// 娣诲姞鐢ㄦ埛瑙掕壊
///
- ///
+ ///
///
public int AddUserRole(List sysUsers);
diff --git a/ZR.Service/System/IService/ISysUserService.cs b/ZR.Service/System/IService/ISysUserService.cs
index 8f2997bb4aa9b3e7689b768f6029635510e32ef5..1c04ddfebf1e619950e2615362da523226ae976e 100644
--- a/ZR.Service/System/IService/ISysUserService.cs
+++ b/ZR.Service/System/IService/ISysUserService.cs
@@ -1,4 +1,5 @@
-锘縰sing ZR.Model;
+锘縰sing System.Collections.Generic;
+using ZR.Model;
using ZR.Model.System;
using ZR.Model.System.Dto;
@@ -70,5 +71,16 @@ namespace ZR.Service.System.IService
SysUser Register(RegisterDto dto);
void CheckUserAllowed(SysUser user);
void CheckUserDataScope(long userid, long loginUserId);
+
+ ///
+ /// 瀵煎叆
+ ///
+ ///
+ ///
+ string ImportUsers(List users);
+
+ SysUser Login(LoginBodyDto user);
+
+ void UpdateLoginInfo(LoginBodyDto user, long userId);
}
}
diff --git a/ZR.Service/System/SysConfigService.cs b/ZR.Service/System/SysConfigService.cs
index 7e651bc6fe2d5a0afb5b8d99397ebfd45aa18aed..bf59c298ebddf69bbbfccff63b330adec37dff38 100644
--- a/ZR.Service/System/SysConfigService.cs
+++ b/ZR.Service/System/SysConfigService.cs
@@ -1,6 +1,5 @@
using Infrastructure.Attribute;
using ZR.Model.System;
-using ZR.Repository;
namespace ZR.Service.System
{
@@ -10,17 +9,11 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ISysConfigService), ServiceLifetime = LifeTime.Transient)]
public class SysConfigService : BaseService, ISysConfigService
{
- private readonly SysConfigRepository _SysConfigrepository;
- public SysConfigService(SysConfigRepository repository)
- {
- _SysConfigrepository = repository;
- }
-
#region 涓氬姟閫昏緫浠g爜
public SysConfig GetSysConfigByKey(string key)
{
- return _SysConfigrepository.Queryable().First(f => f.ConfigKey == key);
+ return Queryable().First(f => f.ConfigKey == key);
}
#endregion
diff --git a/ZR.Service/System/SysDeptService.cs b/ZR.Service/System/SysDeptService.cs
index 5785b294f61d5e8ba7a0ddfa1a2e5ec4e03f5704..8d38e4e08cb7dcb3619290d7ed52eb0c7ec41408 100644
--- a/ZR.Service/System/SysDeptService.cs
+++ b/ZR.Service/System/SysDeptService.cs
@@ -9,7 +9,6 @@ using System.Text;
using ZR.Common;
using ZR.Model.System;
using ZR.Model.Vo.System;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -20,11 +19,9 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ISysDeptService), ServiceLifetime = LifeTime.Transient)]
public class SysDeptService : BaseService, ISysDeptService
{
- public SysDeptRepository DeptRepository;
- public SysRoleDeptRepository RoleDeptRepository;
- public SysDeptService(SysDeptRepository deptRepository, SysRoleDeptRepository roleDeptRepository)
+ public ISysRoleDeptService RoleDeptRepository;
+ public SysDeptService(ISysRoleDeptService roleDeptRepository)
{
- DeptRepository = deptRepository;
RoleDeptRepository = roleDeptRepository;
}
@@ -41,7 +38,7 @@ namespace ZR.Service.System
predicate = predicate.AndIF(dept.DeptName.IfNotEmpty(), it => it.DeptName.Contains(dept.DeptName));
predicate = predicate.AndIF(dept.Status.IfNotEmpty(), it => it.Status == dept.Status);
- var response = DeptRepository.GetList(predicate.ToExpression());
+ var response = GetList(predicate.ToExpression());
return response;
}
@@ -54,7 +51,7 @@ namespace ZR.Service.System
public string CheckDeptNameUnique(SysDept dept)
{
long deptId = dept.DeptId == 0 ? -1L : dept.DeptId;
- SysDept info = DeptRepository.GetFirst(it => it.DeptName == dept.DeptName && it.ParentId == dept.ParentId);
+ SysDept info = GetFirst(it => it.DeptName == dept.DeptName && it.ParentId == dept.ParentId);
if (info != null && info.DeptId != deptId)
{
return UserConstants.NOT_UNIQUE;
@@ -69,7 +66,7 @@ namespace ZR.Service.System
///
public int InsertDept(SysDept dept)
{
- SysDept info = DeptRepository.GetFirst(it => it.DeptId == dept.ParentId);
+ SysDept info = GetFirst(it => it.DeptId == dept.ParentId);
//濡傛灉鐖惰妭鐐逛笉涓烘甯哥姸鎬,鍒欎笉鍏佽鏂板瀛愯妭鐐
if (info != null && !UserConstants.DEPT_NORMAL.Equals(info?.Status))
{
@@ -80,7 +77,7 @@ namespace ZR.Service.System
{
dept.Ancestors = info.Ancestors + "," + dept.ParentId;
}
- return DeptRepository.Add(dept);
+ return Add(dept);
}
///
@@ -90,8 +87,8 @@ namespace ZR.Service.System
///
public int UpdateDept(SysDept dept)
{
- SysDept newParentDept = DeptRepository.GetFirst(it => it.DeptId == dept.ParentId);
- SysDept oldDept = DeptRepository.GetFirst(m => m.DeptId == dept.DeptId);
+ SysDept newParentDept = GetFirst(it => it.DeptId == dept.ParentId);
+ SysDept oldDept = GetFirst(m => m.DeptId == dept.DeptId);
if (newParentDept != null && oldDept != null)
{
string newAncestors = newParentDept.Ancestors + "," + newParentDept.DeptId;
@@ -99,7 +96,7 @@ namespace ZR.Service.System
dept.Ancestors = newAncestors;
UpdateDeptChildren(dept.DeptId, newAncestors, oldAncestors);
}
- int result = DeptRepository.Context.Updateable(dept).ExecuteCommand();
+ int result = Context.Updateable(dept).ExecuteCommand();
if (UserConstants.DEPT_NORMAL.Equals(dept.Status) && dept.Ancestors.IfNotEmpty()
&& !"0".Equals(dept.Ancestors))
{
@@ -119,7 +116,7 @@ namespace ZR.Service.System
dept.Status = "0";
dept.Update_time = DateTime.Now;
- DeptRepository.Update(dept, it => new { it.Update_by, it.Update_time, it.Status }, f => depts.Contains(f.DeptId));
+ Update(dept, it => new { it.Update_by, it.Update_time, it.Status }, f => depts.Contains(f.DeptId));
}
///
@@ -140,7 +137,8 @@ namespace ZR.Service.System
}
if (children.Any())
{
- DeptRepository.UdateDeptChildren(children);
+ Context.Updateable(children).WhereColumns(f => new { f.DeptId })
+ .UpdateColumns(it => new { it.Ancestors }).ExecuteCommand();
}
}
@@ -285,4 +283,16 @@ namespace ZR.Service.System
}
#endregion
}
+
+ ///
+ /// 瑙掕壊閮ㄩ棬
+ ///
+ [AppService(ServiceType = typeof(ISysRoleDeptService), ServiceLifetime = LifeTime.Transient)]
+ public class SysRoleDeptService : BaseService, ISysRoleDeptService
+ {
+ public List SelectRoleDeptByRoleId(long roleId)
+ {
+ return GetList(it => it.RoleId == roleId).ToList();
+ }
+ }
}
diff --git a/ZR.Service/System/SysDictDataService.cs b/ZR.Service/System/SysDictDataService.cs
index 2b44798e9b9ac96fd0fcf31e67f22bd8e0905f00..41056329c9ea490a9b15a0733ac9003cc8574307 100644
--- a/ZR.Service/System/SysDictDataService.cs
+++ b/ZR.Service/System/SysDictDataService.cs
@@ -1,12 +1,11 @@
锘縰sing Infrastructure.Attribute;
-using Infrastructure.Model;
+using SqlSugar;
using System;
using System.Collections.Generic;
-using System.Text;
+using System.Linq;
using ZR.Common;
using ZR.Model;
using ZR.Model.System;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -17,21 +16,20 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ISysDictDataService), ServiceLifetime = LifeTime.Transient)]
public class SysDictDataService : BaseService, ISysDictDataService
{
-
- private readonly SysDictDataRepository SysDictDataRepository;
- public SysDictDataService(SysDictDataRepository sysDictDataRepository)
- {
- SysDictDataRepository = sysDictDataRepository;
- }
-
///
/// 鏌ヨ瀛楀吀鏁版嵁
///
///
+ ///
///
public PagedInfo SelectDictDataList(SysDictData dictData, PagerInfo pagerInfo)
{
- return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
+ //return SysDictDataRepository.SelectDictDataList(dictData, pagerInfo);
+ var exp = Expressionable.Create();
+ exp.AndIF(!string.IsNullOrEmpty(dictData.DictLabel), it => it.DictLabel.Contains(dictData.DictLabel));
+ exp.AndIF(!string.IsNullOrEmpty(dictData.Status), it => it.Status == dictData.Status);
+ exp.AndIF(!string.IsNullOrEmpty(dictData.DictType), it => it.DictType == dictData.DictType);
+ return GetPages(exp.ToExpression(), pagerInfo);
}
///
@@ -44,7 +42,9 @@ namespace ZR.Service.System
string CK = $"SelectDictDataByType_{dictType}";
if (CacheHelper.GetCache(CK) is not List list)
{
- list = SysDictDataRepository.SelectDictDataByType(dictType);
+ list = Queryable().Where(f => f.Status == "0" && f.DictType == dictType)
+ .OrderBy(it => it.DictSort)
+ .ToList();
CacheHelper.SetCache(CK, list, 30);
}
return list;
@@ -54,7 +54,9 @@ namespace ZR.Service.System
string CK = $"SelectDictDataByTypes_{dictTypes}";
if (CacheHelper.GetCache(CK) is not List list)
{
- list = SysDictDataRepository.SelectDictDataByTypes(dictTypes);
+ list = Queryable().Where(f => f.Status == "0" && dictTypes.Contains(f.DictType))
+ .OrderBy(it => it.DictSort)
+ .ToList();
//CacheHelper.SetCache(CK, list, 30);
}
return list;
@@ -69,7 +71,7 @@ namespace ZR.Service.System
string CK = $"SelectDictDataByCode_{dictCode}";
if (CacheHelper.GetCache(CK) is not SysDictData list)
{
- list = SysDictDataRepository.GetFirst(f => f.DictCode == dictCode);
+ list = GetFirst(f => f.DictCode == dictCode);
CacheHelper.SetCache(CK, list, 5);
}
return list;
@@ -82,7 +84,7 @@ namespace ZR.Service.System
///
public long InsertDictData(SysDictData dict)
{
- return SysDictDataRepository.InsertDictData(dict);
+ return Insertable(dict).ExecuteReturnBigIdentity();
}
///
@@ -92,7 +94,18 @@ namespace ZR.Service.System
///
public long UpdateDictData(SysDictData dict)
{
- var result = SysDictDataRepository.UpdateDictData(dict);
+ var result = Update(w => w.DictCode == dict.DictCode, it => new SysDictData()
+ {
+ Remark = dict.Remark,
+ Update_time = DateTime.Now,
+ DictSort = dict.DictSort,
+ DictLabel = dict.DictLabel,
+ DictValue = dict.DictValue,
+ Status = dict.Status,
+ CssClass = dict.CssClass,
+ ListClass = dict.ListClass
+ });
+
CacheHelper.Remove($"SelectDictDataByCode_{dict.DictCode}");
return result;
}
@@ -104,7 +117,32 @@ namespace ZR.Service.System
///
public int DeleteDictDataByIds(long[] dictCodes)
{
- return SysDictDataRepository.DeleteDictDataByIds(dictCodes);
+ return Delete(dictCodes);
+ }
+
+ ///
+ /// 鍚屾淇敼瀛楀吀绫诲瀷
+ ///
+ /// 鏃у瓧鍏哥被鍨
+ /// 鏂板瓧鍏哥被鍨
+ ///
+ public int UpdateDictDataType(string old_dictType, string new_dictType)
+ {
+ //鍙洿鏂癉ictType瀛楁鏍规嵁where鏉′欢
+ return Context.Updateable()
+ .SetColumns(t => new SysDictData() { DictType = new_dictType })
+ .Where(f => f.DictType == old_dictType)
+ .ExecuteCommand();
+ }
+
+ ///
+ /// 鏍规嵁瀛楀吀绫诲瀷鏌ヨ鑷畾涔塻ql
+ ///
+ ///
+ ///
+ public List SelectDictDataByCustomSql(SysDictType sysDictType)
+ {
+ return Context.Ado.SqlQuery(sysDictType?.CustomSql).ToList();
}
}
}
diff --git a/ZR.Service/System/SysDictService.cs b/ZR.Service/System/SysDictService.cs
index 0df06e5326dc7100c17386244df2580873fe1883..f3ae94343b65bf27ae39ecdb5a207bf51dbf30c0 100644
--- a/ZR.Service/System/SysDictService.cs
+++ b/ZR.Service/System/SysDictService.cs
@@ -1,10 +1,10 @@
锘縰sing Infrastructure;
using Infrastructure.Attribute;
+using SqlSugar;
+using System;
using System.Collections.Generic;
-using System.Text;
using ZR.Model;
using ZR.Model.System;
-using ZR.Repository.System;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -15,27 +15,32 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ISysDictService), ServiceLifetime = LifeTime.Transient)]
public class SysDictService : BaseService, ISysDictService
{
- private SysDictRepository DictRepository;
- private SysDictDataRepository DictDataRepository;
+ private ISysDictDataService DictDataService;
- public SysDictService(SysDictRepository sysDictRepository, SysDictDataRepository dictDataRepository)
+ public SysDictService(ISysDictDataService dictDataRepository)
{
- this.DictRepository = sysDictRepository;
- this.DictDataRepository = dictDataRepository;
+ this.DictDataService = dictDataRepository;
}
public List GetAll()
{
- return DictRepository.GetAll();
+ return Queryable().ToList();
}
///
/// 鏌ヨ瀛楁绫诲瀷鍒楄〃
///
/// 瀹炰綋妯″瀷
+ ///
///
- public PagedInfo SelectDictTypeList(SysDictType dictType, Model.PagerInfo pager)
+ public PagedInfo SelectDictTypeList(SysDictType dictType, PagerInfo pager)
{
- return DictRepository.SelectDictTypeList(dictType, pager);
+ var exp = Expressionable.Create();
+ exp.AndIF(!string.IsNullOrEmpty(dictType.DictName), it => it.DictName.Contains(dictType.DictName));
+ exp.AndIF(!string.IsNullOrEmpty(dictType.Status), it => it.Status == dictType.Status);
+ exp.AndIF(!string.IsNullOrEmpty(dictType.DictType), it => it.DictType.Contains(dictType.DictType));
+ exp.AndIF(!string.IsNullOrEmpty(dictType.Type), it => it.Type.Equals(dictType.Type));
+
+ return GetPages(exp.ToExpression(), pager, f => f.DictId, OrderByType.Desc);
}
///
@@ -45,7 +50,7 @@ namespace ZR.Service.System
///
public string CheckDictTypeUnique(SysDictType dictType)
{
- SysDictType sysDictType = DictRepository.GetFirst(f => f.DictType == dictType.DictType);
+ SysDictType sysDictType = GetFirst(f => f.DictType == dictType.DictType);
if (sysDictType != null && sysDictType.DictId != dictType.DictId)
{
return UserConstants.NOT_UNIQUE;
@@ -56,19 +61,19 @@ namespace ZR.Service.System
///
/// 鎵归噺鍒犻櫎瀛楀吀鏁版嵁淇℃伅
///
- ///
+ ///
///
public int DeleteDictTypeByIds(long[] dictIds)
{
foreach (var dictId in dictIds)
{
- SysDictType dictType = DictRepository.GetFirst(x => x.DictId == dictId);
- if (DictDataRepository.Count(f => f.DictType == dictType.DictType) > 0)
+ SysDictType dictType = GetFirst(x => x.DictId == dictId);
+ if (DictDataService.Count(f => f.DictType == dictType.DictType) > 0)
{
throw new CustomException($"{dictType.DictName}宸插垎閰,涓嶈兘鍒犻櫎");
}
}
- int count = DictRepository.DeleteDictTypeByIds(dictIds);
+ int count = Context.Deleteable().In(dictIds).ExecuteCommand();
//if (count > 0)
//{
// DictUtils.clearDictCache();
@@ -83,7 +88,7 @@ namespace ZR.Service.System
///
public long InsertDictType(SysDictType sysDictType)
{
- return DictRepository.InsertReturnBigIdentity(sysDictType);
+ return InsertReturnBigIdentity(sysDictType);
}
///
@@ -93,13 +98,13 @@ namespace ZR.Service.System
///
public int UpdateDictType(SysDictType sysDictType)
{
- SysDictType oldDict = DictRepository.GetFirst(x => x.DictId == sysDictType.DictId);
+ SysDictType oldDict = GetFirst(x => x.DictId == sysDictType.DictId);
if (sysDictType.DictType != oldDict.DictType)
{
//鍚屾淇敼 dict_data琛ㄩ噷闈㈢殑DictType鍊
- DictDataRepository.UpdateDictDataType(oldDict.DictType, sysDictType.DictType);
+ DictDataService.UpdateDictDataType(oldDict.DictType, sysDictType.DictType);
}
- return DictRepository.UpdateDictType(sysDictType);
+ return Context.Updateable(sysDictType).IgnoreColumns(it => new { sysDictType.Create_by }).ExecuteCommand();
}
///
@@ -109,7 +114,23 @@ namespace ZR.Service.System
///
public SysDictType GetInfo(long dictId)
{
- return DictRepository.GetFirst(f => f.DictId == dictId);
+ return GetFirst(f => f.DictId == dictId);
+ }
+
+ ///
+ /// 鏍规嵁瀛楀吀绫诲瀷鏌ヨ鑷畾涔塻ql
+ ///
+ ///
+ ///
+ public List SelectDictDataByCustomSql(string dictType)
+ {
+ var dictInfo = Queryable()
+ .Where(f => f.DictType == dictType).First();
+ if (dictInfo == null || !dictInfo.CustomSql.StartsWith("select", StringComparison.OrdinalIgnoreCase))
+ {
+ return null;
+ }
+ return DictDataService.SelectDictDataByCustomSql(dictInfo);
}
}
}
diff --git a/ZR.Service/System/SysLoginService.cs b/ZR.Service/System/SysLoginService.cs
index 563bb1165cabf7cd406aa44ef8213c55e52f9dc8..804872686c84dc9a8ae32bde2487eb1f35396556 100644
--- a/ZR.Service/System/SysLoginService.cs
+++ b/ZR.Service/System/SysLoginService.cs
@@ -1,12 +1,12 @@
锘縰sing Infrastructure;
using Infrastructure.Attribute;
+using Infrastructure.Extensions;
+using SqlSugar;
using System;
-using System.Collections.Generic;
-using ZR.Common;
using ZR.Model;
-using ZR.Model.System.Dto;
using ZR.Model.System;
-using ZR.Repository.System;
+using ZR.Model.System.Dto;
+using ZR.Repository;
using ZR.Service.System.IService;
namespace ZR.Service.System
@@ -17,11 +17,11 @@ namespace ZR.Service.System
[AppService(ServiceType = typeof(ISysLoginService), ServiceLifetime = LifeTime.Transient)]
public class SysLoginService: BaseService, ISysLoginService
{
- private SysLogininfoRepository SysLogininfoRepository;
+ private readonly ISysUserService SysUserService;
- public SysLoginService(SysLogininfoRepository sysLogininfo)
+ public SysLoginService(ISysUserService sysUserService)
{
- SysLogininfoRepository = sysLogininfo;
+ SysUserService = sysUserService;
}
///
@@ -34,32 +34,31 @@ namespace ZR.Service.System
//瀵嗙爜md5
loginBody.Password = NETCore.Encrypt.EncryptProvider.Md5(loginBody.Password);
- SysUser user = SysLogininfoRepository.Login(loginBody);
- logininfor.userName = loginBody.Username;
- logininfor.status = "1";
- logininfor.loginTime = DateTime.Now;
+ SysUser user = SysUserService.Login(loginBody);
+ logininfor.UserName = loginBody.Username;
+ logininfor.Status = "1";
+ logininfor.LoginTime = DateTime.Now;
if (user == null || user.UserId <= 0)
{
- logininfor.msg = "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒";
+ logininfor.Msg = "鐢ㄦ埛鍚嶆垨瀵嗙爜閿欒";
AddLoginInfo(logininfor);
- throw new CustomException(ResultCode.LOGIN_ERROR ,logininfor.msg);
+ throw new CustomException(ResultCode.LOGIN_ERROR ,logininfor.Msg);
}
if (user.Status == "1")
{
- logininfor.msg = "璇ョ敤鎴峰凡绂佺敤";
+ logininfor.Msg = "璇ョ敤鎴峰凡绂佺敤";
AddLoginInfo(logininfor);
- throw new CustomException(ResultCode.LOGIN_ERROR, logininfor.msg);
+ throw new CustomException(ResultCode.LOGIN_ERROR, logininfor.Msg);
}
- logininfor.status = "0";
- logininfor.msg = "鐧诲綍鎴愬姛";
+ logininfor.Status = "0";
+ logininfor.Msg = "鐧诲綍鎴愬姛";
AddLoginInfo(logininfor);
- SysLogininfoRepository.UpdateLoginInfo(loginBody, user.UserId);
+ SysUserService.UpdateLoginInfo(loginBody, user.UserId);
return user;
}
-
///
/// 鏌ヨ鎿嶄綔鏃ュ織
///
@@ -71,8 +70,15 @@ namespace ZR.Service.System
logininfoDto.BeginTime = DateTimeHelper.GetBeginTime(logininfoDto.BeginTime, -1);
logininfoDto.EndTime = DateTimeHelper.GetBeginTime(logininfoDto.EndTime, 1);
- var list = SysLogininfoRepository.GetLoginLog(logininfoDto, pager);
- return list;
+ var exp = Expressionable.Create();
+ exp.And(it => it.LoginTime >= logininfoDto.BeginTime && it.LoginTime <= logininfoDto.EndTime);
+ exp.AndIF(logininfoDto.Ipaddr.IfNotEmpty(), f => f.Ipaddr == logininfoDto.Ipaddr);
+ exp.AndIF(logininfoDto.UserName.IfNotEmpty(), f => f.UserName.Contains(logininfoDto.UserName));
+ exp.AndIF(logininfoDto.Status.IfNotEmpty(), f => f.Status == logininfoDto.Status);
+ var query = Queryable().Where(exp.ToExpression())
+ .OrderBy(it => it.InfoId, OrderByType.Desc);
+
+ return query.ToPage(pager);
}
///
@@ -82,7 +88,7 @@ namespace ZR.Service.System
///
public void AddLoginInfo(SysLogininfor sysLogininfor)
{
- SysLogininfoRepository.AddLoginInfo(sysLogininfor);
+ Insert(sysLogininfor);
}
///
@@ -90,7 +96,7 @@ namespace ZR.Service.System
///
public void TruncateLogininfo()
{
- SysLogininfoRepository.TruncateLogininfo();
+ Truncate();
}
///
@@ -100,7 +106,7 @@ namespace ZR.Service.System
///
public int DeleteLogininforByIds(long[] ids)
{
- return SysLogininfoRepository.DeleteLogininforByIds(ids);
+ return Delete(ids);
}
}
}
diff --git a/ZR.Service/System/SysMenuService.cs b/ZR.Service/System/SysMenuService.cs
index e0d4631f2fdf3f92485b0251c359301422972b48..5106cb26f519d73c4f86363755eddd15454cdb2f 100644
--- a/ZR.Service/System/SysMenuService.cs
+++ b/ZR.Service/System/SysMenuService.cs
@@ -1,14 +1,15 @@
锘縰sing Infrastructure.Attribute;
+using Infrastructure.Extensions;
+using SqlSugar;
+using System;
using System.Collections.Generic;
using System.Linq;
-using ZR.Model.System.Dto;
+using ZR.Common;
using ZR.Model.System;
+using ZR.Model.System.Dto;
using ZR.Model.System.Vo;
using ZR.Model.Vo.System;
-using ZR.Repository.System;
using ZR.Service.System.IService;
-using ZR.Common;
-using Infrastructure.Extensions;
namespace ZR.Service
{
@@ -18,14 +19,10 @@ namespace ZR.Service
[AppService(ServiceType = typeof(ISysMenuService), ServiceLifetime = LifeTime.Transient)]
public class SysMenuService : BaseService, ISysMenuService
{
- public SysMenuRepository MenuRepository;
public ISysRoleService SysRoleService;
- public SysMenuService(
- SysMenuRepository menuRepository,
- ISysRoleService sysRoleService)
+ public SysMenuService(ISysRoleService sysRoleService)
{
- MenuRepository = menuRepository;
SysRoleService = sysRoleService;
}
@@ -38,12 +35,12 @@ namespace ZR.Service
List menuList;
if (SysRoleService.IsAdmin(userId))
{
- menuList = MenuRepository.SelectTreeMenuList(menu);
+ menuList = SelectTreeMenuList(menu);
}
else
{
var userRoles = SysRoleService.SelectUserRoles(userId);
- menuList = MenuRepository.SelectTreeMenuListByRoles(menu, userRoles);
+ menuList = SelectTreeMenuListByRoles(menu, userRoles);
}
return menuList;
}
@@ -57,12 +54,12 @@ namespace ZR.Service
List menuList;
if (SysRoleService.IsAdmin(userId))
{
- menuList = MenuRepository.SelectMenuList(menu);
+ menuList = SelectAllMenuList(menu);
}
else
{
var userRoles = SysRoleService.SelectUserRoles(userId);
- menuList = MenuRepository.SelectMenuListByRoles(menu, userRoles);
+ menuList = SelectMenuListByRoles(menu, userRoles);
}
return menuList;
}
@@ -74,20 +71,32 @@ namespace ZR.Service
///
public SysMenu GetMenuByMenuId(int menuId)
{
- return MenuRepository.SelectMenuById(menuId);
+ return GetFirst(it => it.MenuId == menuId);
}
///
/// 鏍规嵁鑿滃崟id鑾峰彇鑿滃崟鍒楄〃
///
///
+ ///
///
- public List GetMenusByMenuId(int menuId)
+ public List GetMenusByMenuId(int menuId, long userId)
{
- var list = MenuRepository.GetList(f => f.parentId == menuId).OrderBy(f => f.orderNum).ToList();
+ var menuExpression = Expressionable.Create();
+ menuExpression.And(c => c.ParentId == menuId);
+
+ if (!SysRoleService.IsAdmin(userId))
+ {
+ var userRoles = SysRoleService.SelectUserRoles(userId);
+ var roleMenus = Context.Queryable()
+ .Where(r => userRoles.Contains(r.Role_id)).Select(s => s.Menu_id).ToList();
+
+ menuExpression.And(c => roleMenus.Contains(c.MenuId));
+ }
+ var list = GetList(menuExpression.ToExpression()).OrderBy(f => f.OrderNum).ToList();
Context.ThenMapper(list, item =>
{
- item.SubNum = Context.Queryable().SetContext(x => x.parentId, () => item.MenuId, item).Count;
+ item.SubNum = Context.Queryable().SetContext(x => x.ParentId, () => item.MenuId, item).Count;
});
return list;
}
@@ -99,7 +108,8 @@ namespace ZR.Service
///
public int AddMenu(SysMenu menu)
{
- return MenuRepository.AddMenu(menu);
+ menu.Create_time = DateTime.Now;
+ return InsertReturnIdentity(menu);
}
///
@@ -109,8 +119,8 @@ namespace ZR.Service
///
public int EditMenu(SysMenu menu)
{
- menu.icon = string.IsNullOrEmpty(menu.icon) ? "" : menu.icon;
- return MenuRepository.EditMenu(menu);
+ menu.Icon = string.IsNullOrEmpty(menu.Icon) ? "" : menu.Icon;
+ return Update(menu, false);
}
///
@@ -120,7 +130,7 @@ namespace ZR.Service
///
public int DeleteMenuById(int menuId)
{
- return MenuRepository.DeleteMenuById(menuId);
+ return Delete(menuId);
}
///
@@ -131,7 +141,7 @@ namespace ZR.Service
public string CheckMenuNameUnique(SysMenu menu)
{
long menuId = menu.MenuId == 0 ? -1 : menu.MenuId;
- SysMenu info = MenuRepository.CheckMenuNameUnique(menu);
+ SysMenu info = GetFirst(it => it.MenuName == menu.MenuName && it.ParentId == menu.ParentId);
//if (info != null && menuId != info.menuId && menu.menuName.Equals(info.menuName))
//{
@@ -147,11 +157,11 @@ namespace ZR.Service
///