This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface CrudRepository<T, in ID> { | |
companion object { | |
const val LIMIT: Int = 50 | |
const val MAX_LIMIT: Int = 100 | |
const val OFFSET: Int = 0 | |
const val MIN_LIMIT: Int = 0 | |
} | |
fun save(entity: T): T |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// CREATE | |
val movie = StarWarsFilm.new { | |
name = "The Last Jedi" | |
sequelId = 8 | |
director = "Rian Johnson" | |
} | |
// READ | |
val movies = StarWarsFilm.all() | |
val movies = StarWarsFilm.find { StarWarsFilms.sequelId eq 8 } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// READ | |
val query: Query = StarWarsFilms.select { StarWarsFilms.sequelId eq 8 } | |
// INSERT | |
val id = StarWarsFilms.insertAndGetId { | |
it[name] = "The Last Jedi" | |
it[sequelId] = 8 | |
it[director] = "Rian Johnson" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster | |
import com.nhaarman.mockito_kotlin.any | |
import com.nhaarman.mockito_kotlin.whenever | |
import org.jetbrains.spek.api.Spek | |
import org.jetbrains.spek.api.dsl.given | |
import org.jetbrains.spek.api.dsl.it | |
import org.jetbrains.spek.api.dsl.on | |
import org.junit.Assert.assertEquals | |
import org.mockito.Mockito |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.movies.controllers | |
import com.myblockbuster.core.Request | |
import com.myblockbuster.core.User | |
import com.myblockbuster.core.controllers.Controller | |
import com.myblockbuster.core.factories.ServiceFactory | |
import com.myblockbuster.core.services.Service | |
import com.myblockbuster.movies.Movie | |
class MovieController: Controller<Movie> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.core.factories | |
import com.myblockbuster.core.User | |
import com.myblockbuster.core.services.Service | |
import com.myblockbuster.movies.Movie | |
import com.myblockbuster.movies.services.MovieService | |
/** | |
* Interface Factory | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.movies.controllers | |
import com.myblockbuster.core.Request | |
import com.myblockbuster.core.User | |
import com.myblockbuster.core.controllers.Controller | |
import com.myblockbuster.core.services.Service | |
import com.myblockbuster.movies.Movie | |
import com.myblockbuster.movies.services.MovieService | |
class MovieController: Controller<Movie> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File models.kt in the movies package (microservice) | |
package com.myblockbuster.movies | |
import com.myblockbuster.core.BaseModel | |
data class Person(var name: String, var surname: String) { | |
constructor() : this("", "") | |
} | |
data class Movie(var title: String, var rate: Double, var language: String, var director: Person, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// File exceptions.kt in the movies package (microservice) | |
package com.myblockbuster.movies | |
import com.myblockbuster.core.MyException | |
class MovieAlreadyExistsException(code: Int = 400, message: String = "Movie Already Exists") : MyException(code, message) | |
class MovieNotExistsException(code: Int = 404, message: String = "Movie Doesn't Exists") : MyException(code, message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.myblockbuster.movies.services | |
import com.myblockbuster.core.Page | |
import com.myblockbuster.core.Pagination | |
import com.myblockbuster.core.User | |
import com.myblockbuster.core.services.Service | |
import com.myblockbuster.movies.Movie | |
import com.myblockbuster.movies.MovieAlreadyExistsException | |
import com.myblockbuster.movies.MovieNotExistsException | |
import kotlin.math.min |
NewerOlder