mentorenwahl/docker/backend/src/backend/api/schema/teacher_vote.cr

59 lines
1.7 KiB
Crystal
Raw Normal View History

2022-02-10 07:43:47 +00:00
# Mentorenwahl: A fullstack application for assigning mentors to students based on their whishes.
# Copyright (C) 2022 Dominic Grimm
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
2022-01-23 08:12:57 +00:00
module Backend
module Api
2022-01-23 08:12:57 +00:00
module Schema
@[GraphQL::Object]
2022-02-09 13:35:35 +00:00
# Teacher vote model
2022-01-23 08:12:57 +00:00
class TeacherVote < GraphQL::BaseObject
include Helpers::DbObject
db_object Db::TeacherVote
@[GraphQL::Field]
2022-02-09 13:35:35 +00:00
# Voted teacher
2022-01-23 08:12:57 +00:00
def teacher : Teacher
Teacher.new(find!.teacher.not_nil!)
end
@[GraphQL::Field]
2022-02-09 13:35:35 +00:00
# Teacher vote's priority
2022-01-23 08:12:57 +00:00
def priority : Int32
find!.priority
end
end
@[GraphQL::InputObject]
2022-02-09 13:35:35 +00:00
# Teacher vote creation input
2022-01-23 08:12:57 +00:00
class TeacherVoteCreateInput < GraphQL::BaseInputObject
2022-02-09 13:35:35 +00:00
# Teacher vote's vote ID
2022-01-23 08:12:57 +00:00
getter vote_id
2022-02-09 13:35:35 +00:00
# Teacher vote's teacher ID
2022-01-23 08:12:57 +00:00
getter teacher_id
2022-02-09 13:35:35 +00:00
# Teacher vote's priority
2022-01-23 08:12:57 +00:00
getter priority
@[GraphQL::Field]
def initialize(@vote_id : Int32, @teacher_id : Int32, @priority : Int32)
end
end
end
end
end