back-app-configuration.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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<out 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. Dictionary<string, object> output(); // 最终输出结果
  23. }
  24. /// Table - top entry
  25. public class AppConfigStrategy {
  26. public string key; // 要替换的app config key
  27. public string desc; // 配置说明,方便UI展示示意
  28. public string content; // 22.9.9 配置的序列化内容,可能为string/number/boolean/object/array。(这样就不需要下面的AppConfigContent和AppConfigContentItem表)
  29. /** 22.9.9 由 {key: content} 拼接,加载入JSONObject, 读取里面所有的object结点(包括array内部的,支持无限递归);
  30. 获取object的refPermissionId属性,如果没有该属性,不用处理;如果有该属性,则将此refPermissionId关联PC端的菜单与按钮权限;
  31. 计算当前用户是否存在该权限,并操作和修改refPermissionId的平级属性:satisfyStoreGetters 和 satisfyAny
  32. 第1版,可粗略返回:有权限时为satisfyStoreGetters赋值[], 无权限时为satisfyStoreGetters赋值['false']
  33. **/
  34. // 控制策略
  35. public bool disabled; // 禁用,总开关
  36. public string minVersion; // 最低启用版本,不填不限
  37. public string maxVersion; // 最高启用版本,不填不限
  38. public string[] osTypes; // 操作系统,不填不限
  39. public string[] roles; // 角色,不填不限
  40. public string[] periods; // 学阶,不填不限
  41. public string[] others; // 其它判定条件
  42. /*isParent
  43. 22.9.9
  44. minVersion,maxVersion前端无法判定非boolean类型的表达式
  45. osTypes: 'isIOS','isAndroid','!isIOS','!isAndroid'
  46. roles: 'isFrontStudent','isParent','isFrontTeacher','isFrontHeadteacher','isFrontMaster','hasFrontHeadteacher','!略'
  47. periods: 'isSenior','isJunior','isPrimary','!略'
  48. others: 'isK9Sensitive','currentUser.isK9Sensitive','currentUser.isHiddenV2','currentUser.xxx.yyy','!略' // 可定制新用户属性
  49. */
  50. // 自定义策略
  51. public string[] customStrategies; // 可能需要更复杂的判定逻辑,比如要取某些业务表才能决定
  52. }
  53. [key:'indexElectiveBlocks','desc':'大数据选科模块']
  54. /// Table - config dynamic content
  55. public class AppConfigContent {
  56. public string scope; // parent key
  57. public EnumScopeType scopeType; // type builder
  58. public string desc; // 配置说明,方便UI展示示意
  59. public string itemKey; // map to AppConfigContentItem.key, 没有则直接作用于scope
  60. public string alias; // 别名,用于填充配置时使用,没有则使用itemKey,用于适配同名属性
  61. public string value; // single、multiple时可能要保存选择结果;或者直接填写值
  62. public string customValueFormatter; // 装配配置时的自定义格式转换器
  63. public long refPermissionId; // 菜单或者按钮权限ID
  64. }
  65. [scope:'indexElectiveBlocks.0.dataList.0',itemKey: 'satisfyStoreGetters',
  66. customValueFormatter: customFilterFormatter--ImplementByJava,
  67. refPermissionId: 直接填写菜单或者按钮权限ID]
  68. /// Table - content value shared item pool
  69. public class AppConfigContentItem {
  70. public string key;
  71. public string desc; // 配置说明,方便UI展示示意
  72. public string options; // 配置选项,供于前端选择
  73. public string customOptionsLoader; // 自定义选科加载类,解决固定配置无法完成的部分
  74. public EnumAppConfigOptionType enumOptionType; // 选项使用类型
  75. }
  76. [key:'satisfyStoreGetters', options:['isFrontStudent','isIOS','isMaster']]
  77. public enum EnumScopeType {
  78. none = 0,
  79. obj = 1,
  80. array = 2
  81. }
  82. public enum EnumAppConfigOptionType {
  83. copy = 0, // 直接复制选项值,不需要用户选择
  84. single = 1, // 需要用户选择,单选
  85. multiple = 2, // 需要用户选择,多选
  86. }
  87. public class AppConfigCustomStrategyContext {
  88. public List<ConfigCustomStrategy> strategies;
  89. public ConfigCustomStrategy current;
  90. }
  91. /// 此接口主要用来决策要不要启用某个key的配置替换
  92. public interface IAppConfigCustomStrategy {
  93. bool satisfy(AppConfigCustomStrategyContext context)
  94. }
  95. public class CustomOptionsLoaderContext: AppConfigCustomStrategyContext {
  96. public AppConfigContentItem Item;
  97. }
  98. /// 此接口用来加载配置值的动态选项
  99. public interface ICustomOptionsLoader {
  100. void load(CustomOptionsLoaderContext context)
  101. }
  102. public class CustomValueFormatterContext: AppConfigCustomStrategyContext {
  103. public AppConfigContent content;
  104. }
  105. /// 此接口用来做配置值的输出转换
  106. public interface ICustomValueFormatter {
  107. void format(CustomValueFormatterContext context)
  108. }