AiznModelController.java 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. package com.backendsys.controller.Ai;
  2. import com.backendsys.entity.Ai.Aizn.AiznImageStyleDTO;
  3. import com.backendsys.entity.Ai.Aizn.AiznIntelligentClipTaskDTO;
  4. import com.backendsys.entity.Ai.Aizn.AiznInteractClipTask.AiznInteractClipTaskDTO;
  5. import com.backendsys.entity.Ai.Aizn.AiznModel.AiznModelTaskDTO;
  6. import com.backendsys.entity.System.SysResourcePointsDTO;
  7. import com.backendsys.exception.CustomException;
  8. import com.backendsys.mapper.System.SysResourcePointsMapper;
  9. import com.backendsys.service.Ai.Aizn.AiznImageTaskService;
  10. import com.backendsys.service.Ai.Aizn.AiznModelService;
  11. import com.backendsys.service.SDKService.SDKTencent.SDKTencentCOSService;
  12. import com.backendsys.utils.response.Result;
  13. import jakarta.validation.constraints.NotEmpty;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.security.access.prepost.PreAuthorize;
  16. import org.springframework.validation.annotation.Validated;
  17. import org.springframework.web.bind.annotation.*;
  18. import java.io.IOException;
  19. @Validated
  20. @RestController
  21. public class AiznModelController {
  22. @Autowired
  23. private SysResourcePointsMapper sysResourcePointsMapper;
  24. @Autowired
  25. private AiznModelService aiznModelService;
  26. @Autowired
  27. private AiznImageTaskService aiznImageTaskService;
  28. @Autowired
  29. private SDKTencentCOSService sdkTencentCOSService;
  30. /**
  31. * [紫鸟] AI模特 - 获得风格/场景配置数据
  32. */
  33. @PreAuthorize("@ss.hasPermi('35')")
  34. @GetMapping("/api/ai/zn/getImageStyle")
  35. public Result getImageStyle(AiznImageStyleDTO aiznImageStyleDTO) {
  36. return Result.success(aiznModelService.getImageStyle(aiznImageStyleDTO));
  37. }
  38. /**
  39. * [紫鸟] AI模特 - 获得积分单价 (AI模特)
  40. */
  41. @PreAuthorize("@ss.hasPermi('35')")
  42. @GetMapping("/api/ai/zn/getResourceOfZnModel")
  43. public Result getImageStyle() {
  44. SysResourcePointsDTO sysResourcePointsDTO = new SysResourcePointsDTO();
  45. sysResourcePointsDTO.setResource_type("ZnModel");
  46. return Result.success(sysResourcePointsMapper.queryResourcePointsList(sysResourcePointsDTO));
  47. }
  48. /**
  49. * [紫鸟] AI模特 - 智能抠图 (发起任务)
  50. */
  51. @PreAuthorize("@ss.hasPermi('35')")
  52. @PostMapping("/api/ai/zn/makeIntelligentClipTask")
  53. public Result makeIntelligentClipTask(@Validated @RequestBody AiznIntelligentClipTaskDTO aiznIntelligentClipTaskDTO) {
  54. return Result.success(aiznModelService.makeIntelligentClipTask(aiznIntelligentClipTaskDTO));
  55. }
  56. /**
  57. * [紫鸟] AI模特 - 智能抠图 (查询任务)
  58. */
  59. @PreAuthorize("@ss.hasPermi('35')")
  60. @GetMapping("/api/ai/zn/getProgressOfIntelligentClipTask")
  61. public Result getProgressOfIntelligentClipTask(@NotEmpty(message = "任务ID 不能为空") String id) throws IOException {
  62. return Result.success(aiznImageTaskService.getProgressOfTask(id, 3));
  63. }
  64. /**
  65. * [紫鸟] AI模特 - 交互抠图 (直接返回结果)
  66. */
  67. @PreAuthorize("@ss.hasPermi('35')")
  68. @PostMapping("/api/ai/zn/makeInteractClipTask")
  69. public Result makeInteractClipTask(@Validated @RequestBody AiznInteractClipTaskDTO aiznInteractClipTaskDTO) {
  70. return Result.success(aiznModelService.makeInteractClipTask(aiznInteractClipTaskDTO));
  71. }
  72. /**
  73. * [紫鸟] AI换模特 (发起任务)
  74. */
  75. @PreAuthorize("@ss.hasPermi('35')")
  76. @PostMapping("/api/ai/zn/makeModelTask")
  77. public Result makeModelTask(@Validated @RequestBody AiznModelTaskDTO aiznModelTaskDTO) {
  78. return Result.success(aiznModelService.makeModelTask(aiznModelTaskDTO));
  79. }
  80. /**
  81. * [紫鸟] AI换模特 (查询任务)
  82. */
  83. @PreAuthorize("@ss.hasPermi('35')")
  84. @GetMapping("/api/ai/zn/getProgressOfModelTask")
  85. public Result getProgressOfModelTask(
  86. @RequestParam(value = "id", required = false) String id,
  87. @RequestParam(value = "ids", required = false) String ids
  88. ) throws IOException {
  89. if (ids != null) {
  90. if (id != null) throw new CustomException("id 与 ids 不能同时存在");
  91. return Result.success(aiznImageTaskService.getProgressOfTaskArray(ids, 9));
  92. } else {
  93. if (id == null) throw new CustomException("id 与 ids 至少一项不能为空");
  94. return Result.success(aiznImageTaskService.getProgressOfTask(id, 9));
  95. }
  96. }
  97. }