瀏覽代碼

import lombok

zhangxiaoyu 3 年之前
父節點
當前提交
3b8701978a

+ 1 - 1
src/main/java/com/example/springbootdemo/SpringbootdemoApplication.java

@@ -4,7 +4,7 @@ import org.springframework.boot.SpringApplication;
4 4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 5
 import org.springframework.context.ConfigurableApplicationContext;
6 6
 import org.springframework.context.annotation.ComponentScan;
7
-
7
+import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
8 8
 @SpringBootApplication(scanBasePackages = {"com.example"})
9 9
 @ComponentScan({"com.example.demo","com.example.springbootdemo"})
10 10
 

+ 10 - 1
src/main/java/com/example/springbootdemo/controller/HelloController.java

@@ -1,11 +1,11 @@
1 1
 package com.example.springbootdemo.controller;
2 2
 
3
-import com.example.demo.controller.User;
4 3
 import com.example.springbootdemo.zxyTeST.sql.dao.ArmGrabRepository;
5 4
 import com.example.springbootdemo.zxyTeST.sql.dao.ColorRepository;
6 5
 import com.example.springbootdemo.zxyTeST.sql.entity.ArmGrabEntity;
7 6
 import com.example.springbootdemo.zxyTeST.sql.entity.Color;
8 7
 import org.springframework.beans.factory.annotation.Autowired;
8
+import org.springframework.jdbc.core.JdbcTemplate;
9 9
 import org.springframework.web.bind.annotation.RequestMapping;
10 10
 import org.springframework.web.bind.annotation.RestController;
11 11
 
@@ -17,6 +17,8 @@ public class HelloController {
17 17
     ColorRepository colorRepository;
18 18
     @Autowired
19 19
     ArmGrabRepository armGrabRepository;
20
+    @Autowired
21
+    JdbcTemplate jdbcTemplate;
20 22
     @RequestMapping("/hello")
21 23
     public void hello() {
22 24
         List<Color> listColors = colorRepository.findByColorId(2314);
@@ -28,6 +30,13 @@ public class HelloController {
28 30
             System.out.println("id="+armGrabEntity.getArmGrabId()+"    device_code="+armGrabEntity.getDeviceCode());
29 31
         }
30 32
     }
33
+    @RequestMapping("/jdbc")
34
+    public String jdbc() {
35
+        String sql = "select color_name from wb_tbl_color where color_id = ?";
36
+        String color_name = (String)jdbcTemplate.queryForObject(
37
+                sql, new Object[] { 2314 }, String.class);
38
+        return color_name;
39
+    }
31 40
 
32 41
 
33 42
 }

+ 19 - 8
src/main/java/com/example/springbootdemo/controller/TrainJavaController.java

@@ -1,14 +1,25 @@
1 1
 package com.example.springbootdemo.controller;
2 2
 
3
-public class TrainJavaController {
3
+import com.example.springbootdemo.zxyTeST.sql.dao.FootScanCommonRepository;
4
+import com.example.springbootdemo.zxyTeST.sql.entity.FootScanCommonEntity;
5
+import org.springframework.beans.factory.annotation.Autowired;
6
+import org.springframework.web.bind.annotation.RequestMapping;
7
+import org.springframework.web.bind.annotation.RestController;
4 8
 
5
-    public void Test() {
6
-        try{
7
-            System.out.println(10/0);
8
-        } catch (ArithmeticException e) {
9
-            System.out.println("Exception thrown  :" + e);
10
-        }
11
-        System.out.println("Out of the block");
9
+import java.util.List;
12 10
 
11
+@RestController
12
+public class TrainJavaController {
13
+    @Autowired
14
+    FootScanCommonRepository footScanCommonRepository;
15
+    @RequestMapping("/footScan")
16
+    public String getFootScanInfo() {
17
+        FootScanCommonEntity  footScanCommonInfo = footScanCommonRepository.findByFootScanId(14815);
18
+        List<FootScanCommonEntity> listFootScanList = this.getFootScanList();
19
+        return  footScanCommonInfo.getFootScanSign();
13 20
     }
21
+    public List<FootScanCommonEntity> getFootScanList() {
22
+        return footScanCommonRepository.findByFootScanCommonId(2241);
23
+    }
24
+
14 25
 }

+ 2 - 1
src/main/java/com/example/springbootdemo/zxyTeST/EnumTest.java

@@ -1,4 +1,5 @@
1
-package com.example.springbootdemo.zxyTeST;
1
+package com.example.springbootdemo.zxyTeST.Enum;
2
+
2 3
 
3 4
 public enum EnumTest {
4 5
     //RED,GREEN,BLUE;

+ 26 - 0
src/main/java/com/example/springbootdemo/zxyTeST/Enum/SystemType.java

@@ -0,0 +1,26 @@
1
+package com.example.springbootdemo.zxyTeST.Enum;
2
+
3
+/**
4
+ * @author zhangxiaoyu
5
+ * @version 1.0
6
+ * @date 2021/5/26 上午10:30
7
+ */
8
+public enum SystemType {
9
+    STORE_SYSTEM_TYPE("门店版本",1),
10
+    SCAN_SYSTEM_TYPE("scan",6);
11
+    public String getSystemName() {
12
+        return systemName;
13
+    }
14
+
15
+    public Integer getSystemId() {
16
+        return systemId;
17
+    }
18
+
19
+    private String systemName;
20
+    private Integer systemId;
21
+    SystemType(String systemName,Integer systemId) {
22
+        this.systemName = systemName;
23
+        this.systemId = systemId;
24
+    }
25
+
26
+}

+ 10 - 12
src/main/java/com/example/springbootdemo/zxyTeST/getProperties.java

@@ -1,21 +1,19 @@
1 1
 package com.example.springbootdemo.zxyTeST;
2 2
 
3
-import java.io.FileInputStream;
3
+import com.example.springbootdemo.zxyTeST.Enum.EnumTest;
4
+import com.example.springbootdemo.zxyTeST.Enum.SystemType;
5
+import org.springframework.boot.autoconfigure.SpringBootApplication;
6
+
4 7
 import java.io.FileNotFoundException;
5 8
 import java.io.IOException;
6
-import java.util.Enumeration;
7
-import java.util.Properties;
8 9
 
10
+@SpringBootApplication
9 11
 public class getProperties {
10 12
     public static void main(String[] args) throws FileNotFoundException, IOException {
11
-        Properties pps = new Properties();
12
-        pps.load(new FileInputStream("a.properties"));
13
-        Enumeration enum1 = pps.propertyNames();//得到配置文件的名字
14
-        while(enum1.hasMoreElements()) {
15
-            String strKey = (String) enum1.nextElement();
16
-            String strValue = pps.getProperty(strKey);
17
-            System.out.println(strKey + "=" + strValue);
18
-            //封装到JavaBean。
19
-        }
13
+      for (int i = 0; i< SystemType.values().length; i++) {
14
+          System.out.println("索引"+SystemType.values()[i].ordinal()+",值:"+SystemType.values()[i]);
15
+          System.out.println("值"+ SystemType.values()[i].getSystemName());
16
+      }
17
+
20 18
     }
21 19
 }

+ 16 - 0
src/main/java/com/example/springbootdemo/zxyTeST/sql/dao/FootScanCommonRepository.java

@@ -0,0 +1,16 @@
1
+package com.example.springbootdemo.zxyTeST.sql.dao;
2
+
3
+import com.example.springbootdemo.zxyTeST.sql.entity.FootScanCommonEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+
6
+import java.util.List;
7
+
8
+/**
9
+ * @author zhangxiaoyu
10
+ * @version 1.0
11
+ * @date 2021/5/26 上午10:43
12
+ */
13
+public interface FootScanCommonRepository extends JpaRepository<FootScanCommonEntity, Integer> {
14
+   FootScanCommonEntity findByFootScanId(Integer footScanId);
15
+   List<FootScanCommonEntity> findByFootScanCommonId(Integer footScanCommonId);
16
+}

+ 2 - 2
src/main/java/com/example/springbootdemo/zxyTeST/sql/entity/ArmGrabEntity.java

@@ -16,9 +16,9 @@ import java.io.Serializable;
16 16
 public class ArmGrabEntity implements Serializable {
17 17
     @Id
18 18
     @GeneratedValue
19
-    @Column(name="arm_grab_id")
19
+    @Column(name = "arm_grab_id")
20 20
     private Integer armGrabId;
21
-    @Column(name="device_code")
21
+    @Column(name = "device_code")
22 22
     private String deviceCode;
23 23
 
24 24
 

+ 0 - 6
src/main/java/com/example/springbootdemo/zxyTeST/sql/entity/Color.java

@@ -11,15 +11,9 @@ import java.io.Serializable;
11 11
 public class Color implements Serializable {
12 12
     @Id
13 13
     @GeneratedValue
14
-    @Column(name="color_id")
15 14
     private Integer colorId;
16
-    @Column(name="color_name")
17 15
     private String colorName;
18
-    @Column(name = "color_status")
19 16
     private String colorStatus;
20
-    @Column(name = "color_type")
21 17
     private String colorType;
22 18
 
23
-
24
-
25 19
 }

+ 27 - 0
src/main/java/com/example/springbootdemo/zxyTeST/sql/entity/FootScanCommonEntity.java

@@ -0,0 +1,27 @@
1
+package com.example.springbootdemo.zxyTeST.sql.entity;
2
+
3
+import lombok.Data;
4
+
5
+import javax.persistence.Entity;
6
+import javax.persistence.GeneratedValue;
7
+import javax.persistence.Id;
8
+import javax.persistence.Table;
9
+import java.io.Serializable;
10
+
11
+/**
12
+ * @author zhangxiaoyu
13
+ * @version 1.0
14
+ * @date 2021/5/26 上午10:40
15
+ */
16
+@Entity
17
+@Data
18
+@Table(name="wb_tbl_foot_scan_common")
19
+public class FootScanCommonEntity implements Serializable {
20
+    @Id
21
+    @GeneratedValue
22
+    private Integer footScanCommonId;
23
+    private Integer footScanId;
24
+    private String footScanSign;
25
+    private String leftLength;
26
+    private String rightLength;
27
+}