package com.fs.his.controller;

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

import com.fs.common.exception.CustomException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.core.page.TableDataInfo;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.his.domain.FsSignArticleReadDetail;
import com.fs.his.service.IFsSignArticleReadDetailService;

/**
 * 用户阅读文章明细Controller
 *
 * @author fs
 * @date 2026-04-22
 */
@RestController
@RequestMapping("/his/readDetail")
public class FsSignArticleReadDetailController extends BaseController {
    @Autowired
    private IFsSignArticleReadDetailService fsSignArticleReadDetailService;

    /**
     * 查询用户阅读文章明细列表
     */
    @GetMapping("/list")
    public TableDataInfo list(FsSignArticleReadDetail fsSignArticleReadDetail) {
        startPage();
        List<FsSignArticleReadDetail> list = fsSignArticleReadDetailService.selectFsSignArticleReadDetailList(fsSignArticleReadDetail);
        return getDataTable(list);
    }

    /**
     * 导出用户阅读文章明细列表
     */
    @PostMapping("/export")
    public void export(HttpServletResponse response, FsSignArticleReadDetail fsSignArticleReadDetail) {
        try {
            List<FsSignArticleReadDetail> list = fsSignArticleReadDetailService.selectFsSignArticleReadDetailList(fsSignArticleReadDetail);
            ExcelUtil<FsSignArticleReadDetail> util = new ExcelUtil<FsSignArticleReadDetail>(FsSignArticleReadDetail.class);
            util.exportExcel(response, list, "用户阅读文章明细数据");
        } catch (Exception e) {
            throw new CustomException("导出用户阅读文章明细列表异常");
        }

    }

    /**
     * 获取用户阅读文章明细详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(fsSignArticleReadDetailService.selectFsSignArticleReadDetailById(id));
    }

    /**
     * 新增用户阅读文章明细
     */
    @PostMapping
    public AjaxResult add(@RequestBody FsSignArticleReadDetail fsSignArticleReadDetail) {
        return toAjax(fsSignArticleReadDetailService.insertFsSignArticleReadDetail(fsSignArticleReadDetail));
    }

    /**
     * 修改用户阅读文章明细
     */
    @PutMapping
    public AjaxResult edit(@RequestBody FsSignArticleReadDetail fsSignArticleReadDetail) {
        return toAjax(fsSignArticleReadDetailService.updateFsSignArticleReadDetail(fsSignArticleReadDetail));
    }

    /**
     * 删除用户阅读文章明细
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(fsSignArticleReadDetailService.deleteFsSignArticleReadDetailByIds(ids));
    }
}