From b4c9767455eafb3e71ca29397ac9b528fc6c6fdb Mon Sep 17 00:00:00 2001 From: User_cyk <1020691186@qq.com> Date: Wed, 5 Jul 2023 17:37:50 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B=E7=82=B9=E8=B5=9E=E9=A1=B9=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/dao/supportDao.java | 19 +++++++++++++++++++ .../hellogithub/service/projectService.java | 18 ++++++++++++++++++ .../servlet/userDetailServlet.java | 1 + 3 files changed, 38 insertions(+) diff --git a/src/com/hellogithub/dao/supportDao.java b/src/com/hellogithub/dao/supportDao.java index d311acc..8a7035b 100644 --- a/src/com/hellogithub/dao/supportDao.java +++ b/src/com/hellogithub/dao/supportDao.java @@ -5,9 +5,12 @@ import com.hellogithub.entity.supportEntity; import com.hellogithub.utils.JdbcUtils; import org.apache.commons.dbutils.QueryRunner; import org.apache.commons.dbutils.handlers.BeanHandler; +import org.apache.commons.dbutils.handlers.BeanListHandler; import java.sql.Connection; import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; public class supportDao { public supportEntity selectSupport(int userId,int projectId) @@ -56,4 +59,20 @@ public class supportDao { return num; } + + public List selectProject(int userId) + { + List supportEntityList =new ArrayList<>(); + try{ + Connection conn = JdbcUtils.getConnection(); + QueryRunner runner = new QueryRunner(); + String sql = "select * from support where isValid = 1 and userId = ?"; + supportEntityList = runner.query(conn, sql,new BeanListHandler<>(supportEntity.class) , userId); + conn.close(); + }catch (SQLException e){ + throw new RuntimeException(e); + } + + return supportEntityList; + } } diff --git a/src/com/hellogithub/service/projectService.java b/src/com/hellogithub/service/projectService.java index 306dfdd..24f061d 100644 --- a/src/com/hellogithub/service/projectService.java +++ b/src/com/hellogithub/service/projectService.java @@ -5,8 +5,10 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.hellogithub.dao.categoryDao; import com.hellogithub.dao.projectDao; +import com.hellogithub.dao.supportDao; import com.hellogithub.entity.categoryEntity; import com.hellogithub.entity.projectEntity; +import com.hellogithub.entity.supportEntity; import java.util.*; @@ -16,6 +18,8 @@ public class projectService { private projectDao projectDao = new projectDao(); private categoryDao categoryDao = new categoryDao(); + + private supportDao supportDao = new supportDao(); /** * 按照期刊号查询 */ @@ -186,5 +190,19 @@ public class projectService { } return JSONObject.toJSONString(projectEntityList); } + public String retProBySupport(int userId) + { + List supportEntityList = supportDao.selectProject(userId); + List projectEntityList = new ArrayList<>(); + for(int i=0;i