




版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)
文檔簡介
第Java仿天貓服裝商城系統(tǒng)的實現(xiàn)流程一、項目簡述
功能:網(wǎng)上商城系統(tǒng),前臺+后臺管理,用戶注冊,登錄,上哦展示,分組展示,搜索,收貨地址管理,購物車管理,添加,購買,個人信息修改。訂單查詢等等,后臺商品管理,分類管理,庫存管理,訂單管理,用戶管理,信息、修改等等。
二、項目運行
環(huán)境配置:Jdk1.8+Tomcat8.5+mysql+Eclispe(IntelliJIDEA,Eclispe,MyEclispe,Sts都支持)
項目技術(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)到前臺天貓-產(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)品子信息-分類信息對應(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)品評論信息");
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)到前臺-產(chǎn)品詳情頁");
return"fore/productDetailsPage";
//按產(chǎn)品ID加載產(chǎn)品評論列表-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)品評論列表");
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)品詳情-分類信息對應(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)到前臺天貓-用戶詳情頁
@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ū)級地址");
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";
("創(chuàng)建用戶對象");
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)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025至2030泰國首席技術(shù)官蒸餾行業(yè)產(chǎn)業(yè)運行態(tài)勢及投資規(guī)劃深度研究報告
- 河北省石家莊市井陘礦區(qū)賈莊鎮(zhèn)區(qū)賈莊中學(xué)2025屆化學(xué)九年級第一學(xué)期期末學(xué)業(yè)質(zhì)量監(jiān)測試題含解析
- 車輛設(shè)備研發(fā)、采購、檢測、認(rèn)證一體化服務(wù)合同
- 學(xué)習(xí)計劃制定與執(zhí)行
- 氫能源與儲能技術(shù)的融合發(fā)展研究
- 2025至2030二氧化碳數(shù)據(jù)記錄器行業(yè)發(fā)展研究與產(chǎn)業(yè)戰(zhàn)略規(guī)劃分析評估報告
- 新興工業(yè)設(shè)計領(lǐng)域:AI技術(shù)的行業(yè)可行性分析報告
- 教育中創(chuàng)新能力的培養(yǎng)
- 2025至2030塑料鼓行業(yè)發(fā)展趨勢分析與未來投資戰(zhàn)略咨詢研究報告
- 2025至2030氣體洗滌器行業(yè)項目調(diào)研及市場前景預(yù)測評估報告
- DGJ08-81-2015 現(xiàn)有建筑抗震鑒定與加固規(guī)程
- 2025年中小學(xué)暑假安全教育主題家長會 課件
- 2025年佛山市南海區(qū)圖書館招聘題庫帶答案分析
- 基于學(xué)科核心素養(yǎng)的初中化學(xué)單元整體教學(xué)設(shè)計課題研究的階段小結(jié)基于學(xué)科核心素養(yǎng)的初中化學(xué)單元整體教學(xué)設(shè)計研究
- 初一語文現(xiàn)代文閱讀題及答案
- GMP質(zhì)量管理體系文件 玻璃器皿檢定規(guī)程
- 三年級英語閱讀理解(打印)
- 多彩全動畫像素游戲風(fēng)格PPT模板
- GB/T 4169.19-2006塑料注射模零件第19部分:澆口套
- GB/T 31586.1-2015防護(hù)涂料體系對鋼結(jié)構(gòu)的防腐蝕保護(hù)涂層附著力/內(nèi)聚力(破壞強(qiáng)度)的評定和驗收準(zhǔn)則第1部分:拉開法試驗
- 領(lǐng)導(dǎo)干部的決策力與執(zhí)行力
評論
0/150
提交評論