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.AppletTrain;
import com.ruoyi.model.service.IAppletTrainService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 服务培训Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletTrain")
public class AppletTrainController extends BaseController
{
    @Autowired
    private IAppletTrainService appletTrainService;

    /**
     * 查询服务培训列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletTrain appletTrain)
    {
        startPage();
        List<AppletTrain> list = appletTrainService.selectAppletTrainList(appletTrain);
        return getDataTable(list);
    }

    /**
     * 导出服务培训列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:export')")
    @Log(title = "服务培训", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletTrain appletTrain)
    {
//        List<AppletTrain> list = appletTrainService.selectAppletTrainList(appletTrain);
//        ExcelUtil<AppletTrain> util = new ExcelUtil<AppletTrain>(AppletTrain.class);
//        util.exportExcel(response, list, "服务培训数据");
    }

    /**
     * 获取服务培训详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletTrainService.selectAppletTrainById(id));
    }

    /**
     * 新增服务培训
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:add')")
    @Log(title = "服务培训", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletTrain appletTrain)
    {
        return toAjax(appletTrainService.insertAppletTrain(appletTrain));
    }

    /**
     * 修改服务培训
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:edit')")
    @Log(title = "服务培训", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletTrain appletTrain)
    {
        return toAjax(appletTrainService.updateAppletTrain(appletTrain));
    }

    /**
     * 删除服务培训
     */
    @PreAuthorize("@ss.hasPermi('model:AppletTrain:remove')")
    @Log(title = "服务培训", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletTrainService.deleteAppletTrainByIds(ids));
    }
}
