package org.jeecg.modules.checkData.dynamicStaticGeometricData.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.dto.RailInspectionEquipmentDTO;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipment;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.entity.RailInspectionEquipmentVO;
import org.jeecg.modules.checkData.dynamicStaticGeometricData.service.IRailInspectionEquipmentService;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;

/**
 * <p>
 * 检查数据-动静态几何尺寸数据-轨检仪静态检查数据 前端控制器
 * </p>
 *
 * @author hkl
 * @since 2023-07-16
 */
@RestController
@RequestMapping("/checkData/dynamicStaticGeometricData/railInspectionEquipment")
public class RailInspectionEquipmentController extends JeecgController<RailInspectionEquipment, IRailInspectionEquipmentService> {


    @AutoLog(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-分页列表查询")
    @ApiOperation(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-分页列表查询", notes = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-分页列表查询")
    @GetMapping(value = "/list")
    public Result<IPage<RailInspectionEquipmentVO>> queryPageList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                                  @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
                                                                  RailInspectionEquipmentDTO dto) {
        Page<RailInspectionEquipmentVO> pageData = new Page<>(pageNo, pageSize);
        pageData = this.service.queryPageList(pageData, dto);
        return Result.OK(pageData);
    }

    @AutoLog(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-编辑")
    @ApiOperation(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-编辑", notes = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-编辑")
    @PostMapping(value = "/edit")
    public Result<String> edit(@RequestBody RailInspectionEquipment railInspectionEquipment) {

        this.service.edit(railInspectionEquipment);


        return Result.OK("编辑成功!");
    }

    @AutoLog(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-通过id删除")
    @ApiOperation(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-通过id删除", notes = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-通过id删除")
    @GetMapping(value = "/delete")
    public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
        this.service.removeById(id);
        return Result.OK("删除成功!");
    }

    @AutoLog(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-批量删除")
    @ApiOperation(value = "检查数据-动静态几何尺寸数据-轨检仪静态检查数据-批量删除", notes = "资产管理-扣件管理-批量删除")
    @GetMapping(value = "/deleteBatch")
    public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
        this.service.removeByIds(Arrays.asList(ids.split(",")));
        return Result.OK("批量删除成功!");
    }

}
