package com.tofly.feesapi.bjgl.controller;

import com.tofly.feesapi.common.core.ResultRespone;
import com.tofly.feesapi.bjgl.entity.YhCbkxxLog;
import com.tofly.feesapi.bjgl.entity.dto.YhCbkxxFilter;
import com.tofly.feesapi.bjgl.service.YhCbkxxLogService;
import com.tofly.feesapi.common.core.dto.PageDto;
import com.tofly.feesapi.common.core.vo.PageResult;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.web.bind.annotation.ModelAttribute;

import java.util.Arrays;

@RestController
@AllArgsConstructor
@RequestMapping("api/bjgl/yhcbkxxlog")
@Api(tags = "水表档案-水表档案日志记录表接口")
public class YhCbkxxLogController {

    @Autowired
    private YhCbkxxLogService yhCbkxxLogService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone<PageResult<YhCbkxxLog>> getYhCbkxxLogPage(PageDto pageDto, @ModelAttribute YhCbkxxFilter filter) {
        return ResultRespone.success(yhCbkxxLogService.getYhCbkxxLogPage(pageDto, filter));
    }

    @GetMapping("/{ljfbz}")
    @ApiOperation(value = "通过ID查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ljfbz", value = "ID", required = true, dataType = "String")
    })
    public ResultRespone getById(@PathVariable("ljfbz") String ljfbz) {
        return ResultRespone.success(yhCbkxxLogService.getById(ljfbz));
    }

    @ApiOperation(value = "通过ID批量删除水表档案日志记录表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "ids", value = "批量删除，多个id以逗号隔开", required = true, dataType = "String")
    })
    @DeleteMapping("/deleteByIds")
    public ResultRespone removeByIds(String ids) {
        return ResultRespone.success(yhCbkxxLogService.removeByIds(Arrays.asList(ids.split(","))));
    }
}
