package com.seer.teach.pay.app.wallet.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.annotation.SaCheckPermission;
import cn.dev33.satoken.stp.StpUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.seer.teach.common.PageListBean;
import com.seer.teach.common.ResultBean;
import com.seer.teach.common.annotation.DecryptionAnnotation;
import com.seer.teach.common.annotation.EncryptionAnnotation;
import com.seer.teach.common.utils.PageConverterUtils;
import com.seer.teach.pay.app.wallet.convert.UserCoinAccountTradeLogConvert;
import com.seer.teach.pay.app.wallet.resp.UserCoinAccountTradeLogResp;
import com.seer.teach.pay.entity.PayCoinAccountTradeLogEntity;
import com.seer.teach.pay.app.wallet.req.CoinAccountTradeLogReq;
import com.seer.teach.pay.app.wallet.service.IAppUserCoinAccountTradeLogService;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Tag(name = "APP - 账户交易明细日志")
@Validated
@RequiredArgsConstructor
@RequestMapping("/app/wallet/trade-log")
@SaCheckLogin(type = StpUtil.TYPE)
public class AppUserCoinAccountTradeLogController {

    private final IAppUserCoinAccountTradeLogService userCoinAccountTradeLogService;

    @Operation(summary = "我的交易明细列表")
    @PostMapping
    @DecryptionAnnotation
    @EncryptionAnnotation
    @SaCheckPermission("app:wallet:trade-log:list")
    public ResultBean<PageListBean<UserCoinAccountTradeLogResp>> page(@RequestBody CoinAccountTradeLogReq coinAccountTradeLogReq) {
        IPage<PayCoinAccountTradeLogEntity> iPage = userCoinAccountTradeLogService.myCoinAccountTradePageList(coinAccountTradeLogReq);
        PageListBean<UserCoinAccountTradeLogResp> orderRespPageListBean = PageConverterUtils.convertPageListBean(iPage, UserCoinAccountTradeLogConvert.INSTANCE::convertList);
        return ResultBean.success(orderRespPageListBean);
    }
}