同步一个版本。
This commit is contained in:
parent
2775822ba2
commit
9b9d696d25
178
XPrint.Image/Tools/ChannelImageTool.cs
Normal file
178
XPrint.Image/Tools/ChannelImageTool.cs
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
using HPPH;
|
||||||
|
using ImageMagick;
|
||||||
|
using ImageMagick.Formats;
|
||||||
|
using Pipelines.Sockets.Unofficial.Arenas;
|
||||||
|
using SixLabors.ImageSharp.PixelFormats;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace XPrint.Image.Tools
|
||||||
|
{
|
||||||
|
public class ChannelImageTool
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 分色接口
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputPath">输入图片路径</param>
|
||||||
|
/// <param name="outputPath">输出图片路径</param>
|
||||||
|
/// <param name="iccProfileName">icc名称</param>
|
||||||
|
/// <param name="iccProfilePath">icc文件路径</param>
|
||||||
|
public static void SplitColor(string inputPath, string outputPath, string iccProfilePath = "")
|
||||||
|
{
|
||||||
|
using (var image = new MagickImage(inputPath)
|
||||||
|
{
|
||||||
|
ColorSpace = ColorSpace.sRGB // 若需与 CMYK 工作流对接,改为 CMYK 并与源一致
|
||||||
|
})
|
||||||
|
{
|
||||||
|
//var profileBim1 = image.Get8BimProfile();
|
||||||
|
//if (profileBim1 != null)
|
||||||
|
//{
|
||||||
|
// var data = profileBim1.ToByteArray();
|
||||||
|
// File.WriteAllBytes(@"D:\8bim_white_channel", data);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// 配置大端字节序
|
||||||
|
var writeSettings = new TiffWriteDefines();
|
||||||
|
writeSettings.Endian = Endian.MSB;//大端模式,兼容性好些
|
||||||
|
image.Alpha(AlphaOption.On);
|
||||||
|
image.MetaChannelCount = 0;
|
||||||
|
|
||||||
|
ushort[] area;
|
||||||
|
var pixels = image.GetPixels();
|
||||||
|
var areaAlpha = pixels.GetArea(0, 0, image.Width, image.Height)!;
|
||||||
|
|
||||||
|
image.Alpha(AlphaOption.Off);
|
||||||
|
image.MetaChannelCount = 1;
|
||||||
|
|
||||||
|
var pixels2 = image.GetPixels();
|
||||||
|
|
||||||
|
area = pixels2.GetArea(0, 0, image.Width, image.Height)!;
|
||||||
|
// 遍历每个像素,根据Alpha值设置White通道
|
||||||
|
for (int i = 0; i < areaAlpha.Length; i += 4)
|
||||||
|
{
|
||||||
|
// 获取原始图像的Alpha值
|
||||||
|
ushort alpha = areaAlpha[i + 3];
|
||||||
|
|
||||||
|
var r = area[i];
|
||||||
|
var g = area[i + 1];
|
||||||
|
var b = area[i + 2];
|
||||||
|
|
||||||
|
// 2. 计算白色墨量:通过RGB值计算灰度值(灰度越高,白色墨量越多)
|
||||||
|
// 公式:gray = 0.299*R + 0.587*G + 0.114*B(适配16位范围)
|
||||||
|
double grayValue = 0.299 * r + 0.587 * g + 0.114 * b;
|
||||||
|
ushort whiteInkAmount = (ushort)Math.Clamp(grayValue, 0, 65535); // 确保在0~65535范围内
|
||||||
|
|
||||||
|
// 3. 黑色填充深度 = 白色墨量(墨量越多,黑色越深)
|
||||||
|
// 将白色墨量直接映射到目标通道(i+4),值越高表示黑色越深
|
||||||
|
area[i + 3] = whiteInkAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
pixels2.SetPixels(area);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string bimFileName = "8bim_white_channel";
|
||||||
|
var bimData = File.ReadAllBytes(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"assets/{bimFileName}"));
|
||||||
|
var profileBim = new EightBimProfile(image, bimData);
|
||||||
|
|
||||||
|
//image.Alpha(AlphaOption.Remove);
|
||||||
|
profileBim.SetExifProfile(image.GetExifProfile());
|
||||||
|
profileBim.SetIptcProfile(image.GetIptcProfile());
|
||||||
|
profileBim.SetXmpProfile(image.GetXmpProfile());
|
||||||
|
image.SetProfile(profileBim);
|
||||||
|
|
||||||
|
profileBim.GetExifProfile()?.CreateThumbnail();
|
||||||
|
|
||||||
|
image.Settings.Compression = CompressionMethod.LZW;
|
||||||
|
image.SetCompression(CompressionMethod.LZW);//LZW压缩避免竖线问题
|
||||||
|
//writeSettings.Alpha = TiffAlpha.Associated;
|
||||||
|
// 保存
|
||||||
|
// 4. 保存结果
|
||||||
|
image.Write(outputPath);
|
||||||
|
Console.WriteLine($"填充完成,结果已保存至:{outputPath}");
|
||||||
|
//}
|
||||||
|
|
||||||
|
//var profileBim = image.Get8BimProfile()!;
|
||||||
|
//profileBim.GetExifProfile()?.RemoveThumbnail();
|
||||||
|
//File.WriteAllBytes(@$"D:\{bimFileName}", profileBim.ToByteArray());
|
||||||
|
|
||||||
|
//if (bimProfile != null)
|
||||||
|
//{
|
||||||
|
// var exifProfile = bimProfile.GetExifProfile();
|
||||||
|
// var xmpProfile = bimProfile.GetXmpProfile();
|
||||||
|
// var iptcProfile = bimProfile.GetIptcProfile();
|
||||||
|
|
||||||
|
// profileBim.SetExifProfile(exifProfile);
|
||||||
|
// profileBim.SetIptcProfile(iptcProfile);
|
||||||
|
// profileBim.SetXmpProfile(xmpProfile);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//image.Compose = CompositeOperator.Overlay;
|
||||||
|
|
||||||
|
//var channelNames = new Dictionary<int, string>
|
||||||
|
//{
|
||||||
|
// { 0, "C" }, // 假设通道索引1对应红色
|
||||||
|
// { 1, "M" },
|
||||||
|
// { 2, "Y" },
|
||||||
|
// { 3, "K" },
|
||||||
|
// { 4, "A" },
|
||||||
|
// { 5, "W" }
|
||||||
|
//};
|
||||||
|
|
||||||
|
//TiffModifier.RenameCustomChannels(@"D:\2.tiff", Path.Combine(Path.GetDirectoryName(outputPath)!, "3.tif"), channelNames);
|
||||||
|
// 创建包含 4 个自定义通道的图像
|
||||||
|
//using (System.Drawing.Image imageA = new Bitmap(new MemoryStream(image.ToByteArray())))
|
||||||
|
//{
|
||||||
|
// var items = imageA.PropertyItems;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//private static string AddCustomXmpChannelName(string xmpXml, string channelName)
|
||||||
|
//{
|
||||||
|
// // 注意:此方法需要根据实际 XMP 结构和命名空间调整
|
||||||
|
// // 示例:添加自定义命名空间 "mychannel"
|
||||||
|
// if (!xmpXml.Contains("xmlns:mychannel"))
|
||||||
|
// {
|
||||||
|
// xmpXml = xmpXml.Replace("<rdf:RDF",
|
||||||
|
// "<rdf:RDF xmlns:mychannel=\"http://example.com/channel/\"");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 添加或更新 ChannelName 属性
|
||||||
|
// string channelProperty = $"<mychannel:ChannelName>{channelName}</mychannel:ChannelName>";
|
||||||
|
// int insertPos = xmpXml.IndexOf("</rdf:RDF>");
|
||||||
|
// if (insertPos > 0)
|
||||||
|
// {
|
||||||
|
// xmpXml = xmpXml.Insert(insertPos, channelProperty);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return xmpXml;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//public static void GenerateMultiPageCmykTiff(MagickImage[] imagePages, string outputPath)
|
||||||
|
//{
|
||||||
|
// using (var images = new MagickImageCollection())
|
||||||
|
// {
|
||||||
|
// for (int i = 0; i < imagePages.Length; i++)
|
||||||
|
// {
|
||||||
|
// //设置dpi
|
||||||
|
// //imagePages[i].Density = new Density(300.00, 300.00);
|
||||||
|
// images.Add(imagePages[i]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// // 配置大端字节序
|
||||||
|
// var writeSettings = new WriteTiffBigEndianDefines();
|
||||||
|
|
||||||
|
// // 保存多页
|
||||||
|
// images.Write(outputPath, writeSettings);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,6 @@
|
|||||||
using CrazyStudio.Core.Common.CryptHelper;
|
using CrazyStudio.Core.Common.CryptHelper;
|
||||||
using CrazyStudio.Core.Common.Eitities;
|
using CrazyStudio.Core.Common.Eitities;
|
||||||
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
using CrazyStudio.Core.Common.JWT;
|
using CrazyStudio.Core.Common.JWT;
|
||||||
using CrazyStudio.Core.Common.Tools;
|
using CrazyStudio.Core.Common.Tools;
|
||||||
using Duende.IdentityModel;
|
using Duende.IdentityModel;
|
||||||
@ -13,7 +14,7 @@ using XPrintServer.Business.Dto;
|
|||||||
using XPrintServer.Business.Services;
|
using XPrintServer.Business.Services;
|
||||||
using XPrintServer.DataModel.Models;
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
namespace XPrintServer.Api.Controllers
|
namespace XPrintServer.Admin.Api.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
@ -190,5 +191,23 @@ namespace XPrintServer.Api.Controllers
|
|||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<PageResult<BackstageUser>>> GetBackstageUserList([FromBody] PageData pageData)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var userList = await _backstatgeUserService.GetBackstageUserList(pageData);
|
||||||
|
return Ok(userList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "GetBackstageUserList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
156
XPrintServer.Admin.Api/Controllers/MenuController.cs
Normal file
156
XPrintServer.Admin.Api/Controllers/MenuController.cs
Normal file
@ -0,0 +1,156 @@
|
|||||||
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using StackExchange.Redis;
|
||||||
|
using XPrintServer.Business.Dto;
|
||||||
|
using XPrintServer.Business.Services;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Admin.Api.Controllers
|
||||||
|
{
|
||||||
|
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class MenuController : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly MenuService _menuService;
|
||||||
|
private readonly UserMenuInRoleService _userMenuInRoleService;
|
||||||
|
private readonly ActionLogService _actionLogService;
|
||||||
|
|
||||||
|
public MenuController(IHttpContextAccessor httpContextAccessor, MenuService menuService, UserMenuInRoleService userMenuInRoleService, ActionLogService actionLogService)
|
||||||
|
{
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_menuService = menuService;
|
||||||
|
_userMenuInRoleService = userMenuInRoleService;
|
||||||
|
_actionLogService = actionLogService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> AddOrUpdateMenu([FromBody] Menu menu)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await _menuService.AddOrUpdateMenu(menu);
|
||||||
|
return Ok(menu);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "AddOrUpdateMenu Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> MenuList([FromBody] PageData pageData)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var menuList = await _menuService.GetMenuList(pageData, false);
|
||||||
|
return Ok(menuList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "MenuList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<List<MenuTreeData>>> AllMenuList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var menuList = await _menuService.GetListAsync().ConfigureAwait(false);
|
||||||
|
List<MenuTreeData> menuTreelist = menuList.ConvertAll(m => new MenuTreeData
|
||||||
|
{
|
||||||
|
Id = m.Id,
|
||||||
|
ComponentPath = m.ComponentPath,
|
||||||
|
MenuName = m.MenuName,
|
||||||
|
RouteName = m.RouteName,
|
||||||
|
ParentId = m.ParentId,
|
||||||
|
IsActive = m.IsActive
|
||||||
|
})!;
|
||||||
|
List<MenuTreeData> removeList = new List<MenuTreeData>();
|
||||||
|
foreach (var menu in menuTreelist)
|
||||||
|
{
|
||||||
|
var parentMenu = menuTreelist.Find(m => m.Id == menu.ParentId);
|
||||||
|
if (parentMenu != null)
|
||||||
|
{
|
||||||
|
parentMenu.Children.Add(menu);
|
||||||
|
removeList.Add(menu);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (var removeMenu in removeList)
|
||||||
|
{
|
||||||
|
menuTreelist.Remove(removeMenu);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ok(menuTreelist);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "AllMenuList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> ActiveMenuList([FromBody] PageData pageData)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var menuList = await _menuService.GetMenuList(pageData, true);
|
||||||
|
return Ok(menuList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "ActiveMenuList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> MenuById([FromBody] Guid Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var menu = await _menuService.GetByIdAsync(Id).ConfigureAwait(false);
|
||||||
|
return Ok(menu);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "MenuById Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> DeleteMenu([FromBody] Guid Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//¿ªÊ¼ÊÂÎñ
|
||||||
|
await _menuService.Context.Ado.BeginTranAsync();
|
||||||
|
var isOK = await _menuService.DeleteByIdAsync(Id);
|
||||||
|
|
||||||
|
var deleteDatas = await _userMenuInRoleService.Context.Queryable<UserMenuInRole>().Where(um => um.MenuId == Id).SplitTable().ToListAsync().ConfigureAwait(false);
|
||||||
|
await _userMenuInRoleService.Context.Deleteable(deleteDatas).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
|
//Ìá½»ÊÂÎñ
|
||||||
|
await _menuService.Context.Ado.CommitTranAsync();
|
||||||
|
return Ok(isOK);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Òì³£ÊÂÎñ»Ø¹ö
|
||||||
|
await _menuService.Context.Ado.RollbackTranAsync();
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "DeleteMenu Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
137
XPrintServer.Admin.Api/Controllers/RoleController.cs
Normal file
137
XPrintServer.Admin.Api/Controllers/RoleController.cs
Normal file
@ -0,0 +1,137 @@
|
|||||||
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using XPrintServer.Business.Dto;
|
||||||
|
using XPrintServer.Business.Services;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Admin.Api.Controllers
|
||||||
|
{
|
||||||
|
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
public class RoleController : ControllerBase
|
||||||
|
{
|
||||||
|
|
||||||
|
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||||
|
private readonly RoleService _roleService;
|
||||||
|
private readonly UserMenuInRoleService _userMenuInRoleService;
|
||||||
|
private readonly ActionLogService _actionLogService;
|
||||||
|
|
||||||
|
public RoleController(IHttpContextAccessor httpContextAccessor, RoleService roleService, UserMenuInRoleService userMenuInRoleService, ActionLogService actionLogService)
|
||||||
|
{
|
||||||
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_roleService = roleService;
|
||||||
|
_userMenuInRoleService = userMenuInRoleService;
|
||||||
|
_actionLogService = actionLogService;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> AddOrUpdateRole([FromBody] RoleInfo roleInfo)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//¿ªÊ¼ÊÂÎñ
|
||||||
|
await _roleService.Context.Ado.BeginTranAsync();
|
||||||
|
|
||||||
|
await _roleService.AddOrUpdateRole(roleInfo.Role);
|
||||||
|
|
||||||
|
await _userMenuInRoleService.AddOrUpdateUserMenuInRoles(roleInfo.Role.Id, roleInfo.MenuIds);
|
||||||
|
//Ìá½»ÊÂÎñ
|
||||||
|
await _roleService.Context.Ado.CommitTranAsync();
|
||||||
|
return Ok(roleInfo.Role);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Òì³£ÊÂÎñ»Ø¹ö
|
||||||
|
await _roleService.Context.Ado.RollbackTranAsync();
|
||||||
|
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "AddOrUpdateRole Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<PageResult<Role>>> RoleList([FromBody] PageData pageData)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var roleList = await _roleService.GetRoleList(pageData);
|
||||||
|
return Ok(roleList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "RoleList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<List<Role>>> AllRoleList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var roleList = await _roleService.AllRoleList();
|
||||||
|
return Ok(roleList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "AllRoleList Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> RoleById([FromBody] Guid Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var role = await _roleService.GetByIdAsync(Id).ConfigureAwait(false);
|
||||||
|
return Ok(role);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "RoleById Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<List<Guid>>> RoleMenus([FromBody] Guid Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var roleMenus = await _userMenuInRoleService.SelectRoleUserMenuIdsInRoles(Id).ConfigureAwait(false);
|
||||||
|
return Ok(roleMenus);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "RoleMenus Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult> DeleteRole([FromBody] Guid Id)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//¿ªÊ¼ÊÂÎñ
|
||||||
|
await _roleService.Context.Ado.BeginTranAsync();
|
||||||
|
var isOK = await _roleService.DeleteByIdAsync(Id);
|
||||||
|
await _userMenuInRoleService.DeleteRoleUserMenuInRoles(Id);
|
||||||
|
//Ìá½»ÊÂÎñ
|
||||||
|
await _roleService.Context.Ado.CommitTranAsync();
|
||||||
|
return Ok(isOK);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//Òì³£ÊÂÎñ»Ø¹ö
|
||||||
|
await _roleService.Context.Ado.RollbackTranAsync();
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "DeleteRole Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -8,7 +8,7 @@ using System.Text.Json;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using File = System.IO.File;
|
using File = System.IO.File;
|
||||||
|
|
||||||
namespace XPrintServer.Api.Controllers
|
namespace XPrintServer.Admin.Api.Controllers
|
||||||
{
|
{
|
||||||
|
|
||||||
[Route("api/[controller]/[action]")]
|
[Route("api/[controller]/[action]")]
|
||||||
|
|||||||
@ -141,7 +141,7 @@ namespace XPrintServer.Api.Controllers.Common
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
//查询12个月的已支付订单
|
//查询12个月的已支付订单
|
||||||
var isOK = await _orderService.BatchChangeOrderStatusToProductionFinish(orderIds);
|
var isOK = await _orderService.BatchChangeOrderStatusToProductionStatus(orderIds, OrderStatus.ProductionFinish);
|
||||||
return Ok(isOK);
|
return Ok(isOK);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@ -38,9 +38,15 @@ namespace XPrintServer.Api.Controllers.Common
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var now = DateTime.Now;
|
//var now = DateTime.Now;
|
||||||
//查询12个月的已支付订单
|
//if (pageData.StartTime == null)
|
||||||
var infoResult = await _orderInfoService.GetOrderInfoListForTime(pageData, now.AddMonths(-12), now);
|
//{
|
||||||
|
// pageData.StartTime = now.AddDays(-7);
|
||||||
|
// pageData.EndTime = now;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//查询一周内的已支付订单
|
||||||
|
var infoResult = await _orderInfoService.GetOrderInfoListForTime(pageData, pageData.StartTime, pageData.EndTime);
|
||||||
return Ok(infoResult);
|
return Ok(infoResult);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -64,8 +70,36 @@ namespace XPrintServer.Api.Controllers.Common
|
|||||||
//开始事务
|
//开始事务
|
||||||
await _orderService.Context.Ado.BeginTranAsync();
|
await _orderService.Context.Ado.BeginTranAsync();
|
||||||
//查询12个月的已支付订单
|
//查询12个月的已支付订单
|
||||||
var finishOrderIds = await _orderInfoService.BatchChangeOrderInfoStatusToProductionFinish(orderInfoIds);
|
var finishOrderIds = await _orderInfoService.BatchChangeOrderInfoStatusToProductionFinish(orderInfoIds, ResourceStatus.ProductionFinish);
|
||||||
bool isOK = await _orderService.BatchChangeOrderStatusToProductionFinish(finishOrderIds);
|
bool isOK = await _orderService.BatchChangeOrderStatusToProductionStatus(finishOrderIds, OrderStatus.ProductionFinish);
|
||||||
|
|
||||||
|
//提交事务
|
||||||
|
await _orderService.Context.Ado.CommitTranAsync();
|
||||||
|
return Ok(isOK);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await _orderService.Context.Ado.RollbackTranAsync();
|
||||||
|
await _actionLogService.AddActionLog(new ActionLog { Title = "ProductionBatchFinish Error", Content = ex.Message + " " + ex.StackTrace, DateTime = DateTime.Now });
|
||||||
|
return StatusCode(500, ex.Message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量更改资源状态为已生产
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageData"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public async Task<ActionResult<bool>> ProductionBatchDelete([FromBody] HashSet<Guid> orderInfoIds)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//开始事务
|
||||||
|
await _orderService.Context.Ado.BeginTranAsync();
|
||||||
|
//查询已支付订单
|
||||||
|
var finishOrderIds = await _orderInfoService.BatchChangeOrderInfoStatusToProductionFinish(orderInfoIds, ResourceStatus.Delete);
|
||||||
|
bool isOK = await _orderService.BatchChangeOrderStatusToProductionStatus(finishOrderIds, OrderStatus.ProductionFinish);
|
||||||
|
|
||||||
//提交事务
|
//提交事务
|
||||||
await _orderService.Context.Ado.CommitTranAsync();
|
await _orderService.Context.Ado.CommitTranAsync();
|
||||||
|
|||||||
@ -39,7 +39,7 @@ namespace XPrintServer.Api.Controllers
|
|||||||
public void TestImage()
|
public void TestImage()
|
||||||
{
|
{
|
||||||
//SvgTool.ImageToSvg();
|
//SvgTool.ImageToSvg();
|
||||||
//CmykImageTool.SplitColor(@"D:\±ù¶Õ¶Õ.png", @"D:\±ù¶Õ¶ÕOutput.tif");
|
ChannelImageTool.SplitColor(@"D:\òáòæ.tif", @"D:\111.tif");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,6 +25,9 @@
|
|||||||
<None Update="assets\8bim_alpha">
|
<None Update="assets\8bim_alpha">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
<None Update="assets\8bim_white_channel">
|
||||||
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
|
</None>
|
||||||
<None Update="assets\Aspose.Total.NET.lic">
|
<None Update="assets\Aspose.Total.NET.lic">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</None>
|
||||||
|
|||||||
BIN
XPrintServer.Api/assets/8bim_white_channel
Normal file
BIN
XPrintServer.Api/assets/8bim_white_channel
Normal file
Binary file not shown.
14
XPrintServer.Business/Dto/MenuTreeData.cs
Normal file
14
XPrintServer.Business/Dto/MenuTreeData.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Business.Dto
|
||||||
|
{
|
||||||
|
public class MenuTreeData : Menu
|
||||||
|
{
|
||||||
|
public List<MenuTreeData> Children { get; set; } = new List<MenuTreeData>();
|
||||||
|
}
|
||||||
|
}
|
||||||
16
XPrintServer.Business/Dto/RoleInfo.cs
Normal file
16
XPrintServer.Business/Dto/RoleInfo.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Business.Dto
|
||||||
|
{
|
||||||
|
public class RoleInfo
|
||||||
|
{
|
||||||
|
public Role Role { get; set; } = null!;
|
||||||
|
|
||||||
|
public List<Guid> MenuIds { get; set; } = new List<Guid>();
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -13,5 +13,9 @@ namespace XPrintServer.Business.Enums
|
|||||||
/// 订单状态
|
/// 订单状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public OrderStatus Status { get; set; } = OrderStatus.None;
|
public OrderStatus Status { get; set; } = OrderStatus.None;
|
||||||
|
|
||||||
|
public DateTime? StartTime { get; set; } = null;
|
||||||
|
|
||||||
|
public DateTime? EndTime { get; set; } = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using SqlSugar;
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
|
using SqlSugar;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -45,5 +46,18 @@ namespace XPrintServer.Business.Services
|
|||||||
}
|
}
|
||||||
return dbUser;
|
return dbUser;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<PageResult<BackstageUser>> GetBackstageUserList(PageData pageData)
|
||||||
|
{
|
||||||
|
var userList = await Context.Queryable<BackstageUser>().WhereIF(!string.IsNullOrEmpty(pageData.SearchText), bu => bu.UserName.Contains(pageData.SearchText)
|
||||||
|
|| bu.NickName == null ? false : bu.NickName.Contains(pageData.SearchText)).SplitTable()
|
||||||
|
.ToPageListAsync(pageData.Page, pageData.PageSize).ConfigureAwait(false);
|
||||||
|
return new PageResult<BackstageUser>
|
||||||
|
{
|
||||||
|
Data = userList,
|
||||||
|
PageSize = pageData.PageSize,
|
||||||
|
Total = await Context.Queryable<BackstageUser>().SplitTable().CountAsync().ConfigureAwait(false)
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
56
XPrintServer.Business/Services/MenuService.cs
Normal file
56
XPrintServer.Business/Services/MenuService.cs
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
|
using CrazyStudio.Core.Common.Tools.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using XPrintServer.Business.Services.Interface;
|
||||||
|
using XPrintServer.DataModel;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Business.Services
|
||||||
|
{
|
||||||
|
public class MenuService : SqlSugarRepository<Menu>, IBusinessService
|
||||||
|
{
|
||||||
|
public MenuService(ConnectionConfig config) : base(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddOrUpdateMenu(Menu menu)
|
||||||
|
{
|
||||||
|
if (menu.ParentId.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
menu.ParentId = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menu.Id.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
await Context.Insertable(menu).ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Context.Updateable(menu).ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PageResult<Menu>> GetMenuList(PageData pageData, bool isCheckActive)
|
||||||
|
{
|
||||||
|
var menuList = await Context.Queryable<Menu>().WhereIF(isCheckActive, m => m.IsActive)
|
||||||
|
.ToPageListAsync(pageData.Page, pageData.PageSize).ConfigureAwait(false);
|
||||||
|
return new PageResult<Menu>
|
||||||
|
{
|
||||||
|
Data = menuList,
|
||||||
|
PageSize = pageData.PageSize,
|
||||||
|
Total = await Context.Queryable<Menu>().WhereIF(isCheckActive, m => m.IsActive).CountAsync().ConfigureAwait(false)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Menu> GetMenu(Guid Id)
|
||||||
|
{
|
||||||
|
var menu = await Context.Queryable<Menu>().Where(m => m.Id == Id).FirstAsync().ConfigureAwait(false);
|
||||||
|
return menu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -68,7 +68,13 @@ namespace XPrintServer.Business.Services
|
|||||||
//infoQuery = infoQuery.InnerJoin(orderQuery, (info, order) => info.OrderId == order.Id);
|
//infoQuery = infoQuery.InnerJoin(orderQuery, (info, order) => info.OrderId == order.Id);
|
||||||
|
|
||||||
|
|
||||||
var infoList = await infoQuery!.Where(i => i.ResourceStatus == (int)ResourceStatus.WaitProduction).Select(info => info).OrderByDescending(info => info.SubmitTime).ToPageListAsync(pageData.Page, pageData.PageSize).ConfigureAwait(false);
|
var infoList = await infoQuery!
|
||||||
|
|
||||||
|
.WhereIF(pageData.StartTime != null, i => i.SubmitTime >= pageData.StartTime)
|
||||||
|
.WhereIF(pageData.EndTime != null, i => i.SubmitTime <= pageData.EndTime)
|
||||||
|
.Where(i => i.ResourceStatus != (int)ResourceStatus.Delete)
|
||||||
|
|
||||||
|
.Select(info => info).OrderByDescending(info => info.SubmitTime).ToPageListAsync(pageData.Page, pageData.PageSize).ConfigureAwait(false);
|
||||||
return new PageResult<OrderInfo>
|
return new PageResult<OrderInfo>
|
||||||
{
|
{
|
||||||
Data = infoList,
|
Data = infoList,
|
||||||
@ -101,11 +107,11 @@ namespace XPrintServer.Business.Services
|
|||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 批量更改支付资源状态为已生产完成
|
/// 批量更改支付资源状态为已指定状态
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="orderInfoIds">返回全部资源生产完成的订单</param>
|
/// <param name="orderInfoIds">返回全部资源生产完成的订单</param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<HashSet<Guid>> BatchChangeOrderInfoStatusToProductionFinish(HashSet<Guid> orderInfoIds)
|
public async Task<HashSet<Guid>> BatchChangeOrderInfoStatusToProductionFinish(HashSet<Guid> orderInfoIds, ResourceStatus resourceStatus = ResourceStatus.ProductionFinish)
|
||||||
{
|
{
|
||||||
var orderInfos = await Context.Queryable<OrderInfo>().Where(o => orderInfoIds.Contains(o.Id)).SplitTable().ToListAsync().ConfigureAwait(false);
|
var orderInfos = await Context.Queryable<OrderInfo>().Where(o => orderInfoIds.Contains(o.Id)).SplitTable().ToListAsync().ConfigureAwait(false);
|
||||||
|
|
||||||
@ -113,9 +119,9 @@ namespace XPrintServer.Business.Services
|
|||||||
for (int i = 0; i < orderInfos.Count; i++)
|
for (int i = 0; i < orderInfos.Count; i++)
|
||||||
{
|
{
|
||||||
var info = orderInfos[i];
|
var info = orderInfos[i];
|
||||||
if (info.ResourceStatus == (int)ResourceStatus.WaitProduction || info.ResourceStatus == (int)OrderStatus.InProduction)//order.OrderStatus == (int)OrderStatus.Unpaid Debug
|
if (info.ResourceStatus == (int)ResourceStatus.WaitProduction || info.ResourceStatus == (int)OrderStatus.InProduction || info.ResourceStatus == (int)OrderStatus.ProductionFinish)//order.OrderStatus == (int)OrderStatus.Unpaid Debug
|
||||||
{
|
{
|
||||||
info.ResourceStatus = (int)ResourceStatus.ProductionFinish;
|
info.ResourceStatus = (int)resourceStatus;
|
||||||
if (!orderIds.Contains(info.OrderId))
|
if (!orderIds.Contains(info.OrderId))
|
||||||
{
|
{
|
||||||
orderIds.Add(info.OrderId);
|
orderIds.Add(info.OrderId);
|
||||||
|
|||||||
@ -43,7 +43,7 @@ namespace XPrintServer.Business.Services
|
|||||||
/// <param name="orderId"></param>
|
/// <param name="orderId"></param>
|
||||||
/// <param name="status"></param>
|
/// <param name="status"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<bool> BatchChangeOrderStatusToProductionFinish(HashSet<Guid> orderIds)
|
public async Task<bool> BatchChangeOrderStatusToProductionStatus(HashSet<Guid> orderIds, OrderStatus orderStatus)
|
||||||
{
|
{
|
||||||
var orders = await Context.Queryable<Order>().Where(o => orderIds.Contains(o.Id)).SplitTable().ToListAsync().ConfigureAwait(false);
|
var orders = await Context.Queryable<Order>().Where(o => orderIds.Contains(o.Id)).SplitTable().ToListAsync().ConfigureAwait(false);
|
||||||
bool isOK = false;
|
bool isOK = false;
|
||||||
@ -54,7 +54,7 @@ namespace XPrintServer.Business.Services
|
|||||||
var order = orders[i];
|
var order = orders[i];
|
||||||
if (order.OrderStatus == (int)OrderStatus.Paid || order.OrderStatus == (int)OrderStatus.Unpaid)//order.OrderStatus == (int)OrderStatus.Unpaid Debug
|
if (order.OrderStatus == (int)OrderStatus.Paid || order.OrderStatus == (int)OrderStatus.Unpaid)//order.OrderStatus == (int)OrderStatus.Unpaid Debug
|
||||||
{
|
{
|
||||||
order.OrderStatus = (int)OrderStatus.ProductionFinish;
|
order.OrderStatus = (int)orderStatus;
|
||||||
isOK = true;
|
isOK = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
58
XPrintServer.Business/Services/RoleService.cs
Normal file
58
XPrintServer.Business/Services/RoleService.cs
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
using CrazyStudio.Core.Common.Eitities.Page;
|
||||||
|
using CrazyStudio.Core.Common.Tools.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using XPrintServer.Business.Services.Interface;
|
||||||
|
using XPrintServer.DataModel;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Business.Services
|
||||||
|
{
|
||||||
|
public class RoleService : SqlSugarRepository<Role>, IBusinessService
|
||||||
|
{
|
||||||
|
public RoleService(ConnectionConfig config) : base(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task AddOrUpdateRole(Role role)
|
||||||
|
{
|
||||||
|
if (role.Id.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
await Context.Insertable(role).ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
await Context.Updateable(role).ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<PageResult<Role>> GetRoleList(PageData pageData)
|
||||||
|
{
|
||||||
|
var roleList = await Context.Queryable<Role>()
|
||||||
|
.ToPageListAsync(pageData.Page, pageData.PageSize).ConfigureAwait(false);
|
||||||
|
return new PageResult<Role>
|
||||||
|
{
|
||||||
|
Data = roleList,
|
||||||
|
PageSize = pageData.PageSize,
|
||||||
|
Total = await Context.Queryable<Role>().CountAsync().ConfigureAwait(false)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Role>> AllRoleList()
|
||||||
|
{
|
||||||
|
var roleList = await Context.Queryable<Role>()
|
||||||
|
.ToListAsync().ConfigureAwait(false);
|
||||||
|
return roleList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<Role> GetRole(Guid Id)
|
||||||
|
{
|
||||||
|
var role = await Context.Queryable<Role>().Where(m => m.Id == Id).FirstAsync().ConfigureAwait(false);
|
||||||
|
return role;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
XPrintServer.Business/Services/UserMenuInRoleService.cs
Normal file
63
XPrintServer.Business/Services/UserMenuInRoleService.cs
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
using CrazyStudio.Core.Common.Tools.Extensions;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using XPrintServer.Business.Services.Interface;
|
||||||
|
using XPrintServer.DataModel;
|
||||||
|
using XPrintServer.DataModel.Models;
|
||||||
|
|
||||||
|
namespace XPrintServer.Business.Services
|
||||||
|
{
|
||||||
|
public class UserMenuInRoleService : SqlSugarRepository<UserMenuInRole>, IBusinessService
|
||||||
|
{
|
||||||
|
public UserMenuInRoleService(ConnectionConfig config) : base(config)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task AddOrUpdateUserMenuInRoles(Guid roleId, List<Guid> menuIds)
|
||||||
|
{
|
||||||
|
if (!roleId.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
await DeleteRoleUserMenuInRoles(roleId);
|
||||||
|
if (menuIds.Any())
|
||||||
|
{
|
||||||
|
List<UserMenuInRole> addList = new List<UserMenuInRole>();
|
||||||
|
DateTime now = DateTime.Now;
|
||||||
|
foreach (var menuId in menuIds)
|
||||||
|
{
|
||||||
|
addList.Add(new UserMenuInRole
|
||||||
|
{
|
||||||
|
RoleId = roleId,
|
||||||
|
CreateTime = now,
|
||||||
|
MenuId = menuId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
await Context.Insertable(addList).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task DeleteRoleUserMenuInRoles(Guid roleId)
|
||||||
|
{
|
||||||
|
if (!roleId.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
var deleteDatas = await Context.Queryable<UserMenuInRole>().Where(r => r.RoleId == roleId).SplitTable().ToListAsync().ConfigureAwait(false);
|
||||||
|
await Context.Deleteable(deleteDatas).SplitTable().ExecuteCommandAsync().ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<Guid>> SelectRoleUserMenuIdsInRoles(Guid roleId)
|
||||||
|
{
|
||||||
|
if (!roleId.IsNullOrGuidEmpty())
|
||||||
|
{
|
||||||
|
var menuIds = await Context.Queryable<UserMenuInRole>().Where(r => r.RoleId == roleId).SplitTable().Select(r => r.MenuId).ToListAsync().ConfigureAwait(false);
|
||||||
|
return menuIds;
|
||||||
|
}
|
||||||
|
return new List<Guid>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -38,7 +38,7 @@ namespace XPrintServer.Business.Workflows
|
|||||||
// // 1. 加载工作流JSON文件
|
// // 1. 加载工作流JSON文件
|
||||||
// workflowJson = File.ReadAllText(_createImageworkflowPath);
|
// workflowJson = File.ReadAllText(_createImageworkflowPath);
|
||||||
//}
|
//}
|
||||||
if (string.IsNullOrWhiteSpace(workflowJson))
|
if (string.IsNullOrWhiteSpace(workflowJson) && !string.IsNullOrWhiteSpace(workflowPath))
|
||||||
{
|
{
|
||||||
workflowJson = File.ReadAllText(workflowPath);
|
workflowJson = File.ReadAllText(workflowPath);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -33,7 +33,7 @@ namespace XPrintServer.DataModel.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:用户名
|
/// Desc:用户名
|
||||||
/// Default:
|
/// Default:
|
||||||
/// Nullable:True
|
/// Nullable:False
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Key("UserName")]
|
[Key("UserName")]
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "用户名")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "用户名")]
|
||||||
@ -42,7 +42,7 @@ namespace XPrintServer.DataModel.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:Password
|
/// Desc:Password
|
||||||
/// Default:
|
/// Default:
|
||||||
/// Nullable:True
|
/// Nullable:False
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Key("Password")]
|
[Key("Password")]
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "用户密码")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "用户密码")]
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
using SqlSugar;
|
using SqlSugar;
|
||||||
|
using StackExchange.Redis;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -10,6 +11,8 @@ namespace XPrintServer.DataModel.Models
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 菜单表
|
/// 菜单表
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
[SugarIndex("idx_ids", nameof(ParentId), OrderByType.Desc)]
|
||||||
|
[SugarIndex("idx_menu_name", nameof(MenuName), OrderByType.Desc)]
|
||||||
//[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
//[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
||||||
//[SugarTable("menu_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
//[SugarTable("menu_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
||||||
public class Menu
|
public class Menu
|
||||||
@ -22,17 +25,44 @@ namespace XPrintServer.DataModel.Models
|
|||||||
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键Id")]
|
[SugarColumn(IsPrimaryKey = true, ColumnDescription = "主键Id")]
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
[SugarColumn(IsNullable = true, ColumnDescription = "父级Id,Null则为顶级菜单")]
|
[SugarColumn(IsNullable = true, DefaultValue = null, ColumnDescription = "父级Id,Null则为顶级菜单")]
|
||||||
public Guid? ParentId { get; set; } = null;
|
public Guid? ParentId { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:用户名
|
/// Desc:菜单名称
|
||||||
/// Default:
|
/// Default:
|
||||||
/// Nullable:False
|
/// Nullable:False
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(IsNullable = false, ColumnDescription = "菜单名")]
|
[SugarColumn(IsNullable = false, ColumnDescription = "菜单名称")]
|
||||||
public string MenuName { get; set; } = null!;
|
public string MenuName { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:路由名称
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "路由名称")]
|
||||||
|
public string RouteName { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:组件路径
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "组件路径")]
|
||||||
|
public string ComponentPath { get; set; } = null!;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:是否启用
|
||||||
|
/// Default:
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(IsNullable = false, ColumnDescription = "是否启用")]
|
||||||
|
public bool IsActive { get; set; } = false;
|
||||||
|
|
||||||
///// <summary>
|
///// <summary>
|
||||||
///// 分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表
|
///// 分表字段 在插入的时候会根据这个字段插入哪个表,在更新删除的时候用这个字段找出相关表
|
||||||
///// </summary>
|
///// </summary>
|
||||||
|
|||||||
@ -58,6 +58,15 @@ namespace XPrintServer.DataModel.Models
|
|||||||
public string? ModelPictureUrl { get; set; } = null;
|
public string? ModelPictureUrl { get; set; } = null;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Desc:模型场景Y坐标偏移值
|
||||||
|
/// Nullable:False
|
||||||
|
/// </summary>
|
||||||
|
[Key("OffsetY")]
|
||||||
|
[SugarColumn(IsNullable = false, DefaultValue = "0", ColumnDescription = "模型场景Y坐标偏移值")]
|
||||||
|
public float OffsetY { get; set; } = 0f;
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Desc:摄像头最小可视范围
|
/// Desc:摄像头最小可视范围
|
||||||
/// Nullable:False
|
/// Nullable:False
|
||||||
|
|||||||
@ -11,6 +11,7 @@ namespace XPrintServer.DataModel.Models
|
|||||||
///<summary>
|
///<summary>
|
||||||
///角色表
|
///角色表
|
||||||
///</summary>
|
///</summary>
|
||||||
|
[SugarIndex("idx_role_name", nameof(RoleName), OrderByType.Desc)]
|
||||||
//[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
//[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
||||||
//[SugarTable("role_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
//[SugarTable("role_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
||||||
public partial class Role
|
public partial class Role
|
||||||
|
|||||||
@ -11,6 +11,8 @@ namespace XPrintServer.DataModel.Models
|
|||||||
///<summary>
|
///<summary>
|
||||||
///用户角色的菜单表
|
///用户角色的菜单表
|
||||||
///</summary>
|
///</summary>
|
||||||
|
[SugarIndex("idx_{split_table}_create_time", nameof(CreateTime), OrderByType.Desc)]
|
||||||
|
[SugarIndex("idx_{split_table}_ids", [nameof(MenuId), nameof(RoleId)], [OrderByType.Desc, OrderByType.Desc])]
|
||||||
[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
[SplitTable(SplitType.Year)]//按年分表 (自带分表支持 年、季、月、周、日)
|
||||||
[SugarTable("user_menu_in_role_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
[SugarTable("user_menu_in_role_{year}{month}{day}")]//3个变量必须要有,这么设计为了兼容开始按年,后面改成按月、按日
|
||||||
public partial class UserMenuInRole
|
public partial class UserMenuInRole
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user