| package com.dy.pipIrrGlobal.util; | 
|   | 
| import com.dy.common.mybatis.envm.Deleted; | 
| import org.mapstruct.Named; | 
| import org.springframework.stereotype.Component; | 
| import java.util.Objects; | 
|   | 
| /** | 
|  * Mapping通用转换,数字与枚举转换 | 
|  */ | 
| @Component | 
| @SuppressWarnings("") | 
| public class TypeConversionEnum { | 
|     /** | 
|      * @param obj 参数 | 
|      * @return 转换成的对象 | 
|      */ | 
|     @Named("districtLevelByteToObj") | 
|     public DistrictLevel converseDistrictLevel(Object obj) { | 
|         if (Objects.isNull(obj)) { | 
|             return null; | 
|         }else{ | 
|             byte sourceObj = (obj instanceof Byte?(Byte)obj: DistrictLevel.City.code); | 
|             DistrictLevel rObj = null ; | 
|             if(sourceObj == DistrictLevel.City.code){ | 
|                 rObj = DistrictLevel.City ; | 
|             }else if(sourceObj == DistrictLevel.County.code){ | 
|                 rObj = DistrictLevel.County ; | 
|             }else if(sourceObj == DistrictLevel.Town.code){ | 
|                 rObj = DistrictLevel.Town ; | 
|             }else if(sourceObj == DistrictLevel.Village.code){ | 
|                 rObj = DistrictLevel.Village ; | 
|             } | 
|             return rObj ; | 
|         } | 
|     } | 
|     /** | 
|      * @param obj 参数 | 
|      * @return 转换成的对象 | 
|      */ | 
|     @Named("deletedByteToObj") | 
|     public Deleted converseDeleted(Object obj) { | 
|         if (Objects.isNull(obj)) { | 
|             return null; | 
|         }else{ | 
|             byte sourceObj = (obj instanceof Byte?(Byte)obj: Deleted.NO.code); | 
|             Deleted rObj ; | 
|             if(sourceObj == Deleted.NO.code){ | 
|                 rObj = Deleted.NO ; | 
|             }else if(sourceObj == Deleted.YES.code){ | 
|                 rObj = Deleted.YES ; | 
|             }else{ | 
|                 rObj = Deleted.NO ; | 
|             } | 
|             return rObj ; | 
|         } | 
|     } | 
| } |