编辑: 于世美 | 2019-09-12 |
√ 评分等级 良好 指导教师 简短评语 指导教师签名 日期 备注 评分等级有五种:优秀、良好、中等、及格、不及格 小区物业管理系统的开发 课题内容和要求 课题内容:开发一个小区物业管理系统,进行系统需求分析、功能设计和数据库设计、基于B/S结构进行系统实现,对开发的系统进行测试. 课题要求:要求所开发的系统具有系统管理员、普通用户两类用户.使用前需要进行登录认证.注册普通用户账号需由管理员后台审核.审核后,个人可修改自己的信息,发布相关信息,并提供回复功能.管理员具有管理用户的权限,还可以发布小区通知等消息.数据库设计要充分考虑完整性约束,特别是回复功能所涉及的关联约束.
二、需求分析
1、用户注册:新用户注册,提供用户信息,检验新用户信息的有效性;
2、用户登陆:输入用户名和密码,判断用户身份,进入到对应的系统界面;
3、管理员登录: (1)用户管理:管理员由程序员设置一个,管理员可以对用户的状态进行审核,用户只有审核通过后才能登录到系统,管理员还可以进行修改用户资料,删除用户等操作;
(2)发布小区通知:管理员在信息栏界面进入小区通知发布相关消息;
4、普通用户登录: (1)发布消息:用户在信息栏界面进入普通消息进行消息发布;
?? (2)消息回复:用户可以点击相关消息进行消息回复;
?? (3)消息浏览:注册用户可以任意浏览消息;
(4)个人中心:用户可以在个人中心修改个人资料.
三、概要设计
1、数据库设计:
2、算法流程图: 管理员: 普通用户:
3、存储结构:类中的成员变量 public class Reply { //回复消息 private int rid;
private User user;
private Topic topic;
private Timestamp rtime;
private String rcontents;
public int getRid() { return rid;
} public class Section { //板块 private int sid;
private String sname;
private int snumber;
private String sinfo;
private User user;
public int getSid() { return sid;
} public class Topic { //消息 private int tid;
private Section section;
private User user;
private String tcontents;
private int tnumber;
private Timestamp ttime;
private String ttitle;
public int getTid() { return tid;
} public class User { //用户 private int uid;
private String uname;
private String upassword;
private String ustatus;
private String usex;
private int uage;
private int utel;
private String unumber;
private String ulevel;
public int getUid() { return uid;
}
四、详细设计 ReplyServlet:回复消息部分 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = request.getParameter( method );
if(method!=null&
&
method.equals( select 搜索回复 int id = Integer.parseInt(request.getParameter( id ));
int tid = Integer.parseInt(request.getParameter( tid ));
ReplyDao replyDao = new ReplyDao();
List replyList = null;
if(id==1){ replyList = replyDao.selectPage1(0, 0,tid);
}else{ replyList = replyDao.selectPage(0, 0);
} request.setAttribute( replyList , replyList);
if(id==1){ Topic topic = new Topic();
topic.setTid(tid);
TopicDao topicDao = new TopicDao();
topic = topicDao.selectByTid(topic);
request.setAttribute( topic , topic);
request.getRequestDispatcher( reply/reply.jsp ).forward( request, response);
}else{ request.getRequestDispatcher( reply/replySelect.jsp ).forward( request, response);
} }else if(method!=null&
&
method.equals( save 保存新发布的回复消息 int tid = Integer.parseInt(request.getParameter( tid ));
String rcontents = request.getParameter( rcontents );
UserDao userDao = new UserDao();
User user = (User)request.getSession().getAttribute( user );
int uid = userDao.selectByUname(user.getUname());
Reply reply = new Reply();
Topic topic = new Topic();
topic.setTid(tid);
reply.setTopic(topic);
user = new User();
user.setUid(uid);
reply.setUser(user);
reply.setRcontents(rcontents);
ReplyDao replyDao = new ReplyDao();
int count =replyDao.save(reply);
if(count>
0){ Topic topics = new Topic();
topics.setTid(tid);
TopicDao topicDao = new TopicDao();
topics = topicDao.selectByTid(topics);
request.setAttribute( topic , topics);
List replyList = replyDao.selectPage1(0, 0,tid);
request.setAttribute( replyList , replyList);
request.getRequestDispatcher( reply/reply.jsp ).forward(request, response);
}else{ request.getRequestDispatcher( fail.jsp ).forward(request, response);
} } } } SectionServlet:版块部分(分为小区通知和普通消息) protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = request.getParameter( method );
if (method != null &
&
method.equals( select )) { int id = Integer.parseInt(request.getParameter( id ));
SectionDao sectionDao = new SectionDao();
List sectionList = sectionDao.selectPage(0,0);
User user=new User();
user.setUid(id);
User newuser=new UserDao().selectByUid(user);
request.setAttribute( user ,newuser);
request.setAttribute( sectionList , sectionList);
if (id == 1) { request.getRequestDispatcher( section/section.jsp ).forward( request, response);
} else if(id==4){ request.getRequestDispatcher( section/sectioncommon.jsp ).forward( request, response);
} }else if(method.equals( selecter )){ request.getRequestDispatcher( section/section.jsp ) .forward(request, response);
}else { request.getRequestDispatcher( section/sectionSelect.jsp ) .forward(request, response);
} } } TopicServlet:发布消息部分 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String method = request.getParameter( method );
if (method != null &
&
method.equals( select 消息搜索功能 String page = request.getParameter( goPage );
int id = Integer.parseInt(request.getParameter( id ));
int sid = Integer.parseInt(request.getParameter( sid ));
TopicDao topicDao = new TopicDao();
List topicList = null;
if(id==1){ topicList = topicDao.selectPage1(0, 0,sid);
}else{ topicList = topicDao.selectPage(0, 0);
} request.setAttribute( topicList , topicList);
if(id==1){ Section section = new Section();
section.setSid(sid);
SectionDao sectionDao = new SectionDao();
section = sectionDao.selectByUid(section);
request.setAttribute( section , section);
request.getRequestDispatcher( topic/topic.jsp ).forward( request, response);
}else{ request.getRequestDispatcher( topic/topicSelect.jsp ).forward( request, response);
} } else if (method != null &
&
method.equals( save 保存新发布的消息 int id = Integer.parseInt(request.getParameter( id ));
int sid = Integer.parseInt(request.getParameter( sid ));
UserDao userDao = new UserDao();
User users = (User)request.getSession().getAttribute( user );
int uid = userDao.selectByUname(users.getUname());
String tcontents = request.getParameter( tcontents );
String ttitle = request.getParameter( ttitle );
Topic topic = new Topic();
Section section = new Section();
section.setSid(sid);
User user = new User();
user.setUid(uid);
topic.setSection(section);
topic.setUser(user);
topic.setTcontents(tcontents);
topic.setTtitle(ttitle);
TopicDao topicDao = new TopicDao();
int count = topicDao.save(topic);
List topicList = null;
if(id==1){ Section sections = new Section();
sections.setSid(sid);
SectionDao sectionDao = new SectionDao();
sections = sectionDao.selectByUid(sections);
request.setAttribute( section , sections);
topicList = topicDao.selectPage1(0, 0,sid);
}else{ topicList = topicDao.selectPage(0, 0);
} request.setAttribute( topicList , topicList);
if(id==1){ request.getRequestDispatcher( topic/topic.jsp ).forward( request, response);
}else{ request.getRequestDispatcher( topic/topicSelect.jsp ).forward( request, response);
} } } } UserServlet:用户部分 protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding( utf-8 );
response.setContentType( text/html;
charset=utf-8 );
String method = request.getParameter( method );
if (method != null &
&
method.equals( login 实现登录功能 String uname = request.getParameter( username );
String upassword = request.getParameter( password );
User user = new User();
user.setUname(uname);
user.setUpassword(upassword);
UserDao userDao = new UserDao();
User users = new User();
users = userDao.login(user);
if (users != null) { String ulevel = users.getUlevel();
String ustatus = users.getUstatus();
user.setUlevel(ulevel);
user.setUstatus(ustatus);
if(ulevel.equals( 管理员 判断用户身份进入不同的登录界面 HttpSession session = request.getSession();
session.setAttribute( ulevel , ulevel);
session.setAttribute( user , users);
request.getRequestDispatcher( index.jsp ).forward( request, response);
}else if(ulevel.equals( 普通用户 ) &
&
ustatus.equals( 审核通过 )){ HttpSession session = request.getSession();
session.setAttribute( ustatus , ustatus);
session.setAttribute( user , users);
request.getRequestDispatcher( common.jsp ).forward( request, response);
}else { request.getRequestDispatcher( back/fail.jsp );
} } } else if (method != null &
&
method.equals( register 实现用户注册功能 String uname = request.getParameter( name );
String upassword = request.getParameter( pwd );
User user = new User();
user.setUname(uname);
user.setUpassword(upassword);
UserDao userDao = new UserDao();
int count = userDao.save(user);
if (count >
0) { SectionDao sectionDao = new SectionDao();
List sectionList = sectionDao.select();
request.setAttribute( sectionList , sectionList);
HttpSession session = request.getSession();
session.setAttribute( user , user);
request.getRequestDispatcher( login.jsp ).forward( request, response);
} else { request.getRequestDispatcher( user/register.jsp ).forward( request, response);
} } else if (method != null &
&
method.equals( logout 实现退出功能 request.getSession().removeAttribute( user );
request.getSession().removeAttribute( uid );
request.getSession().removeAttribute( ustatus );
request.getRequestDispatcher( login.jsp ) .forward(request, response);
} else if (method != null &
&
method.equals( list )) { //显示用户管理界面的用户列表 String searchVal = request.getParameter( searchVal );
UserDao userDao = new UserDao();
List userList = userDao.select(searchVal);
request.setAttribute( userList , userList);
request.getRequestDis................