表单设置修改

master
ZR20090193-陈敬勇 9 months ago
parent 8a0e94e5e6
commit 07d7215a45

@ -264,5 +264,9 @@ public static class MultiLanguageConst
public const string CodeStlModeImportNoData = "Code_StlMode_Import_No_Data"; public const string CodeStlModeImportNoData = "Code_StlMode_Import_No_Data";
[Description("存在已导入的结算方式")] [Description("存在已导入的结算方式")]
public const string CodeStlModeImportAlready = "Code_StlMode_Import_Already"; public const string CodeStlModeImportAlready = "Code_StlMode_Import_Already";
[Description("表单设置已存在")]
public const string FormSetExist = "Form_Set_Exist";
#endregion #endregion
} }

@ -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,34 @@
using DS.Module.Core;
using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Code.Entity;
/// <summary>
/// 租户表单设置
/// </summary>
[SqlSugar.SugarTable("op_code_form_set")]
public class CodeFormSet : BaseOrgModel<long>
{
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 表单设置
/// </summary>
[SugarColumn(ColumnDescription = "表单设置", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; }
/// <summary>
/// 排序号
/// </summary>
public string OrderNo { get; set; }
/// <summary>
/// 状态
/// </summary>
[SqlSugar.SugarColumn(ColumnDescription = "状态")]
public StatusEnum? Status { get; set; } = StatusEnum.Enable;
}

@ -1,8 +1,8 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Entity;
namespace DS.WMS.Core.System.Interface; namespace DS.WMS.Core.Code.Interface;
public interface IFormSetService public interface IFormSetService
{ {
@ -11,7 +11,7 @@ public interface IFormSetService
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="request"></param>
/// <returns></returns> /// <returns></returns>
DataResult<List<FormSetRes>> GetListByPage(PageRequest request); DataResult<List<CodeFormSetRes>> GetListByPage(PageRequest request);
/// <summary> /// <summary>
@ -19,12 +19,12 @@ public interface IFormSetService
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
DataResult EditFormSet(FormSetReq model); DataResult EditFormSet(CodeFormSetReq model);
/// <summary> /// <summary>
/// 获取详情 /// 获取详情
/// </summary> /// </summary>
/// <param name="id"></param> /// <param name="id"></param>
/// <returns></returns> /// <returns></returns>
DataResult<FormSetRes> GetFormSetInfo(string id); DataResult<CodeFormSetRes> GetFormSetInfo(string id);
} }

@ -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,6 +1,7 @@
using System.ComponentModel; using System.ComponentModel;
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.Flow.Entity; namespace DS.WMS.Core.Flow.Entity;
/// <summary> /// <summary>
@ -72,5 +73,6 @@ public class FlowInstance: BaseTenantModel<long>
/// <summary> /// <summary>
/// 流程内容 /// 流程内容
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "流程内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } public string Content { get; set; }
} }

@ -31,6 +31,7 @@ public class FlowTemplate : BaseModel<long>
/// <summary> /// <summary>
/// 流程内容 /// 流程内容
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } public string Content { get; set; }
/// <summary> /// <summary>

@ -30,6 +30,7 @@ public class FlowTemplateTenant : BaseTenantModel<long>
/// <summary> /// <summary>
/// 流程内容 /// 流程内容
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } public string Content { get; set; }
/// <summary> /// <summary>

@ -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,5 +1,6 @@
using DS.Module.Core; using DS.Module.Core;
using DS.Module.Core.Data; using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.System.Entity; namespace DS.WMS.Core.System.Entity;
@ -27,6 +28,7 @@ public class SysDataRule : BaseTenantModel<long>
/// <summary> /// <summary>
/// 权限规则 /// 权限规则
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "权限规则", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string DataRules { get; set; } public string DataRules { get; set; }
/// <summary> /// <summary>

@ -27,5 +27,6 @@ public class SysFieldSet
/// <summary> /// <summary>
/// 字段设置 /// 字段设置
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "字段设置", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } public string Content { get; set; }
} }

@ -1,31 +0,0 @@
using SqlSugar;
namespace DS.WMS.Core.System.Entity;
/// <summary>
/// 租户表单设置
/// </summary>
[SqlSugar.SugarTable("sys_tenant_form_set")]
public class SysFormSet
{
/// <summary>
/// ID
/// </summary>
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
/// <summary>
/// 租户id
/// </summary>
public long? TenantId { get; set; }
/// <summary>
/// 权限Id
/// </summary>
public long? PermissionId { get; set; }
/// <summary>
/// 表单设置
/// </summary>
public string Content { get; set; }
}

@ -1,4 +1,5 @@
using DS.Module.Core.Data; using DS.Module.Core.Data;
using SqlSugar;
namespace DS.WMS.Core.System.Entity; namespace DS.WMS.Core.System.Entity;
@ -31,6 +32,7 @@ public class SysNotice : BaseModel<string>
/// <summary> /// <summary>
/// 内容 /// 内容
/// </summary> /// </summary>
[SugarColumn(ColumnDescription = "内容", IsNullable = true, ColumnDataType=StaticConfig.CodeFirst_BigString)]
public string Content { get; set; } public string Content { get; set; }
/// <summary> /// <summary>

@ -366,14 +366,14 @@ public class CommonService : ICommonService
return DataResult<string>.Failed("密码错误!"); return DataResult<string>.Failed("密码错误!");
} }
// //取第一个机构 //取第一个机构
// var orgRelation = db.Queryable<SysOrgUser>() var orgRelation = db.Queryable<SysOrgUser>()
// .First(x => x.UserId == userInfo.Id); .First(x => x.UserId == userInfo.Id);
var tokenModel = new JwtHelper.JwtTokenModel var tokenModel = new JwtHelper.JwtTokenModel
{ {
Uid = userInfo.Id.ToString(), Uid = userInfo.Id.ToString(),
Name = userInfo.UserName, Name = userInfo.UserName,
// OrgId = orgRelation.OrgId.ToString(), OrgId = orgRelation.OrgId.ToString(),
TenantId = userInfo.TenantId.ToString(), TenantId = userInfo.TenantId.ToString(),
}; };
var token = JwtHelper.Encrypt(tokenModel, false, false); var token = JwtHelper.Encrypt(tokenModel, false, false);
@ -399,17 +399,17 @@ public class CommonService : ICommonService
{ {
var userId = long.Parse(user.UserId); var userId = long.Parse(user.UserId);
var tenantId = user.GetTenantId(); var tenantId = user.GetTenantId();
// //取第一个机构 //取第一个机构
// var orgRelations = db.Queryable<SysOrgUser>() var orgRelations = db.Queryable<SysOrgUser>()
// .LeftJoin<SysOrg>((a,b)=>a.OrgId==b.Id) .LeftJoin<SysOrg>((a,b)=>a.OrgId==b.Id)
// .Where(a => a.UserId == userId) .Where(a => a.UserId == userId)
// .Select<UserOrgListRes>() .Select<UserOrgListRes>()
// .ToList(); .ToList();
var tokenModel = new JwtHelper.JwtTokenModel var tokenModel = new JwtHelper.JwtTokenModel
{ {
Uid = user.UserId, Uid = user.UserId,
Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName, Name = db.Queryable<SysUser>().Filter(null, true).First(x => x.Id == userId).UserName,
// OrgId = user.GetOrgId().ToString(), OrgId = user.GetOrgId().ToString(),
TenantId = tenantId.ToString(), TenantId = tenantId.ToString(),
}; };
var refreshToken = JwtHelper.Encrypt(tokenModel, true, false); var refreshToken = JwtHelper.Encrypt(tokenModel, true, false);
@ -426,7 +426,7 @@ public class CommonService : ICommonService
ClientId = a.ClientId, ClientId = a.ClientId,
IsLimitClient = a.IsLimitClient, IsLimitClient = a.IsLimitClient,
RefreshToken = refreshToken, RefreshToken = refreshToken,
// UserOrgs = orgRelations, UserOrgs = orgRelations,
// OrgId = a.OrgId.ToString(), CompanyName = a.CustomerName // OrgId = a.OrgId.ToString(), CompanyName = a.CustomerName
}) })
.Mapper(it => .Mapper(it =>

@ -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);
}
}

@ -1,4 +1,6 @@
using DS.Module.Core; using DS.Module.Core;
using DS.WMS.Core.Code.Dtos;
using DS.WMS.Core.Code.Interface;
using DS.WMS.Core.System.Dtos; using DS.WMS.Core.System.Dtos;
using DS.WMS.Core.System.Interface; using DS.WMS.Core.System.Interface;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -28,7 +30,7 @@ public class FormSetController : ApiController
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("GetFormSetList")] [Route("GetFormSetList")]
public DataResult<List<FormSetRes>> GetFormSetList([FromBody] PageRequest request) public DataResult<List<CodeFormSetRes>> GetFormSetList([FromBody] PageRequest request)
{ {
var res = _invokeService.GetListByPage(request); var res = _invokeService.GetListByPage(request);
return res; return res;
@ -41,7 +43,7 @@ public class FormSetController : ApiController
/// <returns></returns> /// <returns></returns>
[HttpPost] [HttpPost]
[Route("EditFormSet")] [Route("EditFormSet")]
public DataResult EditFormSet([FromBody] FormSetReq req) public DataResult EditFormSet([FromBody] CodeFormSetReq req)
{ {
var res = _invokeService.EditFormSet(req); var res = _invokeService.EditFormSet(req);
return res; return res;
@ -54,7 +56,7 @@ public class FormSetController : ApiController
/// <returns></returns> /// <returns></returns>
[HttpGet] [HttpGet]
[Route("GetFormSetInfo")] [Route("GetFormSetInfo")]
public DataResult<FormSetRes> GetFormSetInfo([FromQuery] string permissionId) public DataResult<CodeFormSetRes> GetFormSetInfo([FromQuery] string permissionId)
{ {
var res = _invokeService.GetFormSetInfo(permissionId); var res = _invokeService.GetFormSetInfo(permissionId);
return res; return res;

Loading…
Cancel
Save