lihao 4 years ago
parent
commit
a45181aeee

+ 26 - 3
gx_api/GxPress/Repository/GxPress.Repository.Implement/AddresseeRepository.cs

@@ -157,10 +157,33 @@ namespace GxPress.Repository.Implement
         {
             return await _repository.ExistsAsync(query);
         }
-
-        public Task<IEnumerable<MissiveReadListResult>> GetMissiveReadListAsync(MissiveReadListRequest request)
+        /// <summary>
+        /// 站内信未读
+        /// </summary>
+        /// <param name="request"></param>
+        /// <returns></returns>
+        public async Task<IEnumerable<MissiveReadListResult>> GetMissiveReadListAsync(MissiveReadListRequest request)
         {
-            throw new NotImplementedException();
+            var query = new SqlKata.Query("tede_addressee");
+            query.Join("tede_user as b", "b.Id", "tede_addressee.UserId");
+            query.Where("tede_addressee.SourceId", request.MissiveId);
+            if (request.ReadType > 0)
+                query.Where("tede_addressee.IsRead", request.ReadType == 1);
+            //
+            var departmentNameQuery = new SqlKata.Query("tede_department");
+            var departmentIdsQuery = new SqlKata.Query("tede_department_user");
+            departmentIdsQuery.WhereColumns("tede_department_user.userId", "=", "tede_addressee.UserId");
+            departmentIdsQuery.Select("DepartmentId");
+            departmentNameQuery.WhereIn(nameof(Entity.Department.Id), departmentIdsQuery);
+            departmentNameQuery.Limit(1);
+            departmentNameQuery.Select("Name");
+            query.Select(departmentNameQuery, "DepartmentName");
+            query.Select("tede_addressee.{SourceId as MissiveId,LastModifiedDate,UserId}");
+            query.Select("b.{AvatarUrl,Name}");
+            var result = await _repository.GetAllAsync<MissiveReadListResult>(query);
+            foreach (var item in result)
+                item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
+            return result;
         }
     }
 }

+ 1 - 1
gx_api/GxPress/Service/GxPress.Service.Implement/Notice/NoticeService.Insert.cs

@@ -115,7 +115,7 @@ namespace GxPress.Service.Implement.Notice
                         NoticeAddresseeType = request.NoticeType,
                         IsTop = false,
                         IsRead = true,
-                        SourceType = AllTypeConst.Notice.GetHashCode()
+                        SourceType =  request.TypeValue
                     };
                     var noticeAddresseeId = await _addresseeRepository.InsertAsync(addresseeEntity);
                     request.NoticeAddresseeUserIds = request.NoticeAddresseeUserIds.Distinct().ToList();