v1.2.9.10 diet_user.macro
This commit is contained in:
parent
acc914f170
commit
8d45635684
@ -11,7 +11,7 @@ plugins {
|
||||
}
|
||||
|
||||
group = "com.aitrainer"
|
||||
version = "1.2.9"
|
||||
version = "1.2.10"
|
||||
java.sourceCompatibility = JavaVersion.VERSION_17
|
||||
|
||||
repositories {
|
||||
|
7
data/db/update_1_2_10.sql
Normal file
7
data/db/update_1_2_10.sql
Normal file
@ -0,0 +1,7 @@
|
||||
START TRANSACTION;
|
||||
|
||||
ALTER TABLE `diet_user` ADD COLUMN `macro` char(255) NULL;
|
||||
|
||||
UPDATE configuration set config_value = "1.2.10", date_change=CURRENT_DATE WHERE config_key = "db_version";
|
||||
|
||||
COMMIT;
|
@ -21,4 +21,11 @@ class DietUserController(private val dietUserRepository: DietUserRepository) {
|
||||
return if (dietUser == null) ResponseEntity.notFound().build() else
|
||||
ResponseEntity.ok().body(dietUser)
|
||||
}
|
||||
|
||||
@PostMapping("/diet_user/{customerId}")
|
||||
fun updateCustomer(@PathVariable customerId: Long, @RequestBody dietUser: DietUser): ResponseEntity<DietUser> {
|
||||
dietUserRepository.findByCustomerId(customerId) ?: return ResponseEntity.notFound().build()
|
||||
val changedUser = dietUserRepository.save(dietUser)
|
||||
return ResponseEntity.ok().body(changedUser)
|
||||
}
|
||||
}
|
@ -10,5 +10,6 @@ import javax.validation.constraints.NotNull
|
||||
@Entity
|
||||
data class DietUser(
|
||||
@Expose @Id @GeneratedValue(strategy = GenerationType.IDENTITY) var dietUserId: Long = 0,
|
||||
@Expose @get: NotNull val customerId: Long
|
||||
@Expose @get: NotNull val customerId: Long,
|
||||
@Expose @get: NotNull var macro: String = "",
|
||||
)
|
@ -16,7 +16,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.2.9
|
||||
application.version=1.2.10
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
@ -14,7 +14,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.9
|
||||
application.version=1.2.10
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
@ -14,7 +14,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structue has been changed, increment this version number
|
||||
application.version=1.2.9
|
||||
application.version=1.2.10
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
@ -17,7 +17,7 @@ logging.config=classpath:logback-spring.xml
|
||||
logging.file=logs
|
||||
|
||||
# if the database structure has been changed, increment this version number
|
||||
application.version=1.2.9
|
||||
application.version=1.2.10
|
||||
|
||||
jwt.secret=aitrainer
|
||||
|
||||
|
@ -50,6 +50,21 @@ class DietUserTest {
|
||||
.contentType(MediaType.APPLICATION_JSON))
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.customerId").value(1))
|
||||
|
||||
dietUser.macro = "Test macro"
|
||||
mockMvc.perform(post("/api/diet_user/999")
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(gson.toJson(dietUser)))
|
||||
.andExpect(status().isNotFound)
|
||||
|
||||
mockMvc.perform(post("/api/diet_user/${dietUser.customerId}")
|
||||
.header("Authorization", "Bearer $authToken")
|
||||
.contentType(MediaType.APPLICATION_JSON)
|
||||
.content(gson.toJson(dietUser)))
|
||||
.andExpect(status().isOk)
|
||||
.andExpect(jsonPath("$.customerId").value(1))
|
||||
.andExpect(jsonPath("$.macro").value("Test macro"))
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user