Files
ning-inspire 26975e5c3a Initial commit: ai4se-harness-suite
Import harness suite (skills, installers, overnight-runner, docs) as a fresh history for InspireChina.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-17 09:57:41 +08:00

48 lines
1.3 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Converter(Infrastructure 层 — PO ⟷ Domain 转换)
```java
package com.xxx.infrastructure.persistence.converter;
import com.xxx.domain.aggregate.Xxx;
import com.xxx.domain.vo.XxxStatus;
import com.xxx.infrastructure.persistence.po.XxxPO;
import org.springframework.stereotype.Component;
@Component
public class XxxConverter {
public Xxx toDomain(XxxPO po) {
if (po == null) return null;
return Xxx.builder()
.id(po.getId())
.userId(po.getUserId())
.field1(po.getField1())
.field2(po.getField2())
.date(po.getDate())
.status(XxxStatus.valueOf(po.getStatus()))
.note(po.getNote())
.build();
}
public XxxPO toPO(Xxx xxx) {
if (xxx == null) return null;
XxxPO po = new XxxPO();
po.setId(xxx.getId());
po.setUserId(xxx.getUserId());
po.setField1(xxx.getField1());
po.setField2(xxx.getField2());
po.setDate(xxx.getDate());
po.setStatus(xxx.getStatus().name());
po.setNote(xxx.getNote());
return po;
}
}
```
## 要点
- `@Component`,两层双向转换
- `toDomain` 使用 Domain 的 `@Builder` 构建
- `toPO` 使用 PO 的 setter(Lombok `@Data`)
- 枚举字段通过 `.name()` / `valueOf()` 与字符串互转