月刊页面接口
This commit is contained in:
@@ -17,8 +17,8 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="18" jdkType="JavaSDK" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" name="libs" level="project" />
|
<orderEntry type="library" exported="" name="libs" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@@ -1,6 +1,6 @@
|
|||||||
package com.hellogithub.dao;
|
package com.hellogithub.dao;
|
||||||
|
|
||||||
import com.hellogithub.entity.UserEntity;
|
import com.hellogithub.entity.userEntity;
|
||||||
import com.hellogithub.utils.JdbcUtils;
|
import com.hellogithub.utils.JdbcUtils;
|
||||||
|
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -12,7 +12,7 @@ import java.sql.ResultSet;
|
|||||||
* 用户Dao层
|
* 用户Dao层
|
||||||
*/
|
*/
|
||||||
public class UserDao {
|
public class UserDao {
|
||||||
private UserEntity userEntity = new UserEntity();
|
private com.hellogithub.entity.userEntity userEntity = new userEntity();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户登录
|
* 用户登录
|
||||||
@@ -20,7 +20,7 @@ public class UserDao {
|
|||||||
* @param userName
|
* @param userName
|
||||||
* @param password
|
* @param password
|
||||||
*/
|
*/
|
||||||
public UserEntity UserLogin(String userName, String password) {
|
public com.hellogithub.entity.userEntity UserLogin(String userName, String password) {
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
@@ -38,7 +38,7 @@ public class UserDao {
|
|||||||
Integer id = resultSet.getInt(1);
|
Integer id = resultSet.getInt(1);
|
||||||
String dbUserName = resultSet.getString(2);
|
String dbUserName = resultSet.getString(2);
|
||||||
String dbUserPassword = resultSet.getString(3);
|
String dbUserPassword = resultSet.getString(3);
|
||||||
userEntity = new UserEntity(dbUserName, dbUserPassword);
|
userEntity = new userEntity(dbUserName, dbUserPassword);
|
||||||
return userEntity;
|
return userEntity;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -87,7 +87,7 @@ public class UserDao {
|
|||||||
*
|
*
|
||||||
* @param userName
|
* @param userName
|
||||||
*/
|
*/
|
||||||
public UserEntity findByUserName(String userName) {
|
public com.hellogithub.entity.userEntity findByUserName(String userName) {
|
||||||
ResultSet resultSet = null;
|
ResultSet resultSet = null;
|
||||||
PreparedStatement preparedStatement = null;
|
PreparedStatement preparedStatement = null;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
@@ -104,7 +104,7 @@ public class UserDao {
|
|||||||
Integer id = resultSet.getInt(1);
|
Integer id = resultSet.getInt(1);
|
||||||
String dbUserName = resultSet.getString(2);
|
String dbUserName = resultSet.getString(2);
|
||||||
String dbUserPwd = resultSet.getString(3);
|
String dbUserPwd = resultSet.getString(3);
|
||||||
UserEntity mayiktUserEntity = new UserEntity(dbUserName, dbUserPwd);
|
com.hellogithub.entity.userEntity mayiktUserEntity = new userEntity(dbUserName, dbUserPwd);
|
||||||
return mayiktUserEntity;
|
return mayiktUserEntity;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
69
src/com/hellogithub/dao/projectDao.java
Normal file
69
src/com/hellogithub/dao/projectDao.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.hellogithub.dao;
|
||||||
|
|
||||||
|
import com.hellogithub.entity.projectEntity;
|
||||||
|
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.Connection;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class projectDao {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public List<projectEntity> retTerm(String num) {
|
||||||
|
List<projectEntity> projectEntityList;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql = "select * from project where periodicals = ?";
|
||||||
|
projectEntityList = runner.query(conn, sql, new BeanListHandler<>(projectEntity.class), num);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntityList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int latestNum() {
|
||||||
|
projectEntity projectEntity;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql = "select * from project Group BY periodicals DESC limit 1";
|
||||||
|
projectEntity = runner.query(conn, sql, new BeanHandler<>(projectEntity.class));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntity.getPeriodicals();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int countAll() {
|
||||||
|
int count;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql = "select count(1) from project";
|
||||||
|
count = runner.query(conn, sql, new BeanHandler<>(Integer.class));
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<projectEntity> retCate(int num) {
|
||||||
|
List<projectEntity> projectEntityList;
|
||||||
|
try {
|
||||||
|
Connection conn = JdbcUtils.getConnection();
|
||||||
|
QueryRunner runner = new QueryRunner();
|
||||||
|
String sql = "select * from project where categoryId = ?";
|
||||||
|
projectEntityList = runner.query(conn, sql, new BeanListHandler<>(projectEntity.class), num);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
return projectEntityList;
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +0,0 @@
|
|||||||
package com.hellogithub.entity;
|
|
||||||
|
|
||||||
public class AdminEntity {
|
|
||||||
}
|
|
8
src/com/hellogithub/entity/adminEntity.java
Normal file
8
src/com/hellogithub/entity/adminEntity.java
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
public class adminEntity {
|
||||||
|
int adminId;
|
||||||
|
String adminName;
|
||||||
|
String adminPassword;
|
||||||
|
int isValid;
|
||||||
|
}
|
54
src/com/hellogithub/entity/articleEntity.java
Normal file
54
src/com/hellogithub/entity/articleEntity.java
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
public class articleEntity {
|
||||||
|
|
||||||
|
int articleId;
|
||||||
|
|
||||||
|
int userId;
|
||||||
|
|
||||||
|
public int getArticleId() {
|
||||||
|
return articleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArticleId(int articleId) {
|
||||||
|
this.articleId = articleId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArticleContent() {
|
||||||
|
return articleContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArticleContent(String articleContent) {
|
||||||
|
this.articleContent = articleContent;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPublishTime() {
|
||||||
|
return publishTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPublishTime(String publishTime) {
|
||||||
|
this.publishTime = publishTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsValid() {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(int isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
String articleContent;
|
||||||
|
|
||||||
|
String publishTime;
|
||||||
|
int isValid;
|
||||||
|
|
||||||
|
}
|
32
src/com/hellogithub/entity/categoryEntity.java
Normal file
32
src/com/hellogithub/entity/categoryEntity.java
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
public class categoryEntity {
|
||||||
|
int categoryId;
|
||||||
|
String category;
|
||||||
|
|
||||||
|
public int getCategoryId() {
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(int categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCategory() {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategory(String category) {
|
||||||
|
this.category = category;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsValid() {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(int isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
int isValid;
|
||||||
|
}
|
69
src/com/hellogithub/entity/commentEntity.java
Normal file
69
src/com/hellogithub/entity/commentEntity.java
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class commentEntity {
|
||||||
|
int commentId;
|
||||||
|
int userId;
|
||||||
|
int projectId;
|
||||||
|
String content;
|
||||||
|
int isUsed;
|
||||||
|
Date commentTime;
|
||||||
|
int isValid;
|
||||||
|
|
||||||
|
public int getCommentId() {
|
||||||
|
return commentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentId(int commentId) {
|
||||||
|
this.commentId = commentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectId(int projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getContent() {
|
||||||
|
return content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContent(String content) {
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsUsed() {
|
||||||
|
return isUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsUsed(int isUsed) {
|
||||||
|
this.isUsed = isUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getCommentTime() {
|
||||||
|
return commentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommentTime(Date commentTime) {
|
||||||
|
this.commentTime = commentTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsValid() {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(int isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
}
|
31
src/com/hellogithub/entity/projectCategoryEntity.java
Normal file
31
src/com/hellogithub/entity/projectCategoryEntity.java
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
public class projectCategoryEntity {
|
||||||
|
int id;
|
||||||
|
int categoryId;
|
||||||
|
int projectId;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCategoryId() {
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(int categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectId(int projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
}
|
114
src/com/hellogithub/entity/projectEntity.java
Normal file
114
src/com/hellogithub/entity/projectEntity.java
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
package com.hellogithub.entity;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
public class projectEntity {
|
||||||
|
int projectId;
|
||||||
|
int userId;
|
||||||
|
String projectUrl;
|
||||||
|
String projectIco;
|
||||||
|
String projectTitle;
|
||||||
|
String projectDescription;
|
||||||
|
int startNum;
|
||||||
|
Date submitTime;
|
||||||
|
int categoryId;
|
||||||
|
int isValid;
|
||||||
|
String fileAddress;
|
||||||
|
int periodicals;
|
||||||
|
|
||||||
|
public int getProjectId() {
|
||||||
|
return projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectId(int projectId) {
|
||||||
|
this.projectId = projectId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserId() {
|
||||||
|
return userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUserId(int userId) {
|
||||||
|
this.userId = userId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjectUrl() {
|
||||||
|
return projectUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectUrl(String projectUrl) {
|
||||||
|
this.projectUrl = projectUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjectIco() {
|
||||||
|
return projectIco;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectIco(String projectIco) {
|
||||||
|
this.projectIco = projectIco;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjectTitle() {
|
||||||
|
return projectTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectTitle(String projectTitle) {
|
||||||
|
this.projectTitle = projectTitle;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProjectDescription() {
|
||||||
|
return projectDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProjectDescription(String projectDescription) {
|
||||||
|
this.projectDescription = projectDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getStartNum() {
|
||||||
|
return startNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartNum(int startNum) {
|
||||||
|
this.startNum = startNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getSubmitTime() {
|
||||||
|
return submitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSubmitTime(Date submitTime) {
|
||||||
|
this.submitTime = submitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCategoryId() {
|
||||||
|
return categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCategoryId(int categoryId) {
|
||||||
|
this.categoryId = categoryId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIsValid() {
|
||||||
|
return isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsValid(int isValid) {
|
||||||
|
this.isValid = isValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileAddress() {
|
||||||
|
return fileAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileAddress(String fileAddress) {
|
||||||
|
this.fileAddress = fileAddress;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPeriodicals() {
|
||||||
|
return periodicals;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPeriodicals(int periodicals) {
|
||||||
|
this.periodicals = periodicals;
|
||||||
|
}
|
||||||
|
}
|
@@ -5,7 +5,7 @@ import java.sql.Date;
|
|||||||
/**
|
/**
|
||||||
* 用户实体层
|
* 用户实体层
|
||||||
*/
|
*/
|
||||||
public class UserEntity {
|
public class userEntity {
|
||||||
/**
|
/**
|
||||||
* CREATE TABLE `user` (
|
* CREATE TABLE `user` (
|
||||||
* `userId` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
* `userId` int(11) NOT NULL AUTO_INCREMENT COMMENT '用户ID',
|
||||||
@@ -30,16 +30,16 @@ public class UserEntity {
|
|||||||
|
|
||||||
private String searchHistory;
|
private String searchHistory;
|
||||||
|
|
||||||
public UserEntity() {
|
public userEntity() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity(String userName, String userPassword) {
|
public userEntity(String userName, String userPassword) {
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.userPassword = userPassword;
|
this.userPassword = userPassword;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserEntity(Integer userId, String userName, String userPassword, Date creatTime, Integer isValid, Integer projectNum, String searchHistory) {
|
public userEntity(Integer userId, String userName, String userPassword, Date creatTime, Integer isValid, Integer projectNum, String searchHistory) {
|
||||||
this.userId = userId;
|
this.userId = userId;
|
||||||
this.userName = userName;
|
this.userName = userName;
|
||||||
this.userPassword = userPassword;
|
this.userPassword = userPassword;
|
@@ -1,7 +1,7 @@
|
|||||||
package com.hellogithub.service;
|
package com.hellogithub.service;
|
||||||
|
|
||||||
import com.hellogithub.dao.UserDao;
|
import com.hellogithub.dao.UserDao;
|
||||||
import com.hellogithub.entity.UserEntity;
|
import com.hellogithub.entity.userEntity;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用户Service层
|
* 用户Service层
|
||||||
@@ -13,7 +13,7 @@ public class UserService {
|
|||||||
* @param userName
|
* @param userName
|
||||||
* @param password
|
* @param password
|
||||||
* */
|
* */
|
||||||
public UserEntity UserLogin(String userName,String password){
|
public userEntity UserLogin(String userName, String password){
|
||||||
return userDao.UserLogin(userName,password);
|
return userDao.UserLogin(userName,password);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@@ -28,7 +28,7 @@ public class UserService {
|
|||||||
* 通过用户名查询
|
* 通过用户名查询
|
||||||
* @param userName
|
* @param userName
|
||||||
* */
|
* */
|
||||||
public UserEntity findByUserName(String userName) {
|
public userEntity findByUserName(String userName) {
|
||||||
return userDao.findByUserName(userName);
|
return userDao.findByUserName(userName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
src/com/hellogithub/service/projectService.java
Normal file
16
src/com/hellogithub/service/projectService.java
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
package com.hellogithub.service;
|
||||||
|
|
||||||
|
import com.hellogithub.dao.UserDao;
|
||||||
|
import com.hellogithub.dao.projectDao;
|
||||||
|
import com.hellogithub.entity.projectEntity;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class projectService {
|
||||||
|
private projectDao projectDao=new projectDao();
|
||||||
|
|
||||||
|
public List<projectEntity> retTerm(String num){return projectDao.retTerm(num);}
|
||||||
|
public int latestNum() {return projectDao.latestNum();}
|
||||||
|
public int countAll() {return projectDao.countAll();}
|
||||||
|
public List<projectEntity> retCate(int num){return projectDao.retCate(num);}
|
||||||
|
}
|
@@ -1,8 +1,7 @@
|
|||||||
package com.hellogithub.servlet;
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hellogithub.entity.UserEntity;
|
import com.hellogithub.entity.userEntity;
|
||||||
import com.hellogithub.service.UserService;
|
import com.hellogithub.service.UserService;
|
||||||
import com.hellogithub.utils.RandomValidateCode;
|
import com.hellogithub.utils.RandomValidateCode;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@@ -59,7 +58,7 @@ public class UserLoginServlet extends HttpServlet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 在调用业务逻辑层
|
// 在调用业务逻辑层
|
||||||
UserEntity adminUserEntity = userService.UserLogin(userName, userPwd);
|
userEntity adminUserEntity = userService.UserLogin(userName, userPwd);
|
||||||
if (adminUserEntity == null) {
|
if (adminUserEntity == null) {
|
||||||
// 用户名称或者密码错误!
|
// 用户名称或者密码错误!
|
||||||
setResultError("用户名或者密码错误!!!", writer);
|
setResultError("用户名或者密码错误!!!", writer);
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
package com.hellogithub.servlet;
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.hellogithub.entity.UserEntity;
|
import com.hellogithub.entity.userEntity;
|
||||||
import com.hellogithub.service.UserService;
|
import com.hellogithub.service.UserService;
|
||||||
import com.hellogithub.utils.RandomValidateCode;
|
import com.hellogithub.utils.RandomValidateCode;
|
||||||
import jakarta.servlet.ServletException;
|
import jakarta.servlet.ServletException;
|
||||||
@@ -60,7 +60,7 @@ public class UserRegisterServlet extends HttpServlet {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 用户注册之前根据用户名称查询该用户是否存在如果不存在的情况下才可以注册 如果存在的话就无法注册
|
// 用户注册之前根据用户名称查询该用户是否存在如果不存在的情况下才可以注册 如果存在的话就无法注册
|
||||||
UserEntity userEntity = userService.findByUserName(userName);
|
userEntity userEntity = userService.findByUserName(userName);
|
||||||
if (userEntity != null) {
|
if (userEntity != null) {
|
||||||
setResultError("用户名: " + userName + "已被注册!", writer);
|
setResultError("用户名: " + userName + "已被注册!", writer);
|
||||||
return;
|
return;
|
||||||
|
47
src/com/hellogithub/servlet/countNumServlet.java
Normal file
47
src/com/hellogithub/servlet/countNumServlet.java
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hellogithub.dao.projectDao;
|
||||||
|
import com.hellogithub.service.projectService;
|
||||||
|
import jakarta.servlet.ServletConfig;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/countNum")
|
||||||
|
public class countNumServlet extends HttpServlet {
|
||||||
|
private projectService projectService=new projectService();
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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");
|
||||||
|
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
String str= "num:"+projectService.countAll();
|
||||||
|
String jsonString = JSONObject.toJSONString(str);
|
||||||
|
writer.println(jsonString);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
45
src/com/hellogithub/servlet/latestServlet.java
Normal file
45
src/com/hellogithub/servlet/latestServlet.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hellogithub.service.projectService;
|
||||||
|
import jakarta.servlet.ServletConfig;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/latest")
|
||||||
|
public class latestServlet extends HttpServlet {
|
||||||
|
private com.hellogithub.service.projectService projectService=new projectService();
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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");
|
||||||
|
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
String jsonString = JSONObject.toJSONString(projectService.latestNum());
|
||||||
|
writer.println(jsonString);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
45
src/com/hellogithub/servlet/selectCateServlet.java
Normal file
45
src/com/hellogithub/servlet/selectCateServlet.java
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hellogithub.service.projectService;
|
||||||
|
import jakarta.servlet.ServletConfig;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/selectCate")
|
||||||
|
public class selectCateServlet extends HttpServlet {
|
||||||
|
private projectService projectService=new projectService();
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 num = req.getParameter("xxxxxxx");
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
String jsonString = JSONObject.toJSONString(projectService.retTerm(String.valueOf(num)));
|
||||||
|
writer.println(jsonString);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
46
src/com/hellogithub/servlet/selectTermServlet.java
Normal file
46
src/com/hellogithub/servlet/selectTermServlet.java
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package com.hellogithub.servlet;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.hellogithub.service.projectService;
|
||||||
|
import jakarta.servlet.ServletConfig;
|
||||||
|
import jakarta.servlet.ServletException;
|
||||||
|
import jakarta.servlet.annotation.WebServlet;
|
||||||
|
import jakarta.servlet.http.HttpServlet;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.PrintWriter;
|
||||||
|
@WebServlet("/selectTerm")
|
||||||
|
public class selectTermServlet extends HttpServlet {
|
||||||
|
private projectService projectService=new projectService();
|
||||||
|
@Override
|
||||||
|
public void init(ServletConfig config) throws ServletException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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 num = req.getParameter("xxxxxxx");
|
||||||
|
PrintWriter writer = resp.getWriter();
|
||||||
|
String jsonString = JSONObject.toJSONString(projectService.retTerm(num));
|
||||||
|
writer.println(jsonString);
|
||||||
|
writer.close();
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user