package com.bonus.canteen.core.account.controller;

import com.bonus.canteen.core.account.domain.AccWalletInfo;
import com.bonus.canteen.core.account.service.IAccWalletInfoService;
import com.bonus.common.core.utils.poi.ExcelUtil;
import com.bonus.common.core.web.controller.BaseController;
import com.bonus.common.core.web.domain.AjaxResult;
import com.bonus.common.core.web.page.TableDataInfo;
import com.bonus.common.log.annotation.SysLog;
import com.bonus.common.log.enums.OperaType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 钱包详情信息Controller
 * 
 * @author xsheng
 * @date 2025-04-05
 */
@Api(tags = "钱包详情信息接口")
@RestController
@RequestMapping("/acc_wallet_info")
public class AccWalletInfoController extends BaseController {
    @Autowired
    private IAccWalletInfoService accWalletInfoService;

    /**
     * 查询钱包详情信息列表
     */
    @ApiOperation(value = "查询钱包详情信息列表")
    //@RequiresPermissions("account:info:list")
    @GetMapping("/list")
    public TableDataInfo list(AccWalletInfo accWalletInfo) {
        startPage();
        List<AccWalletInfo> list = accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
        return getDataTable(list);
    }

    /**
     * 导出钱包详情信息列表
     */
    @ApiOperation(value = "导出钱包详情信息列表")
    //@PreventRepeatSubmit
    //@RequiresPermissions("account:info:export")
    @SysLog(title = "钱包详情信息", businessType = OperaType.EXPORT, logType = 1,module = "仓储管理->导出钱包详情信息")
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccWalletInfo accWalletInfo) {
        List<AccWalletInfo> list = accWalletInfoService.selectAccWalletInfoList(accWalletInfo);
        ExcelUtil<AccWalletInfo> util = new ExcelUtil<AccWalletInfo>(AccWalletInfo.class);
        util.exportExcel(response, list, "钱包详情信息数据");
    }

    /**
     * 获取钱包详情信息详细信息
     */
    @ApiOperation(value = "获取钱包详情信息详细信息")
    //@RequiresPermissions("account:info:query")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId) {
        return success(accWalletInfoService.selectAccWalletInfoByUserId(userId));
    }

    /**
     * 新增钱包详情信息
     */
    @ApiOperation(value = "新增钱包详情信息")
    //@PreventRepeatSubmit
    //@RequiresPermissions("account:info:add")
    @SysLog(title = "钱包详情信息", businessType = OperaType.INSERT, logType = 1,module = "仓储管理->新增钱包详情信息")
    @PostMapping
    public AjaxResult add(@RequestBody AccWalletInfo accWalletInfo) {
        try {
            return toAjax(accWalletInfoService.insertAccWalletInfo(accWalletInfo));
        } catch (Exception e) {
            return error("系统错误, " + e.getMessage());
        }
    }

    /**
     * 删除钱包详情信息
     */
    @ApiOperation(value = "删除钱包详情信息")
    //@PreventRepeatSubmit
    //@RequiresPermissions("account:info:remove")
    @SysLog(title = "钱包详情信息", businessType = OperaType.DELETE, logType = 1,module = "仓储管理->删除钱包详情信息")
	@PostMapping("/del/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds) {
        return toAjax(accWalletInfoService.deleteAccWalletInfoByUserIds(userIds));
    }
}
