zj
2024-03-27 533f1b6ba44f398d1860a95e38589fbc13d60d44
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
56
57
58
package org.example.controller;
 
import cn.hutool.http.HttpUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.example.common.ServerResponse;
import org.example.dao.JournalismMapper;
import org.example.dao.StockMarketNewMapper;
import org.example.enums.EStockType;
import org.example.pojo.Journalism;
import org.example.pojo.StockMarketNew;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
 
/**
 * @program: webSocketProject
 * @description:
 * @create: 2024-03-26 21:51
 **/
@RestController
@RequestMapping("/api/all")
public class ApiController {
 
    @Autowired
    JournalismMapper journalismMapper;
 
    @Autowired
    StockMarketNewMapper stockMarketNewMapper;
 
 
    @GetMapping("JournalismAll")
    public ServerResponse JournalismAll(){
        LambdaQueryWrapper<Journalism> queryWrapper = new LambdaQueryWrapper<>();
        return ServerResponse.createBySuccess(journalismMapper.selectList(queryWrapper));
    }
 
    @GetMapping("StockMarketNew")
    public ServerResponse StockMarketNew(){
        LambdaQueryWrapper<StockMarketNew> queryWrapper = new LambdaQueryWrapper<>();
        return ServerResponse.createBySuccess(stockMarketNewMapper.selectList(queryWrapper));
    }
 
    /*查询股票日线*/
    @RequestMapping({"getKData.do"})
    @ResponseBody
    public String getKData(
            @RequestParam("pid") String pid,
            @RequestParam("interval") String interval,
            @RequestParam("stockType") String stockType
    ) {
        EStockType eStockType = null;
        if(stockType.equals("US")){
            eStockType = EStockType.US;
        }else{
            eStockType = EStockType.IN;
        }
        return HttpUtil.get(eStockType.stockUrl + "kline?pid=" + pid + "&interval=" + interval + "&key=" + eStockType.stockKey);
    }
}