diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/OauthAppTable.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/OauthAppTable.java index 1b3993d..79d14e4 100644 --- a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/OauthAppTable.java +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/OauthAppTable.java @@ -19,7 +19,7 @@ import org.jooq.ForeignKey; import org.jooq.Identity; import org.jooq.Name; import org.jooq.Record; -import org.jooq.Row12; +import org.jooq.Row7; import org.jooq.Schema; import org.jooq.Table; import org.jooq.TableField; @@ -76,31 +76,6 @@ public class OauthAppTable extends TableImpl { */ public final TableField APP_TYPE = createField(DSL.name("app_type"), SQLDataType.VARCHAR(64).nullable(false), this, "github, gitlab", new OAuthAppTypeConverter()); - /** - * The column databasir.oauth_app.client_id. - */ - public final TableField CLIENT_ID = createField(DSL.name("client_id"), SQLDataType.VARCHAR(256), this, ""); - - /** - * The column databasir.oauth_app.client_secret. - */ - public final TableField CLIENT_SECRET = createField(DSL.name("client_secret"), SQLDataType.VARCHAR(256), this, ""); - - /** - * The column databasir.oauth_app.auth_url. - */ - public final TableField AUTH_URL = createField(DSL.name("auth_url"), SQLDataType.VARCHAR(256), this, ""); - - /** - * The column databasir.oauth_app.resource_url. - */ - public final TableField RESOURCE_URL = createField(DSL.name("resource_url"), SQLDataType.VARCHAR(256), this, ""); - - /** - * The column databasir.oauth_app.scope. - */ - public final TableField SCOPE = createField(DSL.name("scope"), SQLDataType.VARCHAR(256), this, ""); - /** * The column databasir.oauth_app.update_at. */ @@ -191,11 +166,11 @@ public class OauthAppTable extends TableImpl { } // ------------------------------------------------------------------------- - // Row12 type methods + // Row7 type methods // ------------------------------------------------------------------------- @Override - public Row12 fieldsRow() { - return (Row12) super.fieldsRow(); + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); } } diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/OauthApp.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/OauthApp.java index 2a0d5f3..f79fba2 100644 --- a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/OauthApp.java +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/pojos/OauthApp.java @@ -23,11 +23,6 @@ public class OauthApp implements Serializable { private String appName; private String appIcon; private OAuthAppType appType; - private String clientId; - private String clientSecret; - private String authUrl; - private String resourceUrl; - private String scope; private LocalDateTime updateAt; private LocalDateTime createAt; @@ -39,11 +34,6 @@ public class OauthApp implements Serializable { this.appName = value.appName; this.appIcon = value.appIcon; this.appType = value.appType; - this.clientId = value.clientId; - this.clientSecret = value.clientSecret; - this.authUrl = value.authUrl; - this.resourceUrl = value.resourceUrl; - this.scope = value.scope; this.updateAt = value.updateAt; this.createAt = value.createAt; } @@ -54,11 +44,6 @@ public class OauthApp implements Serializable { String appName, String appIcon, OAuthAppType appType, - String clientId, - String clientSecret, - String authUrl, - String resourceUrl, - String scope, LocalDateTime updateAt, LocalDateTime createAt ) { @@ -67,11 +52,6 @@ public class OauthApp implements Serializable { this.appName = appName; this.appIcon = appIcon; this.appType = appType; - this.clientId = clientId; - this.clientSecret = clientSecret; - this.authUrl = authUrl; - this.resourceUrl = resourceUrl; - this.scope = scope; this.updateAt = updateAt; this.createAt = createAt; } @@ -146,76 +126,6 @@ public class OauthApp implements Serializable { this.appType = appType; } - /** - * Getter for databasir.oauth_app.client_id. - */ - public String getClientId() { - return this.clientId; - } - - /** - * Setter for databasir.oauth_app.client_id. - */ - public void setClientId(String clientId) { - this.clientId = clientId; - } - - /** - * Getter for databasir.oauth_app.client_secret. - */ - public String getClientSecret() { - return this.clientSecret; - } - - /** - * Setter for databasir.oauth_app.client_secret. - */ - public void setClientSecret(String clientSecret) { - this.clientSecret = clientSecret; - } - - /** - * Getter for databasir.oauth_app.auth_url. - */ - public String getAuthUrl() { - return this.authUrl; - } - - /** - * Setter for databasir.oauth_app.auth_url. - */ - public void setAuthUrl(String authUrl) { - this.authUrl = authUrl; - } - - /** - * Getter for databasir.oauth_app.resource_url. - */ - public String getResourceUrl() { - return this.resourceUrl; - } - - /** - * Setter for databasir.oauth_app.resource_url. - */ - public void setResourceUrl(String resourceUrl) { - this.resourceUrl = resourceUrl; - } - - /** - * Getter for databasir.oauth_app.scope. - */ - public String getScope() { - return this.scope; - } - - /** - * Setter for databasir.oauth_app.scope. - */ - public void setScope(String scope) { - this.scope = scope; - } - /** * Getter for databasir.oauth_app.update_at. */ @@ -253,11 +163,6 @@ public class OauthApp implements Serializable { sb.append(", ").append(appName); sb.append(", ").append(appIcon); sb.append(", ").append(appType); - sb.append(", ").append(clientId); - sb.append(", ").append(clientSecret); - sb.append(", ").append(authUrl); - sb.append(", ").append(resourceUrl); - sb.append(", ").append(scope); sb.append(", ").append(updateAt); sb.append(", ").append(createAt); diff --git a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/OauthAppRecord.java b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/OauthAppRecord.java index 3458241..961352a 100644 --- a/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/OauthAppRecord.java +++ b/dao/generated-src/jooq/main/java/com/databasir/dao/tables/records/OauthAppRecord.java @@ -12,8 +12,8 @@ import java.time.LocalDateTime; import org.jooq.Field; import org.jooq.Record1; -import org.jooq.Record12; -import org.jooq.Row12; +import org.jooq.Record7; +import org.jooq.Row7; import org.jooq.impl.UpdatableRecordImpl; @@ -21,7 +21,7 @@ import org.jooq.impl.UpdatableRecordImpl; * oauth app info */ @SuppressWarnings({ "all", "unchecked", "rawtypes" }) -public class OauthAppRecord extends UpdatableRecordImpl implements Record12 { +public class OauthAppRecord extends UpdatableRecordImpl implements Record7 { private static final long serialVersionUID = 1L; @@ -95,102 +95,32 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen return (OAuthAppType) get(4); } - /** - * Setter for databasir.oauth_app.client_id. - */ - public void setClientId(String value) { - set(5, value); - } - - /** - * Getter for databasir.oauth_app.client_id. - */ - public String getClientId() { - return (String) get(5); - } - - /** - * Setter for databasir.oauth_app.client_secret. - */ - public void setClientSecret(String value) { - set(6, value); - } - - /** - * Getter for databasir.oauth_app.client_secret. - */ - public String getClientSecret() { - return (String) get(6); - } - - /** - * Setter for databasir.oauth_app.auth_url. - */ - public void setAuthUrl(String value) { - set(7, value); - } - - /** - * Getter for databasir.oauth_app.auth_url. - */ - public String getAuthUrl() { - return (String) get(7); - } - - /** - * Setter for databasir.oauth_app.resource_url. - */ - public void setResourceUrl(String value) { - set(8, value); - } - - /** - * Getter for databasir.oauth_app.resource_url. - */ - public String getResourceUrl() { - return (String) get(8); - } - - /** - * Setter for databasir.oauth_app.scope. - */ - public void setScope(String value) { - set(9, value); - } - - /** - * Getter for databasir.oauth_app.scope. - */ - public String getScope() { - return (String) get(9); - } - /** * Setter for databasir.oauth_app.update_at. */ public void setUpdateAt(LocalDateTime value) { - set(10, value); + set(5, value); } /** * Getter for databasir.oauth_app.update_at. */ public LocalDateTime getUpdateAt() { - return (LocalDateTime) get(10); + return (LocalDateTime) get(5); } /** * Setter for databasir.oauth_app.create_at. */ public void setCreateAt(LocalDateTime value) { - set(11, value); + set(6, value); } /** * Getter for databasir.oauth_app.create_at. */ public LocalDateTime getCreateAt() { - return (LocalDateTime) get(11); + return (LocalDateTime) get(6); } // ------------------------------------------------------------------------- @@ -203,17 +133,17 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen } // ------------------------------------------------------------------------- - // Record12 type implementation + // Record7 type implementation // ------------------------------------------------------------------------- @Override - public Row12 fieldsRow() { - return (Row12) super.fieldsRow(); + public Row7 fieldsRow() { + return (Row7) super.fieldsRow(); } @Override - public Row12 valuesRow() { - return (Row12) super.valuesRow(); + public Row7 valuesRow() { + return (Row7) super.valuesRow(); } @Override @@ -242,37 +172,12 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen } @Override - public Field field6() { - return OauthAppTable.OAUTH_APP.CLIENT_ID; - } - - @Override - public Field field7() { - return OauthAppTable.OAUTH_APP.CLIENT_SECRET; - } - - @Override - public Field field8() { - return OauthAppTable.OAUTH_APP.AUTH_URL; - } - - @Override - public Field field9() { - return OauthAppTable.OAUTH_APP.RESOURCE_URL; - } - - @Override - public Field field10() { - return OauthAppTable.OAUTH_APP.SCOPE; - } - - @Override - public Field field11() { + public Field field6() { return OauthAppTable.OAUTH_APP.UPDATE_AT; } @Override - public Field field12() { + public Field field7() { return OauthAppTable.OAUTH_APP.CREATE_AT; } @@ -302,37 +207,12 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen } @Override - public String component6() { - return getClientId(); - } - - @Override - public String component7() { - return getClientSecret(); - } - - @Override - public String component8() { - return getAuthUrl(); - } - - @Override - public String component9() { - return getResourceUrl(); - } - - @Override - public String component10() { - return getScope(); - } - - @Override - public LocalDateTime component11() { + public LocalDateTime component6() { return getUpdateAt(); } @Override - public LocalDateTime component12() { + public LocalDateTime component7() { return getCreateAt(); } @@ -362,37 +242,12 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen } @Override - public String value6() { - return getClientId(); - } - - @Override - public String value7() { - return getClientSecret(); - } - - @Override - public String value8() { - return getAuthUrl(); - } - - @Override - public String value9() { - return getResourceUrl(); - } - - @Override - public String value10() { - return getScope(); - } - - @Override - public LocalDateTime value11() { + public LocalDateTime value6() { return getUpdateAt(); } @Override - public LocalDateTime value12() { + public LocalDateTime value7() { return getCreateAt(); } @@ -427,49 +282,19 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen } @Override - public OauthAppRecord value6(String value) { - setClientId(value); - return this; - } - - @Override - public OauthAppRecord value7(String value) { - setClientSecret(value); - return this; - } - - @Override - public OauthAppRecord value8(String value) { - setAuthUrl(value); - return this; - } - - @Override - public OauthAppRecord value9(String value) { - setResourceUrl(value); - return this; - } - - @Override - public OauthAppRecord value10(String value) { - setScope(value); - return this; - } - - @Override - public OauthAppRecord value11(LocalDateTime value) { + public OauthAppRecord value6(LocalDateTime value) { setUpdateAt(value); return this; } @Override - public OauthAppRecord value12(LocalDateTime value) { + public OauthAppRecord value7(LocalDateTime value) { setCreateAt(value); return this; } @Override - 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) { + public OauthAppRecord values(Integer value1, String value2, String value3, String value4, OAuthAppType value5, LocalDateTime value6, LocalDateTime value7) { value1(value1); value2(value2); value3(value3); @@ -477,11 +302,6 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen value5(value5); value6(value6); value7(value7); - value8(value8); - value9(value9); - value10(value10); - value11(value11); - value12(value12); return this; } @@ -499,7 +319,7 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen /** * Create a detached, initialised OauthAppRecord */ - 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) { + public OauthAppRecord(Integer id, String registrationId, String appName, String appIcon, OAuthAppType appType, LocalDateTime updateAt, LocalDateTime createAt) { super(OauthAppTable.OAUTH_APP); setId(id); @@ -507,11 +327,6 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen setAppName(appName); setAppIcon(appIcon); setAppType(appType); - setClientId(clientId); - setClientSecret(clientSecret); - setAuthUrl(authUrl); - setResourceUrl(resourceUrl); - setScope(scope); setUpdateAt(updateAt); setCreateAt(createAt); } @@ -528,11 +343,6 @@ public class OauthAppRecord extends UpdatableRecordImpl implemen setAppName(value.getAppName()); setAppIcon(value.getAppIcon()); setAppType(value.getAppType()); - setClientId(value.getClientId()); - setClientSecret(value.getClientSecret()); - setAuthUrl(value.getAuthUrl()); - setResourceUrl(value.getResourceUrl()); - setScope(value.getScope()); setUpdateAt(value.getUpdateAt()); setCreateAt(value.getCreateAt()); } diff --git a/dao/src/main/java/com/databasir/dao/enums/OAuthAppType.java b/dao/src/main/java/com/databasir/dao/enums/OAuthAppType.java index fb2f082..f454302 100644 --- a/dao/src/main/java/com/databasir/dao/enums/OAuthAppType.java +++ b/dao/src/main/java/com/databasir/dao/enums/OAuthAppType.java @@ -1,8 +1,15 @@ package com.databasir.dao.enums; +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor public enum OAuthAppType { - GITHUB, GITLAB; + GITHUB("github"), GITLAB("gitlab"), WE_WORK("企业微信"); + + @Getter + private String description; public boolean isSame(String type) { return this.name().equalsIgnoreCase(type); diff --git a/dao/src/main/java/com/databasir/dao/impl/OauthAppPropertyDao.java b/dao/src/main/java/com/databasir/dao/impl/OauthAppPropertyDao.java new file mode 100644 index 0000000..61de648 --- /dev/null +++ b/dao/src/main/java/com/databasir/dao/impl/OauthAppPropertyDao.java @@ -0,0 +1,37 @@ +package com.databasir.dao.impl; + +import com.databasir.dao.tables.pojos.OauthAppProperty; +import lombok.Getter; +import org.jooq.DSLContext; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import java.util.List; + +import static com.databasir.dao.Tables.OAUTH_APP_PROPERTY; + +@Repository +public class OauthAppPropertyDao extends BaseDao { + + @Autowired + @Getter + private DSLContext dslContext; + + public OauthAppPropertyDao() { + super(OAUTH_APP_PROPERTY, OauthAppProperty.class); + } + + public int deleteByOauthAppId(Integer oauthAppId) { + return this.getDslContext() + .deleteFrom(OAUTH_APP_PROPERTY) + .where(OAUTH_APP_PROPERTY.OAUTH_APP_ID.eq(oauthAppId)) + .execute(); + } + + public List selectByOauthAppId(Integer oauthAppID) { + return this.getDslContext() + .select(OAUTH_APP_PROPERTY.fields()) + .from(OAUTH_APP_PROPERTY).where(OAUTH_APP_PROPERTY.OAUTH_APP_ID.eq(oauthAppID)) + .fetchInto(OauthAppProperty.class); + } +} diff --git a/dao/src/main/resources/db/migration/V1.4.6__oauth_prop_migraiton.sql b/dao/src/main/resources/db/migration/V1.4.6__oauth_prop_migraiton.sql new file mode 100644 index 0000000..8fc3bd5 --- /dev/null +++ b/dao/src/main/resources/db/migration/V1.4.6__oauth_prop_migraiton.sql @@ -0,0 +1,30 @@ +insert into oauth_app_property (oauth_app_id, name, value) +select id, 'auth_host', auth_url +from oauth_app +where auth_url is not null; + +insert into oauth_app_property (oauth_app_id, name, value) +select id, 'resource_host', resource_url +from oauth_app +where resource_url is not null; + +insert into oauth_app_property (oauth_app_id, name, value) +select id, 'client_id', client_id +from oauth_app +where client_id is not null; + +insert into oauth_app_property (oauth_app_id, name, value) +select id, 'client_secret', client_secret +from oauth_app +where client_secret is not null; + +alter table oauth_app + drop column auth_url; +alter table oauth_app + drop column resource_url; +alter table oauth_app + drop column client_id; +alter table oauth_app + drop column client_secret; +alter table oauth_app + drop column scope;