




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
第Java仿天貓服裝商城系統(tǒng)的實(shí)現(xiàn)流程一、項(xiàng)目簡述
功能:網(wǎng)上商城系統(tǒng),前臺(tái)+后臺(tái)管理,用戶注冊,登錄,上哦展示,分組展示,搜索,收貨地址管理,購物車管理,添加,購買,個(gè)人信息修改。訂單查詢等等,后臺(tái)商品管理,分類管理,庫存管理,訂單管理,用戶管理,信息、修改等等。
二、項(xiàng)目運(yùn)行
環(huán)境配置:Jdk1.8+Tomcat8.5+mysql+Eclispe(IntelliJIDEA,Eclispe,MyEclispe,Sts都支持)
項(xiàng)目技術(shù):JSP+Spring+SpringMVC+MyBatis+html+css+JavaScript+JQuery+Ajax+layui+maven等等。
權(quán)限控制代碼:
*產(chǎn)品詳情頁
@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;
//轉(zhuǎn)到前臺(tái)天貓-產(chǎn)品詳情頁
@RequestMapping(value="product/{pid}",method=RequestMethod.GET)
publicStringgoToPage(HttpSessionsession,MapString,Objectmap,
@PathVariable("pid")Stringpid/*產(chǎn)品ID*/){
("檢查用戶是否登錄");
ObjectuserId=checkUser(session);
if(userId!=null){
("獲取用戶信息");
Useruser=userService.get(Integer.parseInt(userId.toString()));
map.put("user",user);
("獲取產(chǎn)品ID");
Integerproduct_id=Integer.parseInt(pid);
("獲取產(chǎn)品信息");
Productproduct=productService.get(product_id);
if(product==null||product.getProduct_isEnabled()==1){
return"redirect:/404";
("獲取產(chǎn)品子信息-分類信息");
product.setProduct_category(categoryService.get(product.getProduct_category().getCategory_id()));
("獲取產(chǎn)品子信息-預(yù)覽圖片信息");
ListProductImagesingleProductImageList=productImageService.getList(product_id,(byte)0,null);
product.setSingleProductImageList(singleProductImageList);
("獲取產(chǎn)品子信息-詳情圖片信息");
ListProductImagedetailsProductImageList=productImageService.getList(product_id,(byte)1,null);
product.setDetailProductImageList(detailsProductImageList);
("獲取產(chǎn)品子信息-產(chǎn)品屬性值信息");
ListPropertyValuepropertyValueList=propertyValueService.getList(newPropertyValue().setPropertyValue_product(product),null);
("獲取產(chǎn)品子信息-分類信息對(duì)應(yīng)的屬性列表");
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;
("獲取產(chǎn)品子信息-產(chǎn)品評(píng)論信息");
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為{}的產(chǎn)品總數(shù)為{}條",category_id,total);
//生成隨機(jī)數(shù)
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){
("獲取產(chǎn)品列表的相應(yīng)的一張預(yù)覽圖片");
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()));
("轉(zhuǎn)到前臺(tái)-產(chǎn)品詳情頁");
return"fore/productDetailsPage";
//按產(chǎn)品ID加載產(chǎn)品評(píng)論列表-ajax
@Deprecated
@ResponseBody
@RequestMapping(value="review/{pid}",method=RequestMethod.GET,produces="application/json;charset=utf-8")
publicStringloadProductReviewList(@PathVariable("pid")Stringpid/*產(chǎn)品ID*/,
@RequestParamIntegerindex/*頁數(shù)*/,
@RequestParamIntegercount/*行數(shù)*/){
("獲取產(chǎn)品ID");
Integerproduct_id=Integer.parseInt(pid);
("獲取產(chǎn)品評(píng)論列表");
ListReviewreviewList=reviewService.getListByProductId(product_id,newPageUtil(index,count));
JSONObjectjsonObject=newJSONObject();
jsonObject.put("reviewList",JSONArray.parseArray(JSON.toJSONString(reviewList)));
returnjsonObject.toJSONString();
//按產(chǎn)品ID加載產(chǎn)品屬性列表-ajax
@Deprecated
@ResponseBody
@RequestMapping(value="property/{pid}",method=RequestMethod.GET,produces="application/json;charset=utf-8")
publicStringloadProductPropertyList(@PathVariable("pid")Stringpid/*產(chǎn)品ID*/){
("獲取產(chǎn)品ID");
Integerproduct_id=Integer.parseInt(pid);
("獲取產(chǎn)品詳情-屬性值信息");
Productproduct=newProduct();
product.setProduct_id(product_id);
ListPropertyValuepropertyValueList=propertyValueService.getList(newPropertyValue().setPropertyValue_product(product),null);
("獲取產(chǎn)品詳情-分類信息對(duì)應(yīng)的屬性列表");
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為{}的產(chǎn)品總數(shù)為{}條",cid,total);
//生成隨機(jī)數(shù)
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){
("獲取產(chǎn)品列表的相應(yīng)的一張預(yù)覽圖片");
for(ProductloveProduct:loveProductList){
loveProduct.setSingleProductImageList(productImageService.getList(loveProduct.getProduct_id(),(byte)0,newPageUtil(0,1)));
JSONObjectjsonObject=newJSONObject();
("獲取數(shù)據(jù)成功!");
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;
//轉(zhuǎn)到前臺(tái)天貓-用戶詳情頁
@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);
("獲取用戶所在地區(qū)級(jí)地址");
StringdistrictAddressId=user.getUser_address().getAddress_areaId();
AddressdistrictAddress=addressService.get(districtAddressId);
("獲取市級(jí)地址信息");
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";
//前臺(tái)天貓-用戶更換頭像
@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();
//前臺(tái)天貓-用戶詳情更新
@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/*真實(shí)姓名*/,
@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";
("創(chuàng)建用戶對(duì)象");
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. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 兒童心理健康的提升與干預(yù)
- 【教學(xué)案例】跨境電商專題頁營銷策劃
- 保護(hù)輸電線路安全法律問題分析
- 陜西省渭南市蒲城縣2024-2025學(xué)年七年級(jí)下學(xué)期末質(zhì)量檢測語文試卷(含答案)
- 山東省德州市2025屆高三下學(xué)期三模生物試卷(有答案)
- 巾幗活動(dòng)展覽活動(dòng)方案
- 工會(huì)冬季出游活動(dòng)方案
- 工廠小年活動(dòng)策劃方案
- 展館內(nèi)文化沙龍活動(dòng)方案
- 小班特色涂鴉活動(dòng)方案
- 華南理工大學(xué)《機(jī)器學(xué)習(xí)》2022-2023學(xué)年期末試卷
- 2024年人教版八年級(jí)語文下冊期末考試卷(附答案)
- 影視劇組場地租賃合同
- 個(gè)體工商戶食品安全管理制度
- TSXCAS 015-2023 全固廢低碳膠凝材料應(yīng)用技術(shù)標(biāo)準(zhǔn)
- 北京交通大學(xué)《交通系統(tǒng)建模與測試技術(shù)》2022-2023學(xué)年第一學(xué)期期末試卷
- 耳穴考核試題及答案
- 2024年浙江省中考社會(huì)試卷真題(含標(biāo)準(zhǔn)答案及評(píng)分標(biāo)準(zhǔn))
- 廣東省廣州市白云廣雅2024-2025學(xué)年七年級(jí)上學(xué)期開學(xué)測英語試題+(無答案)
- 《無人機(jī)法律法規(guī)知識(shí)》課件-第1章 民用航空法概述
- 農(nóng)作物植保員技能競賽備考試題庫400題(含答案)
評(píng)論
0/150
提交評(píng)論