Solon

::actable-solon-plugin

</> markdown

此插件,由社区成员(peigen)贡献

<dependency>
    <groupId>com.gitee.peigenlpy</groupId>
    <artifactId>actable-solon-plugin</artifactId>
    <version>1.5.1.RELEASE</version>
</dependency>

1、描述

本插件是完全基于mybatis-enhance-actable,是适用于Solon的插件, 经过简单的配置即可获得ACTable的能力。

开源项目不容易,如果觉得本项目对您的工作还是有帮助的话,请在帮忙在ACTable点以下Star(页面右上角),谢谢。

2、配置示例

在项目配置文件app.yml下配置

actable:
  dataSource:
    schema: hotpot
    jdbcUrl: jdbc:mysql://localhost:3306/hotpot?useUnicode=true&characterEncoding=utf8&autoReconnect=true&rewriteBatchedStatements=true
    driverClassName: com.mysql.cj.jdbc.Driver
    username: root
    password: peigen
    type: "com.zaxxer.hikari.HikariDataSource"
  model:
    pack:
      - "info.peigen.hotpot.business.router.core.repository.entity"
      - "info.peigen.hotpot.business.account.core.repository.mysql.entity"

到这里已经完成actable从spring到solon的转变了。以下的部分就和原版一致了,可以直接看ACTable的官方文档:ACTable官方文档地址

3、应用示例

在您的Entity文件里如下配置,提示:如下代码是本人项目中的一个案例,本案例使用了ACTable和BeetlSQL,当然ACTable也可以和其他ORM工具同时使用。

import com.gitee.peigenlpy.actable.annotation.Column;
import com.gitee.peigenlpy.actable.annotation.Index;
import com.gitee.peigenlpy.actable.annotation.Table;
import com.gitee.peigenlpy.actable.annotation.Unique;
import com.gitee.peigenlpy.actable.constants.MySqlCharsetConstant;
import com.gitee.peigenlpy.actable.constants.MySqlEngineConstant;
import com.gitee.peigenlpy.actable.constants.MySqlTypeConstant;
import info.peigen.hotpot.business.account.facade.enums.AccountStatus;
import info.peigen.hotpot.business.account.facade.enums.AccountType;
import info.peigen.hotpot.business.router.facade.enums.ChannelCode;
import info.peigen.hotpot.component.data.repository.beetlsql.entity.AbstractCreateTimeEntity;
import info.peigen.hotpot.component.data.repository.beetlsql.handler.MoneyBeetlSqlHandler;
import info.peigen.hotpot.common.core.enums.Currency;
import info.peigen.hotpot.common.core.lang.money.Money;
import lombok.*;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;

@Builder
@Data
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
@Table(name = "account", comment = "账户表", charset = MySqlCharsetConstant.UTF8MB4, engine = MySqlEngineConstant.InnoDB)
@org.beetl.sql.annotation.entity.Table(name = "account")
public class AccountEntity extends AbstractCreateTimeEntity {
    @Column(name = "customer_id", type = MySqlTypeConstant.VARCHAR, length = 30, comment = "customerId or partnerId")
    @Index(value = "customerId", columns = "customer_id")
    @org.beetl.sql.annotation.entity.Column("customer_id")
    String        customerId;
    
    @Column(name = "account_id", type = MySqlTypeConstant.VARCHAR, length = 30, isNull = false, comment = "accountId")
    @Unique(value = "accountId", columns = "account_id")
    @org.beetl.sql.annotation.entity.Column("account_id")
    String        accountId;
    
    @Column(name = "account_type", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false,
            comment = "账户类型,Customer:客户账户,Provisions:备付金账户,Card:卡,System:系统账户")
    @Index(value = "accountType", columns = "account_type")
    @org.beetl.sql.annotation.entity.Column("account_type")
    AccountType   accountType;
    
    @Column(name = "status", type = MySqlTypeConstant.VARCHAR, length = 20, isNull = false,
            comment = "账户状态,Init:初始化,Normal:正常账户,Freeze:账户被冻结,Abandon:账户被废弃")
    @Index(value = "status", columns = "status")
    @org.beetl.sql.annotation.entity.Column("status")
    AccountStatus status;
    
    @Column(name = "currency", type = MySqlTypeConstant.VARCHAR, length = 3, isNull = false, comment = "币种")
    @Index(value = "currency", columns = "currency")
    @org.beetl.sql.annotation.entity.Column("currency")
    Currency currency;
    
    @Column(name = "balance", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "余额")
    @org.beetl.sql.annotation.entity.Column("balance")
    @MoneyBeetlSqlHandler
    Money    balance;
    
    @Column(name = "transit_amount", type = MySqlTypeConstant.DECIMAL, length = 65, isNull = false, defaultValue = "0", comment = "在途资金")
    @Column(name = "channel_code", type = MySqlTypeConstant.VARCHAR, length = 50, comment = "渠道编码")
    @Index(value = "channelCode", columns = "channel_code")
    @org.beetl.sql.annotation.entity.Column("channel_code")
    ChannelCode channelCode;
    
    @Column(name = "memo", type = MySqlTypeConstant.VARCHAR, length = 200, comment = "备注")
    @org.beetl.sql.annotation.entity.Column("memo")
    String        memo;
}

更多具体Entity注释请参阅:ACTable官方文档地址