|
@@ -18,10 +18,12 @@ import java.text.SimpleDateFormat
|
|
|
import java.util.*
|
|
|
import kotlin.Any
|
|
|
import kotlin.Boolean
|
|
|
+import kotlin.RuntimeException
|
|
|
import kotlin.String
|
|
|
import kotlin.Throws
|
|
|
import kotlin.Unit
|
|
|
import kotlin.arrayOf
|
|
|
+import kotlin.enumValues
|
|
|
import kotlin.toString
|
|
|
|
|
|
|
|
@@ -45,242 +47,289 @@ class MaintenanceController(
|
|
|
// if (valid == 0) {
|
|
|
// ResponseEntity<Any>(HttpStatus.FORBIDDEN)
|
|
|
// } else {
|
|
|
- if (!tableList.contains(tableName) || tableName.isEmpty()) {
|
|
|
- ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
- } else {
|
|
|
+ if (!tableList.contains(tableName) || tableName.isEmpty()) {
|
|
|
+ ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
+ } else {
|
|
|
|
|
|
- val list = when (tableName) {
|
|
|
- "user" -> userRepository.findAll()
|
|
|
- "project" -> projectRepository.findAll().map {
|
|
|
- ProjectOutput(
|
|
|
- id = it.id, name = it.name, description = it.description, owner = it.owner!!.id.toString()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- "platform" -> platformRepository.findAll().map {
|
|
|
- PlatformOutput(
|
|
|
- id = it.id, name = it.name, project = it.project!!.id.toString()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- "project_member" -> memberRepository.findAll().map {
|
|
|
- MemberOutput(
|
|
|
- id = it.id,
|
|
|
- project = it.project!!.id.toString(),
|
|
|
- user = it.user!!.id.toString(),
|
|
|
- role = Enum.Member.values()[it.role].ordinal.toString()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- "bug" -> bugRepository.findAll().map {
|
|
|
- BugOutput(
|
|
|
- id = it.id,
|
|
|
- created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
- description = it.description,
|
|
|
- qc = it.qc!!.id.toString(),
|
|
|
- dev = it.dev!!.id.toString(),
|
|
|
- platform = it.platform!!.id.toString(),
|
|
|
- goodday_url = it.goodday_url,
|
|
|
- image_url = it.image_url,
|
|
|
- level = Enum.Level.values()[it.level].ordinal.toString(),
|
|
|
- status = Enum.Status.values()[it.status].ordinal.toString(),
|
|
|
- dev_status = Enum.Dev_Status.values()[it.dev_status].ordinal.toString()
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- "comment" -> commentRepository.findAll().map {
|
|
|
- CommentOutput(
|
|
|
- id = it.id,
|
|
|
- bug = it.bug!!.id.toString(),
|
|
|
- creator = it.creator!!.id.toString(),
|
|
|
- created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
- content = it.content
|
|
|
- )
|
|
|
- }
|
|
|
-
|
|
|
- else -> listOf()
|
|
|
- }
|
|
|
- val csvHeader = when (tableName) {
|
|
|
- "user" -> arrayOf("User ID", "Username", "Password", "Name")
|
|
|
- "project" -> arrayOf("Project ID", "Description", "Name", "Owner")
|
|
|
- "platform" -> arrayOf("Platform ID", "Name", "Project")
|
|
|
- "project_member" -> arrayOf("Member ID", "Role", "Project", "User")
|
|
|
- "comment" -> arrayOf("Bug ID", "Content", "Created", "Bug", "Creator")
|
|
|
- "bug" -> arrayOf(
|
|
|
- "Bug ID",
|
|
|
- "created",
|
|
|
- "Description",
|
|
|
- "Dev Status",
|
|
|
- "Goodday Url",
|
|
|
- "Image Url",
|
|
|
- "Level",
|
|
|
- "Status",
|
|
|
- "Dev",
|
|
|
- "Platform",
|
|
|
- "Qc"
|
|
|
+ val list = when (tableName) {
|
|
|
+ "user" -> userRepository.findAll()
|
|
|
+ "project" -> projectRepository.findAll().map {
|
|
|
+ ProjectOutput(
|
|
|
+ id = it.id, name = it.name, description = it.description, owner = it.owner!!.id.toString()
|
|
|
)
|
|
|
+ }
|
|
|
|
|
|
- else -> arrayOf()
|
|
|
+ "platform" -> platformRepository.findAll().map {
|
|
|
+ PlatformOutput(
|
|
|
+ id = it.id, name = it.name, project = it.project!!.id.toString()
|
|
|
+ )
|
|
|
}
|
|
|
- val nameMapping = when (tableName) {
|
|
|
- "user" -> arrayOf("id", "username", "password", "name")
|
|
|
- "project" -> arrayOf("id", "description", "name", "owner")
|
|
|
- "platform" -> arrayOf("id", "name", "project")
|
|
|
- "project_member" -> arrayOf("id", "role", "project", "user")
|
|
|
- "comment" -> arrayOf("id", "content", "created", "bug", "creator")
|
|
|
- "bug" -> arrayOf(
|
|
|
- "id",
|
|
|
- "created",
|
|
|
- "description",
|
|
|
- "dev_status",
|
|
|
- "goodday_url",
|
|
|
- "image_url",
|
|
|
- "level",
|
|
|
- "status",
|
|
|
- "dev",
|
|
|
- "platform",
|
|
|
- "qc"
|
|
|
+
|
|
|
+ "project_member" -> memberRepository.findAll().map {
|
|
|
+ MemberOutput(
|
|
|
+ id = it.id,
|
|
|
+ project = it.project!!.id.toString(),
|
|
|
+ user = it.user!!.id.toString(),
|
|
|
+ role = Enum.Member.values()[it.role].ordinal.toString()
|
|
|
)
|
|
|
+ }
|
|
|
|
|
|
- else -> arrayOf()
|
|
|
+ "bug" -> bugRepository.findAll().map {
|
|
|
+ BugOutput(
|
|
|
+ id = it.id,
|
|
|
+ created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
+ description = it.description,
|
|
|
+ qc = it.qc!!.id.toString(),
|
|
|
+ dev = it.dev!!.id.toString(),
|
|
|
+ platform = it.platform!!.id.toString(),
|
|
|
+ goodday_url = it.goodday_url,
|
|
|
+ image_url = it.image_url,
|
|
|
+ level = Enum.Level.values()[it.level].ordinal.toString(),
|
|
|
+ status = Enum.Status.values()[it.status].ordinal.toString(),
|
|
|
+ dev_status = Enum.Dev_Status.values()[it.dev_status].ordinal.toString()
|
|
|
+ )
|
|
|
}
|
|
|
- val csvWriter: ICsvBeanWriter = CsvBeanWriter(response.writer, CsvPreference.STANDARD_PREFERENCE)
|
|
|
- csvWriter.writeHeader(*csvHeader)
|
|
|
- for (table in list) {
|
|
|
- csvWriter.write(table, *nameMapping)
|
|
|
+
|
|
|
+ "comment" -> commentRepository.findAll().map {
|
|
|
+ CommentOutput(
|
|
|
+ id = it.id,
|
|
|
+ bug = it.bug!!.id.toString(),
|
|
|
+ creator = it.creator!!.id.toString(),
|
|
|
+ created = SimpleDateFormat("dd-MMM-yy HH:mm:ss").format(it.created),
|
|
|
+ content = it.content
|
|
|
+ )
|
|
|
}
|
|
|
- csvWriter.close()
|
|
|
+
|
|
|
+ else -> listOf()
|
|
|
+ }
|
|
|
+ val csvHeader = when (tableName) {
|
|
|
+ "user" -> arrayOf("User ID", "Username", "Password", "Name")
|
|
|
+ "project" -> arrayOf("Project ID", "Description", "Name", "Owner")
|
|
|
+ "platform" -> arrayOf("Platform ID", "Name", "Project")
|
|
|
+ "project_member" -> arrayOf("Member ID", "Role", "Project", "User")
|
|
|
+ "comment" -> arrayOf("Bug ID", "Content", "Created", "Bug", "Creator")
|
|
|
+ "bug" -> arrayOf(
|
|
|
+ "Bug ID",
|
|
|
+ "created",
|
|
|
+ "Description",
|
|
|
+ "Dev Status",
|
|
|
+ "Goodday Url",
|
|
|
+ "Image Url",
|
|
|
+ "Level",
|
|
|
+ "Status",
|
|
|
+ "Dev",
|
|
|
+ "Platform",
|
|
|
+ "Qc"
|
|
|
+ )
|
|
|
+
|
|
|
+ else -> arrayOf()
|
|
|
+ }
|
|
|
+ val nameMapping = when (tableName) {
|
|
|
+ "user" -> arrayOf("id", "username", "password", "name")
|
|
|
+ "project" -> arrayOf("id", "description", "name", "owner")
|
|
|
+ "platform" -> arrayOf("id", "name", "project")
|
|
|
+ "project_member" -> arrayOf("id", "role", "project", "user")
|
|
|
+ "comment" -> arrayOf("id", "content", "created", "bug", "creator")
|
|
|
+ "bug" -> arrayOf(
|
|
|
+ "id",
|
|
|
+ "created",
|
|
|
+ "description",
|
|
|
+ "dev_status",
|
|
|
+ "goodday_url",
|
|
|
+ "image_url",
|
|
|
+ "level",
|
|
|
+ "status",
|
|
|
+ "dev",
|
|
|
+ "platform",
|
|
|
+ "qc"
|
|
|
+ )
|
|
|
+
|
|
|
+ else -> arrayOf()
|
|
|
+ }
|
|
|
+ val csvWriter: ICsvBeanWriter = CsvBeanWriter(response.writer, CsvPreference.STANDARD_PREFERENCE)
|
|
|
+ csvWriter.writeHeader(*csvHeader)
|
|
|
+ for (table in list) {
|
|
|
+ csvWriter.write(table, *nameMapping)
|
|
|
+ }
|
|
|
+ csvWriter.close()
|
|
|
// }
|
|
|
}
|
|
|
//todo multi / zip download?
|
|
|
}
|
|
|
|
|
|
+ @ResponseStatus(HttpStatus.BAD_REQUEST)
|
|
|
+ internal class Error : RuntimeException("oxes")
|
|
|
+
|
|
|
@PostMapping("/maintenance")
|
|
|
- fun import(@RequestParam file: MultipartFile, @RequestParam tableName: String, @RequestParam overwrite: Boolean) {
|
|
|
+ fun import(
|
|
|
+ @RequestParam file: MultipartFile, @RequestParam tableName: String, @RequestParam overwrite: Boolean
|
|
|
+ ): ResponseEntity<Any> {
|
|
|
val userId = userRepository.getUserByUsername(SecurityContextHolder.getContext().authentication.name)
|
|
|
val valid = memberRepository.validAdmin(userId.id.toString())
|
|
|
val tableList = listOf("project", "platform", "user", "project_member", "bug", "comment")
|
|
|
// if (valid == 0) {
|
|
|
// ResponseEntity<Any>(HttpStatus.FORBIDDEN)
|
|
|
// } else {
|
|
|
- if (!tableList.contains(tableName) || tableName.isEmpty()) {
|
|
|
- ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
- } else {
|
|
|
- val nameMapping = when (tableName) {
|
|
|
- "user" -> arrayOf("id", "username", "password", "name")
|
|
|
- "project" -> arrayOf("id", "description", "name", "owner")
|
|
|
- "platform" -> arrayOf("id", "name", "project")
|
|
|
- "project_member" -> arrayOf("id", "role", "project", "user")
|
|
|
- "comment" -> arrayOf("id", "content", "created", "bug", "creator")
|
|
|
- "bug" -> arrayOf(
|
|
|
- "id",
|
|
|
- "created",
|
|
|
- "description",
|
|
|
- "dev_status",
|
|
|
- "goodday_url",
|
|
|
- "image_url",
|
|
|
- "level",
|
|
|
- "status",
|
|
|
- "dev",
|
|
|
- "platform",
|
|
|
- "qc"
|
|
|
- )
|
|
|
+ var found = 0
|
|
|
+ val mapData: MutableList<MutableMap<String, Any>> = mutableListOf()
|
|
|
+ if (!tableList.contains(tableName) || tableName.isEmpty()) {
|
|
|
+ ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
+ } else {
|
|
|
+ val nameMapping = when (tableName) {
|
|
|
+ "user" -> arrayOf("id", "username", "password", "name")
|
|
|
+ "project" -> arrayOf("id", "description", "name", "owner")
|
|
|
+ "platform" -> arrayOf("id", "name", "project")
|
|
|
+ "project_member" -> arrayOf("id", "role", "project", "user")
|
|
|
+ "comment" -> arrayOf("id", "content", "created", "bug", "creator")
|
|
|
+ "bug" -> arrayOf(
|
|
|
+ "id",
|
|
|
+ "created",
|
|
|
+ "description",
|
|
|
+ "dev_status",
|
|
|
+ "goodday_url",
|
|
|
+ "image_url",
|
|
|
+ "level",
|
|
|
+ "status",
|
|
|
+ "dev",
|
|
|
+ "platform",
|
|
|
+ "qc"
|
|
|
+ )
|
|
|
|
|
|
- else -> arrayOf()
|
|
|
- }
|
|
|
- val content = String(file.bytes)
|
|
|
- val lines = content.lines()
|
|
|
- val mapData: MutableList<MutableMap<String, Any>> = mutableListOf()
|
|
|
- lines.forEachIndexed { ind, t ->
|
|
|
- if (ind == 0 && arrayOf(t) !== nameMapping) {
|
|
|
- ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
- } else if (t !== "" && ind > 0) {
|
|
|
- val commas = t.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)".toRegex()).toTypedArray()
|
|
|
- val map: MutableMap<String, Any> = mutableMapOf()
|
|
|
- nameMapping.forEachIndexed { index, s ->
|
|
|
- map[s] = commas[index]
|
|
|
- }
|
|
|
- mapData.add(map)
|
|
|
+ else -> arrayOf()
|
|
|
+ }
|
|
|
+ val content = String(file.bytes)
|
|
|
+ val lines = content.lines()
|
|
|
+ lines.forEachIndexed { ind, t ->
|
|
|
+ if (ind == 0 && arrayOf(t) !== nameMapping) {
|
|
|
+ ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
+ } else if (t !== "" && ind > 0) {
|
|
|
+ val commas = t.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)".toRegex()).toTypedArray()
|
|
|
+ val map: MutableMap<String, Any> = mutableMapOf()
|
|
|
+ nameMapping.forEachIndexed { index, s ->
|
|
|
+ map[s] = commas[index]
|
|
|
}
|
|
|
+ mapData.add(map)
|
|
|
}
|
|
|
- val existing = when (tableName) {
|
|
|
- "project" -> projectRepository.getId()
|
|
|
- "platform" -> platformRepository.getId()
|
|
|
- "user" -> userRepository.getId()
|
|
|
- "project_member" -> memberRepository.getId()
|
|
|
- "bug" -> bugRepository.getId()
|
|
|
- "comment" -> commentRepository.getId()
|
|
|
- else -> listOf()
|
|
|
+ }
|
|
|
+ val existing = when (tableName) {
|
|
|
+ "project" -> projectRepository.getId()
|
|
|
+ "platform" -> platformRepository.getId()
|
|
|
+ "user" -> userRepository.getId()
|
|
|
+ "project_member" -> memberRepository.getId()
|
|
|
+ "bug" -> bugRepository.getId()
|
|
|
+ "comment" -> commentRepository.getId()
|
|
|
+ else -> listOf()
|
|
|
+ }
|
|
|
+ mapData.removeIf { p -> existing.contains(p["id"].toString().toLong()) && !overwrite }
|
|
|
+ val check = when (tableName) {
|
|
|
+ "project" -> mapData.forEach {
|
|
|
+ val owner = userRepository.findById(it["owner"].toString().toLong()).orElseThrow { Error() }
|
|
|
}
|
|
|
- mapData.removeIf { p -> existing.contains(p["id"].toString().toLong()) && !overwrite }
|
|
|
- val unit = when (tableName) {
|
|
|
- "project" -> mapData.forEach {
|
|
|
- val save = Project()
|
|
|
- save.id = it["id"].toString().toLong()
|
|
|
- save.name = it["name"].toString()
|
|
|
- save.description = it["description"].toString()
|
|
|
- save.owner = userRepository.findById(it["owner"].toString().toLong()).get()
|
|
|
- projectRepository.save(save)
|
|
|
- }
|
|
|
|
|
|
- "user" -> mapData.forEach {
|
|
|
- val save = jacksonObjectMapper().readValue(
|
|
|
- jacksonObjectMapper().writeValueAsString(it), User::class.java
|
|
|
- )
|
|
|
- userRepository.save(save)
|
|
|
- }
|
|
|
+ "platform" -> mapData.forEach {
|
|
|
+ val project = projectRepository.findById(it["project"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ }
|
|
|
|
|
|
- "platform" -> mapData.forEach {
|
|
|
- val save = Platform()
|
|
|
- save.id = it["id"].toString().toLong()
|
|
|
- save.name = it["name"].toString()
|
|
|
- save.project = projectRepository.findById(it["project"].toString().toLong()).get()
|
|
|
- platformRepository.save(save)
|
|
|
- }
|
|
|
+ "project_member" -> mapData.forEachIndexed { _, m ->
|
|
|
+ found += if (!enumValues<Enum.Member>().any {
|
|
|
+ it.ordinal.toString() == m["role"].toString()
|
|
|
+ }) 1 else 0
|
|
|
+ val project = projectRepository.findById(m["project"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ val user = userRepository.findById(m["user"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ }
|
|
|
|
|
|
- "project_member" -> mapData.forEach {
|
|
|
- val save = ProjectMember()
|
|
|
- save.id = it["id"].toString().toLong()
|
|
|
- save.role = Enum.Member.values()[Integer.parseInt(it["role"].toString())].ordinal
|
|
|
- save.project = projectRepository.findById(it["project"].toString().toLong()).get()
|
|
|
- save.user = userRepository.findById(it["user"].toString().toLong()).get()
|
|
|
- memberRepository.save(save)
|
|
|
- }
|
|
|
+ "comment" -> mapData.forEach {
|
|
|
+ val bug = bugRepository.findById(it["bug"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ val creator = userRepository.findById(it["creator"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ }
|
|
|
|
|
|
- "comment" -> mapData.forEach {
|
|
|
- val save = Comment()
|
|
|
- save.id = it["id"].toString().toLong()
|
|
|
- save.content = it["content"].toString()
|
|
|
- save.created =
|
|
|
- SimpleDateFormat("dd-MMM-yy HH:mm:ss", Locale.ENGLISH).parse(it["created"].toString())
|
|
|
- save.bug = bugRepository.findById(it["bug"].toString().toLong()).get()
|
|
|
- save.creator = userRepository.findById(it["creator"].toString().toLong()).get()
|
|
|
- commentRepository.save(save)
|
|
|
- }
|
|
|
+ "bug" -> mapData.forEachIndexed { _, m ->
|
|
|
+ found += if (!enumValues<Enum.Level>().any {
|
|
|
+ it.ordinal.toString() == m["level"].toString()
|
|
|
+ } || !enumValues<Enum.Status>().any {
|
|
|
+ it.ordinal.toString() == m["status"].toString()
|
|
|
+ } || !enumValues<Enum.Dev_Status>().any { it.ordinal.toString() == m["dev_status"].toString() }) 1 else 0
|
|
|
+ val dev = userRepository.findById(m["dev"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ val platform =
|
|
|
+ platformRepository.findById(m["platform"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ val qc = userRepository.findById(m["qc"].toString().toLong()).orElseThrow { Error() }
|
|
|
+ }
|
|
|
|
|
|
- "bug" -> mapData.forEach {
|
|
|
- val save = Bug()
|
|
|
- save.id = it["id"].toString().toLong()
|
|
|
- save.created =
|
|
|
- SimpleDateFormat("dd-MMM-yy HH:mm:ss", Locale.ENGLISH).parse(it["created"].toString())
|
|
|
- save.description = it["description"].toString()
|
|
|
- save.dev_status =
|
|
|
- Enum.Dev_Status.values()[Integer.parseInt(it["dev_status"].toString())].ordinal
|
|
|
- save.goodday_url = it["goodday_url"].toString()
|
|
|
- save.image_url = it["image_url"].toString()
|
|
|
- save.level = Enum.Level.values()[Integer.parseInt(it["level"].toString())].ordinal
|
|
|
- save.status = Enum.Status.values()[Integer.parseInt(it["status"].toString())].ordinal
|
|
|
- save.dev = userRepository.findById(it["dev"].toString().toLong()).get()
|
|
|
- save.platform = platformRepository.findById(it["platform"].toString().toLong()).get()
|
|
|
- save.qc = userRepository.findById(it["qc"].toString().toLong()).get()
|
|
|
- bugRepository.save(save)
|
|
|
- }
|
|
|
+ else -> Unit
|
|
|
+ }
|
|
|
+ }
|
|
|
+ val project = Project()
|
|
|
+ val platform = Platform()
|
|
|
+ var user = User()
|
|
|
+ val member = ProjectMember()
|
|
|
+ val comment = Comment()
|
|
|
+ val bug = Bug()
|
|
|
+ if (found == 0) {
|
|
|
+ val unit = when (tableName) {
|
|
|
+ "project" -> mapData.forEach {
|
|
|
+ project.id = it["id"].toString().toLong()
|
|
|
+ project.name = it["name"].toString()
|
|
|
+ project.description = it["description"].toString()
|
|
|
+ project.owner = userRepository.findById(it["owner"].toString().toLong()).get()
|
|
|
+ }
|
|
|
|
|
|
- else -> Unit
|
|
|
+ "user" -> mapData.forEach {
|
|
|
+ user = jacksonObjectMapper().readValue(
|
|
|
+ jacksonObjectMapper().writeValueAsString(it), User::class.java
|
|
|
+ )
|
|
|
}
|
|
|
- ResponseEntity<Any>(HttpStatus.OK)
|
|
|
-// }
|
|
|
+
|
|
|
+ "platform" -> mapData.forEach {
|
|
|
+ platform.id = it["id"].toString().toLong()
|
|
|
+ platform.name = it["name"].toString()
|
|
|
+ platform.project = projectRepository.findById(it["project"].toString().toLong()).get()
|
|
|
+ }
|
|
|
+
|
|
|
+ "project_member" -> mapData.forEach {
|
|
|
+ member.id = it["id"].toString().toLong()
|
|
|
+ member.role = Enum.Member.values()[Integer.parseInt(it["role"].toString())].ordinal
|
|
|
+ member.project = projectRepository.findById(it["project"].toString().toLong()).get()
|
|
|
+ member.user = userRepository.findById(it["user"].toString().toLong()).get()
|
|
|
+ }
|
|
|
+
|
|
|
+ "comment" -> mapData.forEach {
|
|
|
+ comment.id = it["id"].toString().toLong()
|
|
|
+ comment.content = it["content"].toString()
|
|
|
+ comment.created =
|
|
|
+ SimpleDateFormat("dd-MMM-yy HH:mm:ss", Locale.ENGLISH).parse(it["created"].toString())
|
|
|
+ comment.bug = bugRepository.findById(it["bug"].toString().toLong()).get()
|
|
|
+ comment.creator = userRepository.findById(it["creator"].toString().toLong()).get()
|
|
|
+ }
|
|
|
+
|
|
|
+ "bug" -> mapData.forEach {
|
|
|
+ bug.id = it["id"].toString().toLong()
|
|
|
+ bug.created = SimpleDateFormat("dd-MMM-yy HH:mm:ss", Locale.ENGLISH).parse(it["created"].toString())
|
|
|
+ bug.description = it["description"].toString()
|
|
|
+ bug.dev_status = Enum.Dev_Status.values()[Integer.parseInt(it["dev_status"].toString())].ordinal
|
|
|
+ bug.goodday_url = it["goodday_url"].toString()
|
|
|
+ bug.image_url = it["image_url"].toString()
|
|
|
+ bug.level = Enum.Level.values()[Integer.parseInt(it["level"].toString())].ordinal
|
|
|
+ bug.status = Enum.Status.values()[Integer.parseInt(it["status"].toString())].ordinal
|
|
|
+ bug.dev = userRepository.findById(it["dev"].toString().toLong()).get()
|
|
|
+ bug.platform = platformRepository.findById(it["platform"].toString().toLong()).get()
|
|
|
+ bug.qc = userRepository.findById(it["qc"].toString().toLong()).get()
|
|
|
+ }
|
|
|
+
|
|
|
+ else -> Unit
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (found == 0) {
|
|
|
+ when (tableName) {
|
|
|
+ "project" -> projectRepository.save(project)
|
|
|
+ "platform" -> platformRepository.save(platform)
|
|
|
+ "project_member" -> memberRepository.save(member)
|
|
|
+ "user" -> userRepository.save(user)
|
|
|
+ "comment" -> commentRepository.save(comment)
|
|
|
+ "bug" -> bugRepository.save(bug)
|
|
|
+ else -> Unit
|
|
|
+ }
|
|
|
}
|
|
|
+ return if (found == 0) ResponseEntity<Any>(HttpStatus.OK) else ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
|
|
|
}
|
|
|
}
|
|
|
|