28
This commit is contained in:
@@ -4,22 +4,23 @@ import vweb
|
|||||||
|
|
||||||
@['/controller/faculty'; post]
|
@['/controller/faculty'; post]
|
||||||
pub fn (mut app App) controller_get_faculty() vweb.Result {
|
pub fn (mut app App) controller_get_faculty() vweb.Result {
|
||||||
email := app.query['email']
|
email := app.query['em']
|
||||||
password := app.query['password']
|
password := app.query['pw']
|
||||||
|
|
||||||
response := app.service_get_faculty(email, password) or {
|
response := app.service_get_faculty(email, password) or {
|
||||||
app.set_status(400, '')
|
app.set_status(400, '')
|
||||||
return app.text('${err}')
|
return app.text('${err}')
|
||||||
}
|
}
|
||||||
|
app.set_status(201, '')
|
||||||
return app.json(response)
|
return app.json(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
@['/controller/faculty/create'; post]
|
@['/controller/faculty/create'; post]
|
||||||
pub fn (mut app App) controller_create_faculty() vweb.Result {
|
pub fn (mut app App) controller_create_faculty() vweb.Result {
|
||||||
firstname := app.query['firstname']
|
firstname := app.query['fn']
|
||||||
lastname := app.query['lastname']
|
lastname := app.query['ln']
|
||||||
email := app.query['email']
|
email := app.query['em']
|
||||||
password := app.query['password']
|
password := app.query['pw']
|
||||||
|
|
||||||
if firstname == '' {
|
if firstname == '' {
|
||||||
app.set_status(400, '')
|
app.set_status(400, '')
|
||||||
@@ -42,5 +43,8 @@ pub fn (mut app App) controller_create_faculty() vweb.Result {
|
|||||||
return app.text('error: ${err}')
|
return app.text('error: ${err}')
|
||||||
}
|
}
|
||||||
app.set_status(201, '')
|
app.set_status(201, '')
|
||||||
return app.redirect('/faculty')
|
return app.json(Status {
|
||||||
|
ok: true,
|
||||||
|
msg: 'faculty created successfully',
|
||||||
|
})
|
||||||
}
|
}
|
@@ -11,3 +11,9 @@ mut:
|
|||||||
password string @[sql_type: 'TEXT']
|
password string @[sql_type: 'TEXT']
|
||||||
// products []Product @[fkey: 'user_id']
|
// products []Product @[fkey: 'user_id']
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub struct Status {
|
||||||
|
mut:
|
||||||
|
ok bool
|
||||||
|
msg string
|
||||||
|
}
|
Reference in New Issue
Block a user