package com.xinelu.manage.controller.hospitalpersoninfo;

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.domain.hospitalpersoninfo.HospitalPersonInfo;
import com.xinelu.manage.dto.hospitalpersoninfo.HospitalPersonInfoDTO;
import com.xinelu.manage.dto.hospitalpersoninfo.HospitalPersonInfoDtoo;
import com.xinelu.manage.service.hospitalpersoninfo.IHospitalPersonInfoService;
import com.xinelu.manage.vo.hospitalpersoninfo.HospitalPersonInfoVO;
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.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-14
 */
@Api(tags = "健康咨询-科室人员信息控制器")
@RestController
@RequestMapping("/system/hospitalPerson")
public class HospitalPersonInfoController extends BaseController {
    @Resource
    private IHospitalPersonInfoService hospitalPersonInfoService;

    /**
     * 查询健康咨询-科室人员信息分页列表
     */
    @ApiOperation("查询健康咨询-科室人员信息分页列表")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalPersonInfoVO hospitalPersonInfo) {
        startPage();
        List<HospitalPersonInfoVO> list = hospitalPersonInfoService.selectHospitalPersonInfoList(hospitalPersonInfo);
        return getDataTable(list);
    }

	/**
	 * 查询健康咨询-科室人员信息列表
	 */
	@ApiOperation("查询健康咨询-科室人员信息列表")
	@PreAuthorize("@ss.hasPermi('system:hospitalPerson:list')")
	@GetMapping("/getList")
	public AjaxResult getList(HospitalPersonInfoVO hospitalPersonInfo) {
		List<HospitalPersonInfo> list = hospitalPersonInfoService.getList(hospitalPersonInfo);
		return AjaxResult.success(list);
	}

    /**
     * 导出健康咨询-科室人员信息列表
     */
    @ApiOperation("导出健康咨询-科室人员信息列表")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:export')")
    @Log(title = "健康咨询-科室人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalPersonInfoVO hospitalPersonInfo) {
        List<HospitalPersonInfoVO> list = hospitalPersonInfoService.selectHospitalPersonInfoList(hospitalPersonInfo);
        ExcelUtil<HospitalPersonInfoVO> util = new ExcelUtil<>(HospitalPersonInfoVO.class);
        util.exportExcel(response, list, "健康咨询-科室人员信息数据");
    }

    /**
     * 获取健康咨询-科室人员信息详细信息
     */
    @ApiOperation("获取健康咨询-科室人员信息详细信息")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hospitalPersonInfoService.selectHospitalPersonInfoById(id));
    }

    /**
     * 新增健康咨询-科室人员信息
     */
    @ApiOperation("新增健康咨询-科室人员信息")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:add')")
    @Log(title = "健康咨询-科室人员信息", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated(Insert.class) @RequestBody HospitalPersonInfoDTO hospitalPersonInfo) {
        return hospitalPersonInfoService.insertHospitalPersonInfo(hospitalPersonInfo);
    }

    /**
     * 修改健康咨询-科室人员信息
     */
    @ApiOperation("修改健康咨询-科室人员信息")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:edit')")
    @Log(title = "健康咨询-科室人员信息", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated(Update.class) @RequestBody HospitalPersonInfoDTO hospitalPersonInfo) {
        return hospitalPersonInfoService.updateHospitalPersonInfo(hospitalPersonInfo);
    }

    /**
     * 修改健康咨询-科室人员信息
     */
    @PostMapping("/update")
    public AjaxResult update(@RequestBody HospitalPersonInfoDtoo hospitalPersonInfo) {
        return AjaxResult.success(hospitalPersonInfoService.editHospitalPersonInfo(hospitalPersonInfo));
    }

    /**
     * 删除健康咨询-科室人员信息
     */
    @ApiOperation("删除健康咨询-科室人员信息")
    @PreAuthorize("@ss.hasPermi('system:hospitalPerson:remove')")
    @Log(title = "健康咨询-科室人员信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return hospitalPersonInfoService.deleteHospitalPersonInfoByIds(ids);
    }
}