src/main/kotlin/cn/flightfeather/supervision/lightshare/web/ScenseController.kt
@@ -1,40 +1,51 @@
package cn.flightfeather.supervision.lightshare.web
import cn.flightfeather.supervision.config.IgnoreResponseAdvice
import cn.flightfeather.supervision.domain.ds1.entity.Scense
import cn.flightfeather.supervision.domain.ds1.entity.Task
import cn.flightfeather.supervision.lightshare.service.ScenseService
import cn.flightfeather.supervision.lightshare.vo.AreaVo
import cn.flightfeather.supervision.lightshare.vo.BaseResponse
import cn.flightfeather.supervision.lightshare.vo.SceneDetailStr
import io.swagger.annotations.Api
import io.swagger.annotations.ApiImplicitParam
import io.swagger.annotations.ApiOperation
import org.springframework.web.bind.annotation.*
import org.springframework.web.multipart.MultipartFile
@Api(tags = ["ScenseController"], description = "监管场景API接口")
@RestController
@RequestMapping("/scense")
class ScenseController(val scenseService: ScenseService) {
    @IgnoreResponseAdvice
    @GetMapping
    fun getAll() = scenseService.findAll()
    @IgnoreResponseAdvice
    @PutMapping
    fun add(@RequestBody scense: Scense) = scenseService.save(scense)
    @IgnoreResponseAdvice
    @PostMapping
    fun update(@RequestBody scense: Scense) = scenseService.update(scense)
    @IgnoreResponseAdvice
    @PostMapping("/update/list")
    fun updateList(@RequestBody sceneList: MutableList<Scense>) = scenseService.updateList(sceneList)
    @IgnoreResponseAdvice
    @PostMapping("/search")
    fun find(@RequestBody scense: Scense) = scenseService.search(scense)
    @IgnoreResponseAdvice
    @GetMapping("/{id}")
    fun getById(@PathVariable id: String) = scenseService.findOne(id)
    @IgnoreResponseAdvice
    @DeleteMapping("/{id}")
    fun delete(@PathVariable id: String) = scenseService.delete(id)
    @IgnoreResponseAdvice
    @GetMapping("/alltype")
    fun getSceneType() = scenseService.getSceneType()
@@ -44,6 +55,7 @@
     * @param mode 0:只会获取总任务对应的监管版本中存在的场景;1:除了监管版本中存在的场景,还会获取剩余的可用场景
     * @return 场景列表
     */
    @IgnoreResponseAdvice
    @PostMapping("/getByTask")
    fun getByTaskId(@RequestBody task: Task, @RequestParam(value = "mode") mode: Int) = scenseService.getByTaskId(task, mode)
@@ -73,4 +85,30 @@
            @RequestBody sceneDetailStr: SceneDetailStr
    ) = scenseService.updateSceneDetail(typeId, sceneDetailStr)
    @PostMapping("/find")
    fun searchScene(
        @RequestBody areaVo: AreaVo,
        @RequestParam("page", required = false) page: Int?,
        @RequestParam("per_page", required = false) perPage: Int?
    ) = scenseService.searchScene(areaVo, page, perPage)
    @ApiOperation(value = "根据圆心和半径找到范围内的场景")
    @PostMapping("/find/coor")
    fun searchByCoordinate(
        @RequestParam("lng") lng: Double,
        @RequestParam("lat") lat: Double,
        @RequestParam("radius") radius: Double,
    ) = scenseService.searchByCoordinate(lng, lat, radius)
    @ApiOperation(value = "通过文件导入场景信息")
    @PostMapping("/import")
    fun importSceneInfo(
        @RequestPart("file") files: Array<MultipartFile>,
    ) = scenseService.importSceneInfo(files)
    @ApiOperation(value = "创建场景信息")
    @PutMapping("/create")
    fun createScene(
        @RequestBody scense: Scense
    ) = scenseService.createScene(scense)
}