package com.fs.his.controller;

import java.util.List;

import com.fs.his.vo.OptionsVO;
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.fs.common.annotation.Log;
import com.fs.common.core.controller.BaseController;
import com.fs.common.core.domain.AjaxResult;
import com.fs.common.enums.BusinessType;
import com.fs.his.domain.FsDoctorArticleCate;
import com.fs.his.service.IFsDoctorArticleCateService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 医生文章分类Controller
 *
 * @author fs
 * @date 2024-05-08
 */
@RestController
@RequestMapping("/his/doctorArticleCate")
public class FsDoctorArticleCateController extends BaseController
{
    @Autowired
    private IFsDoctorArticleCateService fsDoctorArticleCateService;

    /**
     * 查询医生文章分类列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsDoctorArticleCate fsDoctorArticleCate)
    {
        startPage();
        List<FsDoctorArticleCate> list = fsDoctorArticleCateService.selectFsDoctorArticleCateList(fsDoctorArticleCate);
        return getDataTable(list);
    }

    /**
     * 导出医生文章分类列表
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:export')")
    @Log(title = "医生文章分类", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDoctorArticleCate fsDoctorArticleCate)
    {
        List<FsDoctorArticleCate> list = fsDoctorArticleCateService.selectFsDoctorArticleCateList(fsDoctorArticleCate);
        ExcelUtil<FsDoctorArticleCate> util = new ExcelUtil<FsDoctorArticleCate>(FsDoctorArticleCate.class);
        return util.exportExcel(list, "医生文章分类数据");
    }

    /**
     * 获取医生文章分类详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:query')")
    @GetMapping(value = "/{cateId}")
    public AjaxResult getInfo(@PathVariable("cateId") Long cateId)
    {
        return AjaxResult.success(fsDoctorArticleCateService.selectFsDoctorArticleCateByCateId(cateId));
    }

    /**
     * 新增医生文章分类
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:add')")
    @Log(title = "医生文章分类", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDoctorArticleCate fsDoctorArticleCate)
    {
        return toAjax(fsDoctorArticleCateService.insertFsDoctorArticleCate(fsDoctorArticleCate));
    }

    /**
     * 修改医生文章分类
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:edit')")
    @Log(title = "医生文章分类", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDoctorArticleCate fsDoctorArticleCate)
    {
        return toAjax(fsDoctorArticleCateService.updateFsDoctorArticleCate(fsDoctorArticleCate));
    }

    /**
     * 删除医生文章分类
     */
    @PreAuthorize("@ss.hasPermi('his:doctorArticleCate:remove')")
    @Log(title = "医生文章分类", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cateIds}")
    public AjaxResult remove(@PathVariable Long[] cateIds)
    {
        return toAjax(fsDoctorArticleCateService.deleteFsDoctorArticleCateByCateIds(cateIds));
    }

    @GetMapping("/allList")
    public AjaxResult allList()
    {
        List<OptionsVO> list = fsDoctorArticleCateService.selectFsArticleCateAllList();
        return AjaxResult.success(list);
    }
}
