package com.tofly.feesapi.yhgl.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.feesapi.common.core.ResultRespone;
import com.tofly.feesapi.common.core.dto.PageDto;
import com.tofly.feesapi.common.core.vo.PageResult;
import com.tofly.feesapi.yhgl.entity.YhKhjbxxLog;
import com.tofly.feesapi.yhgl.entity.dto.YhywLogFilter;
import com.tofly.feesapi.yhgl.service.YhKhjbxxLogService;
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
@RequestMapping("api/yhgl/yhkhjbxxlog")
@Api(tags = "用户管理-用户档案日志记录表接口")
public class YhKhjbxxLogController {

    @Autowired
    private YhKhjbxxLogService yhKhjbxxLogService;

    @GetMapping("/page")
    @ApiOperation(value = "分页查询")
    public ResultRespone getYhKhjbxxLogPage(Page page, @ModelAttribute YhKhjbxxLog yhKhjbxxLog) {
        return ResultRespone.success(yhKhjbxxLogService.page(page, Wrappers.query(yhKhjbxxLog)));
    }

    @GetMapping("/getpage")
    @ApiOperation(value = "分页查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "current", value = "当前页码", required = true, dataType = "int"),
            @ApiImplicitParam(name = "size", value = "每页显示数据条数", required = true, dataType = "int"),
    })
    public ResultRespone<PageResult<YhKhjbxxLog>> getLogPage(@ModelAttribute PageDto pageDto, @ModelAttribute YhywLogFilter filter) {
        return ResultRespone.success(yhKhjbxxLogService.getLogPage(pageDto, filter));

    }

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

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


}
