package com.fs.his.controller;
import java.util.List;

import com.fs.his.param.FsUserBillParam;
import com.fs.his.vo.FsUserBillVO;
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.FsUserBill;
import com.fs.his.service.IFsUserBillService;
import com.fs.common.utils.poi.ExcelUtil;
import com.fs.common.core.page.TableDataInfo;

/**
 * 用户帐单记录Controller
 *
 * @author fs
 * @date 2023-06-25
 */
@RestController
@RequestMapping("/his/userBill")
public class FsUserBillController extends BaseController
{
    @Autowired
    private IFsUserBillService fsUserBillService;

    /**
     * 查询用户帐单记录列表
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:list')")
    @GetMapping("/list")
    public TableDataInfo list(FsUserBillParam fsUserBill)
    {
        startPage();
        List<FsUserBillVO> list = fsUserBillService.selectFsUserBillListVO(fsUserBill);
        return getDataTable(list);
    }

    /**
     * 导出用户帐单记录列表
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:export')")
    @Log(title = "用户帐单记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(FsUserBill fsUserBill)
    {
        List<FsUserBill> list = fsUserBillService.selectFsUserBillList(fsUserBill);
        ExcelUtil<FsUserBill> util = new ExcelUtil<FsUserBill>(FsUserBill.class);
        return util.exportExcel(list, "用户帐单记录数据");
    }

    /**
     * 获取用户帐单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:query')")
    @GetMapping(value = "/{billId}")
    public AjaxResult getInfo(@PathVariable("billId") Long billId)
    {
        return AjaxResult.success(fsUserBillService.selectFsUserBillByBillId(billId));
    }

    /**
     * 新增用户帐单记录
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:add')")
    @Log(title = "用户帐单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FsUserBill fsUserBill)
    {
        return toAjax(fsUserBillService.insertFsUserBill(fsUserBill));
    }

    /**
     * 修改用户帐单记录
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:edit')")
    @Log(title = "用户帐单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FsUserBill fsUserBill)
    {
        return toAjax(fsUserBillService.updateFsUserBill(fsUserBill));
    }

    /**
     * 删除用户帐单记录
     */
    @PreAuthorize("@ss.hasPermi('his:userBill:remove')")
    @Log(title = "用户帐单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{billIds}")
    public AjaxResult remove(@PathVariable Long[] billIds)
    {
        return toAjax(fsUserBillService.deleteFsUserBillByBillIds(billIds));
    }
}
