| New file | 
|  |  |  | 
|---|
|  |  |  | package com.dy.pipIrrGlobal.util; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import org.mapstruct.Named; | 
|---|
|  |  |  | import org.springframework.stereotype.Component; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * Mapping通用转换 | 
|---|
|  |  |  | */ | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | @SuppressWarnings("") | 
|---|
|  |  |  | public class TypeConversionDistrict { | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @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 ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|