优化
This commit is contained in:
@@ -185,7 +185,7 @@ public class AdminDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE project SET isValid = ? WHERE userId = ?";
|
||||
String sql="UPDATE project SET isValid = ? WHERE projectId = ?";
|
||||
num = runner.update(conn, sql, isvalid,id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -200,7 +200,7 @@ public class AdminDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE comment SET isValid = ? WHERE userId = ?";
|
||||
String sql="UPDATE comment SET isValid = ? WHERE commentId = ?";
|
||||
num = runner.update(conn, sql, isvalid,id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -245,7 +245,7 @@ public class AdminDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE admin SET isValid = ? WHERE userId = ?";
|
||||
String sql="UPDATE admin SET isValid = ? WHERE adminId = ?";
|
||||
num = runner.update(conn, sql, isvalid,id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
@@ -148,6 +148,7 @@ public class UserDao {
|
||||
}
|
||||
sql="UPDATE user SET searchHistory = ? WHERE userName= ?";
|
||||
num = runner.update(conn,sql,label,name);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -167,6 +168,7 @@ public class UserDao {
|
||||
String sql = "select searchHistory from user where userName=? and isValid = 1";
|
||||
userEntity1 = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
|
||||
label=userEntity1.getSearchHistory();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -186,6 +188,7 @@ public class UserDao {
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE user SET searchHistory = ? WHERE userName= ? and isValid = 1";
|
||||
num = runner.update(conn,sql,label,name);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -206,6 +209,7 @@ public class UserDao {
|
||||
String sql="select count(*) as num from user where isValid = 1";
|
||||
userEntity = runner.query(conn,sql,new BeanHandler<>(userEntity.class));
|
||||
num = userEntity.getNum();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -259,6 +263,7 @@ public class UserDao {
|
||||
label = userEntity.getSearchHistory()+str+";";
|
||||
sql="UPDATE user SET searchHistory = ? WHERE userName= ? and isValid = 1";
|
||||
num = runner.update(conn,sql,label,username);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -276,6 +281,7 @@ public class UserDao {
|
||||
String sql = "select * from user where userName=? and isValid = 1";
|
||||
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
|
||||
num = userEntity.getUserId();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -292,6 +298,7 @@ public class UserDao {
|
||||
String sql = "select * from user where userId=? and isValid = 1";
|
||||
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),id);
|
||||
label = userEntity.getUserName();
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -307,6 +314,7 @@ public class UserDao {
|
||||
String sql = "select * from user where userName=? and isValid = 1";
|
||||
userEntity = runner.query(conn, sql, new BeanHandler<>(userEntity.class),name);
|
||||
userEntity.setUserPassword("*");
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -347,6 +355,7 @@ public class UserDao {
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="UPDATE user SET userAvatar = ? WHERE userName= ? and isValid = 1";
|
||||
num = runner.update(conn,sql,url,name);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -390,6 +399,7 @@ public class UserDao {
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql="select * from user ";
|
||||
userEntityList = runner.query(conn,sql,new BeanListHandler<>(userEntity.class));
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -404,6 +414,7 @@ public class UserDao {
|
||||
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);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
@@ -426,6 +437,7 @@ public class UserDao {
|
||||
runner.update(conn,sql,id);
|
||||
sql="update article set isValid = 0 where userId = ?";
|
||||
runner.update(conn,sql,id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ public class categoryDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from category where categoryId=? and isValid = 1";
|
||||
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) {
|
||||
|
@@ -63,7 +63,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select count(*) as num from project";
|
||||
String sql = "select count(*) as num from project where isValid = 1;";
|
||||
p = runner.query(conn, sql, new BeanHandler<>(projectEntity.class));
|
||||
count = p.getNum();
|
||||
conn.close();
|
||||
@@ -166,7 +166,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from project where isValid = 1 and projectId = ?";
|
||||
String sql = "select * from project where projectId = ? and isValid= 1;";
|
||||
projectEntity = runner.query(conn, sql, new BeanHandler<>(projectEntity.class),id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -230,7 +230,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from project where isValid = 1 and userId= ?";
|
||||
String sql = "select * from project where userId= ? and isValid = 1;";
|
||||
projectEntityList = runner.query(conn, sql, new BeanListHandler<>(projectEntity.class),id);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -274,7 +274,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql ="INSERT into project (userId,projectName,projectUrl,projectIco,projectTitle,projectDescription,startNum,submitTime,categoryId,isValid,periodicals,lookCount) VALUES (?,?,?,?,?,?,0,?,?,1,0,0)";
|
||||
String sql ="INSERT into project (userId,projectName,projectUrl,projectIco,projectTitle,projectDescription,startNum,submitTime,categoryId,isValid,periodicals,lookCount) VALUES (?,?,?,?,?,?,0,?,?,0,0,0)";
|
||||
num = runner.update(conn, sql,userId,projectName,projectUrl,projectIco,projectTitle,projectDescription,submitTime,categoryId);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
@@ -303,7 +303,7 @@ public class projectDao {
|
||||
try {
|
||||
Connection conn = JdbcUtils.getConnection();
|
||||
QueryRunner runner = new QueryRunner();
|
||||
String sql = "select * from project where isValid = 1 and projectName = ?";
|
||||
String sql = "select * from project where projectName = ? ";
|
||||
projectEntity = runner.query(conn, sql, new BeanHandler<>(projectEntity.class),projectName);
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
|
@@ -274,6 +274,7 @@ public class projectService {
|
||||
{
|
||||
flag=0;
|
||||
}
|
||||
|
||||
int proId = projectDao.selectProByProName(projectName).getProjectId();
|
||||
for(int i=0;i<categoryIdList.size();i++)
|
||||
{
|
||||
|
@@ -54,7 +54,6 @@ public class addLikeServlet extends HttpServlet {
|
||||
commentService.addLikeNum(Integer.parseInt(proId));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
|
@@ -71,8 +71,6 @@ public class commitProjectServlet extends HttpServlet {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
|
@@ -46,7 +46,6 @@ public class deleteAllLabelServlet extends HttpServlet {
|
||||
}else{
|
||||
setResultOK("删除成功",writer);
|
||||
}
|
||||
|
||||
}
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
|
@@ -44,6 +44,7 @@ public class selectCateServlet extends HttpServlet {
|
||||
setResultOK("success",writer);
|
||||
writer.println(jsonString);
|
||||
writer.close();
|
||||
|
||||
}
|
||||
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
|
@@ -43,6 +43,7 @@ public class selectCommentByProServlet extends HttpServlet {
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.println(commentService.selectByProjectId(id));
|
||||
writer.close();
|
||||
|
||||
}
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
|
@@ -44,5 +44,6 @@ public class selectCommentByServlet extends HttpServlet {
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.println(commentService.selectByTrait(id,trait));
|
||||
writer.close();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -48,6 +48,8 @@ public class selectLastByCateServlet extends HttpServlet {
|
||||
String jsonString = JSONObject.toJSONString(projectService.retLatestProject(Integer.valueOf(cate),name));
|
||||
writer.println(jsonString);
|
||||
writer.close();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -51,6 +51,7 @@ public class selectProByIdServlet extends HttpServlet {
|
||||
setResult(200, "观看量增加失败", writer);
|
||||
}
|
||||
writer.close();
|
||||
|
||||
}
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
|
@@ -40,6 +40,7 @@ public class selectProjectByPname extends HttpServlet {
|
||||
setResultError("项目已存在", writer);
|
||||
}
|
||||
writer.close();
|
||||
|
||||
}
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
HashMap<String, Object> result = new HashMap<>();
|
||||
|
@@ -42,7 +42,6 @@ public class selectTermServlet extends HttpServlet {
|
||||
String num = req.getParameter("type");
|
||||
PrintWriter writer = resp.getWriter();
|
||||
writer.println(projectService.retTerm(num));
|
||||
// setResultOK("123",writer);
|
||||
}
|
||||
|
||||
public void setResult(Integer code, String msg, PrintWriter writer){
|
||||
|
@@ -51,7 +51,6 @@ public class whetherCancelLikeServlet extends HttpServlet {
|
||||
String tip = supportService.deleteSupport(userEntity.getUserName(),Integer.parseInt(proId));
|
||||
writer.println(tip);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@@ -53,7 +53,7 @@ public class whetherLikeServlet extends HttpServlet {
|
||||
int num = supportService.retNum(userEntity.getUserName(),Integer.parseInt(proId));
|
||||
writer.println(num);
|
||||
}
|
||||
writer.close();
|
||||
writer.close();
|
||||
|
||||
}
|
||||
public void setResult(Integer code, String msg, PrintWriter writer) {
|
||||
|
Reference in New Issue
Block a user