package com.ruoyi.model.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.model.domain.AppletServiceDate;
import com.ruoyi.model.service.IAppletServiceDateService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务日期Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletServiceDate")
public class AppletServiceDateController extends BaseController
{
    @Autowired
    private IAppletServiceDateService appletServiceDateService;

    /**
     * 查询服务日期列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletServiceDate appletServiceDate)
    {
        startPage();
        List<AppletServiceDate> list = appletServiceDateService.selectAppletServiceDateList(appletServiceDate);
        return getDataTable(list);
    }

    /**
     * 导出服务日期列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:export')")
    @Log(title = "服务日期", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletServiceDate appletServiceDate)
    {
//        List<AppletServiceDate> list = appletServiceDateService.selectAppletServiceDateList(appletServiceDate);
//        ExcelUtil<AppletServiceDate> util = new ExcelUtil<AppletServiceDate>(AppletServiceDate.class);
//        util.exportExcel(response, list, "服务日期数据");
    }

    /**
     * 获取服务日期详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletServiceDateService.selectAppletServiceDateById(id));
    }

    /**
     * 新增服务日期
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:add')")
    @Log(title = "服务日期", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletServiceDate appletServiceDate)
    {
        return toAjax(appletServiceDateService.insertAppletServiceDate(appletServiceDate));
    }

    /**
     * 修改服务日期
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:edit')")
    @Log(title = "服务日期", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletServiceDate appletServiceDate)
    {
        return toAjax(appletServiceDateService.updateAppletServiceDate(appletServiceDate));
    }

    /**
     * 删除服务日期
     */
    @PreAuthorize("@ss.hasPermi('model:AppletServiceDate:remove')")
    @Log(title = "服务日期", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletServiceDateService.deleteAppletServiceDateByIds(ids));
    }
}
