package com.mosty.rzzx.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
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.dto.rzzx.TbRzDyjkInsertDto;
import com.mosty.base.model.dto.rzzx.TbRzDyjkUpdateDto;
import com.mosty.base.model.entity.rzzx.TbRzDyjk;
import com.mosty.base.model.query.rzzx.TbRzDyjkQueryDto;
import com.mosty.rzzx.service.TbRzDyjkService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author dw
 * @since 2022/7/18
 * 接口调用日志接口
 **/
@Api(tags = "日志中心-接口调用日志接口")
@RestController
@AllArgsConstructor
@RequestMapping("/tbRzDyjk")
public class TbRzDyjkController extends BaseController {

    private final TbRzDyjkService tbRzDyjkService;

    @ApiOperation("接口调用日志接口新增")
    @JwtSysUser
    @Log(title = "接口调用日志接口新增", businessType = BusinessType.INSERT)
    @PostMapping("add")
    public ResponseResult<Integer> insertEntity(@RequestBody TbRzDyjkInsertDto dto) {
        return ResponseResult.success(this.tbRzDyjkService.insertEntity(dto));
    }

    @ApiOperation("接口调用日志接口修改-补充调用结束时间")
    @JwtSysUser
    @Log(title = "接口调用日志接口修改-补充调用结束时间", businessType = BusinessType.UPDATE)
    @PostMapping("update")
    public ResponseResult<Integer> updateEntity(@RequestBody TbRzDyjkUpdateDto dto) {
        return ResponseResult.success(this.tbRzDyjkService.updateEntity(dto));
    }

    @ApiOperation("接口调用日志详情")
    @JwtSysUser
    @GetMapping("getInfo/{id}")
    public ResponseResult<TbRzDyjk> getInfo(@PathVariable("id") String id) {
        return ResponseResult.success(this.tbRzDyjkService.getInfo(id));
    }

    @ApiOperation("分页查询接口")
    @JwtSysUser
    @GetMapping("getList")
    public ResponseResult<IPage<TbRzDyjk>> getList(TbRzDyjkQueryDto dto) {
        return ResponseResult.success(this.tbRzDyjkService.getList(dto));
    }
}
