public ResponseMessage <List <SongJson> > Search([FromBody] SongSearchRequest request) { // 日志输出:请求体 Console.WriteLine("WS------ Request: \r\n" + request); // 创建响应体 ResponseMessage <List <SongJson> > response = new ResponseMessage <List <SongJson> >(); try { // 业务处理 _SongManager.Serch(response, request); } catch (Exception e) { response.Code = ResponseDefine.ServiceError; response.Message += "\r\n" + e.Message; // 日志输出:服务器错误 Console.WriteLine("WS------ ServiceError: \r\n" + e); } if (response.Code == "0" && response.Extension == null) { response.Code = ResponseDefine.NotFound; // 日志输出:找不到资源 Console.WriteLine("WS------ NotFund: \r\n" + ""); } // 日志输出:响应体 Console.WriteLine("WS------ Response: \r\n" + response != null ? JsonUtil.ToJson(response) : ""); return(response); }
public async ValueTask <byte[]> DownloadAsync(string songName, string artist) { var requestParameter = new SongSearchRequest(songName, artist); var searchResult = await _warpHttpClient.GetAsync <SongSearchResponse>( SearchApi, requestParameter, _defaultOption); return(new byte[] { 0x1, 0x2 }); }
/*---------------------------------------- METHODS ------------------------------------------- */ public async Task SearchSongs() { SongSearchRequest req = new SongSearchRequest() { Title = SongTitle, Text = Text }; await GetSongsBySearchParams(req); }
private async void BtnSongSearch_Click(object sender, EventArgs e) { var obj = new SongSearchRequest() { Title = txtboxTitle.Text, Text = txtBoxLyrics.Text }; var data = await _songService.Get <List <SongGetRequest> >(obj, null); dgvSong.DataSource = data; }
public async ValueTask <byte[]> DownloadAsync(string songName, string artist) { var requestParameter = new SongSearchRequest(songName, artist); var searchResult = await _warpHttpClient.PostAsync <SongSearchResponse>( SearchMusicApi, requestParameter, true, _defaultOption); if (searchResult is not { StatusCode : 200 } || searchResult.Items?.SongCount <= 0)
public async Task <SongSearchResponse> SongSearch(SongSearchRequest request) { try { var result = await _searchClient.PostAsync("SongSearch", HttpClientHelper.GetJsonData(request)); return(JsonConvert.DeserializeObject <SongSearchResponse>(await result.Content.ReadAsStringAsync())); } catch (Exception e) { return(HttpClientHelper.LogError <SongSearchResponse>(_logger, e, new object[] { request.SearchTerms })); } }
public async Task GetSongsBySearchParams(SongSearchRequest req) { SongList.Clear(); List <SongGetRequest> list = await _songService.Get <List <SongGetRequest> >(req, null); if (list.Count != 0) { foreach (var item in list) { SongList.Add(item); } } }
public List <SongGetRequest> Get(SongSearchRequest request) { var query = _context.Song.AsQueryable(); if (!string.IsNullOrWhiteSpace(request?.Title)) { query = query.Where(x => x.Title.Contains(request.Title)); } if (!string.IsNullOrWhiteSpace(request?.Text)) { query = query.Where(x => x.Text.Contains(request.Text)); } var result = query.Include(x => x.Album).Include(x => x.Album.Performer).OrderBy(x => x.Title).Take(9).ToList(); return(_mapper.Map <List <SongGetRequest> >(result)); }
public async Task <IActionResult> SongSearch([FromBody] SongSearchRequest request) { try { var searchResults = await _solrService.Search(request.SearchTerms); return(new JsonResult(new SongSearchResponse { SearchResults = searchResults })); } catch (Exception e) { _logger.LogError(e, "Error in SongSearch"); return(BadRequest()); } }
/// <summary> /// Fuzzy search Songs by Song Name, Artist Name, Album Name, Lyric, Tag or All the Names. /// </summary> /// <param name="response">Response Message</param> /// <param name="request">Song Search Request</param> public void Serch([Required] ResponseMessage <List <SongJson> > response, [Required] SongSearchRequest request) { // Check arguments. if (request.Word == null) { Def.Response.Wrap(response, Def.Response.BadRequsetCode, "Keywords can not be empty!"); } // Search Song by Song Name. if (request.Type == null || request.Type.ToLower() == "song") { response.Extension = Store.LikeName(request.Word).Select(a => _Mapper.Map <SongJson>(a)).ToList(); } // Search Song by Other ways. switch (request.Type.ToLower()) { case "artist": response.Extension = Store.LikeArtistName(request.Word).Select(a => _Mapper.Map <SongJson>(a)).ToList(); break; case "album": response.Extension = Store.LikeAlbumName(request.Word).Select(a => _Mapper.Map <SongJson>(a)).ToList(); break; case "all": response.Extension = Store.LikeAllName(request.Word).Select(a => _Mapper.Map <SongJson>(a)).ToList(); break; case "lyric": default: if (response.Extension == null) { Def.Response.Wrap(response, Def.Response.NotSupportCode, "Does not support query songs by other ways!"); } break; } }
public ActionResult <List <SongGetRequest> > Get([FromQuery] SongSearchRequest request) { return(_songService.Get(request)); }