package com.xinelu.manage.controller.signpatientpackagehardware;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.xinelu.common.annotation.Log;
import com.xinelu.common.core.controller.BaseController;
import com.xinelu.common.core.domain.AjaxResult;
import com.xinelu.common.enums.BusinessType;
import com.xinelu.manage.domain.signpatientpackagehardware.SignPatientPackageHardware;
import com.xinelu.manage.service.signpatientpackagehardware.ISignPatientPackageHardwareService;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.common.core.page.TableDataInfo;

/**
 * 签约患者服务包硬件信息Controller
 *
 * @author haown
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/manage/signHardware")
public class SignPatientPackageHardwareController extends BaseController {
    @Resource
    private ISignPatientPackageHardwareService signPatientPackageHardwareService;

	/**
	 * 查询签约患者服务包硬件信息列表
	 */
	@PreAuthorize("@ss.hasPermi('manage:signHardware:list')")
	@GetMapping("/list")
    public TableDataInfo list(SignPatientPackageHardware signPatientPackageHardware) {
        startPage();
        List<SignPatientPackageHardware> list = signPatientPackageHardwareService.selectSignPatientPackageHardwareList(signPatientPackageHardware);
        return getDataTable(list);
    }

    /**
     * 导出签约患者服务包硬件信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:signHardware:export')")
    @Log(title = "签约患者服务包硬件信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignPatientPackageHardware signPatientPackageHardware) {
        List<SignPatientPackageHardware> list = signPatientPackageHardwareService.selectSignPatientPackageHardwareList(signPatientPackageHardware);
        ExcelUtil<SignPatientPackageHardware> util = new ExcelUtil<SignPatientPackageHardware>(SignPatientPackageHardware. class);
        util.exportExcel(response, list, "签约患者服务包硬件信息数据");
    }

    /**
     * 获取签约患者服务包硬件信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signHardware:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(signPatientPackageHardwareService.selectSignPatientPackageHardwareById(id));
    }

    /**
     * 新增签约患者服务包硬件信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signHardware:add')")
    @Log(title = "签约患者服务包硬件信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignPatientPackageHardware signPatientPackageHardware) {
        return toAjax(signPatientPackageHardwareService.insertSignPatientPackageHardware(signPatientPackageHardware));
    }

    /**
     * 修改签约患者服务包硬件信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signHardware:edit')")
    @Log(title = "签约患者服务包硬件信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignPatientPackageHardware signPatientPackageHardware) {
        return toAjax(signPatientPackageHardwareService.updateSignPatientPackageHardware(signPatientPackageHardware));
    }

    /**
     * 删除签约患者服务包硬件信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signHardware:remove')")
    @Log(title = "签约患者服务包硬件信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(signPatientPackageHardwareService.deleteSignPatientPackageHardwareByIds(ids));
    }
}
