feat: jooq generate -> remove oauth_app unused columns

This commit is contained in:
vran 2022-12-11 18:38:02 +08:00
parent 542a4009b6
commit e93beba0a3
6 changed files with 101 additions and 337 deletions

View File

@ -19,7 +19,7 @@ import org.jooq.ForeignKey;
import org.jooq.Identity; import org.jooq.Identity;
import org.jooq.Name; import org.jooq.Name;
import org.jooq.Record; import org.jooq.Record;
import org.jooq.Row12; import org.jooq.Row7;
import org.jooq.Schema; import org.jooq.Schema;
import org.jooq.Table; import org.jooq.Table;
import org.jooq.TableField; import org.jooq.TableField;
@ -76,31 +76,6 @@ public class OauthAppTable extends TableImpl<OauthAppRecord> {
*/ */
public final TableField<OauthAppRecord, OAuthAppType> APP_TYPE = createField(DSL.name("app_type"), SQLDataType.VARCHAR(64).nullable(false), this, "github, gitlab", new OAuthAppTypeConverter()); 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>.
*/
public final TableField<OauthAppRecord, String> CLIENT_ID = createField(DSL.name("client_id"), SQLDataType.VARCHAR(256), this, "");
/**
* The column <code>databasir.oauth_app.client_secret</code>.
*/
public final TableField<OauthAppRecord, String> CLIENT_SECRET = createField(DSL.name("client_secret"), SQLDataType.VARCHAR(256), this, "");
/**
* The column <code>databasir.oauth_app.auth_url</code>.
*/
public final TableField<OauthAppRecord, String> AUTH_URL = createField(DSL.name("auth_url"), SQLDataType.VARCHAR(256), this, "");
/**
* The column <code>databasir.oauth_app.resource_url</code>.
*/
public final TableField<OauthAppRecord, String> RESOURCE_URL = createField(DSL.name("resource_url"), SQLDataType.VARCHAR(256), this, "");
/**
* The column <code>databasir.oauth_app.scope</code>.
*/
public final TableField<OauthAppRecord, String> SCOPE = createField(DSL.name("scope"), SQLDataType.VARCHAR(256), this, "");
/** /**
* The column <code>databasir.oauth_app.update_at</code>. * The column <code>databasir.oauth_app.update_at</code>.
*/ */
@ -191,11 +166,11 @@ public class OauthAppTable extends TableImpl<OauthAppRecord> {
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Row12 type methods // Row7 type methods
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() { public Row7<Integer, String, String, String, OAuthAppType, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row12) super.fieldsRow(); return (Row7) super.fieldsRow();
} }
} }

View File

@ -23,11 +23,6 @@ public class OauthApp implements Serializable {
private String appName; private String appName;
private String appIcon; private String appIcon;
private OAuthAppType appType; private OAuthAppType appType;
private String clientId;
private String clientSecret;
private String authUrl;
private String resourceUrl;
private String scope;
private LocalDateTime updateAt; private LocalDateTime updateAt;
private LocalDateTime createAt; private LocalDateTime createAt;
@ -39,11 +34,6 @@ public class OauthApp implements Serializable {
this.appName = value.appName; this.appName = value.appName;
this.appIcon = value.appIcon; this.appIcon = value.appIcon;
this.appType = value.appType; 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.updateAt = value.updateAt;
this.createAt = value.createAt; this.createAt = value.createAt;
} }
@ -54,11 +44,6 @@ public class OauthApp implements Serializable {
String appName, String appName,
String appIcon, String appIcon,
OAuthAppType appType, OAuthAppType appType,
String clientId,
String clientSecret,
String authUrl,
String resourceUrl,
String scope,
LocalDateTime updateAt, LocalDateTime updateAt,
LocalDateTime createAt LocalDateTime createAt
) { ) {
@ -67,11 +52,6 @@ public class OauthApp implements Serializable {
this.appName = appName; this.appName = appName;
this.appIcon = appIcon; this.appIcon = appIcon;
this.appType = appType; this.appType = appType;
this.clientId = clientId;
this.clientSecret = clientSecret;
this.authUrl = authUrl;
this.resourceUrl = resourceUrl;
this.scope = scope;
this.updateAt = updateAt; this.updateAt = updateAt;
this.createAt = createAt; this.createAt = createAt;
} }
@ -146,76 +126,6 @@ public class OauthApp implements Serializable {
this.appType = appType; this.appType = appType;
} }
/**
* Getter for <code>databasir.oauth_app.client_id</code>.
*/
public String getClientId() {
return this.clientId;
}
/**
* Setter for <code>databasir.oauth_app.client_id</code>.
*/
public void setClientId(String clientId) {
this.clientId = clientId;
}
/**
* Getter for <code>databasir.oauth_app.client_secret</code>.
*/
public String getClientSecret() {
return this.clientSecret;
}
/**
* Setter for <code>databasir.oauth_app.client_secret</code>.
*/
public void setClientSecret(String clientSecret) {
this.clientSecret = clientSecret;
}
/**
* Getter for <code>databasir.oauth_app.auth_url</code>.
*/
public String getAuthUrl() {
return this.authUrl;
}
/**
* Setter for <code>databasir.oauth_app.auth_url</code>.
*/
public void setAuthUrl(String authUrl) {
this.authUrl = authUrl;
}
/**
* Getter for <code>databasir.oauth_app.resource_url</code>.
*/
public String getResourceUrl() {
return this.resourceUrl;
}
/**
* Setter for <code>databasir.oauth_app.resource_url</code>.
*/
public void setResourceUrl(String resourceUrl) {
this.resourceUrl = resourceUrl;
}
/**
* Getter for <code>databasir.oauth_app.scope</code>.
*/
public String getScope() {
return this.scope;
}
/**
* Setter for <code>databasir.oauth_app.scope</code>.
*/
public void setScope(String scope) {
this.scope = scope;
}
/** /**
* Getter for <code>databasir.oauth_app.update_at</code>. * Getter for <code>databasir.oauth_app.update_at</code>.
*/ */
@ -253,11 +163,6 @@ public class OauthApp implements Serializable {
sb.append(", ").append(appName); sb.append(", ").append(appName);
sb.append(", ").append(appIcon); sb.append(", ").append(appIcon);
sb.append(", ").append(appType); 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(updateAt);
sb.append(", ").append(createAt); sb.append(", ").append(createAt);

View File

@ -12,8 +12,8 @@ import java.time.LocalDateTime;
import org.jooq.Field; import org.jooq.Field;
import org.jooq.Record1; import org.jooq.Record1;
import org.jooq.Record12; import org.jooq.Record7;
import org.jooq.Row12; import org.jooq.Row7;
import org.jooq.impl.UpdatableRecordImpl; import org.jooq.impl.UpdatableRecordImpl;
@ -21,7 +21,7 @@ import org.jooq.impl.UpdatableRecordImpl;
* oauth app info * oauth app info
*/ */
@SuppressWarnings({ "all", "unchecked", "rawtypes" }) @SuppressWarnings({ "all", "unchecked", "rawtypes" })
public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implements Record12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> { public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implements Record7<Integer, String, String, String, OAuthAppType, LocalDateTime, LocalDateTime> {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -95,102 +95,32 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
return (OAuthAppType) get(4); return (OAuthAppType) get(4);
} }
/**
* Setter for <code>databasir.oauth_app.client_id</code>.
*/
public void setClientId(String value) {
set(5, value);
}
/**
* Getter for <code>databasir.oauth_app.client_id</code>.
*/
public String getClientId() {
return (String) get(5);
}
/**
* Setter for <code>databasir.oauth_app.client_secret</code>.
*/
public void setClientSecret(String value) {
set(6, value);
}
/**
* Getter for <code>databasir.oauth_app.client_secret</code>.
*/
public String getClientSecret() {
return (String) get(6);
}
/**
* Setter for <code>databasir.oauth_app.auth_url</code>.
*/
public void setAuthUrl(String value) {
set(7, value);
}
/**
* Getter for <code>databasir.oauth_app.auth_url</code>.
*/
public String getAuthUrl() {
return (String) get(7);
}
/**
* Setter for <code>databasir.oauth_app.resource_url</code>.
*/
public void setResourceUrl(String value) {
set(8, value);
}
/**
* Getter for <code>databasir.oauth_app.resource_url</code>.
*/
public String getResourceUrl() {
return (String) get(8);
}
/**
* Setter for <code>databasir.oauth_app.scope</code>.
*/
public void setScope(String value) {
set(9, value);
}
/**
* Getter for <code>databasir.oauth_app.scope</code>.
*/
public String getScope() {
return (String) get(9);
}
/** /**
* Setter for <code>databasir.oauth_app.update_at</code>. * Setter for <code>databasir.oauth_app.update_at</code>.
*/ */
public void setUpdateAt(LocalDateTime value) { public void setUpdateAt(LocalDateTime value) {
set(10, value); set(5, value);
} }
/** /**
* Getter for <code>databasir.oauth_app.update_at</code>. * Getter for <code>databasir.oauth_app.update_at</code>.
*/ */
public LocalDateTime getUpdateAt() { public LocalDateTime getUpdateAt() {
return (LocalDateTime) get(10); return (LocalDateTime) get(5);
} }
/** /**
* Setter for <code>databasir.oauth_app.create_at</code>. * Setter for <code>databasir.oauth_app.create_at</code>.
*/ */
public void setCreateAt(LocalDateTime value) { public void setCreateAt(LocalDateTime value) {
set(11, value); set(6, value);
} }
/** /**
* Getter for <code>databasir.oauth_app.create_at</code>. * Getter for <code>databasir.oauth_app.create_at</code>.
*/ */
public LocalDateTime getCreateAt() { public LocalDateTime getCreateAt() {
return (LocalDateTime) get(11); return (LocalDateTime) get(6);
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@ -203,17 +133,17 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
} }
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// Record12 type implementation // Record7 type implementation
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
@Override @Override
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> fieldsRow() { public Row7<Integer, String, String, String, OAuthAppType, LocalDateTime, LocalDateTime> fieldsRow() {
return (Row12) super.fieldsRow(); return (Row7) super.fieldsRow();
} }
@Override @Override
public Row12<Integer, String, String, String, OAuthAppType, String, String, String, String, String, LocalDateTime, LocalDateTime> valuesRow() { public Row7<Integer, String, String, String, OAuthAppType, LocalDateTime, LocalDateTime> valuesRow() {
return (Row12) super.valuesRow(); return (Row7) super.valuesRow();
} }
@Override @Override
@ -242,37 +172,12 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
} }
@Override @Override
public Field<String> field6() { public Field<LocalDateTime> field6() {
return OauthAppTable.OAUTH_APP.CLIENT_ID;
}
@Override
public Field<String> field7() {
return OauthAppTable.OAUTH_APP.CLIENT_SECRET;
}
@Override
public Field<String> field8() {
return OauthAppTable.OAUTH_APP.AUTH_URL;
}
@Override
public Field<String> field9() {
return OauthAppTable.OAUTH_APP.RESOURCE_URL;
}
@Override
public Field<String> field10() {
return OauthAppTable.OAUTH_APP.SCOPE;
}
@Override
public Field<LocalDateTime> field11() {
return OauthAppTable.OAUTH_APP.UPDATE_AT; return OauthAppTable.OAUTH_APP.UPDATE_AT;
} }
@Override @Override
public Field<LocalDateTime> field12() { public Field<LocalDateTime> field7() {
return OauthAppTable.OAUTH_APP.CREATE_AT; return OauthAppTable.OAUTH_APP.CREATE_AT;
} }
@ -302,37 +207,12 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
} }
@Override @Override
public String component6() { public LocalDateTime 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() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime component12() { public LocalDateTime component7() {
return getCreateAt(); return getCreateAt();
} }
@ -362,37 +242,12 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
} }
@Override @Override
public String value6() { public LocalDateTime 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() {
return getUpdateAt(); return getUpdateAt();
} }
@Override @Override
public LocalDateTime value12() { public LocalDateTime value7() {
return getCreateAt(); return getCreateAt();
} }
@ -427,49 +282,19 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
} }
@Override @Override
public OauthAppRecord value6(String value) { public OauthAppRecord value6(LocalDateTime 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) {
setUpdateAt(value); setUpdateAt(value);
return this; return this;
} }
@Override @Override
public OauthAppRecord value12(LocalDateTime value) { public OauthAppRecord value7(LocalDateTime value) {
setCreateAt(value); setCreateAt(value);
return this; return this;
} }
@Override @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); value1(value1);
value2(value2); value2(value2);
value3(value3); value3(value3);
@ -477,11 +302,6 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
value5(value5); value5(value5);
value6(value6); value6(value6);
value7(value7); value7(value7);
value8(value8);
value9(value9);
value10(value10);
value11(value11);
value12(value12);
return this; return this;
} }
@ -499,7 +319,7 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
/** /**
* Create a detached, initialised OauthAppRecord * 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); super(OauthAppTable.OAUTH_APP);
setId(id); setId(id);
@ -507,11 +327,6 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
setAppName(appName); setAppName(appName);
setAppIcon(appIcon); setAppIcon(appIcon);
setAppType(appType); setAppType(appType);
setClientId(clientId);
setClientSecret(clientSecret);
setAuthUrl(authUrl);
setResourceUrl(resourceUrl);
setScope(scope);
setUpdateAt(updateAt); setUpdateAt(updateAt);
setCreateAt(createAt); setCreateAt(createAt);
} }
@ -528,11 +343,6 @@ public class OauthAppRecord extends UpdatableRecordImpl<OauthAppRecord> implemen
setAppName(value.getAppName()); setAppName(value.getAppName());
setAppIcon(value.getAppIcon()); setAppIcon(value.getAppIcon());
setAppType(value.getAppType()); setAppType(value.getAppType());
setClientId(value.getClientId());
setClientSecret(value.getClientSecret());
setAuthUrl(value.getAuthUrl());
setResourceUrl(value.getResourceUrl());
setScope(value.getScope());
setUpdateAt(value.getUpdateAt()); setUpdateAt(value.getUpdateAt());
setCreateAt(value.getCreateAt()); setCreateAt(value.getCreateAt());
} }

View File

@ -1,8 +1,15 @@
package com.databasir.dao.enums; package com.databasir.dao.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
public enum OAuthAppType { public enum OAuthAppType {
GITHUB, GITLAB; GITHUB("github"), GITLAB("gitlab"), WE_WORK("企业微信");
@Getter
private String description;
public boolean isSame(String type) { public boolean isSame(String type) {
return this.name().equalsIgnoreCase(type); return this.name().equalsIgnoreCase(type);

View File

@ -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<OauthAppProperty> {
@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<OauthAppProperty> 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);
}
}

View File

@ -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;