| 
					
				 | 
			
			
				@@ -51,18 +51,18 @@ class PlatformController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             val found = platformRepository.findByName(platform.name, project)!!.size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             val foundProject = projectRepository.findById(project.toLong()).isPresent 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (platform.name.isNotBlank()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (!foundProject) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (!foundProject) {//project not found 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Platform>(HttpStatus.NOT_FOUND) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else if (platform.name.length > 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (platform.name.length > 100) {//too long 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Platform>(HttpStatus.PAYLOAD_TOO_LARGE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                } else if (found > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (found > 0) {//duplicate 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Platform>(HttpStatus.CONFLICT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     platform.project_id = projectRepository.findById(project.toLong()).get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     val savePlatform: Platform = platformRepository.save(platform) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Platform>(savePlatform, HttpStatus.CREATED) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else {//invalid name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ResponseEntity<Platform>(HttpStatus.BAD_REQUEST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } catch (e: Exception) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -71,34 +71,36 @@ class PlatformController( 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PutMapping("/platforms/{id}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    fun updatePlatformById(@PathVariable("id") id: Long, @RequestBody platform: PlatformInput): Any { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        val platformData: Optional<Platform?> = platformRepository.findById(id) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        val found = platformRepository.findByName(platform.name, platform.project_id.toString())!!.size 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        val foundProject = projectRepository.findById(platform.project_id!!.toLong()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        return if (platform.name!!.isNotBlank()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (platform.name!!.length > 100) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    fun updatePlatformById(@PathVariable("id") id: Long, @RequestBody input: PlatformInput): Any { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val targetProject = projectRepository.findById(input.project_id!!.toLong())//target project 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        val platformExist = platformRepository.findById(id)//exist data 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return if (input.name!!.isNotBlank()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (input.name!!.length > 100) {//too long 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ResponseEntity<Platform>(HttpStatus.PAYLOAD_TOO_LARGE) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else if (foundProject.isEmpty) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                println(1) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else if (targetProject.isEmpty || platformExist.isEmpty) {//target project not found 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 ResponseEntity<Platform>(HttpStatus.NOT_FOUND) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else if (platformData.isPresent) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                println(2) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (((platform.name == platformData.get().name && found > 0) || (platform.name !== platformData.get().name && found == 0))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    println(3) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    val savePlatform: Platform = platformData.get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    savePlatform.project_id = foundProject.get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    savePlatform.name = platform.name!! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    ResponseEntity<Platform>(platformRepository.save(savePlatform), HttpStatus.OK) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                val savePlatform = platformExist.get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                savePlatform.project_id = targetProject.get() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                savePlatform.name = input.name!! 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (input.project_id.toString() !== platformExist.get().project_id.toString()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    val check = platformRepository.findByName(input.name, input.project_id.toString()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (check!!.isNotEmpty()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ResponseEntity<Platform>(HttpStatus.CONFLICT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ResponseEntity<Platform>(platformRepository.save(savePlatform), HttpStatus.OK) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } else if (input.name !== platformExist.get().name) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (targetProject.isEmpty) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ResponseEntity<Platform>(platformRepository.save(savePlatform), HttpStatus.OK) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        ResponseEntity<Platform>(HttpStatus.CONFLICT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    println(4) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     ResponseEntity<Platform>(HttpStatus.CONFLICT) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                println(5) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                ResponseEntity<Platform>(HttpStatus.NOT_FOUND) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            println(6) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } else {//invalid name 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             ResponseEntity<Platform>(HttpStatus.BAD_REQUEST) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 |