ting.yin пре 8 година
родитељ
комит
018c8fe05b

+ 25 - 10
exam-work-api/pom.xml

@@ -12,11 +12,6 @@
     <artifactId>exam-work-api</artifactId>
 
     <dependencies>
-        <dependency>
-            <artifactId>exam-work-domain</artifactId>
-            <groupId>cn.com.qmth.examcloud.service</groupId>
-            <version>0.1.0</version>
-        </dependency>
         <dependency>
             <groupId>org.springframework.cloud</groupId>
             <artifactId>spring-cloud-starter-feign</artifactId>
@@ -39,10 +34,11 @@
             <artifactId>springfox-swagger-ui</artifactId>
             <version>2.6.1</version>
         </dependency>
-        <dependency>
-            <groupId>com.google.code.gson</groupId>
-            <artifactId>gson</artifactId>
-            <version>2.8.0</version>
+        
+		<dependency>
+            <artifactId>exam-work-domain</artifactId>
+            <groupId>cn.com.qmth.examcloud.service</groupId>
+            <version>0.1.0</version>
         </dependency>
 		<dependency>
             <groupId>cn.com.qmth.examcloud.common</groupId>
@@ -60,6 +56,25 @@
             <version>1.0</version>
         </dependency>
     </dependencies>
-
+    
+	<build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+                <configuration>
+                    <includeSystemScope>true</includeSystemScope>
+                </configuration>
+            </plugin>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <configuration>
+                    <source>1.8</source>
+                    <target>1.8</target>
+                </configuration>
+            </plugin>
+		</plugins>
+    </build>
 
 </project>

+ 15 - 5
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/ExamStudentService.java

@@ -13,6 +13,8 @@ import java.util.List;
 import java.util.zip.ZipEntry;
 import java.util.zip.ZipInputStream;
 
+import javax.persistence.criteria.Predicate;
+
 import org.json.JSONArray;
 import org.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,6 +23,7 @@ import org.springframework.data.domain.Example;
 import org.springframework.data.domain.ExampleMatcher;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
+import org.springframework.data.jpa.domain.Specification;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
@@ -67,10 +70,17 @@ public class ExamStudentService {
      * @return
      */
     public  Page<ExamStudent> getAllExamStudent(ExamStudent examCriteria, Pageable pageable){
-        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
-                .withMatcher("name",startsWith());
-        Example<ExamStudent> examExamStudentple = Example.of(examCriteria, exampleMatcher);
-        return examStudentRepo.findAll(examExamStudentple,pageable);
+//        ExampleMatcher exampleMatcher = ExampleMatcher.matching()
+//                .withMatcher("name",startsWith());
+//        Example<ExamStudent> examExamStudentple = Example.of(examCriteria, exampleMatcher);
+//        return examStudentRepo.findAll(examExamStudentple,pageable);
+    	Specification<ExamStudent> specification = (root, query, cb) -> {
+            List<Predicate> predicates = new ArrayList<>();
+            predicates.add(cb.like(root.get("name"),examCriteria.getName()));
+            predicates.add(cb.like(root.get("studentCode"),examCriteria.getStudentCode()));
+            return cb.and(predicates.toArray(new Predicate[predicates.size()]));
+        };
+        return examStudentRepo.findAll(specification,pageable);
     }
 
     /**
@@ -265,7 +275,7 @@ public class ExamStudentService {
 			JSONArray faceArray = face.getJSONArray("face");
 			if (faceArray.length() > 0) {
 				//人脸识别成功
-//				studentService.updatePhoto(identityNumber);
+				studentService.updatePhoto(identityNumber);
 			} else {
 				error = new ErrorMsg(identityNumber + JPG + "不能被识别人脸,请换一张清晰的照片重新上传!");
 			}

+ 8 - 8
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/StudentService.java

@@ -15,13 +15,13 @@ import cn.com.qmth.examcloud.service.examwork.service.rpc.client.StudentClient;
 @Service
 public class StudentService {
 
-//	@Autowired
-//	StudentClient studentClient;
-//
-//	public Student updatePhoto(String identityNumber) {
-//		String json = studentClient.updatePhoto(identityNumber);
-//		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
-//		return domain;
-//	}
+	@Autowired
+	StudentClient studentClient;
+
+	public Student updatePhoto(String identityNumber) {
+		String json = studentClient.updatePhoto(identityNumber);
+		Student domain = GsonUtil.getInstanceByJson(json, Student.class);
+		return domain;
+	}
 
 }

+ 3 - 3
exam-work-api/src/main/java/cn/com/qmth/examcloud/service/examwork/service/rpc/client/StudentClient.java

@@ -10,10 +10,10 @@ import org.springframework.web.bind.annotation.RequestParam;
  * @author ting.yin
  * @date 2017年1月14日
  */
-//@FeignClient(value = "ExamCloud-service-core")
+@FeignClient(value = "ExamCloud-service-core")
 public interface StudentClient {
 
-//	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/update")
-//	String updatePhoto(@RequestParam("identityNumber") String identityNumber);
+	@RequestMapping(method = RequestMethod.GET, value = "${app.api.core}/student/update")
+	String updatePhoto(@RequestParam("identityNumber") String identityNumber);
 
 }

+ 3 - 3
exam-work-domain/src/main/java/cn/com/qmth/examcloud/service/examwork/dao/ExamStudentRepo.java

@@ -5,12 +5,12 @@ import java.util.List;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
 import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+import org.springframework.data.repository.query.QueryByExampleExecutor;
 
 import cn.com.qmth.examcloud.service.examwork.entity.ExamStudent;
 
-import org.springframework.data.repository.query.QueryByExampleExecutor;
-
-public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>,QueryByExampleExecutor<ExamStudent> {
+public interface ExamStudentRepo extends JpaRepository<ExamStudent, Long>,QueryByExampleExecutor<ExamStudent>,JpaSpecificationExecutor<ExamStudent> {
     Page<ExamStudent> findByExamId(Long examId, Pageable pageable);
 
 	List<ExamStudent> findByExamId(Long examId);

+ 0 - 28
exam-work-main/pom.xml

@@ -16,33 +16,5 @@
             <artifactId>exam-work-api</artifactId>
             <version>0.1.0</version>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-feign</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.cloud</groupId>
-            <artifactId>spring-cloud-starter-eureka</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-test</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-devtools</artifactId>
-            <optional>true</optional>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger2</artifactId>
-            <version>2.6.1</version>
-        </dependency>
-        <dependency>
-            <groupId>io.springfox</groupId>
-            <artifactId>springfox-swagger-ui</artifactId>
-            <version>2.6.1</version>
-        </dependency>
     </dependencies>
 </project>

+ 4 - 2
exam-work-main/src/main/java/cn/com/qmth/examcloud/service/examwork/Application.java

@@ -6,11 +6,13 @@ import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
 import org.springframework.cloud.netflix.feign.EnableFeignClients;
 
 @SpringBootApplication
-//@EnableEurekaClient
-//@EnableFeignClients
+@EnableEurekaClient
+@EnableFeignClients
 public class Application {
 
 	public static void main(String[] args) throws Exception {
 		SpringApplication.run(Application.class, args);
 	}
 }
+
+