package com.aucma.report.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.aucma.common.utils.DateUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.aucma.common.annotation.Log;
import com.aucma.common.core.controller.BaseController;
import com.aucma.common.core.domain.AjaxResult;
import com.aucma.common.enums.BusinessType;
import com.aucma.report.domain.RealTaskInfo;
import com.aucma.report.service.IRealTaskInfoService;
import com.aucma.common.utils.poi.ExcelUtil;
import com.aucma.common.core.page.TableDataInfo;

/**
 * 任务信息Controller
 *
 * @author Yinq
 * @date 2023-11-02
 */
@RestController
@RequestMapping("/report/RealTaskInfo" )
public class RealTaskInfoController extends BaseController {
    @Autowired
    private IRealTaskInfoService realTaskInfoService;

    /**
     * 查询任务信息列表
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:list')" )
    @GetMapping("/list" )
    public TableDataInfo list(RealTaskInfo realTaskInfo) {
        startPage();
        List<RealTaskInfo> list = realTaskInfoService.selectRealTaskInfoList(realTaskInfo);
        return getDataTable(list);
    }

    /**
     * 导出任务信息列表
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:export')" )
    @Log(title = "任务信息" , businessType = BusinessType.EXPORT)
    @PostMapping("/export" )
    public void export(HttpServletResponse response, RealTaskInfo realTaskInfo) {
        List<RealTaskInfo> list = realTaskInfoService.selectRealTaskInfoList(realTaskInfo);
        ExcelUtil<RealTaskInfo> util = new ExcelUtil<RealTaskInfo>(RealTaskInfo. class);
        util.exportExcel(response, list, "任务信息数据" );
    }

    /**
     * 获取任务信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:query')" )
    @GetMapping(value = "/{objid}" )
    public AjaxResult getInfo(@PathVariable("objid" ) Long objid) {
        return success(realTaskInfoService.selectRealTaskInfoByObjid(objid));
    }

    /**
     * 新增任务信息
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:add')" )
    @Log(title = "任务信息" , businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RealTaskInfo realTaskInfo) {
        realTaskInfo.setCreatedBy(getUsername());
        realTaskInfo.setCreatedTime(DateUtils.getNowDate());
        return toAjax(realTaskInfoService.insertRealTaskInfo(realTaskInfo));
    }

    /**
     * 修改任务信息
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:edit')" )
    @Log(title = "任务信息" , businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RealTaskInfo realTaskInfo) {
        realTaskInfo.setUpdatedBy(getUsername());
        realTaskInfo.setUpdatedTime(DateUtils.getNowDate());
        return toAjax(realTaskInfoService.updateRealTaskInfo(realTaskInfo));
    }

    /**
     * 删除任务信息
     */
    @PreAuthorize("@ss.hasPermi('report:RealTaskInfo:remove')" )
    @Log(title = "任务信息" , businessType = BusinessType.DELETE)
    @DeleteMapping("/{objids}" )
    public AjaxResult remove(@PathVariable Long[] objids) {
        return toAjax(realTaskInfoService.deleteRealTaskInfoByObjids(objids));
    }
}
