/// <summary> /// 获取分页数据. /// </summary> /// <param name="modal">The modal<see cref="UserCollectQueryDTO"/>.</param> /// <returns>.</returns> public async Task <BaseResult <UserCollectEntity> > GetCollectList(UserCollectQueryDTO modal) { string tableName = "tbUserCollect"; //string where = " IsDelete=0"; string orderby = "id "; if (modal.sortRule == 1) { orderby += " desc"; } else { orderby += " asc"; } int skip = (modal.pageIndex - 1) * modal.pageSize + 1; StringBuilder sb = new StringBuilder(); sb.AppendFormat(@"SELECT COUNT(1) FROM {0} where 1=1 AND type={1} AND userId={2};", tableName, modal.type, modal.userId); sb.AppendFormat(@"SELECT * FROM(SELECT ROW_NUMBER() OVER(ORDER BY {1}) AS RowNum,* FROM {0} WHERE 1=1 ) AS result WHERE RowNum >= {2} AND RowNum <= {3} AND type={4} AND userId={5} ORDER BY {1}", tableName, orderby, skip, modal.pageIndex * modal.pageSize, modal.type, modal.userId); var result = new BaseResult <UserCollectEntity>(); try { var pageData = await GetPageList(sb.ToString()); if (pageData.total > -1) { result.code = ResultKey.RETURN_SUCCESS_CODE; result.data = pageData; result.desc = ResultKey.RETURN_SUCCESS_DESC; } else { result.code = ResultKey.RETURN_FAIL_CODE; result.desc = ResultKey.RETURN_FAIL_DESC; } } catch (Exception ex) { NlogHelper.InfoLog(ex.Message); throw new Exception(ex.Message); } return(result); }
public async Task <BaseResult <UserCollectEntity> > GetCollectList(UserCollectQueryDTO modal) { return(await userCollectRepository.GetCollectList(modal)); }