Commit 5a4d818d by zhouhaibao

[+]新增接口

1 parent 49f9b9b6
...@@ -22,7 +22,7 @@ import com.glsx.plat.context.EnableRestAdmin; ...@@ -22,7 +22,7 @@ import com.glsx.plat.context.EnableRestAdmin;
*/ */
@EnableRestAdmin @EnableRestAdmin
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = { "cn.com.glsx.charging.*.api","cn.com.glsx.evbusiness.api" }) @EnableFeignClients(basePackages = { "cn.com.glsx.*.api"})
@SpringBootApplication @SpringBootApplication
/* /*
@PropertySource("application.properties_standalone") @PropertySource("application.properties_standalone")
......
...@@ -20,56 +20,59 @@ import javax.annotation.Resource; ...@@ -20,56 +20,59 @@ import javax.annotation.Resource;
@Configuration @Configuration
public class WebConfig implements WebMvcConfigurer { public class WebConfig implements WebMvcConfigurer {
@Resource @Resource
private UploadProperties uploadProperties; private UploadProperties uploadProperties;
/** /**
* 基于MDC的简单的日志链路 * 基于MDC的简单的日志链路
*/ */
@Resource @Resource
private LogInterceptor logInterceptor; private LogInterceptor logInterceptor;
/** /**
* 基于jwt的token认证 * 基于jwt的token认证
*/ */
@Resource @Resource
private VisitInterceptor<ComJwtUser> visitInterceptor; private VisitInterceptor<ComJwtUser> visitInterceptor;
/** /**
* 静态资源 * 静态资源
* *
* @param registry * @param registry
*/ */
@Override @Override
public void addResourceHandlers(ResourceHandlerRegistry registry) { public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry.addResourceHandler("/**") registry.addResourceHandler("/**")
.addResourceLocations("classpath:/META-INF/resources/") .addResourceLocations("classpath:/META-INF/resources/")
.addResourceLocations("classpath:/resources/") .addResourceLocations("classpath:/resources/")
.addResourceLocations("classpath:/static/") .addResourceLocations("classpath:/static/")
.addResourceLocations("classpath:/public/") .addResourceLocations("classpath:/public/")
.addResourceLocations("/dist/"); .addResourceLocations("/dist/");
//本地文件 //本地文件
registry.addResourceHandler("/files/**").addResourceLocations("file://" + uploadProperties.getBasePath()); registry.addResourceHandler("/files/**")
//swagger3 .addResourceLocations("file://" + uploadProperties.getBasePath());
registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/"); //swagger3
} registry.addResourceHandler("/swagger-ui/**")
.addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
}
@Override @Override
public void addInterceptors(InterceptorRegistry registry) { public void addInterceptors(InterceptorRegistry registry) {
//1.加入的顺序就是拦截器执行的顺序, //1.加入的顺序就是拦截器执行的顺序,
//2.按顺序执行所有拦截器的preHandle //2.按顺序执行所有拦截器的preHandle
//3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle //3.所有的preHandle 执行完再执行全部postHandle 最后是postHandle
registry.addInterceptor(visitInterceptor) /* registry.addInterceptor(visitInterceptor)
.addPathPatterns("/**") .addPathPatterns("/**")
.excludePathPatterns("/") .excludePathPatterns("/")
.excludePathPatterns("/login") .excludePathPatterns("/charging/**")
.excludePathPatterns("/actuator/**") .excludePathPatterns("/login")
.excludePathPatterns("/api/**") .excludePathPatterns("/actuator/**")
.excludePathPatterns("/pilecontro/**") .excludePathPatterns("/api/**")
.excludePathPatterns("/offline/card/**") .excludePathPatterns("/pilecontro/**")
.excludePathPatterns(uploadProperties.getFilepath()) .excludePathPatterns("/offline/card/**")
.excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html"); .excludePathPatterns(uploadProperties.getFilepath())
registry.addInterceptor(logInterceptor).addPathPatterns("/**"); .excludePathPatterns("/swagger-resources/**", "/swagger-ui/**", "/v3/**", "/doc.html");
} registry.addInterceptor(logInterceptor).addPathPatterns("/**");*/
}
} }
package cn.com.glsx.charging.modules.api; package cn.com.glsx.charging.modules.api;
import cn.com.glsx.charging.api.PileControlFeignClient; import cn.com.glsx.charging.api.PileControlFeignClient;
import cn.com.glsx.charging.api.UserCenterFeignClient;
import cn.com.glsx.charging.modules.converter.UserConverter;
import cn.com.glsx.charging.modules.entity.User;
import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper; import cn.com.glsx.charging.modules.gbt.ocpp16.Ocpp16Helper;
import cn.com.glsx.charging.modules.gbt.ocpp16.ServerMain; import cn.com.glsx.charging.modules.gbt.ocpp16.ServerMain;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpCallback; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.base.TcpCallback;
...@@ -14,23 +11,22 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData; ...@@ -14,23 +11,22 @@ import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.data.StartMachineReqData;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.AdminSwipeConfirmRsp; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.AdminSwipeConfirmRsp;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.ShutdownMachineReq;
import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineReq; import cn.com.glsx.charging.modules.gbt.ocpp16.tcp.protocol.StartMachineReq;
import cn.com.glsx.charging.modules.model.UserDTO;
import cn.com.glsx.charging.modules.model.pilecontrol.EndBo; import cn.com.glsx.charging.modules.model.pilecontrol.EndBo;
import cn.com.glsx.charging.modules.model.pilecontrol.StartBo; import cn.com.glsx.charging.modules.model.pilecontrol.StartBo;
import cn.com.glsx.charging.modules.service.UserDemoService; import cn.com.glsx.charging.modules.service.UserDemoService;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.glsx.plat.core.annotation.ResponseResultBody; import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.Result; import com.glsx.plat.core.web.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import java.math.BigDecimal; import java.math.BigDecimal;
import javax.annotation.Resource; import javax.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
/** /**
...@@ -45,10 +41,8 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -45,10 +41,8 @@ import org.springframework.web.bind.annotation.RestController;
@ResponseResultBody @ResponseResultBody
public class PileControlApiController implements PileControlFeignClient { public class PileControlApiController implements PileControlFeignClient {
@Resource
private UserDemoService userDemoService;
@Override @Override
@PostMapping("/start")
public Result<Boolean> start(@RequestBody StartBo startBo) { public Result<Boolean> start(@RequestBody StartBo startBo) {
log.info("启动充电桩请求入参{}", JSONObject.toJSONString(startBo)); log.info("启动充电桩请求入参{}", JSONObject.toJSONString(startBo));
StartMachineReq req = new StartMachineReq(); StartMachineReq req = new StartMachineReq();
...@@ -72,6 +66,7 @@ public class PileControlApiController implements PileControlFeignClient { ...@@ -72,6 +66,7 @@ public class PileControlApiController implements PileControlFeignClient {
} }
@Override @Override
@PostMapping("/end")
public Result<Boolean> end(@RequestBody EndBo endBo) { public Result<Boolean> end(@RequestBody EndBo endBo) {
log.info("停止充电桩请求入参{}", JSONObject.toJSONString(endBo)); log.info("停止充电桩请求入参{}", JSONObject.toJSONString(endBo));
ShutdownMachineReq req = new ShutdownMachineReq(); ShutdownMachineReq req = new ShutdownMachineReq();
...@@ -85,6 +80,7 @@ public class PileControlApiController implements PileControlFeignClient { ...@@ -85,6 +80,7 @@ public class PileControlApiController implements PileControlFeignClient {
} }
@Override @Override
@PostMapping("/pileStart")
public Result<Boolean> pileStart(@RequestBody StartBo startBo) { public Result<Boolean> pileStart(@RequestBody StartBo startBo) {
AdminSwipeConfirmRsp rsp = new AdminSwipeConfirmRsp(); AdminSwipeConfirmRsp rsp = new AdminSwipeConfirmRsp();
AdminSwipeConfirmRspData data = new AdminSwipeConfirmRspData(); AdminSwipeConfirmRspData data = new AdminSwipeConfirmRspData();
...@@ -102,4 +98,12 @@ public class PileControlApiController implements PileControlFeignClient { ...@@ -102,4 +98,12 @@ public class PileControlApiController implements PileControlFeignClient {
TcpRsp tcpRsp = tcpRspTcpCallback.get(); TcpRsp tcpRsp = tcpRspTcpCallback.get();
return Result.success(true); return Result.success(true);
} }
@Override
@PostMapping("/test")
@ResponseBody
public Result<Boolean> test() {
log.info("测试");
return Result.success(true);
}
} }
...@@ -34,11 +34,12 @@ spring.profiles.active=dev ...@@ -34,11 +34,12 @@ spring.profiles.active=dev
spring.cloud.nacos.config.file-extension=properties spring.cloud.nacos.config.file-extension=properties
#微服务sentinel、zipkin、actuator等公共配置 #微服务sentinel、zipkin、actuator等公共配置
spring.cloud.nacos.config.shared-configs[0].data-id=rest-microservice-share.properties spring.cloud.nacos.config.shared-configs[0].data-id=platform-microservice-share.properties
spring.cloud.nacos.config.shared-configs[0].group=ARCHETYPE_GROUP spring.cloud.nacos.config.shared-configs[0].group=${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[0].refresh=true spring.cloud.nacos.config.shared-configs[0].refresh=true
#数据库、redis等公共配置
spring.cloud.nacos.config.shared-configs[1].group=ARCHETYPE_GROUP
spring.cloud.nacos.config.shared-configs[1].data-id=rest-admin-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
\ No newline at end of file \ No newline at end of file
spring.cloud.nacos.config.shared-configs[1].group=${spring.cloud.nacos.config.group}
spring.cloud.nacos.config.shared-configs[1].data-id=platform-share-dev.properties
spring.cloud.nacos.config.shared-configs[1].refresh=true
feign.compression.request.min-request-size=4096
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!