You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.5 KiB

3 years ago
  1. import { ConfigRepository, ConfigTestResponse } from '~/domain/models/autoLabeling/configRepository'
  2. import { ConfigItemList, ConfigItem } from '~/domain/models/autoLabeling/config'
  3. export class ConfigApplicationService {
  4. constructor(
  5. private readonly configRepository: ConfigRepository
  6. ) {}
  7. public list(id: string): Promise<ConfigItemList> {
  8. return this.configRepository.list(id)
  9. }
  10. public save(projectId: string, item: ConfigItem): Promise<ConfigItem> {
  11. return this.configRepository.create(projectId, item)
  12. }
  13. public delete(projectId: string, itemId: number) {
  14. return this.configRepository.delete(projectId, itemId)
  15. }
  16. public testParameters(projectId: string, item: ConfigItem, text: string) {
  17. return this.configRepository.testParameters(projectId, item, text)
  18. .then((value) => {
  19. return value
  20. })
  21. .catch((error) => {
  22. const data = error.response.data
  23. throw new Error(data)
  24. })
  25. }
  26. public testTemplate(projectId: string, response: any, item: ConfigItem) {
  27. return this.configRepository.testTemplate(projectId, response, item)
  28. .then((value) => {
  29. return value
  30. })
  31. .catch((error) => {
  32. const data = error.response.data
  33. throw new Error(data)
  34. })
  35. }
  36. public testMapping(projectId: string, item: ConfigItem, response: any) {
  37. return this.configRepository.testMapping(projectId, item, response)
  38. .then((value) => {
  39. return value
  40. })
  41. .catch((error) => {
  42. const data = error.response.data
  43. throw new Error(data)
  44. })
  45. }
  46. }