package com.mosty.base.manager.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.mosty.base.model.dto.jcgl.TbJcglXlfaDto;
import com.mosty.base.model.query.jcgl.TbJcglXlfaQuery;
import com.mosty.base.manager.service.TbJcglXlfaService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

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

/**
 * @author dw
 * @since 2022/08/11
 **/
@Api(tags = "巡逻方案接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbJcglXlfa")
public class TbJcglXlfaController {

    private final TbJcglXlfaService tbJcglXlfaService;

    @ApiOperation("新增巡逻方案")
    @JwtSysUser
    @PostMapping
    @Log(title = "新增巡逻方案", businessType = BusinessType.INSERT)
    public ResponseResult<Integer> addEntity(@RequestBody TbJcglXlfaDto dto) {
        return ResponseResult.success(this.tbJcglXlfaService.addEntity(dto));
    }

    @ApiOperation("修改巡逻方案")
    @JwtSysUser
    @PutMapping
    @Log(title = "修改巡逻方案", businessType = BusinessType.UPDATE)
    public ResponseResult<Integer> updateEntity(@RequestBody TbJcglXlfaDto dto) {
        return ResponseResult.success(this.tbJcglXlfaService.updateEntity(dto));
    }

    @ApiOperation("删除巡逻方案")
    @JwtSysUser
    @DeleteMapping
    @Log(title = "删除巡逻方案", businessType = BusinessType.DELETE)
    public ResponseResult<Integer> delEntity(@RequestBody List<String> ids) {
        return ResponseResult.success(this.tbJcglXlfaService.delEntity(ids));
    }

    @ApiOperation("查询巡逻方案列表--分页")
    @JwtSysUser
    @GetMapping
    public ResponseResult<IPage<TbJcglXlfaDto>> getPageList(TbJcglXlfaQuery dto) {
        return ResponseResult.success(this.tbJcglXlfaService.getPageList(dto));
    }

    @ApiOperation("查询详情")
    @JwtSysUser
    @GetMapping("{id}")
    public ResponseResult<TbJcglXlfaDto> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbJcglXlfaService.getInfo(id));
    }
}
