model.ts 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import { addModel, addModelPlugin, debugModelPlugin, delModel, getModel, getModelById, getModelCount, getModelList, getModelPlugin, updateModelPlugin } from '@/api/iot/model'
  2. import { message } from 'ant-design-vue'
  3. export class ModelController {
  4. static async list (params: {modelLabel?: string, limit?: number, lastId?: string} = {
  5. modelLabel: '',
  6. limit: 10000,
  7. lastId: ''
  8. }) {
  9. return await getModelList(params)
  10. }
  11. static async page (params: IOT.API.MODEL.QueryPamars) {
  12. return await getModel(params)
  13. }
  14. static async post (data: IOT.API.MODEL.Model) {
  15. await addModel(data)
  16. message.success('新增成功')
  17. }
  18. static async count () {
  19. return await getModelCount()
  20. }
  21. static put () {
  22. }
  23. static async detail (id: string) {
  24. const { data } = await getModelById(id)
  25. return data
  26. }
  27. static async del (id: string) {
  28. const { data } = await delModel(id)
  29. if (data) {
  30. message.success('删除成功')
  31. }
  32. }
  33. static async getPlugin (params: {modelId: string}) {
  34. return await getModelPlugin(params)
  35. }
  36. static async postPlugin (data: {modelPluginType: string, modelPluginBody: string, modelId: string}) {
  37. await addModelPlugin(data)
  38. message.success('保存成功')
  39. }
  40. static async updatePlugin (data: {modelPluginType: string, modelPluginBody: string, modelId: string, id: string}) {
  41. await updateModelPlugin(data)
  42. message.success('保存成功')
  43. }
  44. static async debugPlugin (data: {input: string, pluginBody: string, decode: boolean}) {
  45. return await debugModelPlugin(data)
  46. }
  47. }