Skip to content

Commit 7cd53ef

Browse files
authored
Merge pull request #682 from bcgov/yj
feat(dss-364)
2 parents edd9538 + d114ba5 commit 7cd53ef

File tree

8 files changed

+229
-32
lines changed

8 files changed

+229
-32
lines changed

database/ddl/STR_DSS_Views_Sprint_15.sql

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,23 @@ drop view if exists dss_platform_vw;
44

55
CREATE OR REPLACE VIEW dss_platform_vw AS
66
SELECT do2.organization_id
7+
, do2.organization_type
78
, do2.organization_cd
89
, do2.organization_nm
910
, do2.managing_organization_id
1011
, do2.upd_dtm
1112
, do2.upd_user_guid
12-
, docp.organization_contact_person_id as notice_of_takedown_contact_id
13-
, docp.email_address_dsc as notice_of_takedown_contact_email
14-
, docp2.organization_contact_person_id as takedown_request_contact_id
15-
, docp2.email_address_dsc as takedown_request_contact_email
13+
, docp.organization_contact_person_id as notice_of_takedown_contact_id_1
14+
, docp.email_address_dsc as notice_of_takedown_contact_email_1
15+
, docp2.organization_contact_person_id as takedown_request_contact_id_1
16+
, docp2.email_address_dsc as takedown_request_contact_email_1
17+
, docp3.organization_contact_person_id as notice_of_takedown_contact_id_2
18+
, docp3.email_address_dsc as notice_of_takedown_contact_email_2
19+
, docp4.organization_contact_person_id as takedown_request_contact_id_2
20+
, docp4.email_address_dsc as takedown_request_contact_email_2
1621
FROM dss_organization do2
17-
left join dss_organization_contact_person docp on docp.contacted_through_organization_id = do2.organization_id and docp.email_message_type = 'Notice of Takedown'
18-
left join dss_organization_contact_person docp2 on docp2.contacted_through_organization_id = do2.organization_id and docp2.email_message_type = 'Takedown Request'
19-
where do2.organization_type = 'Platform';
22+
left join dss_organization_contact_person docp on docp.contacted_through_organization_id = do2.organization_id and docp.email_message_type = 'Notice of Takedown' and docp.is_primary = true
23+
left join dss_organization_contact_person docp2 on docp2.contacted_through_organization_id = do2.organization_id and docp2.email_message_type = 'Takedown Request' and docp2.is_primary = true
24+
left join dss_organization_contact_person docp3 on docp3.contacted_through_organization_id = do2.organization_id and docp3.email_message_type = 'Notice of Takedown' and docp.is_primary != true
25+
left join dss_organization_contact_person docp4 on docp4.contacted_through_organization_id = do2.organization_id and docp4.email_message_type = 'Takedown Request' and docp4.is_primary != true
26+
where do2.organization_type = 'Platform';

postman/str-dss.postman_collection.json

Lines changed: 151 additions & 11 deletions
Large diffs are not rendered by default.

server/StrDss.Api/Controllers/OrganizationsController.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,5 +87,12 @@ public async Task<ActionResult> GetPlatforms(int pageSize = 10, int pageNumber =
8787
return Ok(platforms);
8888
}
8989

90+
[ApiAuthorize()]
91+
[HttpGet("platforms/{id}")]
92+
public async Task<ActionResult> GetPlatform(long id)
93+
{
94+
var platform = await _orgService.GetPlatform(id);
95+
return Ok(platform);
96+
}
9097
}
9198
}

server/StrDss.Data/Entities/DssDbContext.cs

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -667,21 +667,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
667667
.ToView("dss_platform_vw");
668668

669669
entity.Property(e => e.ManagingOrganizationId).HasColumnName("managing_organization_id");
670-
entity.Property(e => e.NoticeOfTakedownContactEmail)
670+
entity.Property(e => e.NoticeOfTakedownContactEmail1)
671671
.HasMaxLength(320)
672-
.HasColumnName("notice_of_takedown_contact_email");
673-
entity.Property(e => e.NoticeOfTakedownContactId).HasColumnName("notice_of_takedown_contact_id");
672+
.HasColumnName("notice_of_takedown_contact_email_1");
673+
entity.Property(e => e.NoticeOfTakedownContactEmail2)
674+
.HasMaxLength(320)
675+
.HasColumnName("notice_of_takedown_contact_email_2");
676+
entity.Property(e => e.NoticeOfTakedownContactId1).HasColumnName("notice_of_takedown_contact_id_1");
677+
entity.Property(e => e.NoticeOfTakedownContactId2).HasColumnName("notice_of_takedown_contact_id_2");
674678
entity.Property(e => e.OrganizationCd)
675679
.HasMaxLength(25)
676680
.HasColumnName("organization_cd");
677681
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
678682
entity.Property(e => e.OrganizationNm)
679683
.HasMaxLength(250)
680684
.HasColumnName("organization_nm");
681-
entity.Property(e => e.TakedownRequestContactEmail)
685+
entity.Property(e => e.OrganizationType)
686+
.HasMaxLength(25)
687+
.HasColumnName("organization_type");
688+
entity.Property(e => e.TakedownRequestContactEmail1)
689+
.HasMaxLength(320)
690+
.HasColumnName("takedown_request_contact_email_1");
691+
entity.Property(e => e.TakedownRequestContactEmail2)
682692
.HasMaxLength(320)
683-
.HasColumnName("takedown_request_contact_email");
684-
entity.Property(e => e.TakedownRequestContactId).HasColumnName("takedown_request_contact_id");
693+
.HasColumnName("takedown_request_contact_email_2");
694+
entity.Property(e => e.TakedownRequestContactId1).HasColumnName("takedown_request_contact_id_1");
695+
entity.Property(e => e.TakedownRequestContactId2).HasColumnName("takedown_request_contact_id_2");
685696
entity.Property(e => e.UpdDtm).HasColumnName("upd_dtm");
686697
entity.Property(e => e.UpdUserGuid).HasColumnName("upd_user_guid");
687698
});

server/StrDss.Data/Entities/DssPlatformVw.cs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ public partial class DssPlatformVw
77
{
88
public long? OrganizationId { get; set; }
99

10+
public string? OrganizationType { get; set; }
11+
1012
public string? OrganizationCd { get; set; }
1113

1214
public string? OrganizationNm { get; set; }
@@ -17,11 +19,19 @@ public partial class DssPlatformVw
1719

1820
public Guid? UpdUserGuid { get; set; }
1921

20-
public long? NoticeOfTakedownContactId { get; set; }
22+
public long? NoticeOfTakedownContactId1 { get; set; }
23+
24+
public string? NoticeOfTakedownContactEmail1 { get; set; }
25+
26+
public long? TakedownRequestContactId1 { get; set; }
27+
28+
public string? TakedownRequestContactEmail1 { get; set; }
29+
30+
public long? NoticeOfTakedownContactId2 { get; set; }
2131

22-
public string? NoticeOfTakedownContactEmail { get; set; }
32+
public string? NoticeOfTakedownContactEmail2 { get; set; }
2333

24-
public long? TakedownRequestContactId { get; set; }
34+
public long? TakedownRequestContactId2 { get; set; }
2535

26-
public string? TakedownRequestContactEmail { get; set; }
36+
public string? TakedownRequestContactEmail2 { get; set; }
2737
}

server/StrDss.Data/Repositories/OrganizationRepository.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public interface IOrganizationRepository
2424
Task<long?> GetManagingOrgId(long orgId);
2525
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
2626
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
27+
Task<PlatformViewDto?> GetPlatform(long id);
2728
}
2829
public class OrganizationRepository : RepositoryBase<DssOrganization>, IOrganizationRepository
2930
{
@@ -164,5 +165,15 @@ public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int page
164165

165166
return platforms;
166167
}
168+
169+
public async Task<PlatformViewDto?> GetPlatform(long id)
170+
{
171+
var platform = _mapper.Map<PlatformViewDto>(await _dbContext.DssPlatformVws.AsNoTracking().FirstOrDefaultAsync(x => x.OrganizationId == id));
172+
173+
platform.Subsidiaries = _mapper.Map<List<PlatformViewDto>>(await _dbContext.DssPlatformVws.AsNoTracking().Where(x => x.ManagingOrganizationId == id).ToListAsync());
174+
175+
return platform;
176+
}
177+
167178
}
168179
}

server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ public PlatformViewDto()
88
}
99

1010
public long OrganizationId { get; set; }
11+
public string OrganizationType { get; set; } = null!;
1112
public string OrganizationCd { get; set; } = null!;
1213
public string OrganizationNm { get; set; } = null!;
1314
public DateTime UpdDtm { get; set; }
1415
public Guid? UpdUserGuid { get; set; }
15-
public long NoticeOfTakedownContactId { get; set; }
16-
public string NoticeOfTakedownContactEmail { get; set; }
17-
public long TakedownRequestContactId { get; set; }
18-
public string TakedownRequestContactEmail { get; set; }
16+
public long? NoticeOfTakedownContactId1 { get; set; }
17+
public string? NoticeOfTakedownContactEmail1 { get; set; }
18+
public long? TakedownRequestContactId1 { get; set; }
19+
public string? TakedownRequestContactEmail1 { get; set; }
20+
public long? NoticeOfTakedownContactId2 { get; set; }
21+
public string? NoticeOfTakedownContactEmail2 { get; set; }
22+
public long? TakedownRequestContactId2 { get; set; }
23+
public string? TakedownRequestContactEmail2 { get; set; }
1924
public virtual ICollection<PlatformViewDto> Subsidiaries { get; set; }
2025
}
2126
}

server/StrDss.Service/OrganizationService.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ public interface IOrganizationService
1919
Task<long?> GetContainingOrganizationId(Point point);
2020
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
2121
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
22+
Task<PlatformViewDto?> GetPlatform(long id);
2223
}
2324
public class OrganizationService : ServiceBase, IOrganizationService
2425
{
@@ -65,5 +66,10 @@ public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int page
6566
{
6667
return await _orgRepo.GetPlatforms(pageSize, pageNumber, orderBy, direction);
6768
}
69+
70+
public async Task<PlatformViewDto?> GetPlatform(long id)
71+
{
72+
return await _orgRepo.GetPlatform(id);
73+
}
6874
}
6975
}

0 commit comments

Comments
 (0)