back-app-configuration.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. public interface IAppRuntimeFilter {
  2. // APP端专用策略属性, 可判定Vue-Store上所有支持的属性及子属性
  3. // AppConfigNode.content中任何数组属性或者数组子属性及后代属性,都支持implement该接口
  4. // 后台可以将此属性赋值到配置内容的相应属性,让前端自行筛选(这样可以减少API输出差异);
  5. // 也可以自行筛选将最终结果返回给不同用户(这样可以减少传输量),推荐前者。
  6. public string[] satisfyStoreGetters;
  7. public bool satisfyAny;
  8. }
  9. /// 可以定制具体的配置文件类
  10. public class AppConfigNode<T> {
  11. // 对应APP配置模块中要替换的配置结点Key
  12. public string key;
  13. // 配置内容,任意内容
  14. public T content;
  15. }
  16. /// 也可以模糊处理
  17. public class AppConfigNode: AppConfigNode<object> {
  18. }
  19. /// 此接口用来生成最终配置文件
  20. public interface IAppConfigProvider {
  21. List<AppConfigNode> get();
  22. }
  23. /// Table - top entry
  24. public class AppConfigStrategy {
  25. public string key; // 要替换的app config key
  26. public string desc; // 配置说明,方便UI展示示意
  27. // 控制策略
  28. public bool disabled; // 禁用,总开关
  29. public string minVersion; // 最低启用版本,不填不限
  30. public string maxVersion; // 最高启用版本,不填不限
  31. public string[] osTypes; // 操作系统,不填不限
  32. public string[] roles; // 角色,不填不限
  33. public string[] periods; // 学阶,不填不限
  34. // 自定义策略
  35. public string[] customStrategies; // 可能需要更复杂的判定逻辑,比如要取某些业务表才能决定
  36. }
  37. /// Table - config dynamic content
  38. public class AppConfigContent {
  39. public string scope; // parent key
  40. public EnumScopeType scopeType; // type builder
  41. public string itemKey; // map to AppConfigContentItem.key, 没有则直接作用于scope
  42. public string alias; // 别名,用于填充配置时使用,没有则使用itemKey,用于适配同名属性
  43. public string value; // single、multiple时可能要保存选择结果
  44. public string customValueFormatter; // 装配配置时的自定义格式转换器
  45. }
  46. /// Table - content value shared item pool
  47. public class AppConfigContentItem {
  48. public string key;
  49. public string desc; // 配置说明,方便UI展示示意
  50. public string options; // 配置选项,供于前端选择
  51. public string customOptionsLoader; // 自定义选科加载类,解决固定配置无法完成的部分
  52. public EnumAppConfigOptionType enumOptionType; // 选项使用类型
  53. }
  54. public enum EnumScopeType {
  55. none = 0,
  56. obj = 1,
  57. array = 2
  58. }
  59. public enum EnumAppConfigOptionType {
  60. copy = 0, // 直接复制选项值,不需要用户选择
  61. single = 1, // 需要用户选择,单选
  62. multiple = 2, // 需要用户选择,多选
  63. }
  64. public class AppConfigCustomStrategyContext {
  65. public List<ConfigCustomStrategy> strategies;
  66. public ConfigCustomStrategy current;
  67. }
  68. /// 此接口主要用来决策要不要启用某个key的配置替换
  69. public interface IAppConfigCustomStrategy {
  70. bool satisfy(AppConfigCustomStrategyContext context)
  71. }
  72. public class CustomOptionsLoaderContext: AppConfigCustomStrategyContext {
  73. public AppConfigContentItem Item;
  74. }
  75. /// 此接口用来加载配置值的动态选项
  76. public interface ICustomOptionsLoader {
  77. void load(CustomOptionsLoaderContext context)
  78. }
  79. public class CustomValueFormatterContext: AppConfigCustomStrategyContext {
  80. public AppConfigContent content;
  81. }
  82. /// 此接口用来做配置值的输出转换
  83. public interface ICustomValueFormatter {
  84. void format(CustomValueFormatterContext context)
  85. }