init
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package com.sl;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.cache.annotation.EnableCaching;
|
||||
import org.springframework.cloud.openfeign.EnableFeignClients;
|
||||
|
||||
@EnableCaching
|
||||
@EnableFeignClients
|
||||
@SpringBootApplication
|
||||
public class TransportInfoApplication {
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TransportInfoApplication.class, args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.sl.transport.info.controller;
|
||||
|
||||
import com.sl.transport.common.exception.SLException;
|
||||
import com.sl.transport.common.util.BeanUtil;
|
||||
import com.sl.transport.common.util.ObjectUtil;
|
||||
import com.sl.transport.info.domain.TransportInfoDTO;
|
||||
import com.sl.transport.info.entity.TransportInfoEntity;
|
||||
import com.sl.transport.info.enums.ExceptionEnum;
|
||||
import com.sl.transport.info.service.TransportInfoService;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
@Api(tags = "物流信息")
|
||||
@RestController
|
||||
@RequestMapping("infos")
|
||||
public class TransportInfoController {
|
||||
|
||||
@Resource
|
||||
private TransportInfoService transportInfoService;
|
||||
|
||||
/**
|
||||
* 根据运单id查询运单信息
|
||||
*
|
||||
* @param transportOrderId 运单号
|
||||
* @return 运单信息
|
||||
*/
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "transportOrderId", value = "运单id")
|
||||
})
|
||||
@ApiOperation(value = "查询", notes = "根据运单id查询物流信息")
|
||||
@GetMapping("{transportOrderId}")
|
||||
public TransportInfoDTO queryByTransportOrderId(@PathVariable("transportOrderId") String transportOrderId) {
|
||||
TransportInfoEntity transportInfoEntity = transportInfoService.queryByTransportOrderId(transportOrderId);
|
||||
if (ObjectUtil.isNotEmpty(transportInfoEntity)) {
|
||||
return BeanUtil.toBean(transportInfoEntity, TransportInfoDTO.class);
|
||||
}
|
||||
throw new SLException(ExceptionEnum.NOT_FOUND);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.sl.transport.info.entity;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* 物流信息详情
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TransportInfoDetail{
|
||||
|
||||
private Long created; //创建时间,时间戳
|
||||
private String info; //详细信息,例如:您的快件已到达【北京通州分拣中心】
|
||||
private String status; //状态,例如:运输中
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.sl.transport.info.entity;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import lombok.Data;
|
||||
import org.bson.types.ObjectId;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.index.Indexed;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 运输物流信息
|
||||
*/
|
||||
@Data
|
||||
@Document("sl_transport_info")
|
||||
public class TransportInfoEntity {
|
||||
|
||||
@Id
|
||||
@JsonIgnore
|
||||
private ObjectId id;
|
||||
@Indexed
|
||||
private String transportOrderId; //运单id
|
||||
private List<TransportInfoDetail> infoList; //info信息列表
|
||||
private Long created; //创建时间
|
||||
private Long updated; //更新时间
|
||||
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.sl.transport.info.enums;
|
||||
|
||||
import com.sl.transport.common.enums.BaseExceptionEnum;
|
||||
|
||||
/**
|
||||
* 异常枚举
|
||||
*/
|
||||
public enum ExceptionEnum implements BaseExceptionEnum {
|
||||
|
||||
NOT_FOUND(1001, 404, "查询的运单不存在");
|
||||
|
||||
private Integer code;
|
||||
private Integer status;
|
||||
private String value;
|
||||
|
||||
ExceptionEnum(Integer code, String value) {
|
||||
this.code = code;
|
||||
this.value = value;
|
||||
this.status = 500;
|
||||
}
|
||||
|
||||
ExceptionEnum(Integer code, Integer status, String value) {
|
||||
this.code = code;
|
||||
this.status = status;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getCode() {
|
||||
return this.code;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.sl.transport.info.mq;
|
||||
|
||||
import com.sl.transport.common.constant.Constants;
|
||||
import org.springframework.amqp.core.ExchangeTypes;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 物流信息消息
|
||||
*/
|
||||
@Component
|
||||
public class TransportInfoMQListener {
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(
|
||||
value = @Queue(name = Constants.MQ.Queues.TRANSPORT_INFO_APPEND),
|
||||
exchange = @Exchange(name = Constants.MQ.Exchanges.TRANSPORT_INFO, type = ExchangeTypes.TOPIC),
|
||||
key = Constants.MQ.RoutingKeys.TRANSPORT_INFO_APPEND
|
||||
))
|
||||
@Transactional
|
||||
public void listenTransportInfoMsg(String msg) {
|
||||
//{"info":"您的快件已到达【$organId】", "status":"运输中", "organId":90001, "transportOrderId":"SL920733749248" , "created":1653133234913}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.sl.transport.info.service;
|
||||
|
||||
import com.sl.transport.info.domain.TransportInfoDTO;
|
||||
import com.sl.transport.info.entity.TransportInfoDetail;
|
||||
import com.sl.transport.info.entity.TransportInfoEntity;
|
||||
|
||||
/**
|
||||
* 物流信息服务
|
||||
*/
|
||||
public interface TransportInfoService {
|
||||
|
||||
|
||||
/**
|
||||
* 如果运单数据不存在,就新增,否则更新数据
|
||||
*
|
||||
* @param transportOrderId 运单id
|
||||
* @param infoDetail 信息详情
|
||||
* @return 运输信息数据
|
||||
*/
|
||||
TransportInfoEntity saveOrUpdate(String transportOrderId, TransportInfoDetail infoDetail);
|
||||
|
||||
/**
|
||||
* 根据运单id查询运输信息
|
||||
*
|
||||
* @param transportOrderId 运单id
|
||||
* @return 运输信息数据
|
||||
*/
|
||||
TransportInfoEntity queryByTransportOrderId(String transportOrderId);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
|
||||
_ ${spring.application.name} ${application.version}
|
||||
___ | | ___ __ __ _ __ _ __ ___ ___ ___ Port: ${server.port}
|
||||
/ __|| | _____ / _ \\ \/ /| '_ \ | '__|/ _ \/ __|/ __| Pid: ${pid} Profile(s): ${AnsiColor.GREEN}${spring.profiles.active}${AnsiColor.DEFAULT}
|
||||
\__ \| ||_____|| __/ > < | |_) || | | __/\__ \\__ \
|
||||
|___/|_| \___|/_/\_\| .__/ |_| \___||___/|___/ https://sl-express.itheima.net/
|
||||
|_|
|
||||
@@ -0,0 +1,27 @@
|
||||
server:
|
||||
port: 18087
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: 172.17.2.135:8848
|
||||
discovery:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
config:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-redis.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-rabbitmq.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
@@ -0,0 +1,27 @@
|
||||
server:
|
||||
port: 18087
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: 192.168.150.101:8848
|
||||
discovery:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
config:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-redis.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-rabbitmq.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
@@ -0,0 +1,27 @@
|
||||
server:
|
||||
port: 18087
|
||||
tomcat:
|
||||
uri-encoding: UTF-8
|
||||
threads:
|
||||
max: 1000
|
||||
min-spare: 30
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
username: nacos
|
||||
password: nacos
|
||||
server-addr: 172.17.2.135:8848
|
||||
discovery:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
config:
|
||||
namespace: ecae68ba-7b43-4473-a980-4ddeb6157bdc
|
||||
shared-configs: #共享配置
|
||||
- data-id: shared-spring-redis.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-rabbitmq.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
- data-id: shared-spring-mongodb.yml
|
||||
group: SHARED_GROUP
|
||||
refresh: false
|
||||
@@ -0,0 +1,23 @@
|
||||
application:
|
||||
version: v1.0
|
||||
logging:
|
||||
config: classpath:logback-spring.xml
|
||||
spring:
|
||||
application:
|
||||
name: sl-express-ms-transport-info
|
||||
profiles:
|
||||
active: local
|
||||
mvc:
|
||||
pathmatch:
|
||||
#解决异常:swagger Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
|
||||
#因为Springfox使用的路径匹配是基于AntPathMatcher的,而Spring Boot 2.6.X使用的是PathPatternMatcher
|
||||
matching-strategy: ant_path_matcher
|
||||
sl:
|
||||
swagger:
|
||||
package-path: com.sl.transport.info.controller
|
||||
title: 神领物流 - 运输信息微服务接口文档
|
||||
description: 该微服务完成运单的流转信息的记录以及查询。
|
||||
contact-name: 传智教育·研究院
|
||||
contact-url: http://www.itcast.cn/
|
||||
contact-email: yjy@itcast.cn
|
||||
version: ${application.version}
|
||||
@@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--scan: 当此属性设置为true时,配置文件如果发生改变,将会被重新加载,默认值为true。-->
|
||||
<!--scanPeriod: 设置监测配置文件是否有修改的时间间隔,如果没有给出时间单位,默认单位是毫秒。当scan为true时,此属性生效。默认的时间间隔为1分钟。-->
|
||||
<!--debug: 当此属性设置为true时,将打印出logback内部日志信息,实时查看logback运行状态。默认值为false。-->
|
||||
<configuration debug="false" scan="false" scanPeriod="60 seconds">
|
||||
<springProperty scope="context" name="appName" source="spring.application.name"/>
|
||||
<!--文件名-->
|
||||
<property name="logback.appname" value="${appName}"/>
|
||||
<!--文件位置-->
|
||||
<property name="logback.logdir" value="/data/logs"/>
|
||||
|
||||
<!-- 定义控制台输出 -->
|
||||
<appender name="stdout" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<layout class="ch.qos.logback.classic.PatternLayout">
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} - [%thread] - %-5level - %logger{50} - %msg%n</pattern>
|
||||
</layout>
|
||||
</appender>
|
||||
|
||||
|
||||
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<filter class="ch.qos.logback.classic.filter.ThresholdFilter">
|
||||
<level>DEBUG</level>
|
||||
</filter>
|
||||
<File>${logback.logdir}/${logback.appname}/${logback.appname}.log</File>
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
|
||||
<FileNamePattern>${logback.logdir}/${logback.appname}/${logback.appname}.%d{yyyy-MM-dd}.log.zip</FileNamePattern>
|
||||
<maxHistory>90</maxHistory>
|
||||
</rollingPolicy>
|
||||
<encoder>
|
||||
<charset>UTF-8</charset>
|
||||
<pattern>%d [%thread] %-5level %logger{36} %line - %msg%n</pattern>
|
||||
</encoder>
|
||||
</appender>
|
||||
|
||||
|
||||
<!--evel:用来设置打印级别,大小写无关:TRACE, DEBUG, INFO, WARN, ERROR, ALL 和 OFF,-->
|
||||
<!--不能设置为INHERITED或者同义词NULL。默认是DEBUG。-->
|
||||
<root level="INFO">
|
||||
<appender-ref ref="stdout"/>
|
||||
</root>
|
||||
</configuration>
|
||||
Reference in New Issue
Block a user