获取系统参数

获取系统参数

作者:


先在go上设置需要得系统参数,然后在前端取用。 参考:

  • trek/services/form-services/middlewares/entities/time-sheet/index.go
  • apps/link/src/main/screens/projects/time-sheet/form/TimeSheetFormPresenter.tsx
// 这里定义需要查询的系统参数
form_service_middlewares_creators.AppendSystemSettingKeyMiddlewareCreator(
  form_service_middlewares_creators.AppendSystemSettingKeyParams{
    Keys: []string{
      gen_ec.EC_Setting_timsheetWeekStarts,
      gen_ec.EC_Setting_timesheetPrecision,
      gen_ec.EC_Setting_timsheetDay2Hour,
      gen_ec.EC_Setting_timesheetCostRateType,
      gen_ec.EC_Setting_priceScale,
    },
  },
),
this.bizFormPresenter.api.getSystemSetting('timesheetCostRateType');

const key = 'timesheetCostRateType'; // 参数名
const settingDataLoader = new DataLoader(EN_Setting, ['values.value'], {
  criteriaStr: `key='${key}'`,
} as QueryOptions);
const data = await settingDataLoader.query();
const result = data[0]; // result.value就是该参数的值