feat: change appType to enum
This commit is contained in:
parent
a432ade3ec
commit
3e0e0f1c8e
|
@ -1,5 +1,6 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
@ -14,8 +15,8 @@ public class OAuthAppCreateRequest {
|
|||
@NotBlank
|
||||
private String appName;
|
||||
|
||||
@NotBlank
|
||||
private String appType;
|
||||
@NotNull
|
||||
private OAuthAppType appType;
|
||||
|
||||
private String appIcon;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -13,7 +14,7 @@ public class OAuthAppDetailResponse {
|
|||
|
||||
private String appIcon;
|
||||
|
||||
private String appType;
|
||||
private OAuthAppType appType;
|
||||
|
||||
private String registrationId;
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.Tables;
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.Data;
|
||||
import org.jooq.Condition;
|
||||
import org.jooq.impl.DSL;
|
||||
|
@ -13,7 +14,7 @@ public class OAuthAppPageCondition {
|
|||
|
||||
private String appNameContains;
|
||||
|
||||
private String appType;
|
||||
private OAuthAppType appType;
|
||||
|
||||
public Condition toCondition() {
|
||||
List<Condition> conditions = new ArrayList<>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -13,7 +14,7 @@ public class OAuthAppPageResponse {
|
|||
|
||||
private String appIcon;
|
||||
|
||||
private String appType;
|
||||
private OAuthAppType appType;
|
||||
|
||||
private String registrationId;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
|
@ -19,7 +20,7 @@ public class OAuthAppResponse {
|
|||
|
||||
private String appIcon;
|
||||
|
||||
private String appType;
|
||||
private OAuthAppType appType;
|
||||
|
||||
private String registrationId;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.databasir.core.domain.app.data;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
@ -17,8 +18,8 @@ public class OAuthAppUpdateRequest {
|
|||
@NotBlank
|
||||
private String appName;
|
||||
|
||||
@NotBlank
|
||||
private String appType;
|
||||
@NotNull
|
||||
private OAuthAppType appType;
|
||||
|
||||
private String appIcon;
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ public class GithubOpenAuthHandler implements OpenAuthHandler {
|
|||
private final GithubRemoteService githubRemoteService;
|
||||
|
||||
@Override
|
||||
public boolean support(String oauthAppType) {
|
||||
return OAuthAppType.GITHUB.isSame(oauthAppType);
|
||||
public boolean support(OAuthAppType oauthAppType) {
|
||||
return OAuthAppType.GITHUB == oauthAppType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -19,8 +19,8 @@ public class GitlabOpenAuthHandler implements OpenAuthHandler {
|
|||
private final GitlabRemoteService gitlabRemoteService;
|
||||
|
||||
@Override
|
||||
public boolean support(String oauthAppType) {
|
||||
return OAuthAppType.GITLAB.isSame(oauthAppType);
|
||||
public boolean support(OAuthAppType oauthAppType) {
|
||||
return OAuthAppType.GITLAB == oauthAppType;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
package com.databasir.core.domain.app.handler;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import com.databasir.dao.tables.pojos.OauthAppPojo;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface OpenAuthHandler {
|
||||
|
||||
boolean support(String oauthAppType);
|
||||
boolean support(OAuthAppType oauthAppType);
|
||||
|
||||
String authorizationUrl(OauthAppPojo app, Map<String, String[]> requestParams);
|
||||
|
||||
|
|
|
@ -60,6 +60,12 @@ jooq {
|
|||
includeExpression = '.*'
|
||||
includeTypes = 'INET'
|
||||
}
|
||||
forcedType {
|
||||
userType = 'com.databasir.dao.enums.OAuthAppType'
|
||||
converter = 'com.databasir.dao.converter.OAuthAppTypeConverter'
|
||||
includeExpression = 'app_type'
|
||||
includeTypes = '.*'
|
||||
}
|
||||
}
|
||||
}
|
||||
generate {
|
||||
|
|
|
@ -6,6 +6,8 @@ package com.databasir.dao.tables;
|
|||
|
||||
import com.databasir.dao.Databasir;
|
||||
import com.databasir.dao.Keys;
|
||||
import com.databasir.dao.converter.OAuthAppTypeConverter;
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import com.databasir.dao.tables.records.OauthAppRecord;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
@ -72,7 +74,7 @@ public class OauthApp extends TableImpl<OauthAppRecord> {
|
|||
/**
|
||||
* The column <code>databasir.oauth_app.app_type</code>. github, gitlab
|
||||
*/
|
||||
public final TableField<OauthAppRecord, String> APP_TYPE = createField(DSL.name("app_type"), SQLDataType.VARCHAR(64).nullable(false), this, "github, gitlab");
|
||||
public final TableField<OauthAppRecord, OAuthAppType> APP_TYPE = createField(DSL.name("app_type"), SQLDataType.VARCHAR(64).nullable(false), this, "github, gitlab", new OAuthAppTypeConverter());
|
||||
|
||||
/**
|
||||
* The column <code>databasir.oauth_app.client_id</code>.
|
||||
|
@ -193,7 +195,7 @@ public class OauthApp extends TableImpl<OauthAppRecord> {
|
|||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row12<Integer, String, String, String, String, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||
return (Row12) super.fieldsRow();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
package com.databasir.dao.tables.pojos;
|
||||
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
|
@ -20,7 +22,7 @@ public class OauthAppPojo implements Serializable {
|
|||
private String registrationId;
|
||||
private String appName;
|
||||
private String appIcon;
|
||||
private String appType;
|
||||
private OAuthAppType appType;
|
||||
private String clientId;
|
||||
private String clientSecret;
|
||||
private String authUrl;
|
||||
|
@ -51,7 +53,7 @@ public class OauthAppPojo implements Serializable {
|
|||
String registrationId,
|
||||
String appName,
|
||||
String appIcon,
|
||||
String appType,
|
||||
OAuthAppType appType,
|
||||
String clientId,
|
||||
String clientSecret,
|
||||
String authUrl,
|
||||
|
@ -133,14 +135,14 @@ public class OauthAppPojo implements Serializable {
|
|||
/**
|
||||
* Getter for <code>databasir.oauth_app.app_type</code>. github, gitlab
|
||||
*/
|
||||
public String getAppType() {
|
||||
public OAuthAppType getAppType() {
|
||||
return this.appType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Setter for <code>databasir.oauth_app.app_type</code>. github, gitlab
|
||||
*/
|
||||
public void setAppType(String appType) {
|
||||
public void setAppType(OAuthAppType appType) {
|
||||
this.appType = appType;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
package com.databasir.dao.tables.records;
|
||||
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import com.databasir.dao.tables.OauthApp;
|
||||
import com.databasir.dao.tables.pojos.OauthAppPojo;
|
||||
|
||||
|
@ -20,7 +21,7 @@ import org.jooq.impl.UpdatableRecordImpl;
|
|||
* oauth app info
|
||||
*/
|
||||
@SuppressWarnings({ "all", "unchecked", "rawtypes" })
|
||||
public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implements Record12<Integer, String, String, String, String, String, String, String, String, String, LocalDateTime, LocalDateTime> {
|
||||
public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implements Record12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
@ -83,15 +84,15 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
/**
|
||||
* Setter for <code>databasir.oauth_app.app_type</code>. github, gitlab
|
||||
*/
|
||||
public void setAppType(String value) {
|
||||
public void setAppType(OAuthAppType value) {
|
||||
set(4, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for <code>databasir.oauth_app.app_type</code>. github, gitlab
|
||||
*/
|
||||
public String getAppType() {
|
||||
return (String) get(4);
|
||||
public OAuthAppType getAppType() {
|
||||
return (OAuthAppType) get(4);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,12 +207,12 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public Row12<Integer, String, String, String, String, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() {
|
||||
return (Row12) super.fieldsRow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Row12<Integer, String, String, String, String, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() {
|
||||
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() {
|
||||
return (Row12) super.valuesRow();
|
||||
}
|
||||
|
||||
|
@ -236,7 +237,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public Field<String> field5() {
|
||||
public Field<OAuthAppType> field5() {
|
||||
return OauthApp.OAUTH_APP.APP_TYPE;
|
||||
}
|
||||
|
||||
|
@ -296,7 +297,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public String component5() {
|
||||
public OAuthAppType component5() {
|
||||
return getAppType();
|
||||
}
|
||||
|
||||
|
@ -356,7 +357,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public String value5() {
|
||||
public OAuthAppType value5() {
|
||||
return getAppType();
|
||||
}
|
||||
|
||||
|
@ -420,7 +421,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public OauthAppRecord value5(String value) {
|
||||
public OauthAppRecord value5(OAuthAppType value) {
|
||||
setAppType(value);
|
||||
return this;
|
||||
}
|
||||
|
@ -468,7 +469,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
}
|
||||
|
||||
@Override
|
||||
public OauthAppRecord values(Integer value1, String value2, String value3, String value4, String value5, String value6, String value7, String value8, String value9, String value10, LocalDateTime value11, LocalDateTime value12) {
|
||||
public OauthAppRecord values(Integer value1, String value2, String value3, String value4, OAuthAppType value5, String value6, String value7, String value8, String value9, String value10, LocalDateTime value11, LocalDateTime value12) {
|
||||
value1(value1);
|
||||
value2(value2);
|
||||
value3(value3);
|
||||
|
@ -498,7 +499,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
|
|||
/**
|
||||
* Create a detached, initialised OauthAppRecord
|
||||
*/
|
||||
public OauthAppRecord(Integer id, String registrationId, String appName, String appIcon, String appType, String clientId, String clientSecret, String authUrl, String resourceUrl, String scope, LocalDateTime updateAt, LocalDateTime createAt) {
|
||||
public OauthAppRecord(Integer id, String registrationId, String appName, String appIcon, OAuthAppType appType, String clientId, String clientSecret, String authUrl, String resourceUrl, String scope, LocalDateTime updateAt, LocalDateTime createAt) {
|
||||
super(OauthApp.OAUTH_APP);
|
||||
|
||||
setId(id);
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package com.databasir.dao.converter;
|
||||
|
||||
import com.databasir.dao.enums.OAuthAppType;
|
||||
import org.jooq.impl.EnumConverter;
|
||||
|
||||
public class OAuthAppTypeConverter extends EnumConverter<String, OAuthAppType> {
|
||||
|
||||
public OAuthAppTypeConverter() {
|
||||
super(String.class, OAuthAppType.class);
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue