mirror of
https://github.com/ArvinLovegood/go-stock.git
synced 2025-07-19 00:00:09 +08:00
feat(研报):增加个股研报搜索功能
- 修改 App.d.ts 和 App.js,为 StockResearchReport 函数添加股票代码参数 - 更新 app_common.go,将 StockResearchReport 方法改为接收股票代码参数 - 修改 market_news_api.go,实现根据股票代码查询研报的逻辑 - 更新 market_news_api_test.go,添加针对具体股票代码的测试用例 - 在前端 StockResearchReportList 组件中增加股票代码搜索功能
This commit is contained in:
parent
e238700333
commit
ad9bea4c24
@ -14,6 +14,6 @@ func (a *App) LongTigerRank(date string) *[]models.LongTigerRankData {
|
|||||||
return data.NewMarketNewsApi().LongTiger(date)
|
return data.NewMarketNewsApi().LongTiger(date)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) StockResearchReport() []any {
|
func (a *App) StockResearchReport(stockCode string) []any {
|
||||||
return data.NewMarketNewsApi().StockResearchReport(7)
|
return data.NewMarketNewsApi().StockResearchReport(stockCode, 7)
|
||||||
}
|
}
|
||||||
|
@ -378,7 +378,15 @@ func (m MarketNewsApi) LongTiger(date string) *[]models.LongTigerRankData {
|
|||||||
return ranks
|
return ranks
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m MarketNewsApi) StockResearchReport(days int) []any {
|
func (m MarketNewsApi) StockResearchReport(stockCode string, days int) []any {
|
||||||
|
beginDate := time.Now().Add(-time.Duration(days) * 24 * time.Hour).Format("2006-01-02")
|
||||||
|
endDate := time.Now().Format("2006-01-02")
|
||||||
|
if strutil.ContainsAny(stockCode, []string{"."}) {
|
||||||
|
stockCode = strings.Split(stockCode, ".")[0]
|
||||||
|
beginDate = time.Now().Add(-time.Duration(days) * 365 * time.Hour).Format("2006-01-02")
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.SugaredLogger.Infof("StockResearchReport-stockCode:%s", stockCode)
|
||||||
|
|
||||||
type Req struct {
|
type Req struct {
|
||||||
BeginTime string `json:"beginTime"`
|
BeginTime string `json:"beginTime"`
|
||||||
@ -397,8 +405,7 @@ func (m MarketNewsApi) StockResearchReport(days int) []any {
|
|||||||
}
|
}
|
||||||
|
|
||||||
url := "https://reportapi.eastmoney.com/report/list2"
|
url := "https://reportapi.eastmoney.com/report/list2"
|
||||||
beginDate := time.Now().Add(-time.Duration(days) * 24 * time.Hour).Format("2006-01-02")
|
|
||||||
endDate := time.Now().Format("2006-01-02")
|
|
||||||
logger.SugaredLogger.Infof("beginDate:%s endDate:%s", beginDate, endDate)
|
logger.SugaredLogger.Infof("beginDate:%s endDate:%s", beginDate, endDate)
|
||||||
resp, err := resty.New().SetTimeout(time.Duration(15)*time.Second).R().
|
resp, err := resty.New().SetTimeout(time.Duration(15)*time.Second).R().
|
||||||
SetHeader("Host", "reportapi.eastmoney.com").
|
SetHeader("Host", "reportapi.eastmoney.com").
|
||||||
@ -407,13 +414,15 @@ func (m MarketNewsApi) StockResearchReport(days int) []any {
|
|||||||
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
SetHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:140.0) Gecko/20100101 Firefox/140.0").
|
||||||
SetHeader("Content-Type", "application/json").
|
SetHeader("Content-Type", "application/json").
|
||||||
SetBody(&Req{
|
SetBody(&Req{
|
||||||
BeginTime: beginDate,
|
Code: stockCode,
|
||||||
EndTime: endDate,
|
IndustryCode: "*",
|
||||||
PageNo: 1,
|
BeginTime: beginDate,
|
||||||
PageSize: 50,
|
EndTime: endDate,
|
||||||
P: 1,
|
PageNo: 1,
|
||||||
PageNum: 1,
|
PageSize: 50,
|
||||||
PageNumber: 1,
|
P: 1,
|
||||||
|
PageNum: 1,
|
||||||
|
PageNumber: 1,
|
||||||
}).Post(url)
|
}).Post(url)
|
||||||
respMap := map[string]any{}
|
respMap := map[string]any{}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ func TestLongTiger(t *testing.T) {
|
|||||||
|
|
||||||
func TestStockResearchReport(t *testing.T) {
|
func TestStockResearchReport(t *testing.T) {
|
||||||
db.Init("../../data/stock.db")
|
db.Init("../../data/stock.db")
|
||||||
resp := NewMarketNewsApi().StockResearchReport(7)
|
resp := NewMarketNewsApi().StockResearchReport("600584.sh", 7)
|
||||||
for _, a := range resp {
|
for _, a := range resp {
|
||||||
logger.SugaredLogger.Debugf("value: %+v", a)
|
logger.SugaredLogger.Debugf("value: %+v", a)
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,27 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import {onBeforeMount, ref} from 'vue'
|
import {onBeforeMount, ref} from 'vue'
|
||||||
import {StockResearchReport} from "../../wailsjs/go/main/App";
|
import {GetStockList, StockResearchReport} from "../../wailsjs/go/main/App";
|
||||||
import {ArrowDownOutline, CaretDown, CaretUp, PulseOutline, Refresh, RefreshCircleSharp,} from "@vicons/ionicons5";
|
import {ArrowDownOutline, CaretDown, CaretUp, PulseOutline, Refresh, RefreshCircleSharp,} from "@vicons/ionicons5";
|
||||||
|
|
||||||
import KLineChart from "./KLineChart.vue";
|
import KLineChart from "./KLineChart.vue";
|
||||||
import MoneyTrend from "./moneyTrend.vue";
|
import MoneyTrend from "./moneyTrend.vue";
|
||||||
import {NButton} from "naive-ui";
|
import {useMessage} from "naive-ui";
|
||||||
import {BrowserOpenURL} from "../../wailsjs/runtime";
|
import {BrowserOpenURL} from "../../wailsjs/runtime";
|
||||||
|
|
||||||
|
const message=useMessage()
|
||||||
const list = ref([])
|
const list = ref([])
|
||||||
|
|
||||||
function getStockResearchReport() {
|
const options = ref([])
|
||||||
StockResearchReport().then(result => {
|
|
||||||
|
function getStockResearchReport(value) {
|
||||||
|
StockResearchReport(value).then(result => {
|
||||||
console.log(result)
|
console.log(result)
|
||||||
list.value = result
|
list.value = result
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onBeforeMount(()=>{
|
onBeforeMount(()=>{
|
||||||
getStockResearchReport();
|
getStockResearchReport('');
|
||||||
})
|
})
|
||||||
|
|
||||||
function ratingChangeName(ratingChange){
|
function ratingChangeName(ratingChange){
|
||||||
@ -52,9 +55,30 @@ function getmMarketCode(market,code) {
|
|||||||
function openWin(code) {
|
function openWin(code) {
|
||||||
BrowserOpenURL("https://pdf.dfcfw.com/pdf/H3_"+code+"_1.pdf?1749744888000.pdf")
|
BrowserOpenURL("https://pdf.dfcfw.com/pdf/H3_"+code+"_1.pdf?1749744888000.pdf")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function findStockList(query){
|
||||||
|
if (query){
|
||||||
|
GetStockList(query).then(result => {
|
||||||
|
options.value=result.map(item => {
|
||||||
|
return {
|
||||||
|
label: item.name+" - "+item.ts_code,
|
||||||
|
value: item.ts_code
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}else{
|
||||||
|
getStockResearchReport('')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
function handleSearch(value) {
|
||||||
|
getStockResearchReport(value)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<n-card>
|
||||||
|
<n-auto-complete :options="options" placeholder="请输入A股名称或者代码" clearable filterable :on-select="handleSearch" :on-update:value="findStockList" />
|
||||||
|
</n-card>
|
||||||
<n-table striped size="small">
|
<n-table striped size="small">
|
||||||
<n-thead>
|
<n-thead>
|
||||||
<n-tr>
|
<n-tr>
|
||||||
|
2
frontend/wailsjs/go/main/App.d.ts
vendored
2
frontend/wailsjs/go/main/App.d.ts
vendored
@ -89,7 +89,7 @@ export function SetStockSort(arg1:number,arg2:string):Promise<void>;
|
|||||||
|
|
||||||
export function ShareAnalysis(arg1:string,arg2:string):Promise<string>;
|
export function ShareAnalysis(arg1:string,arg2:string):Promise<string>;
|
||||||
|
|
||||||
export function StockResearchReport():Promise<Array<any>>;
|
export function StockResearchReport(arg1:string):Promise<Array<any>>;
|
||||||
|
|
||||||
export function SummaryStockNews(arg1:string,arg2:any):Promise<void>;
|
export function SummaryStockNews(arg1:string,arg2:any):Promise<void>;
|
||||||
|
|
||||||
|
@ -174,8 +174,8 @@ export function ShareAnalysis(arg1, arg2) {
|
|||||||
return window['go']['main']['App']['ShareAnalysis'](arg1, arg2);
|
return window['go']['main']['App']['ShareAnalysis'](arg1, arg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function StockResearchReport() {
|
export function StockResearchReport(arg1) {
|
||||||
return window['go']['main']['App']['StockResearchReport']();
|
return window['go']['main']['App']['StockResearchReport'](arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function SummaryStockNews(arg1, arg2) {
|
export function SummaryStockNews(arg1, arg2) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user