package com.xinelu.manage.controller.patientblacklistabnormalcause;

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.patientblacklistabnormalcause.PatientBlacklistAbnormalCause;
import com.xinelu.manage.service.patientblacklistabnormalcause.IPatientBlacklistAbnormalCauseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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-03-01
 */
@Api(tags = "患者黑名单异常原因控制器")
@RestController
@RequestMapping("/manage/cause")
public class PatientBlacklistAbnormalCauseController extends BaseController {
    @Resource
    private IPatientBlacklistAbnormalCauseService patientBlacklistAbnormalCauseService;

	/**
	 * 分页查询患者黑名单异常原因列表
	 */
	@ApiOperation("分页查询患者黑名单异常原因列表")
	@PreAuthorize("@ss.hasPermi('manage:cause:list')")
	@GetMapping("/list")
    public TableDataInfo list(PatientBlacklistAbnormalCause patientBlacklistAbnormalCause) {
        startPage();
        List<PatientBlacklistAbnormalCause> list = patientBlacklistAbnormalCauseService.selectPatientBlacklistAbnormalCauseList(patientBlacklistAbnormalCause);
        return getDataTable(list);
    }

	/**
	 * 查询患者黑名单异常原因列表
	 */
	@ApiOperation("查询患者黑名单异常原因列表")
	@GetMapping("/getList")
	public R<List<PatientBlacklistAbnormalCause>> getList(PatientBlacklistAbnormalCause patientBlacklistAbnormalCause) {
		List<PatientBlacklistAbnormalCause> list = patientBlacklistAbnormalCauseService.selectPatientBlacklistAbnormalCauseList(patientBlacklistAbnormalCause);
		return R.ok(list);
	}

    /**
     * 导出患者黑名单异常原因列表
     */
    @PreAuthorize("@ss.hasPermi('manage:cause:export')")
    @Log(title = "患者黑名单异常原因", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientBlacklistAbnormalCause patientBlacklistAbnormalCause) {
        List<PatientBlacklistAbnormalCause> list = patientBlacklistAbnormalCauseService.selectPatientBlacklistAbnormalCauseList(patientBlacklistAbnormalCause);
        ExcelUtil<PatientBlacklistAbnormalCause> util = new ExcelUtil<PatientBlacklistAbnormalCause>(PatientBlacklistAbnormalCause. class);
        util.exportExcel(response, list, "患者黑名单异常原因数据");
    }

    /**
     * 获取患者黑名单异常原因详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:cause:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientBlacklistAbnormalCauseService.selectPatientBlacklistAbnormalCauseById(id));
    }

    /**
     * 新增患者黑名单异常原因
     */
    @PreAuthorize("@ss.hasPermi('manage:cause:add')")
    @Log(title = "患者黑名单异常原因", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientBlacklistAbnormalCause patientBlacklistAbnormalCause) {
        return toAjax(patientBlacklistAbnormalCauseService.insertPatientBlacklistAbnormalCause(patientBlacklistAbnormalCause));
    }

    /**
     * 修改患者黑名单异常原因
     */
    @PreAuthorize("@ss.hasPermi('manage:cause:edit')")
    @Log(title = "患者黑名单异常原因", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientBlacklistAbnormalCause patientBlacklistAbnormalCause) {
        return toAjax(patientBlacklistAbnormalCauseService.updatePatientBlacklistAbnormalCause(patientBlacklistAbnormalCause));
    }

    /**
     * 删除患者黑名单异常原因
     */
    @PreAuthorize("@ss.hasPermi('manage:cause:remove')")
    @Log(title = "患者黑名单异常原因", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientBlacklistAbnormalCauseService.deletePatientBlacklistAbnormalCauseByIds(ids));
    }
}
