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