athrainsky 8 месяцев назад
Родитель
Сommit
56f467181c

+ 31 - 0
qodana.yaml

@@ -0,0 +1,31 @@
+#-------------------------------------------------------------------------------#
+#               Qodana analysis is configured by qodana.yaml file               #
+#             https://www.jetbrains.com/help/qodana/qodana-yaml.html            #
+#-------------------------------------------------------------------------------#
+version: "1.0"
+
+#Specify inspection profile for code analysis
+profile:
+  name: qodana.starter
+
+#Enable inspections
+#include:
+#  - name: <SomeEnabledInspectionId>
+
+#Disable inspections
+#exclude:
+#  - name: <SomeDisabledInspectionId>
+#    paths:
+#      - <path/where/not/run/inspection>
+
+projectJDK: 20 #(Applied in CI/CD pipeline)
+
+#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
+#bootstrap: sh ./prepare-qodana.sh
+
+#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
+#plugins:
+#  - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
+
+#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
+linter: jetbrains/qodana-jvm-community:latest

+ 0 - 38
src/main/kotlin/com/swagger/rest/controllers/MaintenanceController.kt

@@ -17,7 +17,6 @@ import java.text.SimpleDateFormat
 import java.util.*
 import kotlin.Any
 import kotlin.Boolean
-import kotlin.ByteArray
 import kotlin.RuntimeException
 import kotlin.String
 import kotlin.Throws
@@ -46,12 +45,7 @@ class MaintenanceController(
     @GetMapping("/maintenance", produces = ["text/csv;charset=utf8;"])
     @Throws(IOException::class)
     fun exportToCSV(response: HttpServletResponse, @RequestParam tableName: String): ResponseEntity<*> {
-//        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()) {
             return ResponseEntity<Any>(HttpStatus.BAD_REQUEST)
         } else {
@@ -99,13 +93,7 @@ class MaintenanceController(
             csvContent.append("${csvHeader.joinToString("")}\n")
             csvContent.append(list.joinToString("\n"))
             val headers = HttpHeaders()
-//            headers.contentType = MediaType.APPLICATION_OCTET_STREAM
-//            headers.setContentDispositionFormData("attachment", "$tableName.csv")
-//            val fileName  = String(tableName.toByteArray(), charset("ISO8859-1"))
-//            headers["content-disposition"] = "attachment;filename=$fileName.csv"
-//            response.addHeader(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=$tableName.csv")
             response.contentType = MediaType.APPLICATION_OCTET_STREAM.toString()
-//            response.addHeade
             response.addHeader(
                 HttpHeaders.CONTENT_DISPOSITION,
                 "attachment; filename=$tableName.csv"
@@ -115,28 +103,7 @@ class MaintenanceController(
             response.outputStream.close()
 
             return ResponseEntity("ok", HttpStatus.OK)
-//            return ResponseEntity(csvContent, headers, HttpStatus.OK)
-
-//            val cacheResultHandler = CacheDataManager()
-//            val inputStream: InputStream
-//            val byteArray: ByteArray
-//            val httpHeaders = HttpHeaders()
-//            val inputStreamResource: InputStreamResource = cacheResultHandler.exportCacheResults(response)
-//            httpHeaders[HttpHeaders.CONTENT_DISPOSITION] = "attachment; filename=$tableName.csv"
-            //convert inputStream to bytes
-//            inputStream = inputStreamResource.inputStream
-//            val buffer = ByteArrayOutputStream()
-//            var nRead: Int
-//            val data = ByteArray(1024)
-//            while ((inputStream.read(data, 0, data.size).also { nRead = it }) != -1) {
-//                buffer.write(data, 0, nRead)
-//            }
-//            buffer.flush()
-//            byteArray = buffer.toByteArray()
-//            httpHeaders.contentLength = byteArray.size.toLong()
-//            return ResponseEntity(byteArray, httpHeaders, HttpStatus.OK)
         }
-//        return ResponseEntity<Any>(HttpStatus.INTERNAL_SERVER_ERROR)
     }
 
     @ResponseStatus(HttpStatus.BAD_REQUEST)
@@ -146,12 +113,7 @@ class MaintenanceController(
     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 {
         var found = 0
         val mapData: MutableList<MutableMap<String, Any>> = mutableListOf()
         if (!tableList.contains(tableName) || tableName.isEmpty()) {

+ 3 - 5
src/main/kotlin/com/swagger/rest/models/Enum.kt

@@ -1,7 +1,5 @@
 package com.swagger.rest.models
 
-import java.util.*
-
 class Enum {
 
     enum class Member {
@@ -9,14 +7,14 @@ class Enum {
     }
 
     enum class Level {
-        NOTE, MINOR, MAJOR, UNDEFINED
+        NOTE, MINOR, MAJOR, MODERATE, UNDEFINED;
     }
 
     enum class Status {
-        ONPROGRESS, DONE, HOLD, CANCEL, UNDEFINED
+        ONPROGRESS, DONE, HOLD, CANCEL, UNDEFINED;
     }
 
     enum class Dev_Status {
-        NOTSTART, ONPROGRESS, DONE, UNDEFINED
+        NOTSTART, ONPROGRESS, DONE, UNDEFINED;
     }
 }

+ 0 - 3
src/main/kotlin/com/swagger/rest/services/BugService.kt

@@ -84,9 +84,6 @@ class BugService {
                 memberRepository!!.validRoleByPlatform(bugInput.qc.toString(), bugInput.platform, 0.toString())
             val countDev =
                 memberRepository.validRoleByPlatform(bugInput.dev.toString(), bugInput.platform, 1.toString())
-//            if (bugInput.image_url == "") {
-//                bugInput.image_url = null.toString()
-//            }
             return if (countPlat > 0) {
                 if (!regex(bugInput.goodday_url.trim())) {
                     HttpStatus.BAD_REQUEST

+ 0 - 4
src/main/kotlin/com/swagger/rest/services/CommentService.kt

@@ -1,15 +1,11 @@
 package com.swagger.rest.services
 
-import com.swagger.rest.models.Bug
 import com.swagger.rest.models.Comment
 import com.swagger.rest.models.CommentInput
 import com.swagger.rest.repositories.BugRepository
 import com.swagger.rest.repositories.CommentRepository
 import com.swagger.rest.repositories.UserRepository
-import jakarta.persistence.criteria.Predicate
 import org.springframework.beans.factory.annotation.Autowired
-import org.springframework.data.jpa.domain.Specification
-import org.springframework.data.repository.findByIdOrNull
 import org.springframework.http.HttpStatus
 import org.springframework.security.core.context.SecurityContextHolder
 import org.springframework.stereotype.Service

+ 0 - 5
src/main/kotlin/com/swagger/rest/services/MyUserDetails.kt

@@ -8,11 +8,7 @@ import org.springframework.security.core.userdetails.UserDetails
 class MyUserDetails(private val user: User) : UserDetails {
 
     override fun getAuthorities(): Collection<GrantedAuthority?> {
-//        val roles: Set<Role> = user.roles
         val authorities: MutableList<SimpleGrantedAuthority?> = ArrayList()
-//        for (role in roles) {
-//            authorities.add(SimpleGrantedAuthority(role.name))
-//        }
         return authorities
     }
 
@@ -37,7 +33,6 @@ class MyUserDetails(private val user: User) : UserDetails {
     }
 
     override fun isEnabled(): Boolean {
-//        return user.isEnabled
         return true
     }
 }

+ 2 - 2
src/main/resources/application.properties

@@ -1,5 +1,5 @@
 spring.jpa.hibernate.ddl-auto=update
-spring.datasource.url=jdbc:mysql://localhost:3306/swagger2
+spring.datasource.url=jdbc:mysql://192.168.100.5:3306/swaggerabi
 spring.datasource.username=root
-spring.datasource.password=root
+spring.datasource.password=datacom
 spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect