Go through the entity design and view panel of ApiHug Api design Copilot

  1. Entity design panel
  2. Source code route
ApiHug Entity Manager

Proto Sample

Please refer: apihug-full-demo account.proto

message AccountEntity {
  string name = 1 [(hope.persistence.column) = {
    name: "NAME",
    description: "name of the account",
    nullable: FALSE,
    updatable: FALSE,
    length: {
      value: 32
    },
    type: VARCHAR
  }];

  string email = 2 [(hope.persistence.column) = {
    name: "EMAIL",
    description: "email of the account",
    updatable: FALSE,
    unique: TRUE,
    length: {
      value: 64
    },
    type: VARCHAR
  }];
}

Java Sample

Please refer: apihug-full-demo AccountEntity.java

@Table(
        name = "DEMO_USER_ACCOUNT",
        indexes = {
                @Index(name = "IDX_DEMO_USER_ACCOUNT_NAME", columnList = "NAME"),
                @Index(name = "IDX_DEMO_USER_ACCOUNT_EMAIL", columnList = "EMAIL")
        }
)
@org.springframework.data.relational.core.mapping.Table("DEMO_USER_ACCOUNT")
@Generated("H.O.P.E. Infra Team")
public final class AccountEntity extends Domain<AccountEntity, Long, Long> {
    @Column("NAME")
    @Description("name of the account")
    @jakarta.persistence.Column(
            name = "NAME",
            insertable = true,
            length = 32
    )
    protected String name;
}

Repository: apihug-full-demo AccountEntityRepository.java

@Repository
public interface AccountEntityRepository extends HopeJdbc<AccountEntity>, UserJdbcSupport, AccountEntityDSL, ListCrudRepository<AccountEntity, Long> {
    default void _save(AccountEntity entity) {
        //...
    }
}

Reference

  1. ApiHug101-Bilibili
  2. ApiHug101-Youtube