Files
tnb.server/common/Tnb.Common/CodeGenUpload/Attributes/CodeGenUploadAttribute.cs
2023-03-13 15:00:34 +08:00

335 lines
9.0 KiB
C#

using JNPF.Common.Const;
using JNPF.Common.Models;
using JNPF.Common.Security;
using JNPF.DependencyInjection;
namespace JNPF.Common.CodeGenUpload;
/// <summary>
/// 代码生成导入.
/// </summary>
[SuppressSniffer]
[AttributeUsage(AttributeTargets.Property)]
public class CodeGenUploadAttribute : Attribute
{
/// <summary>
/// 构造函数.
/// "createUser"
/// "modifyUser"
/// "createTime"
/// "modifyTime"
/// "currOrganize"
/// "currPosition"
/// "currDept"
/// "billRule"
/// "comInput"
/// "textarea"
/// "colorPicker"
/// "rate"
/// "slider"
/// "editor".
/// </summary>
public CodeGenUploadAttribute(string Model, string Config)
{
__Model__ = Model;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "radio"
/// "checkbox"
/// "time"
/// "date".
/// </summary>
public CodeGenUploadAttribute(string Model, string SecondParameter, string Config)
{
__Model__ = Model;
__config__ = Config.ToObject<CodeGenConfigModel>();
switch (__config__.jnpfKey)
{
case JnpfKeyConst.CHECKBOX:
case JnpfKeyConst.RADIO:
__slot__ = SecondParameter?.ToObject<CodeGenSlotModel>();
break;
default:
format = SecondParameter;
break;
}
}
/// <summary>
/// 构造函数
/// "numInput".
/// </summary>
public CodeGenUploadAttribute(string Model, string Config, int Min = default, int Max = default)
{
__Model__ = Model;
min = Min;
max = Max;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "switch".
/// </summary>
public CodeGenUploadAttribute(string Model, string ActiveTxt, string InactiveTxt, string Config)
{
__Model__ = Model;
activeTxt = ActiveTxt;
inactiveTxt = InactiveTxt;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "popupSelect".
/// </summary>
public CodeGenUploadAttribute(string Model, string SecondParameter, string ThreeParameters, string FourParameters, string Config)
{
__Model__ = Model;
interfaceId = SecondParameter;
propsValue = ThreeParameters;
relationField = FourParameters;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "comSelect":
/// "roleSelect":
/// "groupSelect".
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, string Config)
{
__Model__ = Model;
multiple = Multiple;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "select".
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, string Slot, string Config)
{
__Model__ = Model;
multiple = Multiple;
__slot__ = Slot?.ToObject<CodeGenSlotModel>();
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "address".
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, int Level, string Config)
{
__Model__ = Model;
multiple = Multiple;
level = Level;
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 构造函数
/// "treeSelect"
/// "usersSelect":
/// "depSelect":
/// "relationForm".
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, string ThreeParameters, string FourParameters, string Config)
{
__Model__ = Model;
multiple = Multiple;
__config__ = Config.ToObject<CodeGenConfigModel>();
switch (__config__.jnpfKey)
{
case JnpfKeyConst.RELATIONFORM:
modelId = ThreeParameters;
relationField = FourParameters;
break;
case JnpfKeyConst.DEPSELECT:
selectType = ThreeParameters;
ableDepIds = FourParameters?.ToObject<List<string>>();
break;
case JnpfKeyConst.USERSSELECT:
selectType = ThreeParameters;
ableIds = FourParameters?.ToObject<List<string>>();
break;
default:
props = ThreeParameters?.ToObject<CodeGenPropsModel>();
options = FourParameters?.ToObject<List<object>>();
break;
}
}
/// <summary>
/// 构造函数
/// "cascader"
/// "posSelect":
/// "popupTableSelect".
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, string InterfaceId, string PropsValue, string RelationField, string Config)
{
__Model__ = Model;
multiple = Multiple;
__config__ = Config.ToObject<CodeGenConfigModel>();
switch (__config__.jnpfKey)
{
case JnpfKeyConst.CASCADER:
separator = InterfaceId;
props = PropsValue?.ToObject<CodeGenPropsModel>();
options = RelationField?.ToObject<List<object>>();
break;
case JnpfKeyConst.POPUPTABLESELECT:
interfaceId = InterfaceId;
propsValue = PropsValue;
relationField = RelationField;
break;
case JnpfKeyConst.POSSELECT:
selectType = InterfaceId;
ableDepIds = PropsValue?.ToObject<List<string>>();
ablePosIds = RelationField?.ToObject<List<string>>();
break;
}
}
/// <summary>
/// 构造函数
/// "userSelect":.
/// </summary>
public CodeGenUploadAttribute(string Model, bool Multiple, string SelectType, string AbleDepIds, string AblePosIds, string AbleUserIds, string AbleRoleIds, string AbleGroupIds, string Config)
{
__Model__ = Model;
multiple = Multiple;
selectType = SelectType;
ableDepIds = AbleDepIds?.ToObject<List<string>>();
ablePosIds = AblePosIds?.ToObject<List<string>>();
ableUserIds = AbleUserIds?.ToObject<List<string>>();
ableRoleIds = AbleRoleIds?.ToObject<List<string>>();
ableGroupIds = AbleGroupIds?.ToObject<List<string>>();
__config__ = Config.ToObject<CodeGenConfigModel>();
}
/// <summary>
/// 设置默认值为空字符串.
/// </summary>
public string __Model__ { get; set; }
/// <summary>
/// 最小值.
/// </summary>
public int min { get; set; }
/// <summary>
/// 最大值.
/// </summary>
public int max { get; set; }
/// <summary>
/// 开关控件 属性 - 开启展示值.
/// </summary>
public string? activeTxt { get; set; }
/// <summary>
/// 开关控件 属性 - 关闭展示值.
/// </summary>
public string? inactiveTxt { get; set; }
/// <summary>
/// 显示绑定值的格式.
/// </summary>
public string? format { get; set; }
/// <summary>
/// 是否多选.
/// </summary>
public bool multiple { get; set; }
/// <summary>
/// 选项分隔符.
/// </summary>
public string? separator { get; set; }
/// <summary>
/// 配置选项.
/// </summary>
public CodeGenPropsModel? props { get; set; }
/// <summary>
/// 配置项.
/// </summary>
public List<object>? options { get; set; }
/// <summary>
/// 弹窗选择主键.
/// </summary>
public string? propsValue { get; set; }
/// <summary>
/// 关联表单字段.
/// </summary>
public string? relationField { get; set; }
/// <summary>
/// 关联表单id.
/// </summary>
public string? modelId { get; set; }
/// <summary>
/// 数据接口ID.
/// </summary>
public string? interfaceId { get; set; }
/// <summary>
/// 层级.
/// </summary>
public int level { get; set; }
/// <summary>
/// 插槽.
/// </summary>
public CodeGenSlotModel? __slot__ { get; set; }
/// <summary>
/// 配置.
/// </summary>
public CodeGenConfigModel? __config__ { get; set; }
/// <summary>
/// 可选范围.
/// </summary>
public string selectType { get; set; }
/// <summary>
/// 可选部门.
/// </summary>
public List<string> ableDepIds { get; set; }
/// <summary>
/// 可选岗位.
/// </summary>
public List<string> ablePosIds { get; set; }
/// <summary>
/// 可选用户.
/// </summary>
public List<string> ableUserIds { get; set; }
/// <summary>
/// 可选角色.
/// </summary>
public List<string> ableRoleIds { get; set; }
/// <summary>
/// 可选分组.
/// </summary>
public List<string> ableGroupIds { get; set; }
/// <summary>
/// 新用户选择控件.
/// </summary>
public List<string> ableIds { get; set; }
}