This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> readJsonArrayFile(filePath: String): List<Map<*, *>?>? { | |
val mapper = ObjectMapper() | |
//val readFileAsString = readFileAsString(filePath) | |
//println(readFileAsString) | |
val myObjects = mapper.readValue(File(filePath), object : TypeReference<List<Map<*, *>?>>() {}) | |
// for (obj in myObjects) { | |
// println(obj) | |
// } | |
return myObjects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun readDataFromCsv(filePath: String): List<List<String>?> { | |
var csvList: MutableList<List<String>?> = mutableListOf() | |
val csv = java.io.File(filePath) | |
try { | |
BufferedReader(FileReader(csv)).use { br -> | |
var line: String? | |
while (br.readLine().also { line = it } != null) { | |
//println("line $line") | |
val split: List<String>? = line?.split(",") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val fetch = queryFactory.listQuery<Song> { | |
select(entity(Song::class)) | |
from(entity(Song::class)) | |
fetch(Song::album, JoinType.LEFT) | |
offset(pageable.offset.toInt()) | |
limit(pageable.pageSize) | |
where( | |
isSongSearchable(searchCondition, Song::deletedAt) | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
@DisplayName("s3파일 업로드 테스트") | |
fun s3FileUploadTest(){ | |
val imgPath = "src/main/resources/static/img" | |
val mockFile:MultipartFile = MockMultipartFile( | |
"test1", | |
"test1.png", | |
"image/png", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration(proxyBeanMethods = false) | |
class BeanRegistry : ApplicationContextAware { | |
companion object { | |
private lateinit var applicationContext: ApplicationContext | |
// 타입으로 빈을 가져옵니다 | |
fun <T : Any> getBean(type: KClass<T>): T = | |
applicationContext.getBean(type.java) | |
// 이름과 타입으로 빈을 가져옵니다 | |
fun <T : Any> getBean(name: String, type: KClass<T>): T = |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Transactional | |
fun saveCategory(dto:CategorySaveReq, idAncestor: Long?): Category? { | |
val category = categoryRepository.saveCategory(dto.toEntity()) | |
categoryRepository.saveCategoryClosure(category?.id!!, idAncestor ) | |
return category | |
} | |
override fun saveCategoryClosure(idDescendant: Long, idAncestor: Long?) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let rds = { | |
monUiCtl: [], | |
isRun: false, | |
ctlUIStart: function (idx, ch) { | |
console.log("ctlUIStart????", idx, ch); | |
this.monUiCtl[idx].value.changeLayout( | |
1, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
fun pathParsingTest() { | |
val path = "/v1/members" | |
log.info { | |
path.split(delimiters = arrayOf("/"," ")).filter { it.isNotEmpty() }.forEach { | |
println(" $it ") | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@org.springframework.web.bind.annotation.RestControllerAdvice | |
class RestControllerAdvice<T>( | |
) : ResponseBodyAdvice<T>{ | |
private val log = KotlinLogging.logger { } | |
override fun supports(returnType: MethodParameter, converterType: Class<out HttpMessageConverter<*>>): Boolean { | |
//log.info { "returnType: $returnType" } | |
return true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun convertPojoToUrlEncodedFormData(obj: Any?): String { | |
/** | |
* 간단한 함수 input + output 테스트를 위하므로, ObjectMapper를 의존성 주입시키지 않겠다.(스프링과는 독립적인) | |
* util function들은 최대한 의존성 없이 | |
* | |
*/ | |
val map: Map<*, *>? = ObjectMapper().convertValue(obj, Map::class.java) |
OlderNewer