package com.xinelu.manage.controller.patientblacklist;

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.patientblacklist.PatientBlacklist;
import com.xinelu.manage.dto.patientblacklist.PatientBlacklistDto;
import com.xinelu.manage.dto.patientblacklist.PatientBlacklistSaveDto;
import com.xinelu.manage.service.patientblacklist.IPatientBlacklistService;
import com.xinelu.manage.vo.patientblacklist.PatientBlacklistVo;
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-02-27
 */
@Api(tags = "患者-黑明单关系控制器")
@RestController
@RequestMapping("/manage/blacklist")
public class PatientBlacklistController extends BaseController {
    @Resource
    private IPatientBlacklistService patientBlacklistService;

	/**
	 * 查询患者-黑明单关系列表
	 */
	@PreAuthorize("@ss.hasPermi('manage:blacklist:list')")
	@GetMapping("/list")
    public TableDataInfo list(PatientBlacklistDto patientBlacklist) {
        startPage();
        List<PatientBlacklistVo> list = patientBlacklistService.selectPatientBlacklistList(patientBlacklist);
        return getDataTable(list);
    }

    /**
     * 导出患者-黑明单关系列表
     */
    @PreAuthorize("@ss.hasPermi('manage:blacklist:export')")
    @Log(title = "患者-黑明单关系", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientBlacklistDto patientBlacklist) {
        List<PatientBlacklistVo> list = patientBlacklistService.selectPatientBlacklistList(patientBlacklist);
        ExcelUtil<PatientBlacklistVo> util = new ExcelUtil<PatientBlacklistVo>(PatientBlacklistVo. class);
        util.exportExcel(response, list, "患者-黑明单关系数据");
    }

    /**
     * 获取患者-黑明单关系详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:blacklist:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientBlacklistService.selectPatientBlacklistById(id));
    }

    /**
     * 新增患者-黑明单关系
     */
    @PreAuthorize("@ss.hasPermi('manage:blacklist:add')")
    @Log(title = "患者-黑明单关系", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientBlacklistSaveDto patientBlacklist) {
        return toAjax(patientBlacklistService.insertPatientBlacklist(patientBlacklist));
    }

    /**
     * 修改患者-黑明单关系
     */
    @PreAuthorize("@ss.hasPermi('manage:blacklist:edit')")
    @Log(title = "患者-黑明单关系", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientBlacklist patientBlacklist) {
        return toAjax(patientBlacklistService.updatePatientBlacklist(patientBlacklist));
    }

    /**
     * 删除患者-黑明单关系
     */
    @PreAuthorize("@ss.hasPermi('manage:blacklist:remove')")
    @Log(title = "患者-黑明单关系", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientBlacklistService.deletePatientBlacklistByIds(ids));
    }
}
