package com.njcn.device.terminal.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.device.pq.pojo.param.LogsListParam;
import com.njcn.device.pq.pojo.po.PqsTerminalLogs;
import com.njcn.device.terminal.service.IPqsTerminalLogsService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author hongawen
 * @since 2023-04-13
 */
@Slf4j
@Api(tags = "日志")
@RestController
@RequestMapping("/pqsTerminalLogs")
@RequiredArgsConstructor
public class PqsTerminalLogsController extends BaseController {

    private final IPqsTerminalLogsService iPqsTerminalLogsService;

    /**
     * 新增日志表数据
     *
     * @author zbj
     * @date 2023/4/13
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/saveLogs")
    @ApiOperation("新增日志表数据")
    @ApiImplicitParam(name = "pqsTerminalLogs", value = "实体", required = true)
    public HttpResult<Object> saveLogs(@RequestBody PqsTerminalLogs pqsTerminalLogs) {
        String methodDescribe = getMethodDescribe("saveLogs");
        boolean res = iPqsTerminalLogsService.saveLogs(pqsTerminalLogs);
        if (res) {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
        } else {
            return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
        }
    }

    /**
     * 运维日志页面展示
     *
     * @author zbj
     * @date 2023/4/13
     */
    @OperateInfo(info = LogEnum.BUSINESS_COMMON)
    @PostMapping("/getList")
    @ApiOperation("运维日志页面展示")
    @ApiImplicitParam(name = "logsListParam", value = "实体", required = true)
    public HttpResult<Page<PqsTerminalLogs>> getList(@RequestBody LogsListParam logsListParam) {
        String methodDescribe = getMethodDescribe("getList");
        Page<PqsTerminalLogs> result = iPqsTerminalLogsService.getList(logsListParam);
        return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
    }
}

