1、用户:1、用户可以注册会员,利用已经注册的用户名来登录相关界面。2、用户可以登记自己的相关性信息,并且可以查看、更改自己的相关信息。3、用户根据已经注册的用户名来登录系统。用户可以查看所有物品的信息。4、用户可以将想要购买的物品加入购物车,对已经加入购物车的物品,用户可以查看其相关信息,并且可以删除已经加入的物品。5、对于购物车功能,可以增加新书、修改数量、删除已选书籍等,确认后,完成交易;6、用户可以根据作者的姓名、书名、书号来检索书籍。7、用户可以查看当前订单和以往订单的相关信息。8、客户可以通过信息反馈系统跟书店员工进行交流。管理员:1、 管理员可以删除、更改用户信息。2、 管理员可以删
2、除、更改订单信息,可以输入订单的发货日期。3、 管理员可以删除、更改所有商品信息。其他需求: 系统应该具有一定的安全性和可靠性。 数据库支持大量数据的使用。三、概要设计 体系结构设计:用户使用流程:用户应用系统模块设计:管理员应用模块:四、源程序代码Base:/* 供JSON-RPC组件远程调用的AjaxBean */public class AjaxBean extends BaseLog /*取得商品分类列表*/ public String getCategory() String options = null; MerService service = new MerServiceImp
3、l(); try List list = service.browseCategory(); Category cate = null; int i = 0; if (list!=null) options = new Stringlist.size()2; Iterator it = list.iterator(); while(it.hasNext() cate = (Category)it.next(); optionsi0 =cate.getId().toString(); optionsi1 =cate.getCateName().trim(); i+; else options =
4、 new String12; options00 =0; options01 =无商品分类 catch(Exception ex) logger.info(在执行AjaxBean类中的getCategory方法时出错:n); ex.printStackTrace(); return options; /*取得会员级别*/ public String getMemberLevel() MemService service = new MemServiceImpl(); List list = service.browseMemberLevel(); Memberlevel ml = null;
5、ml = (Memberlevel)it.next(); optionsi0 =ml.getId().toString(); optionsi1 =ml.getLevelName().trim();无会员级别在执行AjaxBean类中的getMemberLevel方法时出错: /*注册登录帐号有效性验证*/ public boolean chkLoginName(String loginName) boolean result = false; result = service.chkLoginName(loginName);在执行AjaxBean类中的chkLoginName方法时出错: r
6、eturn result; /*修改选购商品数量*/ public boolean modiCart(int id,int number) CartService service = new CartServiceImpl(); result = service.modiCart(Integer.valueOf(id), number);在执行AjaxBean类中的modiCart方法时出错: /*调整会员级别*/ public boolean updateLevel(Integer id,Integer levelId) Member member = service.loadMember(
7、id); Memberlevel level = service.loadMemberLevel(levelId); member.setMemberlevel(level); service.updateMember(member); result = true;在执行AjaxBean类中的updateLevel方法时出错: ORM:Mysessionfactory:public class MySessionFactory private static String CONFIG_FILE_LOCATION = /hibernate.cfg.xml private static final
8、 ThreadLocal threadLocal = new ThreadLocal(); private static Configuration configuration = new Configuration(); private static org.hibernate.SessionFactory sessionFactory; private static String configFile = CONFIG_FILE_LOCATION; static try configuration.configure(configFile); sessionFactory = config
9、uration.buildSessionFactory(); catch (Exception e) System.err.println(% Error Creating SessionFactory % e.printStackTrace(); private MySessionFactory() public static Session getSession() throws HibernateException Session session = (Session) threadLocal.get(); if (session = null | !session.isOpen() i
10、f (sessionFactory = null) rebuildSessionFactory();session = (sessionFactory != null) ? sessionFactory.openSession(): null; threadLocal.set(session); return session; /*Rebuild hibernate session factory*/ public static void rebuildSessionFactory() /*Close the single hibernate session instance.*/ publi
11、c static void closeSession() throws HibernateException threadLocal.set(null); if (session != null) session.close(); /*return session factory*/ public static org.hibernate.SessionFactory getSessionFactory() return sessionFactory; /*return session factory session factory will be rebuilded in the next
12、call*/ public static void setConfigFile(String configFile) MySessionFactory.configFile = configFile; sessionFactory = null; /*return hibernate configuration*/ public static Configuration getConfiguration() return configuration; SERVICE:AdminServiceImpl:/* 系统用户管理接口实现 */public class AdminServiceImpl e
13、xtends BaseLog implements AdminService /* 系统管理员登录 */ public Admin adminLogin(String loginName, String loginPwd) throws Exception Session session = MySessionFactory.getSession(); Transaction tx = null; Admin admin = null; String hql = select a from Admin as a where a.loginName=:loginName and a.loginP
14、wd=:loginPwd Query query = session.createQuery(hql); query.setString(loginName, loginName);, loginPwd); query.setMaxResults(1); tx = session.beginTransaction(); admin = (Admin)query.uniqueResult(); mit(); if(tx!=null)tx.rollback();在执行AdminServiceImpl类中的adminLogin方法时出错: finally MySessionFactory.close
15、Session(); return admin; /* 新增管理员 */ public boolean addAdmin(Admin admin) throws Exception boolean status = false; session.save(admin); status = true;在执行AdminServiceImpl类中的addAdmin方法时出错: return status; /* 浏览管理员 */ public List browseAdmin() throws Exception List list = null; Query query = session.cre
16、ateQuery(from Admin as a order by a.id list = query.list(); if (!Hibernate.isInitialized(list)Hibernate.initialize(list);在执行AdminServiceImpl类中的browseAdmin方法时出错: return list; /* 删除指定的管理员 */ public boolean delAdmin(Integer id) throws Exception Admin admin = (Admin)session.load(Admin.class, id); sessio
17、n.delete(admin);在执行AdminServiceImpl类中的delAdmin方法时出错: /* 装载指定的管理员 */ public Admin loadAdmin(Integer id) throws Exception admin = (Admin)session.get(Admin.class, id);在执行AdminServiceImpl类中的loadAdmin方法时出错:CartServiceImpl:public class CartServiceImpl extends BaseLog implements CartService /* 选购商品 */ publ
18、ic boolean addCart(Member member, Merchandise mer, int number)throws Exception Session session = MySessionFactory.getSession(); tryCartselectedmer sel = null;int favourable = member.getMemberlevel().getFavourable().intValue(); /判断该会员是否已经有使用中的购物车 String hql =from Cart as a where a.member=:member and
19、a.cartStatus=0 query.setEntity(member, member); Cart cart = (Cart)query.uniqueResult(); if (cart=null)cart = new Cart(); cart.setCartStatus(new Integer(0); cart.setMember(member);cart.setMoney(Double.valueOf(number*mer.getPrice().doubleValue(); cart.getMerchandises().add(mer); session.save(cart);els
20、e /如果选购的是已经选购过的商品则只增加商品数量即可 hql = select a from Cartselectedmer as a where a.cart=:cartid and a.merchandise=:merid order by a.id desc query = session.createQuery(hql); query.setInteger(cartid, cart.getId().intValue();merid, mer.getId().intValue(); query.setMaxResults(1); sel = (Cartselectedmer)query.uniqueResult(); int total = number;System.out.println(total*mer.getPrice().doubleValue()*favourable/100); if(sel!=null)total = n
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1