增加新的接口
This commit is contained in:
@@ -253,6 +253,27 @@ public class AdminDao {
|
|||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
public int countAdminNum()
|
||||||
|
{
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = JdbcUtils.getConnection();
|
||||||
|
String Sql = "select count(*) from admin ";
|
||||||
|
preparedStatement = connection.prepareStatement(Sql);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
// 将db中数据 返回给客户端 查询到数据
|
||||||
|
Integer number = resultSet.getInt(1);
|
||||||
|
return number;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
} finally {
|
||||||
|
JdbcUtils.closeConnection(resultSet, preparedStatement, connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public String ret_logintime(String adminame){
|
public String ret_logintime(String adminame){
|
||||||
String time = null;
|
String time = null;
|
||||||
|
@@ -259,6 +259,26 @@ public class articleDao {
|
|||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int countArticleNum()
|
||||||
|
{
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = JdbcUtils.getConnection();
|
||||||
|
String Sql = "select count(*) from article ";
|
||||||
|
preparedStatement = connection.prepareStatement(Sql);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
// 将db中数据 返回给客户端 查询到数据
|
||||||
|
Integer number = resultSet.getInt(1);
|
||||||
|
return number;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
} finally {
|
||||||
|
JdbcUtils.closeConnection(resultSet, preparedStatement, connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -8,6 +8,8 @@ import org.apache.commons.dbutils.handlers.BeanHandler;
|
|||||||
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -92,5 +94,25 @@ public class categoryDao {
|
|||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
public int countCategoryNum()
|
||||||
|
{
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = JdbcUtils.getConnection();
|
||||||
|
String Sql = "select count(*) from category ";
|
||||||
|
preparedStatement = connection.prepareStatement(Sql);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
// 将db中数据 返回给客户端 查询到数据
|
||||||
|
Integer number = resultSet.getInt(1);
|
||||||
|
return number;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
} finally {
|
||||||
|
JdbcUtils.closeConnection(resultSet, preparedStatement, connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -8,6 +8,8 @@ import org.apache.commons.dbutils.QueryRunner;
|
|||||||
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
|
import java.sql.PreparedStatement;
|
||||||
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -152,4 +154,25 @@ public class commentDao {
|
|||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
public int countCommentNum()
|
||||||
|
{
|
||||||
|
ResultSet resultSet = null;
|
||||||
|
PreparedStatement preparedStatement = null;
|
||||||
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = JdbcUtils.getConnection();
|
||||||
|
String Sql = "select count(*) from comment ";
|
||||||
|
preparedStatement = connection.prepareStatement(Sql);
|
||||||
|
resultSet = preparedStatement.executeQuery();
|
||||||
|
// 将db中数据 返回给客户端 查询到数据
|
||||||
|
Integer number = resultSet.getInt(1);
|
||||||
|
return number;
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
return 0;
|
||||||
|
} finally {
|
||||||
|
JdbcUtils.closeConnection(resultSet, preparedStatement, connection);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -1,10 +1,13 @@
|
|||||||
package com.hellogithub.dao;
|
package com.hellogithub.dao;
|
||||||
|
|
||||||
|
import com.hellogithub.entity.projectCategoryEntity;
|
||||||
import com.hellogithub.utils.JdbcUtils;
|
import com.hellogithub.utils.JdbcUtils;
|
||||||
import org.apache.commons.dbutils.QueryRunner;
|
import org.apache.commons.dbutils.QueryRunner;
|
||||||
|
import org.apache.commons.dbutils.handlers.BeanListHandler;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class projectCategoryDao {
|
public class projectCategoryDao {
|
||||||
|
|
||||||
@@ -23,4 +26,18 @@ public class projectCategoryDao {
|
|||||||
return num ;
|
return num ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<projectCategoryEntity> retProjectNumByCategory()
|
||||||
|
{
|
||||||
|
List<projectCategoryEntity> projectCategoryDaoList ;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql ="select count(projectId) as num ,categoryId from project_category GROUP BY categoryId;";
|
||||||
|
projectCategoryDaoList = runner.query(conn, sql, new BeanListHandler<>(projectCategoryEntity.class));
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectCategoryDaoList ;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -384,4 +384,48 @@ public class projectDao {
|
|||||||
}
|
}
|
||||||
return num;
|
return num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<projectEntity> selectProjectByDate()
|
||||||
|
{
|
||||||
|
List<projectEntity> projectEntityList = null ;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql="select DATE_FORMAT(creatTime,\"%Y-%m-%d\")as date,count(projectId) as num from project GROUP BY DATE_FORMAT(creatTime,\"%Y-%m-%d\")";
|
||||||
|
projectEntityList = runner.query(conn,sql,new BeanListHandler<>(projectEntity.class));
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntityList;
|
||||||
|
}
|
||||||
|
public List<projectEntity> selectProjectByMonth()
|
||||||
|
{
|
||||||
|
List<projectEntity> projectEntityList = null ;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql="select DATE_FORMAT(creatTime,\"%Y-%m\")as date,count(projectId) as num from project GROUP BY DATE_FORMAT(creatTime,\"%Y-%m\")";
|
||||||
|
projectEntityList = runner.query(conn,sql,new BeanListHandler<>(projectEntity.class));
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntityList;
|
||||||
|
}
|
||||||
|
public List<projectEntity> selectProjectByYear()
|
||||||
|
{
|
||||||
|
List<projectEntity> projectEntityList = null ;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql="select DATE_FORMAT(creatTime,\"%Y\")as date,count(projectId) as num from project GROUP BY DATE_FORMAT(creatTime,\"%Y\")";
|
||||||
|
projectEntityList = runner.query(conn,sql,new BeanListHandler<>(projectEntity.class));
|
||||||
|
conn.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntityList;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -28,4 +28,23 @@ public class projectCategoryEntity {
|
|||||||
public void setProjectId(int projectId) {
|
public void setProjectId(int projectId) {
|
||||||
this.projectId = projectId;
|
this.projectId = projectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int num ;
|
||||||
|
|
||||||
|
public int getNum() {
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNum(int num) {
|
||||||
|
this.num = num;
|
||||||
|
}
|
||||||
|
String categoryName;
|
||||||
|
|
||||||
|
public String getCategoryName() {
|
||||||
|
return categoryName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryName(String categoryName) {
|
||||||
|
this.categoryName = categoryName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -181,4 +181,13 @@ public class projectEntity {
|
|||||||
this.userUri = userUri;
|
this.userUri = userUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String date;
|
||||||
|
|
||||||
|
public String getDate() {
|
||||||
|
return date;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDate(String date) {
|
||||||
|
this.date = date;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -43,5 +43,7 @@ public class AdminService {
|
|||||||
{ return adminDao.updateAdminDetail(adminId,isValid,adminName,adminPassword,loginTime);
|
{ return adminDao.updateAdminDetail(adminId,isValid,adminName,adminPassword,loginTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int countAdminNum(){return adminDao.countAdminNum();}
|
||||||
|
|
||||||
public String ret_logintime(String adminame){return adminDao.ret_logintime(adminame);}
|
public String ret_logintime(String adminame){return adminDao.ret_logintime(adminame);}
|
||||||
}
|
}
|
||||||
|
@@ -120,4 +120,5 @@ public class articleService {
|
|||||||
}
|
}
|
||||||
public List<articleEntity> selectAllArticle(){return articleDao.selectAllArticle();}
|
public List<articleEntity> selectAllArticle(){return articleDao.selectAllArticle();}
|
||||||
|
|
||||||
|
public int countArticleNum(){return articleDao.countArticleNum();}
|
||||||
}
|
}
|
@@ -1,14 +1,18 @@
|
|||||||
package com.hellogithub.service;
|
package com.hellogithub.service;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hellogithub.dao.projectCategoryDao;
|
||||||
import com.hellogithub.dao.projectDao;
|
import com.hellogithub.dao.projectDao;
|
||||||
import com.hellogithub.dao.categoryDao;
|
import com.hellogithub.dao.categoryDao;
|
||||||
import com.hellogithub.entity.categoryEntity;
|
import com.hellogithub.entity.categoryEntity;
|
||||||
|
import com.hellogithub.entity.projectCategoryEntity;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class categoryService {
|
public class categoryService {
|
||||||
|
|
||||||
private categoryDao categoryDao = new categoryDao();
|
private categoryDao categoryDao = new categoryDao();
|
||||||
|
private projectCategoryDao projectCategoryDao = new projectCategoryDao();
|
||||||
|
|
||||||
public List<categoryEntity> retLabel() {return categoryDao.retLabel();}
|
public List<categoryEntity> retLabel() {return categoryDao.retLabel();}
|
||||||
|
|
||||||
@@ -20,4 +24,17 @@ public class categoryService {
|
|||||||
|
|
||||||
public List<categoryEntity> selectAllCategory(){return categoryDao.selectAllCategory();}
|
public List<categoryEntity> selectAllCategory(){return categoryDao.selectAllCategory();}
|
||||||
|
|
||||||
|
public int countCategoryNum(){return categoryDao.countCategoryNum();}
|
||||||
|
|
||||||
|
|
||||||
|
public String retProjectNumByCategory(){
|
||||||
|
List<projectCategoryEntity> projectCategoryDaoList = projectCategoryDao.retProjectNumByCategory();
|
||||||
|
for(int i=0 ;i<projectCategoryDaoList.size();i++)
|
||||||
|
{
|
||||||
|
int id = projectCategoryDaoList.get(i).getCategoryId();
|
||||||
|
String name = categoryDao.retNum(id).getCategoryName();
|
||||||
|
projectCategoryDaoList.get(i).setCategoryName(name);
|
||||||
|
}
|
||||||
|
return JSONObject.toJSONString(projectCategoryDaoList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -102,4 +102,6 @@ public class commentService {
|
|||||||
return commentDao.updateCommentDetail( commentId , userId , projectId, content , isUsed ,commentTime ,isValid ,star, likeNum );
|
return commentDao.updateCommentDetail( commentId , userId , projectId, content , isUsed ,commentTime ,isValid ,star, likeNum );
|
||||||
}
|
}
|
||||||
public int deleteComment(int id ){return commentDao.deleteComment(id);}
|
public int deleteComment(int id ){return commentDao.deleteComment(id);}
|
||||||
|
|
||||||
|
public int countCommentNum(){return commentDao.countCommentNum(); }
|
||||||
}
|
}
|
||||||
|
@@ -314,4 +314,14 @@ public class projectService {
|
|||||||
userDao.updateUserDetail(userEntity.getUserId(),userName,userEntity.getUserPassword(),userEntity.getCreatTime(),userEntity.getIsValid(),userEntity.getProjectNum()-1,userEntity.getSearchHistory(),userEntity.getContributionValue(),userEntity.getUserAvatar(),userEntity.getUserLevel());
|
userDao.updateUserDetail(userEntity.getUserId(),userName,userEntity.getUserPassword(),userEntity.getCreatTime(),userEntity.getIsValid(),userEntity.getProjectNum()-1,userEntity.getSearchHistory(),userEntity.getContributionValue(),userEntity.getUserAvatar(),userEntity.getUserLevel());
|
||||||
return projectDao.deleteProject(id);
|
return projectDao.deleteProject(id);
|
||||||
}
|
}
|
||||||
|
public String retProjectByTime()
|
||||||
|
{
|
||||||
|
String jsonString="";
|
||||||
|
Map<String,List<projectEntity>> dataMap = new HashMap<>();
|
||||||
|
dataMap.put("Date",projectDao.selectProjectByDate());
|
||||||
|
dataMap.put("Month",projectDao.selectProjectByMonth());
|
||||||
|
dataMap.put("Year", projectDao.selectProjectByYear());
|
||||||
|
jsonString = JSONObject.toJSONString(dataMap);
|
||||||
|
return jsonString;
|
||||||
|
}
|
||||||
}
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.AdminService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/countAdmin")
|
||||||
|
public class countAdminServlet extends HttpServlet {
|
||||||
|
|
||||||
|
private AdminService adminService = new AdminService() ;
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
|
||||||
|
int num = adminService.countAdminNum();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(num);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.AdminService;
|
||||||
|
import com.hellogithub.service.articleService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/countArticle")
|
||||||
|
public class countArticleServlet extends HttpServlet {
|
||||||
|
private articleService articleService = new articleService() ;
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
int num = articleService.countArticleNum();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(num);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,38 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.categoryService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/countCategory")
|
||||||
|
public class countCategoryServlet extends HttpServlet {
|
||||||
|
|
||||||
|
private categoryService categoryService = new categoryService();
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
|
||||||
|
int num = categoryService.countCategoryNum();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(num);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.commentService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/countComment")
|
||||||
|
public class countCommentServlet extends HttpServlet {
|
||||||
|
private commentService commentService = new commentService();
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
|
||||||
|
int num = commentService.countCommentNum();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(num);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.projectService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/retProjectByTime")
|
||||||
|
public class retProjectByTimeServlet extends HttpServlet {
|
||||||
|
private projectService projectService = new projectService();
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
|
||||||
|
String str = projectService.retProjectByTime();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(str);
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,37 @@
|
|||||||
|
package com.hellogithub.servlet.systemAdmin;
|
||||||
|
|
||||||
|
import com.hellogithub.service.categoryService;
|
||||||
|
|
||||||
|
import javax.servlet.ServletException;
|
||||||
|
import javax.servlet.annotation.WebServlet;
|
||||||
|
import javax.servlet.http.HttpServlet;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/retProjectNumByCategory")
|
||||||
|
public class retProjectNumByCategoryServlet extends HttpServlet {
|
||||||
|
private categoryService categoryService = new categoryService();
|
||||||
|
@Override
|
||||||
|
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
doPost(req, resp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
|
||||||
|
resp.setCharacterEncoding("UTF-8");
|
||||||
|
resp.setContentType("text/html; charset=utf-8");
|
||||||
|
// 设置响应头允许ajax跨域访问
|
||||||
|
String curOrigin = req.getHeader("Origin");
|
||||||
|
resp.setHeader("Access-Control-Allow-Origin", curOrigin == null ? "true" : curOrigin);
|
||||||
|
resp.setHeader("Access-Control-Allow-Credentials", "true");
|
||||||
|
resp.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE, HEAD");
|
||||||
|
resp.setHeader("Access-Control-Max-Age", "3600");
|
||||||
|
resp.setHeader("Access-Control-Allow-Headers", "access-control-allow-origin, authority, content-type, version-info, X-Requested-With");
|
||||||
|
resp.setContentType("application/json;charset=UTF-8");
|
||||||
|
|
||||||
|
String str = categoryService.retProjectNumByCategory();
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
writer.println(str);
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user