[测试代码](dev): 增加 摘要提取 的示例
This commit is contained in:
parent
3b7ba0a004
commit
533767e282
@ -19,6 +19,14 @@ public interface DemoService {
|
||||
* @author nn200433
|
||||
*/
|
||||
public List<People> dictDemo();
|
||||
|
||||
/**
|
||||
* 字典 & 脱敏 & 摘要提取 演示
|
||||
*
|
||||
* @return {@link List }<{@link People }>
|
||||
* @author song_jx
|
||||
*/
|
||||
public List<People> dictDemo2();
|
||||
|
||||
/**
|
||||
* 枚举演示
|
||||
|
@ -2,6 +2,7 @@ package com.aizuda.trans.demo.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.aizuda.trans.annotation.Dictionary;
|
||||
import com.aizuda.trans.entity.ExtendParam;
|
||||
import com.aizuda.trans.service.Translatable;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -16,10 +17,9 @@ import java.util.List;
|
||||
*/
|
||||
@Component
|
||||
public class CustomerTranslateServiceImpl implements Translatable {
|
||||
|
||||
|
||||
@Override
|
||||
public List<Object> translate(String groupValue, String conditionValue, String origin, Dictionary dictConfig,
|
||||
Class dictClass) {
|
||||
public List<Object> translate(String origin, Dictionary dictConfig, ExtendParam extendParam) {
|
||||
List<Object> rList = new ArrayList<Object>(1);
|
||||
if (StrUtil.equals(origin, "1")) {
|
||||
rList.add("结果1");
|
||||
@ -28,5 +28,5 @@ public class CustomerTranslateServiceImpl implements Translatable {
|
||||
}
|
||||
return rList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -24,7 +24,15 @@ public class DemoServiceImpl implements DemoService {
|
||||
People woman = People.builder().sex("2").id("2").phone("18612345678").build();
|
||||
return CollUtil.newArrayList(man, woman);
|
||||
}
|
||||
|
||||
|
||||
@Translator
|
||||
@Override
|
||||
public List<People> dictDemo2() {
|
||||
People man = People.builder().sex("1").id("1").phone("18612345678").introduce("我是一名热爱技术的软件工程师,专注于开发创新的解决方案。我拥有广泛的编程经验,熟悉多种编程语言和技术栈。我喜欢面对挑战并解决复杂的问题,具备良好的分析和解决问题的能力。我注重代码质量和可维护性,喜欢使用最佳实践和设计模式来构建可扩展和高效的应用程序。我乐于与团队合作,善于沟通和分享知识,致力于共同推动项目的成功。我不断学习新的技术和工具,保持与技术发展的步伐同步,以提供最佳的解决方案。").build();
|
||||
People woman = People.builder().sex("2").id("2").phone("18612345678").introduce("我是一名热爱艺术的画家,专注于创作独特的艺术作品。我擅长运用各种绘画技法和材料,将自己的创意和想法通过画笔表达出来。我热衷于探索艺术的边界,不断尝试新的艺术形式和风格,以展现出个人独特的艺术风格。我注重细节和色彩的运用,追求作品的美感和情感表达。我喜欢与其他艺术家交流和分享创作经验,通过合作和互相学习,共同提升艺术水平。我对艺术充满激情和创造力,致力于通过艺术作品传达自己的思想和感受,引发观众的共鸣和思考。我持续关注艺术界的动态和趋势,以保持与时代的连接,并不断探索艺术的可能性。").build();
|
||||
return CollUtil.newArrayList(man, woman);
|
||||
}
|
||||
|
||||
@Translator
|
||||
@Override
|
||||
public List<Device> enumDemo() {
|
||||
@ -55,8 +63,8 @@ public class DemoServiceImpl implements DemoService {
|
||||
Device man_d1 = Device.builder().status("1").build();
|
||||
Device woman_d2 = Device.builder().status("2").build();
|
||||
// 人
|
||||
People man = People.builder().sex("1").id("1").phone("18612345678").device(man_d1).build();
|
||||
People woman = People.builder().sex("2").id("2").phone("18612345678").device(woman_d2).build();
|
||||
People man = People.builder().sex("1").id("1").phone("18612345678").device(man_d1).introduce("我是一名热爱技术的软件工程师,专注于开发创新的解决方案。我拥有广泛的编程经验,熟悉多种编程语言和技术栈。我喜欢面对挑战并解决复杂的问题,具备良好的分析和解决问题的能力。我注重代码质量和可维护性,喜欢使用最佳实践和设计模式来构建可扩展和高效的应用程序。我乐于与团队合作,善于沟通和分享知识,致力于共同推动项目的成功。我不断学习新的技术和工具,保持与技术发展的步伐同步,以提供最佳的解决方案。").build();
|
||||
People woman = People.builder().sex("2").id("2").phone("18612345678").device(woman_d2).introduce("我是一名热爱艺术的画家,专注于创作独特的艺术作品。我擅长运用各种绘画技法和材料,将自己的创意和想法通过画笔表达出来。我热衷于探索艺术的边界,不断尝试新的艺术形式和风格,以展现出个人独特的艺术风格。我注重细节和色彩的运用,追求作品的美感和情感表达。我喜欢与其他艺术家交流和分享创作经验,通过合作和互相学习,共同提升艺术水平。我对艺术充满激情和创造力,致力于通过艺术作品传达自己的思想和感受,引发观众的共鸣和思考。我持续关注艺术界的动态和趋势,以保持与时代的连接,并不断探索艺术的可能性。").build();
|
||||
// 丢到响应数据里头,响应的真实数据由 ResultUnWrapper 类获取到
|
||||
return CollUtil.newArrayList(man, woman);
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import com.aizuda.trans.annotation.Translator;
|
||||
import com.aizuda.trans.constants.DesensitizedTypeConstants;
|
||||
import com.aizuda.trans.demo.impl.CustomerTranslateServiceImpl;
|
||||
import com.aizuda.trans.desensitized.Desensitized;
|
||||
import com.aizuda.trans.summary.SummaryExtract;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
@ -31,7 +32,11 @@ public class People {
|
||||
/** 手机号脱敏 */
|
||||
@Translate(dictClass = Desensitized.class, translateField = "phone", desensitizedModel = DesensitizedTypeConstants.MOBILE_PHONE)
|
||||
private String phone;
|
||||
|
||||
|
||||
/** 摘要提取 */
|
||||
@Translate(dictClass = SummaryExtract.class, maxLen = 10)
|
||||
private String introduce;
|
||||
|
||||
/** 自定义翻译 */
|
||||
@Translate(dictionary = @Dictionary(translator = CustomerTranslateServiceImpl.class), translateField = "name")
|
||||
private String id;
|
||||
|
@ -55,4 +55,10 @@ public class TranslatorTest {
|
||||
Console.log("---> 响应嵌套数据:{}", JSONUtil.toJsonStr(result));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void demo6() {
|
||||
List<People> peopleList = demoService.dictDemo2();
|
||||
Console.log("---> 字典 & 脱敏 & 摘要提取 翻译结果:{}", JSONUtil.toJsonStr(peopleList));
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user