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.DailyUser;
import com.ruoyi.system.service.IDailyUserService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * userDailyController
 * 
 * @author 昊天
 * @date 2024-11-04
 */
@RestController
@RequestMapping("/system/userDaily")
public class DailyUserController extends BaseController
{
    @Autowired
    private IDailyUserService dailyUserService;

    /**
     * 查询userDaily列表
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:list')")
    @GetMapping("/list")
    public TableDataInfo list(DailyUser dailyUser)
    {
        startPage();
        List<DailyUser> list = dailyUserService.selectDailyUserList(dailyUser);
        return getDataTable(list);
    }

    /**
     * 导出userDaily列表
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:export')")
    @Log(title = "userDaily", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DailyUser dailyUser)
    {
        List<DailyUser> list = dailyUserService.selectDailyUserList(dailyUser);
        ExcelUtil<DailyUser> util = new ExcelUtil<DailyUser>(DailyUser.class);
        util.exportExcel(response, list, "userDaily数据");
    }

    /**
     * 获取userDaily详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:query')")
    @GetMapping(value = "/{dailyUserId}")
    public AjaxResult getInfo(@PathVariable("dailyUserId") Long dailyUserId)
    {
        return success(dailyUserService.selectDailyUserByDailyUserId(dailyUserId));
    }

    /**
     * 新增userDaily
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:add')")
    @Log(title = "userDaily", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DailyUser dailyUser)
    {
        return toAjax(dailyUserService.insertDailyUser(dailyUser));
    }

    /**
     * 修改userDaily
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:edit')")
    @Log(title = "userDaily", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DailyUser dailyUser)
    {
        return toAjax(dailyUserService.updateDailyUser(dailyUser));
    }

    /**
     * 删除userDaily
     */
    @PreAuthorize("@ss.hasPermi('system:userDaily:remove')")
    @Log(title = "userDaily", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dailyUserIds}")
    public AjaxResult remove(@PathVariable Long[] dailyUserIds)
    {
        return toAjax(dailyUserService.deleteDailyUserByDailyUserIds(dailyUserIds));
    }
}
