Skip to content

Commit

Permalink
Merge pull request #682 from bcgov/yj
Browse files Browse the repository at this point in the history
feat(dss-364)
  • Loading branch information
ychung-mot authored Sep 26, 2024
2 parents edd9538 + d114ba5 commit 7cd53ef
Show file tree
Hide file tree
Showing 8 changed files with 229 additions and 32 deletions.
21 changes: 14 additions & 7 deletions database/ddl/STR_DSS_Views_Sprint_15.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,23 @@ drop view if exists dss_platform_vw;

CREATE OR REPLACE VIEW dss_platform_vw AS
SELECT do2.organization_id
, do2.organization_type
, do2.organization_cd
, do2.organization_nm
, do2.managing_organization_id
, do2.upd_dtm
, do2.upd_user_guid
, docp.organization_contact_person_id as notice_of_takedown_contact_id
, docp.email_address_dsc as notice_of_takedown_contact_email
, docp2.organization_contact_person_id as takedown_request_contact_id
, docp2.email_address_dsc as takedown_request_contact_email
, docp.organization_contact_person_id as notice_of_takedown_contact_id_1
, docp.email_address_dsc as notice_of_takedown_contact_email_1
, docp2.organization_contact_person_id as takedown_request_contact_id_1
, docp2.email_address_dsc as takedown_request_contact_email_1
, docp3.organization_contact_person_id as notice_of_takedown_contact_id_2
, docp3.email_address_dsc as notice_of_takedown_contact_email_2
, docp4.organization_contact_person_id as takedown_request_contact_id_2
, docp4.email_address_dsc as takedown_request_contact_email_2
FROM dss_organization do2
left join dss_organization_contact_person docp on docp.contacted_through_organization_id = do2.organization_id and docp.email_message_type = 'Notice of Takedown'
left join dss_organization_contact_person docp2 on docp2.contacted_through_organization_id = do2.organization_id and docp2.email_message_type = 'Takedown Request'
where do2.organization_type = 'Platform';
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
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
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
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
where do2.organization_type = 'Platform';
162 changes: 151 additions & 11 deletions postman/str-dss.postman_collection.json

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions server/StrDss.Api/Controllers/OrganizationsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,12 @@ public async Task<ActionResult> GetPlatforms(int pageSize = 10, int pageNumber =
return Ok(platforms);
}

[ApiAuthorize()]
[HttpGet("platforms/{id}")]
public async Task<ActionResult> GetPlatform(long id)
{
var platform = await _orgService.GetPlatform(id);
return Ok(platform);
}
}
}
23 changes: 17 additions & 6 deletions server/StrDss.Data/Entities/DssDbContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -667,21 +667,32 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)
.ToView("dss_platform_vw");

entity.Property(e => e.ManagingOrganizationId).HasColumnName("managing_organization_id");
entity.Property(e => e.NoticeOfTakedownContactEmail)
entity.Property(e => e.NoticeOfTakedownContactEmail1)
.HasMaxLength(320)
.HasColumnName("notice_of_takedown_contact_email");
entity.Property(e => e.NoticeOfTakedownContactId).HasColumnName("notice_of_takedown_contact_id");
.HasColumnName("notice_of_takedown_contact_email_1");
entity.Property(e => e.NoticeOfTakedownContactEmail2)
.HasMaxLength(320)
.HasColumnName("notice_of_takedown_contact_email_2");
entity.Property(e => e.NoticeOfTakedownContactId1).HasColumnName("notice_of_takedown_contact_id_1");
entity.Property(e => e.NoticeOfTakedownContactId2).HasColumnName("notice_of_takedown_contact_id_2");
entity.Property(e => e.OrganizationCd)
.HasMaxLength(25)
.HasColumnName("organization_cd");
entity.Property(e => e.OrganizationId).HasColumnName("organization_id");
entity.Property(e => e.OrganizationNm)
.HasMaxLength(250)
.HasColumnName("organization_nm");
entity.Property(e => e.TakedownRequestContactEmail)
entity.Property(e => e.OrganizationType)
.HasMaxLength(25)
.HasColumnName("organization_type");
entity.Property(e => e.TakedownRequestContactEmail1)
.HasMaxLength(320)
.HasColumnName("takedown_request_contact_email_1");
entity.Property(e => e.TakedownRequestContactEmail2)
.HasMaxLength(320)
.HasColumnName("takedown_request_contact_email");
entity.Property(e => e.TakedownRequestContactId).HasColumnName("takedown_request_contact_id");
.HasColumnName("takedown_request_contact_email_2");
entity.Property(e => e.TakedownRequestContactId1).HasColumnName("takedown_request_contact_id_1");
entity.Property(e => e.TakedownRequestContactId2).HasColumnName("takedown_request_contact_id_2");
entity.Property(e => e.UpdDtm).HasColumnName("upd_dtm");
entity.Property(e => e.UpdUserGuid).HasColumnName("upd_user_guid");
});
Expand Down
18 changes: 14 additions & 4 deletions server/StrDss.Data/Entities/DssPlatformVw.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public partial class DssPlatformVw
{
public long? OrganizationId { get; set; }

public string? OrganizationType { get; set; }

public string? OrganizationCd { get; set; }

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

public Guid? UpdUserGuid { get; set; }

public long? NoticeOfTakedownContactId { get; set; }
public long? NoticeOfTakedownContactId1 { get; set; }

public string? NoticeOfTakedownContactEmail1 { get; set; }

public long? TakedownRequestContactId1 { get; set; }

public string? TakedownRequestContactEmail1 { get; set; }

public long? NoticeOfTakedownContactId2 { get; set; }

public string? NoticeOfTakedownContactEmail { get; set; }
public string? NoticeOfTakedownContactEmail2 { get; set; }

public long? TakedownRequestContactId { get; set; }
public long? TakedownRequestContactId2 { get; set; }

public string? TakedownRequestContactEmail { get; set; }
public string? TakedownRequestContactEmail2 { get; set; }
}
11 changes: 11 additions & 0 deletions server/StrDss.Data/Repositories/OrganizationRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public interface IOrganizationRepository
Task<long?> GetManagingOrgId(long orgId);
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
Task<PlatformViewDto?> GetPlatform(long id);
}
public class OrganizationRepository : RepositoryBase<DssOrganization>, IOrganizationRepository
{
Expand Down Expand Up @@ -164,5 +165,15 @@ public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int page

return platforms;
}

public async Task<PlatformViewDto?> GetPlatform(long id)
{
var platform = _mapper.Map<PlatformViewDto>(await _dbContext.DssPlatformVws.AsNoTracking().FirstOrDefaultAsync(x => x.OrganizationId == id));

platform.Subsidiaries = _mapper.Map<List<PlatformViewDto>>(await _dbContext.DssPlatformVws.AsNoTracking().Where(x => x.ManagingOrganizationId == id).ToListAsync());

return platform;
}

}
}
13 changes: 9 additions & 4 deletions server/StrDss.Model/OrganizationDtos/PlatformViewDto.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,19 @@ public PlatformViewDto()
}

public long OrganizationId { get; set; }
public string OrganizationType { get; set; } = null!;
public string OrganizationCd { get; set; } = null!;
public string OrganizationNm { get; set; } = null!;
public DateTime UpdDtm { get; set; }
public Guid? UpdUserGuid { get; set; }
public long NoticeOfTakedownContactId { get; set; }
public string NoticeOfTakedownContactEmail { get; set; }
public long TakedownRequestContactId { get; set; }
public string TakedownRequestContactEmail { get; set; }
public long? NoticeOfTakedownContactId1 { get; set; }
public string? NoticeOfTakedownContactEmail1 { get; set; }
public long? TakedownRequestContactId1 { get; set; }
public string? TakedownRequestContactEmail1 { get; set; }
public long? NoticeOfTakedownContactId2 { get; set; }
public string? NoticeOfTakedownContactEmail2 { get; set; }
public long? TakedownRequestContactId2 { get; set; }
public string? TakedownRequestContactEmail2 { get; set; }
public virtual ICollection<PlatformViewDto> Subsidiaries { get; set; }
}
}
6 changes: 6 additions & 0 deletions server/StrDss.Service/OrganizationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public interface IOrganizationService
Task<long?> GetContainingOrganizationId(Point point);
Task<StrRequirementsDto?> GetStrRequirements(double longitude, double latitude);
Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int pageNumber, string orderBy, string direction);
Task<PlatformViewDto?> GetPlatform(long id);
}
public class OrganizationService : ServiceBase, IOrganizationService
{
Expand Down Expand Up @@ -65,5 +66,10 @@ public async Task<PagedDto<PlatformViewDto>> GetPlatforms(int pageSize, int page
{
return await _orgRepo.GetPlatforms(pageSize, pageNumber, orderBy, direction);
}

public async Task<PlatformViewDto?> GetPlatform(long id)
{
return await _orgRepo.GetPlatform(id);
}
}
}

0 comments on commit 7cd53ef

Please sign in to comment.