后台管理sql

This commit is contained in:
cyk
2023-07-08 19:19:43 +08:00
parent 4a337e2c40
commit 56c680fe6f
6 changed files with 295 additions and 0 deletions

View File

@@ -4,11 +4,13 @@ import com.hellogithub.entity.adminEntity;
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 AdminDao {
public static adminEntity AdminLogin(String adminName, String password,String loginTime) {
@@ -54,4 +56,52 @@ public class AdminDao {
return num;
}
/*
*
* 后台管理sql
*
* */
public List<adminEntity> selectAllCategory()
{
List<adminEntity> adminEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from admin where isValid = 1";
adminEntityList = runner.query(conn,sql,new BeanListHandler<>(adminEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return adminEntityList;
}
public int updateCategoryDetail(int adminId , int isValid , String adminName, String adminPassword,String loginTime )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
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);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteAdmin(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from admin where adminId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -4,6 +4,7 @@ import com.hellogithub.entity.userEntity;
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.*;
import java.util.ArrayList;
@@ -368,4 +369,52 @@ public class UserDao {
throw new RuntimeException();
}
}
/*
*
* 后台管理sql
*
* */
public List<userEntity> selectAllUser()
{
List<userEntity> userEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from user where isValid = 1";
userEntityList = runner.query(conn,sql,new BeanListHandler<>(userEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return userEntityList;
}
public int updateUserDetail(int userId ,String userName , String userPassword, String creatTime ,int isValid ,int projectNum ,String searchHistory ,int contributionValue, String userAvatar ,int userLevel)
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="update user set userName = ? , userPassword = ? , creatTime = ? ,isValid =?, projectNum=?, searchHistory=?,contributionValue=?,userAvatar=?,userLevel=? where userId = ?";
num = runner.update(conn,sql,userName, userPassword , creatTime , isValid, projectNum, searchHistory, contributionValue, userAvatar ,userLevel,userId);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteUser(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from user where userId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -1,6 +1,7 @@
package com.hellogithub.dao;
import com.hellogithub.entity.articleEntity;
import com.hellogithub.entity.commentEntity;
import com.hellogithub.entity.projectEntity;
import com.hellogithub.entity.userEntity;
import com.hellogithub.utils.JdbcUtils;
@@ -206,4 +207,52 @@ public class articleDao {
}
}return articleEntities;
}
/*
*
* 后台管理sql
*
* */
public List<articleEntity> selectAllArticle()
{
List<articleEntity> articleEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from article where isValid = 1";
articleEntityList = runner.query(conn,sql,new BeanListHandler<>(articleEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return articleEntityList;
}
public int updateArticleDetail(int articleId , int userId , String articleContent, String publishTime ,int readCount ,String articleTitle ,int isValid ,String articleIco )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
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);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteArticle(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from article where articleId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -1,5 +1,6 @@
package com.hellogithub.dao;
import com.hellogithub.entity.articleEntity;
import com.hellogithub.entity.categoryEntity;
import com.hellogithub.entity.projectEntity;
import com.hellogithub.utils.JdbcUtils;
@@ -41,4 +42,53 @@ public class categoryDao {
}
return categoryEntity;
}
/*
*
* 后台管理sql
*
* */
public List<categoryEntity> selectAllCategory()
{
List<categoryEntity> categoryEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from article where isValid = 1";
categoryEntityList = runner.query(conn,sql,new BeanListHandler<>(categoryEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return categoryEntityList;
}
public int updateCategoryDetail(int categoryId , int isValid , String category, String categoryName )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="update category set category = ? , categoryName = ? ,isValid =? where categoryId =? ";
num = runner.update(conn,sql,category, categoryName, isValid,categoryId);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteCategory(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from category where articleId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -2,6 +2,7 @@ package com.hellogithub.dao;
import com.hellogithub.entity.categoryEntity;
import com.hellogithub.entity.commentEntity;
import com.hellogithub.entity.projectEntity;
import com.hellogithub.utils.JdbcUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
@@ -100,4 +101,52 @@ public class commentDao {
return num ;
}
/*
*
* 后台管理sql
*
* */
public List<commentEntity> selectAllComment()
{
List<commentEntity> commentEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from comment where isValid = 1";
commentEntityList = runner.query(conn,sql,new BeanListHandler<>(commentEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return commentEntityList;
}
public int updateCommentDetail(int commentId , int userId , int projectId, String content ,int isUsed ,String commentTime ,int isValid ,int star, int likeNum )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="update project 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);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteComment(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from project where commentId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}

View File

@@ -328,4 +328,52 @@ public class projectDao {
throw new RuntimeException(e);
}
}
/*
*
* 后台管理sql
*
* */
public List<projectEntity> selectAllProject()
{
List<projectEntity> projectEntityList = null ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="select * from project where isValid = 1";
projectEntityList = runner.query(conn,sql,new BeanListHandler<>(projectEntity.class));
} catch (SQLException e) {
throw new RuntimeException(e);
}
return projectEntityList;
}
public int updateProjectDetail(int projectId , int userId , String projectName, String projectUrl ,String projectIco ,String projectTitle ,String projectDescription ,int startNum, String submitTime ,int categoryId,int isValid,String fileAddress,int periodicals,int lookCount)
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
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);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
public int deleteProject(int id )
{
int num ;
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
String sql="delete from project where projectId = ?";
num = runner.update(conn,sql,id);
} catch (SQLException e) {
throw new RuntimeException(e);
}
return num;
}
}