API 1.2+1 DietMeal + fixes
This commit is contained in:
@@ -9,6 +9,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.builder.SpringApplicationBuilder
|
||||
import org.springframework.context.annotation.Bean
|
||||
|
||||
|
||||
@SpringBootApplication
|
||||
class ApiApplication {
|
||||
@Bean(name = ["jasyptStringEncryptor"])
|
||||
@@ -43,3 +44,5 @@ class ApiApplication {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.aitrainer.api.service.EmailTemplateService
|
||||
import com.aitrainer.api.service.Firebase
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.http.HttpHeaders
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.security.access.annotation.Secured
|
||||
@@ -153,7 +154,7 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
}
|
||||
|
||||
@PostMapping("/club_registration")
|
||||
fun clubRegistration(@Valid @RequestBody json: String): ResponseEntity<*> {
|
||||
fun clubRegistration(@Valid @RequestBody json: String, @Value("\${firebase.key}") apiKey: String): ResponseEntity<*> {
|
||||
|
||||
val newUser: ClubUser = ClubUser().fromJson(json)
|
||||
|
||||
@@ -173,7 +174,7 @@ class CustomerController ( private val customerRepository: CustomerRepository) {
|
||||
val stringCharacters = ('0'..'z').toList().toTypedArray()
|
||||
val genPassword = (1..10).map { stringCharacters.random() }.joinToString("")
|
||||
|
||||
val firebase = Firebase()
|
||||
val firebase = Firebase(apiKey)
|
||||
val signupResponse = firebase.signUp(newUser.email, genPassword)
|
||||
?: return ResponseEntity.badRequest().body("Firebase exception ${firebase.error}")
|
||||
|
||||
|
||||
@@ -28,7 +28,8 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
private val dietUserConsumptionRepository: DietUserConsumptionRepository,
|
||||
private val dietUserRepository: DietUserRepository,
|
||||
private val dietUserPreferenceRepository: DietUserPreferenceRepository,
|
||||
private val dietUserSensitivityRepository: DietUserSensitivityRepository
|
||||
private val dietUserSensitivityRepository: DietUserSensitivityRepository,
|
||||
private val customerConversationRepository: CustomerConversationRepository
|
||||
|
||||
) {
|
||||
|
||||
@@ -53,16 +54,10 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
val customerJson: String = gson.toJson(customer)
|
||||
val dietUserJson: String = gson.toJson(dietUser)
|
||||
|
||||
val listCustomerProperty = customerPropertyRepository.findLastPropertiesByCustomerId(customerId)
|
||||
val listCustomerPropertyJson = gson.toJson(listCustomerProperty)
|
||||
|
||||
val listMembership = customerMembership.findAllByCustomer(customer)
|
||||
val listMembershipJson = gson.toJson(listMembership)
|
||||
|
||||
val listDiet = dietRepository.findByDietUserId(dietUserId)
|
||||
val listDietJson = gson.toJson(listDiet)
|
||||
|
||||
val listDietRawMaterial = dietRawMaterialRepository.findByDietId(dietUserId)
|
||||
val listDietRawMaterial = dietRawMaterialRepository.findByDietMealId(dietUserId)
|
||||
val listDietRawMaterialJson = gson.toJson(listDietRawMaterial)
|
||||
|
||||
val listDietUserConsumption = dietUserConsumptionRepository.findByDietUserId(dietUserId)
|
||||
@@ -74,17 +69,18 @@ class CustomerPackageController( private val customerRepository: CustomerReposit
|
||||
val listDietUserSensitivity = dietUserSensitivityRepository.findByDietUserId(dietUserId)
|
||||
val listDietUserSensitivityJson = gson.toJson(listDietUserSensitivity)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(DietUser::class.simpleName, dietUserJson)
|
||||
"|||" + getClassRecord(CustomerProperty::class.simpleName, listCustomerPropertyJson)
|
||||
"|||" + getClassRecord(CustomerMembership::class.simpleName, listMembershipJson)
|
||||
"|||" + getClassRecord(Diet::class.simpleName, listDietJson)
|
||||
"|||" + getClassRecord(DietRawMaterial::class.simpleName, listDietRawMaterialJson)
|
||||
"|||" + getClassRecord(DietUserConsumption::class.simpleName, listDietUserConsumptionJson)
|
||||
"|||" + getClassRecord(DietUserPreference::class.simpleName, listDietUserPreferenceJson)
|
||||
"|||" + getClassRecord(DietUserSensitivity::class.simpleName, listDietUserSensitivityJson)
|
||||
val listCustomerConversation = customerConversationRepository.findByCustomerId(customerId)
|
||||
val listCustomerConversationJson = gson.toJson(listCustomerConversation)
|
||||
|
||||
val packageJson: String =
|
||||
getClassRecord(Customer::class.simpleName, customerJson) +
|
||||
"|||" + getClassRecord(DietUser::class.simpleName, dietUserJson) +
|
||||
"|||" + getClassRecord(Diet::class.simpleName, listDietJson) +
|
||||
"|||" + getClassRecord(DietRawMaterial::class.simpleName, listDietRawMaterialJson) +
|
||||
"|||" + getClassRecord(DietUserConsumption::class.simpleName, listDietUserConsumptionJson) +
|
||||
"|||" + getClassRecord(DietUserPreference::class.simpleName, listDietUserPreferenceJson) +
|
||||
"|||" + getClassRecord(DietUserSensitivity::class.simpleName, listDietUserSensitivityJson) +
|
||||
"|||" + getClassRecord(CustomerConversation::class.simpleName, listCustomerConversationJson)
|
||||
|
||||
return if (packageJson.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(packageJson)
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package com.aitrainer.api.controller
|
||||
|
||||
import com.aitrainer.api.model.OpenAI
|
||||
import com.aitrainer.api.openai.OpenAIService
|
||||
import kotlinx.coroutines.*
|
||||
import org.slf4j.LoggerFactory
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
import org.springframework.web.bind.annotation.*
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api")
|
||||
@@ -13,10 +12,10 @@ class OpenAIController() {
|
||||
private val logger = LoggerFactory.getLogger(javaClass)
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@GetMapping("/openai/completion")
|
||||
fun getOpenAIResponse(question: String) : String {
|
||||
@PostMapping("/openai/completion")
|
||||
fun getOpenAIResponse(@RequestBody question: String) : String {
|
||||
var result = ""
|
||||
val openAIService = OpenAIService()
|
||||
val openAIService = OpenAIService(null, null)
|
||||
val deferred = GlobalScope.async {
|
||||
openAIService.completion(question)
|
||||
}
|
||||
@@ -26,5 +25,35 @@ class OpenAIController() {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@PostMapping("/openai/completion_with_model")
|
||||
fun getOpenAIResponseWithModel(@RequestBody openai: OpenAI) : String {
|
||||
var result = ""
|
||||
val openAIService = OpenAIService(openai.modelName, openai.temperature)
|
||||
val deferred = GlobalScope.async {
|
||||
openAIService.completion(openai.question)
|
||||
}
|
||||
runBlocking {
|
||||
result = deferred.await()
|
||||
//println("Result: $result" )
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
@GetMapping("/openai/list_models")
|
||||
fun getOpenAIModels(): MutableList<String> {
|
||||
var result = mutableListOf<String>()
|
||||
val openAIService = OpenAIService(null, null)
|
||||
val deferred = GlobalScope.async {
|
||||
openAIService.getModels()
|
||||
}
|
||||
runBlocking {
|
||||
result = deferred.await()
|
||||
//println("Result: $result" )
|
||||
}
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,23 @@ class DietController(private val dietRepository: DietRepository) {
|
||||
return ResponseEntity.ok().body(dietRepository.save(diet))
|
||||
}
|
||||
|
||||
@PostMapping("/diet/{id}")
|
||||
fun update(@PathVariable(value = "id") id: Long, @RequestBody diet: Diet): ResponseEntity<Diet> {
|
||||
val existingDiet = dietRepository.findByDietId(id) ?: return ResponseEntity.notFound().build()
|
||||
|
||||
val updatedDiet: Diet = existingDiet.copy(
|
||||
dietId = diet.dietId,
|
||||
dietUserId = diet.dietUserId,
|
||||
dietText = diet.dietText,
|
||||
startDate = diet.startDate
|
||||
)
|
||||
diet.meals.forEach {
|
||||
it.diet = diet
|
||||
updatedDiet.meals.add(it)
|
||||
}
|
||||
return ResponseEntity.ok().body(dietRepository.save(updatedDiet))
|
||||
}
|
||||
|
||||
@GetMapping("/diet/{dietUserId}")
|
||||
fun getByDietUserId(@PathVariable dietUserId: Long): ResponseEntity<List<Diet>> {
|
||||
val list = dietRepository.findByDietUserId(dietUserId)
|
||||
|
||||
@@ -7,11 +7,10 @@ import com.aitrainer.api.model.diet.DietCustomer
|
||||
import com.aitrainer.api.model.diet.DietUser
|
||||
import com.aitrainer.api.repository.CustomerRepository
|
||||
import com.aitrainer.api.repository.diet.DietUserRepository
|
||||
import com.aitrainer.api.service.Email
|
||||
import com.aitrainer.api.service.EmailTemplateService
|
||||
import com.aitrainer.api.service.Firebase
|
||||
import com.aitrainer.api.service.ServiceBeans
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.http.ResponseEntity
|
||||
import org.springframework.web.bind.annotation.*
|
||||
import java.time.LocalDateTime
|
||||
@@ -25,11 +24,8 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
@Autowired
|
||||
var serviceBeans: ServiceBeans? = null
|
||||
|
||||
@Autowired
|
||||
private var emailTemplateService: EmailTemplateService? = null
|
||||
|
||||
@PostMapping("/diet_registration")
|
||||
fun insert(@RequestBody dietCustomerJson: String): ResponseEntity<*> {
|
||||
fun insert(@RequestBody dietCustomerJson: String, @Value("\${firebase.key}") apiKey: String): ResponseEntity<*> {
|
||||
val newDietCustomer: DietCustomer = DietCustomer().fromJson(dietCustomerJson)
|
||||
|
||||
if ( newDietCustomer.email.isEmpty()) {
|
||||
@@ -48,7 +44,7 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
var existingCustomer: Customer? = customerRepository.findByEmailAndActive(newDietCustomer.email, "Y")
|
||||
|
||||
if (existingCustomer == null ) {
|
||||
val firebase = Firebase()
|
||||
val firebase = Firebase(apiKey)
|
||||
val signupResponse = firebase.signUp(newDietCustomer.email, genPassword)
|
||||
?: return ResponseEntity.badRequest().body("Firebase exception ${firebase.error}")
|
||||
idToken = signupResponse.idToken
|
||||
@@ -125,7 +121,7 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
}
|
||||
|
||||
// create email link
|
||||
val activationLink = "https://diet4you.andio.hu/welcome/id=$idToken"
|
||||
/*val activationLink = "https://diet4you.andio.hu/welcome/id=$idToken"
|
||||
if ( emailTemplateService == null ) {
|
||||
emailTemplateService = EmailTemplateService()
|
||||
}
|
||||
@@ -134,7 +130,7 @@ class DietCustomerController(private val dietUserRepository: DietUserRepository,
|
||||
|
||||
// send email
|
||||
val email = Email()
|
||||
email.send(newDietCustomer.email, html, subject)
|
||||
email.send(newDietCustomer.email, html, subject)*/
|
||||
|
||||
return ResponseEntity.ok().body(existingCustomer)
|
||||
}
|
||||
|
||||
@@ -15,9 +15,9 @@ class DietRawMaterialController(private val dietRawMaterialRepository: DietRawMa
|
||||
return ResponseEntity.ok().body(dietRawMaterialRepository.save(dietRawMaterial))
|
||||
}
|
||||
|
||||
@GetMapping("/diet_raw_material/{dietId}")
|
||||
fun getByDietUserId(@PathVariable dietId: Long): ResponseEntity<List<DietRawMaterial>> {
|
||||
val list = dietRawMaterialRepository.findByDietId(dietId)
|
||||
@GetMapping("/diet_raw_material/{dietMealId}")
|
||||
fun getByDietUserId(@PathVariable dietMealId: Long): ResponseEntity<List<DietRawMaterial>> {
|
||||
val list = dietRawMaterialRepository.findByDietMealId(dietMealId)
|
||||
return if (list.isEmpty()) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
|
||||
@@ -26,7 +26,8 @@ class RecipeController(private val recipeRepository: RecipeRepository) {
|
||||
ch = recipe.ch,
|
||||
fat = recipe.fat,
|
||||
protein = recipe.protein,
|
||||
dietUserId = recipe.dietUserId
|
||||
dietUserId = recipe.dietUserId,
|
||||
mealId = recipe.mealId
|
||||
)
|
||||
recipe.rawMaterials.forEach {
|
||||
it.recipe = recipe
|
||||
@@ -42,13 +43,20 @@ class RecipeController(private val recipeRepository: RecipeRepository) {
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
|
||||
@GetMapping("/recipe/{dietUserId}")
|
||||
@GetMapping("/recipe/user/{dietUserId}")
|
||||
fun getByDietUserId(@PathVariable dietUserId: Long): ResponseEntity<List<Recipe>> {
|
||||
val list = recipeRepository.findByDietUserId(dietUserId)
|
||||
return if (list == null) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
|
||||
@GetMapping("/recipe/meal/{mealId}")
|
||||
fun getByMealId(@PathVariable mealId: Long): ResponseEntity<List<Recipe>> {
|
||||
val list = recipeRepository.findByMealId(mealId)
|
||||
return if (list == null) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(list)
|
||||
}
|
||||
|
||||
@GetMapping("/recipe/name/{name}")
|
||||
fun getByName(@PathVariable name: String): ResponseEntity<List<Recipe>> {
|
||||
val list = recipeRepository.findByName(name)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.aitrainer.api.model
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import jakarta.persistence.*
|
||||
import org.springframework.lang.NonNull
|
||||
|
||||
@Entity
|
||||
data class OpenAI (
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @get: NonNull var id: Long = 0,
|
||||
@Expose @get: NonNull var question: String,
|
||||
@Expose @get: NonNull var modelName: String? = null,
|
||||
@Expose @get: NonNull var temperature: Double? = null,
|
||||
)
|
||||
@@ -1,27 +1,19 @@
|
||||
package com.aitrainer.api.model.diet
|
||||
|
||||
import com.google.gson.annotations.Expose
|
||||
import jakarta.persistence.*
|
||||
import org.hibernate.annotations.Fetch
|
||||
import org.hibernate.annotations.FetchMode
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@Entity
|
||||
data class Diet (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose val dietId: Long = 0,
|
||||
|
||||
@Expose @get: NotNull val dietUserId: Long = 0,
|
||||
|
||||
@Expose @get: NotNull val dietText: String = "",
|
||||
|
||||
@Expose @get: NotNull val monday: String = "",
|
||||
|
||||
@Expose @get: NotNull val tuesday: String = "",
|
||||
|
||||
@Expose @get: NotNull val wednesday: String = "",
|
||||
|
||||
@Expose @get: NotNull val thursday: String = "",
|
||||
|
||||
@Expose @get: NotNull val friday: String = "",
|
||||
|
||||
@Expose @get: NotNull val saturday: String = "",
|
||||
|
||||
@Expose @get: NotNull val sunday: String = ""
|
||||
)
|
||||
@Expose @get: NotNull val startDate: String = "",
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "diet")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
@Expose val meals: MutableList<DietMeal> = mutableListOf()
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.aitrainer.api.model.diet
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore
|
||||
import com.google.gson.annotations.Expose
|
||||
import jakarta.persistence.*
|
||||
import org.jetbrains.annotations.NotNull
|
||||
|
||||
@Entity
|
||||
data class DietMeal (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose val id: Long = 0,
|
||||
//@Expose @get: NotNull val dietId: Long = 0,
|
||||
@Expose @get: NotNull val mealName: String = "",
|
||||
@Expose @get: NotNull val meal: String = "",
|
||||
) {
|
||||
@ManyToOne(fetch = FetchType.EAGER, optional = false)
|
||||
@JoinColumn(name = "dietId", nullable = false)
|
||||
@JsonIgnore
|
||||
var diet: Diet? = null
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import org.jetbrains.annotations.NotNull
|
||||
data class DietRawMaterial (
|
||||
@Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Expose val id: Long = 0,
|
||||
|
||||
@Expose @get: NotNull val dietId: Long = 0,
|
||||
@Expose @get: NotNull val dietMealId: Long = 0,
|
||||
@Expose @get: NotNull val rawMaterialId: Long = 0,
|
||||
@Expose @get: NotNull val name: String = "",
|
||||
@Expose @get: NotNull val kcalMin: Int = 0,
|
||||
|
||||
@@ -19,6 +19,7 @@ data class Recipe (
|
||||
@Expose @get: NotNull val fat: Double = 0.0,
|
||||
@Expose @get: NotNull val ch: Double = 0.0,
|
||||
@Expose @get: NotNull val dietUserId: Long = 0,
|
||||
@Expose @get: NotNull val mealId: Long = 0,
|
||||
) {
|
||||
@OneToMany(cascade = [(CascadeType.ALL)], fetch = FetchType.EAGER, mappedBy = "recipe")
|
||||
@Fetch(value = FetchMode.SUBSELECT)
|
||||
|
||||
@@ -3,13 +3,15 @@ package com.aitrainer.api.openai
|
||||
import com.aallam.openai.client.OpenAI
|
||||
import com.aallam.openai.api.completion.CompletionRequest
|
||||
import com.aallam.openai.api.completion.TextCompletion
|
||||
import com.aallam.openai.api.logging.LogLevel
|
||||
import com.aallam.openai.api.model.Model
|
||||
import com.aallam.openai.api.model.ModelId
|
||||
import com.aallam.openai.client.OpenAIConfig
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.Properties
|
||||
|
||||
class OpenAIService {
|
||||
class OpenAIService(private val modelName: String?, private val temperature: Double?) {
|
||||
|
||||
|
||||
private var openAI: OpenAI? = null
|
||||
@@ -24,7 +26,11 @@ class OpenAIService {
|
||||
|
||||
private var modelId: ModelId? = null
|
||||
private suspend fun connect(modelName: String) {
|
||||
openAI = OpenAI(properties.getProperty("openai.key"))
|
||||
val config = OpenAIConfig(
|
||||
token = properties.getProperty("openai.key"),
|
||||
logLevel = LogLevel.All
|
||||
)
|
||||
openAI = OpenAI(config)
|
||||
modelId = ModelId(modelName)
|
||||
model = openAI!!.model(modelId!!)
|
||||
|
||||
@@ -32,22 +38,46 @@ class OpenAIService {
|
||||
|
||||
suspend fun completion(question: String): String {
|
||||
return withContext(Dispatchers.IO) {
|
||||
if (openAI == null) {
|
||||
connect("text-davinci-003")
|
||||
var realModelName = "text-davinci-003"
|
||||
if ( modelName != null) {
|
||||
realModelName = modelName
|
||||
}
|
||||
var realTemperature = 0.1
|
||||
if ( temperature != null ) {
|
||||
realTemperature = temperature
|
||||
}
|
||||
if (openAI == null) {
|
||||
connect(realModelName)
|
||||
}
|
||||
println("OpenAI Question: $question")
|
||||
val completionRequest = CompletionRequest(
|
||||
model = modelId!!,
|
||||
prompt = question,
|
||||
//echo = true,
|
||||
maxTokens = 128,
|
||||
temperature=0.1,
|
||||
maxTokens = 2048 - question.length,
|
||||
temperature=realTemperature,
|
||||
)
|
||||
val completion: TextCompletion = openAI!!.completion(completionRequest)
|
||||
val result = completion.choices[0].text
|
||||
|
||||
//println("Completion: $result")
|
||||
val result = completion.choices[0].text
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun getModels(): MutableList<String> {
|
||||
return withContext(Dispatchers.IO) {
|
||||
if (openAI == null) {
|
||||
openAI = OpenAI(token = properties.getProperty("openai.key"))
|
||||
}
|
||||
|
||||
val list: MutableList<String> = mutableListOf()
|
||||
openAI!!.models().forEach {
|
||||
println(it)
|
||||
list.add(it.id.id)
|
||||
}
|
||||
|
||||
return@withContext list
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,5 +6,5 @@ import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface DietRawMaterialRepository : JpaRepository<DietRawMaterial, Long> {
|
||||
fun findByDietId(dietId: Long): List<DietRawMaterial>
|
||||
fun findByDietMealId(dietMealId: Long): List<DietRawMaterial>
|
||||
}
|
||||
@@ -2,9 +2,13 @@ package com.aitrainer.api.repository.diet
|
||||
|
||||
import com.aitrainer.api.model.diet.Diet
|
||||
import org.springframework.data.jpa.repository.JpaRepository
|
||||
import org.springframework.data.jpa.repository.Query
|
||||
import org.springframework.stereotype.Repository
|
||||
|
||||
@Repository
|
||||
interface DietRepository : JpaRepository<Diet, Long> {
|
||||
fun findByDietUserId(dietUserId: Long): List<Diet>
|
||||
|
||||
@Query(" FROM Diet WHERE dietId = :dietId")
|
||||
fun findByDietId(dietId: Long): Diet?
|
||||
}
|
||||
@@ -9,6 +9,10 @@ interface RecipeRepository : JpaRepository<Recipe, Int> {
|
||||
fun findByName(name: String): List<Recipe>?
|
||||
|
||||
fun findByDietUserId(dietUserId: Long): List<Recipe>?
|
||||
|
||||
@Query(" FROM Recipe WHERE recipeId = :recipeId")
|
||||
fun findByRecipeId(recipeId: Long): Recipe?
|
||||
|
||||
@Query(" FROM Recipe WHERE mealId = :mealId")
|
||||
fun findByMealId(mealId: Long): List<Recipe>?
|
||||
}
|
||||
|
||||
@@ -2,18 +2,22 @@ package com.aitrainer.api.service
|
||||
|
||||
import com.aitrainer.api.model.firebase_response.SignupResponse
|
||||
import com.google.gson.Gson
|
||||
import org.json.JSONObject
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.stereotype.Service
|
||||
import java.net.URI
|
||||
import java.net.http.HttpClient
|
||||
import java.net.http.HttpRequest
|
||||
import java.net.http.HttpResponse
|
||||
import java.nio.charset.StandardCharsets
|
||||
import org.json.JSONObject
|
||||
import java.util.*
|
||||
|
||||
class Firebase {
|
||||
private val apiKey: String = "AIzaSyCUXBWV3_qzvV__ZWZA1siHftrrJpjDKh4"
|
||||
@Service
|
||||
class Firebase(@Value("\${firebase.key}") private val apiKey: String) {
|
||||
private val firebaseBaseUrl: String = "https://identitytoolkit.googleapis.com/v1/accounts"
|
||||
var statusCode: Int = 0
|
||||
var error: String = ""
|
||||
|
||||
fun signUp(email: String, password: String): SignupResponse? {
|
||||
|
||||
val json = JSONObject()
|
||||
@@ -42,6 +46,7 @@ class Firebase {
|
||||
}
|
||||
|
||||
private fun call(command: String, postData: String): String {
|
||||
val apiKey = this.apiKey
|
||||
val url = URI.create("$firebaseBaseUrl:$command?key=$apiKey")
|
||||
|
||||
// Create the HTTP request object
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#spring.config.activate.on-profile=dev,test,prod,prodtest
|
||||
spring.config.use-legacy-processing = true
|
||||
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
|
||||
#spring.datasource.url = jdbc:mysql://localhost:3306/aitrainer?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
|
||||
spring.datasource.url = jdbc:mysql://localhost:3306/diet4you?serverTimezone=CET&useSSL=false&characterEncoding=UTF-8&allowMultiQueries=true
|
||||
spring.datasource.username = aitrainer
|
||||
spring.datasource.password = ENC(WZplPYr8WmrLHshesY4T6oXplK3MlUVJ)
|
||||
|
||||
|
||||
## Hibernate Properties
|
||||
|
||||
|
||||
# The SQL dialect makes Hibernate generate better SQL for the chosen database
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
|
||||
|
||||
logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.2.0
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
openai.key=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
|
||||
firebase.key=AIzaSyBLn7Bz73Z1hB-OhqphBDsskOyGmpI7J8E
|
||||
spring.mail.properties.mail.mime.charset=UTF-8
|
||||
@@ -0,0 +1,22 @@
|
||||
spring.config.activate.on-profile=dietprod
|
||||
spring.config.use-legacy-processing = true
|
||||
|
||||
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
|
||||
spring.datasource.url = jdbc:mysql://mariadb-shared.db.svc.cluster.local:3306/diet4you?serverTimezone=CET&useSSL=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true&allowMultiQueries=true
|
||||
spring.datasource.username = aitrainer
|
||||
spring.datasource.password = ENC(WZplPYr8WmrLHshesY4T6oXplK3MlUVJ)
|
||||
|
||||
# The SQL dialect makes Hibernate generate better SQL for the chosen database
|
||||
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQLDialect
|
||||
|
||||
|
||||
logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.0
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
firebase.key=AIzaSyCUXBWV3_qzvV__ZWZA1siHftrrJpjDKh4
|
||||
openai.key=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
|
||||
@@ -16,4 +16,7 @@ logging.file=logs
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.0
|
||||
|
||||
jwt.secret=aitrainer
|
||||
jwt.secret=aitrainer
|
||||
|
||||
firebase.key=AIzaSyCUXBWV3_qzvV__ZWZA1siHftrrJpjDKh4
|
||||
openai.key=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
|
||||
@@ -23,3 +23,4 @@ jwt.secret=aitrainer
|
||||
|
||||
openai.key=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
|
||||
spring.mail.properties.mail.mime.charset=UTF-8
|
||||
firebase.key=AIzaSyCUXBWV3_qzvV__ZWZA1siHftrrJpjDKh4
|
||||
@@ -65,6 +65,9 @@ class AppCustomerPackageTest {
|
||||
@Autowired
|
||||
private lateinit var dietUserSensitivityRepository: DietUserSensitivityRepository
|
||||
|
||||
@Autowired
|
||||
private lateinit var customerConversationRepository: CustomerConversationRepository
|
||||
|
||||
@Test
|
||||
fun dietCustomerPackageTest() {
|
||||
val gson = Gson()
|
||||
@@ -84,7 +87,8 @@ class AppCustomerPackageTest {
|
||||
dietUserConsumptionRepository,
|
||||
dietUserRepository,
|
||||
dietUserPreferenceRepository,
|
||||
dietUserSensitivityRepository
|
||||
dietUserSensitivityRepository,
|
||||
customerConversationRepository
|
||||
)
|
||||
|
||||
val response = controller.getDietCustomerPackageData(2)
|
||||
@@ -103,8 +107,8 @@ class AppCustomerPackageTest {
|
||||
val dietJson: String = record[1]
|
||||
val type = object : TypeToken<List<Diet?>?>() {}.type
|
||||
val list: List<Diet> = gson.fromJson(dietJson, type)
|
||||
assertEquals(list[0].monday, "Monday meal")
|
||||
assertEquals(list[0].dietText, "Test diet text")
|
||||
assertEquals(list[0].meals[0].mealName, "monday|breakfast")
|
||||
}
|
||||
|
||||
record[0] == DietRawMaterial::class.simpleName -> {
|
||||
@@ -169,7 +173,8 @@ class AppCustomerPackageTest {
|
||||
dietUserConsumptionRepository,
|
||||
dietUserRepository,
|
||||
dietUserPreferenceRepository,
|
||||
dietUserSensitivityRepository
|
||||
dietUserSensitivityRepository,
|
||||
customerConversationRepository
|
||||
)
|
||||
|
||||
val response = controller.getCustomerClubPackageData(90)
|
||||
@@ -224,7 +229,8 @@ class AppCustomerPackageTest {
|
||||
dietUserConsumptionRepository,
|
||||
dietUserRepository,
|
||||
dietUserPreferenceRepository,
|
||||
dietUserSensitivityRepository )
|
||||
dietUserSensitivityRepository,
|
||||
customerConversationRepository)
|
||||
|
||||
var response: ResponseEntity<*> = controller.getCustomerPackageData(91)
|
||||
assertEquals(response.statusCode, HttpStatus.NOT_FOUND)
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.post
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.content
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.status
|
||||
|
||||
@@ -61,16 +62,7 @@ class CustomerConversationTest {
|
||||
mockMvc.perform(get("/api/customer_conversation/123")
|
||||
.header("Authorization", "Bearer $authToken"))
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(content().json("""
|
||||
[
|
||||
{
|
||||
"id": 1,
|
||||
"customerId": 123,
|
||||
"conversationDate": "2022-01-01 10:10:10",
|
||||
"question": "What's up?",
|
||||
"answer": "Not much."
|
||||
}
|
||||
]
|
||||
""".trimIndent()))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.[0].customerId").value(123))
|
||||
.andExpect(MockMvcResultMatchers.jsonPath("$.[0].answer").value("Not much."))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.HttpHeaders
|
||||
@@ -245,10 +246,10 @@ class CustomerTests {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testClubRegistration() {
|
||||
fun testClubRegistration(@Value("\${firebase.key}") apiKey: String) {
|
||||
val json = "{\"firstname\":\"Tib\", \"email\": \"mr@andio.biz\", \"goal\": \"shape\", \"fitnessLevel\": \"advanced\", \"weight\": 85}"
|
||||
val controller = CustomerController(customerRepository)
|
||||
val response: ResponseEntity<*> = controller.clubRegistration(json)
|
||||
val response: ResponseEntity<*> = controller.clubRegistration(json, apiKey)
|
||||
assertEquals(response.statusCode, HttpStatus.BAD_REQUEST)
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.aitrainer.api.service.Firebase
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.springframework.beans.factory.annotation.Value
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertTrue
|
||||
@@ -16,11 +17,12 @@ class FirebaseTest {
|
||||
|
||||
@BeforeAll
|
||||
fun tearUp() {
|
||||
this.firebase = Firebase()
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAuth() {
|
||||
fun testAuth(@Value("\${firebase.key}") apiKey: String) {
|
||||
this.firebase = Firebase(apiKey)
|
||||
val email = "user@exemple.com"
|
||||
val password = "verystrictpassword1"
|
||||
val signupResponse = firebase.signUp(email, password)
|
||||
|
||||
@@ -28,7 +28,7 @@ class DietRawMaterialTest {
|
||||
private lateinit var mockMvc: MockMvc
|
||||
|
||||
private val dietRawMaterial = DietRawMaterial(
|
||||
dietId = 1,
|
||||
dietMealId = 1,
|
||||
rawMaterialId = 10,
|
||||
name = "Tükörtojás",
|
||||
kcalMin = 70,
|
||||
@@ -60,17 +60,13 @@ class DietRawMaterialTest {
|
||||
.content(toJson(dietRawMaterial))
|
||||
)
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.dietId").value(1))
|
||||
.andExpect(jsonPath("$.dietMealId").value(1))
|
||||
.andExpect(jsonPath("$.rawMaterialId").value(10))
|
||||
.andExpect(jsonPath("$.proteinMax").value(25))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `get dietRawMaterial list by dietId id successfully`() {
|
||||
|
||||
// Act & Assert
|
||||
mockMvc.perform(get("/api/diet_raw_material/{dietId}", 1)
|
||||
mockMvc.perform(get("/api/diet_raw_material/{dietMealId}", 1)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.aitrainer.api.test.diet
|
||||
|
||||
import com.aitrainer.api.model.diet.Diet
|
||||
import com.aitrainer.api.model.diet.DietMeal
|
||||
import com.aitrainer.api.test.Tokenizer
|
||||
import com.google.gson.Gson
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
@@ -13,6 +14,7 @@ import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.MvcResult
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers.*
|
||||
@@ -31,13 +33,6 @@ class DietTest {
|
||||
private val diet = Diet(
|
||||
dietUserId = 1,
|
||||
dietText = "Test diet text",
|
||||
monday = "Monday meal",
|
||||
tuesday = "Tuesday meal",
|
||||
wednesday = "Wednesday meal",
|
||||
thursday = "Thursday meal",
|
||||
friday = "Friday meal",
|
||||
saturday = "Saturday meal",
|
||||
sunday = "Sunday meal"
|
||||
)
|
||||
|
||||
private var authToken: String? = ""
|
||||
@@ -50,10 +45,8 @@ class DietTest {
|
||||
|
||||
@Test
|
||||
fun `insert diet successfully`() {
|
||||
// Arrange
|
||||
//given(dietRepository.save(diet)).willReturn(diet)
|
||||
|
||||
mockMvc.perform(
|
||||
val mvcResult: MvcResult = mockMvc.perform(
|
||||
MockMvcRequestBuilders.post("/api/diet")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
@@ -61,16 +54,49 @@ class DietTest {
|
||||
)
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.dietUserId").value(1))
|
||||
.andReturn()
|
||||
|
||||
}
|
||||
val gson= Gson()
|
||||
val newDietJson = mvcResult.response.contentAsString
|
||||
val newDiet = gson.fromJson(newDietJson, Diet::class.java)
|
||||
|
||||
@Test
|
||||
fun `get diet list by dietUserId id successfully`() {
|
||||
mockMvc.perform(get("/api/diet/{dietUserId}", 1)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.[0].monday").value("Monday meal"))
|
||||
.andExpect(jsonPath("$.[0].dietText").value("Test diet text"))
|
||||
|
||||
val meal = DietMeal(
|
||||
mealName = "monday|breakfast",
|
||||
meal = "Főtt tojás"
|
||||
)
|
||||
val meal2 = DietMeal(
|
||||
mealName = "monday|lunch",
|
||||
meal = "Disznópörkölt"
|
||||
)
|
||||
val meal3 = DietMeal(
|
||||
mealName = "monday|lunch",
|
||||
meal = "Savanyúkáposzta"
|
||||
)
|
||||
|
||||
newDiet.meals.add(meal)
|
||||
newDiet.meals.add(meal2)
|
||||
newDiet.meals.add(meal3)
|
||||
|
||||
//update
|
||||
mockMvc.perform(
|
||||
MockMvcRequestBuilders.post("/api/diet/${newDiet.dietId}")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.content(toJson(newDiet))
|
||||
)
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.dietUserId").value(1))
|
||||
.andExpect(jsonPath("$.meals[0].meal").value("Főtt tojás"))
|
||||
.andExpect(jsonPath("$.meals[1].mealName").value("monday|lunch"))
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private fun toJson(obj: Any): String {
|
||||
|
||||
@@ -38,6 +38,7 @@ class RecipeTest {
|
||||
fat = 56.0,
|
||||
ch = 23.0,
|
||||
dietUserId = 4,
|
||||
mealId = 0
|
||||
)
|
||||
private val recipe2 = Recipe(
|
||||
name = "Mákos tészta",
|
||||
@@ -46,7 +47,7 @@ class RecipeTest {
|
||||
protein = 19.0,
|
||||
fat = 30.0,
|
||||
ch = 78.0,
|
||||
dietUserId = 4,
|
||||
dietUserId = 4
|
||||
)
|
||||
private val recipe3 = Recipe(
|
||||
|
||||
@@ -57,6 +58,7 @@ class RecipeTest {
|
||||
fat = 30.0,
|
||||
ch = 34.0,
|
||||
dietUserId = 1,
|
||||
mealId = 1
|
||||
)
|
||||
|
||||
private var authToken: String? = ""
|
||||
@@ -154,7 +156,7 @@ class RecipeTest {
|
||||
|
||||
|
||||
// Act & Assert
|
||||
mockMvc.perform(get("/api/recipe/4")
|
||||
mockMvc.perform(get("/api/recipe/user/4")
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk)
|
||||
@@ -163,7 +165,6 @@ class RecipeTest {
|
||||
.andExpect(jsonPath("$.[0].rawMaterials.[1].rawMaterialId").value(3))
|
||||
|
||||
|
||||
// Act & Assert
|
||||
mockMvc.perform(get("/api/recipe/name/leves")
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
@@ -172,6 +173,13 @@ class RecipeTest {
|
||||
.andExpect(jsonPath("$.[1].name").value("Borsóleves"))
|
||||
.andExpect(jsonPath("$.[0].rawMaterials.[1].rawMaterialId").value(3))
|
||||
|
||||
// GET by User ID
|
||||
mockMvc.perform(get("/api/recipe/meal/1")
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.[0].name").value("Borsóleves"))
|
||||
|
||||
}
|
||||
|
||||
private fun toJson(obj: Any): String {
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.aitrainer.api.test.openai
|
||||
|
||||
import com.aitrainer.api.model.OpenAI
|
||||
import com.aitrainer.api.test.Tokenizer
|
||||
import com.google.gson.Gson
|
||||
import org.junit.jupiter.api.BeforeAll
|
||||
import org.junit.jupiter.api.Test
|
||||
import org.junit.jupiter.api.TestInstance
|
||||
import org.junit.jupiter.api.extension.ExtendWith
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
|
||||
import org.springframework.boot.test.context.SpringBootTest
|
||||
import org.springframework.http.MediaType
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension
|
||||
import org.springframework.test.web.servlet.MockMvc
|
||||
import org.springframework.test.web.servlet.request.MockMvcRequestBuilders
|
||||
import org.springframework.test.web.servlet.result.MockMvcResultMatchers
|
||||
|
||||
|
||||
@ExtendWith(SpringExtension::class)
|
||||
@SpringBootTest
|
||||
@AutoConfigureMockMvc
|
||||
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
|
||||
class OpenAITest {
|
||||
|
||||
@Autowired
|
||||
private lateinit var mockMvc: MockMvc
|
||||
|
||||
private var authToken: String? = ""
|
||||
|
||||
@BeforeAll
|
||||
fun initTest() {
|
||||
authToken = Tokenizer.getToken()
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun `get a question successfully`() {
|
||||
val question = "Who the f. is Alice?"
|
||||
|
||||
mockMvc.perform(
|
||||
MockMvcRequestBuilders.get("/api/openai/completion")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.content(question)
|
||||
)
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
//.andExpect(MockMvcResultMatchers.content().string("Sorry I dont know"))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `get a question successfully with model name`() {
|
||||
val question = "Who the f. is Alice? Who sing that song?"
|
||||
val openai = OpenAI(
|
||||
question = question,
|
||||
modelName = "text-ada-001",
|
||||
temperature = 0.5
|
||||
)
|
||||
mockMvc.perform(
|
||||
MockMvcRequestBuilders.post("/api/openai/completion_with_model")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.content(toJson(openai))
|
||||
)
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
//.andExpect(MockMvcResultMatchers.content().string("Sorry I dont know"))
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `get models successfully`() {
|
||||
mockMvc.perform(
|
||||
MockMvcRequestBuilders.get("/api/openai/list_models")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
)
|
||||
.andExpect(MockMvcResultMatchers.status().isOk)
|
||||
}
|
||||
|
||||
private fun toJson(obj: Any): String {
|
||||
return Gson().toJson(obj)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user