/// <summary> /// 搜索商品 /// </summary> /// <param name="request"></param> /// <returns></returns> public async Task <SearchProductResponseDto> SearchProductAsync(SearchProductRequestDto request) { var sqlWhere = $@"AND ENABLE = 1 "; if (!string.IsNullOrWhiteSpace(request.Keyword)) { sqlWhere = $"{sqlWhere} AND (merchant_name like @Keyword OR category_name like @Keyword OR product_name like @Keyword OR product_label like @Keyword OR brand like @Keyword)"; } var sql = $@" SELECT * FROM( SELECT A.*, CONCAT( B.base_path, B.relative_path ) AS LogoUrl, C.merchant_name FROM t_mall_product A LEFT JOIN t_utility_accessory B ON B.accessory_guid = A.picture_guid LEFT JOIN t_merchant C ON C.merchant_guid = A.merchant_guid )T WHERE 1 = 1 {sqlWhere} ORDER BY creation_date" ; request.Keyword = $"%{request.Keyword}%"; return(await MySqlHelper.QueryByPageAsync <SearchProductRequestDto, SearchProductResponseDto, SearchProductItemDto>(sql, request)); }
public async Task <IActionResult> SearchProductAsync([FromBody] SearchProductRequestDto request) { var response = await new ProductBiz().SearchProductAsync(request); return(Success(response)); }