package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DailyWork;
import com.ruoyi.system.service.IDailyWorkService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 作品每日统计Controller
 * 
 * @author haotian
 * @date 2024-11-08
 */
@RestController
@RequestMapping("/system/dailyWork")
public class DailyWorkController extends BaseController
{
    @Autowired
    private IDailyWorkService dailyWorkService;

    /**
     * 查询作品每日统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailyWork dailyWork)
    {
        startPage();
        List<DailyWork> list = dailyWorkService.selectDailyWorkList(dailyWork);
        return getDataTable(list);
    }

    /**
     * 导出作品每日统计列表
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:export')")
    @Log(title = "作品每日统计", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailyWork dailyWork)
    {
        List<DailyWork> list = dailyWorkService.selectDailyWorkList(dailyWork);
        ExcelUtil<DailyWork> util = new ExcelUtil<DailyWork>(DailyWork.class);
        util.exportExcel(response, list, "作品每日统计数据");
    }

    /**
     * 获取作品每日统计详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:query')")
    @GetMapping(value = "/{dailyWorkId}")
    public AjaxResult getInfo(@PathVariable("dailyWorkId") Long dailyWorkId)
    {
        return success(dailyWorkService.selectDailyWorkByDailyWorkId(dailyWorkId));
    }

    /**
     * 新增作品每日统计
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:add')")
    @Log(title = "作品每日统计", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailyWork dailyWork)
    {
        return toAjax(dailyWorkService.insertDailyWork(dailyWork));
    }

    /**
     * 修改作品每日统计
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:edit')")
    @Log(title = "作品每日统计", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailyWork dailyWork)
    {
        return toAjax(dailyWorkService.updateDailyWork(dailyWork));
    }

    /**
     * 删除作品每日统计
     */
    @PreAuthorize("@ss.hasPermi('system:dailyWork:remove')")
    @Log(title = "作品每日统计", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailyWorkIds}")
    public AjaxResult remove(@PathVariable Long[] dailyWorkIds)
    {
        return toAjax(dailyWorkService.deleteDailyWorkByDailyWorkIds(dailyWorkIds));
    }
}
