|
|
|
@ -12,6 +12,7 @@ using DS.Module.SqlSugar;
|
|
|
|
|
using DS.WMS.Core.Code.Entity;
|
|
|
|
|
using Org.BouncyCastle.Ocsp;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Masuit.Tools.Strings;
|
|
|
|
|
|
|
|
|
|
namespace DS.WMS.Core.Sys.Method
|
|
|
|
|
{
|
|
|
|
@ -96,29 +97,71 @@ namespace DS.WMS.Core.Sys.Method
|
|
|
|
|
.First();
|
|
|
|
|
return DataResult<SysPrintTemplateRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
|
|
|
|
|
}
|
|
|
|
|
public DataResult EditSysPrintTemplate(SysPrintTemplateReq req)
|
|
|
|
|
|
|
|
|
|
public async Task<DataResult> EditSysPrintTemplate(SysPrintTemplateReq req)
|
|
|
|
|
{
|
|
|
|
|
if (req.Id == 0)
|
|
|
|
|
{
|
|
|
|
|
var isExist = db.Queryable<SysPrintTemplate>().Where(x => x.TemplateCode == req.TemplateCode).WhereIF(req.CarrierId != 0, x => x.CarrierId == req.CarrierId).First();
|
|
|
|
|
if (isExist != null)
|
|
|
|
|
if (db.Queryable<SysPrintTemplate>().Where(x => x.TemplateCode == req.TemplateCode).WhereIF(req.CarrierId != 0, x => x.CarrierId == req.CarrierId).Any())
|
|
|
|
|
{
|
|
|
|
|
return DataResult.Failed("打印模板唯一编码已存在!");
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("打印模板唯一编码已存在!"));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (req.IsUseDataSource) {
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(req.SourceSql))
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("打印数据源不能为空!"));
|
|
|
|
|
}
|
|
|
|
|
if (!req.SourceSql.Contains(';'))
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("数据源必须包含分号!"));
|
|
|
|
|
}
|
|
|
|
|
if (req.SourceSql.Substring(req.SourceSql.Length - 1, 1) != ";")
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("数据源最后必须包含分号!"));
|
|
|
|
|
}
|
|
|
|
|
if (req.SourceSql.IsSqlInjection())
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("sql数据源包含非法字符,请检查!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var data = req.Adapt<SysPrintTemplate>();
|
|
|
|
|
|
|
|
|
|
var entity = db.Insertable(data).ExecuteReturnEntity();
|
|
|
|
|
var entity = await db.Insertable(data).ExecuteReturnEntityAsync();
|
|
|
|
|
|
|
|
|
|
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
var info = db.Queryable<SysPrintTemplate>().Where(x => x.Id == req.Id).First();
|
|
|
|
|
var info = await db.Queryable<SysPrintTemplate>().Where(x => x.Id == req.Id).FirstAsync();
|
|
|
|
|
|
|
|
|
|
if (req.IsUseDataSource)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(req.SourceSql))
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("打印数据源不能为空!"));
|
|
|
|
|
}
|
|
|
|
|
if (!req.SourceSql.Contains(';'))
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("数据源必须包含分号!"));
|
|
|
|
|
}
|
|
|
|
|
if (req.SourceSql.Substring(req.SourceSql.Length - 1, 1) != ";")
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("数据源最后必须包含分号!"));
|
|
|
|
|
}
|
|
|
|
|
if (req.SourceSql.IsSqlInjection())
|
|
|
|
|
{
|
|
|
|
|
return await Task.FromResult(DataResult.Failed("sql数据源包含非法字符,请检查!"));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
info = req.Adapt(info);
|
|
|
|
|
|
|
|
|
|
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommand();
|
|
|
|
|
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
|
|
|
|
await db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).ExecuteCommandAsync();
|
|
|
|
|
return await Task.FromResult(DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|