/// <summary> /// 获取广告列表 /// </summary> /// <param name="count"></param> /// <returns></returns> public BaseResopne <List <Advertisement> > GetAdvertisementes(GetAdvertisementesParam Param) { BaseResopne <List <Advertisement> > result = new BaseResopne <List <Advertisement> >(); try { StringBuilder sql = new StringBuilder(); StringBuilder countSql = new StringBuilder(); sql.AppendLine("select * from de2_advertisement"); countSql.AppendLine("select count(id) from de2_advertisement"); sql.AppendLine("order by `index` desc limit @start,@count"); // string sql = string.Format("select * from de2_advertisement order by index desc limit @limit"); MySqlClient _client = new MySqlClient(); result.Total = Convert.ToInt32(_client.ExecuteScalar(countSql.ToString())); result.Data = _client.ExecuteQuery <Advertisement>(sql.ToString(), new MySqlParameter("@start", Param.StartRow), new MySqlParameter("@count", Param.PageSize)); } catch (Exception ex) { LogFactory _LogFactory = new LogFactory(this.GetType()); _LogFactory.CreateLog(LogType.Error, "获取广告列表", "GetAdvertisementList", ex); result.IsSuccess = false; result.Error = ex.Message; } return(result); }
public HttpResponseMessage GetAdvertisementes([FromUri] GetAdvertisementesParam Param) { try { AdvertisementProvider _Provider = new AdvertisementProvider(); var result = _Provider.GetAdvertisementes(Param); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (Exception ex) { LogFactory _LogFactory = new LogFactory(this.GetType()); _LogFactory.CreateLog(LogType.Error, "获取广告列表", "GetAdvertisementes", ex); return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message)); } }