Skip to content

Commit

Permalink
rename Generated --> Table, GeneratedColumn --> Column
Browse files Browse the repository at this point in the history
  • Loading branch information
ningpp committed Sep 4, 2024
1 parent b3eca19 commit 7347468
Show file tree
Hide file tree
Showing 24 changed files with 176 additions and 176 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
@Inherited
@Target({ ElementType.FIELD })
@Retention(RetentionPolicy.RUNTIME)
public @interface GeneratedColumn {
public @interface Column {

/**
* column name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
@Inherited
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.TYPE })
public @interface Generated {
public @interface Table {

/**
* table name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

import org.apache.ibatis.type.JdbcType;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;

@Generated(table = "sys_role")
@Table(table = "sys_role")
public class SysRole {
@GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
@Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
private String id;
@GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR, id = false)
@Column(name = "name", jdbcType = JdbcType.VARCHAR, id = false)
private String name;
public String getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
package me.ningpp.mmegp.demo.entity;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import me.ningpp.mmegp.annotations.SoftDelete;

@Generated
@Table
@SoftDelete(column = "deleted")
public class SysAutoUser {
@GeneratedColumn(id = true, generatedValue = true)
@Column(id = true, generatedValue = true)
private Integer id;
@GeneratedColumn
@Column
private String firstName;
@GeneratedColumn
@Column
private String lastName;
@GeneratedColumn
@Column
private Byte deleted;

public Integer getId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*/
package me.ningpp.mmegp.demo.entity2;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import me.ningpp.mmegp.annotations.SoftDelete;
import org.apache.ibatis.type.JdbcType;

@Generated(table = "sys_org")
@Table(table = "sys_org")
@SoftDelete(column = "deleted")
public class SysOrg {
@GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
@Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
private String id;

@GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR)
@Column(name = "name", jdbcType = JdbcType.VARCHAR)
private String name;

@GeneratedColumn(name = "deleted", jdbcType = JdbcType.TINYINT)
@Column(name = "deleted", jdbcType = JdbcType.TINYINT)
private Byte deleted;

public SysOrg() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,24 @@
*/
package me.ningpp.mmegp.demo.entity2;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import me.ningpp.mmegp.annotations.SoftDelete;
import me.ningpp.mmegp.enums.SoftDeleteStrategy;
import org.apache.ibatis.type.JdbcType;

import java.time.LocalDateTime;

@Generated(table = "sys_org2")
@Table(table = "sys_org2")
@SoftDelete(column = "delete_time", strategy = SoftDeleteStrategy.DELETED_AT)
public record SysOrg2(
@GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
@Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
String id,

@GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR)
@Column(name = "name", jdbcType = JdbcType.VARCHAR)
String name,

@GeneratedColumn(name = "delete_time", jdbcType = JdbcType.TIMESTAMP)
@Column(name = "delete_time", jdbcType = JdbcType.TIMESTAMP)
LocalDateTime deleteTime
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@

import org.apache.ibatis.type.JdbcType;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import org.apache.ibatis.type.StringTypeHandler;

import static org.apache.ibatis.type.JdbcType.VARCHAR;

@Generated(table = "sys_user")
@Table(table = "sys_user")
public class SysUser {
@GeneratedColumn(name = "id", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class)
@Column(name = "id", jdbcType = VARCHAR, id = true, typeHandler = StringTypeHandler.class)
private String id;
@GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR)
@Column(name = "name", jdbcType = JdbcType.VARCHAR)
private String name;
public String getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,26 @@
*/
package me.ningpp.mmegp.demo.entity3;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import org.apache.ibatis.type.JdbcType;

import java.time.LocalDate;

import static org.apache.ibatis.type.JdbcType.VARCHAR;

@Generated(table = "sys_company")
@Table(table = "sys_company")
public record SysCompany(
@GeneratedColumn(name = "id", jdbcType = VARCHAR, id = true)
@Column(name = "id", jdbcType = VARCHAR, id = true)
String id,

@GeneratedColumn(name = "name", jdbcType = VARCHAR)
@Column(name = "name", jdbcType = VARCHAR)
String name,

@GeneratedColumn(name = "start_date", jdbcType = JdbcType.DATE)
@Column(name = "start_date", jdbcType = JdbcType.DATE)
LocalDate startDate,

@GeneratedColumn(name = "unified_code", jdbcType = VARCHAR)
@Column(name = "unified_code", jdbcType = VARCHAR)
String unifiedCode
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

import org.apache.ibatis.type.JdbcType;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;

@Generated(table = "sys_role_menu")
@Table(table = "sys_role_menu")
public class SysRoleMenu {
@GeneratedColumn(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true)
@Column(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true)
private Long id;
@GeneratedColumn(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false)
@Column(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false)
private String roleId;
@GeneratedColumn(name = "menu_id", jdbcType = JdbcType.VARCHAR)
@Column(name = "menu_id", jdbcType = JdbcType.VARCHAR)
private String menuId;
public Long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@

import org.apache.ibatis.type.JdbcType;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;

@Generated(table = "sys_user_role")
@Table(table = "sys_user_role")
public class SysUserRole {
@GeneratedColumn(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true)
@Column(name = "id", jdbcType = JdbcType.BIGINT, id = true, generatedValue = true)
private Long id;
@GeneratedColumn(name = "user_id", jdbcType = JdbcType.VARCHAR)
@Column(name = "user_id", jdbcType = JdbcType.VARCHAR)
private String userId;
@GeneratedColumn(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false)
@Column(name = "role_id", jdbcType = JdbcType.VARCHAR, id = false)
private String roleId;
public Long getId() {
return id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
*/
package me.ningpp.mmegp.demo.entity;

import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import me.ningpp.mmegp.mybatis.type.list.ListCommaIntegerTypeHandler;
import me.ningpp.mmegp.mybatis.type.list.ListCommaLongTypeHandler;
import me.ningpp.mmegp.mybatis.type.list.ListCommaStringTypeHandler;
Expand All @@ -37,83 +37,83 @@
import java.util.Set;
import java.util.UUID;

@Generated(table = "sys_menu")
@Table(table = "sys_menu")
public class SysMenu {
@GeneratedColumn(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
@Column(name = "id", jdbcType = JdbcType.VARCHAR, id = true)
private String id;

@GeneratedColumn(name = "name", jdbcType = JdbcType.VARCHAR)
@Column(name = "name", jdbcType = JdbcType.VARCHAR)
private String name;

@GeneratedColumn(name = "parent_id", jdbcType = JdbcType.VARCHAR)
@Column(name = "parent_id", jdbcType = JdbcType.VARCHAR)
private String parentId;

@GeneratedColumn(name = "integer_list", jdbcType = JdbcType.VARCHAR,
@Column(name = "integer_list", jdbcType = JdbcType.VARCHAR,
typeHandler = ListCommaIntegerTypeHandler.class
)
private List<Integer> integerList;

@GeneratedColumn(name = "long_list", jdbcType = JdbcType.VARCHAR,
@Column(name = "long_list", jdbcType = JdbcType.VARCHAR,
typeHandler = ListCommaLongTypeHandler.class
)
private List<Long> longList;

@GeneratedColumn(name = "string_list", jdbcType = JdbcType.VARCHAR,
@Column(name = "string_list", jdbcType = JdbcType.VARCHAR,
typeHandler = ListCommaStringTypeHandler.class
)
private List<String> stringList;

@GeneratedColumn(name = "integer_set", jdbcType = JdbcType.VARCHAR,
@Column(name = "integer_set", jdbcType = JdbcType.VARCHAR,
typeHandler = SetCommaIntegerTypeHandler.class
)
private Set<Integer> integerSet;

@GeneratedColumn(name = "long_set", jdbcType = JdbcType.VARCHAR,
@Column(name = "long_set", jdbcType = JdbcType.VARCHAR,
typeHandler = SetCommaLongTypeHandler.class
)
private Set<Long> longSet;

@GeneratedColumn(name = "string_set", jdbcType = JdbcType.VARCHAR,
@Column(name = "string_set", jdbcType = JdbcType.VARCHAR,
typeHandler = SetCommaStringTypeHandler.class
)
private Set<String> stringSet;

@GeneratedColumn(
@Column(
name = "integer_linkedhashset", jdbcType = JdbcType.VARCHAR,
typeHandler = LinkedHashSetCommaIntegerTypeHandler.class
)
private LinkedHashSet<Integer> integerLinkedhashset;

@GeneratedColumn(
@Column(
name = "long_linkedhashset", jdbcType = JdbcType.VARCHAR,
typeHandler = LinkedHashSetCommaLongTypeHandler.class
)
private HashSet<Long> longLinkedhashset;

@GeneratedColumn(
@Column(
name = "string_linkedhashset", jdbcType = JdbcType.VARCHAR,
typeHandler = LinkedHashSetCommaStringTypeHandler.class
)
private Set<String> stringLinkedhashset;

@GeneratedColumn(name = "bytes1", jdbcType = JdbcType.BINARY)
@Column(name = "bytes1", jdbcType = JdbcType.BINARY)
private byte[] bytes1;
@GeneratedColumn(name = "bytes2", jdbcType = JdbcType.BINARY)
@Column(name = "bytes2", jdbcType = JdbcType.BINARY)
private Byte[] bytes2;

@GeneratedColumn(
@Column(
name = "uuid", jdbcType = JdbcType.BINARY,
typeHandler = UUIDTypeHandler.class
)
private UUID uuid;

@GeneratedColumn(
@Column(
name = "with_dash_uuid", jdbcType = JdbcType.VARCHAR,
typeHandler = UUIDStringTypeHandler.class
)
private UUID withDashUUID;

@GeneratedColumn(
@Column(
name = "no_dash_uuid", jdbcType = JdbcType.VARCHAR,
typeHandler = UUIDNoDashStringTypeHandler.class
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
import com.github.javaparser.ast.nodeTypes.NodeWithSimpleName;
import com.github.javaparser.ast.nodeTypes.NodeWithType;
import com.github.javaparser.ast.type.Type;
import me.ningpp.mmegp.annotations.Generated;
import me.ningpp.mmegp.annotations.GeneratedColumn;
import me.ningpp.mmegp.annotations.Table;
import me.ningpp.mmegp.annotations.Column;
import me.ningpp.mmegp.enums.AggregateFunction;
import me.ningpp.mmegp.enums.ModelType;
import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -82,7 +82,7 @@ protected GeneratedTableInfo buildGeneratedTable(Context context,
if (modelDeclaration == null || modelDeclaration.getFullyQualifiedName().isEmpty()) {
return null;
}
var annotationMembers = getNormalAnnotationMembers(modelDeclaration, Generated.class);
var annotationMembers = getNormalAnnotationMembers(modelDeclaration, Table.class);

String tableName = parseTableName(annotationMembers, modelDeclaration.getNameAsString(), context);
List<String> countGroupByColumns = parseArrayString(annotationMembers, COUNT_GROUP_BY_COLUMNS_NAME);
Expand Down Expand Up @@ -267,7 +267,7 @@ protected <N1 extends Node, N2 extends Node> Pair<IntrospectedColumn, Boolean> b
NodeWithAnnotations<N1> annotationNode,
NodeWithType<N2, Type> typeNode,
NodeWithSimpleName<N2> nameNode) {
Optional<AnnotationExpr> annoOptional = annotationNode.getAnnotationByClass(GeneratedColumn.class);
Optional<AnnotationExpr> annoOptional = annotationNode.getAnnotationByClass(Column.class);
if (annoOptional.isEmpty()) {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public boolean validate(List<String> warnings) {
@Override
public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass,
IntrospectedTable introspectedTable) {
topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Generated");
topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Table");
List<String> infos = new ArrayList<>();
infos.add(String.format(Locale.ROOT,
"table = \"%s\"",
Expand All @@ -80,10 +80,10 @@ public boolean modelBaseRecordClassGenerated(TopLevelClass topLevelClass,
}

topLevelClass.addAnnotation(String.format(Locale.ROOT,
"@Generated(%s)",
"@Table(%s)",
String.join(DELIMITER, infos)));

topLevelClass.addImportedType("me.ningpp.mmegp.annotations.GeneratedColumn");
topLevelClass.addImportedType("me.ningpp.mmegp.annotations.Column");
topLevelClass.addImportedType("org.apache.ibatis.type.JdbcType");

return true;
Expand Down Expand Up @@ -143,7 +143,7 @@ public boolean modelFieldGenerated(Field field, TopLevelClass topLevelClass,
}

field.addAnnotation(String.format(Locale.ROOT,
"@GeneratedColumn(name = \"%s\", jdbcType = JdbcType.%s%s)",
"@Column(name = \"%s\", jdbcType = JdbcType.%s%s)",
introspectedColumn.getActualColumnName(),
introspectedColumn.getJdbcTypeName(),
otherInfos.isEmpty()
Expand Down
Loading

0 comments on commit 7347468

Please sign in to comment.