Skip to content

Commit a936df7

Browse files
committed
更新OCR
添加搜索中的新闻页
1 parent 73f33e4 commit a936df7

32 files changed

+1072
-281
lines changed

.classpath

+27
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,31 @@
133133
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
134134
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
135135
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
136+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
137+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
138+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
139+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
140+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
141+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
142+
<classpathentry kind="lib" path="/SpringBootTest/src/main/resources/lib/postgresql-9.3.jar"/>
143+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
144+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
145+
<classpathentry kind="lib" path="/SpringBootTest/src/main/resources/lib/postgresql-9.3.jar"/>
146+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
147+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
148+
<classpathentry kind="lib" path="/SpringBootTest/src/main/resources/lib/postgresql-9.3.jar"/>
149+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
150+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
151+
<classpathentry kind="lib" path="/SpringBootTest/src/main/resources/lib/postgresql-9.3.jar"/>
152+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
153+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
154+
<classpathentry kind="lib" path="src/main/resources/lib/ocr_sdk-1.3.6.jar"/>
155+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
156+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
157+
<classpathentry kind="lib" path="src/main/resources/lib/ocr_sdk-1.3.6.jar"/>
158+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/jconsole.jar"/>
159+
<classpathentry kind="lib" path="C:/Program Files/Java/jdk1.8.0_31/lib/tools.jar"/>
160+
<classpathentry kind="lib" path="src/main/resources/lib/ocr_sdk-1.3.6.jar"/>
136161
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.springframework.boot:spring-boot-starter-web:1.5.1.RELEASE"/>
137162
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.springframework.boot:spring-boot-starter:1.5.1.RELEASE"/>
138163
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.springframework.boot:spring-boot-starter-logging:1.5.1.RELEASE"/>
@@ -273,5 +298,7 @@
273298
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.jetbrains.kotlin:kotlin-test:1.1.2-4"/>
274299
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.jetbrains.kotlin:kotlin-stdlib:1.1.2-4"/>
275300
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.jetbrains:annotations:13.0"/>
301+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: org.json:json:20160810"/>
302+
<classpathentry kind="con" path="org.eclipse.jdt.USER_LIBRARY/Maven: com.baidu.aip:java-sdk:1.3.5"/>
276303
<classpathentry kind="output" path="target/classes"/>
277304
</classpath>

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@
22
/target/
33
/log/
44

5+
/static/

SpringBootWiki.eml

+11
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@
88
<excludeFolder url="file://$MODULE_DIR$/src/main/resources/templates/noues"/>
99
<excludeFolder url="file://$MODULE_DIR$/target"/>
1010
</contentEntry>
11+
<lib name="ocr_sdk-1.3.6.jar" scope="COMPILE">
12+
<relative-module-cls project-related="jar://$PROJECT_DIR$/src/main/resources/lib/ocr_sdk-1.3.6.jar!/"/>
13+
</lib>
14+
<lib name="src/main/resources/lib/ocr_sdk-1.3.6.jar" scope="COMPILE">
15+
<relative-module-cls project-related="jar://$PROJECT_DIR$/src/main/resources/lib/ocr_sdk-1.3.6.jar!/"/>
16+
</lib>
17+
<lib name="src/main/resources/lib/ocr_sdk-1.3.6.jar" scope="COMPILE">
18+
<relative-module-cls project-related="jar://$PROJECT_DIR$/src/main/resources/lib/ocr_sdk-1.3.6.jar!/"/>
19+
</lib>
1120
<lib name="Maven: org.yaml:snakeyaml:1.17" scope="RUNTIME"/>
1221
<lib name="Maven: org.springframework.boot:spring-boot-starter-test:1.5.1.RELEASE" scope="TEST"/>
1322
<lib name="Maven: org.springframework.boot:spring-boot-test:1.5.1.RELEASE" scope="TEST"/>
@@ -213,5 +222,7 @@
213222
<level name="Maven: org.jetbrains.kotlin:kotlin-test:1.1.2-4" value="project"/>
214223
<level name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.1.2-4" value="project"/>
215224
<level name="Maven: org.jetbrains:annotations:13.0" value="project"/>
225+
<level name="Maven: org.json:json:20160810" value="project"/>
226+
<level name="Maven: com.baidu.aip:java-sdk:1.3.5" value="project"/>
216227
</levels>
217228
</component>

pom.xml

+21-7
Original file line numberDiff line numberDiff line change
@@ -473,11 +473,6 @@
473473
<version>${kotlin.version}</version>
474474
<scope>test</scope>
475475
</dependency>
476-
<dependency>
477-
<groupId>org.jetbrains.kotlin</groupId>
478-
<artifactId>kotlin-stdlib-jre8</artifactId>
479-
<version>${kotlin.version}</version>
480-
</dependency>
481476

482477

483478
<!--<dependency>
@@ -491,7 +486,19 @@
491486
</exclusion>
492487
</exclusions>
493488
</dependency>-->
494-
489+
<!-- https://mvnrepository.com/artifact/org.json/json -->
490+
<dependency>
491+
<groupId>org.json</groupId>
492+
<artifactId>json</artifactId>
493+
<version>20160810</version>
494+
</dependency>
495+
<dependency>
496+
<groupId>com.baidu.aip</groupId>
497+
<artifactId>java-sdk</artifactId>
498+
<version>1.3.5</version>
499+
<!--<scope>system</scope>-->
500+
<!--<systemPath>${project.basedir}/src/main/resources/lib/ocr_sdk-1.3.6.jar</systemPath>-->
501+
</dependency>
495502

496503
</dependencies>
497504

@@ -520,6 +527,10 @@
520527
<name>SpringSource Enterprise Bundle Repository - External Bundle Releases</name>
521528
<url>http://repository.springsource.com/maven/bundles/external</url>
522529
</repository>-->
530+
<repository>
531+
<id>project-repo</id>
532+
<url>file://d:/repo</url>
533+
</repository>
523534

524535
<repository>
525536
<id>spring-libs-milestone</id>
@@ -644,10 +655,13 @@
644655
</archive>
645656
<excludes>
646657
<exclude>config/**</exclude>
658+
<exclude>lib/**</exclude>
659+
<exclude>manual/**</exclude>
647660
<exclude>templates/**</exclude>
648661
<exclude>static/**</exclude>
649-
<exclude>logback.xml</exclude>
650662
<exclude>nouse/**</exclude>
663+
<exclude>*.xml</exclude>
664+
<exclude>*.zip</exclude>
651665
</excludes>
652666
</configuration>
653667
</plugin>

src/main/java/net/liuxuan/SprKi/controller/faq/FAQController.java

+34-113
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import net.liuxuan.SprKi.entity.CMSCategoryEditor;
44
import net.liuxuan.SprKi.entity.CMSComment;
5+
import net.liuxuan.SprKi.entity.CMSContent;
56
import net.liuxuan.SprKi.entity.CMSContentTags;
67
import net.liuxuan.SprKi.entity.DTO.FAQSearchDTO;
78
import net.liuxuan.SprKi.entity.labthink.Department;
@@ -153,12 +154,18 @@ public String getFAQID(@PathVariable Long id, HttpServletRequest request, HttpSe
153154
FAQContent faq = faqContentService.findById(id);
154155

155156
//TODO 无权限时 显示内容
156-
if (!hasAccessRight(faq)) {
157+
if (!faqContentService.hasAccessRight(faq)) {
157158
faq = createNoAccessRightFaqContent("您无权编辑该条信息");
158159
faq.setId(id);
159160
model.put("faq", faq);
160161
return "faq/faq_show";
161162
}
163+
if(faq.isDisabled()==true){
164+
faq = createNoAccessRightFaqContent("该条信息已删除");
165+
faq.setId(id);
166+
model.put("faq", faq);
167+
return "faq/faq_show";
168+
}
162169

163170

164171
log.trace("faq to show publish_date is:{}", faq.getPublishDate());
@@ -190,12 +197,22 @@ public String showFAQID(@PathVariable Long id, HttpServletRequest request, HttpS
190197
if (faq == null) {
191198
throw new ContentNotFoundException("", id);
192199
}
193-
if (!hasAccessRight(faq)) {
200+
if (!faqContentService.hasAccessRight(faq)) {
194201
faq = createNoAccessRightFaqContent("您无权查看该条信息");
195202
faq.setId(id);
196203
model.put("faq", faq);
197204
return "faq/faq_show";
198205
}
206+
if(faq.isDisabled()==true){
207+
faq = createNoAccessRightFaqContent("该条信息已删除");
208+
faq.setId(id);
209+
model.put("faq", faq);
210+
return "faq/faq_show";
211+
}
212+
boolean isAdmin = SystemHelper.isCurrentUserAdmin();
213+
//将是否可修改comment设定到每个comment的 canedit属性中(临时属性,不计入数据库的)
214+
faq.getComments().stream().forEach(e->e.judgeCanEdit(isAdmin));
215+
199216
model.put("faq", faq);
200217
// devicesRepository.findAll();
201218
// List<Devices> devicesAll = devicesRepository.findAll();
@@ -222,7 +239,7 @@ public String deleteFAQID(@PathVariable Long id, HttpServletRequest request, Htt
222239
if (faq == null) {
223240
return "redirect:/faq/list";
224241
}
225-
if (!hasAccessRight(faq)) {
242+
if (!faqContentService.hasAccessRight(faq)) {
226243
faq = createNoAccessRightFaqContent("您无权删除该条信息");
227244
faq.setId(id);
228245
model.put("faq", faq);
@@ -253,109 +270,6 @@ public FAQContent createNoAccessRightFaqContent(String accessErrorText) {
253270
return faq;
254271
}
255272

256-
/**
257-
* Judge if the User has role to access the FAQContent.
258-
*
259-
* @param rolenames the rolenames
260-
* @param dept the faq
261-
* @return the boolean
262-
*/
263-
public boolean hasRole(Set<String> rolenames, Department dept) {
264-
String deparmentRoleName = departmentService.getDeparmentRoleName(dept);
265-
if (rolenames.contains(deparmentRoleName)) {
266-
return true;
267-
} else {
268-
return false;
269-
}
270-
}
271-
272-
/**
273-
* Judge if the User has role to access the FAQContent.
274-
*
275-
* @param rolenames the rolenames
276-
* @param faq the faq
277-
* @return the boolean
278-
*/
279-
public boolean hasRole(Set<String> rolenames, FAQContent faq) {
280-
return hasRole(rolenames, faq.getDepartment());
281-
}
282-
283-
/**
284-
* Judge if the User has role to access the FAQContent.
285-
*
286-
* @param faq the faq
287-
* @return the boolean
288-
*/
289-
public boolean hasRole(FAQContent faq) {
290-
List<Role> currentUserRoles = SystemHelper.getCurrentUserRoles();
291-
Set<String> rolenames = currentUserRoles.stream().map(e -> e.getRolename()).collect(Collectors.toSet());
292-
return hasRole(rolenames, faq);
293-
}
294-
295-
/**
296-
* Is admin boolean.
297-
*
298-
* @param rolenames the rolenames
299-
* @return the boolean
300-
*/
301-
public boolean isAdmin(Set<String> rolenames) {
302-
// if (rolenames.contains("ROLE_ADMIN")) {
303-
// return true;
304-
// }
305-
// return false;
306-
return rolenames.contains("ROLE_ADMIN");
307-
}
308-
309-
/**
310-
* Is admin boolean.
311-
*
312-
* @return the boolean
313-
*/
314-
public boolean isAdmin() {
315-
List<Role> currentUserRoles = SystemHelper.getCurrentUserRoles();
316-
Set<String> rolenames = currentUserRoles.stream().map(e -> e.getRolename()).collect(Collectors.toSet());
317-
return isAdmin(rolenames);
318-
}
319-
320-
/**
321-
* Is author boolean.
322-
*
323-
* @param faq the faq
324-
* @return the boolean
325-
*/
326-
public boolean isAuthor(FAQContent faq) {
327-
DbUser currentUser = SystemHelper.getCurrentUser();
328-
if (faq.getAuthor().getUsername().equals(currentUser.getUsername())) {
329-
return true;
330-
} else {
331-
return false;
332-
}
333-
}
334-
335-
/**
336-
* Has access right boolean.
337-
*
338-
* @param rolenames the rolenames
339-
* @param faq the faq
340-
* @return the boolean
341-
*/
342-
public boolean hasAccessRight(Set<String> rolenames, FAQContent faq) {
343-
boolean rtn = isAdmin(rolenames) || isAuthor(faq) || hasRole(rolenames, faq);
344-
return rtn;
345-
}
346-
347-
/**
348-
* Has access right boolean.
349-
*
350-
* @param faq the faq
351-
* @return the boolean
352-
*/
353-
public boolean hasAccessRight(FAQContent faq) {
354-
List<Role> currentUserRoles = SystemHelper.getCurrentUserRoles();
355-
Set<String> rolenames = currentUserRoles.stream().map(e -> e.getRolename()).collect(Collectors.toSet());
356-
return hasAccessRight(rolenames, faq);
357-
}
358-
359273
/**
360274
* Gets faq list.
361275
*
@@ -386,10 +300,11 @@ public String getFAQList(FAQSearchDTO dto, HttpServletRequest request, HttpServl
386300
/*
387301
处理按照权限查询
388302
*/
389-
List<FAQContent> filteredFAQContents = allFAQContents
390-
.stream()
391-
.filter(faq -> hasAccessRight(rolenames, faq))
392-
.collect(Collectors.toList());
303+
List<FAQContent> filteredFAQContents = faqContentService.filterListByAccessRight(allFAQContents,rolenames);
304+
// List<FAQContent> filteredFAQContents = allFAQContents
305+
// .stream()
306+
// .filter(faq -> hasAccessRight(rolenames, faq))
307+
// .collect(Collectors.toList());
393308
log.debug("faq list size is {}", filteredFAQContents.size());
394309
model.put("allfaqlist", filteredFAQContents);
395310
model.put("dto", dto);
@@ -454,14 +369,20 @@ public String postFAQ(FAQContent faq, HttpServletRequest request, Map<String, Ob
454369
@RequestMapping(value = "/faq/comment", method = RequestMethod.POST)
455370
// @PreAuthorize("hasRole('ROLE_USER')")
456371
public void postComment(CMSComment comment, HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws IOException {
457-
System.out.println(comment.getId());
372+
// System.out.println(comment.getId());
458373
FAQContent faq = faqContentService.findById(comment.getId());
459374
comment.setContent(faq);
460375
comment.setId(null);
461376
comment = cmsCommentService.saveCMSComment(comment);
462377
ResponseHelper.writeObjectToResponseAsJson(response,comment);
463-
464-
378+
}
379+
@RequestMapping(value = "/faq/comment/delete", method = RequestMethod.POST)
380+
public void deleteComment(CMSComment comment, HttpServletRequest request, HttpServletResponse response, Map<String, Object> model) throws IOException {
381+
System.out.println(comment.getId());
382+
comment = cmsCommentService.findCMSCommentById(comment.getId());
383+
faqContentService.refreshCache(comment.getContent().getId());
384+
boolean b = cmsCommentService.deleteCMSCommentById(comment.getId());
385+
ResponseHelper.writeObjectToResponseAsJson(response,b);
465386
}
466387

467388
/**

src/main/java/net/liuxuan/SprKi/controller/supporttools/OCRController.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package net.liuxuan.SprKi.controller.supporttools;
22

33
import net.liuxuan.utils.OCRUtils;
4+
import net.liuxuan.utils.OCRUtils2;
45
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
67
import org.springframework.stereotype.Controller;
@@ -54,7 +55,7 @@ public void uploadFileHandler(@RequestParam("file") String file,@RequestParam("t
5455
if(index>0){
5556
file =file.substring(index+7);
5657
}
57-
String res = OCRUtils.getOcrByBase64(file);
58+
String res = OCRUtils2.getOcrByBase64(file);
5859
try {
5960
response.getWriter().write(res);
6061
} catch (IOException e) {

0 commit comments

Comments
 (0)