diff --git a/src/faculty_controller.v b/src/faculty_controller.v index 0254387..095d333 100644 --- a/src/faculty_controller.v +++ b/src/faculty_controller.v @@ -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', + }) } \ No newline at end of file diff --git a/src/faculty_entities.v b/src/faculty_entities.v index 79b2287..473f8ba 100644 --- a/src/faculty_entities.v +++ b/src/faculty_entities.v @@ -11,3 +11,9 @@ mut: password string @[sql_type: 'TEXT'] // products []Product @[fkey: 'user_id'] } + +pub struct Status { +mut: + ok bool + msg string +} \ No newline at end of file