deason 6 vuotta sitten
vanhempi
commit
da8ce1388f

+ 34 - 35
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/ExamStructureConvert.java

@@ -1,49 +1,48 @@
 package cn.com.qmth.examcloud.core.print.service.bean;
 
-import java.util.List;
-import java.util.stream.Collectors;
-
+import cn.com.qmth.examcloud.core.print.common.utils.JsonMapper;
+import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
+import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
+import com.google.common.collect.Lists;
 import org.springframework.beans.BeanUtils;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.PageImpl;
 import org.springframework.data.domain.PageRequest;
 import org.springframework.data.domain.Pageable;
 
-import com.google.common.collect.Lists;
-
-import cn.com.qmth.examcloud.core.print.common.utils.JsonMapper;
-import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
-import cn.com.qmth.examcloud.core.print.entity.ExamStructure;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * @author weiwenhai
- * @since  2018.10.30
+ * @since 2018.10.30
  */
 public class ExamStructureConvert {
-	
-	public static ExamStructure of(ExamStructureInfo info){
-		ExamStructure entity = new ExamStructure();
-		BeanUtils.copyProperties(info, entity);
-		String struct = new JsonMapper().toJson(info.getExamQuestionStructures());
-		entity.setStruct(struct);
-		return entity;
-	}
-	
-	public static ExamStructureInfo of(ExamStructure entity){
-		ExamStructureInfo info = new ExamStructureInfo();
-		BeanUtils.copyProperties(entity, info);
-		List<ExamQuestionStructure> list = new JsonMapper().toList(entity.getStruct(), ExamQuestionStructure.class);
-		info.setExamQuestionStructures(list);
-		return info;
-	}
 
-	public static Page<ExamStructureInfo> ofPage(Page<ExamStructure> page){
-		Pageable pageable = new PageRequest(page.getNumber(), page.getSize());
-		List<ExamStructure> entities = page.getContent();
-		if(entities == null || entities.isEmpty()){
-			return new PageImpl<ExamStructureInfo>(Lists.newArrayList(), pageable, page.getTotalElements());
-		}
-		List<ExamStructureInfo> list = entities.stream().map(entity -> of(entity)).collect(Collectors.toList());
-		return new PageImpl<ExamStructureInfo>(list, pageable ,page.getTotalElements());
-	}
-}
+    public static ExamStructure of(ExamStructureInfo info) {
+        ExamStructure entity = new ExamStructure();
+        BeanUtils.copyProperties(info, entity);
+        String struct = new JsonMapper().toJson(info.getQuestionStructure());
+        entity.setStruct(struct);
+        return entity;
+    }
+
+    public static ExamStructureInfo of(ExamStructure entity) {
+        ExamStructureInfo info = new ExamStructureInfo();
+        BeanUtils.copyProperties(entity, info);
+        ExamQuestionStructure questionStructure = new JsonMapper().fromJson(entity.getStruct(), ExamQuestionStructure.class);
+        info.setQuestionStructure(questionStructure);
+        return info;
+    }
+
+    public static Page<ExamStructureInfo> ofPage(Page<ExamStructure> page) {
+        Pageable pageable = new PageRequest(page.getNumber(), page.getSize());
+        List<ExamStructure> entities = page.getContent();
+        if (entities == null || entities.isEmpty()) {
+            return new PageImpl<>(Lists.newArrayList(), pageable, page.getTotalElements());
+        }
+        List<ExamStructureInfo> list = entities.stream().map(entity -> of(entity)).collect(Collectors.toList());
+        return new PageImpl<>(list, pageable, page.getTotalElements());
+    }
+
+}

+ 84 - 87
examcloud-core-print-service/src/main/java/cn/com/qmth/examcloud/core/print/service/bean/ExamStructureInfo.java

@@ -1,156 +1,153 @@
 package cn.com.qmth.examcloud.core.print.service.bean;
 
-import java.util.List;
-
 import cn.com.qmth.examcloud.commons.web.cloud.api.JsonSerializable;
 import cn.com.qmth.examcloud.core.print.entity.ExamQuestionStructure;
 
 /**
  * @author weiwenhai
- * @since  2018.10.30
+ * @since 2018.10.30
  */
 public class ExamStructureInfo implements JsonSerializable {
+    private static final long serialVersionUID = 1L;
+
+    private Long id;
 
-	private static final long serialVersionUID = 2678304552525917716L;
-	
-	private Long id;
-	
-	/**
+    /**
      * 考试ID
      */
     private Long examId;
-    
+
     /**
      * 学校机构ID
      */
     private Long orgId;
-	
-	/**
+
+    /**
      * 学校机构名称
      */
     private String orgName;
-    
+
     /**
      * 考试名称
      */
     private String examName;
-    
+
     /**
      * 考试类型
      */
     private String examType;
-    
+
     /**
      * 试题结构信息
      */
-    private List<ExamQuestionStructure> examQuestionStructures;
-    
+    private ExamQuestionStructure questionStructure;
+
     /**
      * 复用后的机构id
      */
     private Long newOrgId;
-    
+
     /**
      * 复用后的考试id
      */
     private Long newExamId;
-    
+
     /**
      * 复用后的学校机构名称
      */
     private String newOrgName;
-    
+
     /**
      * 复用后的考试名称
      */
     private String newExamName;
 
-	public Long getId() {
-		return id;
-	}
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
 
-	public void setId(Long id) {
-		this.id = id;
-	}
+    public Long getExamId() {
+        return examId;
+    }
 
-	public String getOrgName() {
-		return orgName;
-	}
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
 
-	public void setOrgName(String orgName) {
-		this.orgName = orgName;
-	}
+    public Long getOrgId() {
+        return orgId;
+    }
 
-	public String getExamName() {
-		return examName;
-	}
+    public void setOrgId(Long orgId) {
+        this.orgId = orgId;
+    }
 
-	public void setExamName(String examName) {
-		this.examName = examName;
-	}
+    public String getOrgName() {
+        return orgName;
+    }
 
-	public List<ExamQuestionStructure> getExamQuestionStructures() {
-		return examQuestionStructures;
-	}
+    public void setOrgName(String orgName) {
+        this.orgName = orgName;
+    }
 
-	public void setExamQuestionStructures(List<ExamQuestionStructure> examQuestionStructures) {
-		this.examQuestionStructures = examQuestionStructures;
-	}
+    public String getExamName() {
+        return examName;
+    }
 
-	public Long getExamId() {
-		return examId;
-	}
+    public void setExamName(String examName) {
+        this.examName = examName;
+    }
 
-	public void setExamId(Long examId) {
-		this.examId = examId;
-	}
+    public String getExamType() {
+        return examType;
+    }
 
-	public Long getOrgId() {
-		return orgId;
-	}
+    public void setExamType(String examType) {
+        this.examType = examType;
+    }
 
-	public void setOrgId(Long orgId) {
-		this.orgId = orgId;
-	}
+    public ExamQuestionStructure getQuestionStructure() {
+        return questionStructure;
+    }
 
-	public String getExamType() {
-		return examType;
-	}
+    public void setQuestionStructure(ExamQuestionStructure questionStructure) {
+        this.questionStructure = questionStructure;
+    }
 
-	public void setExamType(String examType) {
-		this.examType = examType;
-	}
+    public Long getNewOrgId() {
+        return newOrgId;
+    }
 
-	public Long getNewOrgId() {
-		return newOrgId;
-	}
+    public void setNewOrgId(Long newOrgId) {
+        this.newOrgId = newOrgId;
+    }
 
-	public void setNewOrgId(Long newOrgId) {
-		this.newOrgId = newOrgId;
-	}
+    public Long getNewExamId() {
+        return newExamId;
+    }
 
-	public Long getNewExamId() {
-		return newExamId;
-	}
+    public void setNewExamId(Long newExamId) {
+        this.newExamId = newExamId;
+    }
 
-	public void setNewExamId(Long newExamId) {
-		this.newExamId = newExamId;
-	}
+    public String getNewOrgName() {
+        return newOrgName;
+    }
 
-	public String getNewOrgName() {
-		return newOrgName;
-	}
+    public void setNewOrgName(String newOrgName) {
+        this.newOrgName = newOrgName;
+    }
 
-	public void setNewOrgName(String newOrgName) {
-		this.newOrgName = newOrgName;
-	}
+    public String getNewExamName() {
+        return newExamName;
+    }
 
-	public String getNewExamName() {
-		return newExamName;
-	}
+    public void setNewExamName(String newExamName) {
+        this.newExamName = newExamName;
+    }
 
-	public void setNewExamName(String newExamName) {
-		this.newExamName = newExamName;
-	}
-    
-}
+}