Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserApiController {
- constructor()
- {
- this.getUsers = this.getUsers.bind(this),
- this.findUser = this.findUser.bind(this),
- this.findTheatre = this.findTheatre.bind(this),
- this.getTheatres = this.getTheatres.bind(this),
- this.getMovies = this.getMovies.bind(this),
- this.findMovie = this.findMovie.bind(this),
- this.getTimes = this.getTimes.bind(this),
- this.findTime = this.findTime.bind(this)
- }
- _usersList()
- {
- return [
- {id: 0, name: 'Pasirinkite'},
- {id: 1, name: 'Panevėžio'},
- {id: 2, name: 'Kauno'},
- {id: 3, name: 'Šiaulių'},
- {id: 4, name: 'Vilniaus'},
- {id: 5, name: 'Klaipėdos'}
- ]
- }
- _theatreList()
- {
- return [
- {id: 0, cid: 0, name: 'Pasirinkite'},
- {id: 1, cid: 2, name: 'Forum cinemas Akropolis'},
- {id: 2, cid: 1, name: 'Garsas'},
- {id: 3, cid: 1, name: 'Apollo kinas Babilonas'},
- {id: 4, cid: 3, name: 'Forum cinemas Saulės miestas'},
- {id: 5, cid: 4, name: 'Forum cinemas Vingis'},
- {id: 6, cid: 5, name: 'Forum cinemas Klaipėda'}
- ]
- }
- _movieList()
- {
- return [
- {id: 1, tid: 1, name: '1917', genre: [ 'karinis', 'drama'], price_s: 5, price_v:4},
- {id: 2, tid: 2, name: 'La La Land', genre: [ 'drama' ], price_s: 4, price_v:3},
- {id: 3, tid: 1, name: 'Hacksaw ridge', genre: [ 'karinis' ], price_s: 12, price_v:8},
- {id: 4, tid: 3, name: 'Intouchables', genre: [ 'drama' ], price_s: 8, price_v:6},
- {id: 5, tid: 4, name: 'Dunkirk', genre: [ 'karinis' ], price_s: 9, price_v:7},
- {id: 6, tid: 5, name: 'The Godfather', genre: [ 'drama' ], price_s: 10, price_v:8}
- ]
- }
- _timeList()
- {
- return [
- {id: 0, lid: 0, vietos: 0, multiplier: 0, date: 'Pasirinkite'},
- {id: 1, lid: 1, vietos: 1, multiplier: 1.2, date: '2020 Kovo 7d. 15:30'},
- {id: 2, lid: 2, vietos: 0, multiplier: 1.4, date: '2020 Kovo 8d. 16:30'},
- {id: 3, lid: 1, vietos: 0, multiplier: 1.8, date: '2020 Kovo 9d. 12:30'},
- {id: 4, lid: 3, vietos: 1, multiplier: 2, date: '2020 Kovo 10d. 19:30'},
- {id: 5, lid: 4, vietos: 1, multiplier: 3, date: '2020 Kovo 11d. 14:30'},
- {id: 6, lid: 5, vietos: 0, multiplier: 1.5, date: '2020 Kovo 12d. 20:30'}
- ]
- }
- getUsers(req,res,next){
- const users = this._usersList()
- return res.json(users)
- }
- getTheatres(req,res,next){
- const theatres = this._theatreList()
- return res.json(theatres)
- }
- getMovies(req,res,next){
- const movies = this._movieList()
- return res.json(movies)
- }
- getTimes(req,res,next){
- const times = this._timeList()
- return res.json(times)
- }
- findUser(req,res,next){
- const userId = parseInt(req.body.userId) || 0
- const users = this._usersList()
- const amount = users.length
- let result = {}
- for (let i=0;1<amount;i++){
- let user=users[i]
- if(user.id==userId){
- result = user
- break
- }
- }
- return res.json(result)
- }
- findTheatre(req,res,next){
- const theatreId = parseInt(req.query.theatreId) || 0
- const theatres = this._theatreList()
- const users = this._usersList()
- const amount = theatres.length
- let result = []
- for (let i=0;1<amount;i++){
- let theatre=theatres[i]
- let user=users[i]
- if(theatre.id == theatreId){
- console.log(theatre)
- console.log(user)
- result.push(theatre)
- break
- }
- }
- return res.json(result)
- }
- findMovie(req,res,next){
- const movieId = parseInt(req.body.movieId) || 0
- const movies = this._movieList()
- const amount = movies.length
- let result = {}
- for (let i=0;1<amount;i++){
- let movie=movies[i]
- if(movie.id==movieId){
- result = movie
- break
- }
- }
- return res.json(result)
- }
- findTime(req,res,next){
- const timeId = parseInt(req.body.timeId) || 0
- const times = this._timeList()
- const amount = times.length
- let result = {}
- console.log(timeId)
- for (let i=0;1<amount;i++){
- let time=times[i]
- if(time.id==timeId){
- //console.log(timeId)
- result = time
- break
- }
- }
- return res.json(result)
- }
- }
- module.exports = UserApiController
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement