新版仿ok交易所-后端
zyy
2025-10-13 9b818aedae8481c21a0f45cca55f212eb551cd5b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.yami.trading.api.controller.exchange;
 
import com.mysql.cj.util.StringUtils;
import com.yami.trading.bean.rate.domain.ExchangeRate;
import com.yami.trading.common.domain.Result;
import com.yami.trading.common.exception.YamiShopBindException;
import com.yami.trading.security.common.util.SecurityUtils;
import com.yami.trading.service.rate.UserRateConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
 
@RestController
@RequestMapping()
@Api(tags = "API 计价方式")
public class ApiExchangeRateUserConfigController {
    private final String action = "api/exchangerateuserconfig!";
    @Autowired
    private UserRateConfigService userRateConfigService;
 
    /**
     * 获取 汇率
     */
    @GetMapping(action + "get.action")
    @ApiOperation("获取 汇率")
    public Result get() throws IOException {
        String partyId = SecurityUtils.getCurrentUserId();
        Map<String, Object> data = new HashMap<String, Object>();
        ExchangeRate exchangeRate = this.userRateConfigService.findUserConfig(partyId);
        data.put("currency", exchangeRate.getCurrency());
        data.put("name", exchangeRate.getName());
        data.put("currency_symbol", exchangeRate.getCurrencySymbol());
        data.put("rate", exchangeRate.getRata());
        return Result.succeed(data);
    }
 
    @GetMapping(action + "userSetRate.action")
    @ApiOperation("设置计价方式")
    public Object userSetRate(@RequestParam String rateId) throws IOException {
        String partyId = SecurityUtils.getUser().getUserId();
        if (StringUtils.isNullOrEmpty(rateId)) {
            throw new YamiShopBindException("rateId is null");
        }
        this.userRateConfigService.update(rateId, partyId);
        return Result.succeed();
    }
}