package com.ruoyi.business.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.database.domain.gwglLog;
import com.ruoyi.database.service.gwglLogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Description gwglLogController
 * @Author lijingtong
 * @Date 2025-06-06
 */

@Api(tags = "审批日志")
@RestController
@RequestMapping("/gwglLog")
@RequiredArgsConstructor
public class gwglLogController extends BaseController {

    private final gwglLogService gwglLogService;

    @ApiOperation("查询审批日志")
    @PostMapping("/list")
    public TableDataInfo query(@RequestBody gwglLog gwglLog){
        startPage();
        QueryWrapper<gwglLog> queryWrapper = new QueryWrapper<>(gwglLog);
//        queryWrapper.orderByDesc("create_time");
        return getDataTable(gwglLogService.list(queryWrapper));
    }

    @ApiOperation("根据编号查询日志")
    @GetMapping("/detail/{applyNo}")
    public TableDataInfo detail(@PathVariable String applyNo){
        QueryWrapper<gwglLog> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("apply_no", applyNo);
        List<gwglLog> list = gwglLogService.list(queryWrapper);
        long size = list.size();
        return getDataTableEnhance(list, size);
    }
}
