AdmModelController.java 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. package com.persagy.proxy.adm.controller;
  2. import cn.hutool.core.util.StrUtil;
  3. import com.alibaba.fastjson.JSONArray;
  4. import com.persagy.proxy.adm.model.AdmModelKey;
  5. import com.persagy.proxy.adm.request.AdmQueryCriteria;
  6. import com.persagy.proxy.adm.request.AdmResponse;
  7. import com.persagy.proxy.adm.service.IAdmModelKeyService;
  8. import com.persagy.proxy.adm.utils.AdmContextUtil;
  9. import com.persagy.proxy.common.entity.DmpResult;
  10. import com.persagy.proxy.common.entity.InstanceUrlParam;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.beans.factory.annotation.Value;
  13. import org.springframework.web.bind.annotation.PostMapping;
  14. import org.springframework.web.bind.annotation.RequestBody;
  15. import org.springframework.web.bind.annotation.RequestMapping;
  16. import org.springframework.web.bind.annotation.RestController;
  17. /**
  18. * 模型操作
  19. * @author lvxy
  20. * @date 2021/8/25
  21. */
  22. @RestController
  23. @RequestMapping("/model")
  24. public class AdmModelController {
  25. @Autowired
  26. private IAdmModelKeyService service;
  27. @Value("${middleware.group.code}")
  28. private String groupCode;
  29. /**
  30. * 模型文件下载地址 key
  31. */
  32. @PostMapping("/key")
  33. public AdmResponse count(@RequestBody AdmQueryCriteria request) {
  34. InstanceUrlParam context = AdmContextUtil.toDmpContext();
  35. if(StrUtil.isBlank(context.getProjectId())) {
  36. return AdmResponse.failure("项目 id 不能为空");
  37. }
  38. DmpResult<JSONArray> result = service.doQuery(context, request);
  39. return AdmResponse.fromDmp(request, result, AdmModelKey.class);
  40. }
  41. }