package com.jianshui.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.jianshui.common.annotation.Log;
import com.jianshui.common.core.controller.BaseController;
import com.jianshui.common.core.domain.AjaxResult;
import com.jianshui.common.enums.BusinessType;
import com.jianshui.system.domain.ServiceManage;
import com.jianshui.system.service.IServiceManageService;
import com.jianshui.common.utils.poi.ExcelUtil;
import com.jianshui.common.core.page.TableDataInfo;

/**
 * 服务管理Controller
 * 
 * @author Gong Quanlin
 * @date 2022-03-27
 */
@RestController
@RequestMapping("/system/manageservices")
public class ServiceManageController extends BaseController
{
    @Autowired
    private IServiceManageService serviceManageService;

    /**
     * 查询服务管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:list')")
    @GetMapping("/list")
    public TableDataInfo list(ServiceManage serviceManage)
    {
        startPage();
        List<ServiceManage> list = serviceManageService.selectServiceManageList(serviceManage);
        return getDataTable(list);
    }

    /**
     * 导出服务管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:export')")
    @Log(title = "服务管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ServiceManage serviceManage)
    {
        List<ServiceManage> list = serviceManageService.selectServiceManageList(serviceManage);
        ExcelUtil<ServiceManage> util = new ExcelUtil<ServiceManage>(ServiceManage.class);
        util.exportExcel(response, list, "服务管理数据");
    }

    /**
     * 获取服务管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(serviceManageService.selectServiceManageById(id));
    }

    /**
     * 新增服务管理
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:add')")
    @Log(title = "服务管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ServiceManage serviceManage)
    {
        return toAjax(serviceManageService.insertServiceManage(serviceManage));
    }

    /**
     * 修改服务管理
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:edit')")
    @Log(title = "服务管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ServiceManage serviceManage)
    {
        return toAjax(serviceManageService.updateServiceManage(serviceManage));
    }

    /**
     * 删除服务管理
     */
    @PreAuthorize("@ss.hasPermi('system:manageservices:remove')")
    @Log(title = "服务管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(serviceManageService.deleteServiceManageByIds(ids));
    }
}
