rider creation

This commit is contained in:
2026-09-04 16:02:47 +05:30
parent e51ad615ed
commit 593b11f1b8
5 changed files with 535 additions and 0 deletions

View File

@@ -129,3 +129,110 @@ type RiderlogDetails struct {
Breakhours float32 `json:"breakhours"`
Logstatus int `json:"logstatus"`
}
// NewRider is one rider being onboarded, as the console sends it.
//
// A rider is three rows, not one. `app_users` holds the person, `ridersettings`
// the vehicle and licence, and `app_userpools` their place in the availability
// pool — and `getriders` INNER JOINs all three, so a rider missing any of them
// is not a partial rider, they are no rider at all. The flat shape here is
// deliberate: the caller should not have to know the table layout to hire
// somebody.
//
// `Tenantid` is filled in by the controller from the caller's scope, never read
// from the body — a store admin must not be able to put a rider on another
// merchant's books by editing a payload.
type NewRider struct {
Userid int `json:"userid"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Contactno string `json:"contactno"`
Email string `json:"email"`
Password string `json:"password"`
Address string `json:"address"`
Suburb string `json:"suburb"`
City string `json:"city"`
State string `json:"state"`
Postcode string `json:"postcode"`
// Whose rider they are, where they ride, and who they ride for.
Tenantid int `json:"tenantid"`
Applocationid int `json:"applocationid"`
Partnerid int `json:"partnerid"`
Shiftid int `json:"shiftid"`
// The vehicle half — `ridersettings`.
Identificationno string `json:"identificationno"`
Vehiclename string `json:"vehiclename"`
Vehicleno string `json:"vehicleno"`
Licenseno string `json:"licenseno"`
Registrationno string `json:"registrationno"`
Status string `json:"status"`
}
// RiderRosterRow is one rider in the directory.
//
// Distinct from RiderInfo, which is the ON-DUTY read: that one requires a
// riderlog stamped today, which is right for an assignment picker and wrong for
// a staff list, where somebody who has not started their shift must still
// appear. This carries the last log rather than requiring one.
type RiderRosterRow struct {
Userid int `json:"userid"`
Firstname string `json:"firstname"`
Lastname string `json:"lastname"`
Fullname string `json:"fullname"`
Contactno string `json:"contactno"`
Email string `json:"email"`
Tenantid int `json:"tenantid"`
Applocationid int `json:"applocationid"`
Applocation string `json:"applocation"`
Partnerid int `json:"partnerid"`
Partnername string `json:"partnername"`
Shiftid int `json:"shiftid"`
Shiftname string `json:"shiftname"`
Identificationno string `json:"identificationno"`
Vehiclename string `json:"vehiclename"`
Vehicleno string `json:"vehicleno"`
Licenseno string `json:"licenseno"`
Registrationno string `json:"registrationno"`
// Duty state, as facts rather than as a filter.
Onduty int `json:"onduty"`
Lastlogdate string `json:"lastlogdate"`
// True when there is a log dated today with logstatus 0 — on shift right now.
Isonduty bool `json:"isonduty"`
Status string `json:"status"`
}
// Ridersettings is the vehicle-and-licence half of a rider.
//
// `riderid` is DELIBERATELY ABSENT. It is a GENERATED ALWAYS identity column,
// and including it makes GORM send a zero, which Postgres rejects outright:
// "cannot insert a non-DEFAULT value into column riderid". Leaving it off the
// struct is what keeps the insert to the columns that are actually ours to set.
type Ridersettings struct {
Userid int `json:"userid"`
Partnerid int `json:"partnerid"`
Shiftid int `json:"shiftid"`
Identificationno string `json:"identificationno"`
Vehiclename string `json:"vehiclename"`
Vehicleno string `json:"vehicleno"`
Licenseno string `json:"licenseno"`
Registrationno string `json:"registrationno"`
}
// Appuserpools is a rider's place in the availability pool.
//
// `poolid` is absent for the same reason as `riderid` above — same identity
// column, same rejection.
//
// `Onduty` means "may be given work", not "on shift right now". The second
// question is answered by riderlogs, which the rider's own app writes.
type Appuserpools struct {
Userid int `json:"userid"`
Partnerid int `json:"partnerid"`
Onduty int `json:"onduty"`
Status string `json:"status"`
}