package org.nl.system.controller.logicflow;


import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.base.TableDataInfo;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.logging.annotation.Log;
import org.nl.system.service.logicflow.IStageImageService;
import org.nl.system.service.logicflow.dao.StageImage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
import java.util.Set;


/**
 * @Author: lyd
 * @Description: 舞台图标控制层
 * @Date: 2022-07-29
 */
@RestController
@RequiredArgsConstructor
@Api(tags = "舞台管理")
@RequestMapping("/api/stageImage")
@Slf4j
public class StageImageController {

    @Autowired
    private IStageImageService stageImageService;
    @GetMapping
    @Log("查询舞台")
    @ApiOperation("查询舞台")
    //@SaCheckPermission("stageImage:list")
    public ResponseEntity<Object> query(@RequestParam Map whereJson, PageQuery page) {
        return new ResponseEntity<>(TableDataInfo.build(stageImageService.queryAll(whereJson, page)), HttpStatus.OK);
    }

    @PostMapping
    @Log("新增舞台图片")
    @ApiOperation("新增舞台图片")
    //@SaCheckPermission("stageImage:add")
    public ResponseEntity<Object> create(@Validated @RequestBody StageImage entity) {
        stageImageService.create(entity);
        return new ResponseEntity<>(HttpStatus.CREATED);
    }

    @PutMapping
    @Log("修改舞台")
    @ApiOperation("修改舞台")
    //@SaCheckPermission("stageImage:edit")
    public ResponseEntity<Object> update(@Validated @RequestBody StageImage entity) {
        stageImageService.update(entity);
        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
    }

    @Log("删除舞台")
    @ApiOperation("删除舞台")
    //@SaCheckPermission("stageImage:del")
    @DeleteMapping
    public ResponseEntity<Object> delete(@RequestBody Set<String> ids) {
        stageImageService.deleteAll(ids);
        return new ResponseEntity<>(HttpStatus.OK);
    }

    @GetMapping("/selectList")
    @Log("下拉选设备图标")
    @ApiOperation("下拉选设备图标")
    //@SaCheckPermission("routePlan:list")
    public ResponseEntity<Object> selectList() {
        return new ResponseEntity<>(stageImageService.selectList(), HttpStatus.OK);
    }
}

