package com.ruoyi.model.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.model.domain.AppletAmountLog;
import com.ruoyi.model.service.IAppletAmountLogService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 金额明细Controller
 * 
 * @author ruoyi
 * @date 2025-03-28
 */
@RestController
@RequestMapping("/model/AppletAmountLog")
public class AppletAmountLogController extends BaseController
{
    @Autowired
    private IAppletAmountLogService appletAmountLogService;

    /**
     * 查询金额明细列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppletAmountLog appletAmountLog)
    {
        startPage();
        List<AppletAmountLog> list = appletAmountLogService.selectAppletAmountLogList(appletAmountLog);
        return getDataTable(list);
    }

    /**
     * 导出金额明细列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:export')")
    @Log(title = "金额明细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppletAmountLog appletAmountLog)
    {
//        List<AppletAmountLog> list = appletAmountLogService.selectAppletAmountLogList(appletAmountLog);
//        ExcelUtil<AppletAmountLog> util = new ExcelUtil<AppletAmountLog>(AppletAmountLog.class);
//        util.exportExcel(response, list, "金额明细数据");
    }

    /**
     * 获取金额明细详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appletAmountLogService.selectAppletAmountLogById(id));
    }

    /**
     * 新增金额明细
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:add')")
    @Log(title = "金额明细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppletAmountLog appletAmountLog)
    {
        return toAjax(appletAmountLogService.insertAppletAmountLog(appletAmountLog));
    }

    /**
     * 修改金额明细
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:edit')")
    @Log(title = "金额明细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppletAmountLog appletAmountLog)
    {
        return toAjax(appletAmountLogService.updateAppletAmountLog(appletAmountLog));
    }

    /**
     * 删除金额明细
     */
    @PreAuthorize("@ss.hasPermi('model:AppletAmountLog:remove')")
    @Log(title = "金额明细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appletAmountLogService.deleteAppletAmountLogByIds(ids));
    }
}
