package com.xinelu.manage.controller.patienttaskpushrecord;

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.patienttaskpushrecord.PatientTaskPushRecord;
import com.xinelu.manage.service.patienttaskpushrecord.IPatientTaskPushRecordService;
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-03-21
 */
@RestController
@RequestMapping("/system/taskPushRecord")
public class PatientTaskPushRecordController extends BaseController {
    @Resource
    private IPatientTaskPushRecordService patientTaskPushRecordService;

    /**
     * 查询患者管理任务推送方式记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:list')")
    @GetMapping("/list")
    public TableDataInfo list(PatientTaskPushRecord patientTaskPushRecord) {
        startPage();
        List<PatientTaskPushRecord> list = patientTaskPushRecordService.selectPatientTaskPushRecordList(patientTaskPushRecord);
        return getDataTable(list);
    }

    /**
     * 导出患者管理任务推送方式记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:export')")
    @Log(title = "患者管理任务推送方式记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientTaskPushRecord patientTaskPushRecord) {
        List<PatientTaskPushRecord> list = patientTaskPushRecordService.selectPatientTaskPushRecordList(patientTaskPushRecord);
        ExcelUtil<PatientTaskPushRecord> util = new ExcelUtil<>(PatientTaskPushRecord.class);
        util.exportExcel(response, list, "患者管理任务推送方式记录数据");
    }

    /**
     * 获取患者管理任务推送方式记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientTaskPushRecordService.selectPatientTaskPushRecordById(id));
    }

    /**
     * 新增患者管理任务推送方式记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:add')")
    @Log(title = "患者管理任务推送方式记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@RequestBody PatientTaskPushRecord patientTaskPushRecord) {
        return toAjax(patientTaskPushRecordService.insertPatientTaskPushRecord(patientTaskPushRecord));
    }

    /**
     * 修改患者管理任务推送方式记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:edit')")
    @Log(title = "患者管理任务推送方式记录", businessType = BusinessType.UPDATE)
    @PutMapping("/edit")
    public AjaxResult edit(@RequestBody PatientTaskPushRecord patientTaskPushRecord) {
        return toAjax(patientTaskPushRecordService.updatePatientTaskPushRecord(patientTaskPushRecord));
    }

    /**
     * 删除患者管理任务推送方式记录
     */
    @PreAuthorize("@ss.hasPermi('system:taskPushRecord:remove')")
    @Log(title = "患者管理任务推送方式记录", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientTaskPushRecordService.deletePatientTaskPushRecordByIds(ids));
    }


    @GetMapping("/getManageRouteNode")
    public AjaxResult getManageRouteNode(Long manageRouteNodeId) {
        return AjaxResult.success(patientTaskPushRecordService.getManageRouteNode(manageRouteNodeId));
    }
}
