예제 #1
0
 /// <summary>
 /// 获取学术资源列表
 /// </summary>
 /// <param name="Param"></param>
 /// <returns></returns>
 public BaseResopne <List <AcademicResources> > GetAcademicResourcesListForManager(GetPeriodicalListParam Param)
 {
     return(GetAcademicResourcesList(Param, true));
 }
예제 #2
0
 /// <summary>
 /// 获取学术资源列表应用
 /// </summary>
 /// <param name="Param"></param>
 /// <returns></returns>
 public BaseResopne <List <AcademicResources> > GetAcademicResourcesListForApp(GetPeriodicalListParam Param)
 {
     return(GetAcademicResourcesList(Param, false));
 }
예제 #3
0
        /// <summary>
        /// 获取学术资源列表
        /// </summary>
        /// <param name="Param"></param>
        /// <param name="isPublish"></param>
        /// <returns></returns>
        private BaseResopne <List <AcademicResources> > GetAcademicResourcesList(GetPeriodicalListParam Param, bool isPublish)
        {
            BaseResopne <List <AcademicResources> > result = new BaseResopne <List <AcademicResources> >();

            try
            {
                StringBuilder sql      = new StringBuilder();
                StringBuilder sqlCount = new StringBuilder();
                sql.AppendLine(@"select dac.id,dac.`name`,dac.parentID,dac.sourceTypeID,dat.typeName as sourceTypeName
                            ,dac.createTime,u.userName as createUserName,dac.createUserID,dac.isMenu
                            ,dac.isChild,dac.author,`year`,periodNumber
                            from de2_aresource  dac
                            LEFT JOIN de2_user u on  u.id=dac.createUserID
                            LEFT JOIN de2_aresource_type dat on dat.id=dac.sourceTypeID where 1=1");
                sql.AppendLine("select count(id) from de2_aresource  where 1=1");
                //检索条件
                if (Param.sourceTypeID != 0)
                {
                    sql.AppendLine("sourceTypeID=@sourceTypeID");
                    sqlCount.AppendLine("sourceTypeID=@sourceTypeID");
                }
                //年度
                if (!string.IsNullOrEmpty(Param.year))
                {
                    sql.AppendLine("`year`=@`year`");
                    sqlCount.AppendLine("`year`=@`year`");
                }
                //期数
                if (!string.IsNullOrEmpty(Param.periodNumber))
                {
                    sql.AppendLine("periodNumber=@periodNumber");
                    sqlCount.AppendLine("periodNumber=@periodNumber");
                }
                //父级ID
                sql.AppendLine("  parentID=@parentID");
                sqlCount.AppendLine("  parentID=@parentID");
                //是否发布
                sql.AppendLine("  isPublish=@isPublish");
                sqlCount.AppendLine("  isPublish=@isPublish");

                //排序
                sql.AppendLine(" order by dam.createTime @orderByType");
                sql.AppendLine(" limit @start,@pageSize ");
                //执行sql
                MySqlClient _client = new MySqlClient();
                result.Total = Convert.ToInt32(_client.ExecuteScalar(sqlCount.ToString()
                                                                     , new MySqlParameter("@sourceTypeID", Param.sourceTypeID)
                                                                     , new MySqlParameter("@parentID", Param.parenId)
                                                                     , new MySqlParameter("@`year`", Param.year)
                                                                     , new MySqlParameter("@periodNumber", Param.periodNumber)
                                                                     , new MySqlParameter("@isPublish", isPublish)));
                result.Data = _client.ExecuteQuery <AcademicResources>(sql.ToString()
                                                                       , new MySqlParameter("@sourceTypeID", Param.sourceTypeID)
                                                                       , new MySqlParameter("@orderByType", Param.orderType)
                                                                       , new MySqlParameter("@parentID", Param.parenId)
                                                                       , new MySqlParameter("@isPublish", isPublish)
                                                                       , new MySqlParameter("@`year`", Param.year)
                                                                       , new MySqlParameter("@periodNumber", Param.periodNumber)
                                                                       , new MySqlParameter("@start", Param.StartRow)
                                                                       , new MySqlParameter("@pageSize", Param.PageSize));
                result.IsSuccess = true;
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取学术资源列表", "GetAcademicResourcesList", ex);
                result.IsSuccess = false;
            }
            return(result);
        }