一、项目简介:
该网站的开发使用的编译器是Eclipse,使用Java语言开发。主要用到的技术是Jsp+Servlet,以及MVC设计思想。通过MySQL数据库来存储该网站的数据信息,通过Tomcat将其部署。
二、系统角色:
系统分为3类角色,分别是管理员、用户、编辑者。不同的角色登录之后,具有不同的操作权限。管理员的权限最高。可以添加编辑者和用户的账户,并对他们的信息进行修改。
管理员:
1、管理员有权限管理所有信息,并对编辑者发布的小说内容进行审核。
2、管理员也可以录入、修改、删除小说的内容。
3、管理员还可以新增小说的种类,例如言情小说、科幻小说等。
4、可以查看到所有用户对小说的评论,也可以对评论进行删除操作。
编辑者:
1、编辑者可以查看并修改个人信息。
2、可以通过小说内容管理查看列表,查看发布的小说是否由管理员审核通过。
3、编辑者可以新增小说名称,可以通过小说列表查看,并录入小说新章节。
用户:
1、在小说阅读网站阅读小说。可以选择想要阅读的种类进行搜索。
2、当游客想要给该小说评论时,首先要注册账号,成为用户之后,方可参与评论。
三、实现功能:
登录功能实现:
三种角色进入以后,选择自己的身份使用。普通用户如果没有账号,可以先注册账号再登录。
管理员主要功能实现:
1、用户管理:用户信息的增删改查。
2、新增用户:
3、编辑者管理:编辑者信息的增删改查。
修改编辑者信息的Servlet层主要代码如下。
String id=request.getParameter("eid");
String ename = request.getParameter("ename");
String pwd = request.getParameter("pwd");
String phone = request.getParameter("phone");
String sex = request.getParameter("sex");
String email = request.getParameter("email");
String eno = request.getParameter("eno");
Editors ss = new Editors();
ss.setEmail(email);
ss.setEname(ename);
ss.setPwd(pwd);
ss.setPhone(phone);
ss.setSex(sex);
ss.setEno(eno);
ss.setId(Integer.parseInt(id));
service.updateEditors(ss);
response.sendRedirect(request.getContextPath()+"/EditorsServlet?action=EditorsList");//重定向
4、小说信息列表管理:小说信息的增删改查。
删除小说信息列表的Servlet层主要代码如下:
protected void deleteNews(HttpServletRequest request, HttpServletResponse response) throws Exception {
String id=request.getParameter("id");
service.deleteNews(id);
response.sendRedirect(request.getContextPath()+"/NewsServlet?action=NewsList");
}
5、小说内容类型管理:小说类型的增删改查。
新增小说类型:
修改小说类型的Servlet层主要代码如下:
String names=request.getParameter("cname");
String id=request.getParameter("tid");
Category Category = new Category();
Category.setCname(names);
Category.setId(Integer.parseInt(id));
service.updateCategory(Category);
}
6、小说内容管理 :管理员要对编辑者发布的所有小说进行审核,审核通过之后,才能供游客和用户阅读。如果内容不符合要求,将会拒绝该小说内容发布
7、评论管理:管理员可以查看到用户的所有评论,以及评论的用户和时间。对不当的评论进行删除。
普通用户主要功能实现
1、注册账户
2、小说网站的首页图。
3、参与评论 :
编辑者主要功能实现
1、个人信息管理 。修改个人信息
2、小说内容审核列表 :查看发布的小说内容是否审核通过,审核通过之后,才能供游客和用户阅读。
3、新增小说 :编辑者想要发布新一骗小说时,首先要将小说的名称录入该系统,并选择相应的小说类型。之后才可以进行录入小说内容。
4、小说内容管理列表
public List<Editors> getEditorsPage(int pageNum, int pageSize,Map map) {
String sql="select * from Editors where 1 = 1 ";
if(map.get("names") != null && !map.get("names").toString().equals("")) {
sql+=" and ename like '%"+map.get("names")+"%'";
}
if(map.get("eid") != null && !map.get("eid").toString().equals("")) {
sql+=" and id = "+map.get("eid");
}
sql += " limit ?,? ";
int startNo=(pageNum-1)*pageSize;
List<Editors> list=null;
try {
list= runner.query(sql, new BeanListHandler<Editors>(Editors.class),new Object[] {startNo,pageSize});//添加实体类的适配器进行类的反�?
return list;
} catch (Exception e) {//捕获异常
throw new RuntimeException(e);//抛出运行异常
}
}
public int queryEditorsCount(Map map) {
String sql="select count(*) from Editors where 1 = 1 ";
if(map.get("names") != null && !map.get("names").toString().equals("")) {
sql+=" and ename like '%"+map.get("names")+"%'";
}
if(map.get("eid") != null && !map.get("eid").toString().equals("")) {
sql+=" and id = "+map.get("eid");
}
try {
Long count = (Long) runner.query(sql, new ScalarHandler());
return count.intValue();
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException(e);
}
}
public void addEditors(Editors ss) {
// TODO Auto-generated method stub
try {
//执行插入sql
runner.update("insert into Editors(ename,pwd,phone,sex,email,times,eno) values (?,?,?,?,?,?,?)",
ss.getEname(),ss.getPwd(),ss.getPhone(),ss.getSex(),ss.getEmail(),ss.getTimes(),ss.getEno());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public Editors selectEditors(String id) {
try {//
return runner.query("select * from Editors where id=?", new BeanHandler<Editors>(Editors.class),Integer.parseInt(id));
} catch (Exception e) {
throw new RuntimeException(e);//抛出运行异常
}
}
public Editors selectEditors1(Integer id) {
try {//
return runner.query("select * from Editors where id=?", new BeanHandler<Editors>(Editors.class),id);
} catch (Exception e) {
throw new RuntimeException(e);//抛出运行异常
}
}
public void updateEditors(Editors ss) {
// TODO Auto-generated method stub
try {
//执行插入sql
runner.update("update Editors set ename=?,pwd=?,phone=?,sex=?,email=?,eno=? where id=?",
ss.getEname(),ss.getPwd(),ss.getPhone(),ss.getSex(),ss.getEmail(),ss.getEno(),ss.getId());
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public void deleteEditors(String id) {
// TODO Auto-generated method stub
try {
//执行插入sql
runner.update("delete from Editors where id=?",
Integer.parseInt(id));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
public List<Editors> selectList() {
String sql="select * from Editors ";
List<Editors> list=null;
try {
list= runner.query(sql, new BeanListHandler<Editors>(Editors.class));//添加实体类的适配器进行类的反�?
return list;
} catch (Exception e) {//捕获异常
throw new RuntimeException(e);//抛出运行异常
}
}
}