package com.xinelu.manage.controller.hospitalpersoncertificate;

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.custominterface.Insert;
import com.xinelu.common.custominterface.Update;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.dto.hospitalpersoncertificate.HospitalPersonCertificateDTO;
import com.xinelu.manage.service.hospitalpersoncertificate.IHospitalPersonCertificateService;
import com.xinelu.manage.vo.hospitalpersoncertificate.HospitalPersonCertificateVO;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
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.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 健康咨询-科室人员资质证书信息Controller
 *
 * @author xinyilu
 * @date 2023-02-23
 */
@RestController
@RequestMapping("/system/certificate")
public class HospitalPersonCertificateController extends BaseController {
    @Resource
    private IHospitalPersonCertificateService hospitalPersonCertificateService;

    /**
     * 查询健康咨询-科室人员资质证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalPersonCertificateDTO hospitalPersonCertificate) {
        startPage();
        List<HospitalPersonCertificateVO> list = hospitalPersonCertificateService.selectHospitalPersonCertificateList(hospitalPersonCertificate);
        return getDataTable(list);
    }

    /**
     * 导出健康咨询-科室人员资质证书信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:export')")
    @Log(title = "健康咨询-科室人员资质证书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalPersonCertificateDTO hospitalPersonCertificate) {
        List<HospitalPersonCertificateVO> list = hospitalPersonCertificateService.selectHospitalPersonCertificateList(hospitalPersonCertificate);
        ExcelUtil<HospitalPersonCertificateVO> util = new ExcelUtil<>(HospitalPersonCertificateVO.class);
        util.exportExcel(response, list, "健康咨询-科室人员资质证书信息数据");
    }

    /**
     * 获取健康咨询-科室人员资质证书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hospitalPersonCertificateService.selectHospitalPersonCertificateById(id));
    }

    /**
     * 新增健康咨询-科室人员资质证书信息
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:add')")
    @Log(title = "健康咨询-科室人员资质证书信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated(Insert.class) @RequestBody HospitalPersonCertificateDTO hospitalPersonCertificate) {
        return hospitalPersonCertificateService.insertHospitalPersonCertificate(hospitalPersonCertificate);
    }

    /**
     * 修改健康咨询-科室人员资质证书信息
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:edit')")
    @Log(title = "健康咨询-科室人员资质证书信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated(Update.class) @RequestBody HospitalPersonCertificateDTO hospitalPersonCertificate) {
        return hospitalPersonCertificateService.updateHospitalPersonCertificate(hospitalPersonCertificate);
    }

    /**
     * 删除健康咨询-科室人员资质证书信息
     */
    @PreAuthorize("@ss.hasPermi('system:certificate:remove')")
    @Log(title = "健康咨询-科室人员资质证书信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hospitalPersonCertificateService.deleteHospitalPersonCertificateByIds(ids));
    }
}
