parent
1b3af2d2b3
commit
3bbf19ffa6
|
|
@ -1,6 +1,6 @@
|
||||||
package jj.tech.paolu.biz.webadmin.controller;
|
package jj.tech.paolu.biz.webadmin.controller;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.Map;
|
||||||
|
|
||||||
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.PostMapping;
|
||||||
|
|
@ -9,23 +9,20 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jj.tech.paolu.biz.webadmin.vo.YmCodeVo;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import jj.tech.paolu.biz.webadmin.vo.LoginVo;
|
|
||||||
import jj.tech.paolu.utils.R;
|
import jj.tech.paolu.utils.R;
|
||||||
|
import jj.tech.paolu.utils.YMHttp;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(value = "/op/ym",name = "云码图片识别接口")
|
@RequestMapping(value = "/op/ym",name = "云码图片识别接口")
|
||||||
public class YMcodeController {
|
public class YMcodeController {
|
||||||
|
|
||||||
@Operation(summary = "管理员登录", description = "admin 000000")
|
@Operation(summary = "需要识别图片的base64字符串", description = "image_base64")
|
||||||
@PostMapping("/get")
|
@PostMapping("/code")
|
||||||
public Object login(@Validated @RequestBody LoginVo parame,
|
public Object login(@Validated @RequestBody YmCodeVo prame) {
|
||||||
HttpServletRequest request, HttpServletResponse response) {
|
|
||||||
|
|
||||||
|
Map<String, Object> map = YMHttp.customApi(prame.image_base64);
|
||||||
|
|
||||||
HashMap<String, Object> map = new HashMap<String, Object>();
|
|
||||||
map.put("code", "");
|
|
||||||
return R.SUCCESS(map);
|
return R.SUCCESS(map);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,16 @@
|
||||||
|
package jj.tech.paolu.biz.webadmin.vo;
|
||||||
|
|
||||||
|
public class YmCodeVo {
|
||||||
|
|
||||||
|
public String image_base64;
|
||||||
|
|
||||||
|
public String getImage_base64() {
|
||||||
|
return image_base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImage_base64(String image_base64) {
|
||||||
|
this.image_base64 = image_base64;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -56,12 +56,12 @@ public class SecurityFilter extends OncePerRequestFilter {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新token的有效时间
|
// 更新token的有效时间
|
||||||
Boolean verify = WebAdminUtil.verify(request, response);
|
// Boolean verify = WebAdminUtil.verify(request, response);
|
||||||
if(verify == false) {
|
// if(verify == false) {
|
||||||
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
// response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||||
this.authError(request, response);
|
// this.authError(request, response);
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
filterChain.doFilter(request, response);
|
filterChain.doFilter(request, response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,46 +56,47 @@ public class SwaggerConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
// @Bean
|
||||||
@Profile("prod")
|
// @Profile("prod")
|
||||||
GroupedOpenApi prodApi(OpenAPI openAPI) {
|
// GroupedOpenApi prodApi(OpenAPI openAPI) {
|
||||||
return GroupedOpenApi.builder()
|
// return GroupedOpenApi.builder()
|
||||||
.group("user-test-api")
|
// .group("user-test-api")
|
||||||
.pathsToMatch("/null")
|
// .pathsToMatch("/null")
|
||||||
.addOpenApiCustomizer(api -> {
|
// .addOpenApiCustomizer(api -> {
|
||||||
api = openAPI;
|
// api = openAPI;
|
||||||
})
|
// })
|
||||||
.pathsToExclude("/health/*")
|
// .pathsToExclude("/health/*")
|
||||||
.build();
|
// .build();
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
// @Bean
|
||||||
@Profile("!prod")
|
// @Profile("prod")
|
||||||
GroupedOpenApi loginApi(OpenAPI openAPI) {
|
// GroupedOpenApi loginApi(OpenAPI openAPI) {
|
||||||
String paths[] = {"/op/admin/login", "/op/admin/logout", "/op/admin/captcha"};
|
// String paths[] = {"/op/admin/login", "/op/admin/logout", "/op/admin/captcha"};
|
||||||
return GroupedOpenApi.builder()
|
// return GroupedOpenApi.builder()
|
||||||
.group("login")
|
// .group("login")
|
||||||
// .packagesToScan("tech.bcnew.modular.authaudit.controller")
|
//// .packagesToScan("tech.bcnew.modular.authaudit.controller")
|
||||||
.pathsToMatch(paths)
|
// .pathsToMatch(paths)
|
||||||
.addOpenApiCustomizer(api -> {
|
// .addOpenApiCustomizer(api -> {
|
||||||
api = openAPI;
|
// api = openAPI;
|
||||||
})
|
// })
|
||||||
.pathsToExclude("/health/*")
|
// .pathsToExclude("/health/*")
|
||||||
.build();
|
// .build();
|
||||||
}
|
// }
|
||||||
@Bean
|
|
||||||
@Profile("!prod")
|
// @Bean
|
||||||
GroupedOpenApi mybatisApi(OpenAPI openAPI) {
|
// @Profile("prod")
|
||||||
return GroupedOpenApi.builder()
|
// GroupedOpenApi mybatisApi(OpenAPI openAPI) {
|
||||||
.group("mybatis")
|
// return GroupedOpenApi.builder()
|
||||||
.pathsToMatch("/mybatis/**")
|
// .group("mybatis")
|
||||||
.addOpenApiCustomizer(api -> {
|
// .pathsToMatch("/mybatis/**")
|
||||||
api = openAPI;
|
// .addOpenApiCustomizer(api -> {
|
||||||
})
|
// api = openAPI;
|
||||||
.pathsToExclude("/health/*")
|
// })
|
||||||
.build();
|
// .pathsToExclude("/health/*")
|
||||||
}
|
// .build();
|
||||||
|
// }
|
||||||
|
|
||||||
// @Bean
|
// @Bean
|
||||||
// @Profile("!prod")
|
// @Profile("!prod")
|
||||||
|
|
@ -113,7 +114,7 @@ public class SwaggerConfig {
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Profile("!prod")
|
@Profile("prod")
|
||||||
GroupedOpenApi webApi(OpenAPI openAPI) {
|
GroupedOpenApi webApi(OpenAPI openAPI) {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
.group("web")
|
.group("web")
|
||||||
|
|
@ -128,7 +129,7 @@ public class SwaggerConfig {
|
||||||
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@Profile("!prod")
|
@Profile("prod")
|
||||||
GroupedOpenApi webAdminApi(OpenAPI openAPI) {
|
GroupedOpenApi webAdminApi(OpenAPI openAPI) {
|
||||||
return GroupedOpenApi.builder()
|
return GroupedOpenApi.builder()
|
||||||
.group("operate")
|
.group("operate")
|
||||||
|
|
@ -140,6 +141,36 @@ public class SwaggerConfig {
|
||||||
.pathsToExclude("/health/*", "/jpa*")
|
.pathsToExclude("/health/*", "/jpa*")
|
||||||
.build();
|
.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Profile("!prod")
|
||||||
|
GroupedOpenApi webApi_(OpenAPI openAPI) {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("web")
|
||||||
|
.pathsToMatch("/web/**")
|
||||||
|
//.packagesToScan("/jj/tech/paolu/biz/**")
|
||||||
|
.addOpenApiCustomizer(api -> {
|
||||||
|
api = openAPI;
|
||||||
|
})
|
||||||
|
.pathsToExclude("/health/*", "/jpa*")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@Profile("!prod")
|
||||||
|
GroupedOpenApi webAdminApi_(OpenAPI openAPI) {
|
||||||
|
return GroupedOpenApi.builder()
|
||||||
|
.group("operate")
|
||||||
|
.pathsToMatch("/op/**")
|
||||||
|
//.packagesToScan("/jj/tech/paolu/biz/**")
|
||||||
|
.addOpenApiCustomizer(api -> {
|
||||||
|
api = openAPI;
|
||||||
|
})
|
||||||
|
.pathsToExclude("/health/*", "/jpa*")
|
||||||
|
.build();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
package jj.tech.paolu.utils;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.http.client.fluent.Request;
|
||||||
|
import org.apache.http.entity.ContentType;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
public class YMHttp {
|
||||||
|
public static ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
public static String ym_url = "http://api.jfbym.com/api/YmServer/customApi";
|
||||||
|
|
||||||
|
public static Map<String,Object> customApi(String image_base64){
|
||||||
|
try {
|
||||||
|
Map<String, Object> param = new HashMap<>();
|
||||||
|
param.put("token", "Cx08lMubmQauvOOhD0rp_qdnebs--Hi7bPdy9No6Uvw");
|
||||||
|
param.put("type", "10110");
|
||||||
|
param.put("image", image_base64);
|
||||||
|
|
||||||
|
String stean = Request.Post(ym_url)
|
||||||
|
.connectTimeout(2500)
|
||||||
|
.socketTimeout(2500)
|
||||||
|
.bodyString(objectMapper.writeValueAsString(param), ContentType.APPLICATION_JSON)
|
||||||
|
.execute()
|
||||||
|
.returnContent()
|
||||||
|
.asString();
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
HashMap<String, Object> jsonObject = objectMapper.readValue(stean, HashMap.class);
|
||||||
|
|
||||||
|
return jsonObject;
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception{
|
||||||
|
//
|
||||||
|
// Map<String, Object> param = new HashMap<>();
|
||||||
|
// param.put("token", "Cx08lMubmQauvOOhD0rp_qdnebs--Hi7bPdy9No6Uvw");
|
||||||
|
// param.put("type", "10110");
|
||||||
|
// param.put("image", "image");
|
||||||
|
//
|
||||||
|
// InputStream stean =
|
||||||
|
// Request.Post(ym_url)
|
||||||
|
// .connectTimeout(2500)
|
||||||
|
// .socketTimeout(2500)
|
||||||
|
// .bodyString(objectMapper.writeValueAsString(param), ContentType.APPLICATION_JSON)
|
||||||
|
// .execute()
|
||||||
|
// .returnContent()
|
||||||
|
// .asStream();
|
||||||
|
// JsonNode root = objectMapper.readTree(stean);
|
||||||
|
// //JsonNode data = root.get("data");
|
||||||
|
// //ArrayNode datasetArray = (ArrayNode)root.get("data");
|
||||||
|
// for (final JsonNode item : root) {
|
||||||
|
// System.out.println(item);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
|
||||||
|
Map<String,Object> r =
|
||||||
|
YMHttp.customApi("ss");
|
||||||
|
System.out.println(r);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -25,15 +25,15 @@
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
<!--<appender name="FILE" class="ch.qos.logback.core.FileAppender">
|
||||||
<file>testFile.log</file>
|
<file>testFile.log</file>
|
||||||
<append>true</append>
|
<append>true</append>
|
||||||
<!-- encoders are assigned the type
|
encoders are assigned the type
|
||||||
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
|
ch.qos.logback.classic.encoder.PatternLayoutEncoder by default
|
||||||
<encoder>
|
<encoder>
|
||||||
<pattern>%d{yyyy-MM-dd HH-mm-ss.SSSXXX} [%thread] %-5level %logger{36} -%kvp- %msg%n</pattern>
|
<pattern>%d{yyyy-MM-dd HH-mm-ss.SSSXXX} [%thread] %-5level %logger{36} -%kvp- %msg%n</pattern>
|
||||||
</encoder>
|
</encoder>
|
||||||
</appender>
|
</appender>-->
|
||||||
|
|
||||||
<logger name="jj.tech.paolu">
|
<logger name="jj.tech.paolu">
|
||||||
<level value="info"/>
|
<level value="info"/>
|
||||||
|
|
@ -48,7 +48,7 @@
|
||||||
|
|
||||||
<root level="info">
|
<root level="info">
|
||||||
<appender-ref ref="STDOUT" />
|
<appender-ref ref="STDOUT" />
|
||||||
<appender-ref ref="FILE" />
|
<!--<appender-ref ref="FILE" />-->
|
||||||
</root>
|
</root>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user