package com.fs.his.controller;

import java.util.List;
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.FsDfAccount;
import com.fs.his.service.IFsDfAccountService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 代服账户Controller
 *
 * @author fs
 * @date 2025-10-13
 */
@RestController
@RequestMapping("/his/dfAccount")
public class FsDfAccountController extends BaseController
{
    @Autowired
    private IFsDfAccountService fsDfAccountService;

    /**
     * 查询代服账户列表
     */

    @GetMapping("/list")
    public TableDataInfo list(FsDfAccount fsDfAccount)
    {
        startPage();
        List<FsDfAccount> list = fsDfAccountService.selectFsDfAccountList(fsDfAccount);
        return getDataTable(list);
    }

    /**
     * 导出代服账户列表
     */
    @PreAuthorize("@ss.hasPermi('his:dfAccount:export')")
    @Log(title = "代服账户", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsDfAccount fsDfAccount)
    {
        List<FsDfAccount> list = fsDfAccountService.selectFsDfAccountList(fsDfAccount);
        ExcelUtil<FsDfAccount> util = new ExcelUtil<FsDfAccount>(FsDfAccount.class);
        return util.exportExcel(list, "代服账户数据");
    }

    /**
     * 获取代服账户详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:dfAccount:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(fsDfAccountService.selectFsDfAccountById(id));
    }

    /**
     * 新增代服账户
     */
    @PreAuthorize("@ss.hasPermi('his:dfAccount:add')")
    @Log(title = "代服账户", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsDfAccount fsDfAccount)
    {
        return toAjax(fsDfAccountService.insertFsDfAccount(fsDfAccount));
    }

    /**
     * 修改代服账户
     */
    @PreAuthorize("@ss.hasPermi('his:dfAccount:edit')")
    @Log(title = "代服账户", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsDfAccount fsDfAccount)
    {
        return toAjax(fsDfAccountService.updateFsDfAccount(fsDfAccount));
    }

    /**
     * 删除代服账户
     */
    @PreAuthorize("@ss.hasPermi('his:dfAccount:remove')")
    @Log(title = "代服账户", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(fsDfAccountService.deleteFsDfAccountByIds(ids));
    }
}
