package com.ruoyi.app.mendian;

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

import com.ruoyi.common.annotation.Anonymous;
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.ServiceType;
import com.ruoyi.system.service.IServiceTypeService;
import com.ruoyi.common.utils.MessageUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * ServiceTypeController
 * 
 * @author ruoyi
 * @date 2024-02-24
 */
@RestController
@RequestMapping("/system/ServiceType")
public class ServiceTypeController extends BaseController
{
    @Autowired
    private IServiceTypeService serviceTypeService;

    //获取服务类型列表
    @Anonymous
    @GetMapping("/fwlxlist")
    public TableDataInfo fwlxlist(ServiceType serviceType)
    {
        startPage();
        List<ServiceType> list = serviceTypeService.selectServiceTypeList(serviceType);
        return getDataTable(list);
    }
    /**
     * 查询ServiceType列表
     */
    @PreAuthorize("@ss.hasPermi('system:ServiceType:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceType serviceType)
    {
        startPage();
        List<ServiceType> list = serviceTypeService.selectServiceTypeList(serviceType);
        return getDataTable(list);
    }

    /**
     * 导出ServiceType列表
     */
    @PreAuthorize("@ss.hasPermi('system:ServiceType:export')")
    @Log(title = "ServiceType", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceType serviceType)
    {
        List<ServiceType> list = serviceTypeService.selectServiceTypeList(serviceType);
        ExcelUtil<ServiceType> util = new ExcelUtil<ServiceType>(ServiceType.class);
        util.exportExcel(response, list, MessageUtils.message("no.export.excel.servicetype"));
    }

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

    /**
     * 新增ServiceType
     */
    @PreAuthorize("@ss.hasPermi('system:ServiceType:add')")
    @Log(title = "ServiceType", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceType serviceType)
    {
        return toAjax(serviceTypeService.insertServiceType(serviceType));
    }

    /**
     * 修改ServiceType
     */
    @PreAuthorize("@ss.hasPermi('system:ServiceType:edit')")
    @Log(title = "ServiceType", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceType serviceType)
    {
        return toAjax(serviceTypeService.updateServiceType(serviceType));
    }

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