package com.webchat.controller.client;

import com.webchat.common.bean.APIResponseBean;
import com.webchat.common.bean.APIResponseBeanUtil;
import com.webchat.common.helper.SessionHelper;
import com.webchat.config.annotation.ValidateLogin;
import com.webchat.service.UserWalletService;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;

/**
 * @author 程序员七七， https://www.coderutil.com网站作者
 * @date 2024/11/9 05:34
 */
@Api(tags = "【客户端】用户钱包服务接口")
@RestController
@RequestMapping("/api/user/wallet")
public class UserWalletController {
    
    @Autowired
    private UserWalletService userWalletService;

    /**
     * 查询钱包余额
     *
     * @return
     */
    @ValidateLogin
    @GetMapping("/balance")
    public APIResponseBean<String> balance() {
        String userId = SessionHelper.getCurrentUserId();
        // 系统充钱
        BigDecimal balance = userWalletService.getUserWalletBalanceFromCache(userId);
        return APIResponseBeanUtil.success(balance.toString());
    }
}