Browse Source

import lombok

zhangxiaoyu 3 years ago
parent
commit
9ddb9c05c3

+ 4 - 1
pom.xml

@@ -25,7 +25,10 @@
25
             <groupId>org.springframework.boot</groupId>
25
             <groupId>org.springframework.boot</groupId>
26
             <artifactId>spring-boot-starter-data-jpa</artifactId>
26
             <artifactId>spring-boot-starter-data-jpa</artifactId>
27
         </dependency>
27
         </dependency>
28
-
28
+        <dependency>
29
+            <groupId>org.projectlombok</groupId>
30
+            <artifactId>lombok</artifactId>
31
+        </dependency>
29
         <dependency>
32
         <dependency>
30
             <groupId>org.springframework.boot</groupId>
33
             <groupId>org.springframework.boot</groupId>
31
             <artifactId>spring-boot-starter-test</artifactId>
34
             <artifactId>spring-boot-starter-test</artifactId>

+ 8 - 0
src/main/java/com/example/springbootdemo/controller/HelloController.java

@@ -1,7 +1,9 @@
1
 package com.example.springbootdemo.controller;
1
 package com.example.springbootdemo.controller;
2
 
2
 
3
 import com.example.demo.controller.User;
3
 import com.example.demo.controller.User;
4
+import com.example.springbootdemo.zxyTeST.sql.dao.ArmGrabRepository;
4
 import com.example.springbootdemo.zxyTeST.sql.dao.ColorRepository;
5
 import com.example.springbootdemo.zxyTeST.sql.dao.ColorRepository;
6
+import com.example.springbootdemo.zxyTeST.sql.entity.ArmGrabEntity;
5
 import com.example.springbootdemo.zxyTeST.sql.entity.Color;
7
 import com.example.springbootdemo.zxyTeST.sql.entity.Color;
6
 import org.springframework.beans.factory.annotation.Autowired;
8
 import org.springframework.beans.factory.annotation.Autowired;
7
 import org.springframework.web.bind.annotation.RequestMapping;
9
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -13,12 +15,18 @@ import java.util.List;
13
 public class HelloController {
15
 public class HelloController {
14
     @Autowired
16
     @Autowired
15
     ColorRepository colorRepository;
17
     ColorRepository colorRepository;
18
+    @Autowired
19
+    ArmGrabRepository armGrabRepository;
16
     @RequestMapping("/hello")
20
     @RequestMapping("/hello")
17
     public void hello() {
21
     public void hello() {
18
         List<Color> listColors = colorRepository.findByColorId(2314);
22
         List<Color> listColors = colorRepository.findByColorId(2314);
19
         for (Color color:listColors) {
23
         for (Color color:listColors) {
20
             System.out.println("color_name="+color.getColorName()+"    color_id="+color.getColorId());
24
             System.out.println("color_name="+color.getColorName()+"    color_id="+color.getColorId());
21
         }
25
         }
26
+        List<ArmGrabEntity> armGrabEntityList = armGrabRepository.findByArmGrabId(1);
27
+        for (ArmGrabEntity armGrabEntity:armGrabEntityList) {
28
+            System.out.println("id="+armGrabEntity.getArmGrabId()+"    device_code="+armGrabEntity.getDeviceCode());
29
+        }
22
     }
30
     }
23
 
31
 
24
 
32
 

+ 10 - 0
src/main/java/com/example/springbootdemo/zxyTeST/sql/dao/ArmGrabRepository.java

@@ -0,0 +1,10 @@
1
+package com.example.springbootdemo.zxyTeST.sql.dao;
2
+
3
+import com.example.springbootdemo.zxyTeST.sql.entity.ArmGrabEntity;
4
+import org.springframework.data.jpa.repository.JpaRepository;
5
+
6
+import java.util.List;
7
+
8
+public interface ArmGrabRepository extends JpaRepository<ArmGrabEntity,Long> {
9
+    List<ArmGrabEntity> findByArmGrabId(Integer armGrabId);
10
+}

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

@@ -0,0 +1,25 @@
1
+package com.example.springbootdemo.zxyTeST.sql.entity;
2
+
3
+import lombok.Data;
4
+
5
+import javax.persistence.*;
6
+import java.io.Serializable;
7
+
8
+/**
9
+ * @author zhangxiaoyu
10
+ * @version 1.0
11
+ * @date 2021/5/25 下午6:17
12
+ */
13
+@Entity
14
+@Data
15
+@Table(name = "wb_tbl_arm_grab")
16
+public class ArmGrabEntity implements Serializable {
17
+    @Id
18
+    @GeneratedValue
19
+    @Column(name="arm_grab_id")
20
+    private Integer armGrabId;
21
+    @Column(name="device_code")
22
+    private String deviceCode;
23
+
24
+
25
+}