package com.dayou.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.web.bind.annotation.RestController;
import com.dayou.service.IOperationLogService;
import com.dayou.entity.OperationLog;
import com.dayou.common.RestResponse;
import org.springframework.web.bind.annotation.*;

/**
 * 系统操作日志
 *
 * @author wucl
 * @since 2023-01-16
 */
@RestController
@RequestMapping("operationLog")
@Slf4j
public class OperationLogController extends BaseController {
    @Autowired
    private IOperationLogService operationLogService;

    /**
    * 系统操作日志列表
    */
    @GetMapping("")
    public RestResponse<Page<OperationLog>> page(OperationLog operationLog, Page page){
        Page<OperationLog> pages=operationLogService.selectPage(page,operationLog);
        return RestResponse.data(pages);
    }

    /**
     * 系统操作日志详情
     */
    @GetMapping("/{id}")
    public RestResponse<OperationLog> detail(@PathVariable Long id){
        OperationLog xOperationLog =operationLogService.detail(id);
        return RestResponse.data(xOperationLog);
     }

    /**
     * 系统操作日志新增
     */
    @PostMapping("")
    public RestResponse<Boolean> save(@RequestBody OperationLog operationLog) {
        Boolean ret = operationLogService.add(operationLog);
        return RestResponse.data(ret);
    }

    /**
     * 系统操作日志更新
     */
    @PutMapping("")
    public RestResponse<Boolean> update(@RequestBody OperationLog operationLog) {
        Boolean ret = operationLogService.update(operationLog);
        return RestResponse.data(ret);
    }

    /**
     * 系统操作日志删除
     */
    @DeleteMapping("/{id}")
    public RestResponse<Boolean> delete(@PathVariable Long id) {
        Boolean ret = operationLogService.delete(id);
        return RestResponse.data(ret);
    }


}

