-
Notifications
You must be signed in to change notification settings - Fork 505
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
162 additions
and
56 deletions.
There are no files selected for viewing
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
50 changes: 50 additions & 0 deletions
50
...repository/src/main/kotlin/com/tencent/devops/repository/pojo/oauth/RepositoryScmToken.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. | ||
* | ||
* A copy of the MIT License is included in this file. | ||
* | ||
* | ||
* Terms of the MIT License: | ||
* --------------------------------------------------- | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
* the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.tencent.devops.repository.pojo.oauth | ||
|
||
import com.fasterxml.jackson.annotation.JsonProperty | ||
import io.swagger.v3.oas.annotations.media.Schema | ||
|
||
@Schema(title = "Token模型") | ||
data class RepositoryScmToken( | ||
@get:Schema(title = "鉴权token") | ||
@JsonProperty("access_token") | ||
var userId: String = "", | ||
@get:Schema(title = "代码库类型") | ||
var scmCode: String = "", | ||
@get:Schema(title = "应用类型") | ||
var appType: String = "", | ||
@get:Schema(title = "鉴权token") | ||
var accessToken: String = "", | ||
@get:Schema(title = "刷新token") | ||
var refreshToken: String = "", | ||
@get:Schema(title = "过期时间") | ||
val expiresIn: Long = 0L, | ||
@get:Schema(title = "创建时间") | ||
val createTime: Long? = 0L | ||
) |
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
87 changes: 87 additions & 0 deletions
87
...biz-repository/src/main/kotlin/com/tencent/devops/repository/dao/RepositoryScmTokenDao.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* | ||
* Tencent is pleased to support the open source community by making BK-CI 蓝鲸持续集成平台 available. | ||
* | ||
* Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. | ||
* | ||
* BK-CI 蓝鲸持续集成平台 is licensed under the MIT license. | ||
* | ||
* A copy of the MIT License is included in this file. | ||
* | ||
* | ||
* Terms of the MIT License: | ||
* --------------------------------------------------- | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated | ||
* documentation files (the "Software"), to deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to | ||
* permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of | ||
* the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT | ||
* LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
* NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE | ||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
*/ | ||
|
||
package com.tencent.devops.repository.dao | ||
|
||
import com.tencent.devops.model.repository.tables.TRepositoryScmToken | ||
import com.tencent.devops.model.repository.tables.records.TRepositoryScmTokenRecord | ||
import com.tencent.devops.repository.pojo.oauth.RepositoryScmToken | ||
import org.jooq.DSLContext | ||
import org.springframework.stereotype.Repository | ||
import java.time.LocalDateTime | ||
|
||
@Repository | ||
class RepositoryScmTokenDao { | ||
fun getToken( | ||
dslContext: DSLContext, | ||
userId: String, | ||
scmCode: String, | ||
appType: String | ||
): TRepositoryScmTokenRecord? { | ||
with(TRepositoryScmToken.T_REPOSITORY_SCM_TOKEN) { | ||
return dslContext.selectFrom(this) | ||
.where( | ||
USER_ID.eq(userId) | ||
.and(SCM_CODE.eq(scmCode)) | ||
.and( | ||
APP_TYPE.eq(appType) | ||
) | ||
) | ||
.fetchOne() | ||
} | ||
} | ||
|
||
fun saveAccessToken(dslContext: DSLContext, scmToken: RepositoryScmToken): Int { | ||
with(TRepositoryScmToken.T_REPOSITORY_SCM_TOKEN) { | ||
return dslContext.insertInto( | ||
this, | ||
USER_ID, | ||
SCM_CODE, | ||
APP_TYPE, | ||
ACCESS_TOKEN, | ||
REFRESH_TOKEN, | ||
EXPIRES_IN, | ||
CREATE_TIME | ||
) | ||
.values( | ||
scmToken.userId, | ||
scmToken.scmCode, | ||
scmToken.appType, | ||
scmToken.accessToken, | ||
scmToken.refreshToken, | ||
scmToken.expiresIn, | ||
LocalDateTime.now() | ||
) | ||
.onDuplicateKeyUpdate() | ||
.set(ACCESS_TOKEN, scmToken.accessToken) | ||
.set(REFRESH_TOKEN, scmToken.refreshToken) | ||
.set(EXPIRES_IN, scmToken.expiresIn) | ||
.set(UPDATE_TIME, LocalDateTime.now()) | ||
.execute() | ||
} | ||
} | ||
} |
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
35 changes: 0 additions & 35 deletions
35
support-files/sql/2004_v3.x/2030_ci_repository-update_v3.0_mysql.sql
This file was deleted.
Oops, something went wrong.