add:增加计量单位转换feign api
This commit is contained in:
@@ -0,0 +1,85 @@
|
|||||||
|
package com.zt.plat.module.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.module.api.dto.unitconversion.*;
|
||||||
|
import com.zt.plat.module.base.enums.ApiConstants;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.cloud.openfeign.FeignClient;
|
||||||
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位转换 Feign API
|
||||||
|
* 提供给其他服务远程调用的单位转换接口
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@FeignClient(name = ApiConstants.NAME)
|
||||||
|
@Tag(name = "RPC 服务 - 单位转换")
|
||||||
|
public interface UnitConversionApi {
|
||||||
|
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/unit-management/unit-conversion";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按ID转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 转换请求参数
|
||||||
|
* @return 转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/convert")
|
||||||
|
@Operation(summary = "按ID转换单位")
|
||||||
|
CommonResult<UnitConvertRespDTO> convert(@Valid @RequestBody UnitConvertReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按符号转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 转换请求参数(包含单位符号)
|
||||||
|
* @return 转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/convert-by-symbol")
|
||||||
|
@Operation(summary = "按符号转换单位")
|
||||||
|
CommonResult<UnitConvertRespDTO> convertBySymbol(@Valid @RequestBody UnitConvertBySymbolReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按名称转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 转换请求参数(包含单位名称)
|
||||||
|
* @return 转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/convert-by-name")
|
||||||
|
@Operation(summary = "按名称转换单位")
|
||||||
|
CommonResult<UnitConvertRespDTO> convertByName(@Valid @RequestBody UnitConvertByNameReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量按ID转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 批量转换请求参数
|
||||||
|
* @return 批量转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/batch-convert")
|
||||||
|
@Operation(summary = "批量按ID转换单位")
|
||||||
|
CommonResult<BatchUnitConvertRespDTO> batchConvert(@Valid @RequestBody BatchUnitConvertReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量按符号转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 批量转换请求参数(包含单位符号)
|
||||||
|
* @return 批量转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/batch-convert-by-symbol")
|
||||||
|
@Operation(summary = "批量按符号转换单位")
|
||||||
|
CommonResult<BatchUnitConvertRespDTO> batchConvertBySymbol(@Valid @RequestBody BatchUnitConvertBySymbolReqDTO reqDTO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量按名称转换单位
|
||||||
|
*
|
||||||
|
* @param reqDTO 批量转换请求参数(包含单位名称)
|
||||||
|
* @return 批量转换结果
|
||||||
|
*/
|
||||||
|
@PostMapping(PREFIX + "/batch-convert-by-name")
|
||||||
|
@Operation(summary = "批量按名称转换单位")
|
||||||
|
CommonResult<BatchUnitConvertRespDTO> batchConvertByName(@Valid @RequestBody BatchUnitConvertByNameReqDTO reqDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量按名称单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 批量按名称单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class BatchUnitConvertByNameReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "千克")
|
||||||
|
@NotBlank(message = "源单位名称不能为空")
|
||||||
|
private String srcUnitName;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "吨")
|
||||||
|
@NotBlank(message = "目标单位名称不能为空")
|
||||||
|
private String tgtUnitName;
|
||||||
|
|
||||||
|
@Schema(description = "待转换的值列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "待转换的值列表不能为空")
|
||||||
|
private List<BigDecimal> values;
|
||||||
|
|
||||||
|
@Schema(description = "精度(小数位数)", example = "6")
|
||||||
|
private Integer precision = 6;
|
||||||
|
|
||||||
|
@Schema(description = "是否忽略错误(true:遇到错误继续执行, false:遇到错误立即停止)", example = "false")
|
||||||
|
private Boolean ignoreErrors = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量按符号单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 批量按符号单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class BatchUnitConvertBySymbolReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位符号", requiredMode = Schema.RequiredMode.REQUIRED, example = "m")
|
||||||
|
@NotBlank(message = "源单位符号不能为空")
|
||||||
|
private String srcUnitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位符号", requiredMode = Schema.RequiredMode.REQUIRED, example = "km")
|
||||||
|
@NotBlank(message = "目标单位符号不能为空")
|
||||||
|
private String tgtUnitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "待转换的值列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "待转换的值列表不能为空")
|
||||||
|
private List<BigDecimal> values;
|
||||||
|
|
||||||
|
@Schema(description = "精度(小数位数)", example = "6")
|
||||||
|
private Integer precision = 6;
|
||||||
|
|
||||||
|
@Schema(description = "是否忽略错误(true:遇到错误继续执行, false:遇到错误立即停止)", example = "false")
|
||||||
|
private Boolean ignoreErrors = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotEmpty;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 批量单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class BatchUnitConvertReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "转换项列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
@NotEmpty(message = "转换项列表不能为空")
|
||||||
|
private List<UnitConvertReqDTO> items;
|
||||||
|
|
||||||
|
@Schema(description = "是否忽略错误(true:遇到错误继续执行, false:遇到错误立即停止)", example = "false")
|
||||||
|
private Boolean ignoreErrors = false;
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量单位转换响应 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 批量单位转换 Response DTO")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class BatchUnitConvertRespDTO {
|
||||||
|
|
||||||
|
@Schema(description = "转换结果列表")
|
||||||
|
private List<UnitConvertResultItem> results;
|
||||||
|
|
||||||
|
@Schema(description = "成功数量", example = "10")
|
||||||
|
private Integer successCount;
|
||||||
|
|
||||||
|
@Schema(description = "失败数量", example = "0")
|
||||||
|
private Integer failureCount;
|
||||||
|
|
||||||
|
@Schema(description = "总数量", example = "10")
|
||||||
|
private Integer totalCount;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转换结果项
|
||||||
|
*/
|
||||||
|
@Schema(description = "转换结果项")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public static class UnitConvertResultItem {
|
||||||
|
|
||||||
|
@Schema(description = "是否成功", example = "true")
|
||||||
|
private Boolean success;
|
||||||
|
|
||||||
|
@Schema(description = "转换结果(成功时返回)")
|
||||||
|
private UnitConvertRespDTO data;
|
||||||
|
|
||||||
|
@Schema(description = "错误信息(失败时返回)", example = "找不到转换规则")
|
||||||
|
private String errorMessage;
|
||||||
|
|
||||||
|
@Schema(description = "原始请求")
|
||||||
|
private UnitConvertReqDTO request;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按名称单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 按名称单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class UnitConvertByNameReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "千克")
|
||||||
|
@NotBlank(message = "源单位名称不能为空")
|
||||||
|
private String srcUnitName;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "吨")
|
||||||
|
@NotBlank(message = "目标单位名称不能为空")
|
||||||
|
private String tgtUnitName;
|
||||||
|
|
||||||
|
@Schema(description = "待转换的值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||||
|
@NotNull(message = "待转换的值不能为空")
|
||||||
|
private BigDecimal value;
|
||||||
|
|
||||||
|
@Schema(description = "精度(小数位数)", example = "6")
|
||||||
|
private Integer precision = 6;
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import jakarta.validation.constraints.NotBlank;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按符号单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 按符号单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class UnitConvertBySymbolReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位符号", requiredMode = Schema.RequiredMode.REQUIRED, example = "kg")
|
||||||
|
@NotBlank(message = "源单位符号不能为空")
|
||||||
|
private String srcUnitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位符号", requiredMode = Schema.RequiredMode.REQUIRED, example = "t")
|
||||||
|
@NotBlank(message = "目标单位符号不能为空")
|
||||||
|
private String tgtUnitSymbol;
|
||||||
|
|
||||||
|
@Schema(description = "待转换的值", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||||
|
@NotNull(message = "待转换的值不能为空")
|
||||||
|
private BigDecimal value;
|
||||||
|
|
||||||
|
@Schema(description = "精度(小数位数)", example = "6")
|
||||||
|
private Integer precision = 6;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import jakarta.validation.constraints.NotNull;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位转换请求 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 单位转换 Request DTO")
|
||||||
|
@Data
|
||||||
|
public class UnitConvertReqDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
|
||||||
|
@NotNull(message = "源单位ID不能为空")
|
||||||
|
private Long srcUntId;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "2")
|
||||||
|
@NotNull(message = "目标单位ID不能为空")
|
||||||
|
private Long tgtUntId;
|
||||||
|
|
||||||
|
@Schema(description = "待转换的值", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||||
|
@NotNull(message = "待转换的值不能为空")
|
||||||
|
private BigDecimal value;
|
||||||
|
|
||||||
|
@Schema(description = "精度(小数位数)", example = "6")
|
||||||
|
private Integer precision = 6;
|
||||||
|
}
|
||||||
@@ -0,0 +1,55 @@
|
|||||||
|
package com.zt.plat.module.api.dto.unitconversion;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.NoArgsConstructor;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位转换响应 DTO
|
||||||
|
* 用于Feign远程调用
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@Schema(description = "RPC 服务 - 单位转换 Response DTO")
|
||||||
|
@Data
|
||||||
|
@Builder
|
||||||
|
@NoArgsConstructor
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class UnitConvertRespDTO {
|
||||||
|
|
||||||
|
@Schema(description = "源单位ID", example = "1")
|
||||||
|
private Long srcUntId;
|
||||||
|
|
||||||
|
@Schema(description = "源单位名称", example = "米")
|
||||||
|
private String srcUntName;
|
||||||
|
|
||||||
|
@Schema(description = "源单位符号", example = "m")
|
||||||
|
private String srcUntSmb;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位ID", example = "2")
|
||||||
|
private Long tgtUntId;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位名称", example = "千米")
|
||||||
|
private String tgtUntName;
|
||||||
|
|
||||||
|
@Schema(description = "目标单位符号", example = "km")
|
||||||
|
private String tgtUntSmb;
|
||||||
|
|
||||||
|
@Schema(description = "原始值", example = "1000")
|
||||||
|
private BigDecimal originalValue;
|
||||||
|
|
||||||
|
@Schema(description = "转换后的值", example = "1")
|
||||||
|
private BigDecimal convertedValue;
|
||||||
|
|
||||||
|
@Schema(description = "转换因子", example = "0.001")
|
||||||
|
private BigDecimal factor;
|
||||||
|
|
||||||
|
@Schema(description = "转换公式", example = "1000m = 1km")
|
||||||
|
private String formula;
|
||||||
|
|
||||||
|
@Schema(description = "转换策略", example = "DIRECT")
|
||||||
|
private String strategy;
|
||||||
|
}
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
package com.zt.plat.module.base.api;
|
||||||
|
|
||||||
|
import com.zt.plat.framework.common.pojo.CommonResult;
|
||||||
|
import com.zt.plat.framework.common.util.object.BeanUtils;
|
||||||
|
import com.zt.plat.module.api.UnitConversionApi;
|
||||||
|
import com.zt.plat.module.api.dto.unitconversion.*;
|
||||||
|
import com.zt.plat.module.base.controller.admin.unitConversion.vo.*;
|
||||||
|
import com.zt.plat.module.base.service.unitConversion.UnitConversionService;
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.validation.Valid;
|
||||||
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import static com.zt.plat.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单位转换 Feign API 实现类
|
||||||
|
* 直接调用现有的 UnitConversionService 方法
|
||||||
|
*
|
||||||
|
* @author ZT
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@Validated
|
||||||
|
public class UnitConversionApiImpl implements UnitConversionApi {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private UnitConversionService unitConversionService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<UnitConvertRespDTO> convert(@Valid UnitConvertReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
UnitConvertReqVO reqVO = BeanUtils.toBean(reqDTO, UnitConvertReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service
|
||||||
|
UnitConvertRespVO respVO = unitConversionService.convert(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
UnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, UnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<UnitConvertRespDTO> convertBySymbol(@Valid UnitConvertBySymbolReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
UnitConvertBySymbolReqVO reqVO = BeanUtils.toBean(reqDTO, UnitConvertBySymbolReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service
|
||||||
|
UnitConvertRespVO respVO = unitConversionService.convertBySymbol(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
UnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, UnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<UnitConvertRespDTO> convertByName(@Valid UnitConvertByNameReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
UnitConvertByNameReqVO reqVO = BeanUtils.toBean(reqDTO, UnitConvertByNameReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service
|
||||||
|
UnitConvertRespVO respVO = unitConversionService.convertByName(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
UnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, UnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<BatchUnitConvertRespDTO> batchConvert(@Valid BatchUnitConvertReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
BatchUnitConvertReqVO reqVO = BeanUtils.toBean(reqDTO, BatchUnitConvertReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service(Service已经实现了批量转换逻辑)
|
||||||
|
BatchUnitConvertRespVO respVO = unitConversionService.batchConvert(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
BatchUnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, BatchUnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<BatchUnitConvertRespDTO> batchConvertBySymbol(@Valid BatchUnitConvertBySymbolReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
BatchUnitConvertBySymbolReqVO reqVO = BeanUtils.toBean(reqDTO, BatchUnitConvertBySymbolReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service(Service已经实现了批量转换逻辑)
|
||||||
|
BatchUnitConvertRespVO respVO = unitConversionService.batchConvertBySymbol(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
BatchUnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, BatchUnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CommonResult<BatchUnitConvertRespDTO> batchConvertByName(@Valid BatchUnitConvertByNameReqDTO reqDTO) {
|
||||||
|
// DTO → VO
|
||||||
|
BatchUnitConvertByNameReqVO reqVO = BeanUtils.toBean(reqDTO, BatchUnitConvertByNameReqVO.class);
|
||||||
|
|
||||||
|
// 调用Service(Service已经实现了批量转换逻辑)
|
||||||
|
BatchUnitConvertRespVO respVO = unitConversionService.batchConvertByName(reqVO);
|
||||||
|
|
||||||
|
// VO → DTO
|
||||||
|
BatchUnitConvertRespDTO respDTO = BeanUtils.toBean(respVO, BatchUnitConvertRespDTO.class);
|
||||||
|
|
||||||
|
return success(respDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user