added shipcall participant list to API GET call

This commit is contained in:
Daniel Schick 2023-08-11 15:07:42 +02:00
parent c08ba046c9
commit 794cd8efaf
5 changed files with 42 additions and 6 deletions

View File

@ -1,7 +1,7 @@
//----------------------
// <auto-generated>
// Generated REST API Client Code Generator v1.7.17.0 on 07.08.2023 15:13:59
// Generated REST API Client Code Generator v1.7.17.0 on 11.08.2023 12:15:43
// Using the tool OpenAPI Generator v6.6.0
// </auto-generated>
//----------------------
@ -6017,9 +6017,10 @@ namespace BreCalClient.misc.Model
/// <param name="tidalWindowTo">tidalWindowTo.</param>
/// <param name="rainSensitiveCargo">rainSensitiveCargo.</param>
/// <param name="recommendedTugs">recommendedTugs.</param>
/// <param name="participants">participants.</param>
/// <param name="created">created.</param>
/// <param name="modified">modified.</param>
public Shipcall(int id = default(int), int shipId = default(int), TypeEnum type = default(TypeEnum), DateTime eta = default(DateTime), string voyage = default(string), DateTime? etd = default(DateTime?), int? arrivalBerthId = default(int?), int? departureBerthId = default(int?), bool? tugReguired = default(bool?), bool? pilotRequired = default(bool?), int? flags = default(int?), bool? pierSide = default(bool?), bool? bunkering = default(bool?), bool? replenishing = default(bool?), float? draft = default(float?), DateTime? tidalWindowFrom = default(DateTime?), DateTime? tidalWindowTo = default(DateTime?), bool? rainSensitiveCargo = default(bool?), int? recommendedTugs = default(int?), DateTime created = default(DateTime), DateTime? modified = default(DateTime?))
public Shipcall(int id = default(int), int shipId = default(int), TypeEnum type = default(TypeEnum), DateTime eta = default(DateTime), string voyage = default(string), DateTime? etd = default(DateTime?), int? arrivalBerthId = default(int?), int? departureBerthId = default(int?), bool? tugReguired = default(bool?), bool? pilotRequired = default(bool?), int? flags = default(int?), bool? pierSide = default(bool?), bool? bunkering = default(bool?), bool? replenishing = default(bool?), float? draft = default(float?), DateTime? tidalWindowFrom = default(DateTime?), DateTime? tidalWindowTo = default(DateTime?), bool? rainSensitiveCargo = default(bool?), int? recommendedTugs = default(int?), List<int> participants = default(List<int>), DateTime created = default(DateTime), DateTime? modified = default(DateTime?))
{
this.Id = id;
this.ShipId = shipId;
@ -6050,6 +6051,7 @@ namespace BreCalClient.misc.Model
this.TidalWindowTo = tidalWindowTo;
this.RainSensitiveCargo = rainSensitiveCargo;
this.RecommendedTugs = recommendedTugs;
this.Participants = participants;
this.Created = created;
this.Modified = modified;
}
@ -6145,6 +6147,11 @@ namespace BreCalClient.misc.Model
[DataMember(Name = "recommended_tugs", EmitDefaultValue = true)]
public int? RecommendedTugs { get; set; }
/// <summary>
/// Gets or Sets Participants
/// </summary>
[DataMember(Name = "participants", EmitDefaultValue = true)]
public List<int> Participants { get; set; }
/// <summary>
/// Gets or Sets Created
/// </summary>
[DataMember(Name = "created", EmitDefaultValue = true)]
@ -6181,6 +6188,7 @@ namespace BreCalClient.misc.Model
sb.Append(" TidalWindowTo: ").Append(TidalWindowTo).Append("\n");
sb.Append(" RainSensitiveCargo: ").Append(RainSensitiveCargo).Append("\n");
sb.Append(" RecommendedTugs: ").Append(RecommendedTugs).Append("\n");
sb.Append(" Participants: ").Append(Participants).Append("\n");
sb.Append(" Created: ").Append(Created).Append("\n");
sb.Append(" Modified: ").Append(Modified).Append("\n");
sb.Append("}\n");
@ -6307,6 +6315,12 @@ namespace BreCalClient.misc.Model
(this.RecommendedTugs != null &&
this.RecommendedTugs.Equals(input.RecommendedTugs))
) &&
(
this.Participants == input.Participants ||
this.Participants != null &&
input.Participants != null &&
this.Participants.SequenceEqual(input.Participants)
) &&
(
this.Created == input.Created ||
(this.Created != null &&
@ -6394,6 +6408,10 @@ namespace BreCalClient.misc.Model
{
hashCode = (hashCode * 59) + this.RecommendedTugs.GetHashCode();
}
if (this.Participants != null)
{
hashCode = (hashCode * 59) + this.Participants.GetHashCode();
}
if (this.Created != null)
{
hashCode = (hashCode * 59) + this.Created.GetHashCode();

View File

@ -375,6 +375,11 @@ components:
recommended_tugs:
type: integer
nullable: true
participants:
type: array
items:
type: integer
example: [1, 5, 7]
created:
type: string
format: date-time

View File

@ -1,8 +1,8 @@
{
"host" : "lager",
"port" : 3306,
"host" : "localhost",
"port" : 33306,
"user" : "ds",
"password" : "HalloWach23",
"password" : "HalloWach_2323XXL!!",
"pool_name" : "brecal_pool",
"pool_size" : 20,
"database" : "bremen_calling",

View File

@ -21,6 +21,11 @@ def GetShipcalls(options):
"flags, pier_side, bunkering, replenishing, draft, tidal_window_from, tidal_window_to, rain_sensitive_cargo, recommended_tugs, " +
"created, modified FROM shipcall WHERE eta IS NULL OR eta >= DATE(NOW() - INTERVAL 2 DAY) " +
"ORDER BY eta", model=model.Shipcall)
for shipcall in data:
participant_query = "SELECT participant_id FROM shipcall_participant_map WHERE shipcall_id=?shipcall_id?";
for record in commands.query(participant_query, model=dict, param={"shipcall_id" : shipcall.id}, buffered=False):
shipcall.participants.append(record["participant_id"])
pooledConnection.close()
except Exception as ex:
@ -52,6 +57,8 @@ def PostShipcalls(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
if key == "participants":
continue
if isNotFirst:
query += ","
isNotFirst = True
@ -61,6 +68,8 @@ def PostShipcalls(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
if key == "participants":
continue
if isNotFirst:
query += ","
isNotFirst = True
@ -99,6 +108,8 @@ def PutShipcalls(schemaModel):
for key in schemaModel.keys():
if key == "id":
continue
if key == "participants":
continue
if isNotFirst:
query += ", "
isNotFirst = True

View File

@ -1,5 +1,7 @@
from dataclasses import field
from marshmallow import Schema, fields, INCLUDE, ValidationError
from marshmallow_dataclass import dataclass
from typing import List
import json
import datetime
@ -104,7 +106,7 @@ class Shipcall:
recommended_tugs: int
created: datetime
modified: datetime
participants: List[int] = field(default_factory=list)
class ShipcallId(Schema):
pass