package com.xinelu.manage.controller.specialdiseaseroute;

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.manage.domain.specialdiseaseroute.SpecialDiseaseRoute;
import com.xinelu.manage.service.specialdiseaseroute.ISpecialDiseaseRouteService;
import com.xinelu.manage.vo.specialdiseaseroute.SpecialDiseaseRouteVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 专病路径信息Controller
 *
 * @author xinelu
 * @date 2024-03-13
 */
@RestController
@RequestMapping("/system/specialDiseaseRoute")
public class SpecialDiseaseRouteController extends BaseController {
    @Resource
    private ISpecialDiseaseRouteService specialDiseaseRouteService;

    /**
     * 查询专病路径信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:specialDiseaseRoute:list')")
    @GetMapping("/list")
    public TableDataInfo list(SpecialDiseaseRoute specialDiseaseRoute) {
        startPage();
        List<SpecialDiseaseRouteVO> list = specialDiseaseRouteService.selectSpecialDiseaseRouteList(specialDiseaseRoute);
        return getDataTable(list);
    }

    /**
     * 获取专病路径信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:specialDiseaseRoute:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(specialDiseaseRouteService.selectSpecialDiseaseRouteById(id));
    }

    /**
     * 新增专病路径信息
     */
    @PreAuthorize("@ss.hasPermi('system:specialDiseaseRoute:add')")
    @Log(title = "专病路径信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody SpecialDiseaseRouteVO specialDiseaseRoute) {
        return specialDiseaseRouteService.insertSpecialDiseaseRoute(specialDiseaseRoute);
    }

    /**
     * 修改专病路径信息
     */
    @PreAuthorize("@ss.hasPermi('system:specialDiseaseRoute:edit')")
    @Log(title = "专病路径信息", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody SpecialDiseaseRouteVO specialDiseaseRoute) {
        return specialDiseaseRouteService.updateSpecialDiseaseRoute(specialDiseaseRoute);
    }

    /**
     * 删除专病路径信息
     */
    @PreAuthorize("@ss.hasPermi('system:specialDiseaseRoute:remove')")
    @Log(title = "专病路径信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Long id) {
        return specialDiseaseRouteService.deleteSpecialDiseaseRouteById(id);
    }

    /**
     * 科室路径数量
     */
    @GetMapping("/departmentRouteCount")
    public AjaxResult departmentRouteCount(String departmentName) {
        return specialDiseaseRouteService.departmentRouteCount(departmentName);
    }

    /**
     * 发布专病路径信息
     */
    @PostMapping("/editReleaseStatus")
    public AjaxResult editReleaseStatus(@RequestBody SpecialDiseaseRoute specialDiseaseRoute) {
        return specialDiseaseRouteService.editReleaseStatus(specialDiseaseRoute);
    }
}
