fix:拉取缓存不存在应该返回null

This commit is contained in:
李鹏军 2024-03-28 11:25:00 +08:00
parent e9af631ee4
commit 2c6d730c4b

View File

@ -51,19 +51,19 @@ public class TrackPullCacheService : ApplicationService, ITrackPullCacheService
public async Task<TrackPullParamWithContentConfigDto?> SetPullConfigAsync(int? id = null, int? subSystemId = null, public async Task<TrackPullParamWithContentConfigDto?> SetPullConfigAsync(int? id = null, int? subSystemId = null,
int? serviceProviderId = null) int? serviceProviderId = null)
{ {
var data = new TrackPullParamWithContentConfigDto();
Expression<Func<TrackPullConfigEntity, bool>> exp = x => true; Expression<Func<TrackPullConfigEntity, bool>> exp = x => true;
if (id.HasValue) exp = x => x.Id == id; if (id.HasValue) exp = x => x.Id == id;
else if (subSystemId.HasValue && serviceProviderId.HasValue) else if (subSystemId.HasValue && serviceProviderId.HasValue)
exp = x => x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId; exp = x => x.SubSystemId == subSystemId && x.ServiceProviderId == serviceProviderId;
var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp); var trackPullConfigEntity = await _trackPullConfigRepository.GetFirstAsync(exp);
if (trackPullConfigEntity == null) return data; if (trackPullConfigEntity == null) return null;
var trackPullConfigDetail = await _trackPullConfigRepository.GetDetailAsync(trackPullConfigEntity.Id); var trackPullConfigDetail = await _trackPullConfigRepository.GetDetailAsync(trackPullConfigEntity.Id);
var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id); var trackPullContentList = await _trackPullConfigRepository.GetContentListCacheAsync(trackPullConfigEntity.Id);
if (trackPullContentList.Count == 0) return data; if (trackPullContentList.Count == 0) return null;
var data = new TrackPullParamWithContentConfigDto();
data.ParamConfig = data.ParamConfig =
ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail); ObjectMapper.Map<GetTrackPullConfigDetailOutputVO, TrackPullParamConfigDto>(trackPullConfigDetail);