|
@@ -96,31 +96,28 @@ namespace GxPress.Repository.Implement
|
|
|
/// <returns></returns>
|
|
|
public async Task<IEnumerable<NoticeReadListResult>> GetNoticeAddresseeByUserIdIdAsync(NoticeReadListRequest request)
|
|
|
{
|
|
|
- var sqlValue = "";
|
|
|
- if (request.ReadType == 1)
|
|
|
- sqlValue += " and a.IsRead=1";
|
|
|
- else if (request.ReadType == 2)
|
|
|
- sqlValue += " and a.IsRead=0";
|
|
|
- if (request.SourceType > 0)
|
|
|
- sqlValue += $" and a.SourceType={request.SourceType}";
|
|
|
- if (!string.IsNullOrWhiteSpace(request.Key))
|
|
|
- sqlValue += $" and b.Name like '%{request.Key}%'";
|
|
|
- var sql = $"SELECT a.*,b.Name,b.AvatarUrl,c.Name FROM tede_addressee a inner join tede_user b on a.UserId=b.Id inner join tede_department c on c.Id=b.DepartmentId where a.SourceId={request.NoticeId} {sqlValue} order by a.LastModifiedDate desc";
|
|
|
- var databaseType = StringUtils.ToEnum<DatabaseType>(_databaseTypeStr, DatabaseType.MySql);
|
|
|
- var database = new Database(databaseType, _connectionString);
|
|
|
- var connection = database.GetConnection();
|
|
|
- var items = await connection
|
|
|
- .QueryAsync<NoticeReadListResult, User, Department, NoticeReadListResult>(sql,
|
|
|
- (noticeReadListResult, user, department) =>
|
|
|
- {
|
|
|
- noticeReadListResult.Name = user != null ? user.Name : "";
|
|
|
- noticeReadListResult.AvatarUrl = user != null ? StringUtils.AddDomainMin(user.AvatarUrl) : "";
|
|
|
- noticeReadListResult.DepartmentName = department.Name;
|
|
|
- noticeReadListResult.LastModifiedDate = Convert.ToDateTime(noticeReadListResult.LastModifiedDate).ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
- return noticeReadListResult;
|
|
|
- },
|
|
|
- splitOn: "Name,Name");
|
|
|
- return items;
|
|
|
+ var query = new SqlKata.Query("tede_addressee");
|
|
|
+ query.Join("tede_user as b", "b.Id", "tede_addressee.UserId");
|
|
|
+ query.Where("tede_addressee.SourceId", request.NoticeId);
|
|
|
+ if (!string.IsNullOrEmpty(request.Key))
|
|
|
+ query.WhereLike("b.Name", $"%{request.Key}%");
|
|
|
+ if (request.ReadType > 0)
|
|
|
+ query.Where("tede_addressee.IsRead", request.ReadType == 1);
|
|
|
+ query.OrderByDesc("tede_addressee.LastModifiedDate");
|
|
|
+ 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 NoticeId,LastModifiedDate,UserId}");
|
|
|
+ query.Select("b.{AvatarUrl,Name}");
|
|
|
+ var result = await _repository.GetAllAsync<NoticeReadListResult>(query);
|
|
|
+ foreach (var item in result)
|
|
|
+ item.AvatarUrl = StringUtils.AddDomainMin(item.AvatarUrl);
|
|
|
+ return result;
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 获取收件人
|
|
@@ -167,9 +164,11 @@ namespace GxPress.Repository.Implement
|
|
|
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 (!string.IsNullOrEmpty(request.Key))
|
|
|
+ query.WhereLike("b.Name", $"%{request.Key}%");
|
|
|
if (request.ReadType > 0)
|
|
|
query.Where("tede_addressee.IsRead", request.ReadType == 1);
|
|
|
- //
|
|
|
+ query.OrderByDesc("tede_addressee.LastModifiedDate");
|
|
|
var departmentNameQuery = new SqlKata.Query("tede_department");
|
|
|
var departmentIdsQuery = new SqlKata.Query("tede_department_user");
|
|
|
departmentIdsQuery.WhereColumns("tede_department_user.userId", "=", "tede_addressee.UserId");
|