package com.xinelu.manage.controller.specialdiseaseroutepackage;

import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.core.page.TableDataInfo;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.specialdiseaseroutepackage.SpecialDiseaseRoutePackage;
import com.xinelu.manage.service.specialdiseaseroutepackage.ISpecialDiseaseRoutePackageService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 专病路径-服务包关系（多对多关系）Controller
 *
 * @author xinelu
 * @date 2024-04-09
 */
@RestController
@RequestMapping("/system/routePackage")
public class SpecialDiseaseRoutePackageController extends BaseController {
    @Resource
    private ISpecialDiseaseRoutePackageService specialDiseaseRoutePackageService;

    /**
     * 查询专病路径-服务包关系（多对多关系）列表
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:list')")
    @GetMapping("/list")
    public TableDataInfo list(SpecialDiseaseRoutePackage specialDiseaseRoutePackage) {
        startPage();
        List<SpecialDiseaseRoutePackage> list = specialDiseaseRoutePackageService.selectSpecialDiseaseRoutePackageList(specialDiseaseRoutePackage);
        return getDataTable(list);
    }

    /**
     * 导出专病路径-服务包关系（多对多关系）列表
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:export')")
    @Log(title = "专病路径-服务包关系（多对多关系）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SpecialDiseaseRoutePackage specialDiseaseRoutePackage) {
        List<SpecialDiseaseRoutePackage> list = specialDiseaseRoutePackageService.selectSpecialDiseaseRoutePackageList(specialDiseaseRoutePackage);
        ExcelUtil<SpecialDiseaseRoutePackage> util = new ExcelUtil<>(SpecialDiseaseRoutePackage.class);
        util.exportExcel(response, list, "专病路径-服务包关系（多对多关系）数据");
    }

    /**
     * 获取专病路径-服务包关系（多对多关系）详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(specialDiseaseRoutePackageService.selectSpecialDiseaseRoutePackageById(id));
    }

    /**
     * 新增专病路径-服务包关系（多对多关系）
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:add')")
    @Log(title = "专病路径-服务包关系（多对多关系）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SpecialDiseaseRoutePackage specialDiseaseRoutePackage) {
        return toAjax(specialDiseaseRoutePackageService.insertSpecialDiseaseRoutePackage(specialDiseaseRoutePackage));
    }

    /**
     * 修改专病路径-服务包关系（多对多关系）
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:edit')")
    @Log(title = "专病路径-服务包关系（多对多关系）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SpecialDiseaseRoutePackage specialDiseaseRoutePackage) {
        return toAjax(specialDiseaseRoutePackageService.updateSpecialDiseaseRoutePackage(specialDiseaseRoutePackage));
    }

    /**
     * 删除专病路径-服务包关系（多对多关系）
     */
    @PreAuthorize("@ss.hasPermi('system:routePackage:remove')")
    @Log(title = "专病路径-服务包关系（多对多关系）", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(specialDiseaseRoutePackageService.deleteSpecialDiseaseRoutePackageByIds(ids));
    }
}
