diff --git a/springboot-prometheus-canal/pom.xml b/springboot-prometheus-canal/pom.xml index 3a6b9ce..43b3418 100644 --- a/springboot-prometheus-canal/pom.xml +++ b/springboot-prometheus-canal/pom.xml @@ -65,6 +65,22 @@ lombok 1.16.18 + + com.baomidou + mybatis-plus-extension + 3.2.0 + + + + com.baomidou + mybatis-plus-boot-starter + 3.2.0 + + + + org.springframework.boot + spring-boot-starter-data-jpa + compile diff --git a/springboot-prometheus-canal/src/main/java/com/pancm/dao/CanalRepository.java b/springboot-prometheus-canal/src/main/java/com/pancm/dao/CanalRepository.java new file mode 100644 index 0000000..9956fb1 --- /dev/null +++ b/springboot-prometheus-canal/src/main/java/com/pancm/dao/CanalRepository.java @@ -0,0 +1,9 @@ +package com.pancm.dao; + +import com.pancm.domain.CanalDO; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface CanalRepository extends JpaRepository { +} \ No newline at end of file diff --git a/springboot-prometheus-canal/src/main/java/com/pancm/domain/CanalDO.java b/springboot-prometheus-canal/src/main/java/com/pancm/domain/CanalDO.java new file mode 100644 index 0000000..5296fa7 --- /dev/null +++ b/springboot-prometheus-canal/src/main/java/com/pancm/domain/CanalDO.java @@ -0,0 +1,36 @@ +package com.pancm.domain; + +import lombok.Data; + +import javax.persistence.*; +import java.sql.Date; + +/** + * @author pancm + * @Title: springBoot-study + * @Description: + * @Version:1.0.0 + * @Since:jdk1.8 + * @date 2023/9/15 + */ +@Data +@Entity +@Table(name = "business_monitoring_original_data") +public class CanalDO { + @Id + @GeneratedValue(strategy = GenerationType.AUTO) + private Long id; + private Date createTime; + private Date updateTime; + private String binlogName; + private String dbName; + private String tableName; + private String event_type; + private String keyName; + private String keyValue; + private String timeIndex; + private String gatherTime; + + + +} diff --git a/springboot-prometheus-canal/src/main/java/com/pancm/service/ICanalService.java b/springboot-prometheus-canal/src/main/java/com/pancm/service/ICanalService.java new file mode 100644 index 0000000..26def3d --- /dev/null +++ b/springboot-prometheus-canal/src/main/java/com/pancm/service/ICanalService.java @@ -0,0 +1,21 @@ +package com.pancm.service; + +import com.pancm.domain.CanalDO; + +import java.util.List; + +/** + * @author pancm + * @Title: springBoot-study + * @Description: + * @Version:1.0.0 + * @Since:jdk1.8 + * @date 2023/8/25 + */ +public interface ICanalService { + + CanalDO save(CanalDO canalDO); + + List query(CanalDO canalDO); + +} diff --git a/springboot-prometheus-canal/src/main/java/com/pancm/service/impl/CanalServiceImpl.java b/springboot-prometheus-canal/src/main/java/com/pancm/service/impl/CanalServiceImpl.java new file mode 100644 index 0000000..fac6fad --- /dev/null +++ b/springboot-prometheus-canal/src/main/java/com/pancm/service/impl/CanalServiceImpl.java @@ -0,0 +1,34 @@ +package com.pancm.service.impl; + +import com.pancm.dao.CanalRepository; +import com.pancm.domain.CanalDO; +import com.pancm.service.ICanalService; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +/** + * @author pancm + * @Title: springBoot-study + * @Description: + * @Version:1.0.0 + * @Since:jdk1.8 + * @date 2023/9/15 + */ +@Service +public class CanalServiceImpl implements ICanalService { + + @Resource + private CanalRepository canalRepository; + + @Override + public CanalDO save(CanalDO canalDO) { + return canalRepository.save(canalDO); + } + + @Override + public List query(CanalDO canalDO) { + return canalRepository.findAll(); + } +} diff --git a/springboot-prometheus-canal/src/main/resources/application.properties b/springboot-prometheus-canal/src/main/resources/application.properties index ab9a9fe..9ce957c 100644 --- a/springboot-prometheus-canal/src/main/resources/application.properties +++ b/springboot-prometheus-canal/src/main/resources/application.properties @@ -1,4 +1,4 @@ -spring.port = 8787 +server.port= 8787 spring.application.name=springboot-prometheus-canal # /health¶Ëµã ±©Â¶ÏêϸÐÅÏ¢ management.endpoint.health.show-details=always @@ -18,6 +18,9 @@ info.app.name=@project.name@ info.app.description=@project.description@ info.app.version=@project.version@ - +spring.datasource.url=jdbc:mysql://localhost:3306/canal?useUnicode=true&characterEncoding=utf8 +spring.datasource.username=root +spring.datasource.password=123456 +spring.datasource.driverClassName=com.mysql.jdbc.Driver