Skip to content

Commit

Permalink
[datareader] Add support for uuid generate rule
Browse files Browse the repository at this point in the history
  • Loading branch information
wgzhao committed Nov 24, 2021
1 parent 2800d5a commit 64767b7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions docs/reader/datareader.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,5 +104,7 @@
| `phone` |随机生成一个国内手机号码|`15292600492`|string| 暂不考虑虚拟手机号 |
| `stockCode` |随机生成一个6位的股票代码|`687461`|string| 前两位满足国内股票代码编号规范 |
| `stockAccount` |随机生成一个10位的股票交易账户|`0692522928`|string| 完全随机,不满足账户规范 |
| `uuid` |随机生成一个 UUID 字符串|`bc1cf125-929b-43b7-b324-d7c4cc5a75d2`|string| 完全随机,不满足账户规范 |


注意:上述表格中的规则返回的数据类型是固定的,且不支持修改,因此 `type` 无需配置,配置的类型也会被忽略,因为数据生成来自内部规则,所以 `value` 也无需配置,配置的内容也会被忽略。
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import static com.wgzhao.addax.common.base.Constant.DEFAULT_DATE_FORMAT;
import static com.wgzhao.addax.common.base.Key.COLUMN;
Expand Down Expand Up @@ -569,6 +570,8 @@ else if (columnType == Type.DATE) {
return new StringColumn(StockUtil.nextStockAccount());
case NAME:
return new StringColumn(PersonUtil.nextName());
case UUID:
return new StringColumn(UUID.randomUUID().toString());
default:
throw AddaxException.asAddaxException(DataReaderErrorCode.ILLEGAL_VALUE,
columnRule + " is unsupported");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,5 +40,6 @@ public enum Rule
PHONE,
RANDOM,
STOCK_ACCOUNT,
STOCK_CODE
STOCK_CODE,
UUID
}

0 comments on commit 64767b7

Please sign in to comment.