更新sql逻辑
This commit is contained in:
@@ -92,7 +92,7 @@ public class UserDao {
|
||||
Connection connection = null;
|
||||
try {
|
||||
connection = JdbcUtils.getConnection();
|
||||
String loginSql = "select * from user where userName=?";
|
||||
String loginSql = "select * from user where userName=? and isValid = 1";
|
||||
preparedStatement = connection.prepareStatement(loginSql);
|
||||
preparedStatement.setString(1, userName);
|
||||
resultSet = preparedStatement.executeQuery();
|
||||
@@ -123,7 +123,7 @@ public class UserDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select searchHistory from user where userName=?";
|
||||
String sql = "select searchHistory from user where userName=? and isValid = 1";
|
||||
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
|
||||
label = userEntity.getSearchHistory().replace(str+";","");
|
||||
sql="UPDATE user SET searchHistory = ? WHERE userName= ?";
|
||||
@@ -144,7 +144,7 @@ public class UserDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select searchHistory from user where userName=?";
|
||||
String sql = "select searchHistory from user where userName=? and isValid = 1";
|
||||
userEntity1 = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
|
||||
label=userEntity1.getSearchHistory();
|
||||
} catch (SQLException e) {
|
||||
@@ -164,7 +164,7 @@ public class UserDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE user SET searchHistory = ? WHERE userName= ?";
|
||||
String sql="UPDATE user SET searchHistory = ? WHERE userName= ? and isValid = 1";
|
||||
num = runner.update(conn,sql,label,name);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
@@ -183,7 +183,7 @@ public class UserDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="select count(*) as num from user";
|
||||
String sql="select count(*) as num from user where isValid = 1";
|
||||
userEntity = runner.query(conn,sql,new BeanHandler<>(userEntity.class));
|
||||
num = userEntity.getNum();
|
||||
} catch (SQLException e) {
|
||||
@@ -201,7 +201,7 @@ public class UserDao {
|
||||
Connection conn = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet rs = null;
|
||||
String sql = "SELECT * FROM `user` t1,article t2 WHERE t1.userId = t2.userId AND t1.userId = ?";
|
||||
String sql = "SELECT * FROM `user` t1,article t2 WHERE t1.userId = t2.userId AND t1.userId = ? and isValid = 1";
|
||||
int Value = 0;
|
||||
try{
|
||||
conn = JdbcUtils.getConnection();
|
||||
@@ -239,10 +239,10 @@ public class UserDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select searchHistory from user where userName=?";
|
||||
String sql = "select searchHistory from user where userName=? and isValid = 1";
|
||||
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),username);
|
||||
label = userEntity.getSearchHistory()+str+";";
|
||||
sql="UPDATE user SET searchHistory = ? WHERE userName= ?";
|
||||
sql="UPDATE user SET searchHistory = ? WHERE userName= ? and isValid = 1";
|
||||
num = runner.update(conn,sql,label,username);
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
|
@@ -24,7 +24,7 @@ public class articleDao {
|
||||
Connection conn = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet rs = null;
|
||||
String sql = "SELECT * FROM `article` ORDER BY publishTime DESC;";
|
||||
String sql = "SELECT * FROM `article` where isValid = 1 ORDER BY publishTime DESC;";
|
||||
ArrayList<com.hellogithub.entity.articleEntity> articleEntities = new ArrayList<articleEntity>();
|
||||
try {
|
||||
conn = JdbcUtils.getConnection();
|
||||
@@ -62,7 +62,7 @@ public class articleDao {
|
||||
Connection conn = null;
|
||||
PreparedStatement preparedStatement = null;
|
||||
ResultSet rs = null;
|
||||
String sql = "SELECT * FROM `article` ORDER BY readCount DESC";
|
||||
String sql = "SELECT * FROM `article` where isValid = 1 ORDER BY readCount DESC";
|
||||
ArrayList<com.hellogithub.entity.articleEntity> articleEntities = new ArrayList<articleEntity>();
|
||||
try {
|
||||
conn = JdbcUtils.getConnection();
|
||||
|
@@ -19,7 +19,7 @@ public class categoryDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from category ";
|
||||
String sql = "select * from category where isValid = 1";
|
||||
categoryEntity = runner.query(conn, sql, new BeanListHandler<>(categoryEntity.class));
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -33,7 +33,7 @@ public class categoryDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from category where categoryId=?";
|
||||
String sql = "select * from category where categoryId=? and isValid = 1";
|
||||
categoryEntity = runner.query(conn, sql, new BeanHandler<>(categoryEntity.class),id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
@@ -213,7 +213,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select categoryName from category where categoryId in( select categoryId from project_category where projectId = ?)";
|
||||
String sql = "select categoryName from category where isValid = 1 and categoryId in( select categoryId from project_category where projectId = ? and isValid = 1)";
|
||||
categoryEntityList = runner.query(conn, sql,new BeanListHandler<>(categoryEntity.class),id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
Reference in New Issue
Block a user