李昊 4 년 전
부모
커밋
1a1102ea8c

+ 13 - 10
gx_api/GxPress/Repository/GxPress.Repository.Implement/Missive/MissiveRepository.cs

@@ -8,6 +8,7 @@ using GxPress.Common.AppOptions;
 using GxPress.Common.Page;
 using GxPress.Common.Tools;
 using GxPress.Entity;
+using GxPress.EnumConst;
 using GxPress.Repository.Interface.Missive;
 using GxPress.Request.App.Missive;
 using GxPress.Result.App.Missive;
@@ -92,9 +93,9 @@ namespace GxPress.Repository.Implement.Missive
                                                     Id IN (SELECT 
                                                             UserId
                                                         FROM
-                                                            tede_missive_addressee
-                                                        WHERE
-                                                            MissiveId = a.MiddleId)
+                                                            tede_addressee
+                                                        WHERE  SourceType={AllTypeConst.Missive.GetHashCode()} and 
+                                                            SourceId = a.MiddleId)
                                                         AND Name LIKE '%{request.Key}%')
                                                 OR a.CreatedDate LIKE '%{request.Key}%')";
             if (request.FolderId > 0)
@@ -122,21 +123,23 @@ namespace GxPress.Repository.Implement.Missive
                         (SELECT 
                                 COUNT(1)
                             FROM
-                                tede_missive_addressee
+                                tede_addressee
                             WHERE
-                                MissiveId = a.MiddleId AND IsRead = 1) AS ReadCount,
+                                 SourceType={AllTypeConst.Missive.GetHashCode()} and 
+                                                            SourceId = a.MiddleId AND IsRead = 1) AS ReadCount,
                         (SELECT 
                                 COUNT(1)
                             FROM
-                                tede_missive_addressee
-                            WHERE
-                                MissiveId = a.MiddleId) AS AllCount,
+                                tede_addressee
+                            WHERE  SourceType={AllTypeConst.Missive.GetHashCode()} and 
+                                                            SourceId = a.MiddleId ) AS AllCount,
                         (SELECT 
                                 COUNT(1)
                             FROM
-                                tede_missive_addressee
+                                tede_addressee
                             WHERE
-                                MissiveId = a.MiddleId AND IsRead = 1
+                                 SourceType={AllTypeConst.Missive.GetHashCode()} and 
+                                                            SourceId = a.MiddleId  AND IsRead = 1
                                     AND UserId =  {request.UserId}
                             LIMIT 0 , 1) AS IsRead, b.Title, b.UserName, b.MissiveType,b.SendUserId,b.Content,b.SourceId
                                             FROM

+ 2 - 2
gx_api/GxPress/Repository/GxPress.Repository.Implement/UserRepository.cs

@@ -833,12 +833,12 @@ namespace GxPress.Repository.Implement
         public async Task<UserCountResult> GetUserCountAsync(int userId)
         {
             var result = new UserCountResult();
-            string sql = $"select count(1) from tede_middle where FolderType=1 and UserId={userId} and MiddleId in (select NoticeId from tede_notice_addressee where UserId={userId} and IsRead=0 and IsDelete=0)";
+            string sql = $"select count(1) from tede_middle where FolderType={AllTypeConst.Notice.GetHashCode()} and UserId={userId} and MiddleId in (select SourceId from tede_addressee where UserId={userId} and IsRead=0 and IsDelete=0 and SourceType={AllTypeConst.Notice.GetHashCode()})";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
             var noticeCount = await connection.ExecuteScalarAsync<int>(sql);
-            sql = $"select count(1) from tede_middle where FolderType=5 and UserId={userId} and MiddleId in (select MissiveId from tede_missive_addressee where UserId={userId} and IsDelete=0 and IsRead=0)";
+            sql = $"select count(1) from tede_middle where FolderType={AllTypeConst.Missive.GetHashCode()} and UserId={userId} and MiddleId in (select SourceId from tede_addressee where UserId={userId} and SourceType={AllTypeConst.Missive.GetHashCode()} and IsDelete=0 and IsRead=0)";
             var missiveCount = await connection.ExecuteScalarAsync<int>(sql);
             sql = $"SELECT count(1) FROM tede_admin_verify where AdminId={userId} and DisposeType=0";
             noticeCount += await connection.ExecuteScalarAsync<int>(sql);