package com.xinelu.manage.controller.hospitaldepartmentinfo;

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.hospitaldepartmentinfo.HospitalDepartmentDTO;
import com.xinelu.manage.domain.hospitaldepartmentinfo.HospitalDepartmentInfo;
import com.xinelu.manage.service.hospitaldepartmentinfo.IHospitalDepartmentInfoService;
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 zh
 * @date 2023-02-13
 */
@Api(tags = "科室信息管理控制器")
@RestController
@RequestMapping("/system/hospitalDepartment")
public class HospitalDepartmentInfoController extends BaseController {
    @Resource
    private IHospitalDepartmentInfoService hospitalDepartmentInfoService;

    /**
     * 查询科室信息管理分页列表
     */
    @ApiOperation("查询科室信息管理分页列表")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:list')")
    @GetMapping("/list")
    public TableDataInfo list(HospitalDepartmentInfo hospitalDepartmentInfo) {
        startPage();
        List<HospitalDepartmentInfo> list = hospitalDepartmentInfoService.selectHospitalDepartmentInfoList(hospitalDepartmentInfo);
        return getDataTable(list);
    }

	/**
	 * 查询科室信息管理列表
	 */
	@ApiOperation("查询科室信息管理列表")
	@PreAuthorize("@ss.hasPermi('system:hospitalDepartment:list')")
	@GetMapping("/getList")
	public AjaxResult getList(HospitalDepartmentInfo hospitalDepartmentInfo) {
		List<HospitalDepartmentInfo> list = hospitalDepartmentInfoService.selectHospitalDepartmentInfoList(hospitalDepartmentInfo);
		return AjaxResult.success(list);
	}

    /**
     * 导出科室信息管理列表
     */
    @ApiOperation("导出科室信息管理列表")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:export')")
    @Log(title = "科室信息管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HospitalDepartmentInfo hospitalDepartmentInfo) {
        List<HospitalDepartmentInfo> list = hospitalDepartmentInfoService.selectHospitalDepartmentInfoList(hospitalDepartmentInfo);
        ExcelUtil<HospitalDepartmentInfo> util = new ExcelUtil<>(HospitalDepartmentInfo.class);
        util.exportExcel(response, list, "科室信息管理数据");
    }

    /**
     * 获取科室信息管理详细信息
     */
    @ApiOperation("获取科室信息管理详细信息")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(hospitalDepartmentInfoService.selectHospitalDepartmentInfoById(id));
    }

    /**
     * 新增科室信息管理
     */
    @ApiOperation("新增科室信息管理")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:add')")
    @Log(title = "科室信息管理", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    public AjaxResult add(@Validated(Insert.class) @RequestBody HospitalDepartmentDTO hospitalDepartment) {
        return hospitalDepartmentInfoService.insertHospitalDepartmentInfo(hospitalDepartment);
    }

    /**
     * 修改科室信息管理
     */
    @ApiOperation("修改科室信息管理")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:edit')")
    @Log(title = "科室信息管理", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    public AjaxResult edit(@Validated(Update.class) @RequestBody HospitalDepartmentInfo hospitalDepartmentInfo) {
        return hospitalDepartmentInfoService.updateHospitalDepartmentInfo(hospitalDepartmentInfo);
    }

    /**
     * 删除科室信息管理
     */
    @ApiOperation("删除科室信息管理")
    @PreAuthorize("@ss.hasPermi('system:hospitalDepartment:remove')")
    @Log(title = "科室信息管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(hospitalDepartmentInfoService.deleteHospitalDepartmentInfoByIds(ids));
    }
}
