表单设置修改
parent
8a0e94e5e6
commit
07d7215a45
@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace DS.Module.Core.Data;
|
||||
|
||||
/// <summary>
|
||||
/// 机构实体基类
|
||||
/// </summary>
|
||||
public abstract class BaseOrgModel<TKey> : BaseModel<TKey>, IOrgId
|
||||
{
|
||||
/// <summary>
|
||||
/// 主键ID
|
||||
/// </summary>
|
||||
[Description("主键ID")]
|
||||
[SqlSugar.SugarColumn(IsPrimaryKey = true, Length = 100, ColumnDescription = "主键ID")]
|
||||
public TKey Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 机构Id
|
||||
/// </summary>
|
||||
[SqlSugar.SugarColumn(ColumnDescription = "机构Id", IsOnlyIgnoreUpdate = true)]
|
||||
public long OrgId { get; set; } = 0;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
using DS.Module.Core;
|
||||
using FluentValidation;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单设置请求实体
|
||||
/// </summary>
|
||||
public class CodeFormSetReq
|
||||
{
|
||||
/// <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 FormSetReqValidator : AbstractValidator<CodeFormSetReq>
|
||||
{
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
public FormSetReqValidator()
|
||||
{
|
||||
this.RuleFor(o => o.PermissionId)
|
||||
.NotEmpty().WithName("权限模块Id");
|
||||
this.RuleFor(o => o.Content)
|
||||
.NotEmpty().WithName("中文视图名");
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
using DS.Module.Core;
|
||||
|
||||
namespace DS.WMS.Core.Code.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单设置返回实体
|
||||
/// </summary>
|
||||
public class CodeFormSetRes
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 主键Id
|
||||
/// </summary>
|
||||
public long Id { get; set; }
|
||||
/// <summary>
|
||||
/// 权限Id
|
||||
/// </summary>
|
||||
public long? PermissionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段设置
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
|
||||
/// <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,95 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Extensions;
|
||||
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 FormSetService : IFormSetService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ISqlSugarClient db;
|
||||
private readonly IUser user;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public FormSetService(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
||||
user = _serviceProvider.GetRequiredService<IUser>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<List<CodeFormSetRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = db.Queryable<CodeFormSet>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(whereList)
|
||||
.Select<CodeFormSetRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult EditFormSet(CodeFormSetReq req)
|
||||
{
|
||||
if (req.Id == 0)
|
||||
{
|
||||
if (db.Queryable<CodeFormSet>()
|
||||
.Where(x => x.OrgId == long.Parse(user.OrgId) && x.PermissionId == req.PermissionId).Any())
|
||||
{
|
||||
return DataResult.Failed("表单设置已存在!", MultiLanguageConst.FormSetExist);
|
||||
}
|
||||
|
||||
var data = req.Adapt<CodeFormSet>();
|
||||
|
||||
var entity = db.Insertable(data).ExecuteReturnEntity();
|
||||
|
||||
return DataResult.Successed("添加成功!", entity.Id, MultiLanguageConst.DataCreateSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
var info = db.Queryable<CodeFormSet>().Where(x => x.Id == req.Id).First();
|
||||
|
||||
info = req.Adapt(info);
|
||||
|
||||
db.Updateable(info).IgnoreColumns(ignoreAllNullColumns: true).EnableDiffLogEvent().ExecuteCommand();
|
||||
return DataResult.Successed("更新成功!", MultiLanguageConst.DataUpdateSuccess);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="id"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<CodeFormSetRes> GetFormSetInfo(string id)
|
||||
{
|
||||
var data = db.Queryable<CodeFormSet>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(x => x.Id == long.Parse(id))
|
||||
.Select<CodeFormSetRes>()
|
||||
.First();
|
||||
return DataResult<CodeFormSetRes>.Success(data, MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
namespace DS.WMS.Core.System.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单设置请求实体
|
||||
/// </summary>
|
||||
public class FormSetReq
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限Id
|
||||
/// </summary>
|
||||
public long? PermissionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段设置
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
namespace DS.WMS.Core.System.Dtos;
|
||||
|
||||
/// <summary>
|
||||
/// 租户表单设置返回实体
|
||||
/// </summary>
|
||||
public class FormSetRes
|
||||
{
|
||||
/// <summary>
|
||||
/// 权限Id
|
||||
/// </summary>
|
||||
public long? PermissionId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 字段设置
|
||||
/// </summary>
|
||||
public string Content { get; set; }
|
||||
}
|
@ -1,88 +0,0 @@
|
||||
using DS.Module.Core;
|
||||
using DS.Module.Core.Extensions;
|
||||
using DS.Module.UserModule;
|
||||
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.System.Method;
|
||||
|
||||
public class FormSetService : IFormSetService
|
||||
{
|
||||
private readonly IServiceProvider _serviceProvider;
|
||||
private readonly ISqlSugarClient db;
|
||||
private readonly IUser user;
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="serviceProvider"></param>
|
||||
public FormSetService(IServiceProvider serviceProvider)
|
||||
{
|
||||
_serviceProvider = serviceProvider;
|
||||
db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
|
||||
user = _serviceProvider.GetRequiredService<IUser>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 列表
|
||||
/// </summary>
|
||||
/// <param name="request"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<List<FormSetRes>> GetListByPage(PageRequest request)
|
||||
{
|
||||
//序列化查询条件
|
||||
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(request.QueryCondition);
|
||||
var data = db.Queryable<SysFormSet>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(whereList)
|
||||
.Select<FormSetRes>().ToQueryPage(request.PageCondition);
|
||||
return data;
|
||||
}
|
||||
/// <summary>
|
||||
/// 编辑
|
||||
/// </summary>
|
||||
/// <param name="req"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult EditFormSet(FormSetReq req)
|
||||
{
|
||||
var info = db.Queryable<SysFormSet>()
|
||||
.Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == req.PermissionId).First();
|
||||
|
||||
if (info.IsNull())
|
||||
{
|
||||
var entity = new SysFormSet
|
||||
{
|
||||
TenantId = long.Parse(user.TenantId),
|
||||
PermissionId = req.PermissionId,
|
||||
Content = req.Content
|
||||
};
|
||||
db.Insertable(entity).ExecuteCommand();
|
||||
}
|
||||
else
|
||||
{
|
||||
info.Content = req.Content;
|
||||
db.Updateable(info).ExecuteCommand();
|
||||
}
|
||||
|
||||
return DataResult.Successed("更新成功",MultiLanguageConst.DataUpdateSuccess);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 详情
|
||||
/// </summary>
|
||||
/// <param name="permissionId"></param>
|
||||
/// <returns></returns>
|
||||
public DataResult<FormSetRes> GetFormSetInfo(string permissionId)
|
||||
{
|
||||
var data = db.Queryable<SysFormSet>()
|
||||
.LeftJoin<SysPermission>((a, b) => a.PermissionId == b.Id)
|
||||
.Where(x => x.TenantId == long.Parse(user.TenantId) && x.PermissionId == long.Parse(permissionId))
|
||||
.Select<FormSetRes>()
|
||||
.First();
|
||||
return DataResult<FormSetRes>.Success(data,MultiLanguageConst.DataQuerySuccess);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue