some re-arrange of menu
This commit is contained in:
parent
4e80a3d9f2
commit
f576d33ec9
@ -221,16 +221,6 @@ fun main(args: Array<String>) {
|
||||
"/{id}", ReminderCtrl::delete, Roles(Role.Explicit("ROLE_REMINDER_CREATE"))
|
||||
)
|
||||
}
|
||||
path("/vehicle") {
|
||||
post("", VehicleCtrl::create, Roles(Role.Explicit("ROLE_FLEET_CREATE")))
|
||||
get(
|
||||
"/{id}", VehicleCtrl::get, Roles(Role.Explicit("ROLE_FLEET_VIEW", "ROLE_FLEET_CREATE"))
|
||||
)
|
||||
put("/{id}", VehicleCtrl::update, Roles(Role.Explicit("ROLE_FLEET_CREATE")))
|
||||
post(
|
||||
"/getAll", VehicleCtrl::getAll, Roles(Role.Explicit("ROLE_FLEET_CREATE", "ROLE_FLEET_VIEW"))
|
||||
)
|
||||
}
|
||||
path("/fleetType") {
|
||||
post("", FleetTypeCtrl::create, Roles(Role.Explicit("ROLE_FLEET_CREATE")))
|
||||
get(
|
||||
|
||||
@ -53,43 +53,6 @@ object FleetCtrl {
|
||||
}
|
||||
}
|
||||
|
||||
object VehicleCtrl {
|
||||
fun create(ctx: Context) {
|
||||
val vehicle = ctx.bodyAsClass<Vehicle>()
|
||||
Session.database.save(vehicle)
|
||||
ctx.json(vehicle).status(HttpStatus.CREATED)
|
||||
}
|
||||
|
||||
fun get(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val vehicle = Session.database.find(Vehicle::class.java, id)
|
||||
?: throw NotFoundResponse("No vehicle found with id $id")
|
||||
ctx.json(vehicle).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
fun getAll(ctx: Context) {
|
||||
val vehicles = Session.database.find(Vehicle::class.java).findList()
|
||||
val excel = ctx.queryParam("excel")
|
||||
if (excel !== null) {
|
||||
// exportVehicles(vehicles)
|
||||
val inputStream = FileInputStream("./excel/Vehicles.xls")
|
||||
ctx.result(inputStream).status(HttpStatus.OK)
|
||||
} else {
|
||||
ctx.json(vehicles).status(HttpStatus.OK)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fun update(ctx: Context) {
|
||||
val id = ctx.pathParam("id").toLong()
|
||||
val vehicle =
|
||||
Session.database.find(Vehicle::class.java, id) ?: throw NotFoundResponse("vehicle not found for $id")
|
||||
val updatedVehicle = ctx.bodyAsClass<Vehicle>()
|
||||
vehicle.patchValues(updatedVehicle)
|
||||
vehicle.update()
|
||||
ctx.json(vehicle).status(HttpStatus.OK)
|
||||
}
|
||||
}
|
||||
|
||||
object FleetTypeCtrl {
|
||||
fun create(ctx: Context) {
|
||||
|
||||
@ -55,16 +55,6 @@ open class FleetType : BaseTenantModel() {
|
||||
var name: String = ""
|
||||
var personIncharge: String = ""
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class Vehicle : BaseTenantModel() {
|
||||
fun patchValues(updated: Vehicle) {
|
||||
this.name = updated.name
|
||||
}
|
||||
|
||||
var name: String = ""
|
||||
}
|
||||
|
||||
@Entity
|
||||
open class Renewal : BaseTenantModel() {
|
||||
fun patchValues(updated: Renewal) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user