コード例 #1
0
        /// <summary>
        /// 目前只取面向全部人员类型
        /// TODO 后期添加其他类型
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <Page <OaMessageMyList> > MyListAsync(OaMessageMyListSearch search)
        {
            Page <OaMessageMyList> page = new Page <OaMessageMyList>()
            {
                PageIndex = search.PageIndex,
                PageSize  = search.PageSize
            };
            string sqlwhere = " ";

            if (search.IsRead == 1)
            {
                sqlwhere += "AND om.IsRead=1 ";
            }
            else if (search.IsRead == 0)
            {
                sqlwhere += "AND om.IsRead=0 ";
            }

            string sql = $@"SELECT * FROM ( SELECT om.`Id`,om.`MsgType`,om.`TargetType`,om.`Title`,om.`IsLocal`,om.`Link`,om.`CreateTime`,(omur.`Id` > 0) AS IsRead  FROM oa_message om
LEFT JOIN oa_message_user_read omur ON omur.`MessageId`=om.`Id` AND omur.`UserId`= @userid
WHERE om.`IsEnable`=1 AND om.`IsDel`=0 AND om.`FaceUserType`=0 ) om WHERE 1=1  {sqlwhere}
ORDER BY om.`CreateTime` DESC LIMIT @offset,@pageSize";


            page.Items = await this.Connection.QueryAsync <OaMessageMyList>(sql, new { userid = search.UserId, offset = search.OffSet(), pageSize = search.PageSize });

            page.TotalItems = await this.ExecuteScalarAsync <int>($@"SELECT COUNT(1) FROM 
( SELECT om.`Id`,om.`MsgType`,om.`TargetType`,om.`Title`,om.`IsLocal`,om.`Link`,om.`CreateTime`,(omur.`Id` > 0) AS IsRead  FROM oa_message om
LEFT JOIN oa_message_user_read omur ON omur.`MessageId`=om.`Id` AND omur.`UserId`= @userid
WHERE om.`IsEnable`=1 AND om.`IsDel`=0 AND om.`FaceUserType`=0 ) om WHERE 1=1  {sqlwhere}", new { userid = search.UserId });

            return(page);
        }
コード例 #2
0
        public async Task <Page <OaMessageMyList> > MyListAsync(OaMessageMyListSearch search)
        {
            var uri            = API.OaMessage.MyListAsync(_baseUrl, search);
            var responseString = await _apiClient.GetStringAsync(uri);

            return(responseString.ToObject <Page <OaMessageMyList> >());
        }
コード例 #3
0
        public async Task <IActionResult> MyList(OaMessageMyListSearch search)
        {
            if (search.PageIndex == 0)
            {
                search.PageIndex = 1;
            }
            if (search.PageSize == 0)
            {
                search.PageSize = 10;
            }
            search.UserId = UserIdentity.UserId;
            var page = await _messageService.MyListAsync(search);

            return(View(page));
        }
コード例 #4
0
        /// <summary>
        /// 获取首页消息
        /// </summary>
        /// <returns></returns>
        public async Task <IActionResult> HomeMessage()
        {
            OaMessageMyListSearch search = new OaMessageMyListSearch();

            if (search.PageIndex == 0)
            {
                search.PageIndex = 1;
            }
            if (search.PageSize == 0)
            {
                search.PageSize = 10;
            }
            search.IsRead = 0;
            search.UserId = UserIdentity.UserId;
            var page = await _messageService.MyListAsync(search);

            return(Ok(page));
        }
コード例 #5
0
        /// <summary>
        /// 目前只取面向全部人员类型
        /// TODO 后期添加其他类型
        /// </summary>
        /// <param name="search"></param>
        /// <returns></returns>
        public async Task <Page <OaMessageMyList> > MyListAsync(OaMessageMyListSearch search)
        {
            Page <OaMessageMyList> page = new Page <OaMessageMyList>()
            {
                PageIndex = search.PageIndex,
                PageSize  = search.PageSize
            };
            string sqlwhere = " ";

            if (search.IsRead == 1)
            {
                sqlwhere += "AND omu.IsRead=1 ";
            }
            else if (search.IsRead == 0)
            {
                sqlwhere += "AND omu.IsRead=0 ";
            }

            string sql = $@"SELECT om.`Id`,om.`MsgType`,om.`TargetType`,om.`Title`,om.`IsLocal`,om.`Link`,om.`CreateTime`,omu.IsRead FROM oa_message_user omu
INNER JOIN oa_message om ON om.Id=omu.MessageId
WHERE omu.Id in(
SELECT MAX(omu2.Id) Id FROM oa_message_user omu2 WHERE omu2.UserId=@userid GROUP BY omu2.MessageId
)
{sqlwhere}
ORDER BY om.CreateTime DESC
LIMIT @offset,@pageSize
";


            page.Items = await this.Connection.QueryAsync <OaMessageMyList>(sql, new { userid = search.UserId, offset = search.OffSet(), pageSize = search.PageSize });

            page.TotalItems = await this.ExecuteScalarAsync <int>($@"SELECT COUNT(omu.Id) FROM oa_message_user omu
                    INNER JOIN oa_message om ON om.Id=omu.MessageId
                    WHERE omu.Id in(
                    SELECT MAX(omu2.Id) Id FROM oa_message_user omu2 WHERE omu2.UserId=@userid GROUP BY omu2.MessageId
                    )
                    {sqlwhere}", new { userid = search.UserId });

            return(page);
        }
コード例 #6
0
 public static string MyListAsync(string baseUri, OaMessageMyListSearch search) => $"{baseUri}/Message/MyListAsync?" + search.ToUrlParam();
コード例 #7
0
 public async Task <Page <OaMessageMyList> > MyListAsync(OaMessageMyListSearch search)
 {
     return(await _databaseFixture.Db.OaMessage.MyListAsync(search));
 }
コード例 #8
0
 public async Task <Page <OaMessageMyList> > MyListAsync([FromQuery] OaMessageMyListSearch search)
 {
     return(await _messageService.MyListAsync(search));
 }