refactor: 优化单个和批量哈希查询的响应处理方式
This commit is contained in:
parent
a2d17709ed
commit
5dfc935f18
@ -394,17 +394,14 @@ func GetSongIdsByHash(hashs []string) (hashToSongId map[string]string, err error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var response map[string]struct {
|
||||
var response = make(map[string]struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
})
|
||||
if len(batchHashs) == 1 {
|
||||
var singleResponse struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
err = json.Unmarshal(body, &singleResponse)
|
||||
response = make(map[string]struct {
|
||||
ID string `json:"id"`
|
||||
})
|
||||
response[batchHashs[0]] = singleResponse
|
||||
} else {
|
||||
err = json.Unmarshal(body, &response)
|
||||
|
@ -422,17 +422,14 @@ func GetSongIdsByHash(hashs []string) (hashToSongId map[string]string, err error
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var response map[string]struct {
|
||||
var response = make(map[string]struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
})
|
||||
if len(batchHashs) == 1 {
|
||||
var singleResponse struct {
|
||||
ID string `json:"id"`
|
||||
}
|
||||
err = json.Unmarshal(body, &singleResponse)
|
||||
response = make(map[string]struct {
|
||||
ID string `json:"id"`
|
||||
})
|
||||
response[batchHashs[0]] = singleResponse
|
||||
} else {
|
||||
err = json.Unmarshal(body, &response)
|
||||
|
Loading…
x
Reference in New Issue
Block a user