package com.fdage.controller;

import com.fdage.aop.WebControllerLog;
import com.fdage.dto.SceneDto;
import com.fdage.entity.SceneEntity;
import com.fdage.service.SceneService;
import com.fdage.util.AjaxJson;
import com.fdage.util.Result;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import springfox.documentation.annotations.ApiIgnore;

import javax.validation.Valid;

/**
 * Created by owen on 2021/8/23 0023 15:35
 */
@ApiIgnore
@Api(tags = "场景管理")
@RestController
@RequestMapping("/zhoushan/scene")
public class SceneController {
    @Autowired
    SceneService sceneService;

    @ApiOperation("列表")
    @PostMapping("list")
    public Result list() {
        return sceneService.findAll();
    }

    @WebControllerLog(description = "场景管理-新增/编辑")
    @ApiOperation("新增/编辑")
    @PostMapping("save")
    public Result<SceneEntity> save(@Valid @RequestBody SceneDto param) {
        return sceneService.saveEntity(param);
    }


    @WebControllerLog(description = "场景管理-删除")
    @ApiOperation(value = "删除", notes = "db数据软删除， 物理数据真删除")
    @GetMapping("remove/{id}")
    public Result remove(@PathVariable Long id) {
        return sceneService.remove(id);
    }

    @WebControllerLog(description = "场景管理-详情")
    @ApiOperation(value = "详情")
    @GetMapping("detail/{id}")
    public Result detail(@PathVariable Long id) {

        return sceneService.detail(id);
    }


    @ApiOperation(value = "上传", notes = "重命名文件")
    @PostMapping("upload")
    public Result upload(MultipartFile file) {

        return sceneService.upload(file, null, false);
    }
}
