mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-10-30 01:38:43 +08:00 
			
		
		
		
	全局:增加 VO 数据翻译的支持
This commit is contained in:
		| @@ -77,6 +77,15 @@ | ||||
|             <groupId>com.github.yulichang</groupId> | ||||
|             <artifactId>mybatis-plus-join-boot-starter</artifactId> <!-- MyBatis 联表查询 --> | ||||
|         </dependency> | ||||
|  | ||||
|         <dependency> | ||||
|             <groupId>com.fhs-opensource</groupId> <!-- VO 数据翻译 --> | ||||
|             <artifactId>easy-trans-spring-boot-starter</artifactId> | ||||
|         </dependency> | ||||
|         <dependency> | ||||
|             <groupId>com.fhs-opensource</groupId> | ||||
|             <artifactId>easy-trans-mybatis-plus-extend</artifactId> | ||||
|         </dependency> | ||||
|     </dependencies> | ||||
|  | ||||
| </project> | ||||
|   | ||||
| @@ -3,6 +3,8 @@ package cn.iocoder.yudao.framework.mybatis.core.dataobject; | ||||
| import com.baomidou.mybatisplus.annotation.FieldFill; | ||||
| import com.baomidou.mybatisplus.annotation.TableField; | ||||
| import com.baomidou.mybatisplus.annotation.TableLogic; | ||||
| import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||||
| import com.fhs.core.trans.vo.TransPojo; | ||||
| import lombok.Data; | ||||
| import org.apache.ibatis.type.JdbcType; | ||||
|  | ||||
| @@ -12,10 +14,14 @@ import java.time.LocalDateTime; | ||||
| /** | ||||
|  * 基础实体对象 | ||||
|  * | ||||
|  * 为什么实现 {@link TransPojo} 接口? | ||||
|  * 因为使用 Easy-Trans TransType.SIMPLE 模式,集成 MyBatis Plus 查询 | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| @Data | ||||
| public abstract class BaseDO implements Serializable { | ||||
| @JsonIgnoreProperties(value = "transMap") // 由于 Easy-Trans 会添加 transMap 属性,避免 Jackson 在 Spring Cache 反序列化报错 | ||||
| public abstract class BaseDO implements Serializable, TransPojo { | ||||
|  | ||||
|     /** | ||||
|      * 创建时间 | ||||
|   | ||||
| @@ -1 +0,0 @@ | ||||
| package cn.iocoder.yudao.framework; | ||||
| @@ -0,0 +1,18 @@ | ||||
| package cn.iocoder.yudao.framework.translate.config; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.translate.core.TranslateUtils; | ||||
| import com.fhs.trans.service.impl.TransService; | ||||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||||
| import org.springframework.context.annotation.Bean; | ||||
|  | ||||
| @AutoConfiguration | ||||
| public class YudaoTranslateAutoConfiguration { | ||||
|  | ||||
|     @Bean | ||||
|     @SuppressWarnings({"InstantiationOfUtilityClass", "SpringJavaInjectionPointsAutowiringInspection"}) | ||||
|     public TranslateUtils translateUtils(TransService transService) { | ||||
|         TranslateUtils.init(transService); | ||||
|         return new TranslateUtils(); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,37 @@ | ||||
| package cn.iocoder.yudao.framework.translate.core; | ||||
|  | ||||
| import cn.hutool.core.collection.CollUtil; | ||||
| import com.fhs.core.trans.vo.VO; | ||||
| import com.fhs.trans.service.impl.TransService; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * VO 数据翻译 Utils | ||||
|  * | ||||
|  * @author 芋道源码 | ||||
|  */ | ||||
| public class TranslateUtils { | ||||
|  | ||||
|     private static TransService transService; | ||||
|  | ||||
|     public static void init(TransService transService) { | ||||
|         TranslateUtils.transService = transService; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 数据翻译 | ||||
|      * | ||||
|      * 使用场景:无法使用 @TransMethodResult 注解的场景,只能通过手动触发翻译 | ||||
|      * | ||||
|      * @param data 数据 | ||||
|      * @return 翻译结果 | ||||
|      */ | ||||
|     public static <T extends VO> List<T> translate(List<T> data) { | ||||
|         if (CollUtil.isNotEmpty((data))) { | ||||
|             transService.transBatch(data); | ||||
|         } | ||||
|         return data; | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -0,0 +1,4 @@ | ||||
| /** | ||||
|  * 使用 Easy-Trans 提升使用 VO 数据翻译的开发效率 | ||||
|  */ | ||||
| package cn.iocoder.yudao.framework.translate; | ||||
| @@ -1,2 +1,3 @@ | ||||
| cn.iocoder.yudao.framework.datasource.config.YudaoDataSourceAutoConfiguration | ||||
| cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration | ||||
| cn.iocoder.yudao.framework.mybatis.config.YudaoMybatisAutoConfiguration | ||||
| cn.iocoder.yudao.framework.translate.config.YudaoTranslateAutoConfiguration | ||||
		Reference in New Issue
	
	Block a user
	 YunaiV
					YunaiV