From 1aa2a55a55d071ba4aa50c42fc7c675760863f39 Mon Sep 17 00:00:00 2001 From: sjm <2431685932@qq.com> Date: Sat, 8 Jul 2023 13:49:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=94=E5=9B=9Egithubinfo=E7=9A=84=E4=BF=A1?= =?UTF-8?q?=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/dao/githubDao.java | 19 +++++++++ .../hellogithub/service/githubService.java | 16 +++++++ .../githubinfo/ret_Github_infoServlet.java | 42 +++++++++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 src/com/hellogithub/servlet/githubinfo/ret_Github_infoServlet.java diff --git a/src/com/hellogithub/dao/githubDao.java b/src/com/hellogithub/dao/githubDao.java index bf0666c..a064615 100644 --- a/src/com/hellogithub/dao/githubDao.java +++ b/src/com/hellogithub/dao/githubDao.java @@ -1,12 +1,17 @@ package com.hellogithub.dao; import com.hellogithub.entity.githubEntity; +import com.hellogithub.entity.projectEntity; import com.hellogithub.entity.userEntity; import com.hellogithub.utils.JdbcUtils; +import org.apache.commons.dbutils.QueryRunner; +import org.apache.commons.dbutils.handlers.BeanListHandler; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.List; public class githubDao { githubEntity githubentity = new githubEntity(); @@ -45,4 +50,18 @@ public class githubDao { return rs; } + public List ret_Github_info(int projectid){ + List githubEntityList; + try { + Connection conn = JdbcUtils.getConnection(); + QueryRunner runner = new QueryRunner(); + String sql = "select * from githubinfo where projectId = ? and isValid = 1"; + githubEntityList = runner.query(conn, sql, new BeanListHandler<>(githubEntity.class), projectid); + conn.close(); + } catch (SQLException e) { + throw new RuntimeException(e); + } + return githubEntityList; + } + } diff --git a/src/com/hellogithub/service/githubService.java b/src/com/hellogithub/service/githubService.java index c71d0d9..caed02b 100644 --- a/src/com/hellogithub/service/githubService.java +++ b/src/com/hellogithub/service/githubService.java @@ -1,6 +1,12 @@ package com.hellogithub.service; +import com.alibaba.fastjson.JSONObject; import com.hellogithub.dao.githubDao; +import com.hellogithub.entity.githubEntity; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; public class githubService { private githubDao githubDao = new githubDao(); @@ -8,4 +14,14 @@ public class githubService { public int ins_Github_info(int projectId, String name, String starImgUrl, int starCount, String mainLanguage, String isActive, int subscriber, int issues, String isOrganization, String defaultBranch, int forks, String protocol, String version){ return githubDao.ins_Github_info(projectId, name,starImgUrl,starCount, mainLanguage,isActive, subscriber, issues, isOrganization,defaultBranch, forks, protocol, version); } + + public String ret_Github_info(int projectId){ + List githubEntityList = githubDao.ret_Github_info(projectId); + Map dataMap = new HashMap<>(); + for(int i=1;i