网上拍卖系统论文(8)

2019-04-09 08:20

哈尔滨工业大学成人教育专升本 计算机科学与技术专业毕业论文 网上拍卖系统

import org.yeeku.service.AuctionManager; import org.yeeku.exception.AuctionException; import org.yeeku.struts.base.BaseAction; /**

* @author shm songhongmei_529@163.com * @version 1.0

* 处理商品种类显示动作 */

public class ViewKindAction extends BaseAction {

public ViewKindAction()

{ }

public ActionForward execute(ActionMapping mapping, ActionForm form,

javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AuctionException {

List kinds = mgr.getAllKind();

request.setAttribute(\将找到的对象保存到request对象再传入 request.setAttribute(\ return mapping.findForward(\ } }

其中BaseAction封装了系统所有逻辑功能的实现类org.yeeku.service包下的AuctionManager接口,其实现类为AuctionManagerImpl。主要包含的方法如下:

List getItemByWiner(int winerId) throws AuctionException;//根据赢取者查询物品

List getFailItems() throws AuctionException;//查询全部流拍的物品 Integer validLogin(String username , String pass) throws AuctionException;//根据用户名,密码验证登陆是否成功

List getBidByUser(int userId) throws AuctionException;//查询用户的全部出价

List getItemsByOwner(int userId) throws AuctionException;//根据用户id查找目前仍在拍卖中的物品

31

哈尔滨工业大学成人教育专升本 计算机科学与技术专业毕业论文 网上拍卖系统

List getAllKind()throws AuctionException;//查询全部种类

void addItem(String name , String desc , String remark , double initPrice , int avail , int kind , int userId) throws AuctionException;//添加物品

void addKind(String name , String desc ) throws AuctionException;//添加种类

List getItemsByKind(int kindId) throws AuctionException;//根据产品分类,获取当前拍卖的全部商品

Sring getKind(int kindId) throws AuctionException;//根据分类id,获取种类名

ItemBean getItem(int itemId) throws AuctionException;//根据物品id,获取物品

void addBid(int userId , int itemId , double bidPrice)throws AuctionException;//增加新的竞价

void updateWiner()throws AuctionException;//根据时间来修改物品的赢取者

void addAuctionUser(String username, String userpass, String email) throws AuctionException;//增加新的用户

3.实现数据访问层

涉及到显示商品种类的数据访问层方法AuctionManager的getAllKind()方法,并在该方法中调用为KindDao的findAll()方法,实现代码如下:

public List getAllKind() throws AuctionException {

try {

return kindDao.findAll(); //通过调用此方法 }

catch (Exception e) {

log.debug(e.getMessage());

throw new AuctionException(\底层业务异常,请重新试\ } }

public List findAll() {

return getHibernateTemplate().find(\ }

其中使用的HQL语句为“from Kind”,即从kind数据表中取出所有

32

哈尔滨工业大学成人教育专升本 计算机科学与技术专业毕业论文 网上拍卖系统

记录。

5.2.3 实现浏览拍卖物品页面

1.表示层实现

通过查看商品种类界面,点击某一种类链接时,就直接将请求转发给动作viewItem.do处理。最后转向实际的主页面(页面名称为“viewItem.jsp”)即可。在struts-config.xml文件中的设置如下:

type=\ scope=\ validate=\ parameter=\

点击主页导航栏上浏览拍卖物品链接即可进入浏览物品种类页面。如图5-2所示。

图5-2 浏览某类所有物品界面

查看某中类所有商品界面主要代码如下:

33

哈尔滨工业大学成人教育专升本 计算机科学与技术专业毕业论文 网上拍卖系统

bgcolor=\

name=\

name=\property=\name=\property=\

property=\

property=\

bgcolor=\

property=\

bgcolor=\

property=\

name=\name=\

其中,使用Struts的logic及bean标签循环显示商品分类信息。在遍历中用bean:write元素输出。

2.实现业务逻辑 浏览某一种类拍卖物品页面的显示涉及到得业务逻辑为org.yeeku.struts包下的ViewItemAction类,他用于从数据库中调出数据供页面显示。其中涉及商品类别的分类显示代码如下: import java.util.List;

import org.yeeku.service.AuctionManager; import org.yeeku.exception.AuctionException; import org.yeeku.struts.base.BaseAction; import org.yeeku.model.*;

34

哈尔滨工业大学成人教育专升本 计算机科学与技术专业毕业论文 网上拍卖系统

/**

* @author shm songhongmei_529@163.com * @version 1.0

* 处理商品显示动作 */

public class ViewItemAction extends BaseAction {

public ViewItemAction() { }

public ActionForward execute(ActionMapping mapping, ActionForm form, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws AuctionException { String id = request.getParameter(\ if (id == null || id.trim().equals(\ { request.setAttribute(\您必须选择有效的种类\ return mapping.findForward(\ } else {

String kind = mgr.getKind(Integer.parseInt(id) );

List items = mgr.getItemsByKind(Integer.parseInt(id) ); request.setAttribute(\ request.setAttribute(\

return mapping.findForward(\

} }

3.实现数据访问层

涉及到显示商品种类的数据访问层方法AuctionManager的getAllItem()方法,并在该方法中调用为ItemDao的findItemByKind(Integer kindId)方法,实现代码如下:

public List getItemsByKind(int kindId) throws AuctionException {

try {

List result = new ArrayList(); List items = itemDao.findItemByKind(new Integer(kindId));

35


网上拍卖系统论文(8).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:秦皇岛年丰林果种植农民专业合作社典型材料

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: