李昊 4 年之前
父節點
當前提交
52e0e41d9c
共有 1 個文件被更改,包括 2 次插入2 次删除
  1. 2 2
      GxPress/Repository/GxPress.Repository.Implement/Visit/VisitRepository.cs

+ 2 - 2
GxPress/Repository/GxPress.Repository.Implement/Visit/VisitRepository.cs

@@ -41,7 +41,7 @@ namespace GxPress.Repository.Implement.Visit
         public async Task<PagedList<VisitResult>> GetVisitResultAsync(VisitPageSearchRequest request)
         {
             var resultData = new PagedList<VisitResult>();
-            string sql = $"SELECT a.*,b.Name,b.AvatarUrl,c.Name FROM ccpph.tede_visit a inner join ccpph.tede_user b on a.UserId=b.Id inner join ccpph.tede_department c on c.Id=b.DepartmentId where a.TypeId={request.TypeId} and a.SourceId={request.SouceId} order by a. CreatedDate desc limit {(request.Page - 1) * request.PerPage},{request.PerPage}";
+            string sql = $"SELECT a.*,b.Name,b.AvatarUrl,c.Name FROM ccpph.tede_visit a inner join ccpph.tede_user b on a.UserId=b.Id left join ccpph.tede_department c on c.Id=b.DepartmentId where a.TypeId={request.TypeId} and a.SourceId={request.SouceId} order by a. CreatedDate desc limit {(request.Page - 1) * request.PerPage},{request.PerPage}";
             var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypestr, DatabaseType.MySql);
             var database = new Database(databaseType, _connectionString);
             var connection = database.GetConnection();
@@ -50,7 +50,7 @@ namespace GxPress.Repository.Implement.Visit
                     .QueryAsync<VisitResult, User, Department, VisitResult>(sql,
                         (visitResult, user, department) =>
                         {
-                            visitResult.DepartmentName = department.Name;
+                            visitResult.DepartmentName =department!=null?department.Name:"";
                             visitResult.Name = user.Name;
                             visitResult.AvatarUrl = StringUtils.AddDomainMin(user.AvatarUrl);
                             return visitResult;