网上订餐系统源程序清单课程设计Word下载.docx

上传人:b****5 文档编号:19709245 上传时间:2023-01-09 格式:DOCX 页数:35 大小:150.20KB
下载 相关 举报
网上订餐系统源程序清单课程设计Word下载.docx_第1页
第1页 / 共35页
网上订餐系统源程序清单课程设计Word下载.docx_第2页
第2页 / 共35页
网上订餐系统源程序清单课程设计Word下载.docx_第3页
第3页 / 共35页
网上订餐系统源程序清单课程设计Word下载.docx_第4页
第4页 / 共35页
网上订餐系统源程序清单课程设计Word下载.docx_第5页
第5页 / 共35页
点击查看更多>>
下载资源
资源描述

网上订餐系统源程序清单课程设计Word下载.docx

《网上订餐系统源程序清单课程设计Word下载.docx》由会员分享,可在线阅读,更多相关《网上订餐系统源程序清单课程设计Word下载.docx(35页珍藏版)》请在冰豆网上搜索。

网上订餐系统源程序清单课程设计Word下载.docx

用户个人信息管理模块

选择相应个人信息管理功能

执行相应信息管理方法

用户订餐模块

选择相应订餐功能

执行相应订餐方法

 

2模块1(database)

2.1功能说明

数据库底层设计,涉及直接对数据库表中数据操作的公共方法的设计。

2.2设计说明

(1)本模块在网上订餐系统中处于底层,包括系统内的各个实体类及属性的设计,通过Dao层与其它层进行交互,在Daoimpl里面定义对Dao层的具体实现。

(2)考虑到若数据库被意外改动不方便重新建立,所以使用Hibernate进行数据库的连接和数据表的创建等工作。

而且由管理员进行定期的备份工作,方便数据表信息恢复。

(3)由于系统中几乎对所有类对象的操作都要涉及到增加、删除、修改和查询,为了增强代码的重用性,所以把对数据库增删改查的操作都提取出来作为公共代码使用。

2.3原代码清单

2.3.1子模块1(valueObject)

(1)用户信息表(t_user)//用Hibernate的XML方式,在Person.hbm.xml中,管理用户表

<

hibernate-mappingpackage="

cn.soft.vo"

>

<

classname="

Person"

table="

t_user"

<

idname="

user_id"

type="

integer"

>

generatorclass="

native"

/>

/id>

propertyname="

user_name"

length="

30"

not-null="

true"

/>

user_pass"

user_mail"

user_realname"

50"

user_sex"

user_role"

4"

one-to-onename="

userinfo"

property-ref="

user"

cascade="

delete"

!

—配置跟用户信息表的一对一的关系映射-->

<

keycolumn="

one-to-manyclass="

Orders"

/set>

setname="

message"

inverse="

--配置跟留言表Message的一对多的关系映射-->

<

Message"

/class>

/hibernate-mapping>

(2)菜单信息表(t_menu)//用Hibernate的XML方式,在Mymenu.hbm.xml中,管理菜单表

MyMenu"

t_menu"

menu_id"

menu_name"

menu_intro"

menu_price"

5"

orders"

false"

(3)订单信息表(t_order)//用Hibernate的XML方式,在Orders.hbm.xml中,管理订单表

order_id"

order_num"

order_notice"

other_notice"

states"

order_date"

many-to-onename="

column="

menu"

(4)留言信息表(t_message)//用Hibernate的XML方式,在Orders.hbm.xml中,管理留言表

t_message"

id"

subject"

45"

content"

200"

dates"

mg_date"

(5)配送信息表(userInfo)//用Hibernate的XML方式,在UserInfo.hbm.xml中,管理留言表

UserInfo"

t_userInfo"

address"

100"

tel"

15"

mobile"

11"

notice"

150"

sendDate"

send_date"

unique="

2.3.2子模块2(connectConfig)

(1)ApplicationContext.xml中配置和数据库的连接,设置Hibernate对数据库的自动管理,由Spring将所有类当作Bean进行管理。

context:

component-scanbase-package="

cn.soft"

beanid="

dataSource"

class="

com.mchange.v2.c3p0.ComboPooledDataSource"

destroy-method="

close"

—配置数据库连接名、用户名和密码等,配置数据源-->

/bean>

sessionFactory"

class="

org.springframework.orm.hibernate3.LocalSessionFactoryBean"

ref="

mappingResources"

list>

--将所有实体类的配置文件列出,在hibernate配置文件中添加映射-->

value>

cn/soft/vo/Person.hbm.xml<

/value>

/list>

/property>

hibernateProperties"

props>

propkey="

hibernate.dialect"

org.hibernate.dialect.MySQL5Dialect<

/prop>

hibernate.hbm2ddl.auto"

update<

hibernate.transaction.factory_class"

org.hibernate.transaction.JDBCTransactionFactory<

/props>

txManager"

org.springframework.orm.hibernate3.HibernateTransactionManager"

tx:

annotation-drivenproxy-target-class="

transaction-manager="

—配置类名和bean的id名的对应,方便在struts配置文件中使用-->

(2)hibernate.cfg.xml中添加映射,应用XML方式创建数据库

session-factory>

hibernate.connection.driver_class"

com.mysql.jdbc.Driver<

hibernate.connection.url"

jdbc:

mysql:

//localhost/order<

hibernate.connection.username"

root<

hibernate.connection.password"

hbm2ddl.auto"

--这里最好用update-->

format_sql"

true<

mappingresource="

cn/soft/vo/Person.hbm.xml"

/mapping>

mappingclass="

cn.soft.vo.Person"

ApplicationContext.xml"

-->

/session-factory>

3模块2(menuManage)

3.1功能说明

本模块主要实现菜单的管理工作,下设菜单添加、菜单删除、菜单修改和菜单查询4个子功能模块,可以对菜单中菜品的各项属性进行编辑和修改,可实现添加菜单记录时上传新菜单图片。

3.2设计说明

(1)本模块通过MenuDao与其它层进行交互,在MenuImpl里面定义dao层的具体实现。

(3)在MenuAction中定义与菜单表操作有关的方法,并返回字符串的结构通过struts中的配置跳转到下一个相应页面或方法。

3.3原代码清单

3.3.1子模块1(menuQuery)

图3-1菜单查询流程图

//查找出所有菜单,并分页显示,供管理员管理菜单页面使用,之后返回“menulist”,跳转到manage/menu_manage下的menu_index.jsp页面,通过依次读取searchList中的记录,来逐条显示菜单信息。

publicStringmenuList()

{ActionContextac=ActionContext.getContext();

QueryResult<

MyMenu>

qr=nextPage.viewList(menuDao,page,15,MyMenu.class,"

orderbyo.menu_id"

);

ac.getSession().put("

searchList"

qr.getResultSet());

page"

page);

return"

menulist"

;

}

3.3.2子模块2(menuAdd)

图3-2管理员添加菜单流程图

(1)添加菜单,自动按升序生成menu_id并将该条记录添加到菜单表里,跳转到上传图片界面。

publicStringaddMenu()

{menuDao.save(menu);

HttpServletRequestrequest=ServletActionContext.getRequest();

intnew_id=menu.getMenu_id();

request.getSession().setAttribute("

new_id"

new_id);

success"

(2)上传图片类,上传到项目webRoot文件夹下的dishes-img文件夹中,根据刚刚上传的菜单id命名为某菜单id.jpg。

HttpServletResponseresponse=ServletActionContext.getResponse();

HttpServletRequestrequest=ServletActionContext.getRequest();

HttpSessionsession=request.getSession();

publicFilegetUpload(){returnupload;

}

publicvoidsetUpload(Fileupload){this.upload=upload;

publicStringgetUploadFileName(){returnuploadFileName;

publicvoidsetUploadFileName(StringuploadFileName){this.uploadFileName=uploadFileName;

publicStringgetUploadContentType(){returnuploadContentType;

publicvoidsetUploadContentType(StringuploadContentType)

{this.uploadContentType=uploadContentType;

publicStringupload()

{

ActionContextact=ActionContext.getContext();

PrintWriterout=null;

try{

response.setCharacterEncoding("

GBK"

out=response.getWriter();

}catch(IOExceptione1){e1.printStackTrace();

Stringrealpath=ServletActionContext.getServletContext().getRealPath("

/dishes-img"

if(upload!

=null)

{FilesaveDir=newFile(realpath);

if(!

saveDir.exists())

{saveDir.mkdirs();

intnew_id1=(Integer)session.getAttribute("

Stringimg_id=String.valueOf(new_id1);

Stringimg_name=img_id.concat("

.jpg"

this.setUploadFileName(img_name);

FilesaveFile=newFile(saveDir,uploadFileName);

try{FileUtils.copyFile(upload,saveFile);

}catch(IOExceptione){e.printStackTrace();

}

3.3.3子模块3(menuDelete)

3-3删除菜单流程图

//删除菜单方法,跳转到菜单管理页面。

publicStringdeleteMenu()

{HttpServletRequestrequest=ServletActionContext.getRequest();

intid=Integer.parseInt(request.getParameter("

menuID"

));

menuDao.delete(MyMenu.class,id);

3.3.4子模块4(menuUpdate)

图3-4更新菜单流程图

(1)根据id先查出对应菜单的信息,然后跳转到更新页面

publicStringupdateUI()

{

MyMenum=menuDao.find(MyMenu.class,id);

m);

update"

//更新菜单信息,调用menuDao的update方法进行更新

publicStringupdateMenu()

{MyMenum=menuDao.find(MyMenu.class,menu.getMenu_id());

m.setMenu_name(menu.getMenu_name());

m.setMenu_price(menu.getMenu_price());

m.setMenu_intro(menu.getMenu_intro());

menuDao.update(m);

publicStringgetName(){returnname;

publicvoidsetName(Stringname){this.name=name;

publicintgetPage(){returnpage;

publicvoidsetPage(intpage){this.page=page;

publicMyMenugetMenu(){returnmenu;

publicvoidsetMenu(MyMenumenu){this.menu=menu;

4模块3(messageManage)

4.1功能说明

本模块中下设添加留言、浏览留言和删除留言2个子功能模块,用户可以对自己的留言进行管理,管理员可以对所有用户的留言进行管理。

4.2设计说明

(1)本模块通过MessageDao与其它层交互,在MessageImpl里面定义dao层的具体实现。

(3)在MessageAction中定义与菜单表操作有关的方法,并返回字符串的结构通过struts中的配置跳转到下一个相应页面或方法。

4.3原代码清单

4.3.1子模块1(messageQuery)

图4-1管理员查看留言流程图

(1)/*如果用户已处于登录状态,就查询出所有留言记录,返回到一个显示留言列表的视图,如果没有登录则返回的到登录界面视图让用户先登录*/

publicStringmessageUI()

ActionContexta

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 基础医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1