|
@@ -321,273 +321,499 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<PagedList<NoticeListPageResult>> GetNoticeListPageAsync(NoticePageSearchRequest request)
|
|
|
{
|
|
|
- //用户收件人
|
|
|
- string sb = "";
|
|
|
+ // //用户收件人
|
|
|
+ // string sb = "";
|
|
|
+ // if (request.SearchType == 1)
|
|
|
+ // sb += " AND a.IsAdmin = 1 and a.NoticeAddresseeType=1 AND a.IsDelete = 0";
|
|
|
+ // else if (request.SearchType == 2)
|
|
|
+ // sb += " and a.NoticeAddresseeType=2 AND a.AttributeValue=1 AND a.IsDelete = 0";
|
|
|
+ // else if (request.SearchType == 3)
|
|
|
+ // sb += " AND a.IsDelete = 1 AND a.AttributeValue=1";
|
|
|
+ // else if (request.SearchType > 3)
|
|
|
+ // sb += $"and a.NoticeAddresseeType<>2 AND b.TypeValue={request.SearchType} AND a.IsDelete = 0";
|
|
|
+ // else
|
|
|
+ // sb += " AND a.IsDelete = 0 AND a.NoticeAddresseeType != 2";
|
|
|
+ // if (!string.IsNullOrEmpty(request.Keyword))
|
|
|
+ // {
|
|
|
+ // if (request.NoticeFolderId > 0)
|
|
|
+ // sb += $@" AND a.ParentId ={request.NoticeFolderId} AND a.AttributeValue != 2 and (b.Title LIKE '%{request.Keyword}%'
|
|
|
+ // OR b.Content LIKE '%{request.Keyword}%'
|
|
|
+ // OR c.Name LIKE '%{request.Keyword}%'
|
|
|
+ // OR d.UserName LIKE '%{request.Keyword}%'
|
|
|
+ // OR a.CreatedDate LIKE '%{request.Keyword}%' or a.MiddleId in (SELECT
|
|
|
+ // g.SourceId
|
|
|
+ // FROM
|
|
|
+ // tede_addressee g
|
|
|
+ // INNER JOIN
|
|
|
+ // tede_user h ON g.UserId = h.Id
|
|
|
+ // WHERE
|
|
|
+ // g.SourceId =a.MiddleId AND h.Name LIKE '%{request.Keyword}%'))";
|
|
|
+ // else
|
|
|
+ // sb += $@" AND a.AttributeValue != 2 AND (b.Title LIKE '%{request.Keyword}%'
|
|
|
+ // OR b.Content LIKE '%{request.Keyword}%'
|
|
|
+ // OR c.Name LIKE '%{request.Keyword}%'
|
|
|
+ // OR d.UserName LIKE '%{request.Keyword}%'
|
|
|
+ // OR a.CreatedDate LIKE '%{request.Keyword}%' or a.MiddleId in (SELECT
|
|
|
+ // g.SourceId
|
|
|
+ // FROM
|
|
|
+ // tede_addressee g
|
|
|
+ // INNER JOIN
|
|
|
+ // tede_user h ON g.UserId = h.Id
|
|
|
+ // WHERE
|
|
|
+ // g.SourceId =a.MiddleId AND h.Name LIKE '%{request.Keyword}%'))";
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // var searchList = new List<int> { 1, 2, 3 };
|
|
|
+ // if (!searchList.Contains(request.SearchType))
|
|
|
+ // sb += " AND a.ParentId = " + request.NoticeFolderId;
|
|
|
+ // }
|
|
|
+ // var noticeTypeValue = GxPress.EnumConst.AllTypeConst.Inbox.GetHashCode();
|
|
|
+ // var sql = $@"SELECT a.*,
|
|
|
+ // (SELECT GROUP_CONCAT(SourceName Separator'、') from tede_user_middle where MiddleType=10 and DataSourceId=a.MiddleId) as EnjoyUser,
|
|
|
+ // (SELECT
|
|
|
+ // GROUP_CONCAT(Name
|
|
|
+ // SEPARATOR '、')
|
|
|
+ // FROM
|
|
|
+ // tede_user
|
|
|
+ // WHERE
|
|
|
+ // Id IN (SELECT
|
|
|
+ // UserId
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // FlowId = b.SourceId
|
|
|
+ // AND type = 'ApproverCheck')) AS FlowUserName,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // FlowId = b.SourceId
|
|
|
+ // AND type = 'ApproverCheck') AS UCheckedCount,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // FlowId = b.SourceId
|
|
|
+ // AND type = 'ApproverCheck'
|
|
|
+ // AND IsRead = 1) AS CheckedCount,
|
|
|
+ // (SELECT
|
|
|
+ // IsRead
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // UserId = a.UserId
|
|
|
+ // AND FlowId = b.SourceId
|
|
|
+ // AND Type = 'CarbonCopy'
|
|
|
+ // LIMIT 1) AS IsFlowRead,
|
|
|
+ // (SELECT
|
|
|
+ // IsRead
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // UserId = b.UserId
|
|
|
+ // AND FlowId = b.SourceId
|
|
|
+ // AND Type = 'ApproverCheck' and IsRead=1
|
|
|
+ // LIMIT 1) AS IsFlowChecked,
|
|
|
+ // (SELECT
|
|
|
+ // IsRead
|
|
|
+ // FROM
|
|
|
+ // tede_flow
|
|
|
+ // WHERE
|
|
|
+ // id = b.SourceId AND UserId = b.UserId) AS IsMyFlowRead,
|
|
|
+ // (select IsRecall from tede_notice where id=a.MiddleId) as IsRecall,
|
|
|
+ // (SELECT
|
|
|
+ // IsDone
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // type = 'ApproverCheck'
|
|
|
+ // AND UserId = a.UserId
|
|
|
+ // LIMIT 1) AS IsDone,
|
|
|
+ // (SELECT
|
|
|
+ // IsChecked
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // type = 'ApproverCheck'
|
|
|
+ // AND UserId = a.UserId
|
|
|
+ // LIMIT 1) AS IsChecked,
|
|
|
+ // (SELECT
|
|
|
+ // DoneType
|
|
|
+ // FROM
|
|
|
+ // tede_flow_todo
|
|
|
+ // WHERE
|
|
|
+ // type = 'ApproverCheck'
|
|
|
+ // AND UserId = a.UserId
|
|
|
+ // LIMIT 1) AS DoneType,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 1) AS PraiseCount,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 1
|
|
|
+ // LIMIT 0 , 1) AS IsLaud,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_comment
|
|
|
+ // WHERE
|
|
|
+ // ArticleId = a.MiddleId and pid=0
|
|
|
+ // AND TypeValue = {noticeTypeValue}) AS CommentCount,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 4) AS RetransmissionCount,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 4
|
|
|
+ // LIMIT 0 , 1) AS IsRetransmission,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 4
|
|
|
+ // LIMIT 0 , 1) AS IsCollect,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_analyze
|
|
|
+ // WHERE
|
|
|
+ // UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
+ // AND SourceId = a.MiddleId
|
|
|
+ // AND AnalyzeType = 4) AS CollectCount,
|
|
|
+ // (SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_middle
|
|
|
+ // WHERE
|
|
|
+ // ParentId = a.Id and IsDelete=0 and NoticeAddresseeType<>2) as FileCount,(SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_addressee
|
|
|
+ // WHERE
|
|
|
+ // SourceId = a.MiddleId AND IsRead = 1) as ReadCount,(SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_addressee
|
|
|
+ // WHERE
|
|
|
+ // SourceId = a.MiddleId ) as AllCount,(SELECT
|
|
|
+ // COUNT(1)
|
|
|
+ // FROM
|
|
|
+ // tede_addressee
|
|
|
+ // WHERE
|
|
|
+ // SourceId = a.MiddleId AND IsRead = 1 and UserId={request.UserId} limit 0,1) as IsRead, b.*,a.Id, c.AvatarUrl, d.Id as NoticeAddresseeId,d.SourceId as NoticeId,(SELECT
|
|
|
+ // Name
|
|
|
+ // FROM
|
|
|
+ // tede_user
|
|
|
+ // WHERE
|
|
|
+ // id = (SELECT
|
|
|
+ // userId
|
|
|
+ // FROM
|
|
|
+ // tede_flow
|
|
|
+ // WHERE
|
|
|
+ // id = b.SourceId)) as UserName
|
|
|
+ // ,(select count(1) from tede_flow where id=b.SourceId and UserId={request.UserId}) as IsFlowAdmin,b.UserId,a.IsTop
|
|
|
+ // FROM
|
|
|
+ // tede_middle a
|
|
|
+ // left JOIN
|
|
|
+ // tede_notice b ON a.MiddleId = b.Id
|
|
|
+ // left JOIN
|
|
|
+ // tede_user c ON b.UserId = c.Id
|
|
|
+ // left JOIN
|
|
|
+ // tede_addressee d ON d.Id = a.MiddleSonId
|
|
|
+ // WHERE a.IsRecall=0 and
|
|
|
+ // a.UserId = {request.UserId} and a.FolderType={noticeTypeValue}
|
|
|
+ // {sb}
|
|
|
+ // ORDER BY a.AttributeValue desc,a.IsTop desc,a.LastModifiedDate desc
|
|
|
+ // LIMIT {(request.Page - 1) * request.PerPage},{request.PerPage}";
|
|
|
+ // var countSql = string.Format(@"SELECT
|
|
|
+ // count(1)
|
|
|
+ // FROM
|
|
|
+ // tede_middle a
|
|
|
+ // left JOIN
|
|
|
+ // tede_notice b ON a.MiddleId = b.Id
|
|
|
+ // left JOIN
|
|
|
+ // tede_user c ON a.UserId = c.Id
|
|
|
+ // left JOIN
|
|
|
+ // tede_addressee d ON d.Id = a.MiddleSonId
|
|
|
+ // WHERE a.IsRecall=0 and
|
|
|
+ // a.UserId = {1} and a.FolderType={2}
|
|
|
+ // {0}", sb, request.UserId, noticeTypeValue);
|
|
|
+ // var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
+ // var database = new Database(databaseType, _connectionString);
|
|
|
+ // var connection = database.GetConnection();
|
|
|
+ // var items = await connection.QueryAsync<NoticeListPageResult>(sql);
|
|
|
+ // foreach (var item in items)
|
|
|
+ // {
|
|
|
+ // item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
|
|
|
+ // if (item.AttributeValue == 3)
|
|
|
+ // {
|
|
|
+ // var query = Q.NewQuery();
|
|
|
+ // query.Where(nameof(Entity.AdminVerify.AdminId), request.UserId);
|
|
|
+ // query.Where(nameof(Entity.AdminVerify.DisposeType), AdminVerifyTypeConst.UDispose.GetHashCode());
|
|
|
+ // item.UReadCount = await _adminVerifyRepository.CountAsync(query);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // PagedList<NoticeListPageResult> result = new PagedList<NoticeListPageResult>
|
|
|
+ // {
|
|
|
+ // Total = await CountAsync(countSql),
|
|
|
+ // Items = items
|
|
|
+ // };
|
|
|
+ // return result;
|
|
|
+ return await GetNewNoticeListPageAsync(request);
|
|
|
+ }
|
|
|
+
|
|
|
+ /// <summary>
|
|
|
+ /// 获取通知列表
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="request"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public async Task<PagedList<NoticeListPageResult>> GetNewNoticeListPageAsync(NoticePageSearchRequest request)
|
|
|
+ {
|
|
|
+ var result = new PagedList<NoticeListPageResult>();
|
|
|
+ var noticeTypeValue = GxPress.EnumConst.AllTypeConst.Inbox.GetHashCode();
|
|
|
+ var query = new SqlKata.Query("tede_middle");
|
|
|
+ query.LeftJoin("tede_notice", "tede_notice.Id", "tede_middle.MiddleId");
|
|
|
+ query.LeftJoin("tede_user", "tede_user.Id", "tede_notice.UserId");
|
|
|
+ query.LeftJoin("tede_addressee", "tede_addressee.Id", "tede_middle.MiddleSonId");
|
|
|
if (request.SearchType == 1)
|
|
|
- sb += " AND a.IsAdmin = 1 and a.NoticeAddresseeType=1 AND a.IsDelete = 0";
|
|
|
+ {
|
|
|
+ query.Where("tede_middle.IsAdmin", true);
|
|
|
+ query.Where("tede_middle.NoticeAddresseeType", 1);
|
|
|
+ query.Where("tede_middle.IsDelete", false);
|
|
|
+ }
|
|
|
else if (request.SearchType == 2)
|
|
|
- sb += " and a.NoticeAddresseeType=2 AND a.AttributeValue=1 AND a.IsDelete = 0";
|
|
|
+ {
|
|
|
+ query.Where("tede_middle.AttributeValue", 1);
|
|
|
+ query.Where("tede_middle.NoticeAddresseeType", 2);
|
|
|
+ query.Where("tede_middle.IsDelete", false);
|
|
|
+ }
|
|
|
else if (request.SearchType == 3)
|
|
|
- sb += " AND a.IsDelete = 1 AND a.AttributeValue=1";
|
|
|
+ {
|
|
|
+ query.Where("tede_middle.AttributeValue", 1);
|
|
|
+ query.Where("tede_middle.IsDelete", true);
|
|
|
+ }
|
|
|
else if (request.SearchType > 3)
|
|
|
- sb += $"and a.NoticeAddresseeType<>2 AND b.TypeValue={request.SearchType} AND a.IsDelete = 0";
|
|
|
+ {
|
|
|
+ query.Where("tede_notice.TypeValue", request.SearchType);
|
|
|
+ query.WhereNot("tede_middle.NoticeAddresseeType", 2);
|
|
|
+ query.Where("tede_middle.IsDelete", false);
|
|
|
+ }
|
|
|
else
|
|
|
- sb += " AND a.IsDelete = 0 AND a.NoticeAddresseeType != 2";
|
|
|
+ {
|
|
|
+ query.WhereNot("tede_middle.NoticeAddresseeType", 2);
|
|
|
+ query.Where("tede_middle.IsDelete", false);
|
|
|
+ }
|
|
|
if (!string.IsNullOrEmpty(request.Keyword))
|
|
|
{
|
|
|
if (request.NoticeFolderId > 0)
|
|
|
- sb += $@" AND a.ParentId ={request.NoticeFolderId} AND a.AttributeValue != 2 and (b.Title LIKE '%{request.Keyword}%'
|
|
|
- OR b.Content LIKE '%{request.Keyword}%'
|
|
|
- OR c.Name LIKE '%{request.Keyword}%'
|
|
|
- OR d.UserName LIKE '%{request.Keyword}%'
|
|
|
- OR a.CreatedDate LIKE '%{request.Keyword}%' or a.MiddleId in (SELECT
|
|
|
- g.SourceId
|
|
|
- FROM
|
|
|
- tede_addressee g
|
|
|
- INNER JOIN
|
|
|
- tede_user h ON g.UserId = h.Id
|
|
|
- WHERE
|
|
|
- g.SourceId =a.MiddleId AND h.Name LIKE '%{request.Keyword}%'))";
|
|
|
- else
|
|
|
- sb += $@" AND a.AttributeValue != 2 AND (b.Title LIKE '%{request.Keyword}%'
|
|
|
- OR b.Content LIKE '%{request.Keyword}%'
|
|
|
- OR c.Name LIKE '%{request.Keyword}%'
|
|
|
- OR d.UserName LIKE '%{request.Keyword}%'
|
|
|
- OR a.CreatedDate LIKE '%{request.Keyword}%' or a.MiddleId in (SELECT
|
|
|
- g.SourceId
|
|
|
- FROM
|
|
|
- tede_addressee g
|
|
|
- INNER JOIN
|
|
|
- tede_user h ON g.UserId = h.Id
|
|
|
- WHERE
|
|
|
- g.SourceId =a.MiddleId AND h.Name LIKE '%{request.Keyword}%'))";
|
|
|
+ query.Where("tede_middle.ParentId", request.NoticeFolderId);
|
|
|
+ var sourceIdQuery = new SqlKata.Query("tede_addressee");
|
|
|
+ sourceIdQuery.Join("tede_user", "tede_user.Id", "tede_addressee.UserId");
|
|
|
+ sourceIdQuery.WhereColumns("tede_addressee.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ sourceIdQuery.WhereLike("tede_user.Name", $"%{request.Keyword}%");
|
|
|
+ sourceIdQuery.Select("tede_addressee.SourceId");
|
|
|
+ query.WhereNot("tede_middle.AttributeValue", 2);
|
|
|
+ query.Where(n => n.OrWhereLike("tede_notice.Title", $"%{request.Keyword}%").OrWhereLike("tede_notice.Content", $"%{request.Keyword}%")
|
|
|
+ .OrWhere(n => n.WhereIn("tede_middle.MiddleId", sourceIdQuery)));
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
var searchList = new List<int> { 1, 2, 3 };
|
|
|
if (!searchList.Contains(request.SearchType))
|
|
|
- sb += " AND a.ParentId = " + request.NoticeFolderId;
|
|
|
+ query.Where("tede_middle.ParentId", request.NoticeFolderId);
|
|
|
}
|
|
|
- var noticeTypeValue = GxPress.EnumConst.AllTypeConst.Inbox.GetHashCode();
|
|
|
- var sql = $@"SELECT a.*,
|
|
|
- (SELECT GROUP_CONCAT(SourceName Separator'、') from tede_user_middle where MiddleType=10 and DataSourceId=a.MiddleId) as EnjoyUser,
|
|
|
- (SELECT
|
|
|
- GROUP_CONCAT(Name
|
|
|
- SEPARATOR '、')
|
|
|
- FROM
|
|
|
- tede_user
|
|
|
- WHERE
|
|
|
- Id IN (SELECT
|
|
|
- UserId
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- FlowId = b.SourceId
|
|
|
- AND type = 'ApproverCheck')) AS FlowUserName,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- FlowId = b.SourceId
|
|
|
- AND type = 'ApproverCheck') AS UCheckedCount,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- FlowId = b.SourceId
|
|
|
- AND type = 'ApproverCheck'
|
|
|
- AND IsRead = 1) AS CheckedCount,
|
|
|
- (SELECT
|
|
|
- IsRead
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- UserId = a.UserId
|
|
|
- AND FlowId = b.SourceId
|
|
|
- AND Type = 'CarbonCopy'
|
|
|
- LIMIT 1) AS IsFlowRead,
|
|
|
- (SELECT
|
|
|
- IsRead
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- UserId = b.UserId
|
|
|
- AND FlowId = b.SourceId
|
|
|
- AND Type = 'ApproverCheck' and IsRead=1
|
|
|
- LIMIT 1) AS IsFlowChecked,
|
|
|
- (SELECT
|
|
|
- IsRead
|
|
|
- FROM
|
|
|
- tede_flow
|
|
|
- WHERE
|
|
|
- id = b.SourceId AND UserId = b.UserId) AS IsMyFlowRead,
|
|
|
- (select IsRecall from tede_notice where id=a.MiddleId) as IsRecall,
|
|
|
- (SELECT
|
|
|
- IsDone
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- type = 'ApproverCheck'
|
|
|
- AND UserId = a.UserId
|
|
|
- LIMIT 1) AS IsDone,
|
|
|
- (SELECT
|
|
|
- IsChecked
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- type = 'ApproverCheck'
|
|
|
- AND UserId = a.UserId
|
|
|
- LIMIT 1) AS IsChecked,
|
|
|
- (SELECT
|
|
|
- DoneType
|
|
|
- FROM
|
|
|
- tede_flow_todo
|
|
|
- WHERE
|
|
|
- type = 'ApproverCheck'
|
|
|
- AND UserId = a.UserId
|
|
|
- LIMIT 1) AS DoneType,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 1) AS PraiseCount,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 1
|
|
|
- LIMIT 0 , 1) AS IsLaud,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_comment
|
|
|
- WHERE
|
|
|
- ArticleId = a.MiddleId and pid=0
|
|
|
- AND TypeValue = {noticeTypeValue}) AS CommentCount,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 4) AS RetransmissionCount,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 4
|
|
|
- LIMIT 0 , 1) AS IsRetransmission,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 4
|
|
|
- LIMIT 0 , 1) AS IsCollect,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_analyze
|
|
|
- WHERE
|
|
|
- UserId = {request.UserId} AND TypeValue = {noticeTypeValue}
|
|
|
- AND SourceId = a.MiddleId
|
|
|
- AND AnalyzeType = 4) AS CollectCount,
|
|
|
- (SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_middle
|
|
|
- WHERE
|
|
|
- ParentId = a.Id and IsDelete=0 and NoticeAddresseeType<>2) as FileCount,(SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_addressee
|
|
|
- WHERE
|
|
|
- SourceId = a.MiddleId AND IsRead = 1) as ReadCount,(SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_addressee
|
|
|
- WHERE
|
|
|
- SourceId = a.MiddleId ) as AllCount,(SELECT
|
|
|
- COUNT(1)
|
|
|
- FROM
|
|
|
- tede_addressee
|
|
|
- WHERE
|
|
|
- SourceId = a.MiddleId AND IsRead = 1 and UserId={request.UserId} limit 0,1) as IsRead, b.*,a.Id, c.AvatarUrl, d.Id as NoticeAddresseeId,d.SourceId as NoticeId,(SELECT
|
|
|
- Name
|
|
|
- FROM
|
|
|
- tede_user
|
|
|
- WHERE
|
|
|
- id = (SELECT
|
|
|
- userId
|
|
|
- FROM
|
|
|
- tede_flow
|
|
|
- WHERE
|
|
|
- id = b.SourceId)) as UserName
|
|
|
- ,(select count(1) from tede_flow where id=b.SourceId and UserId={request.UserId}) as IsFlowAdmin,b.UserId,a.IsTop
|
|
|
- FROM
|
|
|
- tede_middle a
|
|
|
- left JOIN
|
|
|
- tede_notice b ON a.MiddleId = b.Id
|
|
|
- left JOIN
|
|
|
- tede_user c ON b.UserId = c.Id
|
|
|
- left JOIN
|
|
|
- tede_addressee d ON d.Id = a.MiddleSonId
|
|
|
- WHERE a.IsRecall=0 and
|
|
|
- a.UserId = {request.UserId} and a.FolderType={noticeTypeValue}
|
|
|
- {sb}
|
|
|
- ORDER BY a.AttributeValue desc,a.IsTop desc,a.LastModifiedDate desc
|
|
|
- LIMIT {(request.Page - 1) * request.PerPage},{request.PerPage}";
|
|
|
- var countSql = string.Format(@"SELECT
|
|
|
- count(1)
|
|
|
- FROM
|
|
|
- tede_middle a
|
|
|
- left JOIN
|
|
|
- tede_notice b ON a.MiddleId = b.Id
|
|
|
- left JOIN
|
|
|
- tede_user c ON a.UserId = c.Id
|
|
|
- left JOIN
|
|
|
- tede_addressee d ON d.Id = a.MiddleSonId
|
|
|
- WHERE a.IsRecall=0 and
|
|
|
- a.UserId = {1} and a.FolderType={2}
|
|
|
- {0}", sb, request.UserId, noticeTypeValue);
|
|
|
- var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
- var database = new Database(databaseType, _connectionString);
|
|
|
- var connection = database.GetConnection();
|
|
|
- var items = await connection.QueryAsync<NoticeListPageResult>(sql);
|
|
|
- foreach (var item in items)
|
|
|
- {
|
|
|
+ query.Where("tede_middle.IsRecall", false);
|
|
|
+ query.Where("tede_middle.UserId", request.UserId);
|
|
|
+ query.Where("tede_middle.FolderType", noticeTypeValue);
|
|
|
+ //条数
|
|
|
+ result.Total = await _middleRepository.CountAsync(query);
|
|
|
+ var enjoyUser = new SqlKata.Query("tede_user_middle");
|
|
|
+ enjoyUser.Where("MiddleType", 10);
|
|
|
+ enjoyUser.WhereColumns("DataSourceId", "=", "tede_middle.MiddleId");
|
|
|
+ enjoyUser.SelectRaw("GROUP_CONCAT(SourceName Separator'、')");
|
|
|
+ query.Select(enjoyUser, "EnjoyUser");
|
|
|
+ var flowUserName = new SqlKata.Query("tede_user");
|
|
|
+ flowUserName.SelectRaw("GROUP_CONCAT(Name Separator'、')");
|
|
|
+ var flowTodo = new SqlKata.Query("tede_flow_todo");
|
|
|
+ flowTodo.WhereColumns("tede_flow_todo.FlowId", "=", "tede_notice.SourceId");
|
|
|
+ flowTodo.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ flowTodo.Select("tede_flow_todo.UserId");
|
|
|
+ flowUserName.WhereIn("tede_user.Id", flowTodo);
|
|
|
+ query.Select(flowUserName, "FlowUserName");
|
|
|
+ var uCheckedCount = new SqlKata.Query("tede_flow_todo");
|
|
|
+ uCheckedCount.WhereColumns("tede_flow_todo.FlowId", "=", "tede_notice.SourceId");
|
|
|
+ uCheckedCount.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ uCheckedCount.AsCount();
|
|
|
+ query.Select(uCheckedCount, "UCheckedCount");
|
|
|
+ var checkedCount = new SqlKata.Query("tede_flow_todo");
|
|
|
+ checkedCount.WhereColumns("tede_flow_todo.FlowId", "=", "tede_notice.SourceId");
|
|
|
+ checkedCount.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ checkedCount.Where("tede_flow_todo.IsRead", true);
|
|
|
+ checkedCount.AsCount();
|
|
|
+ query.Select(checkedCount, "CheckedCount");
|
|
|
+ var isFlowRead = new SqlKata.Query("tede_flow_todo");
|
|
|
+ isFlowRead.WhereColumns("tede_flow_todo.FlowId", "=", "tede_notice.SourceId");
|
|
|
+ isFlowRead.WhereColumns("tede_flow_todo.UserId", "=", "tede_middle.UserId");
|
|
|
+ isFlowRead.Where("tede_flow_todo.type", "CarbonCopy");
|
|
|
+ isFlowRead.Limit(1);
|
|
|
+ isFlowRead.Select("IsRead");
|
|
|
+ query.Select(isFlowRead, "IsFlowRead");
|
|
|
+ var isFlowChecked = new SqlKata.Query("tede_flow_todo");
|
|
|
+ isFlowChecked.WhereColumns("tede_flow_todo.FlowId", "=", "tede_notice.SourceId");
|
|
|
+ isFlowChecked.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ isFlowChecked.Where("tede_flow_todo.IsRead", true);
|
|
|
+ isFlowChecked.Limit(1);
|
|
|
+ isFlowChecked.Select("IsRead");
|
|
|
+ query.Select(isFlowChecked, "IsFlowChecked");
|
|
|
+ var IsMyFlowRead = new SqlKata.Query("tede_flow");
|
|
|
+ IsMyFlowRead.WhereColumns("tede_flow.Id", "=", "tede_notice.SourceId");
|
|
|
+ IsMyFlowRead.WhereColumns("tede_flow.UserId", "=", "tede_notice.UserId");
|
|
|
+ IsMyFlowRead.Select("IsRead");
|
|
|
+ query.Select(IsMyFlowRead, "IsMyFlowRead");
|
|
|
+ var IsDone = new SqlKata.Query("tede_flow_todo");
|
|
|
+ IsDone.WhereColumns("tede_flow_todo.UserId", "=", "tede_middle.UserId");
|
|
|
+ IsDone.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ IsDone.Limit(1);
|
|
|
+ IsDone.Select("IsDone");
|
|
|
+ query.Select(IsDone, "IsDone");
|
|
|
+ var IsChecked = new SqlKata.Query("tede_flow_todo");
|
|
|
+ IsChecked.WhereColumns("tede_flow_todo.UserId", "=", "tede_middle.UserId");
|
|
|
+ IsChecked.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ IsChecked.Limit(1);
|
|
|
+ IsChecked.Select("IsChecked");
|
|
|
+ query.Select(IsChecked, "IsChecked");
|
|
|
+ var DoneType = new SqlKata.Query("tede_flow_todo");
|
|
|
+ DoneType.WhereColumns("tede_flow_todo.UserId", "=", "tede_middle.UserId");
|
|
|
+ DoneType.Where("tede_flow_todo.type", "ApproverCheck");
|
|
|
+ DoneType.Limit(1);
|
|
|
+ DoneType.Select("DoneType");
|
|
|
+ query.Select(DoneType, "DoneType");
|
|
|
+ var PraiseCount = new SqlKata.Query("tede_analyze");
|
|
|
+ PraiseCount.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ PraiseCount.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ PraiseCount.Where("tede_analyze.AnalyzeType", 1);
|
|
|
+ PraiseCount.AsCount();
|
|
|
+ query.Select(PraiseCount, "PraiseCount");
|
|
|
+ var IsLaud = new SqlKata.Query("tede_analyze");
|
|
|
+ IsLaud.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ IsLaud.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ IsLaud.Where("tede_analyze.UserId", request.UserId);
|
|
|
+ IsLaud.Where("tede_analyze.AnalyzeType", 1);
|
|
|
+ IsLaud.Limit(1);
|
|
|
+ IsLaud.AsCount();
|
|
|
+ query.Select(IsLaud, "IsLaud");
|
|
|
+ var CommentCount = new SqlKata.Query("tede_comment");
|
|
|
+ CommentCount.WhereColumns("tede_comment.ArticleId", "=", "tede_middle.MiddleId");
|
|
|
+ CommentCount.Where("tede_comment.pid", 0);
|
|
|
+ CommentCount.Where("tede_comment.TypeValue", noticeTypeValue);
|
|
|
+ CommentCount.AsCount();
|
|
|
+ query.Select(CommentCount, "CommentCount");
|
|
|
+ var RetransmissionCount = new SqlKata.Query("tede_analyze");
|
|
|
+ RetransmissionCount.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ RetransmissionCount.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ RetransmissionCount.Where("tede_analyze.UserId", request.UserId);
|
|
|
+ RetransmissionCount.Where("tede_analyze.AnalyzeType", 4);
|
|
|
+ RetransmissionCount.AsCount();
|
|
|
+ query.Select(RetransmissionCount, "RetransmissionCount");
|
|
|
+ var IsRetransmission = new SqlKata.Query("tede_analyze");
|
|
|
+ IsRetransmission.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ IsRetransmission.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ IsRetransmission.Where("tede_analyze.UserId", request.UserId);
|
|
|
+ IsRetransmission.Where("tede_analyze.AnalyzeType", 4);
|
|
|
+ IsRetransmission.Limit(1);
|
|
|
+ IsRetransmission.AsCount();
|
|
|
+ query.Select(IsRetransmission, "IsRetransmission");
|
|
|
+ var IsCollect = new SqlKata.Query("tede_analyze");
|
|
|
+ IsCollect.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ IsCollect.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ IsCollect.Where("tede_analyze.UserId", request.UserId);
|
|
|
+ IsCollect.Where("tede_analyze.AnalyzeType", 3);
|
|
|
+ IsCollect.Limit(1);
|
|
|
+ IsCollect.AsCount();
|
|
|
+ query.Select(IsCollect, "IsCollect");
|
|
|
+ var CollectCount = new SqlKata.Query("tede_analyze");
|
|
|
+ CollectCount.WhereColumns("tede_analyze.SourceId", "=", "tede_middle.MiddleId");
|
|
|
+ CollectCount.Where("tede_analyze.TypeValue", noticeTypeValue);
|
|
|
+ CollectCount.Where("tede_analyze.UserId", request.UserId);
|
|
|
+ CollectCount.Where("tede_analyze.AnalyzeType", 3);
|
|
|
+ CollectCount.AsCount();
|
|
|
+ query.Select(CollectCount, "CollectCount");
|
|
|
+ var FileCount = new SqlKata.Query("tede_middle");
|
|
|
+ FileCount.WhereColumns("tede_middle.ParentId", "=", "tede_middle.Id");
|
|
|
+ FileCount.Where("tede_middle.IsDelete", false);
|
|
|
+ FileCount.WhereNot("tede_middle.NoticeAddresseeType", 2); ;
|
|
|
+ FileCount.AsCount();
|
|
|
+ query.Select(FileCount, "FileCount");
|
|
|
+ var ReadCount = new SqlKata.Query("tede_addressee");
|
|
|
+ ReadCount.WhereColumns("tede_addressee.SourceId", "=", "tede_middle.Id");
|
|
|
+ ReadCount.Where("tede_addressee.IsRead", true);
|
|
|
+ ReadCount.AsCount();
|
|
|
+ query.Select(ReadCount, "ReadCount");
|
|
|
+ var AllCount = new SqlKata.Query("tede_addressee");
|
|
|
+ AllCount.WhereColumns("tede_addressee.SourceId", "=", "tede_middle.Id");
|
|
|
+ AllCount.AsCount();
|
|
|
+ query.Select(AllCount, "AllCount");
|
|
|
+ var IsRead = new SqlKata.Query("tede_addressee");
|
|
|
+ IsRead.WhereColumns("tede_addressee.SourceId", "=", "tede_middle.Id");
|
|
|
+ IsRead.Where("tede_addressee.IsRead", true);
|
|
|
+ IsRead.Where("tede_addressee.UserId", request.UserId);
|
|
|
+ IsRead.Limit(1);
|
|
|
+ IsRead.AsCount();
|
|
|
+ query.Select(IsRead, "IsRead");
|
|
|
+ var userName = new SqlKata.Query("tede_user");
|
|
|
+ var tedeFlow = new SqlKata.Query("tede_flow");
|
|
|
+ tedeFlow.WhereColumns("tede_flow.Id", "=", "tede_notice.SourceId");
|
|
|
+ tedeFlow.Select("tede_flow.UserId");
|
|
|
+ userName.WhereIn("tede_user.Id", tedeFlow);
|
|
|
+ userName.Limit(1);
|
|
|
+ userName.Select("Name");
|
|
|
+ query.Select(userName, "Name");
|
|
|
+ var IsFlowAdmin = new SqlKata.Query("tede_flow");
|
|
|
+ IsFlowAdmin.WhereColumns("tede_flow.Id", "=", "tede_notice.SourceId");
|
|
|
+ IsFlowAdmin.Where("tede_flow.UserId", request.UserId);
|
|
|
+ IsFlowAdmin.AsCount();
|
|
|
+ query.Select(IsFlowAdmin, "IsFlowAdmin");
|
|
|
+ query.OrderByDesc("tede_middle.AttributeValue");
|
|
|
+ query.OrderByDesc("tede_middle.IsTop");
|
|
|
+ query.OrderByDesc("tede_middle.LastModifiedDate");
|
|
|
+ query.OrderByDesc("tede_middle.Sort");
|
|
|
+ query.ForPage(request.Page, request.PerPage);
|
|
|
+ query.Select(
|
|
|
+ "tede_middle.Id", "tede_middle.MiddleId", "tede_middle.IsTop"
|
|
|
+ , "tede_notice.{UserId,UserName,CreatedDate,Title,Content,TypeValue}"
|
|
|
+ , "tede_user.{AvatarUrl}"
|
|
|
+ , "tede_addressee.{Id as NoticeAddresseeId, SourceId as NoticeId}");
|
|
|
+ result.Items = await _middleRepository.GetAllAsync<NoticeListPageResult>(query);
|
|
|
+ foreach (var item in result.Items)
|
|
|
item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
|
|
|
- if (item.AttributeValue == 3)
|
|
|
- {
|
|
|
- var query = Q.NewQuery();
|
|
|
- query.Where(nameof(Entity.AdminVerify.AdminId), request.UserId);
|
|
|
- query.Where(nameof(Entity.AdminVerify.DisposeType), AdminVerifyTypeConst.UDispose.GetHashCode());
|
|
|
- item.UReadCount = await _adminVerifyRepository.CountAsync(query);
|
|
|
- }
|
|
|
- }
|
|
|
- PagedList<NoticeListPageResult> result = new PagedList<NoticeListPageResult>
|
|
|
- {
|
|
|
- Total = await CountAsync(countSql),
|
|
|
- Items = items
|
|
|
- };
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
public async Task<int> CountAsync(string sql)
|
|
|
{
|
|
|
var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|