package com.mosty.yszx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.vo.yszx.TbYsDlQuery;
import com.mosty.base.model.vo.yszx.TbYsDlVo;
import com.mosty.common.base.domain.BaseController;
import com.mosty.common.base.domain.ResponseResult;
import com.mosty.common.base.entity.log.BusinessType;
import com.mosty.common.base.entity.log.Log;
import com.mosty.common.token.JwtSysUser;
import com.mosty.base.model.vo.yszx.TbYsDlDto;
import com.mosty.base.model.entity.yszx.TbYsDl;
import com.mosty.yszx.service.TbYsDlService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import javax.annotation.Resource;


/**
 * @author dw
 * @since 2022/7/18
 * 要素中心-地理要素
 **/
@Api(tags = "要素中心-地理要素")
@RestController
@AllArgsConstructor
@RequestMapping("/tbYsDl")
public class TbYsDlController extends BaseController {

    @Resource
    private TbYsDlService tbYsDlService;

    @RequestMapping(value = "/selectGeography", method = {RequestMethod.GET, RequestMethod.POST})
    @ApiOperation(value = "大屏-地图-地理要素(社会资源),pageNum参数不传则查询所有数据")
    @JwtSysUser
    public ResponseResult<IPage<TbYsDlVo>> queryAll(@RequestBody TbYsDlQuery dto) {
        return ResponseResult.success(this.tbYsDlService.queryAll(dto));
    }

    @GetMapping("/selectByNr")
    @ApiOperation(value = "根据关键字查询地理要素")
    @JwtSysUser
    public ResponseResult<List<TbYsDlVo>> selectByNr(@RequestParam("keyword") String keyword) {
        return ResponseResult.success(this.tbYsDlService.selectByNr(keyword));
    }

    @ApiOperation(value = "通过主键查询单条数据")
    @GetMapping("{id}")
    public ResponseResult<TbYsDlVo> queryById(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbYsDlService.queryById(id));
    }

    @ApiOperation(value = "新增地理要素数据")
    @PostMapping
    public ResponseResult<Void> add(@RequestBody TbYsDlDto dto) {
        this.tbYsDlService.insert(dto);
        return ResponseResult.success();
    }

    @ApiOperation(value = "编辑地理要素数据")
    @PutMapping
    @Log(title = "编辑地理要素数据", businessType = BusinessType.INSERT)
    public ResponseResult<Void> edit(@RequestBody TbYsDlDto dto) {
        this.tbYsDlService.update(dto);
        return ResponseResult.success();
    }

    @ApiOperation(value = "删除")
    @DeleteMapping("{id}")
    @Log(title = "删除地理要素数据", businessType = BusinessType.INSERT)
    public ResponseResult<Void> deleteById(@PathVariable("id") String id) {
        this.tbYsDlService.deleteById(id);
        return ResponseResult.success();
    }

    @PostMapping("/selectVideoServo")
    @ApiOperation(value = "大屏-巡组气泡框-视频随动")
    @JwtSysUser
    public ResponseResult<List<TbYsDl>> selectVideoServo(@RequestBody TbYsDl tbYsDl) {
        return ResponseResult.success(this.tbYsDlService.selectVideoServo(tbYsDl));
    }

    @GetMapping("/selectDlys")
    @ApiOperation(value = "根据名称查询地理要素")
    @JwtSysUser
    public ResponseResult<TbYsDl> selectDlys(@RequestParam String ysmc) {
        return ResponseResult.success(this.tbYsDlService.selectDlys(ysmc));
    }
}


