|
1 | | -import { Equal, Like, Between, FindManyOptions} from "typeorm"; |
2 | 1 | import { Context } from '@core/koa' |
3 | 2 | import { StockHistory, History, KeyofHistory } from '../entities/mysql/shares/stockHistory' |
4 | 3 | import { Guid } from "../utils/tools"; |
@@ -92,25 +91,6 @@ class SharesController { |
92 | 91 | } |
93 | 92 | } |
94 | 93 |
|
95 | | - static async insert(args: Partial<StockHistory>) { |
96 | | - let model = new StockHistory() |
97 | | - model.uuid = Guid() |
98 | | - model.tradeAt = args.tradeAt |
99 | | - model.open = args.open |
100 | | - model.close = args.close |
101 | | - model.high = args.high |
102 | | - model.low = args.low |
103 | | - model.total = args.total |
104 | | - model.totalAmt = args.totalAmt |
105 | | - model.amplitude = args.amplitude |
106 | | - model.rasingRatio = args.rasingRatio |
107 | | - model.rasingPrice = args.rasingPrice |
108 | | - model.exchangeRatio = args.exchangeRatio |
109 | | - const result = await getSharesManager().save(model) |
110 | | - console.log(result.id) |
111 | | - return result.id |
112 | | - } |
113 | | - |
114 | 94 | static async add(data: History) { |
115 | 95 | let model = new History() |
116 | 96 | model.stockId = data.stockId |
@@ -169,24 +149,24 @@ class SharesController { |
169 | 149 | async pages(ctx: Context) { |
170 | 150 | const { code, page = 1, pageSize = 10 } = ctx.query |
171 | 151 | if(!code) { |
172 | | - ctx.Json({msg: 'code参数缺失', status: 400}) |
| 152 | + throw new Error('code参数缺失') |
173 | 153 | } |
174 | | - const [list, total] = await StockService.pages(page, pageSize, code) |
| 154 | + const [list, total] = await StockHistoryService.pages(Number(page), Number(pageSize), code) |
175 | 155 | ctx.Pages({list, total}) |
176 | 156 | } |
177 | 157 |
|
178 | 158 | async updateHistory(ctx: Context) { |
179 | 159 | const { code } = ctx.fields |
180 | 160 | const stock = await StockService.getByCode(code) |
181 | | - const [list, total] = await StockHistoryService.pages(1, 10, stock.id) |
182 | | - let lastestDate = 0 |
183 | | - if(total > 0) { |
184 | | - lastestDate = list[total - 1].timestamp |
185 | | - const today = new Date |
186 | | - // const |
187 | | - } else { |
188 | | - // |
189 | | - } |
| 161 | + // const [list, total] = await StockHistoryService.pages(1, 10, stock.id) |
| 162 | + // let lastestDate = 0 |
| 163 | + // if(total > 0) { |
| 164 | + // lastestDate = list[total - 1].timestamp |
| 165 | + // const today = new Date |
| 166 | + // // const |
| 167 | + // } else { |
| 168 | + // // |
| 169 | + // } |
190 | 170 | return stock |
191 | 171 | } |
192 | 172 | } |
|
0 commit comments