package com.ruoyi.adjust.controller;

import java.util.List;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ruoyi.adjust.domain.AsynchExpLog;
import com.ruoyi.adjust.service.IAsynchExpLogService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 异步导出日志Controller
 * 
 * @author klbc
 * @date 2022-05-22
 */
@RestController
@RequestMapping("/adjust/asynchExpLog")
public class AsynchExpLogController extends BaseController {
	@Autowired
	private IAsynchExpLogService asynchExpLogService;

	/**
	 * 查询异步导出日志列表
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:list')")
	@GetMapping("/list")
	public TableDataInfo list(AsynchExpLog asynchExpLog) {
		startPage();
		asynchExpLog.setCreateBy(getUsername());
		List<AsynchExpLog> list = asynchExpLogService.selectAsynchExpLogList(asynchExpLog);
		return getDataTable(list);
	}

	/**
	 * 导出异步导出日志列表
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:export')")
	@Log(title = "异步导出日志", businessType = BusinessType.EXPORT)
	@PostMapping("/export")
	public void export(HttpServletResponse response, AsynchExpLog asynchExpLog) {
		List<AsynchExpLog> list = asynchExpLogService.selectAsynchExpLogList(asynchExpLog);
		ExcelUtil<AsynchExpLog> util = new ExcelUtil<AsynchExpLog>(AsynchExpLog.class);
		util.exportExcel(response, list, "异步导出日志数据");
	}

	/**
	 * 获取异步导出日志详细信息
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:query')")
	@GetMapping(value = "/{id}")
	public AjaxResult getInfo(@PathVariable("id") Long id) {
		return AjaxResult.success(asynchExpLogService.selectAsynchExpLogById(id));
	}

	/**
	 * 新增异步导出日志
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:add')")
	@Log(title = "异步导出日志", businessType = BusinessType.INSERT)
	@PostMapping
	public AjaxResult add(@RequestBody AsynchExpLog asynchExpLog) {
		return toAjax(asynchExpLogService.insertAsynchExpLog(asynchExpLog));
	}

	/**
	 * 修改异步导出日志
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:edit')")
	@Log(title = "异步导出日志", businessType = BusinessType.UPDATE)
	@PutMapping
	public AjaxResult edit(@RequestBody AsynchExpLog asynchExpLog) {
		return toAjax(asynchExpLogService.updateAsynchExpLog(asynchExpLog));
	}

	/**
	 * 删除异步导出日志
	 */
	@PreAuthorize("@ss.hasPermi('adjust:asynchExpLog:remove')")
	@Log(title = "异步导出日志", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
	public AjaxResult remove(@PathVariable Long[] ids) {
		return toAjax(asynchExpLogService.deleteAsynchExpLogByIds(ids));
	}
}
