package org.jeecg.modules.stm.doc.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 
 
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.stm.doc.entity.DocFilesHistory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.jeecg.modules.stm.doc.service.IDocFilesHistoryService;

import jakarta.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Description: 文件修改历史
 * @Author: jeecg-boot
 * @Date:   2025-07-07
 * @Version: V1.0
 */

@RestController
@RequestMapping("/doc/docFilesHistory")
@Slf4j
public class DocFilesHistoryController extends JeecgController<DocFilesHistory, IDocFilesHistoryService> {
	@Autowired
	private IDocFilesHistoryService docFilesHistoryService;
	
	/**
	 * 分页列表查询
	 *
	 * @param docFilesHistory
	 * @param pageNo
	 * @param pageSize
	 * @param req
	 * @return
	 */
	//@AutoLog(value = "文件修改历史-分页列表查询")

	@GetMapping(value = "/list")
	public Result<IPage<DocFilesHistory>> queryPageList(DocFilesHistory docFilesHistory,
								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
								   HttpServletRequest req) {
		QueryWrapper<DocFilesHistory> queryWrapper = QueryGenerator.initQueryWrapper(docFilesHistory, req.getParameterMap());
		Page<DocFilesHistory> page = new Page<DocFilesHistory>(pageNo, pageSize);
		IPage<DocFilesHistory> pageList = docFilesHistoryService.page(page, queryWrapper);
		return Result.OK(pageList);
	}

	@GetMapping(value = "/findHistoryByHisid")
	public Result<List<DocFilesHistory>> findHistoryByHisid(DocFilesHistory docFilesHistory, HttpServletRequest req) {
		QueryWrapper<DocFilesHistory> queryWrapper = QueryGenerator.initQueryWrapper(docFilesHistory, req.getParameterMap());
		List<DocFilesHistory> list = docFilesHistoryService.list(queryWrapper);
		return Result.OK(list);
	}


	@GetMapping(value = "/saveHistory")
	public void saveHistory(DocFilesHistory docFilesHistory, HttpServletRequest req) {
		QueryWrapper<DocFilesHistory> queryWrapper = QueryGenerator.initQueryWrapper(docFilesHistory, req.getParameterMap());
		docFilesHistoryService.save(docFilesHistory);
	}
}
