增加参数的有效性判断

This commit is contained in:
injoyai
2024-10-30 15:29:49 +08:00
parent a8ec5c19a2
commit bd82866f03
3 changed files with 105 additions and 17 deletions

View File

@@ -15,6 +15,9 @@ type StockKlineReq struct {
}
func (this *StockKlineReq) Bytes(Type TypeKline) (g.Bytes, error) {
if this.Count > 800 {
return nil, errors.New("单次数量不能超过800")
}
if len(this.Code) != 6 {
return nil, errors.New("股票代码长度错误")
}
@@ -78,7 +81,6 @@ func (stockKline) Decode(bs []byte, Type TypeKline) (*StockKlineResp, error) {
bs = bs[2:]
var last Price
for i := uint16(0); i < resp.Count; i++ {
k := &StockKline{
Time: GetTime([4]byte(bs[:4]), Type),