package com.xinelu.manage.controller.signpatientpackage;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
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.signpatientpackage.SignPatientPackage;
import com.xinelu.manage.service.signpatientpackage.ISignPatientPackageService;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.common.core.page.TableDataInfo;

/**
 * 签约患者服务包信息Controller
 *
 * @author haown
 * @date 2024-02-27
 */
@Api(tags = "签约患者服务包控制器")
@RestController
@RequestMapping("/manage/signPackage")
public class SignPatientPackageController extends BaseController {
    @Resource
    private ISignPatientPackageService signPatientPackageService;

	/**
	 * 查询签约患者服务包信息列表
	 */
	@ApiOperation("分页查询签约患者服务包信息列表")
	@PreAuthorize("@ss.hasPermi('manage:signPackage:list')")
	@GetMapping("/list")
    public TableDataInfo list(SignPatientPackage signPatientPackage) {
        startPage();
        List<SignPatientPackage> list = signPatientPackageService.selectSignPatientPackageList(signPatientPackage);
        return getDataTable(list);
    }

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

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

    /**
     * 新增签约患者服务包信息
     */
    @ApiOperation("新增签约患者服务包信息")
    @PreAuthorize("@ss.hasPermi('manage:signPackage:add')")
    @Log(title = "签约患者服务包信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignPatientPackage signPatientPackage) {
        return toAjax(signPatientPackageService.insertSignPatientPackage(signPatientPackage));
    }

    /**
     * 修改签约患者服务包信息
     */
    @ApiOperation("修改签约患者服务包信息")
    @PreAuthorize("@ss.hasPermi('manage:signPackage:edit')")
    @Log(title = "签约患者服务包信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignPatientPackage signPatientPackage) {
        return toAjax(signPatientPackageService.updateSignPatientPackage(signPatientPackage));
    }

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