refactor: TransportTaskApiImpl 改为 Feign 模式,新增 TransportTaskApi 接口和 RpcConfiguration
This commit is contained in:
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.code.nl.module.task.api;
|
||||||
|
|
||||||
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
|
import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO;
|
||||||
|
import cn.code.nl.module.task.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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task 服务 RPC API 接口
|
||||||
|
* <p>
|
||||||
|
* LMS/WMS 等调用方通过 Feign 客户端注入此接口,调用 Task 服务
|
||||||
|
*/
|
||||||
|
@FeignClient(name = ApiConstants.NAME)
|
||||||
|
@Tag(name = "RPC 服务 - 搬运任务")
|
||||||
|
public interface TransportTaskApi {
|
||||||
|
|
||||||
|
String PREFIX = ApiConstants.PREFIX + "/transport";
|
||||||
|
|
||||||
|
@PostMapping(PREFIX + "/create")
|
||||||
|
@Operation(summary = "创建搬运任务(LMS/WMS 调用)")
|
||||||
|
CommonResult<Long> createTransportTask(@Valid @RequestBody TransportTaskCreateReqDTO reqDTO);
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Author: liyongde
|
||||||
|
* @Date: 2026/7/14 18:57
|
||||||
|
*/package cn.code.nl.module.task.api;
|
||||||
@@ -2,32 +2,25 @@ package cn.code.nl.module.task.api;
|
|||||||
|
|
||||||
import cn.code.nl.framework.common.pojo.CommonResult;
|
import cn.code.nl.framework.common.pojo.CommonResult;
|
||||||
import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO;
|
import cn.code.nl.module.task.dto.TransportTaskCreateReqDTO;
|
||||||
import cn.code.nl.module.task.enums.ApiConstants;
|
|
||||||
import cn.code.nl.module.task.service.transporttask.TransportTaskService;
|
import cn.code.nl.module.task.service.transporttask.TransportTaskService;
|
||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import jakarta.validation.Valid;
|
|
||||||
|
|
||||||
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
import static cn.code.nl.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task 服务 RPC 接口实现
|
* Task 服务 RPC 接口实现(Feign 服务端)
|
||||||
*/
|
*/
|
||||||
@RestController
|
@RestController // 提供 RESTful API 接口,给 Feign 调用
|
||||||
@RequestMapping(ApiConstants.PREFIX)
|
|
||||||
@Validated
|
@Validated
|
||||||
public class TransportTaskApiImpl {
|
public class TransportTaskApiImpl implements TransportTaskApi {
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TransportTaskService transportTaskService;
|
private TransportTaskService transportTaskService;
|
||||||
|
|
||||||
@PostMapping("/transport/create")
|
@Override
|
||||||
public CommonResult<Long> createTransportTask(@Valid @RequestBody TransportTaskCreateReqDTO reqDTO) {
|
public CommonResult<Long> createTransportTask(TransportTaskCreateReqDTO reqDTO) {
|
||||||
return success(transportTaskService.createTransportTaskByRpc(reqDTO));
|
return success(transportTaskService.createTransportTaskByRpc(reqDTO));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.code.nl.module.task.framework.rpc.config;
|
||||||
|
|
||||||
|
import cn.code.nl.module.task.api.TransportTaskApi;
|
||||||
|
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Task 服务 RPC 配置
|
||||||
|
* <p>
|
||||||
|
* 注册 Feign 客户端,使 LMS/WMS 等调用方可通过 @Resource 注入 TransportTaskApi
|
||||||
|
*/
|
||||||
|
@Configuration
|
||||||
|
@EnableFeignClients(clients = {TransportTaskApi.class})
|
||||||
|
public class RpcConfiguration {
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Author: liyongde
|
||||||
|
* @Date: 2026/7/14 18:47
|
||||||
|
*/package cn.code.nl.module.task.mq.consumer;
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
/**
|
||||||
|
*
|
||||||
|
* @Author: liyongde
|
||||||
|
* @Date: 2026/7/14 18:47
|
||||||
|
*/package cn.code.nl.module.task.mq.message;
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* 消息队列的消息
|
||||||
|
*/
|
||||||
|
package cn.code.nl.module.infra.mq.message;
|
||||||
Reference in New Issue
Block a user