ship-filter-control.js 1.0 KB

1234567891011121314151617181920212223242526
  1. import SourceService from "../service/source-service.js";
  2. import ApiResult from "../config/api.js";
  3. import ParamsService from "../service/params-service.js";
  4. import ParamsDictService from "../service/params-dict-service.js";
  5. import TrackService from "../service/track-service.js";
  6. const ShipFilterControl = {
  7. getConfig: async (req, res) => {
  8. try {
  9. const sourceData = await SourceService.list({orderByColumn: 'sort', isAsc: false})
  10. for (const source of sourceData) {
  11. const trackData = await TrackService.queryBy({sourceId: source.id})
  12. source.track = trackData?.[0] || {}
  13. const paramsData = await ParamsService.list({sourceId: source.id})
  14. for (const params of paramsData) {
  15. const dictData = await ParamsDictService.list({paramsId: params.id})
  16. params.dict = dictData
  17. }
  18. source.params = paramsData
  19. }
  20. res.send(new ApiResult().success(sourceData))
  21. } catch (e) {
  22. res.send(new ApiResult().error(e))
  23. }
  24. },
  25. }
  26. export default ShipFilterControl