package com.hzs.system.config.controller.api;

import cn.hutool.core.bean.BeanUtil;
import com.hzs.common.core.annotation.Log;
import com.hzs.common.core.enums.*;
import com.hzs.common.core.web.controller.BaseController;
import com.hzs.common.core.web.domain.AjaxResult;
import com.hzs.common.domain.system.config.BdAccount;
import com.hzs.common.security.utils.SecurityUtils;
import com.hzs.system.config.param.PkBdAccountParam;
import com.hzs.system.config.service.IBdAccountService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 * 币种配置表 前端控制器
 * </p>
 *
 * @author zhangjing
 * @since 2022-08-25
 */
@Slf4j
@RestController
@RequestMapping("/api/account")
public class ApiBdAccountController extends BaseController {

    @Autowired
    private IBdAccountService accountService;

    /**
     * @description: 查询转换币种列表
     * @author: zhang jing
     * @date: 2022/10/25 16:20
     * @param: []
     * @return: com.hzs.common.core.web.page.TableDataInfo
     **/
    @Log(module = EOperationModule.WALLET_CONFIG,business = EOperationBusiness.CURRENCY_CONFIG,method = EOperationMethod.SELECT)
    @GetMapping("/pkBdAccountList")
    public AjaxResult list(PkBdAccountParam accountParam) {
        List<BdAccount> list= accountService.queryAccountByType(accountParam.getAccountProperty(),SecurityUtils.getPkCountry());
        List<PkBdAccountParam> paList = new ArrayList<>();
        list.forEach(item -> paList.add(BeanUtil.copyProperties(item, PkBdAccountParam.class)));
        return AjaxResult.success(paList);
    }






}
