package com.lzw.dao;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.lzw.form.ModifyMemberForm;
import com.lzw.model.TbBbs;
import com.lzw.model.TbGoods;
import com.lzw.model.TbManager;
import com.lzw.model.TbMember;
import com.lzw.model.TbOrder;
import com.lzw.model.TbSubType;
import com.lzw.model.TbSuperType;
import com.lzw.model.VGoods;
public class Dao extends HibernateDaoSupport {
// 获取特价商品
public List getShowSaleGoodsList() {
return getHibernateTemplate().find(
"from TbGoods where sale=1 order by INTime desc");
}
// 获取新品
public List getShowNewGoodsList() {
return getHibernateTemplate().find(
"from TbGoods where newGoods=1 order by INTime desc");
}
// 获取单个商品信息
public TbGoods getGoods(Long id) {
return (TbGoods) getHibernateTemplate().get(TbGoods.class, id);
}
public List getGoodsByType(Integer type) {
return getHibernateTemplate()
.find("from VGoods where id.subId=" + type);
}
public List getGoodsByQuery(String query) {
System.out.println(query+"\to");
return getHibernateTemplate().find(query);
}
// 获取用户
public TbMember getUser(String username, String pwd) {
List list = null;
TbMember user = null;
list = getHibernateTemplate().find(
"from TbMember where userName='" + username + "' and freeze=0");
if (list.size() > 0) {
user = (TbMember) list.get(0);
if (pwd != null && !user.getPassWord().equals(pwd)) {
user = null;
}
}
return user;
}
// 获取公告
public List getPlacard() {
return getHibernateTemplate().find("from TbBbs order by INTime desc");
}
// 获取指定公告
public TbBbs getPlacard(Integer id) {
return (TbBbs) getHibernateTemplate().get(TbBbs.class, id);
}
public List getSellSort() {
List list = getHibernateTemplate()
.find(
"select id.goodsId,id.goodsName from"
+ " VOrderDetail group by id.goodsId,id.goodsName order by count(id.number) desc");
return list;
}
// 获取商品类别列表
public Map getTypeList() {
Map model = new HashMap();
List types = getHibernateTemplate()
.find(
"select id.id,id.superType from VType group by id.id,id.superType");
Iterator iterator = types.iterator();
while (iterator.hasNext()) {
Object[] type = (Object[]) iterator.next();
List subList = getHibernateTemplate().find(
"from VType where id.id='" + type[0] + "'");
model.put(type[1], subList);
}
return model;
}
// 获取搜索类型
public List getSearchClassify() {
return getHibernateTemplate()
.find(
"select id.id,id.superType from VType group by id.id,id.superType order by id.superType");
}
public TbSuperType getSuperType(Integer id) {
return (TbSuperType) getHibernateTemplate().get(TbSuperType.class, id);
}
// 修改并更新用户信息
public void updateUserInfo(ModifyMemberForm form) {
TbMember oldUser = (TbMember) getHibernateTemplate().get(
TbMember.class, new Integer(form.getId()));
oldUser.setAddress(form.getAddress());
oldUser.setCardNo(form.getCardno());
oldUser.setCardType(form.getCardtype());
oldUser.setCity(form.getCity());
oldUser.setEmail(form.getEmail());
oldUser.setPassWord(form.getPwd());
oldUser.setPostcode(form.getPostcode());
oldUser.setTel(form.getTel());
oldUser.setTrueName(form.getTruename());
getHibernateTemplate().update(oldUser);
}
public List getOrder(String username) {
return getHibernateTemplate().find(
"from TbOrder where username='" + username + "'");
}
public List getOrders() {
return getHibernateTemplate().loadAll(TbOrder.class);
}
public TbOrder getOrder(Long id) {
return (TbOrder) getHibernateTemplate().get(TbOrder.class, id);
}
// 获取会员折扣
public float getUserRebate(String username) {
float rebate = 1;
List list = getHibernateTemplate().find(
"select id.rebate from VMember where username='" + username
+ "'");
if (list.size() > 0) {
System.out.println(list.get(0));
rebate = Float.valueOf(list.get(0) + "").floatValue();
}
return rebate;
}
// 获得TbRebate表数据等级为ID的记录
public int getGrade(double amount) {
int grade = 0;
List list = getHibernateTemplate().find(
"select grade from TbRebate where amount<" + amount);
if (list.size() > 0) {
grade = Integer.valueOf(list.get(0) + "");
}
return grade;
}
public boolean insertObject(Object obj) {
try {
getHibernateTemplate().save(obj);
return true;
} catch (DataAccessException e) {
e.printStackTrace();
return false;
}
}
// 在事物中完成订单保存和会员的更新
public void insertObject(TbMember user, TbOrder order) {
getHibernateTemplate().saveOrUpdate(user);
getHibernateTemplate().save(order);
}
// 获取管理员
public TbManager getManager(String manager) {
List list = getHibernateTemplate().find(
"from TbManager where manager='" + manager + "'");
TbManager user = null;
if (list.size() > 0)
user = (TbManager) list.get(0);
return user;
}
public List getSuperTypes() {
return getHibernateTemplate().find("from TbSuperType order by id Desc");
}
public List getSubTypes() {
return getHibernateTemplate().find("from VType order by id.id Desc");
}
public boolean delSuperType(String ids) {
String sql = "delete from TbSuperType Where id in(" + ids + ")";
boolean del = false;
try {
getHibernateTemplate().bulkUpdate(sql);
del = true;
} catch (Exception e) {
del = false;
}
return del;
}
public TbSuperType getSuperType(String typename) {
TbSuperType tst = null;
List list = getHibernateTemplate().find(
"from TbSuperType where typeName='" + typename + "'");
if (list.size() > 0)
tst = (TbSuperType) list.get(0);
return tst;
}
public boolean delSubType(String subTypeID) {
String sql = "delete from TbSubType Where id in(" + subTypeID + ")";
boolean del = false;
try {
getHibernateTemplate().bulkUpdate(sql);
del = true;
} catch (Exception e) {
del = false;
}
return del;
}
public TbSubType getSubType(String typename) {
TbSubType tst = null;
List list = getHibernateTemplate().find(
"from TbSubType where typeName='" + typename + "'");
if (list.size() > 0)
tst = (TbSubType) list.get(0);
return tst;
}
public TbSubType getSubType(Integer typeId) {
return (TbSubType) getHibernateTemplate().get(TbSubType.class, typeId);
}
public void insertOrUpdate(TbGoods form) {
getHibernateTemplate().saveOrUpdate(form);
}
public VGoods getVGoods(Long id) {
return (VGoods) getHibernateTemplate().get(VGoods.class, id);
}
public void delObject(Object obj) {
getHibernateTemplate().delete(obj);
}
public List getMembers() {
return getHibernateTemplate().loadAll(TbMember.class);
}
public int updateFreeze(int id) {
String sql = "update TbMember set freeze=1 where ID=" + id;
return getHibernateTemplate().bulkUpdate(sql);
}
public int updateThaw(int id) {
String sql = "update TbMember set freeze=0 where ID=" + id;
return getHibernateTemplate().bulkUpdate(sql);
}
public TbMember getMember(Integer id) {
return (TbMember) getHibernateTemplate().get(TbMember.class, id);
}
public int updateEnforce(int id) {
String sql = "update TbOrder set enforce=1 where orderID=" + id;
return getHibernateTemplate().bulkUpdate(sql);
}
public boolean delPlacard(String id) {
String sql = "delete from TbBbs Where id in(" + id + ")";
boolean del = false;
try {
getHibernateTemplate().bulkUpdate(sql);
del = true;
} catch (Exception e) {
del = false;
}
return del;
}
public TbBbs getBBS(String title) {
List list = getHibernateTemplate(
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
在线购物已经成了一种时尚,它为人们提供了网络购物的方便性,使顾客可以足不出户就可以购买商品,因其具有方便、安全、友好的交互等特性,顾客群体也逐渐庞大,尤其是网络时代中成长的年轻人。现在流行的电子商务有B2B,B2C,C2C,G2C等类型。欣想电子商城采用的是B2B类型,它可以使顾客通过网络购物、浏览商品、查询订单、查看公告和销售排行等。通过对一些典型电子商城网站的考察、分析,并结合企业要求以及实际的市场调查,要求本系统具有以下功能: 美观友好的操作界面,能保证系统的易用性。 规范、完善的基础信息设置。 商品分类详尽,可按不同类别查看商品信息。 按商品大类及商品名称进行模糊查询。 实现网上购物。 新品及特价商品展示。 商品销售排行。
资源推荐
资源详情
资源评论
收起资源包目录
欣想电子商城 spring+hibernate+sqlserver (302个子文件)
Dao.class 10KB
CartCheckoutController.class 6KB
VMemberId.class 5KB
TbOrder.class 4KB
VGoods.class 4KB
TbMember.class 4KB
CartController.class 4KB
TbGoods.class 4KB
SearchController.class 4KB
GoodsModifyController.class 3KB
LoginController.class 3KB
RegisterController.class 3KB
LoginController.class 3KB
SuperTypeController.class 3KB
ModifyMemberForm.class 3KB
GoodsDelController.class 3KB
ProductManagerController.class 3KB
SubTypeAddController.class 3KB
VOrderDetailId.class 3KB
ModifyMemberValidate.class 2KB
MemberTilesController.class 2KB
MemberManagerController.class 2KB
GoodsAddController.class 2KB
PlacardAddController.class 2KB
NewGoodsController.class 2KB
VTypeId.class 2KB
SuperTypeAddController.class 2KB
GoodsDetailsController.class 2KB
OrderManagerController.class 2KB
SubTypeController.class 2KB
PlacardManageController.class 2KB
TbOrderDetail.class 2KB
ModifyMemberController.class 2KB
ModifyMemberTilesController.class 2KB
CartCheckoutForm.class 2KB
CartCheckoutTilesController.class 2KB
PlacardDetailsController.class 2KB
TypeController.class 2KB
OrderDetailsController.class 2KB
OrderController.class 2KB
GridLayoutDemo.class 2KB
TbBbs.class 2KB
TypeListTilesController.class 2KB
GoodsAddTilesController.class 1KB
SubTypeAddTilesController.class 1KB
SearchTileController.class 1KB
sellSortTilesController.class 1KB
SubTypeTilesController.class 1KB
placardTilesController.class 1KB
TbSubType.class 1KB
TbRebate.class 1KB
GoodsElement.class 1KB
TbManager.class 1KB
TbSuperType.class 1KB
GridLayoutDemo$1.class 1KB
SearchForm.class 781B
SubTypeAddForm.class 762B
UserLoginForm.class 746B
LoginForm.class 738B
CommandForm.class 722B
VOrderDetail.class 685B
VMember.class 655B
VType.class 643B
ProductCommand.class 589B
SuperTypeAddForm.class 577B
SuperTypeForm.class 562B
OrderManageTilesController.class 529B
.classpath 780B
style.css 2KB
css.css 47B
readme.doc 898KB
cart.gif 1KB
del.gif 1KB
freeze.gif 982B
jia.gif 614B
thaw.gif 567B
enforce.gif 567B
folder.gif 564B
jian.gif 369B
jian_null.gif 369B
list.gif 367B
modify.gif 121B
clock.gif 97B
placardStar.gif 80B
searchStar.gif 72B
sellSortLeftStar.gif 64B
bg.gif 46B
Dao.java 8KB
VMemberId.java 6KB
VGoods.java 5KB
TbOrder.java 3KB
CartCheckoutController.java 3KB
TbMember.java 3KB
TbGoods.java 3KB
CartController.java 3KB
VOrderDetailId.java 3KB
VTypeId.java 2KB
SearchController.java 2KB
LoginController.java 2KB
ModifyMemberValidate.java 2KB
共 302 条
- 1
- 2
- 3
- 4
zhangweimlh
- 粉丝: 37
- 资源: 21
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
- 3
前往页