-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add refresh endpoint, modified create dock report routine to pull mor…
…e info from classes (#12) Co-authored-by: Alex Banks <[email protected]>
- Loading branch information
1 parent
a560091
commit 672bf65
Showing
4 changed files
with
89 additions
and
28 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
...sailcbi/APIServer/Api/Endpoints/Staff/Dockhouse/DockReport/RefreshDockReportClasses.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package org.sailcbi.APIServer.Api.Endpoints.Staff.Dockhouse.DockReport | ||
|
||
import com.coleji.neptune.Core.{ParsedRequest, PermissionsAuthority} | ||
import org.sailcbi.APIServer.Entities.EntityDefinitions.{DockReport, DockReportApClass} | ||
import org.sailcbi.APIServer.Entities.dto.PutDockReportApClassDto | ||
import org.sailcbi.APIServer.Logic.DockhouseLogic.DockReportLogic | ||
import org.sailcbi.APIServer.UserTypes.StaffRequestCache | ||
import play.api.libs.json.Json | ||
import play.api.mvc.{Action, AnyContent, InjectedController} | ||
|
||
import javax.inject.Inject | ||
import scala.concurrent.{ExecutionContext, Future} | ||
|
||
class RefreshDockReportClasses @Inject()(implicit val exec: ExecutionContext) extends InjectedController { | ||
|
||
def post()(implicit PA: PermissionsAuthority): Action[AnyContent] = Action.async(req => { | ||
val parsedRequest = ParsedRequest(req) | ||
PA.withRequestCache(StaffRequestCache)(None, parsedRequest, rc => { | ||
Future(Ok(Json.toJson(rc.getObjectsByFilters(DockReport, List(DockReport.fields.reportDate.alias.isDateConstant(PA.now().toLocalDate)), Set( | ||
DockReport.fields.dockReportId | ||
)).headOption.map(dockReportToday => { | ||
val currentClasses = DockReportLogic.getDockReportClasses(rc, dockReportToday) | ||
|
||
DockReportLogic.refreshDockReportClasses(rc, dockReportToday, id => { | ||
currentClasses.find(c => { | ||
c.values.apInstanceId.get == id | ||
}).getOrElse(new DockReportApClass()) | ||
|
||
}) | ||
}).getOrElse(List[PutDockReportApClassDto]())))) | ||
}) | ||
}) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters