package com.ai.da.controller;

import com.ai.da.common.config.exception.BusinessException;
import com.ai.da.common.response.Response;
import com.ai.da.model.dto.*;
import com.ai.da.model.vo.CollectionSketchVO;
import com.ai.da.model.vo.DesignCollectionVO;
import com.ai.da.model.vo.DesignLikeVO;
import com.ai.da.service.DesignService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.List;


@Api(tags = "design模块")
@Slf4j
@RestController
@RequestMapping("/api/design")
public class DesignController {
    @Resource
    private DesignService designService;

    @ApiOperation(value = "设计 Conllection")
    @PostMapping("/designCollection")
    @CrossOrigin
    public Response<DesignCollectionVO> designCollection(@Valid @RequestBody DesignCollectionDTO designDTO) {
        return Response.success(designService.designCollection(designDTO));
    }

    @ApiOperation(value = "design进度条")
    @GetMapping("/designProcess")
    public Response<Integer> designProcess(@RequestParam("processId") String processId) {
        return Response.success(designService.designProcess(processId));
    }

    @ApiOperation(value = "重新设计 Collection")
    @PostMapping("/reDesignCollection")
    public Response<DesignCollectionVO> reDesignCollection(@Valid @RequestBody ReDesignCollectionDTO reDesignDTO) {
        return Response.success(designService.reDesignCollection(reDesignDTO));
    }

    @ApiOperation(value = "designItem list,刷新用")
    @GetMapping("/designItemList")
    public Response<DesignCollectionVO> designItemList(@ApiParam("designId") @RequestParam("designId") Long designId) {
        return Response.success(designService.designItemList(designId));
    }

    @ApiOperation(value = "统计design进度")
    @PostMapping("/countDesignProcess")
    public Response<BigDecimal> countDesignProcess() {
        return Response.success(designService.countDesignProcess());
    }

    @ApiOperation(value = "Design Like")
    @PostMapping("/like")
    public Response<DesignLikeVO> like(@Valid @RequestBody DesignLikeDTO designLikeDTO) {
        return Response.success(designService.like(designLikeDTO));
    }

    @ApiOperation(value = "Design Dislike")
    @PostMapping("/dislike")
    public Response<Boolean> dislike(@Valid @RequestBody DisDesignLikeDTO disDesignLikeDTO) {
        return Response.success(designService.dislike(disDesignLikeDTO));
    }

    @ApiOperation(value = "sketchBoard upload generate design前裁剪")
    @PostMapping("/sketchBoardsBoundingBox")
    public Response<List<CollectionSketchVO>> sketchesBoundingBox(@Valid @RequestBody SketchesBoundingBoxDTO sketchesBoundingBoxDTO) {
        return Response.success(designService.sketchesBoundingBox(sketchesBoundingBoxDTO));
    }

    @ApiOperation(value = "通过designItemId获取模特图")
    @PostMapping("/getModel")
    public Response<List<String>> getModel(@RequestBody List<Long> designItemIdList){
        return Response.success(designService.getModel(designItemIdList));
    }

}
