表单字段复制模板
parent
22ac514a70
commit
c6d8650fc1
@ -0,0 +1,57 @@
|
||||
using DS.Module.Core;
|
||||
using FluentValidation;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单字段复制设置请求实体
|
||||
/// </summary>
|
||||
public class CodeFormCopyReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 权限Id
|
||||
/// </summary>
|
||||
public long? PermissionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段复制设置
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int? OrderNo { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0 启用 1 禁用
|
||||
/// </summary>
|
||||
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 验证
|
||||
/// </summary>
|
||||
public class CodeFormCopyReqValidator : AbstractValidator<CodeFormCopyReq>
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public CodeFormCopyReqValidator()
|
||||
{
|
||||
this.RuleFor(o => o.PermissionId)
|
||||
.NotEmpty().WithName("权限模块Id");
|
||||
this.RuleFor(o => o.Content)
|
||||
.NotEmpty().WithName("字段复制设置");
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
using DS.Module.Core;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单字段复制设置返回实体
|
||||
/// </summary>
|
||||
public class CodeFormCopyRes
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 权限Id
|
||||
/// </summary>
|
||||
public long? PermissionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段设置
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 模板名称
|
||||
/// </summary>
|
||||
public string TemplateName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否公共标识
|
||||
/// </summary>
|
||||
public bool IsPublic { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 状态 0 启用 1 禁用
|
||||
/// </summary>
|
||||
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
|
||||
/// <summary>
|
||||
/// 备注
|
||||
/// </summary>
|
||||
public string Note { get; set; } = "";
|
||||
/// <summary>
|
||||
/// 排序
|
||||
/// </summary>
|
||||
public int? OrderNo { get; set; } = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public DateTime CreateTime { get; set; }
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
using DS.Module.Core;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
using DS.WMS.Core.System.Dtos;
|
||||
|
||||
namespace DS.WMS.Core.Code.Interface;
|
||||
|
||||
public interface IFormCopyService
|
||||
{
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<List<CodeFormCopyRes>> GetListByPage(PageRequest request);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="model"></param>
|
||||
/// <returns></returns>
|
||||
DataResult EditFormCopy(CodeFormCopyReq model);
|
||||
|
||||
/// <summary>
|
||||
/// 获取详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
DataResult<CodeFormCopyRes> GetFormCopyInfo(string id);
|
||||
}
|
@ -0,0 +1,100 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Extensions;
|
||||
using DS.Module.SqlSugar;
|
||||
using DS.Module.UserModule;
|
||||
using DS.WMS.Core.Code.Dtos;
|
||||
using DS.WMS.Core.Code.Entity;
|
||||
using DS.WMS.Core.Code.Interface;
|
||||
using DS.WMS.Core.System.Dtos;
|
||||
using DS.WMS.Core.System.Entity;
|
||||
using DS.WMS.Core.System.Interface;
|
||||
using Mapster;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SqlSugar;
|
||||
|
||||
namespace DS.WMS.Core.Code.Method;
|
||||
|
||||
public class CodeFormCopyService : IFormCopyService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ISqlSugarClient db;
|
||||
private readonly IUser user;
|
||||
private readonly ISaasDbService saasService;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public CodeFormCopyService(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
||||
user = _serviceProvider.GetRequiredService<IUser>();
|
||||
saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<List<CodeFormCopyRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = tenantDb.Queryable<CodeFormCopy>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(whereList)
|
||||
.Select<CodeFormCopyRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult EditFormCopy(CodeFormCopyReq req)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
if (req.Id == 0)
|
||||
{
|
||||
if (tenantDb.Queryable<CodeFormCopy>()
|
||||
.Where(x => x.OrgId == long.Parse(user.OrgId) && x.PermissionId == req.PermissionId && x.CreateBy == user.UserId).Any())
|
||||
{
|
||||
return DataResult.Failed("表单复制字段设置已存在!", MultiLanguageConst.FormCopyExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeFormCopy>();
|
||||
|
||||
var entity = tenantDb.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = tenantDb.Queryable<CodeFormCopy>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
tenantDb.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<CodeFormCopyRes> GetFormCopyInfo(string id)
|
||||
{
|
||||
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
||||
var data = tenantDb.Queryable<CodeFormCopy>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(x => x.Id == long.Parse(id))
|
||||
.Select<CodeFormCopyRes>()
|
||||
.First();
|
||||
return DataResult<CodeFormCopyRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue