mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-07-17 10:42:08 +08:00
#I7A7YE 建议加入打印功能
This commit is contained in:
parent
319986ae1c
commit
852d52436a
@ -0,0 +1,63 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// This code was generated by a CodeSmith Template.
|
||||||
|
//
|
||||||
|
// DO NOT MODIFY contents of this file. Changes to this
|
||||||
|
// file will be lost if the code is regenerated.
|
||||||
|
// Author:Yubao Li
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using OpenAuth.Repository.Core;
|
||||||
|
|
||||||
|
namespace OpenAuth.App.Request
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public class AddOrUpdateSysPrinterPlanReq
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///方案名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///方案ID
|
||||||
|
/// </summary>
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///创建人
|
||||||
|
/// </summary>
|
||||||
|
public string CreateUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///数据源;打印方案对应的数据来源SQL
|
||||||
|
/// </summary>
|
||||||
|
public string SourceSql { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///中文视图名;设计打印方案时,提供中文快捷按钮的视图来源
|
||||||
|
/// </summary>
|
||||||
|
public string CloumnView { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///打印方案内容;打印方案JSON对象
|
||||||
|
/// </summary>
|
||||||
|
public string PlanContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///创建日期
|
||||||
|
/// </summary>
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///是否可用
|
||||||
|
/// </summary>
|
||||||
|
public bool Disable { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,7 @@
|
|||||||
|
namespace OpenAuth.App.Request
|
||||||
|
{
|
||||||
|
public class QuerySysPrinterPlanListReq : PageReq
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
75
OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs
Normal file
75
OpenAuth.App/SysPrinterPlanApp/SysPrinterPlanApp.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Infrastructure;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using OpenAuth.App.Interface;
|
||||||
|
using OpenAuth.App.Request;
|
||||||
|
using OpenAuth.App.Response;
|
||||||
|
using OpenAuth.Repository;
|
||||||
|
using OpenAuth.Repository.Domain;
|
||||||
|
using OpenAuth.Repository.Interface;
|
||||||
|
|
||||||
|
|
||||||
|
namespace OpenAuth.App
|
||||||
|
{
|
||||||
|
public class SysPrinterPlanApp : BaseStringApp<SysPrinterPlan, OpenAuthDBContext>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 加载列表
|
||||||
|
/// </summary>
|
||||||
|
public async Task<TableData> Load(QuerySysPrinterPlanListReq request)
|
||||||
|
{
|
||||||
|
var loginContext = _auth.GetCurrentUser();
|
||||||
|
if (loginContext == null)
|
||||||
|
{
|
||||||
|
throw new CommonException("登录已过期", Define.INVALID_TOKEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
var columnFields = loginContext.GetTableColumns("SysPrinterPlan");
|
||||||
|
if (columnFields == null || columnFields.Count == 0)
|
||||||
|
{
|
||||||
|
throw new Exception("请在代码生成界面配置SysPrinterPlan表的字段属性");
|
||||||
|
}
|
||||||
|
|
||||||
|
var result = new TableData();
|
||||||
|
var objs = GetDataPrivilege("u");
|
||||||
|
if (!string.IsNullOrEmpty(request.key))
|
||||||
|
{
|
||||||
|
//增加筛选条件,如:
|
||||||
|
objs = objs.Where(u => u.Name.Contains(request.key));
|
||||||
|
}
|
||||||
|
|
||||||
|
var propertyStr = string.Join(',', columnFields.Select(u => u.ColumnName));
|
||||||
|
result.columnFields = columnFields;
|
||||||
|
result.data = objs.OrderBy(u => u.Id)
|
||||||
|
.Skip((request.page - 1) * request.limit)
|
||||||
|
.Take(request.limit).Select($"new ({propertyStr})");
|
||||||
|
result.count = await objs.CountAsync();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Add(AddOrUpdateSysPrinterPlanReq obj)
|
||||||
|
{
|
||||||
|
//程序类型取入口应用的名称,可以根据自己需要调整
|
||||||
|
var addObj = obj.MapTo<SysPrinterPlan>();
|
||||||
|
//addObj.Time = DateTime.Now;
|
||||||
|
Repository.Add(addObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Update(AddOrUpdateSysPrinterPlanReq obj)
|
||||||
|
{
|
||||||
|
UnitWork.Update<SysPrinterPlan>(u => u.Id == obj.Id, u => new SysPrinterPlan
|
||||||
|
{
|
||||||
|
Name = obj.Name,
|
||||||
|
SourceSql = obj.SourceSql,
|
||||||
|
PlanContent = obj.PlanContent
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysPrinterPlanApp(IUnitWork<OpenAuthDBContext> unitWork,
|
||||||
|
IRepository<SysPrinterPlan, OpenAuthDBContext> repository, IAuth auth) : base(unitWork, repository, auth)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
75
OpenAuth.Repository/Domain/SysPrinterPlan.cs
Normal file
75
OpenAuth.Repository/Domain/SysPrinterPlan.cs
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// This code was generated by a CodeSmith Template.
|
||||||
|
//
|
||||||
|
// DO NOT MODIFY contents of this file. Changes to this
|
||||||
|
// file will be lost if the code is regenerated.
|
||||||
|
// Author:Yubao Li
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
using OpenAuth.Repository.Core;
|
||||||
|
|
||||||
|
namespace OpenAuth.Repository.Domain
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
[Table("SysPrinterPlan")]
|
||||||
|
public class SysPrinterPlan : StringEntity
|
||||||
|
{
|
||||||
|
public SysPrinterPlan()
|
||||||
|
{
|
||||||
|
this.Name = "";
|
||||||
|
this.CreateUser = "";
|
||||||
|
this.SourceSql = "";
|
||||||
|
this.CloumnView = "";
|
||||||
|
this.PlanContent = "";
|
||||||
|
this.CreateTime = DateTime.Now;
|
||||||
|
this.Disable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///方案名称
|
||||||
|
/// </summary>
|
||||||
|
[Description("方案名称")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///创建人
|
||||||
|
/// </summary>
|
||||||
|
[Description("创建人")]
|
||||||
|
public string CreateUser { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///数据源;打印方案对应的数据来源SQL
|
||||||
|
/// </summary>
|
||||||
|
[Description("数据源;打印方案对应的数据来源SQL")]
|
||||||
|
public string SourceSql { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///中文视图名;设计打印方案时,提供中文快捷按钮的视图来源
|
||||||
|
/// </summary>
|
||||||
|
[Description("中文视图名;设计打印方案时,提供中文快捷按钮的视图来源")]
|
||||||
|
public string CloumnView { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///打印方案内容;打印方案JSON对象
|
||||||
|
/// </summary>
|
||||||
|
[Description("打印方案内容;打印方案JSON对象")]
|
||||||
|
public string PlanContent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///创建日期
|
||||||
|
/// </summary>
|
||||||
|
[Description("创建日期")]
|
||||||
|
public DateTime CreateTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///是否可用
|
||||||
|
/// </summary>
|
||||||
|
[Description("是否可用")]
|
||||||
|
public bool Disable { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using Infrastructure;
|
using Infrastructure;
|
||||||
@ -102,13 +102,10 @@ namespace OpenAuth.Repository
|
|||||||
public virtual DbSet<Role> Roles { get; set; }
|
public virtual DbSet<Role> Roles { get; set; }
|
||||||
public virtual DbSet<User> Users { get; set; }
|
public virtual DbSet<User> Users { get; set; }
|
||||||
public virtual DbSet<UploadFile> UploadFiles { get; set; }
|
public virtual DbSet<UploadFile> UploadFiles { get; set; }
|
||||||
|
public virtual DbSet<SysPrinterPlan> SysPrinterPlans { get; set; }
|
||||||
public virtual DbSet<FrmLeaveReq> FrmLeaveReqs { get; set; }
|
public virtual DbSet<FrmLeaveReq> FrmLeaveReqs { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<SysLog> SysLogs { get; set; }
|
public virtual DbSet<SysLog> SysLogs { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<SysMessage> SysMessages { get; set; }
|
public virtual DbSet<SysMessage> SysMessages { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<DataPrivilegeRule> DataPrivilegeRules { get; set; }
|
public virtual DbSet<DataPrivilegeRule> DataPrivilegeRules { get; set; }
|
||||||
|
|
||||||
public virtual DbSet<WmsInboundOrderDtbl> WmsInboundOrderDtbls { get; set; }
|
public virtual DbSet<WmsInboundOrderDtbl> WmsInboundOrderDtbls { get; set; }
|
||||||
@ -120,5 +117,8 @@ namespace OpenAuth.Repository
|
|||||||
public virtual DbSet<QueryStringObj> QueryStringObjs { get; set; }
|
public virtual DbSet<QueryStringObj> QueryStringObjs { get; set; }
|
||||||
public virtual DbSet<SysTableColumn> SysTableColumns { get; set; }
|
public virtual DbSet<SysTableColumn> SysTableColumns { get; set; }
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
113
OpenAuth.WebApi/Controllers/SysPrinterPlansController.cs
Normal file
113
OpenAuth.WebApi/Controllers/SysPrinterPlansController.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Infrastructure;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using OpenAuth.App;
|
||||||
|
using OpenAuth.App.Request;
|
||||||
|
using OpenAuth.App.Response;
|
||||||
|
using OpenAuth.Repository.Domain;
|
||||||
|
|
||||||
|
namespace OpenAuth.WebApi.Controllers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 打印模板接口
|
||||||
|
/// </summary>
|
||||||
|
[Route("api/[controller]/[action]")]
|
||||||
|
[ApiController]
|
||||||
|
[ApiExplorerSettings(GroupName = "打印模板接口_SysPrinterPlans")]
|
||||||
|
public class SysPrinterPlansController : ControllerBase
|
||||||
|
{
|
||||||
|
private readonly SysPrinterPlanApp _app;
|
||||||
|
|
||||||
|
//获取详情
|
||||||
|
[HttpGet]
|
||||||
|
public Response<SysPrinterPlan> Get(string id)
|
||||||
|
{
|
||||||
|
var result = new Response<SysPrinterPlan>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
result.Result = _app.Get(id);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//添加
|
||||||
|
[HttpPost]
|
||||||
|
public Response Add(AddOrUpdateSysPrinterPlanReq obj)
|
||||||
|
{
|
||||||
|
var result = new Response();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.Add(obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改
|
||||||
|
[HttpPost]
|
||||||
|
public Response Update(AddOrUpdateSysPrinterPlanReq obj)
|
||||||
|
{
|
||||||
|
var result = new Response();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.Update(obj);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载列表
|
||||||
|
/// </summary>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<TableData> Load([FromQuery]QuerySysPrinterPlanListReq request)
|
||||||
|
{
|
||||||
|
return await _app.Load(request);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量删除
|
||||||
|
/// </summary>
|
||||||
|
[HttpPost]
|
||||||
|
public Response Delete([FromBody]string[] ids)
|
||||||
|
{
|
||||||
|
var result = new Response();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
_app.Delete(ids);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
result.Code = 500;
|
||||||
|
result.Message = ex.InnerException?.Message ?? ex.Message;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysPrinterPlansController(SysPrinterPlanApp app)
|
||||||
|
{
|
||||||
|
_app = app;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user