uncln пре 5 година
родитељ
комит
b71d854125

+ 25 - 0
seec-data-server/pom.xml

@@ -115,6 +115,14 @@
 			<version>${seecoder.gitlab.version}</version>
 		</dependency>
 
+		<dependency>
+			<groupId>org.springframework.boot</groupId>
+			<artifactId>spring-boot-devtools</artifactId>
+			<optional>true</optional>
+			<scope>true</scope>
+
+		</dependency>
+
 		<!-- Httpclient -->
 		<dependency>
 			<groupId>org.apache.httpcomponents</groupId>
@@ -139,6 +147,23 @@
 					</excludes>
 				</configuration>
 			</plugin>
+			<plugin>
+
+				<!--热部署配置-->
+
+				<groupId>org.springframework.boot</groupId>
+
+				<artifactId>spring-boot-maven-plugin</artifactId>
+
+				<configuration>
+
+					<!--fork:如果没有该项配置,整个devtools不会起作用-->
+
+					<fork>true</fork>
+
+				</configuration>
+
+			</plugin>
 		</plugins>
 	</build>
 

+ 20 - 0
seec-data-server/src/main/java/cn/seecoder/data/server/domain/knowledge/KnowledgeOnPositionDao.java

@@ -1,10 +1,14 @@
 package cn.seecoder.data.server.domain.knowledge;
 
 import lombok.AllArgsConstructor;
+import lombok.Builder;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 @Data
+@NoArgsConstructor
 @AllArgsConstructor
+@Builder
 public class KnowledgeOnPositionDao {
     private int id;
     private String name;
@@ -17,4 +21,20 @@ public class KnowledgeOnPositionDao {
     private String position;
     private double weight;
     private int isleaf;
+
+//    public KnowledgeOnPositionDao(int id,String name,String nameEng,String abbreviation,int parentId,String parentName,int uid,int pid,String position,double weight,int isleaf){
+//        this.id = id;
+//        this.name = name;
+//        this.nameEng = nameEng;
+//        this.abbreviation = abbreviation;
+//        this.parentId = parentId;
+//        this.parentName = parentName;
+//        this.uid = uid;
+//        this.pid = pid;
+//        this.isleaf = isleaf;
+//        if(position!=null)
+//            this.position = position;
+//        if(weight!=0)
+//            this.weight = weight;
+//    }
 }

+ 6 - 6
seec-data-server/src/main/java/cn/seecoder/data/server/repository/knowledge/KnowledgeRepository.java

@@ -17,8 +17,8 @@ public interface KnowledgeRepository extends JpaRepository<KnowledgeDao,Integer>
 
     public KnowledgeDao findById(int id);
 
-    @Query(value = " select new cn.seecoder.data.server.domain.knowledge.KnowledgeOnPositionDao(" +
-            "k1.id," +
+    @Query(value =
+            "select k1.id," +
             "k1.name," +
             "k1.nameEng," +
             "k1.abbreviation," +
@@ -26,10 +26,10 @@ public interface KnowledgeRepository extends JpaRepository<KnowledgeDao,Integer>
             "k1.parentName," +
             "k1.uid," +
             "k1.pid," +
+            "k1.isleaf," +
             "k2.position," +
-            "k2.weight," +
-            "k1.isleaf)" +
-            " from KnowledgeDao k1,PositionWeightDao k2 where k1.id = k2.knowledgeId order by k1.id"
+            "k2.weight" +
+            " from KnowledgeDao k1 left join PositionWeightDao k2 on k1.id = k2.knowledgeId order by k1.id"
             )
-    public List<KnowledgeOnPositionDao> findAllInfo();
+    public List<Object> findAllInfo();
 }

+ 24 - 1
seec-data-server/src/main/java/cn/seecoder/data/server/service/Impl/KnowledgeServiceImpl.java

@@ -33,7 +33,8 @@ public class KnowledgeServiceImpl implements KnowledgeService {
 
     @Override
     public List<KnowledgeVO> getAllKnowledgeAndWeight() {
-        List<KnowledgeOnPositionDao> knowledgeOnPositionDaos = knowledgeRepository.findAllInfo();
+        List knowledgeOnPositionList = knowledgeRepository.findAllInfo();
+        ArrayList<KnowledgeOnPositionDao> knowledgeOnPositionDaos = objectToDao(knowledgeOnPositionList);
         ArrayList<KnowledgeVO> knowledgeVOS = new ArrayList<>();
         KnowledgeVO knowledgeVO = null;
         if(knowledgeOnPositionDaos.size()>0)
@@ -50,9 +51,31 @@ public class KnowledgeServiceImpl implements KnowledgeService {
                 knowledgeVO = new KnowledgeVO(knowledgeOnPositionDaos.get(i));
             }
         }
+        System.out.println();
         return knowledgeVOS;
     }
 
+    private ArrayList<KnowledgeOnPositionDao> objectToDao(List knowledgeOnPositionList) {
+        ArrayList<KnowledgeOnPositionDao> ans = new ArrayList<>();
+        for(int i=0;i<knowledgeOnPositionList.size();i++){
+            Object[] tempDaos = (Object[]) knowledgeOnPositionList.get(i);
+            if(tempDaos.length>10)
+                ans.add(KnowledgeOnPositionDao.builder()
+                    .id(Integer.valueOf(tempDaos[0].toString()))
+                    .name(tempDaos[1].toString())
+                    .nameEng(tempDaos[2].toString())
+                    .abbreviation(tempDaos[3].toString())
+                    .parentId(Integer.valueOf(tempDaos[4].toString()))
+                    .parentName(tempDaos[5].toString())
+                    .pid(Integer.valueOf(tempDaos[6].toString()))
+                    .uid(Integer.valueOf(tempDaos[7].toString()))
+                    .isleaf(Integer.valueOf(tempDaos[8].toString()))
+                    .position(tempDaos[9]==null?"":tempDaos[9].toString())
+                    .weight(tempDaos[10]==null?0:Double.valueOf(tempDaos[10].toString())).build());
+        }
+        return ans;
+    }
+
     @Override
     public KnowledgeVO updatePositionWeight(KnowledgeVO knowledgeVO) {
         Map<String,Double> positonWeight = knowledgeVO.getWeightOnPosition();

+ 15 - 15
seec-data-server/src/test/java/cn/seecoder/data/server/service/Impl/KnowledgeServiceImplTest.java

@@ -33,21 +33,21 @@ class KnowledgeServiceImplTest {
     @Autowired
     PositionWeightRepository positionWeightRepository;
 
-//    @Test
-//    void pushDataTest(){
-//        String[] position = {"algorithm"};
-//        Random random = new Random();
-//        List<KnowledgeDao> knowledgeDaos = knowledgeRepository.findAll();
-//        for(int i=0;i<knowledgeDaos.size();i=i+60){
-//            int knowledgeId = knowledgeDaos.get(i).getId();
-//            PositionWeightDao positionWeightDao = new PositionWeightDao();
-//            positionWeightDao.setKnowledgeId(knowledgeId);
-//            positionWeightDao.setPosition(position[0]);
-//            positionWeightDao.setWeight(random.nextDouble());
-//            positionWeightRepository.save(positionWeightDao);
-//            System.out.println(positionWeightDao);
-//        }
-//    }
+    @Test
+    void pushDataTest(){
+        String[] position = {"algorithm"};
+        Random random = new Random();
+        List<KnowledgeDao> knowledgeDaos = knowledgeRepository.findAll();
+        for(int i=0;i<knowledgeDaos.size();i=i+60){
+            int knowledgeId = knowledgeDaos.get(i).getId();
+            PositionWeightDao positionWeightDao = new PositionWeightDao();
+            positionWeightDao.setKnowledgeId(knowledgeId);
+            positionWeightDao.setPosition(position[0]);
+            positionWeightDao.setWeight(random.nextDouble());
+            positionWeightRepository.save(positionWeightDao);
+            System.out.println(positionWeightDao);
+        }
+    }
 
 //    @Test
 //    void positionTest(){