ArchitectureReceiveControllerImpl.kt
/*
Copyright (C) 2026 Sber
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
In any derivative products, you must retain the information of
owner of the original code and provide clear attribution to the project
https://dochub.info
The use of this product or its derivatives for any purpose cannot be a secret.
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Maintainers:
Alexander Romashin <romashin.a.va@sberbank.ru>, Sber - 2026
Contributors:
Alexander Romashin <romashin.a.va@sberbank.ru>, Sber - 2026
Sergeev Viktor <sergeevviktor017@gmail.com>, Sber - 2026
Марат Ниязматов <mrusniyazmatov@sberbank.ru>, Sber - 2026
*/
package org.archtool.controller
import org.archtool.data.dto.ArchitectureSendResponse
import org.archtool.service.FileUploadToGitService
import org.slf4j.Logger
import org.slf4j.LoggerFactory
import org.springframework.http.codec.multipart.FilePart
import org.springframework.http.codec.multipart.FormFieldPart
import org.springframework.web.bind.annotation.RestController
import java.util.UUID
import org.archtool.service.dto.UploadRequest
@RestController
class ArchitectureReceiveControllerImpl(
private val fileUploadToGitService: FileUploadToGitService,
) : ArchitectureReceiveController {
override suspend fun receiveArchitecture(
processIdPart: FormFieldPart,
repoUrlPart: FormFieldPart,
subPart: FormFieldPart,
emailPart: FormFieldPart?,
namePart: FormFieldPart,
surnamePart: FormFieldPart,
branchNamePart: FormFieldPart?,
filePart: FilePart,
checksum: String
): ArchitectureSendResponse {
val branchName = branchNamePart?.value()?.takeIf { it.isNotBlank() }
val requestId = UUID.randomUUID()
val processId = processIdPart.value()
val repoUrl = repoUrlPart.value()
val sub = subPart.value()
val name = namePart.value()
val surname = surnamePart.value()
val email = emailPart?.value()
log.debug(
"Приём архитектуры: processId={}, repoUrl={}, sub={}, name={}, surname={}, email={}, branchName={}, checksum={}, requestId={}",
processId, repoUrl, sub, name, surname, email, branchName, checksum, requestId
)
return fileUploadToGitService.uploadArchive(
UploadRequest(
processId = processId,
repoUrl = repoUrl,
userData = UploadRequest.UserData(
sub = sub,
email = email,
name = name,
surname = surname,
),
filePart = filePart,
checksum = checksum,
branchName = branchName,
commitMessage = "Новая архитектура проекта $processId от $name $surname ($sub)",
),
)
}
companion object {
val log: Logger = LoggerFactory.getLogger(ArchitectureReceiveControllerImpl::class.java)
}
}