package com.ruoyi.framework.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
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.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.framework.system.domain.FollowUpRecords;
import com.ruoyi.framework.system.service.IFollowUpRecordsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 随访记录Controller
 * 
 * @author ruoyi
 * @date 2024-11-13
 */
@RestController
@RequestMapping("/system/FollowUpRecords")
public class FollowUpRecordsController extends BaseController
{
    @Autowired
    private IFollowUpRecordsService followUpRecordsService;

    /**
     * 查询随访记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:list')")
    @GetMapping("/list")
    public TableDataInfo list(FollowUpRecords followUpRecords)
    {
        startPage();
        List<FollowUpRecords> list = followUpRecordsService.selectFollowUpRecordsList(followUpRecords);
        return getDataTable(list);
    }

    /**
     * 导出随访记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:export')")
    @Log(title = "随访记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FollowUpRecords followUpRecords)
    {
        List<FollowUpRecords> list = followUpRecordsService.selectFollowUpRecordsList(followUpRecords);
        ExcelUtil<FollowUpRecords> util = new ExcelUtil<FollowUpRecords>(FollowUpRecords.class);
        util.exportExcel(response, list, "随访记录数据");
    }

    /**
     * 获取随访记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:query')")
    @GetMapping(value = "/{RecordID}")
    public AjaxResult getInfo(@PathVariable("RecordID") Long RecordID)
    {
        return success(followUpRecordsService.selectFollowUpRecordsByRecordID(RecordID));
    }

    /**
     * 新增随访记录
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:add')")
    @Log(title = "随访记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FollowUpRecords followUpRecords)
    {
        return toAjax(followUpRecordsService.insertFollowUpRecords(followUpRecords));
    }

    /**
     * 修改随访记录
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:edit')")
    @Log(title = "随访记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FollowUpRecords followUpRecords)
    {
        return toAjax(followUpRecordsService.updateFollowUpRecords(followUpRecords));
    }

    /**
     * 删除随访记录
     */
    @PreAuthorize("@ss.hasPermi('system:FollowUpRecords:remove')")
    @Log(title = "随访记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{RecordIDs}")
    public AjaxResult remove(@PathVariable Long[] RecordIDs)
    {
        return toAjax(followUpRecordsService.deleteFollowUpRecordsByRecordIDs(RecordIDs));
    }
}
