package com.ruoyi.ibs.draw.controller;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.ibs.draw.domain.dto.DrawShapeDTO;
import com.ruoyi.ibs.draw.service.DrawGridCustService;
import com.ruoyi.ibs.draw.service.DrawShapeService;
import com.ruoyi.ibs.draw.utils.DrawUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = "绘制测试接口")
@RestController
@RequestMapping("/draw")
public class DrawController extends BaseController {

    @Resource
    private DrawShapeService drawShapeService;

    @Resource
    private DrawGridCustService drawGridCustService;

    @ApiOperation("判断绘制的图形是否重叠")
    @Log(title = "自定义绘制网格-判断绘制的图形是否重叠")
    @PostMapping("/intersect")
    public AjaxResult intersect(@RequestBody DrawShapeDTO drawShapeDTO) {

        return AjaxResult.success(DrawUtils.isIntersect(drawShapeDTO.getWktA(), drawShapeDTO.getWktB()));
    }

    @ApiOperation("测试")
    @GetMapping("/test")
    public void test(@RequestParam Long shapeId) {

        drawGridCustService.updateCustListByShape(shapeId);
        return;
    }
}
