package com.xinelu.manage.controller.signpatientinformed;

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.enums.BusinessType;
import com.xinelu.common.utils.poi.ExcelUtil;
import com.xinelu.manage.domain.signpatientinformed.SignPatientInformed;
import com.xinelu.manage.service.signpatientinformed.ISignPatientInformedService;
import io.swagger.annotations.Api;
import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
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.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 签约知情同意书信息Controller
 *
 * @author xinelu
 * @date 2024-02-27
 */
@Api(tags = "签约知情同意书控制器")
@RestController
@RequestMapping("/manage/signInformed")
public class SignPatientInformedController extends BaseController {
    @Resource
    private ISignPatientInformedService signPatientInformedService;

/**
 * 查询签约知情同意书信息列表
 */
@PreAuthorize("@ss.hasPermi('manage:signInformed:list')")
@GetMapping("/list")
    public TableDataInfo list(SignPatientInformed signPatientInformed) {
        startPage();
        List<SignPatientInformed> list = signPatientInformedService.selectSignPatientInformedList(signPatientInformed);
        return getDataTable(list);
    }

    /**
     * 导出签约知情同意书信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:signInformed:export')")
    @Log(title = "签约知情同意书信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SignPatientInformed signPatientInformed) {
        List<SignPatientInformed> list = signPatientInformedService.selectSignPatientInformedList(signPatientInformed);
        ExcelUtil<SignPatientInformed> util = new ExcelUtil<SignPatientInformed>(SignPatientInformed. class);
        util.exportExcel(response, list, "签约知情同意书信息数据");
    }

    /**
     * 获取签约知情同意书信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signInformed:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(signPatientInformedService.selectSignPatientInformedById(id));
    }

    /**
     * 新增签约知情同意书信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signInformed:add')")
    @Log(title = "签约知情同意书信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SignPatientInformed signPatientInformed) {
        return toAjax(signPatientInformedService.insertSignPatientInformed(signPatientInformed));
    }

    /**
     * 修改签约知情同意书信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signInformed:edit')")
    @Log(title = "签约知情同意书信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SignPatientInformed signPatientInformed) {
        return toAjax(signPatientInformedService.updateSignPatientInformed(signPatientInformed));
    }

    /**
     * 删除签约知情同意书信息
     */
    @PreAuthorize("@ss.hasPermi('manage:signInformed:remove')")
    @Log(title = "签约知情同意书信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(signPatientInformedService.deleteSignPatientInformedByIds(ids));
    }

}
