package com.xinelu.manage.controller.patientnodeparamscurrent;

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.domain.R;
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.patientnodeparamscurrent.PatientNodeParamsCurrent;
import com.xinelu.manage.service.patientnodeparamscurrent.IPatientNodeParamsCurrentService;
import io.swagger.annotations.Api;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 患者节点参数Controller
 *
 * @author haown
 * @date 2024-05-20
 */
@Api(tags = "患者节点参数控制器")
@RestController
@RequestMapping("/manage/nodeParamsCurrent")
public class PatientNodeParamsCurrentController extends BaseController {
    @Resource
    private IPatientNodeParamsCurrentService patientNodeParamsCurrentService;

	/**
	 * 查询患者节点参数列表
	 */
	@PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:list')")
	@GetMapping("/list")
    public TableDataInfo list(PatientNodeParamsCurrent patientNodeParamsCurrent) {
        startPage();
        List<PatientNodeParamsCurrent> list = patientNodeParamsCurrentService.selectPatientNodeParamsCurrentList(patientNodeParamsCurrent);
        return getDataTable(list);
    }

    /**
     * 导出患者节点参数列表
     */
    @PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:export')")
    @Log(title = "患者节点参数", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientNodeParamsCurrent patientNodeParamsCurrent) {
        List<PatientNodeParamsCurrent> list = patientNodeParamsCurrentService.selectPatientNodeParamsCurrentList(patientNodeParamsCurrent);
        ExcelUtil<PatientNodeParamsCurrent> util = new ExcelUtil<>(PatientNodeParamsCurrent. class);
        util.exportExcel(response, list, "患者节点参数数据");
    }

    /**
     * 获取患者节点参数详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientNodeParamsCurrentService.selectPatientNodeParamsCurrentById(id));
    }

    /**
     * 新增患者节点参数
     */
    @PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:add')")
    @Log(title = "患者节点参数", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientNodeParamsCurrent patientNodeParamsCurrent) {
        return toAjax(patientNodeParamsCurrentService.insertPatientNodeParamsCurrent(patientNodeParamsCurrent));
    }

    /**
     * 修改患者节点参数
     */
    @PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:edit')")
    @Log(title = "患者节点参数", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientNodeParamsCurrent patientNodeParamsCurrent) {
        return toAjax(patientNodeParamsCurrentService.updatePatientNodeParamsCurrent(patientNodeParamsCurrent));
    }

    /**
     * 删除患者节点参数
     */
    @PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:remove')")
    @Log(title = "患者节点参数", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientNodeParamsCurrentService.deletePatientNodeParamsCurrentByIds(ids));
    }

	/**
	 * 批量新增患者节点参数
	 */
	@PreAuthorize("@ss.hasPermi('manage:nodeParamsCurrent:add')")
	@Log(title = "患者节点参数", businessType = BusinessType.INSERT)
	@PostMapping("/inserList")
	public R<?> inserList(@RequestBody List<List<PatientNodeParamsCurrent>> paramsList) {
		patientNodeParamsCurrentService.insertList(paramsList);
		return R.ok();
	}
}
