package com.cyl.manager.oth.controller;

import java.util.List;

import com.cyl.manager.oth.domain.entity.ScenicSpotInfo;
import com.cyl.manager.oth.domain.query.ScenicSpotInfoQuery;
import com.cyl.manager.oth.service.ScenicSpotInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Page;
import org.springframework.http.ResponseEntity;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.enums.BusinessType;
/**
 * 展馆&景点信息Controller
 *
 * @author zcc
 * @date 2024-08-01
 */
@Api(description ="展馆&景点信息接口列表")
@RestController
@RequestMapping("/oth/scenicSpotInfo")
public class ScenicSpotInfoController extends BaseController {
    @Autowired
    private ScenicSpotInfoService service;

    @ApiOperation("查询展馆&景点信息列表")
    @PreAuthorize("@ss.hasPermi('oth:scenicSpotInfo:list')")
    @PostMapping("/list")
    public ResponseEntity<Page<ScenicSpotInfo>> list(@RequestBody ScenicSpotInfoQuery query, Pageable page) {
        List<ScenicSpotInfo> list = service.selectList(query, page);
        return ResponseEntity.ok(new PageImpl<>(list, page, ((com.github.pagehelper.Page)list).getTotal()));
    }

    @ApiOperation("获取展馆&景点信息详细信息")
    @PreAuthorize("@ss.hasPermi('oth:scenicSpotInfo:query')")
    @GetMapping(value = "/{id}")
    public ResponseEntity<ScenicSpotInfo> getInfo(@PathVariable("id") Long id) {
        return ResponseEntity.ok(service.selectById(id));
    }

    @ApiOperation("新增展馆&景点信息")
    @PreAuthorize("@ss.hasPermi('oth:scenicSpotInfo:add')")
    @Log(title = "展馆&景点信息", businessType = BusinessType.INSERT)
    @PostMapping
    public ResponseEntity<Integer> add(@RequestBody ScenicSpotInfo scenicSpotInfo) {
        return ResponseEntity.ok(service.insert(scenicSpotInfo));
    }

    @ApiOperation("修改展馆&景点信息")
    @PreAuthorize("@ss.hasPermi('oth:scenicSpotInfo:edit')")
    @Log(title = "展馆&景点信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public ResponseEntity<Integer> edit(@RequestBody ScenicSpotInfo scenicSpotInfo) {
        return ResponseEntity.ok(service.update(scenicSpotInfo));
    }

    @ApiOperation("删除展馆&景点信息")
    @PreAuthorize("@ss.hasPermi('oth:scenicSpotInfo:remove')")
    @Log(title = "展馆&景点信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public ResponseEntity<Integer> remove(@PathVariable Long[] ids) {
        return ResponseEntity.ok(service.deleteByIds(ids));
    }
}
