2023-08-17 11:59:19 +08:00
|
|
|
package com.ai.da.controller;
|
|
|
|
|
|
|
|
|
|
import com.ai.da.common.response.Response;
|
2023-08-29 10:33:32 +08:00
|
|
|
import com.ai.da.model.dto.GenerateLikeDTO;
|
2024-09-20 11:32:09 +08:00
|
|
|
import com.ai.da.model.dto.GenerateModifyDTO;
|
2023-08-17 11:59:19 +08:00
|
|
|
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
2024-09-23 11:13:44 +08:00
|
|
|
import com.ai.da.model.dto.ImageToSketchDTO;
|
2024-04-18 14:07:20 +08:00
|
|
|
import com.ai.da.model.vo.*;
|
2023-08-17 11:59:19 +08:00
|
|
|
import com.ai.da.service.GenerateService;
|
|
|
|
|
import io.swagger.annotations.Api;
|
|
|
|
|
import io.swagger.annotations.ApiOperation;
|
2023-09-19 15:39:21 +08:00
|
|
|
import io.swagger.annotations.ApiParam;
|
2023-08-17 11:59:19 +08:00
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.validation.Valid;
|
2024-04-18 14:07:20 +08:00
|
|
|
import java.util.List;
|
2023-08-17 11:59:19 +08:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author XP
|
|
|
|
|
*/
|
|
|
|
|
@Api(tags = "Generate模块")
|
|
|
|
|
@Slf4j
|
|
|
|
|
@RestController
|
|
|
|
|
@RequestMapping("/api/generate")
|
|
|
|
|
public class GenerateController {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private GenerateService generateService;
|
|
|
|
|
|
2024-06-03 17:13:48 +08:00
|
|
|
/*@ApiOperation("自动识别sketch的caption 暂时未上")
|
2023-08-17 11:59:19 +08:00
|
|
|
@PostMapping("/caption")
|
2023-10-20 14:47:18 +08:00
|
|
|
public Response<GenerateCaptionVO> generateCaption(@RequestParam Long sketchElementId) {
|
2023-08-17 11:59:19 +08:00
|
|
|
return Response.success(generateService.generateCaption(sketchElementId));
|
2024-06-03 17:13:48 +08:00
|
|
|
}*/
|
2023-08-17 11:59:19 +08:00
|
|
|
|
2024-04-18 16:48:19 +08:00
|
|
|
/*@ApiOperation("通过文字、图片生成图片")
|
2023-08-18 10:42:08 +08:00
|
|
|
@PostMapping("/sketchAndPrint")
|
2024-04-18 14:07:20 +08:00
|
|
|
public void generateThroughImageText(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
|
|
|
|
// return Response.success(generateService.generateThroughImageText(generateThroughImageTextDTO));
|
|
|
|
|
generateService.generateThroughImageText(generateThroughImageTextDTO);
|
2024-04-18 16:48:19 +08:00
|
|
|
}*/
|
2023-08-17 11:59:19 +08:00
|
|
|
|
2023-08-29 10:33:32 +08:00
|
|
|
@ApiOperation("喜欢生成的图片")
|
|
|
|
|
@PostMapping("/like")
|
2023-10-20 14:47:18 +08:00
|
|
|
public Response<GenerateLikeVO> like(@Valid @RequestBody GenerateLikeDTO generateLikeDTO) {
|
2023-08-29 10:33:32 +08:00
|
|
|
return Response.success(generateService.generateLike(generateLikeDTO));
|
|
|
|
|
}
|
2023-08-17 11:59:19 +08:00
|
|
|
|
2023-09-19 15:21:53 +08:00
|
|
|
@ApiOperation(value = "取消喜欢")
|
2023-09-19 15:39:21 +08:00
|
|
|
@GetMapping("/dislike")
|
|
|
|
|
public Response<Boolean> dislike(@ApiParam("generateDetailId") @RequestParam Long generateDetailId,
|
|
|
|
|
@ApiParam("timeZone") @RequestParam String timeZone) {
|
2023-10-20 14:47:18 +08:00
|
|
|
return Response.success(generateService.generateDislike(generateDetailId, timeZone));
|
2023-09-19 15:21:53 +08:00
|
|
|
}
|
|
|
|
|
|
2024-01-22 14:00:05 +08:00
|
|
|
@ApiOperation(value = "发起生成请求,异步获取结果")
|
2024-01-21 14:14:55 +08:00
|
|
|
@PostMapping("/prepare")
|
2024-04-18 16:48:19 +08:00
|
|
|
public Response<PrepareForGenerateVO> prepareForGenerate(@Valid @RequestBody GenerateThroughImageTextDTO generateThroughImageTextDTO) {
|
2024-01-24 11:43:56 +08:00
|
|
|
return Response.success(generateService.prepareForGenerate(generateThroughImageTextDTO));
|
2024-01-21 14:14:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "取消继续生成")
|
2024-01-22 16:21:32 +08:00
|
|
|
@GetMapping("/stopWaiting")
|
2024-01-26 13:12:04 +08:00
|
|
|
public Response<String> stopWaiting(@RequestParam("userId") Long userId,
|
2024-04-18 16:48:19 +08:00
|
|
|
@RequestParam("uniqueId") List<String> uniqueId,
|
2024-06-24 17:02:25 +08:00
|
|
|
@RequestParam("timeZone") String timeZone,
|
|
|
|
|
@RequestParam("type") String type) {
|
|
|
|
|
generateService.cancelGenerate(userId, uniqueId, timeZone, type);
|
2024-01-21 14:14:55 +08:00
|
|
|
return Response.success("stop waiting successfully");
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-18 14:07:20 +08:00
|
|
|
/*@ApiOperation(value = "获取生成结果")
|
2024-01-22 14:00:05 +08:00
|
|
|
@GetMapping("/result")
|
2024-01-24 11:43:56 +08:00
|
|
|
public Response<GenerateCollectionVO> getGenerateResult(@RequestParam("uniqueId") String uniqueId) {
|
2024-01-21 14:14:55 +08:00
|
|
|
GenerateCollectionVO generateResult = generateService.getGenerateResult(uniqueId);
|
|
|
|
|
return Response.success(generateResult);
|
2024-04-18 14:07:20 +08:00
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
@ApiOperation(value = "获取生成结果")
|
|
|
|
|
@PostMapping("/result")
|
|
|
|
|
public Response<List<GenerateResultVO>> getGenerateResults(@Valid @RequestBody List<String> taskIdList) {
|
|
|
|
|
List<GenerateResultVO> generateResult = generateService.getGenerateResultList(taskIdList);
|
|
|
|
|
return Response.success(generateResult);
|
2024-01-21 14:14:55 +08:00
|
|
|
}
|
2024-04-18 14:07:20 +08:00
|
|
|
|
2024-09-20 11:32:09 +08:00
|
|
|
@ApiOperation(value = "imageToSketch")
|
|
|
|
|
@PostMapping("/imageToSketch")
|
2024-09-23 11:13:44 +08:00
|
|
|
public Response<GenerateResultVO> imageToSketch(@Valid @RequestBody ImageToSketchDTO imageToSketchDTO) {
|
|
|
|
|
return Response.success(generateService.imageToSketch(imageToSketchDTO));
|
2024-09-20 11:32:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// modifySketch
|
|
|
|
|
@ApiOperation(value = "modifySketch")
|
|
|
|
|
@PostMapping("/modifySketch")
|
2024-09-27 15:40:30 +08:00
|
|
|
public Response<GenerateResultVO> modifySketch(@Valid @RequestBody GenerateModifyDTO generateModifyDTO) {
|
2024-09-23 11:13:44 +08:00
|
|
|
return Response.success(generateService.modifySketch(generateModifyDTO));
|
2024-09-20 11:32:09 +08:00
|
|
|
}
|
2024-04-18 14:07:20 +08:00
|
|
|
|
2023-08-17 11:59:19 +08:00
|
|
|
}
|