zyy
2025-12-06 ab7e92d5154b5acf05699bd527c4d8b5fff10550
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
53
54
55
package com.yami.trading.api.controller;
 
import com.yami.trading.common.exception.BusinessException;
import com.yami.trading.common.web.ResultObject;
import com.yami.trading.service.system.TipService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
 
@RestController
@CrossOrigin
@Slf4j
public class ApiTips {
 
    @Autowired
    TipService tipService;
 
    @RequestMapping("/api/tip/getRandomByType")
    public Object getRandomByType(@RequestParam String type) {
        ResultObject resultObject = new ResultObject();
        try {
            resultObject.setData(tipService.getRandom(type));
            resultObject.setCode("0");
        } catch (BusinessException e) {
            resultObject.setCode("1");
            resultObject.setMsg(e.getMessage());
        } catch (Throwable t) {
            resultObject.setCode("1");
            resultObject.setMsg("程序错误");
            log.error("error:", t);
        }
        return resultObject;
    }
 
    @RequestMapping("/api/tip/getRandom")
    public Object list() {
        ResultObject resultObject = new ResultObject();
        try {
            resultObject.setData(tipService.getRandom());
            resultObject.setCode("0");
        } catch (BusinessException e) {
            resultObject.setCode("1");
            resultObject.setMsg(e.getMessage());
        } catch (Throwable t) {
            resultObject.setCode("1");
            resultObject.setMsg("程序错误");
            log.error("error:", t);
        }
        return resultObject;
    }
 
}