This commit is contained in:
2023-07-10 18:02:57 +08:00
parent a6cea999f3
commit 89db94c18c
7 changed files with 49 additions and 12 deletions

View File

@@ -45,6 +45,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE admin SET loginTime = ? WHERE adminName= ? and isValid = 1";
num = runner.update(conn,sql,loginTime,name);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -127,6 +128,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="select * from admin";
adminEntityList = runner.query(conn,sql,new BeanListHandler<>(adminEntity.class));
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -141,6 +143,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="update admin set adminName = ? , adminPassword = ?, loginTime = ? ,isValid =? where adminId =? ";
num = runner.update(conn,sql,adminName, adminPassword,loginTime, isValid,adminId);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -155,6 +158,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="delete from admin where adminId = ?";
num = runner.update(conn,sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -169,6 +173,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE user SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -182,6 +187,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE project SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -196,6 +202,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE comment SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -210,6 +217,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE category SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -224,6 +232,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE article SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -238,6 +247,7 @@ public class AdminDao {
QueryRunner runner = new QueryRunner();
String sql="UPDATE admin SET isValid = ? WHERE userId = ?";
num = runner.update(conn, sql, isvalid,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -222,6 +222,7 @@ public class articleDao {
QueryRunner runner = new QueryRunner();
String sql="select * from article";
articleEntityList = runner.query(conn,sql,new BeanListHandler<>(articleEntity.class));
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -236,6 +237,7 @@ public class articleDao {
QueryRunner runner = new QueryRunner();
String sql="update article set userId = ? , articleContent = ? , publishTime = ? ,isValid =?, readCount=?, articleTitle=?, articleIco=? where articleId =? ";
num = runner.update(conn,sql,userId, articleContent , publishTime , isValid, readCount, articleTitle, articleIco ,articleId);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -250,6 +252,7 @@ public class articleDao {
QueryRunner runner = new QueryRunner();
String sql="delete from article where articleId = ?";
num = runner.update(conn,sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -56,6 +56,7 @@ public class categoryDao {
QueryRunner runner = new QueryRunner();
String sql="select * from category ";
categoryEntityList = runner.query(conn,sql,new BeanListHandler<>(categoryEntity.class));
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -70,6 +71,7 @@ public class categoryDao {
QueryRunner runner = new QueryRunner();
String sql="update category set category = ? , categoryName = ? ,isValid =? where categoryId =? ";
num = runner.update(conn,sql,category, categoryName, isValid,categoryId);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -84,6 +86,7 @@ public class categoryDao {
QueryRunner runner = new QueryRunner();
String sql="delete from category where articleId = ?";
num = runner.update(conn,sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -116,6 +116,7 @@ public class commentDao {
QueryRunner runner = new QueryRunner();
String sql="select * from comment ";
commentEntityList = runner.query(conn,sql,new BeanListHandler<>(commentEntity.class));
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -130,6 +131,7 @@ public class commentDao {
QueryRunner runner = new QueryRunner();
String sql="update comment set userId = ? , projectId = ? , content = ? ,isUsed =?, commentTime=?, isValid=?,star=?,likeNum=?where commentId =? ";
num = runner.update(conn,sql,userId, projectId , content , isUsed, commentTime, isValid, star, likeNum ,commentId);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -144,6 +146,7 @@ public class commentDao {
QueryRunner runner = new QueryRunner();
String sql="delete from comment where commentId = ?";
num = runner.update(conn,sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -67,6 +67,7 @@ public class githubDao {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
githubEntityList = runner.query(conn,sql,new BeanHandler<>(githubEntity.class),projectid);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -324,6 +324,7 @@ public class projectDao {
return 1;
else
return 0;
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -343,6 +344,7 @@ public class projectDao {
QueryRunner runner = new QueryRunner();
String sql="select * from project ";
projectEntityList = runner.query(conn,sql,new BeanListHandler<>(projectEntity.class));
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -357,6 +359,7 @@ public class projectDao {
QueryRunner runner = new QueryRunner();
String sql="update project set userId = ? , projectName = ? , projectUrl = ? ,projectIco =?, projectTitle=?, projectDescription=?,startNum=?,submitTime=?,categoryId=?,isValid=? ,fileAddress = ? , periodicals = ? ,lookCount = ? where projectId =? ";
num = runner.update(conn,sql,userId, projectName , projectUrl , projectIco, projectTitle, projectDescription, startNum, submitTime ,categoryId,isValid,fileAddress,periodicals,lookCount,projectId);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}
@@ -375,6 +378,7 @@ public class projectDao {
runner.update(conn,sql,id);
sql="delete from project_category where projectId = ?";
runner.update(conn,sql,id);
conn.close();
} catch (SQLException e) {
throw new RuntimeException(e);
}

View File

@@ -195,21 +195,34 @@ public class projectService {
long t = System.currentTimeMillis();
Random random = new Random(t);
List<projectEntity> projectEntityList1 = projectDao.retLatestProject();
Set<Integer> integers =new HashSet<>();
while(integers.size()<5){
int num = random.nextInt(projectEntityList1.size());
integers.add(num);
}
Iterator<Integer> it = integers.iterator();
while(it.hasNext())
if(projectEntityList1.size()<5)
{
int id = it.next();
projectEntity projectEntity =projectEntityList1.get(id);
categoryEntity categoryEntity = categoryDao.retNum(projectEntity.getCategoryId());
projectEntity.setCategoryName(categoryEntity.getCategoryName());
projectEntityList.add(projectEntity);
for(int i=0;i<projectEntityList1.size();i++)
{
projectEntity projectEntity =projectEntityList1.get(i);
categoryEntity categoryEntity = categoryDao.retNum(projectEntity.getCategoryId());
projectEntityList1.get(i).setCategoryName(categoryEntity.getCategoryName());
}
projectEntityList = projectEntityList1;
}else{
Set<Integer> integers =new HashSet<>();
while(integers.size()<5){
int num = random.nextInt(projectEntityList1.size());
integers.add(num);
}
Iterator<Integer> it = integers.iterator();
while(it.hasNext())
{
int id = it.next();
projectEntity projectEntity =projectEntityList1.get(id);
categoryEntity categoryEntity = categoryDao.retNum(projectEntity.getCategoryId());
projectEntity.setCategoryName(categoryEntity.getCategoryName());
projectEntityList.add(projectEntity);
}
}
return projectEntityList;
}
public String retProjectByUserId(int id){