package com.ruoyi.model.controller;

import java.io.IOException;
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.AppWallet;
import com.ruoyi.model.service.IAppWalletService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 钱包Controller
 * 
 * @author ruoyi
 * @date 2025-03-08
 */
@RestController
@RequestMapping("/model/AppWallet")
public class AppWalletController extends BaseController
{
    @Autowired
    private IAppWalletService appWalletService;

    /**
     * 查询钱包列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppWallet appWallet)
    {
        startPage();
        List<AppWallet> list = appWalletService.selectAppWalletList(appWallet);
        return getDataTable(list);
    }

    /**
     * 导出钱包列表
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:export')")
    @Log(title = "钱包", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AppWallet appWallet) throws IOException {
        List<AppWallet> list = appWalletService.selectAppWalletList(appWallet);
        ExcelUtil<AppWallet> util = new ExcelUtil<AppWallet>(AppWallet.class);
        util.exportExcel(response, list, "钱包数据");
    }

    /**
     * 获取钱包详细信息
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(appWalletService.selectAppWalletById(id));
    }

    /**
     * 新增钱包
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:add')")
    @Log(title = "钱包", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AppWallet appWallet)
    {
        return toAjax(appWalletService.insertAppWallet(appWallet));
    }

    /**
     * 修改钱包
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:edit')")
    @Log(title = "钱包", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AppWallet appWallet)
    {
        return toAjax(appWalletService.updateAppWallet(appWallet));
    }

    /**
     * 删除钱包
     */
    @PreAuthorize("@ss.hasPermi('model:AppWallet:remove')")
    @Log(title = "钱包", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(appWalletService.deleteAppWalletByIds(ids));
    }
}
