Esempio n. 1
0
        /// <summary>
        /// 查
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public ExcutedResult QueryNoticeInfo(QueryNoticeRequestModel model)
        {
            try
            {
                if (model == null)
                {
                    throw new BusinessException(BusinessResultCode.ArgumentError, "参数错误或无效");
                }
                NoticeParams noticeParams = new NoticeParams();
                if (!string.IsNullOrEmpty(model.Title))
                {
                    noticeParams.Title = model.Title;
                }
                if (!string.IsNullOrEmpty(model.ServiceName))
                {
                    noticeParams.ServiceName = model.ServiceName;
                }
                if (!string.IsNullOrEmpty(model.Content))
                {
                    noticeParams.Content = model.Content;
                }
                if (model.IsShutdownSystem != default(byte) && model.IsShutdownSystem < 3)
                {
                    noticeParams.IsShutdownSystem = model.IsShutdownSystem;
                }
                noticeParams.SortName        = "CreateTime";
                noticeParams.IsSortOrderDesc = true;
                noticeParams.SortList        = new Dictionary <string, bool> {
                    { noticeParams.SortName, noticeParams.IsSortOrderDesc }
                };

                var dataInfo = _noticeRepository.GetQuery(noticeParams);
                if (dataInfo != null)
                {
                    return(ExcutedResult.SuccessResult(dataInfo));
                }
                return(ExcutedResult.FailedResult(BusinessResultCode.DataNotExist, "数据不存在,请刷新!"));
            }
            catch (BusinessException businessException)
            {
                return(ExcutedResult.FailedResult(businessException.ErrorCode, businessException.Message));
            }
            catch (Exception ex)
            {
                return(ExcutedResult.FailedResult(SysResultCode.ServerException, "发生异常,请稍后再试或联系管理员"));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 获取公告(分页)
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public PagedResults <Notice> GetQuery(NoticeParams model)
        {
            Expression <Func <Notice, bool> > queryExp = p => true;

            if (!string.IsNullOrEmpty(model.Content))
            {
                queryExp = queryExp.And(p => p.Content.Contains(model.Content));
            }
            if (!string.IsNullOrEmpty(model.Title))
            {
                queryExp = queryExp.And(p => p.Title.Contains(model.Title));
            }
            if (!string.IsNullOrEmpty(model.ServiceName))
            {
                queryExp = queryExp.And(p => p.ServiceName == model.ServiceName);
            }
            if (model.IsShutdownSystem != 2)
            {
                queryExp = queryExp.And(p => p.IsShutdownSystem == model.IsShutdownSystem);
            }
            return(QueryPagedResults(queryExp, model));
        }