package com.xinelu.manage.controller.patientpropaganda;

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.patientpropaganda.PatientPropaganda;
import com.xinelu.manage.service.patientpropaganda.IPatientPropagandaService;
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/patientPropaganda")
public class PatientPropagandaController extends BaseController {
    @Resource
    private IPatientPropagandaService patientPropagandaService;

	/**
	 * 查询患者宣教信息列表
	 */
	@ApiOperation("分页查询患者宣教信息列表")
	@PreAuthorize("@ss.hasPermi('manage:patientPropaganda:list')")
	@GetMapping("/list")
	public TableDataInfo list(PatientPropaganda patientPropaganda) {
		startPage();
		List<PatientPropaganda> list = patientPropagandaService.selectPatientPropagandaList(patientPropaganda);
		return getDataTable(list);
	}

	/**
	 * 查询患者宣教信息列表
	 */
	@ApiOperation("查询患者宣教信息列表")
	@PreAuthorize("@ss.hasPermi('manage:patientPropaganda:list')")
	@GetMapping("/getList")
	public AjaxResult getList(PatientPropaganda patientPropaganda) {
		List<PatientPropaganda> list = patientPropagandaService.selectPatientPropagandaList(patientPropaganda);
		return AjaxResult.success(list);
	}

    /**
     * 导出患者宣教信息列表
     */
    @PreAuthorize("@ss.hasPermi('manage:patientPropaganda:export')")
    @Log(title = "患者宣教信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PatientPropaganda patientPropaganda) {
        List<PatientPropaganda> list = patientPropagandaService.selectPatientPropagandaList(patientPropaganda);
        ExcelUtil<PatientPropaganda> util = new ExcelUtil<PatientPropaganda>(PatientPropaganda. class);
        util.exportExcel(response, list, "患者宣教信息数据");
    }

    /**
     * 获取患者宣教信息详细信息
     */
    @ApiOperation("根据主键获取患者宣教信息详细信息")
    @PreAuthorize("@ss.hasPermi('manage:patientPropaganda:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(patientPropagandaService.selectPatientPropagandaById(id));
    }

    /**
     * 新增患者宣教信息
     */
    @ApiOperation("新增患者宣教信息")
    @PreAuthorize("@ss.hasPermi('manage:patientPropaganda:add')")
    @Log(title = "患者宣教信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PatientPropaganda patientPropaganda) {
        return toAjax(patientPropagandaService.insertPatientPropaganda(patientPropaganda));
    }

    /**
     * 修改患者宣教信息
     */
    @ApiOperation("修改患者宣教信息")
    @PreAuthorize("@ss.hasPermi('manage:patientPropaganda:edit')")
    @Log(title = "患者宣教信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PatientPropaganda patientPropaganda) {
        return toAjax(patientPropagandaService.updatePatientPropaganda(patientPropaganda));
    }

    /**
     * 删除患者宣教信息
     */
    @ApiOperation("批量删除患者宣教信息")
    @PreAuthorize("@ss.hasPermi('manage:patientPropaganda:remove')")
    @Log(title = "患者宣教信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(patientPropagandaService.deletePatientPropagandaByIds(ids));
    }
}
