Java仿天猫服装商城系统的实现流程_第1页
Java仿天猫服装商城系统的实现流程_第2页
Java仿天猫服装商城系统的实现流程_第3页
Java仿天猫服装商城系统的实现流程_第4页
Java仿天猫服装商城系统的实现流程_第5页
已阅读5页,还剩9页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

第Java仿天猫服装商城系统的实现流程一、项目简述

功能:网上商城系统,前台+后台管理,用户注册,登录,上哦展示,分组展示,搜索,收货地址管理,购物车管理,添加,购买,个人信息修改。订单查询等等,后台商品管理,分类管理,库存管理,订单管理,用户管理,信息、修改等等。

二、项目运行

环境配置:Jdk1.8+Tomcat8.5+mysql+Eclispe(IntelliJIDEA,Eclispe,MyEclispe,Sts都支持)

项目技术:JSP+Spring+SpringMVC+MyBatis+html+css+JavaScript+JQuery+Ajax+layui+maven等等。

权限控制代码:

*产品详情页

@Controller

publicclassForeProductDetailsControllerextendsBaseController{

@Resource(name="productService")

privateProductServiceproductService;

@Resource(name="userService")

privateUserServiceuserService;

@Resource(name="productImageService")

privateProductImageServiceproductImageService;

@Resource(name="categoryService")

privateCategoryServicecategoryService;

@Resource(name="propertyValueService")

privatePropertyValueServicepropertyValueService;

@Resource(name="propertyService")

privatePropertyServicepropertyService;

@Resource(name="reviewService")

privateReviewServicereviewService;

@Resource(name="productOrderItemService")

privateProductOrderItemServiceproductOrderItemService;

//转到前台天猫-产品详情页

@RequestMapping(value="product/{pid}",method=RequestMethod.GET)

publicStringgoToPage(HttpSessionsession,MapString,Objectmap,

@PathVariable("pid")Stringpid/*产品ID*/){

("检查用户是否登录");

ObjectuserId=checkUser(session);

if(userId!=null){

("获取用户信息");

Useruser=userService.get(Integer.parseInt(userId.toString()));

map.put("user",user);

("获取产品ID");

Integerproduct_id=Integer.parseInt(pid);

("获取产品信息");

Productproduct=productService.get(product_id);

if(product==null||product.getProduct_isEnabled()==1){

return"redirect:/404";

("获取产品子信息-分类信息");

product.setProduct_category(categoryService.get(product.getProduct_category().getCategory_id()));

("获取产品子信息-预览图片信息");

ListProductImagesingleProductImageList=productImageService.getList(product_id,(byte)0,null);

product.setSingleProductImageList(singleProductImageList);

("获取产品子信息-详情图片信息");

ListProductImagedetailsProductImageList=productImageService.getList(product_id,(byte)1,null);

product.setDetailProductImageList(detailsProductImageList);

("获取产品子信息-产品属性值信息");

ListPropertyValuepropertyValueList=propertyValueService.getList(newPropertyValue().setPropertyValue_product(product),null);

("获取产品子信息-分类信息对应的属性列表");

ListPropertypropertyList=propertyService.getList(newProperty().setProperty_category(product.getProduct_category()),null);

("属性列表和属性值列表合并");

for(Propertyproperty:propertyList){

for(PropertyValuepropertyValue:propertyValueList){

if(property.getProperty_id().equals(propertyValue.getPropertyValue_property().getProperty_id())){

ListPropertyValueproperty_value_item=newArrayList(1);

property_value_item.add(propertyValue);

property.setPropertyValueList(property_value_item);

break;

("获取产品子信息-产品评论信息");

product.setReviewList(reviewService.getListByProductId(product_id,null));

if(product.getReviewList()!=null){

for(Reviewreview:product.getReviewList()){

review.setReview_user(userService.get(review.getReview_user().getUser_id()));

("获取猜你喜欢列表");

Integercategory_id=product.getProduct_category().getCategory_id();

Integertotal=productService.getTotal(newProduct().setProduct_category(newCategory().setCategory_id(category_id)),newByte[]{0,2});

("分类ID为{}的产品总数为{}条",category_id,total);

//生成随机数

inti=newRandom().nextInt(total);

if(i+2=total){

i=total-3;

if(i0){

i=0;

ListProductloveProductList=productService.getList(newProduct().setProduct_category(

newCategory().setCategory_id(category_id)),

newByte[]{0,2},

null,

newPageUtil().setCount(3).setPageStart(i)

if(loveProductList!=null){

("获取产品列表的相应的一张预览图片");

for(ProductloveProduct:loveProductList){

loveProduct.setSingleProductImageList(productImageService.getList(loveProduct.getProduct_id(),(byte)0,newPageUtil(0,1)));

("获取分类列表");

ListCategorycategoryList=categoryService.getList(null,newPageUtil(0,3));

map.put("loveProductList",loveProductList);

map.put("categoryList",categoryList);

map.put("propertyList",propertyList);

map.put("product",product);

map.put("guessNumber",i);

map.put("pageUtil",newPageUtil(0,10).setTotal(product.getProduct_review_count()));

("转到前台-产品详情页");

return"fore/productDetailsPage";

//按产品ID加载产品评论列表-ajax

@Deprecated

@ResponseBody

@RequestMapping(value="review/{pid}",method=RequestMethod.GET,produces="application/json;charset=utf-8")

publicStringloadProductReviewList(@PathVariable("pid")Stringpid/*产品ID*/,

@RequestParamIntegerindex/*页数*/,

@RequestParamIntegercount/*行数*/){

("获取产品ID");

Integerproduct_id=Integer.parseInt(pid);

("获取产品评论列表");

ListReviewreviewList=reviewService.getListByProductId(product_id,newPageUtil(index,count));

JSONObjectjsonObject=newJSONObject();

jsonObject.put("reviewList",JSONArray.parseArray(JSON.toJSONString(reviewList)));

returnjsonObject.toJSONString();

//按产品ID加载产品属性列表-ajax

@Deprecated

@ResponseBody

@RequestMapping(value="property/{pid}",method=RequestMethod.GET,produces="application/json;charset=utf-8")

publicStringloadProductPropertyList(@PathVariable("pid")Stringpid/*产品ID*/){

("获取产品ID");

Integerproduct_id=Integer.parseInt(pid);

("获取产品详情-属性值信息");

Productproduct=newProduct();

product.setProduct_id(product_id);

ListPropertyValuepropertyValueList=propertyValueService.getList(newPropertyValue().setPropertyValue_product(product),null);

("获取产品详情-分类信息对应的属性列表");

ListPropertypropertyList=propertyService.getList(newProperty().setProperty_category(product.getProduct_category()),null);

("属性列表和属性值列表合并");

for(Propertyproperty:propertyList){

for(PropertyValuepropertyValue:propertyValueList){

if(property.getProperty_id().equals(propertyValue.getPropertyValue_property().getProperty_id())){

ListPropertyValueproperty_value_item=newArrayList(1);

property_value_item.add(propertyValue);

property.setPropertyValueList(property_value_item);

break;

JSONObjectjsonObject=newJSONObject();

jsonObject.put("propertyList",JSONArray.parseArray(JSON.toJSONString(propertyList)));

returnjsonObject.toJSONString();

//加载猜你喜欢列表-ajax

@ResponseBody

@RequestMapping(value="guess/{cid}",method=RequestMethod.GET,produces="application/json;charset=utf-8")

publicStringguessYouLike(@PathVariable("cid")Integercid,@RequestParamIntegerguessNumber){

("获取猜你喜欢列表");

Integertotal=productService.getTotal(newProduct().setProduct_category(newCategory().setCategory_id(cid)),newByte[]{0,2});

("分类ID为{}的产品总数为{}条",cid,total);

//生成随机数

inti=newRandom().nextInt(total);

if(i+2=total){

i=total-3;

if(i0){

i=0;

while(i==guessNumber){

i=newRandom().nextInt(total);

if(i+2=total){

i=total-3;

if(i0){

i=0;

break;

("guessNumber值为{},新guessNumber值为{}",guessNumber,i);

ListProductloveProductList=productService.getList(newProduct().setProduct_category(

newCategory().setCategory_id(cid)),

newByte[]{0,2},

null,

newPageUtil().setCount(3).setPageStart(i)

if(loveProductList!=null){

("获取产品列表的相应的一张预览图片");

for(ProductloveProduct:loveProductList){

loveProduct.setSingleProductImageList(productImageService.getList(loveProduct.getProduct_id(),(byte)0,newPageUtil(0,1)));

JSONObjectjsonObject=newJSONObject();

("获取数据成功!");

jsonObject.put("success",true);

jsonObject.put("loveProductList",JSONArray.parseArray(JSON.toJSONString(loveProductList)));

jsonObject.put("guessNumber",i);

returnjsonObject.toJSONString();

}

用户信息管理控制层:

*用户信息管理

@Controller

publicclassForeUserControllerextendsBaseController{

@Resource(name="addressService")

privateAddressServiceaddressService;

@Resource(name="userService")

privateUserServiceuserService;

//转到前台天猫-用户详情页

@RequestMapping(value="userDetails",method=RequestMethod.GET)

publicStringgoToUserDetail(HttpSessionsession,MapString,Objectmap){

("检查用户是否登录");

ObjectuserId=checkUser(session);

if(userId!=null){

("获取用户信息");

Useruser=userService.get(Integer.parseInt(userId.toString()));

map.put("user",user);

("获取用户所在地区级地址");

StringdistrictAddressId=user.getUser_address().getAddress_areaId();

AddressdistrictAddress=addressService.get(districtAddressId);

("获取市级地址信息");

AddresscityAddress=addressService.get(districtAddress.getAddress_regionId().getAddress_areaId());

("获取其他地址信息");

ListAddressaddressList=addressService.getRoot();

ListAddresscityList=addressService.getList(

null,cityAddress.getAddress_regionId().getAddress_areaId()

ListAddressdistrictList=addressService.getList(null,cityAddress.getAddress_areaId());

map.put("addressList",addressList);

map.put("cityList",cityList);

map.put("districtList",districtList);

map.put("addressId",cityAddress.getAddress_regionId().getAddress_areaId());

map.put("cityAddressId",cityAddress.getAddress_areaId());

map.put("districtAddressId",districtAddressId);

return"fore/userDetails";

}else{

return"redirect:/login";

//前台天猫-用户更换头像

@ResponseBody

@RequestMapping(value="user/uploadUserHeadImage",method=RequestMethod.POST,produces="application/json;charset=utf-8")

publicStringuploadUserHeadImage(@RequestParamMultipartFilefile,HttpSessionsession

StringoriginalFileName=file.getOriginalFilename();

("获取图片原始文件名:{}",originalFileName);

Stringextension=originalFileName.substring(originalFileName.lastIndexOf('.'));

StringfileName=UUID.randomUUID()+extension;

StringfilePath=session.getServletContext().getRealPath("/")+"res/images/item/userProfilePicture/"+fileName;

("文件上传路径:{}",filePath);

JSONObjectjsonObject=newJSONObject();

try{

("文件上传中...");

file.transferTo(newFile(filePath));

("文件上传成功!");

jsonObject.put("success",true);

jsonObject.put("fileName",fileName);

}catch(IOExceptione){

logger.warn("文件上传失败!");

e.printStackTrace();

jsonObject.put("success",false);

returnjsonObject.toJSONString();

//前台天猫-用户详情更新

@RequestMapping(value="user/update",method=RequestMethod.POST,produces="application/json;charset=utf-8")

publicStringuserUpdate(HttpSessionsession,MapString,Objectmap,

@RequestParam(value="user_nickname")Stringuser_nickname/*用户昵称*/,

@RequestParam(value="user_realname")Stringuser_realname/*真实姓名*/,

@RequestParam(value="user_gender")Stringuser_gender/*用户性别*/,

@RequestParam(value="user_birthday")Stringuser_birthday/*用户生日*/,

@RequestParam(value="user_address")Stringuser_address/*用户所在地*/,

@RequestParam(value="user_profile_picture_src",required=false)

Stringuser_profile_picture_src/*用户头像*/,

@RequestParam(value="user_password")Stringuser_password/*用户密码*/

)throwsParseException,UnsupportedEncodingException{

("检查用户是否登录");

ObjectuserId=checkUser(session);

if(userId!=null){

("获取用户信息");

Useruser=userService.get(Integer.parseInt(userId.toString()));

map.put("user",user);

}else{

return"redirect:/login";

("创建用户对象");

if(user_profile_picture_src!=null"".equals(user_profile_picture_src)){

user_profile_picture_src=null;

UseruserUpdate=newUser()

.setUser_id(Integer.parseInt(userId.toString()))

.setUser_nickname(user_nickname)

.setUser_realname(user_realname)

.setUser_gender(Byte.valueOf(user_gender))

.setUser_b

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论