Commit a70f203701075284b74ca1290c2479ff7e7dfa41
1 parent
bc95fd02
Exists in
master
百度接口回调封装,切图接口调试完成
Showing
11 changed files
with
265 additions
and
102 deletions
Show diff stats
... | ... | @@ -0,0 +1,9 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<module type="JAVA_MODULE" version="4"> | |
3 | + <component name="NewModuleRootManager" inherit-compiler-output="true"> | |
4 | + <exclude-output /> | |
5 | + <content url="file://$MODULE_DIR$" /> | |
6 | + <orderEntry type="inheritedJdk" /> | |
7 | + <orderEntry type="sourceFolder" forTests="false" /> | |
8 | + </component> | |
9 | +</module> | |
0 | 10 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,8 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project version="4"> | |
3 | + <component name="ProjectModuleManager"> | |
4 | + <modules> | |
5 | + <module fileurl="file://$PROJECT_DIR$/.idea/javassm.iml" filepath="$PROJECT_DIR$/.idea/javassm.iml" /> | |
6 | + </modules> | |
7 | + </component> | |
8 | +</project> | |
0 | 9 | \ No newline at end of file | ... | ... |
... | ... | @@ -0,0 +1,169 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<project version="4"> | |
3 | + <component name="ChangeListManager"> | |
4 | + <list default="true" id="3d777fc9-3797-4a37-8968-b32bb87dfc27" name="Default Changelist" comment=""> | |
5 | + <change afterPath="$PROJECT_DIR$/.idea/javassm.iml" afterDir="false" /> | |
6 | + <change afterPath="$PROJECT_DIR$/.idea/misc.xml" afterDir="false" /> | |
7 | + <change afterPath="$PROJECT_DIR$/.idea/modules.xml" afterDir="false" /> | |
8 | + <change afterPath="$PROJECT_DIR$/.idea/vcs.xml" afterDir="false" /> | |
9 | + <change beforePath="$PROJECT_DIR$/springboot/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/springboot/pom.xml" afterDir="false" /> | |
10 | + </list> | |
11 | + <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> | |
12 | + <option name="SHOW_DIALOG" value="false" /> | |
13 | + <option name="HIGHLIGHT_CONFLICTS" value="true" /> | |
14 | + <option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> | |
15 | + <option name="LAST_RESOLUTION" value="IGNORE" /> | |
16 | + </component> | |
17 | + <component name="DefaultGradleProjectSettings"> | |
18 | + <option name="testRunner" value="GRADLE" /> | |
19 | + <option name="delegatedBuild" value="true" /> | |
20 | + </component> | |
21 | + <component name="FileEditorManager"> | |
22 | + <leaf SIDE_TABS_SIZE_LIMIT_KEY="300"> | |
23 | + <file pinned="false" current-in-tab="false"> | |
24 | + <entry file="file://$PROJECT_DIR$/springboot/src/main/resources/application.properties"> | |
25 | + <provider selected="true" editor-type-id="text-editor"> | |
26 | + <state relative-caret-position="180"> | |
27 | + <caret line="12" column="40" selection-start-line="12" selection-start-column="40" selection-end-line="12" selection-end-column="40" /> | |
28 | + </state> | |
29 | + </provider> | |
30 | + </entry> | |
31 | + </file> | |
32 | + <file pinned="false" current-in-tab="true"> | |
33 | + <entry file="file://$PROJECT_DIR$/springboot/src/main/java/com/sincre/springboot/SpringbootApplication.java"> | |
34 | + <provider selected="true" editor-type-id="text-editor"> | |
35 | + <state relative-caret-position="210"> | |
36 | + <caret line="26" selection-start-line="26" selection-end-line="26" /> | |
37 | + </state> | |
38 | + </provider> | |
39 | + </entry> | |
40 | + </file> | |
41 | + </leaf> | |
42 | + </component> | |
43 | + <component name="Git.Settings"> | |
44 | + <option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" /> | |
45 | + </component> | |
46 | + <component name="ProjectFrameBounds"> | |
47 | + <option name="y" value="23" /> | |
48 | + <option name="width" value="1280" /> | |
49 | + <option name="height" value="777" /> | |
50 | + </component> | |
51 | + <component name="ProjectView"> | |
52 | + <navigator proportions="" version="1"> | |
53 | + <foldersAlwaysOnTop value="true" /> | |
54 | + </navigator> | |
55 | + <panes> | |
56 | + <pane id="ProjectPane"> | |
57 | + <subPane> | |
58 | + <expand> | |
59 | + <path> | |
60 | + <item name="javassm" type="b2602c69:ProjectViewProjectNode" /> | |
61 | + <item name="javassm" type="462c0819:PsiDirectoryNode" /> | |
62 | + </path> | |
63 | + <path> | |
64 | + <item name="javassm" type="b2602c69:ProjectViewProjectNode" /> | |
65 | + <item name="javassm" type="462c0819:PsiDirectoryNode" /> | |
66 | + <item name="springboot" type="462c0819:PsiDirectoryNode" /> | |
67 | + </path> | |
68 | + </expand> | |
69 | + <select /> | |
70 | + </subPane> | |
71 | + </pane> | |
72 | + <pane id="Scope" /> | |
73 | + <pane id="PackagesPane" /> | |
74 | + </panes> | |
75 | + </component> | |
76 | + <component name="PropertiesComponent"> | |
77 | + <property name="ASKED_SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> | |
78 | + <property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" /> | |
79 | + <property name="last_opened_file_path" value="$PROJECT_DIR$" /> | |
80 | + </component> | |
81 | + <component name="RunDashboard"> | |
82 | + <option name="ruleStates"> | |
83 | + <list> | |
84 | + <RuleState> | |
85 | + <option name="name" value="ConfigurationTypeDashboardGroupingRule" /> | |
86 | + </RuleState> | |
87 | + <RuleState> | |
88 | + <option name="name" value="StatusDashboardGroupingRule" /> | |
89 | + </RuleState> | |
90 | + </list> | |
91 | + </option> | |
92 | + </component> | |
93 | + <component name="SvnConfiguration"> | |
94 | + <configuration>$USER_HOME$/.subversion</configuration> | |
95 | + </component> | |
96 | + <component name="TaskManager"> | |
97 | + <task active="true" id="Default" summary="Default task"> | |
98 | + <changelist id="3d777fc9-3797-4a37-8968-b32bb87dfc27" name="Default Changelist" comment="" /> | |
99 | + <created>1573119911506</created> | |
100 | + <option name="number" value="Default" /> | |
101 | + <option name="presentableId" value="Default" /> | |
102 | + <updated>1573119911506</updated> | |
103 | + </task> | |
104 | + <servers /> | |
105 | + </component> | |
106 | + <component name="ToolWindowManager"> | |
107 | + <frame x="0" y="23" width="1280" height="777" extended-state="0" /> | |
108 | + <layout> | |
109 | + <window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.3206785" /> | |
110 | + <window_info id="Structure" order="1" side_tool="true" weight="0.25" /> | |
111 | + <window_info id="Image Layers" order="2" /> | |
112 | + <window_info id="Designer" order="3" /> | |
113 | + <window_info id="UI Designer" order="4" /> | |
114 | + <window_info id="Capture Tool" order="5" /> | |
115 | + <window_info id="Favorites" order="6" side_tool="true" /> | |
116 | + <window_info anchor="bottom" id="Message" order="0" /> | |
117 | + <window_info anchor="bottom" id="Find" order="1" /> | |
118 | + <window_info anchor="bottom" id="Run" order="2" /> | |
119 | + <window_info anchor="bottom" id="Debug" order="3" weight="0.4" /> | |
120 | + <window_info anchor="bottom" id="Cvs" order="4" weight="0.25" /> | |
121 | + <window_info anchor="bottom" id="Inspection" order="5" weight="0.4" /> | |
122 | + <window_info anchor="bottom" id="TODO" order="6" /> | |
123 | + <window_info anchor="bottom" id="Terminal" order="7" visible="true" weight="0.329927" /> | |
124 | + <window_info anchor="bottom" id="Event Log" order="8" side_tool="true" /> | |
125 | + <window_info anchor="bottom" id="Version Control" order="9" weight="0.329927" /> | |
126 | + <window_info anchor="bottom" id="Messages" order="10" /> | |
127 | + <window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" /> | |
128 | + <window_info anchor="right" id="Ant Build" order="1" weight="0.25" /> | |
129 | + <window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" /> | |
130 | + <window_info anchor="right" id="Palette" order="3" /> | |
131 | + <window_info anchor="right" id="Capture Analysis" order="4" /> | |
132 | + <window_info anchor="right" id="Theme Preview" order="5" /> | |
133 | + <window_info anchor="right" id="Maven" order="6" /> | |
134 | + <window_info anchor="right" id="Palette	" order="7" /> | |
135 | + </layout> | |
136 | + </component> | |
137 | + <component name="editorHistoryManager"> | |
138 | + <entry file="file://$PROJECT_DIR$/springboot/src/main/resources/application.properties"> | |
139 | + <provider selected="true" editor-type-id="text-editor"> | |
140 | + <state relative-caret-position="180"> | |
141 | + <caret line="12" column="40" selection-start-line="12" selection-start-column="40" selection-end-line="12" selection-end-column="40" /> | |
142 | + </state> | |
143 | + </provider> | |
144 | + </entry> | |
145 | + <entry file="file://$PROJECT_DIR$/springboot/src/main/java/com/sincre/springboot/SpringbootApplication.java"> | |
146 | + <provider selected="true" editor-type-id="text-editor"> | |
147 | + <state relative-caret-position="210"> | |
148 | + <caret line="26" selection-start-line="26" selection-end-line="26" /> | |
149 | + </state> | |
150 | + </provider> | |
151 | + </entry> | |
152 | + </component> | |
153 | + <component name="masterDetails"> | |
154 | + <states> | |
155 | + <state key="ProjectJDKs.UI"> | |
156 | + <settings> | |
157 | + <last-edited>1.8</last-edited> | |
158 | + <splitter-proportions> | |
159 | + <option name="proportions"> | |
160 | + <list> | |
161 | + <option value="0.2" /> | |
162 | + </list> | |
163 | + </option> | |
164 | + </splitter-proportions> | |
165 | + </settings> | |
166 | + </state> | |
167 | + </states> | |
168 | + </component> | |
169 | +</project> | |
0 | 170 | \ No newline at end of file | ... | ... |
springboot.iml
... | ... | @@ -21,11 +21,16 @@ |
21 | 21 | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-to-slf4j:2.11.2" level="project" /> |
22 | 22 | <orderEntry type="library" name="Maven: org.apache.logging.log4j:log4j-api:2.11.2" level="project" /> |
23 | 23 | <orderEntry type="library" name="Maven: org.slf4j:jul-to-slf4j:1.7.25" level="project" /> |
24 | + <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> | |
24 | 25 | <orderEntry type="library" scope="RUNTIME" name="Maven: org.yaml:snakeyaml:1.23" level="project" /> |
25 | 26 | <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-json:2.1.3.RELEASE" level="project" /> |
26 | 27 | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.9.8" level="project" /> |
27 | 28 | <orderEntry type="library" name="Maven: com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.9.8" level="project" /> |
28 | 29 | <orderEntry type="library" name="Maven: com.fasterxml.jackson.module:jackson-module-parameter-names:2.9.8" level="project" /> |
30 | + <orderEntry type="library" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.3.RELEASE" level="project" /> | |
31 | + <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.16" level="project" /> | |
32 | + <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.16" level="project" /> | |
33 | + <orderEntry type="library" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.16" level="project" /> | |
29 | 34 | <orderEntry type="library" name="Maven: org.hibernate.validator:hibernate-validator:6.0.14.Final" level="project" /> |
30 | 35 | <orderEntry type="library" name="Maven: javax.validation:validation-api:2.0.1.Final" level="project" /> |
31 | 36 | <orderEntry type="library" name="Maven: org.jboss.logging:jboss-logging:3.3.2.Final" level="project" /> |
... | ... | @@ -39,11 +44,6 @@ |
39 | 44 | <orderEntry type="library" name="Maven: com.zaxxer:HikariCP:3.2.0" level="project" /> |
40 | 45 | <orderEntry type="library" name="Maven: org.springframework:spring-jdbc:5.1.5.RELEASE" level="project" /> |
41 | 46 | <orderEntry type="library" name="Maven: org.springframework:spring-tx:5.1.5.RELEASE" level="project" /> |
42 | - <orderEntry type="library" scope="PROVIDED" name="Maven: org.springframework.boot:spring-boot-starter-tomcat:2.1.3.RELEASE" level="project" /> | |
43 | - <orderEntry type="library" name="Maven: javax.annotation:javax.annotation-api:1.3.2" level="project" /> | |
44 | - <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat.embed:tomcat-embed-core:9.0.16" level="project" /> | |
45 | - <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat.embed:tomcat-embed-el:9.0.16" level="project" /> | |
46 | - <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.tomcat.embed:tomcat-embed-websocket:9.0.16" level="project" /> | |
47 | 47 | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-starter-test:2.1.3.RELEASE" level="project" /> |
48 | 48 | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test:2.1.3.RELEASE" level="project" /> |
49 | 49 | <orderEntry type="library" scope="TEST" name="Maven: org.springframework.boot:spring-boot-test-autoconfigure:2.1.3.RELEASE" level="project" /> | ... | ... |
springboot/pom.xml
... | ... | @@ -11,7 +11,7 @@ |
11 | 11 | <groupId>com.sincre</groupId> |
12 | 12 | <artifactId>springboot</artifactId> |
13 | 13 | <version>0.0.1-SNAPSHOT</version> |
14 | - <packaging>war</packaging> | |
14 | + <packaging>jar</packaging> | |
15 | 15 | <name>springboot</name> |
16 | 16 | <description>Demo project for Spring Boot</description> |
17 | 17 | |
... | ... | @@ -37,11 +37,11 @@ |
37 | 37 | <artifactId>spring-boot-starter-jdbc</artifactId> |
38 | 38 | </dependency> |
39 | 39 | |
40 | - <dependency> | |
41 | - <groupId>org.springframework.boot</groupId> | |
42 | - <artifactId>spring-boot-starter-tomcat</artifactId> | |
43 | - <scope>provided</scope> | |
44 | - </dependency> | |
40 | +<!-- <dependency>--> | |
41 | +<!-- <groupId>org.springframework.boot</groupId>--> | |
42 | +<!-- <artifactId>spring-boot-starter-tomcat</artifactId>--> | |
43 | +<!-- <scope>provided</scope>--> | |
44 | +<!-- </dependency>--> | |
45 | 45 | |
46 | 46 | <dependency> |
47 | 47 | <groupId>org.springframework.boot</groupId> |
... | ... | @@ -135,6 +135,16 @@ |
135 | 135 | <groupId>com.baidu.aip</groupId> |
136 | 136 | <artifactId>java-sdk</artifactId> |
137 | 137 | <version>4.12.0</version> |
138 | + <exclusions> | |
139 | + <exclusion> | |
140 | + <groupId>org.slf4j</groupId> | |
141 | + <artifactId>slf4j-log4j12</artifactId> | |
142 | + </exclusion> | |
143 | + <exclusion> | |
144 | + <groupId>log4j</groupId> | |
145 | + <artifactId>log4j</artifactId> | |
146 | + </exclusion> | |
147 | + </exclusions> | |
138 | 148 | </dependency> |
139 | 149 | </dependencies> |
140 | 150 | ... | ... |
springboot/src/main/java/com/sincre/springboot/ApiModel/BaiduResult.java
1 | 1 | package com.sincre.springboot.ApiModel; |
2 | 2 | import com.fasterxml.jackson.annotation.JsonInclude; |
3 | 3 | |
4 | -@JsonInclude(JsonInclude.Include.NON_EMPTY) | |
5 | - | |
6 | -public class BaiduResult <T>{ | |
7 | - | |
8 | - public Boolean getSuccess() { | |
9 | - return success; | |
10 | - } | |
11 | - | |
12 | - public void setSuccess(Boolean success) { | |
13 | - this.success = success; | |
14 | - } | |
4 | +import java.util.List; | |
15 | 5 | |
16 | - public T getResult() { | |
17 | - return result; | |
18 | - } | |
19 | 6 | |
20 | - public void setResult(T result) { | |
21 | - this.result = result; | |
22 | - } | |
7 | +@JsonInclude(JsonInclude.Include.NON_EMPTY) | |
23 | 8 | |
24 | - public String getCode() { | |
25 | - return code; | |
26 | - } | |
9 | +public class BaiduResult <T>{ | |
27 | 10 | |
28 | - public void setCode(String code) { | |
29 | - this.code = code; | |
30 | - } | |
11 | + private int error_code; | |
12 | + private String error_msg; | |
31 | 13 | |
32 | - public String getMsg() { | |
33 | - return msg; | |
14 | + public String getError_msg() { | |
15 | + return error_msg; | |
34 | 16 | } |
35 | 17 | |
36 | - public void setMsg(String msg) { | |
37 | - this.msg = msg; | |
18 | + public void setError_msg(String error_msg) { | |
19 | + this.error_msg = error_msg; | |
38 | 20 | } |
39 | 21 | |
40 | - public Long getT() { | |
41 | - return t; | |
22 | + public int getError_code() { | |
23 | + return error_code; | |
42 | 24 | } |
43 | 25 | |
44 | - public void setT(Long t) { | |
45 | - this.t = t; | |
26 | + public void setError_code(int error_code) { | |
27 | + this.error_code = error_code; | |
46 | 28 | } |
47 | - | |
48 | - private Boolean success; | |
49 | - private String code; | |
50 | - private String msg; | |
51 | - private Long t; | |
52 | - private T result; | |
53 | 29 | } | ... | ... |
springboot/src/main/java/com/sincre/springboot/controller/BaiduController.java
... | ... | @@ -2,9 +2,7 @@ package com.sincre.springboot.controller; |
2 | 2 | |
3 | 3 | |
4 | 4 | import com.alibaba.fastjson.JSON; |
5 | -import com.baidu.aip.util.Base64Util; | |
6 | 5 | import com.sincre.springboot.ApiModel.BaiduResult; |
7 | -import com.sincre.springboot.ApiModel.TuYaResResult; | |
8 | 6 | import com.sincre.springboot.common.ServerResponse; |
9 | 7 | import com.sincre.springboot.utils.ApiHelper; |
10 | 8 | import com.sincre.springboot.utils.CacheHelper; |
... | ... | @@ -12,11 +10,9 @@ import com.sincre.springboot.utils.ResultUtils; |
12 | 10 | import io.swagger.annotations.Api; |
13 | 11 | import io.swagger.annotations.ApiImplicitParam; |
14 | 12 | import io.swagger.annotations.ApiOperation; |
15 | -import org.springframework.web.bind.annotation.GetMapping; | |
16 | -import org.springframework.web.bind.annotation.RequestMapping; | |
17 | -import org.springframework.web.bind.annotation.RestController; | |
13 | +import io.swagger.annotations.ApiParam; | |
14 | +import org.springframework.web.bind.annotation.*; | |
18 | 15 | |
19 | -import java.net.URLEncoder; | |
20 | 16 | import java.util.HashMap; |
21 | 17 | import java.util.Map; |
22 | 18 | |
... | ... | @@ -25,35 +21,29 @@ import java.util.Map; |
25 | 21 | @Api(tags = "百度云服务API调用") |
26 | 22 | public class BaiduController { |
27 | 23 | |
28 | - @ApiOperation("根据上传的图片二进制数据进行切图") | |
29 | - @ApiImplicitParam(name="imgPostData",value = "图片二进制数据",required = true) | |
30 | - @GetMapping("general") | |
31 | - public static ServerResponse general(byte[] imgPostData) { | |
24 | + @ApiOperation("根据上传的图片进行切图") | |
25 | + @ApiImplicitParam(name = "imgUrl",value = "图片地址url",required = true) | |
26 | + @PostMapping("cutPicture") | |
27 | + public ServerResponse cutPicture( String imgUrl) { | |
32 | 28 | // 请求url |
33 | 29 | String url = "https://aip.baidubce.com/rest/2.0/ocr/v1/general"; |
34 | - try { | |
35 | - byte[] imgData = imgPostData; | |
36 | - String imgStr = Base64Util.encode(imgData); | |
37 | - String imgParam = URLEncoder.encode(imgStr, "UTF-8"); | |
38 | - String param = "image=" + imgParam; | |
39 | - // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | |
40 | - String accessToken = CacheHelper.getBaiDuToken(); | |
41 | - Long t = System.currentTimeMillis(); | |
42 | - | |
43 | - Map<String,String> headMap = new HashMap<>(); | |
44 | - headMap.put("Content-Type","application/x-www-form-urlencoded"); | |
45 | - | |
46 | - Map<String,Object> bodyMap = new HashMap<>(); | |
47 | - bodyMap.put("image",param); | |
48 | - bodyMap.put("t",t.toString()); | |
49 | - | |
50 | - String result = ApiHelper.doPost(url+accessToken,headMap,bodyMap); | |
51 | - BaiduResult baiduResult = JSON.parseObject(result,BaiduResult.class); | |
52 | - return ResultUtils.getInstance().returnResultBaidu(baiduResult); | |
53 | - } catch (Exception e) { | |
54 | - e.printStackTrace(); | |
55 | - } | |
56 | - return null; | |
57 | - } | |
58 | 30 | |
31 | + String param = imgUrl; | |
32 | + // 注意这里仅为了简化编码每一次请求都去获取access_token,线上环境access_token有过期时间, 客户端可自行缓存,过期后重新获取。 | |
33 | + String accessToken = CacheHelper.getBaiDuToken(); | |
34 | + | |
35 | + String postToken = "?access_token=" + accessToken; | |
36 | + | |
37 | + Map<String, String> headMap = new HashMap<>(); | |
38 | + headMap.put("Content-Type", "application/x-www-form-urlencoded"); | |
39 | + | |
40 | + Map<String,Object> body = new HashMap<>(); | |
41 | + body.put("url",param); | |
42 | + | |
43 | + String result = ApiHelper.doPost(url+postToken,headMap,body); | |
44 | + | |
45 | + BaiduResult baiduResult = JSON.parseObject(result, BaiduResult.class); | |
46 | + | |
47 | + return ResultUtils.getInstance().returnResult_Baidu(baiduResult,result); | |
48 | + } | |
59 | 49 | } | ... | ... |
springboot/src/main/java/com/sincre/springboot/utils/ResultUtils.java
... | ... | @@ -96,31 +96,22 @@ public class ResultUtils { |
96 | 96 | |
97 | 97 | /** |
98 | 98 | * 百度云返回结果 |
99 | - * @param | |
99 | + * @param baiduResult | |
100 | 100 | * @return |
101 | 101 | */ |
102 | - public ServerResponse returnResultBaidu(BaiduResult baiduResResult) { | |
102 | + public ServerResponse returnResult_Baidu(BaiduResult baiduResult,String data) { | |
103 | 103 | try { |
104 | - boolean success = baiduResResult.getSuccess(); | |
104 | + int code = baiduResult.getError_code(); | |
105 | + String msg = baiduResult.getError_msg(); | |
105 | 106 | |
106 | - if (success) { | |
107 | - //data 返回的是数组 | |
108 | - if(JSON.isValidArray(baiduResResult.getResult().toString())){ | |
109 | - int total; | |
110 | - JSONArray jsonArray = JSON.parseArray(baiduResResult.getResult().toString()); | |
111 | - total = jsonArray.size(); | |
112 | - return ServerResponse.createBySuccess(String.valueOf(total), ResponseCode.SUCCESS.getDesc(), baiduResResult.getResult()); | |
113 | - } | |
114 | - //data 返回的是对象 | |
115 | - return ServerResponse.createBySuccess(ResponseCode.SUCCESS.getDesc(), baiduResResult.getResult()); | |
107 | + if (msg == null) { | |
108 | + return ServerResponse.createBySuccess(data); | |
109 | + }else{ | |
110 | + return ServerResponse.createByErrorCodeMessage(code,msg); | |
116 | 111 | } |
117 | - | |
118 | - int code = Integer.valueOf(baiduResResult.getCode()); | |
119 | - return ServerResponse.createByErrorCodeMessage(code, baiduResResult.getMsg()); | |
120 | 112 | } |
121 | 113 | catch (Exception ex){ |
122 | 114 | return ServerResponse.createByErrorMessage("服务器内部处理出错!"); |
123 | 115 | } |
124 | 116 | } |
125 | - | |
126 | 117 | } | ... | ... |
springboot/src/main/resources/application.properties
1 | 1 | spring.application.name=iot-api |
2 | 2 | #server.port=8088 |
3 | -# 设置数据库相关属性 | |
3 | + | |
4 | 4 | spring.datasource.username=thd |
5 | 5 | spring.datasource.password=pmd19930415A |
6 | 6 | spring.datasource.url=jdbc:sqlserver://60.190.202.57:14333;database=test |
... | ... | @@ -9,5 +9,5 @@ mybatis.config-location=classpath:mybatis-config.xml |
9 | 9 | mybatis.mapper-locations=classpath:/mapper/*.xml |
10 | 10 | mybatis.type-aliases-package=com.sincre.springboot.model |
11 | 11 | |
12 | -#对应服务注册中心的配置内容,指定服务注册中心的位置。 | |
13 | -eureka.client.serviceUrl.defaultZone=http://localhost:8001/eureka/ | |
14 | 12 | \ No newline at end of file |
13 | + | |
14 | +eureka.client.serviceUrl.defaultZone=http://121.40.109.21:8761/eureka/ | |
15 | 15 | \ No newline at end of file | ... | ... |