feat: Allow setting existing IDs for Planning and RegistrationDesk
- Add `id` field to `PlanningArg` struct - Add `id` field to `RegistrationDeskArg` struct - Update `set` handler for Planning to use `PlanningArg` - Update `set` handler for RegistrationDesk to use `RegistrationDeskArg` - Enable setting existing IDs during `set` operations
This commit is contained in:
@@ -184,6 +184,7 @@ fn (mut self DBPlanning) load(mut o Planning, mut e encoder.Decoder) ! {
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct PlanningArg {
|
pub struct PlanningArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
id u32
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
color string
|
color string
|
||||||
@@ -297,7 +298,11 @@ pub fn planning_handle(mut f ModelsFactory, rpcid int, servercontext map[string]
|
|||||||
return new_response(rpcid, json.encode(res))
|
return new_response(rpcid, json.encode(res))
|
||||||
}
|
}
|
||||||
'set' {
|
'set' {
|
||||||
mut o := db.decode_generic[Planning](params)!
|
mut args := db.decode_generic[PlanningArg](params)!
|
||||||
|
mut o := f.planning.new(args)!
|
||||||
|
if args.id != 0 {
|
||||||
|
o.id = args.id
|
||||||
|
}
|
||||||
o = f.planning.set(o)!
|
o = f.planning.set(o)!
|
||||||
return new_response_int(rpcid, int(o.id))
|
return new_response_int(rpcid, int(o.id))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -178,6 +178,7 @@ pub fn (mut self DBRegistrationDesk) load(mut o RegistrationDesk, mut e encoder.
|
|||||||
@[params]
|
@[params]
|
||||||
pub struct RegistrationDeskArg {
|
pub struct RegistrationDeskArg {
|
||||||
pub mut:
|
pub mut:
|
||||||
|
id u32
|
||||||
name string
|
name string
|
||||||
description string
|
description string
|
||||||
fs_items []u32 // IDs of linked files or dirs
|
fs_items []u32 // IDs of linked files or dirs
|
||||||
@@ -303,7 +304,11 @@ pub fn registration_desk_handle(mut f ModelsFactory, rpcid int, servercontext ma
|
|||||||
return new_response(rpcid, json.encode(res))
|
return new_response(rpcid, json.encode(res))
|
||||||
}
|
}
|
||||||
'set' {
|
'set' {
|
||||||
mut o := db.decode_generic[RegistrationDesk](params)!
|
mut args := db.decode_generic[RegistrationDeskArg](params)!
|
||||||
|
mut o := f.registration_desk.new(args)!
|
||||||
|
if args.id != 0 {
|
||||||
|
o.id = args.id
|
||||||
|
}
|
||||||
o = f.registration_desk.set(o)!
|
o = f.registration_desk.set(o)!
|
||||||
return new_response_int(rpcid, int(o.id))
|
return new_response_int(rpcid, int(o.id))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user