├── README.md ├── 高仿小米商城前端 ├── .browserslistrc ├── .editorconfig ├── .env.prev ├── .eslintrc.js ├── .gitignore ├── README.md ├── babel.config.js ├── env.js ├── package-lock.json ├── package.json ├── public │ ├── imgs │ │ ├── banner │ │ │ ├── 1.webp │ │ │ ├── 2.webp │ │ │ └── 3.webp │ │ ├── detail │ │ │ ├── item-price.jpeg │ │ │ ├── phone-1.jpg │ │ │ ├── phone-2.jpg │ │ │ ├── phone-3.jpg │ │ │ └── phone-4.jpg │ │ ├── icon-no-data.png │ │ ├── icon.svg │ │ ├── loading-svg │ │ │ ├── loading-balls.svg │ │ │ ├── loading-bars.svg │ │ │ ├── loading-bubbles.svg │ │ │ ├── loading-cubes.svg │ │ │ ├── loading-cylon-red.svg │ │ │ ├── loading-cylon.svg │ │ │ ├── loading-spin.svg │ │ │ ├── loading-spinning-bubbles.svg │ │ │ └── loading-spokes.svg │ │ ├── login-logo.png │ │ ├── logo-foot.png │ │ └── pay │ │ │ ├── icon-ali.png │ │ │ ├── icon-qrcode.png │ │ │ ├── icon-scan.png │ │ │ └── icon-wechat.png │ └── index.html ├── src │ ├── App.vue │ ├── assets │ │ ├── imgs │ │ │ └── placeholder.png │ │ ├── logo.png │ │ └── scss │ │ │ ├── base.scss │ │ │ ├── button.scss │ │ │ ├── config.scss │ │ │ ├── mixin.scss │ │ │ ├── modal.scss │ │ │ └── reset.scss │ ├── components │ │ ├── Flash.vue │ │ ├── Loading.vue │ │ ├── Modal.vue │ │ ├── MyList.vue │ │ ├── MyMenu.vue │ │ ├── NavFooter.vue │ │ ├── NavHeader.vue │ │ ├── NoData.vue │ │ ├── OrderHeader.vue │ │ ├── ProductParam.vue │ │ ├── ScanPayCode.vue │ │ └── ServiceBar.vue │ ├── main.js │ ├── mock │ │ └── api.js │ ├── router │ │ └── index.js │ ├── storage │ │ └── index.js │ ├── store │ │ ├── actions.js │ │ ├── index.js │ │ └── mutations.js │ ├── util │ │ └── index.js │ └── views │ │ ├── Register.vue │ │ ├── alipay.vue │ │ ├── cart.vue │ │ ├── detail.vue │ │ ├── home.vue │ │ ├── index.vue │ │ ├── login.vue │ │ ├── order.vue │ │ ├── orderConfirm.vue │ │ ├── orderList.vue │ │ ├── orderPay.vue │ │ └── product.vue └── vue.config.js └── 高仿小米商城后台 ├── .gitignore ├── .mvn └── wrapper │ ├── MavenWrapperDownloader.java │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── README.md ├── mvnw ├── mvnw.cmd ├── pom.xml ├── src ├── main │ ├── java │ │ └── com │ │ │ └── zty │ │ │ └── xiaomi │ │ │ └── server │ │ │ ├── Config │ │ │ ├── AlipayConfig.java │ │ │ ├── DruidConfig.java │ │ │ └── RedisConfig.java │ │ │ ├── Controller │ │ │ ├── AddrController.java │ │ │ ├── AliPayController.java │ │ │ ├── CartController.java │ │ │ ├── GoodController.java │ │ │ ├── IndexController.java │ │ │ ├── LogRegController.java │ │ │ ├── OrderController.java │ │ │ └── ProductController.java │ │ │ ├── Entity │ │ │ ├── Address │ │ │ │ ├── AddrResult.java │ │ │ │ ├── AddrSuccResult.java │ │ │ │ ├── Addre.java │ │ │ │ └── AddreList.java │ │ │ ├── Cart │ │ │ │ ├── CartGood.java │ │ │ │ ├── CartGoodInsert.java │ │ │ │ ├── CartResult.java │ │ │ │ ├── cartProduct.java │ │ │ │ ├── cartProductVoList.java │ │ │ │ └── pushCart.java │ │ │ ├── CartGetGoodItem.java │ │ │ ├── CartGetGoodList.java │ │ │ ├── Good.java │ │ │ ├── GoodAll.java │ │ │ ├── GoodsAll.java │ │ │ ├── LoginData.java │ │ │ ├── Order │ │ │ │ ├── Alipay.java │ │ │ │ ├── OrdCreaParm.java │ │ │ │ ├── OrdFina.java │ │ │ │ ├── OrdFinaResult.java │ │ │ │ ├── OrdPayParm.java │ │ │ │ ├── OrderList.java │ │ │ │ ├── OrderResult.java │ │ │ │ ├── UserOrdItemList.java │ │ │ │ ├── UserOrdList.java │ │ │ │ ├── UserOrdListResone.java │ │ │ │ ├── UserOrdListResult.java │ │ │ │ └── orderItemVoList.java │ │ │ ├── Product │ │ │ │ ├── ProductInfo.java │ │ │ │ └── ProductResult.java │ │ │ ├── ProductFoot │ │ │ │ ├── ProductFootInfo.java │ │ │ │ └── ProductFootResult.java │ │ │ ├── ProductHead │ │ │ │ ├── ProductHeadInfo.java │ │ │ │ └── ProductHeadResult.java │ │ │ ├── Suggest │ │ │ │ ├── SuggestBig.java │ │ │ │ ├── SuggestFoot.java │ │ │ │ └── SuggestFootResult.java │ │ │ ├── User.java │ │ │ └── index │ │ │ │ ├── Categor.java │ │ │ │ ├── CategorData.java │ │ │ │ ├── CategoryGood.java │ │ │ │ ├── CategoryResult.java │ │ │ │ └── GoodCategory.java │ │ │ ├── Mapper │ │ │ ├── Address.java │ │ │ ├── Category.java │ │ │ ├── GoodCart.java │ │ │ ├── Goods.java │ │ │ ├── Order.java │ │ │ ├── Product.java │ │ │ ├── ProductFoot.java │ │ │ ├── ProductHead.java │ │ │ ├── RegLogUser.java │ │ │ └── Suggest.java │ │ │ ├── ServerApplication.java │ │ │ ├── Service │ │ │ ├── Address │ │ │ │ ├── AddService.java │ │ │ │ └── AddServiceImp.java │ │ │ ├── AlipayService.java │ │ │ ├── Cart │ │ │ │ ├── CartService.java │ │ │ │ └── CartServiceImp.java │ │ │ ├── Category │ │ │ │ ├── CategoryIndex.java │ │ │ │ └── CategoryIndexImp.java │ │ │ ├── Good │ │ │ │ ├── GoodService.java │ │ │ │ └── GoodServiceImp.java │ │ │ ├── Order │ │ │ │ ├── OrderService.java │ │ │ │ └── OrderServiceImp.java │ │ │ ├── ProdFoot │ │ │ │ ├── ProdFoot.java │ │ │ │ └── ProductFootImp.java │ │ │ ├── ProdHead │ │ │ │ ├── ProdHead.java │ │ │ │ └── ProductHeadImp.java │ │ │ ├── Product │ │ │ │ ├── ProdService.java │ │ │ │ └── ProdServiceImp.java │ │ │ ├── RegLogin │ │ │ │ ├── RegLogService.java │ │ │ │ └── RegLogServiceImp.java │ │ │ └── Suggest │ │ │ │ ├── SugFootService.java │ │ │ │ └── SugFootServiceImp.java │ │ │ ├── Vo │ │ │ ├── LogOutResult.java │ │ │ ├── LoginResult.java │ │ │ ├── RegResult.java │ │ │ └── UserInfoChangeResult.java │ │ │ ├── redis │ │ │ ├── JedisConfig.java │ │ │ └── RedisTemplateConfig.java │ │ │ └── utils │ │ │ ├── DateUtil.java │ │ │ ├── OrderNumUtil.java │ │ │ ├── RSAUtils.java │ │ │ └── TokenUtil.java │ └── resources │ │ ├── application.yml │ │ └── log4j.properties └── test │ └── java │ └── com │ └── zty │ └── xiaomi │ └── server │ └── ServerApplicationTests.java └── xiaomi.sql /README.md: -------------------------------------------------------------------------------- 1 | # tongyimall 2 | 高仿小米商城用户端(分为商城前端(tongyimall-vue)和商城后端(tongyimall-api)两部分),是Vue + SpringBoot的前后端分离项目,用户端包括首页门户、商品分类、首页轮播、商品展示、商品推荐、购物车、地址管理、下订单、扫码支付等功能模块。 3 | 4 | ## 主要技术栈 5 | 前端:vue2 + vue-router + vuex + axios + sass (vue-cli4搭建的)
6 | 后端:SpringBoot + MyBatis注解版 + MySQL + redis6 7 | 8 | 9 | ### 一、功能与版本(在线演示地址:www.tongyi.site) 10 |     当前版本v1.4.0
11 |     目前项目开发中,存在诸多不足,以下是目前已开发的功能。
12 | 13 | >**V 1.0.0**
14 | >1,首页轮播图左侧的商品分类弹出框
15 | >2,首页轮播图
16 | >3,首页顶部商品下拉栏
17 | >4,首页品牌列表分类
18 | >5,商品详情页
19 | >6,购物车
20 | 21 | >**V 1.1.0**
22 | >1,首页底部增加了推荐商品功能
23 | >3,完善了网页底公共栏
24 | >4,增加了下单前地址管理,实现了选择省市的二级联动功能
25 | >5,订单下单
26 | 27 | >**V 1.2.0**
28 | >1,首页左侧弹出框后台管理 29 | >2,首页商品大类推荐后台管理 30 | >3,首页底部推荐后台管理 31 |
32 | 33 | >**V 1.3.0**
34 | >1,引入布隆过滤器 35 | >2,完善订单功能 36 | >3,首页商品大类引入redis缓存,小米秒杀部分页面做成 37 |
38 | 39 | >**V 1.4.0**
40 | >1,所有商品信息都引入redis缓存 41 |
42 | 43 | >**V 1.5.0**
44 | >1,完成模拟支付功能 45 | >2,完成订单超时30分钟取消功能 46 |
47 | 48 | >**V 1.6.0**
49 | >1,引入支付宝扫码支付,需要用沙箱钱包,详细见:https://opendocs.alipay.com/open/194/106078 50 | >2,引入事务乐观锁避免超卖问题(库存不足时会提示下单失败) 51 | >3,使用监听线程监听,超时30分钟未付款则取消订单,删除数据库中相应表记录,并恢复预减的库存 52 | ![](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/支付和事务.jpg) 53 | ![](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/未命名文件.jpg) 54 |
55 | 56 | ### 二、运行环境 57 |     为保证项目能够运行,请至少安装好以下运行环境: 58 | + 1、Maven(项目对象模型,可以通过一小段描述信息来管理项目的构建,报告和文档的项目管理工具软件,教程:[Maven的安装与配置](https://blog.csdn.net/a805814077/article/details/100545928)) 59 | + 2、MySQL 8.0+版本 60 | + 3、Node环境 61 | + 4、JDK1.8 62 | + 5、Redis 63 | 64 | ### 三、快速启动 65 | ##### 1、前端部分 66 | ``` 67 | git clone https://github.com/ZTY18873242003/tongyimall //下载到本地 68 | 69 | cd /高仿小米商城前端 //进入到前端目录 70 | 71 | npm install // 安装项目依赖(需要电脑上装有Node环境),等待安装完成之后,安装失败可用 cnpm 或 yarn 72 | 73 | 74 | npm run serve // 开启服务器,浏览器访问 http://localhost:8080 75 | 76 | 77 | npm run build // 执行构建命令,生成的dist文件夹放在服务器下即可访问 78 | ``` 79 | 80 | ##### 2、后端部分 81 | ``` 82 | 使用root用户权限在本地新建名为xiaomi的mysql数据库,可在 /高仿小米商城后台/src/main/resources/application.yml文件中修改密码 83 | 84 | cd /高仿小米商城后台 //进入到后端目录 85 | 86 | 使用数据库管理工具(如Navicat)运行xiaomi.sql脚本文件(用户端也是这个数据库),或复制其中内容在命令行执行 87 | 88 | 打开IDEA或者Eclipse 运行 高仿小米商城后台/src/main/java/com/zty/xiaomiadmin/server/ServerApplication.java文件,默认是8080端口 89 | ``` 90 | 91 | ### 四、商城部分界面(可参考[小米官网](https://www.mi.com),很多界面类似) 92 | 1、商品分类及轮播图 93 | ![在这里插入图片描述](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/QQ截图20210301091854.jpg) 94 | 2、商品细节图 95 | ![在这里插入图片描述](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/QQ截图20210301091911.jpg) 96 | 3、登录注册模块![在这里插入图片描述](https://img-blog.csdnimg.cn/20210205215801308.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1pob25ndG9uZ3lp,size_16,color_FFFFFF,t_70) 97 | 4、购物车模块![在这里插入图片描述](https://img-blog.csdnimg.cn/20210205215804719.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1pob25ndG9uZ3lp,size_16,color_FFFFFF,t_70) 98 | 5、地址管理 99 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20210214210955903.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L1pob25ndG9uZ3lp,size_16,color_FFFFFF,t_70#pic_center) 100 | 6、商品推荐 101 | ![在这里插入图片描述](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/QQ截图20210301092202.jpg) 102 | 7、订单模块 103 | ![](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/QQ截图20210408204946.jpg) 104 | ![](https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/QQ截图20210408205017.jpg) 105 | ### 五、完整项目地址 106 |     项目目前分为商城端(tongyimall)和管理端(tongyimall-admin)两个部分,我分开放到两个仓库中了。
107 |     商城端:[tongyimall](https://github.com/ZTY18873242003/tongyimall)
108 |     管理端:[tongyimall-admin](https://github.com/ZTY18873242003/tongyimall-admin) -------------------------------------------------------------------------------- /高仿小米商城前端/.browserslistrc: -------------------------------------------------------------------------------- 1 | > 1% 2 | last 2 versions 3 | -------------------------------------------------------------------------------- /高仿小米商城前端/.editorconfig: -------------------------------------------------------------------------------- 1 | [*.{js,jsx,ts,tsx,vue}] 2 | indent_style = space 3 | indent_size = 2 4 | trim_trailing_whitespace = true 5 | insert_final_newline = true 6 | -------------------------------------------------------------------------------- /高仿小米商城前端/.env.prev: -------------------------------------------------------------------------------- 1 | NODE_ENV='prev' -------------------------------------------------------------------------------- /高仿小米商城前端/.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | env: { 4 | node: true 5 | }, 6 | extends: [ 7 | 'plugin:vue/essential', 8 | // '@vue/standard' 9 | ], 10 | parserOptions: { 11 | parser: 'babel-eslint' 12 | }, 13 | rules: { 14 | 'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off', 15 | 'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off' 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /高仿小米商城前端/.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | /dist 4 | 5 | # local env files 6 | .env.local 7 | .env.*.local 8 | 9 | # Log files 10 | npm-debug.log* 11 | yarn-debug.log* 12 | yarn-error.log* 13 | 14 | # Editor directories and files 15 | .idea 16 | .vscode 17 | *.suo 18 | *.ntvs* 19 | *.njsproj 20 | *.sln 21 | *.sw? 22 | -------------------------------------------------------------------------------- /高仿小米商城前端/README.md: -------------------------------------------------------------------------------- 1 | # tongyimall-vue 2 | 高仿小米商城用户端前端 3 |


4 | ## 技术栈 5 | vue2 + vue-router + vuex + axios + sass + ElementUI + vue脚手架4 6 |


7 | ## 启动 8 | > + 推荐node版本为10.16.0左右,高版本可能会出现npm install失败的问题,如第一次安装失败可以多试几次。 9 | > + 将npm设置为淘宝镜像以提高下载速度,否则可能出现卡顿问题 10 | 11 | > + 进入前端目录在命令提示符下输入 npm install 命令来安装依赖 12 | > + npm run serve 13 | > + npm run build (打包) 14 |


15 | ## 注意 16 | - vue-cli4中axios使用请求的注意点(与vue-cli2有出入): 17 | ``` 18 | 【注】get请求的传参需要写在params中 19 | axios.get('url',{ 20 | params: { 21 | 参数名:值 22 | } 23 | }).then(function (response) {}).catch(function (error) {}) 24 | 25 | // post请求的传参直接写在第二个参数对象中(无需再写在params里) 26 | axios.get( 'url',{ 参数名:值 } ).then(function (response) {}).catch(function (error) {}) 27 | ``` 28 |

29 | 30 | ### 项目目录 31 | * public: 一般放大图片, 32 | * src/assets: 放小图片,可以转成base64,不用请求图片资源 33 | * src/assets/scss/reset.scss :重置浏览器的样式,防止默认浏览器样式干扰 34 | * src/assets/scss/mixin.scss :一般放置css函数,即抽取出来复用高的css属性,如span设置图标、flex布局都可以抽离出来,使用函数替代 35 | * src/assets/scss/base.scss :抽取的一些公共样式,即多处相同类名设置相同的css属性,需要抽离出来,提高代码复用 36 | 37 | * src/components: 一般放页面组件,命名方式用大头驼峰命名:如 NavHeader.vue 38 | * src/views: 放页面(需要单独配置路由的页面),命名方式用小写:如 index.vue、 home.vue 39 | 40 | * src/router/index.js: 路由的配置 41 | * src/store/index.js: vuex状态管理 42 | * src/storage: 这里放置缓存sessionStorage、cookie、localStorage等存取以及删除等公共方法,便于操作缓存(虽然已经缓存提供了一些API,但自己封装的能根据项目而定) 43 |
44 | -------------------------------------------------------------------------------- /高仿小米商城前端/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | '@vue/cli-plugin-babel/preset' 4 | ] 5 | } 6 | -------------------------------------------------------------------------------- /高仿小米商城前端/env.js: -------------------------------------------------------------------------------- 1 | export default { 2 | baseURL 3 | } 4 | -------------------------------------------------------------------------------- /高仿小米商城前端/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tongyimall-vue", 3 | "version": "1.0.0", 4 | "private": true, 5 | "scripts": { 6 | "serve": "vue-cli-service serve", 7 | "build": "vue-cli-service build", 8 | "lint": "vue-cli-service lint" 9 | }, 10 | "dependencies": { 11 | "@babel/plugin-syntax-dynamic-import": "^7.8.3", 12 | "axios": "^0.19.2", 13 | "core-js": "^3.6.4", 14 | "element-ui": "^2.15.0", 15 | "font-awesome": "^4.6.3", 16 | "mockjs": "^1.1.0", 17 | "qrcode": "^1.4.4", 18 | "vue": "^2.6.11", 19 | "vue-infinite-scroll": "^2.0.2", 20 | "vue-lazyload": "^1.3.3", 21 | "vue-router": "^3.1.5", 22 | "vuex": "^3.1.2" 23 | }, 24 | "devDependencies": { 25 | "@vue/cli-plugin-babel": "^4.2.0", 26 | "@vue/cli-plugin-eslint": "^4.2.0", 27 | "@vue/cli-plugin-router": "^4.2.0", 28 | "@vue/cli-plugin-vuex": "^4.2.0", 29 | "@vue/cli-service": "^4.2.0", 30 | "@vue/eslint-config-standard": "^5.1.0", 31 | "babel-eslint": "^10.0.3", 32 | "element-ui": "^2.13.0", 33 | "eslint": "^6.7.2", 34 | "eslint-plugin-import": "^2.20.1", 35 | "eslint-plugin-node": "^11.0.0", 36 | "eslint-plugin-promise": "^4.2.1", 37 | "eslint-plugin-standard": "^4.0.0", 38 | "eslint-plugin-vue": "^6.1.2", 39 | "lint-staged": "^9.5.0", 40 | "mockjs": "^1.1.0", 41 | "node-sass": "^4.12.0", 42 | "sass-loader": "^8.0.2", 43 | "vue-awesome-swiper": "^3.1.3", 44 | "vue-axios": "^2.1.5", 45 | "vue-cookie": "^1.1.4", 46 | "vue-lazyload": "^1.3.3", 47 | "vue-template-compiler": "^2.6.11" 48 | }, 49 | "gitHooks": { 50 | "pre-commit": "lint-staged" 51 | }, 52 | "lint-staged": { 53 | "*.{js,jsx,vue}": [ 54 | "vue-cli-service lint", 55 | "git add" 56 | ] 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/banner/1.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/banner/1.webp -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/banner/2.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/banner/2.webp -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/banner/3.webp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/banner/3.webp -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/detail/item-price.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/detail/item-price.jpeg -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/detail/phone-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/detail/phone-1.jpg -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/detail/phone-2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/detail/phone-2.jpg -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/detail/phone-3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/detail/phone-3.jpg -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/detail/phone-4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/detail/phone-4.jpg -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/icon-no-data.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/icon-no-data.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/icon.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-balls.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-bars.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-bubbles.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | 6 | 7 | 9 | 10 | 11 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-cubes.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-cylon-red.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-cylon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-spin.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-spinning-bubbles.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/loading-svg/loading-spokes.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/login-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/login-logo.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/logo-foot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/logo-foot.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/pay/icon-ali.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/pay/icon-ali.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/pay/icon-qrcode.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/pay/icon-qrcode.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/pay/icon-scan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/pay/icon-scan.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/imgs/pay/icon-wechat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/public/imgs/pay/icon-wechat.png -------------------------------------------------------------------------------- /高仿小米商城前端/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 高仿小米商城 9 | 10 | 11 | 14 |
15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/App.vue: -------------------------------------------------------------------------------- 1 | 6 | 7 | 66 | 67 | 72 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/imgs/placeholder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/src/assets/imgs/placeholder.png -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/src/assets/logo.png -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/base.scss: -------------------------------------------------------------------------------- 1 | // base.scss : 放置公共样式 2 | @import './mixin.scss'; 3 | .container{ 4 | position: relative; 5 | width:1226px; 6 | margin-right:auto; 7 | margin-left:auto; 8 | } 9 | a{ 10 | img{ 11 | width:100%; 12 | height: 100%; 13 | } 14 | } 15 | input{ 16 | outline: none; 17 | box-sizing: border-box; 18 | font-size: 14px; 19 | } 20 | .fl{ 21 | float: left; 22 | } 23 | .fr{ 24 | float: right; 25 | } 26 | .clearfix:before,.clearfix:after{ 27 | content:' '; 28 | display:table; 29 | } 30 | .clearfix:after{ 31 | clear: both; 32 | } 33 | // 公共头部导航的logo 34 | .header-logo{ 35 | display:inline-block; 36 | width:55px; 37 | height:55px; 38 | background-color:#FF6600; 39 | a{ 40 | display:inline-block; 41 | width:110px; 42 | height:55px; 43 | &:before{ 44 | content:' '; 45 | @include bgImg(55px,55px,'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/mi-logo.png',55px); 46 | transition:margin .2s; 47 | } 48 | &:after{ 49 | content:' '; 50 | @include bgImg(55px,55px,'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/mi-home.png',55px); 51 | } 52 | &:hover:before{ 53 | margin-left:-55px; 54 | transition:margin .2s; 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/button.scss: -------------------------------------------------------------------------------- 1 | .btn{ 2 | display: inline-block; 3 | width: 110px; 4 | height: 30px; 5 | line-height: 30px; 6 | text-align: center; 7 | background-color: $colorA; 8 | color: $colorG; 9 | border: none; 10 | cursor: pointer; 11 | } 12 | .btn-default{ 13 | background-color: #B0B0B0; 14 | color: $colorG; 15 | } 16 | .btn-large{ 17 | width: 202px; 18 | height: 50px; 19 | line-height: 50px; 20 | font-size: 18px; 21 | } 22 | .btn-huge{ 23 | width: 300px; 24 | height: 54px; 25 | line-height: 54px; 26 | font-size: 16px; 27 | } 28 | .btn-group{ 29 | .btn{ 30 | margin-right: 20px; 31 | &:last-child{ 32 | margin-right: 0; 33 | } 34 | } 35 | } -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/config.scss: -------------------------------------------------------------------------------- 1 | /* 2 | 样式规范表 3 | */ 4 | $min-width:1226px; //容器安全区域宽度 5 | 6 | // 常规字体大小设置 7 | $fontA: 80px; //产品站大标题 8 | $fontB: 38px; //产品站标题 9 | $fontC: 28px; //导航标题 10 | $fontD: 26px; //产品站副标题 11 | $fontE: 24px; 12 | $fontF: 22px; 13 | $fontG: 20px; //用在较为重要的文字、操作按钮 14 | $fontH: 18px; //用于大多数文字 15 | $fontI: 16px; //用于辅助性文字 16 | $fontJ: 14px; //用于一般文字 17 | $fontK: 12px; //系统默认大小 18 | 19 | // 常规配色设置 20 | $colorA: #FF6600 !default; //用于需要突出和强调的文字、按钮和icon 21 | $colorB: #333333 !default; //用于较为重要的文字信息、内页标题等 22 | $colorC: #666666 !default; //用于普通段落信息 引导词 23 | $colorD: #999999 !default; //用于辅助、次要的文字信息、普通按钮的描边 24 | $colorE: #cccccc !default; //用于特别弱的文字 25 | $colorF: #d7d7d7 !default; //用于列表分割线、标签秒变 26 | $colorG: #ffffff !default; //用于导航栏文字、按钮文字、白色背景 27 | $colorH: #e5e5e5 !default; //用于上下模块分割线 28 | $colorI: #000000 !default; //纯黑色背景,用于遮罩层 29 | $colorJ: #F5F5F5 !default; //弹框标题背景色 30 | $colorK: #FFFAF7 !default; //订单标题背景色 31 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/mixin.scss: -------------------------------------------------------------------------------- 1 | //scss语法,@mixin 方法名($参数1:默认值, $参数2, ...){ 公共css样式 } 2 | //flex布局复用, 冒号后面是变量的默认值(即不填参数就是这个) 3 | @mixin flex($hov:space-between,$col:center){ 4 | display:flex; 5 | justify-content:$hov; //水平方向,默认两边放置 6 | align-items:$col; //垂直方向,默认居中 7 | } 8 | 9 | @mixin bgImg($w:0,$h:0,$img:'',$size:contain){ 10 | display:inline-block; 11 | width:$w; 12 | height:$h; 13 | background:url($img) no-repeat center; 14 | background-size:$size; 15 | } 16 | @mixin position($pos:absolute,$top:0,$left:0,$w:100%,$h:100%){ 17 | position:$pos; 18 | top:$top; 19 | left:$left; 20 | width:$w; 21 | height:$h; 22 | } 23 | @mixin positionImg($pos:absolute,$top:0,$right:0,$w:0,$h:0,$img:''){ 24 | position:$pos; 25 | top:$top; 26 | right:$right; 27 | width:$w; 28 | height:$h; 29 | background:url($img) no-repeat center; 30 | background-size:contain; 31 | } 32 | @mixin height($h:0,$lh:$h) { 33 | height: $h; 34 | line-height: $lh; 35 | } 36 | @mixin wH($w:0,$h:0) { 37 | width:$w; 38 | height: $h; 39 | } 40 | @mixin border($bw:1px,$bc:$colorF,$bs:solid) { 41 | border: $bw $bs $bc; 42 | } -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/modal.scss: -------------------------------------------------------------------------------- 1 | .modal{ 2 | @include position(fixed); 3 | z-index: 20; 4 | transition: all 0.5s; 5 | .mask{ 6 | @include position(fixed); 7 | background-color: $colorI; 8 | opacity: 0.5; 9 | } 10 | // &代表元素自身,即.modal, 这里表示.modal.slide-enter-active 11 | &.slide-enter-active{ 12 | top:0; 13 | } 14 | &.slide-leave-active{ 15 | top:-100%; 16 | } 17 | &.slide-enter{ 18 | top:-100%; 19 | } 20 | .modal-dialog{ 21 | @include position(absolute,40%,50%,660px,auto); 22 | background-color: $colorG; 23 | transform:translate(-50%,-50%); 24 | .modal-header{ 25 | height:60px; 26 | background-color: $colorJ; 27 | padding:0 25px; 28 | line-height: 60px; 29 | font-size:$fontI; 30 | .icon-close{ 31 | @include positionImg(absolute,23px,25px,14px,14px,'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon-close.png'); 32 | transition: transform 0.3s; 33 | &:hover{ 34 | transform: scale(1.5); 35 | } 36 | } 37 | } 38 | .modal-body{ 39 | padding:42px 40px 54px; 40 | font-size:14px; 41 | } 42 | .modal-footer{ 43 | height: 82px; 44 | line-height: 82px; 45 | text-align: center; 46 | background-color: $colorJ; 47 | } 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/assets/scss/reset.scss: -------------------------------------------------------------------------------- 1 | // reset.scss : 初始化样式 2 | body,div,p,h1,h2,h3,h4,h5,h6,ul,li,dl,dt,a,input,button,textarea,select{ 3 | margin: 0; 4 | padding: 0; 5 | outline: none; 6 | } 7 | html,body{ 8 | font-family:Helvetica Neue,Helvetica,Arial,Microsoft Yahei,Hiragino Sans GB,Heiti SC,WenQuanYi Micro Hei,sans-serif; 9 | color: #333333; 10 | background-color: #ffffff; 11 | min-width: 1226px; 12 | font-size: 12px; 13 | } 14 | a{ 15 | text-decoration: none; 16 | } 17 | ul,li{ 18 | list-style: none; 19 | } 20 | input{ 21 | font: normal; 22 | } 23 | input:focus,a:focus{ 24 | outline: none; 25 | } -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/Flash.vue: -------------------------------------------------------------------------------- 1 | 59 | 60 | 65 | 66 | 206 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/Loading.vue: -------------------------------------------------------------------------------- 1 | 6 | 11 | 22 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/Modal.vue: -------------------------------------------------------------------------------- 1 | 25 | 50 | 55 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/MyList.vue: -------------------------------------------------------------------------------- 1 | 6 | 31 | 59 | 142 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/MyMenu.vue: -------------------------------------------------------------------------------- 1 | 7 | 23 | 46 | 62 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/NavFooter.vue: -------------------------------------------------------------------------------- 1 | 37 | 38 | 44 | 116 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/NoData.vue: -------------------------------------------------------------------------------- 1 | 7 | 12 | 25 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/OrderHeader.vue: -------------------------------------------------------------------------------- 1 | 16 | 17 | 29 | 30 | 65 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/ProductParam.vue: -------------------------------------------------------------------------------- 1 | 16 | 44 | 78 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/ScanPayCode.vue: -------------------------------------------------------------------------------- 1 | 17 | 28 | 100 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/components/ServiceBar.vue: -------------------------------------------------------------------------------- 1 | 13 | 18 | 53 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/main.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import router from './router' 3 | import axios from 'axios' 4 | import VueAxios from 'vue-axios' 5 | import VueLazyLoad from 'vue-lazyload' 6 | import VueCookie from 'vue-cookie' 7 | import { Message } from 'element-ui' 8 | import 'element-ui/lib/theme-chalk/index.css' 9 | import store from './store' 10 | 11 | import ElementUI from 'element-ui'; 12 | import 'element-ui/lib/theme-chalk/index.css'; 13 | 14 | import App from './App.vue' 15 | 16 | /** 17 | * - 根据环境变量获取不同的请求地址[方式一]: CORS和JSONP跨越时,使用env.js自己定义的环境文件 18 | * import env from './env' 19 | * axios.defaults.baseURL = env.baseURL 20 | */ 21 | 22 | /** 23 | * - 根据环境变量获取不同的请求地址[方式二]: 代理跨越,则不用env.js,直接修改vue.config.js和axios.defaults.baseURL = '/api' 24 | * 根据前端的跨域方式做调整 /pro/b : /api/pro/b => /pro/b 25 | * 因为是代理方式跨越,域名相同可直接写'/api',若是JSONP/CORS其他方式跨域则要写全'http:www.jerrybro.cn/api' 26 | * 将每个通过axios发送的请求都在url中加上/api 27 | */ 28 | // axios.defaults.baseURL = '/api' 29 | // 第三中方式:模拟接口数据(使用easy-mock方式模拟请求数据) 30 | // axios.defaults.baseURL = 'https://www.easy-mock.com/mock/5dc7afee2b69d9223b633cbb/mimall'; 31 | // axios.defaults.timeout = 8000 32 | 33 | /** 34 | * 第二种方式:模拟接口数据 35 | * 常量mock为开关,需要自己写src/mock/api.js文件,即为下面require引入的代码 36 | * const mock = true 37 | * if (mock) { 38 | * require('./mock/api') 39 | * } 40 | */ 41 | 42 | // 接口响应拦截 (请求拦截没做) 43 | // 第一个参数,是请求响应200成功后的拦截(根据请求内容的状态字段判断拦截), 44 | // 第二个参数,是请求响应除200(如4xx/5xx)以外失败后的拦截 45 | axios.interceptors.response.use(function (response) { 46 | const res = response.data 47 | try { 48 | JSON.parse(res); 49 | } catch(e) { 50 | console.log(e); 51 | return res; 52 | } 53 | if (res.status === 0 || res.status === 1 ||res.status === 200 || res.status === 404 || 54 | res.status === 2002 || res.status === 2007 || res.status === 2008 || res.status === null) { // 0:表示成功 55 | return res 56 | } else if (res.status === 10) { // 10:表示未登录 57 | // 在.js文件中,只能使用window.location.href跳转,才有效 58 | // 路由跳转只能在.vue页面中使用,因为路由跳转需要获取Vue实例,而.js中获取不到Vue实例 59 | 60 | window.location.href = '/#/login' 61 | return Promise.reject(res) 62 | } else { 63 | Message.warning(res.msg) 64 | // Promise.reject():抛出异常,不会进入成功的this.axios.get().then()中,而是只进入catch()中 65 | return Promise.reject(res) 66 | } 67 | }, (error) => { 68 | const res = error.response 69 | Message.error(res.data.message) 70 | return Promise.reject(error) 71 | }) 72 | 73 | // 将axios挂载到Vue实例中,其他页面都可以this.axios.get()调用,不用再单独引入axios,更方便 74 | Vue.use(VueAxios, axios) 75 | Vue.use(VueCookie) 76 | Vue.use(VueLazyLoad, { 77 | loading: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/loading-bars.svg' 78 | }) 79 | // 将element-ui中的Message模块挂载到Vue实例的$message属性中【注:$message是(通过prototype原型属性来操作的)自定义的名字】 80 | Vue.prototype.$message = Message 81 | Vue.config.productionTip = false 82 | Vue.use(ElementUI); 83 | 84 | new Vue({ 85 | store, 86 | router, 87 | render: h => h(App) 88 | }).$mount('#app') 89 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/mock/api.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/src/mock/api.js -------------------------------------------------------------------------------- /高仿小米商城前端/src/router/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import VueRouter from 'vue-router' 3 | 4 | // Vue加载插件的语法 5 | Vue.use(VueRouter) 6 | 7 | // 再导出VueRouter实例,这里格式是:VueRouter实例的参数是一个对象 8 | export default new VueRouter({ 9 | // routes(路由):即url输入对应的路径,加载显示对应的组件 10 | routes: [ 11 | { 12 | path: '/', 13 | name: 'home', // 若这里取了name,则对应导入的component组件中也要定义相同的name: 'home' 14 | component: () => import('./../views/home.vue'), 15 | redirect: '/index', // 默认输入xxx:8080 跳转到 xxx:8080/index中 16 | children: [ 17 | { 18 | // 示例:http://192.168.0.107:8080/index 19 | path: '/index', 20 | name: 'index', 21 | component: () => import('./../views/index.vue') 22 | }, 23 | { 24 | // 动态路由(即url中可加参数并获取): 25 | // http://192.168.0.107:8080/product/id(一个参数) 26 | path: '/product/:id', 27 | name: 'product', 28 | component: () => import('./../views/product.vue') 29 | }, 30 | { 31 | // 动态路由(即可加参数并获取): 32 | // http://192.168.0.107:8080/detail/id(一个参数) 33 | path: '/detail/:id', 34 | name: 'detail', 35 | component: () => import('./../views/detail.vue') 36 | } 37 | ] 38 | }, 39 | { 40 | path: '/login', 41 | name: 'login', 42 | component: () => import('./../views/login.vue') 43 | }, 44 | { 45 | path: '/register', 46 | name: 'register', 47 | component: () => import('./../views/Register.vue') 48 | }, 49 | { 50 | path: '/cart', 51 | name: 'cart', 52 | component: () => import('./../views/cart.vue') 53 | }, 54 | { 55 | path: '/order', 56 | name: 'order', 57 | component: () => import('./../views/order.vue'), 58 | children: [ 59 | { 60 | path: '/order/list', 61 | name: 'order-list', 62 | component: () => import('./../views/orderList.vue') 63 | }, 64 | { 65 | path: '/order/confirm', 66 | name: 'order-confirm', 67 | component: () => import('./../views/orderConfirm.vue') 68 | }, 69 | { 70 | path: '/order/pay', 71 | name: 'order-pay', 72 | component: () => import('./../views/orderPay.vue') 73 | }, 74 | { 75 | path: '/order/alipay', 76 | name: 'alipay', 77 | component: () => import('./../views/alipay.vue') 78 | } 79 | ] 80 | } 81 | ] 82 | }) 83 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/storage/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Storage封装, 封装了两级,再往下存储或删除只能重新传入新对象替换 3 | * 这里的键名加上" ",是因为JSON.parse(字符串)参数中要传入字符串,再转成对象 4 | * 封装样例: 5 | * Key : Value 6 | * mall : { 7 | * "user": { 8 | * "userName": "jack", 9 | * "age": 30, 10 | * "sex": 1 11 | * } 12 | * } 13 | * 使用示例: 14 | * storage.setItem('user', { name: 'JerryBro' }) 15 | * storage.setItem('info', { height: '180cm' }, 'user') 16 | * const info = storage.getItem('info', 'user') 17 | * storage.clear('info', 'user') 18 | */ 19 | const STORAGE_KEY = 'mall' 20 | export default { 21 | // 存储值,原理同下(注意看是否有moduleName,有则存储到二级,无则到一级,即键为mall的值下) 22 | // value(第二个参数):可以是对象,数字,字符串都行 23 | setItem (key, value, moduleName) { 24 | if (moduleName) { 25 | const val = this.getItem(moduleName) 26 | val[key] = value 27 | // 递归setItem()方法,即没有第三个参数,存储在键为mall的值内 28 | this.setItem(moduleName, val) 29 | } else { 30 | const val = this.getStorage() 31 | val[key] = value 32 | // 注意: 这里的window.sessionStorage.setItem是API自带的方法,而不是用的自己定义的方法 33 | window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(val)) 34 | } 35 | }, 36 | /** 37 | * this.getStorage()得到缓存中键为mall的对象 38 | * @param {*} key : this.getStorage()[key]根据键名获取对应的值 39 | * @param {*} moduleName : 若有第二个参数,则先获取this.getStorage()[moduleName]对象,再查找该对象下的key值 40 | * 功能: 若只填一个参数或填了两个参数(其中第二个参数是null或mall下不存在的键名),则相当于查找一级this.getStorage()[key] 41 | * 即: 获取sessionStorage键为mall的值下的键为key的内容(若有moduleName,则获取moduleName下的key内容) 42 | * 返回值: Object 43 | */ 44 | getItem (key, moduleName) { 45 | if (moduleName) { 46 | // 这里递归了getItem(),显然进入调用的是一个参数的getItem()方法,直接返回this.getStorage()[key]对象 47 | const val = this.getItem(moduleName) 48 | if (val) return val[key] 49 | } 50 | return this.getStorage()[key] 51 | }, 52 | getStorage () { 53 | // 若window.sessionStorage.getItem(STORAGE_KEY)为null,则JSON.parse('{}'),将字符串'{}'转成一个对象{} 54 | // 即下面代码意思:若缓存中键名为mall中的值为空,则返回空对象{},否则转换mall中的值为对象返回 55 | return JSON.parse(window.sessionStorage.getItem(STORAGE_KEY) || '{}') 56 | }, 57 | clear (key, moduleName) { 58 | const val = this.getStorage() 59 | if (moduleName) { 60 | // 若moduleName为空,则直接返回(即什么都没做) 61 | if (!val[moduleName]) return 62 | // 若moduleName不为空,则删除该模块下的key值 63 | delete val[moduleName][key] 64 | } else { 65 | delete val[key] 66 | } 67 | window.sessionStorage.setItem(STORAGE_KEY, JSON.stringify(val)) 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/store/actions.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 商城Vuex-actions 3 | * 每个方法的第一个参数:context(上下文) 4 | * 第二个参数:接收的传参 5 | */ 6 | export default { 7 | // 通过:this.$store.dispatch('saveUserName',传参),来触发actions.js中的saveUserName()方法 8 | // actions.js中的saveUserName()方法,再触发mutations.js中的saveUserName()方法 9 | // 【context.commit()触发的方法名根据mutations.js设置的来定义,一般都取相同的名字来命名】 10 | saveUserName (context, username) { 11 | context.commit('saveUserName', username) 12 | }, 13 | saveCartCount (context, count) { 14 | context.commit('saveCartCount', count) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/store/index.js: -------------------------------------------------------------------------------- 1 | import Vue from 'vue' 2 | import Vuex from 'vuex' 3 | import mutations from './mutations' 4 | import actions from './actions' 5 | Vue.use(Vuex) 6 | 7 | // vuex中的状态变量通过:this.$store.state.username 来读取 8 | const state = { 9 | username: '', 10 | token:'', 11 | cartCount: 0 12 | } 13 | export default new Vuex.Store({ 14 | state, 15 | mutations, 16 | actions 17 | }) 18 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/store/mutations.js: -------------------------------------------------------------------------------- 1 | /** 2 | * 商城Vuex-mutations 3 | * 每个方法的第一个参数:state(状态) 4 | * 第二个参数:接收的传参 5 | */ 6 | export default { 7 | // 由actions.js触发该方法,mutations.js中的方法再改变state状态(即修改最终存储的地方) 8 | saveUserName (state, username) { 9 | state.username = username 10 | }, 11 | saveCartCount (state, count) { 12 | state.cartCount = count 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/util/index.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城前端/src/util/index.js -------------------------------------------------------------------------------- /高仿小米商城前端/src/views/alipay.vue: -------------------------------------------------------------------------------- 1 | 8 | 44 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/views/home.vue: -------------------------------------------------------------------------------- 1 | 12 | 25 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/views/login.vue: -------------------------------------------------------------------------------- 1 | 40 | 100 | 195 | -------------------------------------------------------------------------------- /高仿小米商城前端/src/views/order.vue: -------------------------------------------------------------------------------- 1 | 8 | 19 | -------------------------------------------------------------------------------- /高仿小米商城前端/vue.config.js: -------------------------------------------------------------------------------- 1 | // 给webpack打包编译用的、具体看官方文档vue-cli的参考配置 2 | // 注意:这里的配置只是本地启动node服务器才有效,若部署到服务器上,要重新配置nginx才有效 3 | module.exports = { 4 | // 公共路径(必须有的) 5 | publicPath: "./", 6 | // 输出文件目录 7 | outputDir: "dist", 8 | // 静态资源存放的文件夹(相对于ouputDir) 9 | assetsDir: "public", 10 | // eslint-loader 是否在保存的时候检查(果断不用,这玩意儿我都没装) 11 | // 我用的only,打包后小些 12 | 13 | pwa: { 14 | iconPaths: { 15 | favicon32: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon.svg', 16 | favicon16: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon.svg', 17 | appleTouchIcon: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon.svg', 18 | maskIcon: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon.svg', 19 | msTileImage: 'https://cdn.jsdelivr.net/gh/ZTY18873242003/img/优雅的使用图床/icon.svg' 20 | } 21 | }, 22 | lintOnSave: false, //如果为false,就是取消eslint规则的检查 23 | devServer: { 24 | host: 'localhost', 25 | port: 8080, 26 | }, 27 | 28 | productionSourceMap: false, // 设为false:打包后部署在Sources中搜索不到main.js(即看不到源码),更安全 29 | chainWebpack: (config) => { // 删除预加载,防止重复加载 30 | config.plugins.delete('prefetch') 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /高仿小米商城后台/.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | -------------------------------------------------------------------------------- /高仿小米商城后台/.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | import java.net.*; 18 | import java.io.*; 19 | import java.nio.channels.*; 20 | import java.util.Properties; 21 | 22 | public class MavenWrapperDownloader { 23 | 24 | private static final String WRAPPER_VERSION = "0.5.6"; 25 | /** 26 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 27 | */ 28 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 29 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 30 | 31 | /** 32 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 33 | * use instead of the default one. 34 | */ 35 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 36 | ".mvn/wrapper/maven-wrapper.properties"; 37 | 38 | /** 39 | * Path where the maven-wrapper.jar will be saved to. 40 | */ 41 | private static final String MAVEN_WRAPPER_JAR_PATH = 42 | ".mvn/wrapper/maven-wrapper.jar"; 43 | 44 | /** 45 | * Name of the property which should be used to override the default download url for the wrapper. 46 | */ 47 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 48 | 49 | public static void main(String args[]) { 50 | System.out.println("- Downloader started"); 51 | File baseDirectory = new File(args[0]); 52 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 53 | 54 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 55 | // wrapperUrl parameter. 56 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 57 | String url = DEFAULT_DOWNLOAD_URL; 58 | if (mavenWrapperPropertyFile.exists()) { 59 | FileInputStream mavenWrapperPropertyFileInputStream = null; 60 | try { 61 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 62 | Properties mavenWrapperProperties = new Properties(); 63 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 64 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 65 | } catch (IOException e) { 66 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 67 | } finally { 68 | try { 69 | if (mavenWrapperPropertyFileInputStream != null) { 70 | mavenWrapperPropertyFileInputStream.close(); 71 | } 72 | } catch (IOException e) { 73 | // Ignore ... 74 | } 75 | } 76 | } 77 | System.out.println("- Downloading from: " + url); 78 | 79 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 80 | if (!outputFile.getParentFile().exists()) { 81 | if (!outputFile.getParentFile().mkdirs()) { 82 | System.out.println( 83 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 84 | } 85 | } 86 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 87 | try { 88 | downloadFileFromURL(url, outputFile); 89 | System.out.println("Done"); 90 | System.exit(0); 91 | } catch (Throwable e) { 92 | System.out.println("- Error downloading"); 93 | e.printStackTrace(); 94 | System.exit(1); 95 | } 96 | } 97 | 98 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 99 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 100 | String username = System.getenv("MVNW_USERNAME"); 101 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 102 | Authenticator.setDefault(new Authenticator() { 103 | @Override 104 | protected PasswordAuthentication getPasswordAuthentication() { 105 | return new PasswordAuthentication(username, password); 106 | } 107 | }); 108 | } 109 | URL website = new URL(urlString); 110 | ReadableByteChannel rbc; 111 | rbc = Channels.newChannel(website.openStream()); 112 | FileOutputStream fos = new FileOutputStream(destination); 113 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 114 | fos.close(); 115 | rbc.close(); 116 | } 117 | 118 | } 119 | -------------------------------------------------------------------------------- /高仿小米商城后台/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ZTY18873242003/tongyimall/f61cb0161f5615e40ffe89a34e6b411bc53564c7/高仿小米商城后台/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /高仿小米商城后台/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /高仿小米商城后台/README.md: -------------------------------------------------------------------------------- 1 | # tongyimall-api 2 | 高仿小米商城用户端后台 3 |

4 | ## 技术栈 5 | Springboot + MyBatis + MySQL + jwtToken + RSA加密 + Redis + Druid连接池 6 |

7 | ## 启动 8 |     使用数据库管理软件(如DataGrip或者navicat)运行xiaomi.sql脚本文件在本地建库建表及插入数据.
9 |     mysql和redis登录的用户名和密码在src/main/resources目录下的application.yml文件中 10 |

11 | -------------------------------------------------------------------------------- /高仿小米商城后台/mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM https://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /高仿小米商城后台/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | org.springframework.boot 7 | spring-boot-starter-parent 8 | 2.4.0 9 | 10 | 11 | com.zty.xiaomi 12 | server 13 | 0.0.1-SNAPSHOT 14 | server 15 | Demo project for Spring Boot 16 | 17 | 18 | 1.8 19 | 20 | 21 | 22 | 23 | org.springframework.boot 24 | spring-boot-starter-web 25 | 26 | 27 | org.mybatis.spring.boot 28 | mybatis-spring-boot-starter 29 | 2.1.4 30 | 31 | 32 | 33 | org.projectlombok 34 | lombok 35 | true 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-test 40 | test 41 | 42 | 43 | com.auth0 44 | java-jwt 45 | 3.8.2 46 | 47 | 48 | mysql 49 | mysql-connector-java 50 | 51 | 52 | com.aliyun.oss 53 | aliyun-sdk-oss 54 | 3.10.2 55 | 56 | 57 | 58 | com.alibaba 59 | druid 60 | 1.2.1 61 | 62 | 63 | 64 | 65 | org.springframework.boot 66 | spring-boot-starter-data-redis 67 | 68 | 69 | 70 | org.apache.commons 71 | commons-pool2 72 | 73 | 74 | 75 | redis.clients 76 | jedis 77 | 78 | 79 | 80 | com.alipay.sdk 81 | alipay-easysdk 82 | 2.2.0 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | log4j 91 | log4j 92 | 1.2.17 93 | 94 | 95 | 96 | 97 | 98 | com.google.guava 99 | guava 100 | 23.0 101 | 102 | 103 | 104 | commons-io 105 | commons-io 106 | 2.6 107 | 108 | 109 | 110 | 111 | org.aspectj 112 | aspectjweaver 113 | 1.9.5 114 | 115 | 116 | 117 | 118 | org.aspectj 119 | aspectjrt 120 | 1.9.3 121 | 122 | 123 | com.alipay.sdk 124 | alipay-sdk-java 125 | 4.9.100.ALL 126 | 127 | 128 | 129 | 130 | 131 | 132 | org.springframework.boot 133 | spring-boot-maven-plugin 134 | 135 | 136 | 137 | 138 | 139 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Config/AlipayConfig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Config; 2 | 3 | 4 | import com.alipay.easysdk.factory.Factory; 5 | import com.alipay.easysdk.kernel.Config; 6 | import org.springframework.beans.factory.annotation.Value; 7 | import org.springframework.boot.ApplicationArguments; 8 | import org.springframework.boot.ApplicationRunner; 9 | import org.springframework.stereotype.Component; 10 | 11 | @Component 12 | public class AlipayConfig implements ApplicationRunner { 13 | // 应用ID,您的APPID,收款账号既是您的APPID对应支付宝账号 14 | @Value("${alipay.app_id}") 15 | public String app_id; 16 | // 商户私钥,您的PKCS8格式RSA2私钥 17 | @Value("${alipay.merchant_private_key}") 18 | public String merchant_private_key; 19 | // 支付宝公钥,查看地址:https://openhome.alipay.com/platform/keyManage.htm 对应APPID下的支付宝公钥。 20 | @Value("${alipay.alipay_public_key}") 21 | public String alipay_public_key; 22 | //格式 23 | @Value("${alipay.format}") 24 | public String format; 25 | 26 | // 服务器异步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问 27 | @Value("${alipay.notify_url}") 28 | public String notify_url; 29 | // 页面跳转同步通知页面路径 需http://格式的完整路径,不能加?id=123这类自定义参数,必须外网可以正常访问 30 | // 即支付成功之后,需要跳转到的页面,一般为网站的首页 31 | @Value("${alipay.return_url}") 32 | public String return_url; 33 | // 签名方式 34 | @Value("${alipay.sign_type}") 35 | public String sign_type; 36 | // 字符编码格式 37 | @Value("${alipay.charset}") 38 | public String charset; 39 | // 支付宝网关 40 | @Value("${alipay.gatewayUrl}") 41 | public String gatewayUrl; 42 | 43 | @Override 44 | public void run(ApplicationArguments args) throws Exception { 45 | //这里省略了一些不必要的配置,可参考文档的说明 46 | Config config = new Config(); 47 | config.protocol = "https"; 48 | config.gatewayHost = this.gatewayUrl; 49 | config.signType = this.sign_type; 50 | config.appId = this.app_id; 51 | // 为避免私钥随源码泄露,推荐从文件中读取私钥字符串而不是写入源码中 52 | config.merchantPrivateKey = this.merchant_private_key; 53 | // 注:如果采用非证书模式,则无需赋值上面的三个证书路径,改为赋值如下的支付宝公钥字符串即可 54 | config.alipayPublicKey = this.alipay_public_key; 55 | // 可设置异步通知接收服务地址(可选) 56 | config.notifyUrl = this.notify_url; 57 | //初始化支付宝SDK 58 | Factory.setOptions(config); 59 | System.out.println("=======支付宝SDK初始化成功"); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Config/DruidConfig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Config; 2 | 3 | 4 | import com.alibaba.druid.pool.DruidDataSource; 5 | import com.alibaba.druid.support.http.StatViewServlet; 6 | import org.springframework.boot.context.properties.ConfigurationProperties; 7 | import org.springframework.boot.web.servlet.ServletRegistrationBean; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | 11 | import javax.sql.DataSource; 12 | import java.util.HashMap; 13 | 14 | 15 | @Configuration 16 | public class DruidConfig { 17 | @ConfigurationProperties(prefix = "spring.datasource") 18 | @Bean 19 | public DataSource druidDataSource(){ 20 | return new DruidDataSource(); 21 | } 22 | 23 | //后台监控:因为springboot内置了servlet容器,使用没有web.xml,可以用ServletRegistrationBean替代 24 | @Bean 25 | public ServletRegistrationBean statViewServlet(){ 26 | ServletRegistrationBean bean = new ServletRegistrationBean<>(new StatViewServlet(),"/druid/*"); 27 | 28 | //后台需要有人登陆,账号密码 29 | HashMap initParameters = new HashMap<>(); 30 | 31 | //增加配置 32 | initParameters.put("loginUsername","admin"); //登陆参数是固定的 33 | initParameters.put("loginPassword","2000918131X"); 34 | 35 | //允许谁可以访问 36 | initParameters.put("allow",""); 37 | 38 | 39 | bean.setInitParameters(initParameters); //设置初始化参数 40 | return bean; 41 | } 42 | 43 | } 44 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Config/RedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Config; 2 | 3 | import org.springframework.cache.CacheManager; 4 | import org.springframework.cache.annotation.CachingConfigurerSupport; 5 | import org.springframework.cache.interceptor.KeyGenerator; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import org.springframework.data.redis.cache.RedisCacheConfiguration; 9 | import org.springframework.data.redis.cache.RedisCacheManager; 10 | import org.springframework.data.redis.connection.RedisConnectionFactory; 11 | import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer; 12 | import org.springframework.data.redis.serializer.RedisSerializationContext; 13 | import org.springframework.data.redis.serializer.StringRedisSerializer; 14 | 15 | import java.lang.reflect.Method; 16 | 17 | @Configuration 18 | public class RedisConfig extends CachingConfigurerSupport { 19 | 20 | @Bean 21 | public CacheManager cacheManager(RedisConnectionFactory connectionFactory) { 22 | GenericJackson2JsonRedisSerializer genericJackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer(); 23 | StringRedisSerializer stringRedisSerializer = new StringRedisSerializer(); 24 | // 配置序列化 25 | RedisCacheConfiguration config = RedisCacheConfiguration.defaultCacheConfig(); 26 | RedisCacheConfiguration redisCacheConfiguration = config 27 | // 键序列化方式 redis字符串序列化 28 | .serializeKeysWith(RedisSerializationContext.SerializationPair.fromSerializer(stringRedisSerializer)) 29 | // 值序列化方式 简单json序列化 30 | .serializeValuesWith(RedisSerializationContext.SerializationPair.fromSerializer(genericJackson2JsonRedisSerializer)); 31 | return RedisCacheManager.builder(connectionFactory).cacheDefaults(redisCacheConfiguration).build(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/AddrController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.AddrResult; 4 | import com.zty.xiaomi.server.Entity.Address.AddrSuccResult; 5 | import com.zty.xiaomi.server.Entity.Address.Addre; 6 | import com.zty.xiaomi.server.Entity.User; 7 | import com.zty.xiaomi.server.Service.Address.AddServiceImp; 8 | import com.zty.xiaomi.server.Service.RegLogin.RegLogServiceImp; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.io.IOException; 13 | 14 | @CrossOrigin 15 | @RestController 16 | @RequestMapping("shippings") 17 | public class AddrController { 18 | @Autowired 19 | private RegLogServiceImp regLogServiceImp; 20 | @Autowired 21 | private AddServiceImp addServiceImp; 22 | 23 | @PostMapping("/push") 24 | public AddrSuccResult pushSucc(@RequestBody Addre a) throws IOException { 25 | User userByUserName = regLogServiceImp.getUserByUserName(a.getUsername()); 26 | a.setUserid(userByUserName.getUserid()); 27 | AddrSuccResult addrSuccResult = addServiceImp.inseAddre(a); 28 | return addrSuccResult; 29 | } 30 | 31 | @RequestMapping("/getAll") 32 | public AddrResult getAll(@RequestParam("username") String username) throws IOException { 33 | User userByUserName = regLogServiceImp.getUserByUserName(username); 34 | String userid = userByUserName.getUserid(); 35 | AddrResult addrResult = addServiceImp.getAll(userid); 36 | return addrResult; 37 | } 38 | 39 | @PutMapping("{id}") 40 | public AddrSuccResult updatAddre(@PathVariable("id") int id,@RequestBody Addre a) throws IOException { 41 | User userByUserName = regLogServiceImp.getUserByUserName(a.getUsername()); 42 | a.setUserid(userByUserName.getUserid()); 43 | a.setId(id); 44 | AddrSuccResult addrSuccResult = addServiceImp.updaAddre(a); 45 | return addrSuccResult; 46 | } 47 | @DeleteMapping("{id}") 48 | public AddrSuccResult deletAddre(@PathVariable("id") int id) throws IOException { 49 | AddrSuccResult addrSuccResult = addServiceImp.deleAddre(id); 50 | return addrSuccResult; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/AliPayController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | 4 | import com.alipay.easysdk.factory.Factory; 5 | import com.zty.xiaomi.server.Mapper.Order; 6 | import com.zty.xiaomi.server.Service.AlipayService; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.web.bind.annotation.RequestMapping; 9 | import org.springframework.web.bind.annotation.RestController; 10 | 11 | import javax.servlet.http.HttpServletRequest; 12 | import java.util.HashMap; 13 | import java.util.Map; 14 | 15 | @RestController 16 | @RequestMapping("/alipay") 17 | public class AliPayController { 18 | @Autowired 19 | private AlipayService alipayService; 20 | 21 | @Autowired 22 | private Order order; 23 | 24 | /** 25 | * 跳转到支付界面 26 | * 27 | * @return 28 | * @throws Exception 29 | */ 30 | @RequestMapping("/page") 31 | public String pay(String subject, String total) throws Exception { 32 | return alipayService.toPayPage(subject, "10011", total); 33 | } 34 | 35 | /** 36 | * @param request: 请求 37 | * @return java.lang.String 38 | * @description: 支付宝异步回调 39 | */ 40 | @RequestMapping("/notify") 41 | public String notify_url(HttpServletRequest request) throws Exception { 42 | 43 | if (request.getParameter("trade_status").equals("TRADE_SUCCESS")) { 44 | System.out.println("=========支付宝异步回调========"); 45 | 46 | Map params = new HashMap<>(); 47 | Map requestParams = request.getParameterMap(); 48 | for (String name : requestParams.keySet()) { 49 | params.put(name, request.getParameter(name)); 50 | // System.out.println(name + " = " + request.getParameter(name)); 51 | } 52 | 53 | // 支付宝验签 54 | if (Factory.Payment.Common().verifyNotify(params)) { 55 | // 验签通过 56 | System.out.println("交易名称: " + params.get("subject")); 57 | System.out.println("交易状态: " + params.get("trade_status")); 58 | System.out.println("支付宝交易凭证号: " + params.get("trade_no")); 59 | System.out.println("商户订单号: " + params.get("out_trade_no")); 60 | System.out.println("交易金额: " + params.get("total_amount")); 61 | System.out.println("买家在支付宝唯一id: " + params.get("buyer_id")); 62 | System.out.println("买家付款时间: " + params.get("gmt_payment")); 63 | System.out.println("买家付款金额: " + params.get("buyer_pay_amount")); 64 | 65 | int out_trade_no = Integer.parseInt(params.get("out_trade_no")); 66 | order.updOrderTime(out_trade_no,params.get("gmt_payment")); 67 | order.buyOrder(out_trade_no); 68 | } 69 | } 70 | return "success"; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/CartController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.zty.xiaomi.server.Entity.Cart.*; 4 | import com.zty.xiaomi.server.Entity.User; 5 | import com.zty.xiaomi.server.Service.Cart.CartServiceImp; 6 | import com.zty.xiaomi.server.Service.Good.GoodServiceImp; 7 | import com.zty.xiaomi.server.Service.RegLogin.RegLogServiceImp; 8 | import com.zty.xiaomi.server.utils.TokenUtil; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.web.bind.annotation.*; 11 | 12 | import java.io.IOException; 13 | 14 | @CrossOrigin 15 | @RestController 16 | @RequestMapping("carts") 17 | public class CartController { 18 | 19 | @Autowired 20 | private RegLogServiceImp regLogServiceImp; 21 | @Autowired 22 | private GoodServiceImp goodServiceImp; 23 | @Autowired 24 | private CartServiceImp cartServiceImp; 25 | 26 | @PostMapping("/push") 27 | public CartResult putShop(@RequestBody pushCart pushcart) throws IOException { 28 | 29 | CartResult cartResult = new CartResult(); 30 | boolean success = TokenUtil.verify(pushcart.getToken()); 31 | if (success) { 32 | cartResult.setStatus(0); 33 | User user = regLogServiceImp.getUserByUserName(pushcart.getUsername().trim()); 34 | String userid = user.getUserid(); 35 | CartGood cartGood = goodServiceImp.getGoodByid(userid, pushcart.getProductId()); 36 | if (cartGood == null) { 37 | int goodcount = 1; 38 | CartGoodInsert goodByidinsert = goodServiceImp.getGoodByidinsert(pushcart.getProductId()); 39 | 40 | goodServiceImp.insCartGood(userid, pushcart.getProductId(), goodByidinsert.getName(), 41 | goodByidinsert.getPrice(), goodcount, goodByidinsert.getSubtitle(), goodByidinsert.getProductStock(), 42 | goodByidinsert.getStatus(), true); 43 | } else { 44 | goodServiceImp.updateCartGood(userid, cartGood.getCount() + 1, pushcart.getProductId(), (cartGood.getCount() + 1) * cartGood.getPrice()); 45 | } 46 | 47 | cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); 48 | 49 | int cartTotalPrice = 0; 50 | boolean selectedAll = true; 51 | int cartTotalQuantity = 0; 52 | for (cartProduct cartProduct : cartProductVoList.getList()) { 53 | cartTotalPrice += cartProduct.getProductTotalPrice(); 54 | if (!cartProduct.isProductSelected()) { 55 | selectedAll = false; 56 | } 57 | cartTotalQuantity += cartProduct.getCount(); 58 | } 59 | 60 | cartResult.setStatus(0); 61 | cartResult.setCartTotalPrice(cartTotalPrice); 62 | cartResult.setCartTotalQuantity(cartTotalQuantity); 63 | cartResult.setData(cartProductVoList); 64 | cartResult.setImageHost("www.mi.com"); 65 | cartResult.setSelectedAll(selectedAll); 66 | } else { 67 | cartResult.setStatus(10); 68 | } 69 | return cartResult; 70 | } 71 | @GetMapping("/sum") 72 | public CartResult getCartSum(@RequestParam("username") String username) throws IOException { 73 | CartResult cartResult = new CartResult(); 74 | 75 | User user = regLogServiceImp.getUserByUserName(username); 76 | String userid = user.getUserid(); 77 | cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); 78 | if(cartProductVoList==null){ 79 | cartResult.setStatus(0); 80 | cartResult.setCartTotalQuantity(0); 81 | } 82 | else { 83 | int cartTotalQuantity=0; 84 | for(cartProduct cartProduct:cartProductVoList.getList()){ 85 | cartTotalQuantity+=cartProduct.getCount(); 86 | } 87 | cartResult.setStatus(0); 88 | cartResult.setCartTotalQuantity(cartTotalQuantity); 89 | } 90 | return cartResult; 91 | } 92 | @RequestMapping("/del") 93 | public CartResult delCarts(@RequestParam("id") int goodid, 94 | @RequestParam("username") String username) throws IOException { 95 | User user = regLogServiceImp.getUserByUserName(username); 96 | String userid = user.getUserid(); 97 | goodServiceImp.delGoodByid(userid,goodid); 98 | CartResult cartResult = getCarts(username); 99 | return cartResult; 100 | } 101 | 102 | @RequestMapping("/getcarts") 103 | public CartResult getCarts (@RequestParam("username") String username) throws IOException { 104 | CartResult cartResult = new CartResult(); 105 | User user = regLogServiceImp.getUserByUserName(username); 106 | String userid = user.getUserid(); 107 | cartProductVoList cartProductVoList = cartServiceImp.getCartProduct(userid); 108 | if(cartProductVoList==null){ 109 | cartResult.setStatus(0); 110 | cartResult.setCartTotalQuantity(0); 111 | cartResult.setSelectedAll(false); 112 | cartResult.setImageHost("www.mi.com"); 113 | cartResult.setCartTotalQuantity(0); 114 | } 115 | else { 116 | int carttotalPrice=0; 117 | boolean selectedall=true; 118 | int carttotalQuantity=0; 119 | for(cartProduct cartProduct:cartProductVoList.getList()){ 120 | if(cartProduct.isProductSelected()) 121 | carttotalPrice+=cartProduct.getProductTotalPrice(); 122 | if(!cartProduct.isProductSelected()){ 123 | selectedall=false; 124 | } 125 | carttotalQuantity+=cartProduct.getCount(); 126 | } 127 | 128 | cartResult.setStatus(0); 129 | cartResult.setCartTotalPrice(carttotalPrice); 130 | cartResult.setCartTotalQuantity(carttotalQuantity); 131 | cartResult.setData(cartProductVoList); 132 | cartResult.setImageHost("www.mi.com"); 133 | cartResult.setSelectedAll(selectedall); 134 | } 135 | return cartResult; 136 | } 137 | 138 | @GetMapping("/updatecart") 139 | public CartResult getCarts ( 140 | @RequestParam("goodid") int goodid, 141 | @RequestParam("username") String username, 142 | @RequestParam("quantity") int count, 143 | @RequestParam("selected") boolean selected 144 | ) throws IOException { 145 | User user = regLogServiceImp.getUserByUserName(username); 146 | String userid = user.getUserid(); 147 | 148 | CartGood goodByid = goodServiceImp.getGoodByid(userid, goodid); 149 | goodServiceImp.updaCartNumSel(userid,goodid,count,selected,goodByid.getPrice()*count); 150 | CartResult carts = getCarts(username); 151 | return carts; 152 | } 153 | 154 | @GetMapping("/selectAll") 155 | public CartResult SelectAllCart(@RequestParam("username") String username) throws IOException { 156 | User user = regLogServiceImp.getUserByUserName(username); 157 | String userid = user.getUserid(); 158 | goodServiceImp.updaCartSelect(userid); 159 | CartResult cartResult = getCarts(username); 160 | return cartResult; 161 | } 162 | 163 | @GetMapping("/unSelectAll") 164 | public CartResult unSelectAllCart(@RequestParam("username") String username) throws IOException { 165 | User user = regLogServiceImp.getUserByUserName(username); 166 | String userid = user.getUserid(); 167 | goodServiceImp.updaCartunSelect(userid); 168 | CartResult cartResult = getCarts(username); 169 | cartResult.setCartTotalQuantity(0); 170 | cartResult.setCartTotalPrice(0); 171 | return cartResult; 172 | } 173 | } 174 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/GoodController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.zty.xiaomi.server.Entity.Good; 4 | import com.zty.xiaomi.server.Entity.GoodAll; 5 | import com.zty.xiaomi.server.Entity.GoodsAll; 6 | import com.zty.xiaomi.server.Entity.index.GoodCategory; 7 | import com.zty.xiaomi.server.Service.Good.GoodServiceImp; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.web.bind.annotation.CrossOrigin; 10 | import org.springframework.web.bind.annotation.RequestMapping; 11 | import org.springframework.web.bind.annotation.RestController; 12 | 13 | import java.util.ArrayList; 14 | import java.util.List; 15 | 16 | @CrossOrigin 17 | @RestController 18 | @RequestMapping("goods") 19 | public class GoodController { 20 | @Autowired 21 | private GoodServiceImp goodServiceImp; 22 | 23 | @RequestMapping("getGoodsAll") 24 | private GoodsAll getGoodByCategory() { 25 | GoodsAll goodsAll = new GoodsAll(); 26 | ArrayList goodAlls = new ArrayList<>(); 27 | for (int i = 1; i <= 9; i++) { 28 | List good = goodServiceImp.getGood(i); 29 | GoodCategory goodCategory = goodServiceImp.getGoodCategory(i); 30 | GoodAll goodAll = new GoodAll(); 31 | goodAll.setName(goodCategory.getName()); 32 | goodAll.setFoods(good); 33 | goodAlls.add(goodAll); 34 | } 35 | goodsAll.setData(goodAlls); 36 | return goodsAll; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/IndexController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.google.common.hash.BloomFilter; 4 | import com.google.common.hash.Funnels; 5 | import com.zty.xiaomi.server.Entity.ProductFoot.ProductFootInfo; 6 | import com.zty.xiaomi.server.Entity.ProductFoot.ProductFootResult; 7 | import com.zty.xiaomi.server.Entity.ProductHead.ProductHeadInfo; 8 | import com.zty.xiaomi.server.Entity.ProductHead.ProductHeadResult; 9 | import com.zty.xiaomi.server.Entity.Suggest.SuggestFoot; 10 | import com.zty.xiaomi.server.Entity.Suggest.SuggestFootResult; 11 | import com.zty.xiaomi.server.Entity.index.CategoryResult; 12 | import com.zty.xiaomi.server.Service.Category.CategoryIndexImp; 13 | import com.zty.xiaomi.server.Service.ProdFoot.ProductFootImp; 14 | import com.zty.xiaomi.server.Service.ProdHead.ProductHeadImp; 15 | import com.zty.xiaomi.server.Service.Suggest.SugFootServiceImp; 16 | import org.springframework.beans.factory.annotation.Autowired; 17 | import org.springframework.web.bind.annotation.CrossOrigin; 18 | import org.springframework.web.bind.annotation.RequestMapping; 19 | import org.springframework.web.bind.annotation.RequestParam; 20 | import org.springframework.web.bind.annotation.RestController; 21 | import java.io.IOException; 22 | import java.util.List; 23 | 24 | @CrossOrigin 25 | @RestController 26 | @RequestMapping("index") 27 | public class IndexController { 28 | 29 | @Autowired 30 | private CategoryIndexImp categoryIndexImp; 31 | @Autowired 32 | private ProductHeadImp productHeadImp; 33 | @Autowired 34 | private ProductFootImp productFootImp; 35 | @Autowired 36 | private SugFootServiceImp sugFootServiceImp; 37 | 38 | 39 | private BloomFilter bf = BloomFilter.create(Funnels.integerFunnel(), 4); 40 | 41 | @RequestMapping("/category") 42 | public CategoryResult getCategory() throws IOException { 43 | CategoryResult categoryResult = new CategoryResult(); 44 | categoryResult.setStatus(0); 45 | categoryResult = categoryIndexImp.getCategoryGoods(); 46 | return categoryResult; 47 | } 48 | 49 | @RequestMapping("/product") 50 | public ProductHeadResult getProduct(@RequestParam("categoryId") int categoryId) throws IOException { 51 | 52 | bf.put(1);bf.put(2);bf.put(3);bf.put(9); 53 | 54 | ProductHeadResult productHeadResult = new ProductHeadResult(); 55 | 56 | if(!bf.mightContain(categoryId)){ 57 | productHeadResult.setStatus(500); 58 | return productHeadResult; 59 | } 60 | productHeadResult.setStatus(0); 61 | List productHeadInfo = productHeadImp.getProductHeadInfo(categoryId); 62 | productHeadResult.setData(productHeadInfo); 63 | return productHeadResult; 64 | } 65 | 66 | @RequestMapping("/productfoot") 67 | public ProductFootResult getProductFoot(@RequestParam("categoryId") int categoryId) { 68 | 69 | ProductFootResult productFootResult = new ProductFootResult(); 70 | productFootResult.setStatus(0); 71 | List productFootInfo = productFootImp.getProductFootInfo(categoryId); 72 | productFootResult.setData(productFootInfo); 73 | return productFootResult; 74 | } 75 | 76 | @RequestMapping("/productfootnormal") 77 | public ProductFootResult getProductFootNormal(@RequestParam("categoryId") int categoryId) throws IOException { 78 | 79 | ProductFootResult productFootResult = new ProductFootResult(); 80 | productFootResult.setStatus(0); 81 | List productFootInfo = productFootImp.getProductFootInfoNormal(categoryId); 82 | productFootResult.setData(productFootInfo); 83 | return productFootResult; 84 | } 85 | 86 | 87 | @RequestMapping("/suggest") 88 | public SuggestFootResult getSugFoot() throws IOException { 89 | SuggestFootResult suggestFootResult = new SuggestFootResult(); 90 | suggestFootResult.setStatus(200); 91 | List sugFoot = sugFootServiceImp.getSugFoot(); 92 | suggestFootResult.setSugglist(sugFoot); 93 | return suggestFootResult; 94 | } 95 | } 96 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/LogRegController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.zty.xiaomi.server.Entity.LoginData; 4 | import com.zty.xiaomi.server.Entity.User; 5 | import com.zty.xiaomi.server.Service.RegLogin.RegLogServiceImp; 6 | import com.zty.xiaomi.server.Vo.LoginResult; 7 | import com.zty.xiaomi.server.Vo.RegResult; 8 | import com.zty.xiaomi.server.utils.DateUtil; 9 | import com.zty.xiaomi.server.utils.RSAUtils; 10 | import com.zty.xiaomi.server.utils.TokenUtil; 11 | import org.springframework.beans.factory.annotation.Autowired; 12 | import org.springframework.web.bind.annotation.CrossOrigin; 13 | import org.springframework.web.bind.annotation.RequestMapping; 14 | import org.springframework.web.bind.annotation.RequestParam; 15 | import org.springframework.web.bind.annotation.RestController; 16 | 17 | import java.io.IOException; 18 | import java.security.NoSuchAlgorithmException; 19 | import java.security.spec.InvalidKeySpecException; 20 | import java.util.Map; 21 | import java.util.UUID; 22 | 23 | @CrossOrigin 24 | @RestController 25 | @RequestMapping("login") 26 | public class LogRegController { 27 | @Autowired 28 | private RegLogServiceImp regLogServiceImp; 29 | 30 | //注册功能 31 | @RequestMapping("/getRegister") 32 | public RegResult Register(@RequestParam("username") String username, 33 | @RequestParam("email") String email, 34 | @RequestParam("password") String password, 35 | @RequestParam("phone") String phone) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { 36 | RegResult result = new RegResult(); 37 | System.out.println(username.length()); 38 | if(username.equals("") || email.equals("") || password.equals("") || phone.equals("")){ 39 | result.setStatus(404); 40 | result.setMsg("填写信息不全"); 41 | return result; 42 | } 43 | 44 | User user = regLogServiceImp.getUserByName(username); 45 | 46 | if (user != null) { 47 | result.setStatus(2002); 48 | result.setMsg("账号已存在,注册失败!"); 49 | } 50 | else { 51 | String userid = UUID.randomUUID().toString(); 52 | Map keyMap = RSAUtils.createKeys(512); 53 | String publicKey = keyMap.get("publicKey"); 54 | String privateKey = keyMap.get("privateKey"); 55 | 56 | //公钥加密 57 | String encodedData = RSAUtils.publicEncrypt(password,RSAUtils.getPublicKey(publicKey)); 58 | 59 | String date = DateUtil.ptfDate(); 60 | regLogServiceImp.insertUser(userid,username,email,encodedData,phone,"可用",date,privateKey); 61 | result.setStatus(200); 62 | result.setMsg("注册成功!"); 63 | } 64 | return result; 65 | } 66 | 67 | 68 | //登录验证 69 | @RequestMapping("/UserLogin") 70 | public LoginResult Login(@RequestParam("username") String username, 71 | @RequestParam("password") String password) throws IOException, InvalidKeySpecException, NoSuchAlgorithmException { 72 | User user = regLogServiceImp.getUserByUserName(username); 73 | LoginResult result = new LoginResult(); 74 | LoginData loginData = new LoginData(); 75 | if(user==null){ 76 | result.setMsg("无此用户,请重新输入正确用户名"); 77 | result.setStatus(2008); 78 | } 79 | else { 80 | if(RSAUtils.privateDecrypt(user.getPwd(), RSAUtils.getPrivateKey(user.getPrivatekey().trim())).equals(password)){ 81 | result.setStatus(0); 82 | String token = TokenUtil.token(user.getUserid().trim()); 83 | loginData.setToken(token); 84 | result.setMsg("登录成功"); 85 | result.setData(loginData); 86 | } 87 | else { 88 | result.setStatus(2007); 89 | result.setMsg("密码错误"); 90 | } 91 | } 92 | return result; 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/OrderController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | 4 | 5 | import com.zty.xiaomi.server.Entity.Order.*; 6 | import com.zty.xiaomi.server.Entity.User; 7 | import com.zty.xiaomi.server.Service.AlipayService; 8 | import com.zty.xiaomi.server.Service.Order.OrderServiceImp; 9 | import com.zty.xiaomi.server.Service.RegLogin.RegLogServiceImp; 10 | 11 | 12 | import com.alipay.api.AlipayApiException; 13 | import com.alipay.api.AlipayClient; 14 | import com.alipay.api.domain.AlipayTradePagePayModel; 15 | import com.alipay.api.internal.util.AlipaySignature; 16 | import com.alipay.api.request.AlipayTradePagePayRequest; 17 | import com.alipay.api.response.AlipayTradePagePayResponse; 18 | import org.springframework.beans.factory.annotation.Autowired; 19 | import org.springframework.web.bind.annotation.*; 20 | 21 | import javax.servlet.http.HttpServletRequest; 22 | import java.util.HashMap; 23 | import java.util.Map; 24 | import java.io.IOException; 25 | import java.util.List; 26 | 27 | @CrossOrigin 28 | @RestController 29 | @RequestMapping("orders") 30 | public class OrderController { 31 | 32 | @Autowired 33 | private OrderServiceImp orderServiceImp; 34 | 35 | @Autowired 36 | private RegLogServiceImp regLogServiceImp; 37 | 38 | @Autowired 39 | private AlipayService alipayService; 40 | 41 | @Autowired 42 | private Alipay alipay; 43 | 44 | 45 | @Autowired 46 | private AlipayClient alipayClient; 47 | 48 | @PostMapping("/createorder") 49 | public OrderResult createOrder(@RequestBody OrdCreaParm ordCreaParm) throws Exception { 50 | OrderResult orderResult = new OrderResult(); 51 | orderResult.setStatus(0); 52 | OrderList orderList = orderServiceImp.creatOrder(ordCreaParm); 53 | if(orderList.getOrderNo() == 0){ 54 | orderResult.setStatus(1); 55 | return orderResult; 56 | } 57 | orderResult.setData(orderList); 58 | return orderResult; 59 | } 60 | 61 | @RequestMapping("/getorderlist") 62 | public UserOrdListResult getUserOrdList(String username) throws IOException { 63 | 64 | UserOrdListResult userOrdListResult = new UserOrdListResult(); 65 | User user = regLogServiceImp.getUserByUserName(username); 66 | String userid = user.getUserid(); 67 | 68 | List orderList = orderServiceImp.getOrderList(userid); 69 | 70 | for(UserOrdList userOrdList:orderList){ 71 | int orderNo = userOrdList.getOrderNo(); 72 | List orderListItems = orderServiceImp.getOrderListItems(orderNo); 73 | userOrdList.setItems(orderListItems); 74 | } 75 | 76 | userOrdListResult.setStatus(0); 77 | userOrdListResult.setTotal(orderList.size()); 78 | userOrdListResult.setList(orderList); 79 | 80 | return userOrdListResult; 81 | 82 | } 83 | 84 | 85 | 86 | //下单成功后调用下面两个方法 87 | @RequestMapping("/getorder") 88 | public OrdFinaResult getOrder(@RequestParam("id") int id) throws IOException{ 89 | OrdFinaResult orderResult = new OrdFinaResult(); 90 | orderResult.setStatus(0); 91 | OrdFina orderList = orderServiceImp.getOrderById(id); 92 | orderResult.setOrdFina(orderList); 93 | return orderResult; 94 | } 95 | 96 | 97 | @RequestMapping("/getorderdetail") 98 | public OrdFinaResult getOrderDetail(@RequestParam("username") String username) throws IOException{ 99 | User user = regLogServiceImp.getUserByUserName(username); 100 | String userid = user.getUserid(); 101 | List orderItems = orderServiceImp.getOrderItems(userid); 102 | OrdFinaResult orderResult = new OrdFinaResult(); 103 | orderResult.setStatus(0); 104 | orderResult.setLists(orderItems); 105 | return orderResult; 106 | } 107 | 108 | @RequestMapping("/buy") 109 | public void buyOrder(@RequestParam("id") int id, 110 | @RequestParam("name") String username){ 111 | orderServiceImp.buyOrder(id,username); 112 | 113 | } 114 | 115 | @RequestMapping("/page") 116 | public String butrue(@RequestBody OrdPayParm ordPayParm) throws Exception { 117 | 118 | return alipayService.toPayPage(ordPayParm.getSubject(), ordPayParm.getOrderId(), ordPayParm.getTotal()); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Controller/ProductController.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Controller; 2 | 3 | import com.zty.xiaomi.server.Entity.Product.ProductResult; 4 | import com.zty.xiaomi.server.Service.Product.ProdServiceImp; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.web.bind.annotation.CrossOrigin; 7 | import org.springframework.web.bind.annotation.RequestMapping; 8 | import org.springframework.web.bind.annotation.RequestParam; 9 | import org.springframework.web.bind.annotation.RestController; 10 | import java.io.IOException; 11 | 12 | @CrossOrigin 13 | @RestController 14 | @RequestMapping("product") 15 | public class ProductController { 16 | 17 | @Autowired 18 | private ProdServiceImp prodServiceImp; 19 | @RequestMapping("getinfo") 20 | public ProductResult getProductInfo(@RequestParam("id") int id) throws IOException { 21 | ProductResult productResult = new ProductResult(); 22 | productResult.setStatus(0); 23 | productResult.setData(prodServiceImp.getProductInfo(id)); 24 | return productResult; 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Address/AddrResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Address; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AddrResult { 7 | private int status; 8 | private AddreList data; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Address/AddrSuccResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Address; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class AddrSuccResult { 7 | private int status; 8 | private String msg; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Address/Addre.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Address; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Addre { 7 | private int id; 8 | private String userid; 9 | private String username; 10 | private String receiverName; 11 | private String receiverMobile; 12 | private String receiverProvince; 13 | private String receiverCity; 14 | private String receiverAddress; 15 | private String receiverZip; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Address/AddreList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Address; 2 | 3 | import lombok.Data; 4 | import java.util.List; 5 | 6 | @Data 7 | public class AddreList { 8 | private int total; 9 | private List addreList; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/CartGood.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | import lombok.Data; 3 | 4 | @Data 5 | public class CartGood { 6 | private int count; 7 | private String goods_name; 8 | private String subtitle; 9 | private int price; 10 | private int status; 11 | private int productStock; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/CartGoodInsert.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CartGoodInsert { 7 | private String name; 8 | private int price; 9 | private int status; 10 | private String subtitle; 11 | private int productStock; 12 | private int sellcount; 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/CartResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CartResult { 7 | private int status; 8 | private cartProductVoList data; 9 | private int cartTotalPrice; 10 | private String imageHost; 11 | private boolean selectedAll; 12 | private int cartTotalQuantity; 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/cartProduct.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class cartProduct { 7 | private int good_id; 8 | private int count; 9 | private String goods_name; 10 | private String subtitle; 11 | private int price; 12 | private int Status; 13 | private int productTotalPrice; 14 | private int productStock; 15 | private boolean productSelected; 16 | 17 | } 18 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/cartProductVoList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class cartProductVoList { 9 | private List list; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Cart/pushCart.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Cart; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class pushCart { 7 | private String token; 8 | private int productId; 9 | private String username; 10 | private boolean select; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/CartGetGoodItem.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CartGetGoodItem { 7 | private int good_id; 8 | private String goods_name; 9 | private int price; 10 | private int count; 11 | private String pic_url; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/CartGetGoodList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | 8 | @Data public class CartGetGoodList { 9 | private List items; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Good.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class Good { 7 | private String name; 8 | private int price; 9 | private int oldPrice; 10 | private String description; 11 | private int sellCount; 12 | private int rating; 13 | private String info; 14 | private String icon; 15 | private String image; 16 | } 17 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/GoodAll.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class GoodAll { 9 | private String name; 10 | private int type; 11 | private List foods; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/GoodsAll.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | 7 | @Data 8 | public class GoodsAll { 9 | private int errno; 10 | ArrayList data; 11 | public GoodsAll(){ 12 | this.errno=0; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/LoginData.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LoginData { 7 | private String token; 8 | } 9 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/Alipay.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | import org.springframework.boot.context.properties.ConfigurationProperties; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Data 8 | @Component 9 | @ConfigurationProperties("alipay") 10 | public class Alipay { 11 | private String app_id; 12 | private String gatewayUrl; 13 | private String format; 14 | private String charset; 15 | private String sign_type; 16 | private String merchant_private_key; 17 | private String alipay_public_key; 18 | private String return_url; 19 | private String notify_url; 20 | } 21 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrdCreaParm.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class OrdCreaParm { 7 | private String name; 8 | private int shippingId; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrdFina.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class OrdFina { 7 | private int payment; 8 | private String receiverName; 9 | private String receiverMobile; 10 | private String receiverAddress; 11 | private String receiverCity; 12 | private String receiverProvince; 13 | private String receiverZip; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrdFinaResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class OrdFinaResult { 9 | private int status; 10 | private OrdFina ordFina; 11 | private List lists; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrdPayParm.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class OrdPayParm { 7 | private String subject; 8 | private String orderId; 9 | private String total; 10 | 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrderList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.Addre; 4 | import lombok.Data; 5 | 6 | import java.util.List; 7 | 8 | @Data 9 | public class OrderList { 10 | private int orderNo; 11 | private int payment; 12 | private int paymentType=1; 13 | private String paymentTypeDesc="在线支付"; 14 | private int postage=0;//邮费 15 | private int status; 16 | private String statusDesc; 17 | private String paymentTime; 18 | private String sendTime; 19 | private String endTime; 20 | private String closeTime; 21 | private String createTime; 22 | private List orderItemList; 23 | private String imageHost="www.mi.com"; 24 | private int shippingId; 25 | private String receiverName; 26 | private Addre shippingVo; 27 | } 28 | 29 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/OrderResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class OrderResult { 7 | private int status; 8 | private OrderList data; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/UserOrdItemList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class UserOrdItemList { 7 | private int productId; 8 | private String productName; 9 | private int currentUnitPrice; 10 | private int quantity; 11 | private int totalPrice; 12 | private String imgurl; 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/UserOrdList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class UserOrdList { 9 | private String createTime; 10 | private String receiverName; 11 | private int orderNo; 12 | private String paymentTypeDesc; 13 | private int payment; 14 | private int status; 15 | private String statusDesc; 16 | private List items; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/UserOrdListResone.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | public class UserOrdListResone { 4 | } 5 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/UserOrdListResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class UserOrdListResult { 9 | private List list; 10 | int total; 11 | private int status; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Order/orderItemVoList.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Order; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class orderItemVoList { 7 | private int orderNo; 8 | private int good_id; 9 | private String goods_name; 10 | private int price; 11 | private int count; 12 | private int productTotalPrice; 13 | private String productImage; 14 | private String createTime; 15 | } 16 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Product/ProductInfo.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Product; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ProductInfo { 7 | private String name; 8 | private String subtitle; 9 | private int price; 10 | private String desc1; 11 | private String desc2; 12 | private String p1; 13 | private String p2; 14 | } 15 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Product/ProductResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Product; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ProductResult { 7 | private int status; 8 | private ProductInfo data; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/ProductFoot/ProductFootInfo.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.ProductFoot; 2 | 3 | import lombok.Data; 4 | 5 | import java.io.Serializable; 6 | 7 | @Data 8 | public class ProductFootInfo implements Serializable { 9 | private int good_id; 10 | private String subtitle; 11 | private String name; 12 | private int price; 13 | private int oldprice; 14 | private String imageFoot; 15 | } -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/ProductFoot/ProductFootResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.ProductFoot; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class ProductFootResult { 9 | private int status; 10 | private List data; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/ProductHead/ProductHeadInfo.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.ProductHead; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ProductHeadInfo { 7 | private int good_id; 8 | private String name; 9 | private int price; 10 | private String imageHead; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/ProductHead/ProductHeadResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.ProductHead; 2 | 3 | import lombok.Data; 4 | import java.util.List; 5 | 6 | @Data 7 | public class ProductHeadResult { 8 | private int status; 9 | private List data; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Suggest/SuggestBig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Suggest; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SuggestBig { 7 | private String name; 8 | private int category_id; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Suggest/SuggestFoot.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Suggest; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SuggestFoot { 7 | private int goodid; 8 | private String imgUrl; 9 | private String name; 10 | private int price; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/Suggest/SuggestFootResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.Suggest; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.List; 6 | 7 | @Data 8 | public class SuggestFootResult { 9 | private int status; 10 | private List sugglist; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/User.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class User { 7 | private String userid; 8 | private String name; 9 | private String email; 10 | private String tel; 11 | private String pwd; 12 | private String privatekey; 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/index/Categor.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.index; 2 | 3 | import lombok.Data; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | @Data 7 | public class Categor { 8 | private int categoryId; 9 | private String name; 10 | private ArrayList> menuList; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/index/CategorData.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.index; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.ArrayList; 6 | 7 | @Data 8 | public class CategorData { 9 | private ArrayList cateList; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/index/CategoryGood.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.index; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CategoryGood { 7 | private int good_id; 8 | private String icon; 9 | private String name; 10 | } 11 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/index/CategoryResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.index; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class CategoryResult { 7 | private int status; 8 | private CategorData data; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Entity/index/GoodCategory.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Entity.index; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class GoodCategory { 7 | private String name; 8 | private int categoryId; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Address.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.Addre; 4 | import org.apache.ibatis.annotations.Delete; 5 | import org.apache.ibatis.annotations.Insert; 6 | import org.apache.ibatis.annotations.Select; 7 | import org.apache.ibatis.annotations.Update; 8 | import org.springframework.stereotype.Component; 9 | 10 | import java.util.List; 11 | 12 | @Component 13 | public interface Address { 14 | @Insert("insert into address(userid,receiverName,receiverMobile,receiverProvince,receiverCity,receiverAddress,receiverZip)" + 15 | " values(#{userid},#{receiverName},#{receiverMobile},#{receiverProvince}" + 16 | ",#{receiverCity},#{receiverAddress},#{receiverZip})") 17 | void inseAddre(String userid,String receiverName,String receiverMobile,String receiverProvince, String receiverCity,String receiverAddress,String receiverZip); 18 | 19 | @Update("update address set receiverName = #{receiverName},receiverMobile = #{receiverMobile},receiverProvince=" + 20 | "#{receiverProvince},receiverCity= #{receiverCity},receiverAddress= #{receiverAddress} ,receiverZip= #{receiverZip}" + 21 | "where id = #{id} and userid like #{userid}") 22 | void updateAddre(String userid,int id ,String receiverName,String receiverMobile,String receiverProvince, 23 | String receiverCity,String receiverAddress,String receiverZip); 24 | 25 | @Delete("delete from address where id = #{id}") 26 | void deleteAddre(int id); 27 | 28 | @Select("select * from address where userid like #{userid}") 29 | List getAll(String userid); 30 | 31 | } 32 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Category.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.index.GoodCategory; 4 | import com.zty.xiaomi.server.Entity.index.CategoryGood; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface Category { 12 | 13 | @Select("select good_id,icon,name from goods where category_id = #{category_id}") 14 | List getGoodbyCategory(int category_id); 15 | 16 | // @Select("select good_id,icon,name from goods where category_id = #{category_id}" + 17 | // " and good_id between #{start} and #{end}") 18 | // List getGoodbyCategory(int category_id,int start,int end); 19 | 20 | @Select("select count(*) from category") 21 | int getCateCount(); 22 | 23 | @Select("select categoryId,name from category where categoryId = #{category_id}") 24 | GoodCategory getGoodCategory(int category_id); 25 | } 26 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/GoodCart.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Cart.CartGoodInsert; 4 | import com.zty.xiaomi.server.Entity.Cart.cartProduct; 5 | import com.zty.xiaomi.server.Entity.Cart.CartGood; 6 | import org.apache.ibatis.annotations.Delete; 7 | import org.apache.ibatis.annotations.Insert; 8 | import org.apache.ibatis.annotations.Select; 9 | import org.apache.ibatis.annotations.Update; 10 | import org.springframework.stereotype.Component; 11 | 12 | import java.util.List; 13 | 14 | @Component 15 | public interface GoodCart { 16 | @Select("select count,goods_name,subtitle,price,status,productStock from cart where user_id like #{userid} and good_id = #{id}") 17 | CartGood getGoodByid(String userid, int id); 18 | 19 | @Delete("delete from cart where user_id like #{userid} and good_id = #{id}") 20 | void delGoodByid(String userid,int id); 21 | 22 | @Delete("delete from cart where user_id like #{userid}") 23 | void delGoodByname(String userid); 24 | 25 | @Select("select name,price,subtitle,status,productStock from goods where good_id = #{goodid}") 26 | CartGoodInsert getGoodByidinsert(int goodid); 27 | 28 | @Update("update cart set count = #{count},productSelected = #{select},productTotalPrice = #{totalprice} where user_id like #{userid} and good_id = #{goodid}") 29 | void updaCartNumSel(String userid,int goodid,int count,boolean select,int totalprice); 30 | 31 | @Update("update cart set productSelected = true where user_id like #{userid}") 32 | void updaCartSelect(String userid); 33 | 34 | @Update("update cart set productSelected = false where user_id like #{userid}") 35 | void updaCartunSelect(String userid); 36 | 37 | @Insert("insert into cart(user_id,good_id,goods_name,price,count," + 38 | "Subtitle,ProductStock,Status,productSelected,productTotalPrice)" + 39 | " values(#{userid},#{goodid},#{goodname},#{price},#{count}" + 40 | ",#{Subtitle},#{ProductStock},#{Status},#{select},#{totalprice})") 41 | void insCartGood(String userid,int goodid,String goodname,int price, 42 | int count, String Subtitle,int ProductStock,int Status,boolean select,int totalprice); 43 | 44 | @Update("update cart set count = #{count},productTotalPrice = #{totalprice} where user_id like #{userid} and good_id = #{goodid}") 45 | void updateCartGood(String userid,int count,int goodid,int totalprice); 46 | 47 | // @Select("select good_id,goods_name,price,count,pic_url from cart where user_id like #{userid}") 48 | // List getCartGood(String userid); 49 | 50 | @Select("select good_id,count,goods_name,price,subtitle,Status," + 51 | "productTotalPrice,productStock,productSelected from cart where user_id like #{userid}") 52 | List getcartProduct(String userid); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Goods.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Good; 4 | import com.zty.xiaomi.server.Entity.index.GoodCategory; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface Goods { 12 | @Select("select name,price,oldPrice,description,sellcount,rating,info,icon,image from goods where category_id = #{category_id}") 13 | List getGood(int category_id); 14 | @Select("select name,type from category where category_id = #{category_id}") 15 | GoodCategory getGoodCategory(int category_id); 16 | } 17 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Order.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.Addre; 4 | import com.zty.xiaomi.server.Entity.Order.OrdFina; 5 | import com.zty.xiaomi.server.Entity.Order.UserOrdItemList; 6 | import com.zty.xiaomi.server.Entity.Order.UserOrdList; 7 | import com.zty.xiaomi.server.Entity.Order.orderItemVoList; 8 | import org.apache.ibatis.annotations.Delete; 9 | import org.apache.ibatis.annotations.Insert; 10 | import org.apache.ibatis.annotations.Select; 11 | import org.apache.ibatis.annotations.Update; 12 | import org.springframework.stereotype.Component; 13 | 14 | import java.util.List; 15 | 16 | @Component 17 | public interface Order { 18 | 19 | @Select("select good_id,goods_name,price,count,productTotalPrice from cart where user_id like #{userid} and status = 1") 20 | List getOrderItems(String userid); 21 | 22 | @Select("select * from address where userid like #{userid} and id = #{id}") 23 | Addre getAddre(String userid, int id); 24 | 25 | @Insert("insert into orde(hostid,orderNo,payment,paymentType,paymentTypeDesc,postage,status,statusDesc" + 26 | ",paymentTime,endTime,createTime,imageHost,shippingId,receiverName,receiverMobile,receiverProvince,receiverCity,receiverAddress,receiverZip) values(#{userid},#{orderNo},#{payment},#{paymentType}," + 27 | "#{paymentTypeDesc},#{postage},#{status},#{statusDesc},#{paymentTime},#{endTime},#{createTime},#{imageHost},#{shippingid},#{receiveName},#{receiveMobile},#{receiveProvince},#{receiverCity}," + 28 | "#{receiverAddress},#{receiverZip})") 29 | void insOrder(String userid,int orderNo,int payment,int paymentType,String paymentTypeDesc,int postage, 30 | int status,String statusDesc,String paymentTime,String endTime, 31 | String createTime,String imageHost,int shippingid,String receiveName, 32 | String receiveMobile, String receiveProvince,String receiverCity,String receiverAddress,String receiverZip); 33 | 34 | @Insert("insert into ordergood(orderNo,productId,productName,currentUnitPrice,quantity,totalPrice,status,imgurl) values" + 35 | "(#{orderNo},#{productId},#{productName},#{currentUnitPrice},#{quantity},#{totalPrice},#{status},#{imgurl})") 36 | void insOrderGood(int orderNo,int productId,String productName,int currentUnitPrice,int quantity,int totalPrice,int status,String imgurl); 37 | 38 | @Select("select orderNo,payment,receiverName,receiverMobile,receiverAddress,receiverCity,receiverProvince,receiverZip from orde where orderNo = #{id}") 39 | OrdFina getOrderById(int id); 40 | 41 | @Select("select createTime,receiverName,orderNo,paymentTypeDesc,payment,status,statusDesc from orde where hostid like #{userId}") 42 | List getUserOrdList(String userId); 43 | 44 | @Select("select productId,productName,currentUnitPrice,quantity,totalPrice,imgurl from ordergood where orderNo = #{orderNo}") 45 | List getOrdItems(int orderNo); 46 | 47 | @Select("select imageFoot from goods where good_id = #{productId}") 48 | String getOrderImg(int productId); 49 | 50 | @Update("update orde set status = 1,statusDesc = '已支付' where orderNo = #{id}") 51 | void buyOrder(int id); 52 | 53 | @Select("select status from orde where orderNo = #{id}") 54 | int getOrderStatus(int id); 55 | 56 | @Delete("delete from orde where orderNo = #{orderNo}") 57 | void delOrde(int orderNo); 58 | 59 | @Delete("delete from ordergood where orderNo = #{orderNo}") 60 | void delOrder(int orderNo); 61 | 62 | @Update("update goods set productStock = #{count} where #{count} >= 0 and good_id = #{goodid}") 63 | int chanProdStock(int goodid,int proStock,int count); 64 | 65 | @Update("update goods set sellcount = #{after} where good_id = #{goodid}") 66 | void addSellCount(int goodid,int after); 67 | 68 | @Select("select productStock from goods where good_id = #{goodid}") 69 | int getProdStock(int goodid); 70 | 71 | @Select("select sellcount from goods where good_id = #{goodid}") 72 | int getProdSellCount(int goodid); 73 | 74 | 75 | @Update("update goods set productStock = #{count} where good_id = #{productid}") 76 | void rollbackStock(int productid,int count); 77 | 78 | @Update("update goods set sellcount = #{count} where good_id = #{productid}") 79 | void rollbackSellCount(int productid,int count); 80 | 81 | @Update("update orde set paymentTime = #{time} where orderNo = #{orderNo}") 82 | void updOrderTime(int orderNo,String time); 83 | } 84 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Product.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Product.ProductInfo; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Component; 6 | 7 | @Component 8 | public interface Product { 9 | @Select("select name,subtitle,price,desc1,desc2,p1,p2 from goods where good_id= #{id}") 10 | ProductInfo getProductInfoById(int id); 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/ProductFoot.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.ProductFoot.ProductFootInfo; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | public interface ProductFoot { 11 | @Select("select good_id,price,oldprice,name,imageFoot,subtitle from goods where name like #{goodname}") 12 | ProductFootInfo getProductFootInfo(String goodname); 13 | 14 | @Select("select good_id,price,oldprice,name,imageFoot,subtitle" + 15 | " from goods where category_id = #{category_id} limit 7") 16 | List getProductFootInfoNormal(int category_id); 17 | } 18 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/ProductHead.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.ProductHead.ProductHeadInfo; 4 | import org.apache.ibatis.annotations.Select; 5 | import org.springframework.stereotype.Component; 6 | 7 | import java.util.List; 8 | 9 | @Component 10 | public interface ProductHead { 11 | @Select("select good_id,name,imageHead,price from goods where category_id = #{categoryId}") 12 | List getProductHeadInfo(int categoryId); 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/RegLogUser.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.User; 4 | import org.apache.ibatis.annotations.Insert; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.springframework.stereotype.Component; 7 | 8 | @Component 9 | public interface RegLogUser { 10 | @Select("select userid,name,email,pwd,tel from userinfo where name like #{username}") 11 | User getUserByName(String username); 12 | 13 | @Select("select userid,name,email,pwd,tel,privatekey from userinfo where name like #{username}") 14 | User getUserByUserName(String username); 15 | 16 | @Insert("insert into userinfo values(#{userid},#{name},#{email},#{pwd},#{phone},#{status},#{date},#{prikey})") 17 | void insertUser(String userid, String name, String email, String pwd, 18 | String phone, String status,String date,String prikey); 19 | 20 | 21 | } 22 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Mapper/Suggest.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Mapper; 2 | 3 | import com.zty.xiaomi.server.Entity.Suggest.SuggestBig; 4 | import com.zty.xiaomi.server.Entity.Suggest.SuggestFoot; 5 | import org.apache.ibatis.annotations.Select; 6 | import org.springframework.stereotype.Component; 7 | 8 | import java.util.List; 9 | 10 | @Component 11 | public interface Suggest { 12 | 13 | @Select("select * from goodsuggefoot") 14 | List getSuggest(); 15 | 16 | @Select("select * from goodsuggebig where category_id = #{categoryId}") 17 | List getSuggestBig(int categoryId); 18 | } 19 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/ServerApplication.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server; 2 | 3 | import org.mybatis.spring.annotation.MapperScan; 4 | import org.springframework.boot.SpringApplication; 5 | import org.springframework.boot.autoconfigure.SpringBootApplication; 6 | import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration; 7 | import org.springframework.cache.annotation.EnableCaching; 8 | import org.springframework.transaction.annotation.EnableTransactionManagement; 9 | 10 | 11 | @SpringBootApplication(exclude= {DataSourceAutoConfiguration.class}) 12 | @EnableCaching 13 | @EnableTransactionManagement 14 | @MapperScan("com.zty.xiaomi.server.Mapper,com.alipay.api") 15 | 16 | public class ServerApplication { 17 | 18 | public static void main(String[] args) { 19 | SpringApplication.run(ServerApplication.class, args); 20 | } 21 | 22 | } 23 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Address/AddService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Address; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.AddrResult; 4 | import com.zty.xiaomi.server.Entity.Address.AddrSuccResult; 5 | import com.zty.xiaomi.server.Entity.Address.Addre; 6 | import org.apache.ibatis.session.SqlSession; 7 | import java.io.IOException; 8 | 9 | public interface AddService { 10 | 11 | AddrSuccResult inseAddre(Addre addre) throws IOException; 12 | AddrResult getAll(String userid) throws IOException; 13 | AddrSuccResult updaAddre(Addre addre) throws IOException; 14 | AddrSuccResult deleAddre(int id) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Address/AddServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Address; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.AddrResult; 4 | import com.zty.xiaomi.server.Entity.Address.AddrSuccResult; 5 | import com.zty.xiaomi.server.Entity.Address.Addre; 6 | import com.zty.xiaomi.server.Entity.Address.AddreList; 7 | import com.zty.xiaomi.server.Mapper.Address; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class AddServiceImp implements AddService { 15 | 16 | @Autowired 17 | private Address addressmapper; 18 | 19 | @Override 20 | public AddrSuccResult inseAddre(Addre addre) { 21 | AddrSuccResult addrSuccResult = new AddrSuccResult(); 22 | addrSuccResult.setStatus(0); 23 | addrSuccResult.setMsg("新建地址成功"); 24 | addressmapper.inseAddre(addre.getUserid(),addre.getReceiverName(),addre.getReceiverMobile(),addre.getReceiverProvince(),addre.getReceiverCity(),addre.getReceiverAddress(),addre.getReceiverZip()); 25 | return addrSuccResult; 26 | } 27 | 28 | @Override 29 | public AddrResult getAll(String userid) { 30 | AddrResult addrResult = new AddrResult(); 31 | addrResult.setStatus(0); 32 | AddreList addreList = new AddreList(); 33 | List addres = addressmapper.getAll(userid); 34 | if (addres == null) 35 | addreList.setTotal(0); 36 | else { 37 | addreList.setTotal(addres.toArray().length); 38 | addreList.setAddreList(addres); 39 | } 40 | addrResult.setData(addreList); 41 | return addrResult; 42 | } 43 | 44 | @Override 45 | public AddrSuccResult updaAddre(Addre addre){ 46 | AddrSuccResult addrSuccResult = new AddrSuccResult(); 47 | addrSuccResult.setStatus(0); 48 | addrSuccResult.setMsg("更新地址成功"); 49 | addressmapper.updateAddre(addre.getUserid(),addre.getId(),addre.getReceiverName(),addre.getReceiverMobile(), addre.getReceiverProvince(),addre.getReceiverCity(),addre.getReceiverAddress(),addre.getReceiverZip()); 50 | return addrSuccResult; 51 | } 52 | 53 | @Override 54 | public AddrSuccResult deleAddre(int id) { 55 | AddrSuccResult addrSuccResult = new AddrSuccResult(); 56 | addrSuccResult.setStatus(0); 57 | addrSuccResult.setMsg("删除地址成功"); 58 | addressmapper.deleteAddre(id); 59 | return addrSuccResult; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/AlipayService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service; 2 | 3 | 4 | import com.alipay.easysdk.factory.Factory; 5 | import com.alipay.easysdk.payment.page.models.AlipayTradePagePayResponse; 6 | import com.zty.xiaomi.server.Config.AlipayConfig; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.stereotype.Service; 9 | 10 | @Service 11 | public class AlipayService { 12 | @Autowired 13 | private AlipayConfig alipayConfig; 14 | 15 | /** 16 | * 电脑版支付 17 | * 18 | * @param subject 标题 19 | * @param orderId 订单ID 20 | * @param total 金额 21 | * @return 22 | * @throws Exception 23 | */ 24 | public String toPayPage(String subject, String orderId, String total) throws Exception { 25 | AlipayTradePagePayResponse response = Factory.Payment.Page().pay(subject, orderId, total, alipayConfig.return_url); 26 | return response.getBody(); 27 | } 28 | 29 | 30 | } 31 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Cart/CartService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Cart; 2 | 3 | import com.zty.xiaomi.server.Entity.Cart.cartProductVoList; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | 8 | public interface CartService { 9 | 10 | cartProductVoList getCartProduct(String userid) throws IOException; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Cart/CartServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Cart; 2 | 3 | import ch.qos.logback.classic.Logger; 4 | import com.zty.xiaomi.server.Entity.Cart.cartProduct; 5 | import com.zty.xiaomi.server.Entity.Cart.cartProductVoList; 6 | import com.zty.xiaomi.server.Mapper.GoodCart; 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.cache.annotation.Cacheable; 9 | import org.springframework.stereotype.Service; 10 | 11 | import java.util.List; 12 | 13 | @Service 14 | public class CartServiceImp implements CartService{ 15 | 16 | @Autowired 17 | private GoodCart goodCartmapper; 18 | 19 | @Cacheable(value = "cart",key = "'cart'+#userid",unless = "#result==null") 20 | @Override 21 | public cartProductVoList getCartProduct(String userid) { 22 | cartProductVoList cartProductVoList = new cartProductVoList(); 23 | List cartProducts = goodCartmapper.getcartProduct(userid); 24 | if(cartProducts.isEmpty()){ 25 | return null; 26 | } 27 | cartProductVoList.setList(cartProducts); 28 | return cartProductVoList; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Category/CategoryIndex.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Category; 2 | 3 | import com.zty.xiaomi.server.Entity.index.CategoryResult; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | 8 | public interface CategoryIndex { 9 | 10 | 11 | int getCateCount() throws IOException; 12 | CategoryResult getCategoryGoods() throws IOException; 13 | } 14 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Category/CategoryIndexImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Category; 2 | 3 | import com.zty.xiaomi.server.Mapper.Category; 4 | import com.zty.xiaomi.server.Entity.index.*; 5 | 6 | import org.apache.ibatis.io.Resources; 7 | import org.apache.ibatis.session.SqlSession; 8 | import org.apache.ibatis.session.SqlSessionFactory; 9 | import org.apache.ibatis.session.SqlSessionFactoryBuilder; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.cache.annotation.Cacheable; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.util.ArrayList; 17 | import java.util.List; 18 | 19 | @Service 20 | public class CategoryIndexImp implements CategoryIndex { 21 | 22 | @Autowired 23 | private Category category; 24 | @Override 25 | public int getCateCount() throws IOException { 26 | // SqlSession sqlSession = ; 27 | int cateCount = category.getCateCount(); 28 | return cateCount; 29 | } 30 | 31 | @Cacheable(value = "category",key = "'category'") 32 | @Override 33 | public CategoryResult getCategoryGoods() throws IOException { 34 | // SqlSession sqlSession = ; 35 | CategoryResult categoryResult = new CategoryResult(); 36 | categoryResult.setStatus(0); 37 | 38 | CategorData categorData = new CategorData(); 39 | 40 | int categoryCount=getCateCount(); 41 | ArrayList categors = new ArrayList<>(categoryCount); 42 | 43 | for (int i = 1; i <=categoryCount ; i++) { 44 | Categor categor = new Categor(); 45 | GoodCategory goodCategory = category.getGoodCategory(i); 46 | categor.setCategoryId(goodCategory.getCategoryId()); 47 | categor.setName(goodCategory.getName()); 48 | 49 | List goodbyCategory = category.getGoodbyCategory(i); 50 | 51 | int compleKind= goodbyCategory.size()/4; 52 | 53 | ArrayList> lists = new ArrayList<>(1); 54 | 55 | for(int j=1;j<=compleKind;j++){ 56 | ArrayList compleGoods = new ArrayList<>(4); 57 | compleGoods.add(goodbyCategory.get((j-1)*4)); 58 | compleGoods.add(goodbyCategory.get((j-1)*4 + 1)); 59 | compleGoods.add(goodbyCategory.get((j-1)*4 + 2)); 60 | compleGoods.add(goodbyCategory.get((j-1)*4 + 3)); 61 | 62 | lists.add(compleGoods);//四个一组完整的加入lists中 63 | } 64 | 65 | //表示不能整除4最后的剩余(0 uncomplGoods = new ArrayList<>(4); 69 | for(int k=0;k< nocomple;k++){ 70 | uncomplGoods.add(goodbyCategory.get(4*compleKind+k)); 71 | } 72 | 73 | lists.add(uncomplGoods); 74 | } 75 | 76 | categor.setMenuList(lists); 77 | 78 | categors.add(categor); 79 | } 80 | 81 | categorData.setCateList(categors); 82 | categoryResult.setData(categorData); 83 | return categoryResult; 84 | 85 | // for (int i = 1; i <= 8; i++) { 86 | // Categor categor = new Categor(); 87 | // GoodCategory goodCategory = sqlSession.getMapper(Category.class).getGoodCategory(i); 88 | // 89 | // //后续每个分类中暑扩大后再改初始扩容1,现在只有4个 90 | // ArrayList> lists = new ArrayList<>(1); 91 | // int end= (i-1) * 12 + 8; 92 | // for(int j=(i-1)*12+1;j<=end;j+=4){ 93 | // int k=j+3; 94 | // List goodbyCategory = sqlSession.getMapper(Category.class).getGoodbyCategory(i, j, k); 95 | // lists.add(goodbyCategory); 96 | // } 97 | // categor.setCategoryId(goodCategory.getCategoryId()); 98 | // categor.setName(goodCategory.getName()); 99 | // categor.setMenuList(lists); 100 | // categors.add(categor); 101 | // } 102 | // categorData.setCateList(categors); 103 | // categoryResult.setData(categorData); 104 | // return categoryResult; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Good/GoodService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Good; 2 | 3 | import com.zty.xiaomi.server.Entity.Cart.CartGoodInsert; 4 | import com.zty.xiaomi.server.Entity.Cart.cartProduct; 5 | import com.zty.xiaomi.server.Entity.Cart.CartGood; 6 | import com.zty.xiaomi.server.Entity.Good; 7 | import com.zty.xiaomi.server.Entity.index.GoodCategory; 8 | import org.apache.ibatis.session.SqlSession; 9 | 10 | import java.io.IOException; 11 | import java.util.List; 12 | 13 | public interface GoodService { 14 | 15 | 16 | List getGood(int categoryid) throws IOException; 17 | 18 | GoodCategory getGoodCategory(int categoryid) throws IOException; 19 | 20 | CartGood getGoodByid(String userid,int id) throws IOException; 21 | 22 | void delGoodByid(String userid,int id) throws IOException; 23 | 24 | CartGoodInsert getGoodByidinsert(int goodid) throws IOException; 25 | 26 | void updaCartNumSel(String userid,int goodid,int count,boolean select,int totalprice) throws IOException; 27 | 28 | void updaCartSelect(String userid) throws IOException; 29 | 30 | void updaCartunSelect(String userid) throws IOException; 31 | 32 | List getGoodByuser(String userid) throws IOException; 33 | 34 | void updateCartGood(String userid,int count,int goodid,int totalprice) throws IOException; 35 | 36 | void insCartGood(String userid,int goodid,String goodname,int price, 37 | int count, String Subtitle,int ProductStock,int Status,boolean select 38 | ) throws IOException; 39 | // 40 | // List getCartGood(String userid) throws IOException; 41 | } 42 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Good/GoodServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Good; 2 | 3 | import com.zty.xiaomi.server.Entity.Cart.CartGood; 4 | import com.zty.xiaomi.server.Entity.Cart.CartGoodInsert; 5 | import com.zty.xiaomi.server.Entity.Cart.cartProduct; 6 | import com.zty.xiaomi.server.Entity.Good; 7 | import com.zty.xiaomi.server.Entity.index.GoodCategory; 8 | import com.zty.xiaomi.server.Mapper.GoodCart; 9 | import com.zty.xiaomi.server.Mapper.Goods; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.cache.annotation.CacheEvict; 12 | import org.springframework.cache.annotation.CachePut; 13 | import org.springframework.cache.annotation.Cacheable; 14 | import org.springframework.stereotype.Service; 15 | import java.util.List; 16 | 17 | @Service 18 | public class GoodServiceImp implements GoodService { 19 | 20 | @Autowired 21 | private Goods goodsmapper; 22 | @Autowired 23 | private GoodCart goodCartmapper; 24 | 25 | @Override 26 | public List getGood(int categoryid) { 27 | List goodList = goodsmapper.getGood(categoryid); 28 | return goodList; 29 | } 30 | 31 | @Override 32 | public GoodCategory getGoodCategory(int categoryid) { 33 | GoodCategory goodCategory = goodsmapper.getGoodCategory(categoryid); 34 | return goodCategory; 35 | } 36 | 37 | @Override 38 | public CartGood getGoodByid(String userid, int id) { 39 | CartGood cartGood = goodCartmapper.getGoodByid(userid,id); 40 | return cartGood; 41 | } 42 | 43 | @CacheEvict(value = "cart",key = "'cart'+#userid") 44 | @Override 45 | public void delGoodByid(String userid, int id) { 46 | goodCartmapper.delGoodByid(userid,id); 47 | } 48 | 49 | 50 | @Override 51 | public CartGoodInsert getGoodByidinsert(int goodid) { 52 | CartGoodInsert cartGoodInsert = goodCartmapper.getGoodByidinsert(goodid); 53 | return cartGoodInsert; 54 | } 55 | 56 | 57 | @CacheEvict(value = "cart",key = "'cart'+#userid") 58 | @Override 59 | public void updaCartNumSel(String userid, int goodid, int count, boolean select,int totalprice) { 60 | goodCartmapper.updaCartNumSel(userid, goodid, count, select,totalprice); 61 | } 62 | 63 | @CacheEvict(value = "cart",key = "'cart'+#userid") 64 | @Override 65 | public void updaCartSelect(String userid) { 66 | goodCartmapper.updaCartSelect(userid); 67 | } 68 | 69 | @CacheEvict(value = "cart",key = "'cart'+#userid") 70 | @Override 71 | public void updaCartunSelect(String userid) { 72 | goodCartmapper.updaCartunSelect(userid); 73 | } 74 | 75 | @Override 76 | public List getGoodByuser(String userid) { 77 | List cartgoods = goodCartmapper.getcartProduct(userid); 78 | return cartgoods; 79 | } 80 | 81 | @CacheEvict(value = "cart",key = "'cart'+#userid") 82 | @Override 83 | public void updateCartGood(String userid,int count,int goodid,int totalprice) { 84 | goodCartmapper.updateCartGood(userid,count,goodid,totalprice); 85 | } 86 | 87 | @CacheEvict(value = "cart",key = "'cart'+#userid") 88 | @Override 89 | public void insCartGood(String userid, int goodid, String goodname, int price, int count, 90 | String Subtitle,int ProductStock,int Status,boolean select 91 | ) { 92 | goodCartmapper.insCartGood(userid,goodid,goodname,price,count,Subtitle,ProductStock,Status,select,count*price); 93 | } 94 | 95 | } 96 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Order/OrderService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Order; 2 | 3 | import com.zty.xiaomi.server.Entity.Address.Addre; 4 | import com.zty.xiaomi.server.Entity.Order.*; 5 | import org.apache.ibatis.session.SqlSession; 6 | 7 | import java.io.IOException; 8 | import java.util.List; 9 | 10 | public interface OrderService { 11 | 12 | OrderList creatOrder(OrdCreaParm ordCreaParm) throws IOException, Exception; 13 | 14 | int getOrderStatus(int orderid); 15 | 16 | void delOrder(int orderid); 17 | 18 | List getOrderItems(String userid) throws IOException; 19 | 20 | Addre getAdd(String userid, int id) throws IOException; 21 | 22 | OrdFina getOrderById(int id) throws IOException; 23 | 24 | List getOrderList(String userid) throws IOException; 25 | 26 | List getOrderListItems(int orderId) throws IOException; 27 | 28 | void buyOrder(int id,String username); 29 | 30 | 31 | 32 | 33 | 34 | } 35 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/ProdFoot/ProdFoot.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.ProdFoot; 2 | 3 | import com.zty.xiaomi.server.Entity.ProductFoot.ProductFootInfo; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | import java.util.List; 8 | 9 | public interface ProdFoot { 10 | 11 | 12 | List getProductFootInfo(int categoryId) throws IOException; 13 | 14 | List getProductFootInfoNormal(int category_id) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/ProdFoot/ProductFootImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.ProdFoot; 2 | 3 | import com.zty.xiaomi.server.Entity.ProductFoot.ProductFootInfo; 4 | import com.zty.xiaomi.server.Entity.Suggest.SuggestBig; 5 | import com.zty.xiaomi.server.Mapper.ProductFoot; 6 | import com.zty.xiaomi.server.Mapper.Suggest; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.springframework.beans.factory.annotation.Autowired; 10 | import org.springframework.cache.annotation.Cacheable; 11 | import org.springframework.cache.annotation.EnableCaching; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.io.IOException; 15 | import java.util.ArrayList; 16 | import java.util.List; 17 | 18 | @Service 19 | @EnableCaching 20 | public class ProductFootImp implements ProdFoot { 21 | 22 | @Autowired 23 | private Suggest suggest; 24 | 25 | @Autowired 26 | private ProductFoot productFootmapper; 27 | 28 | private Logger logger = LoggerFactory.getLogger(this.getClass()); 29 | 30 | @Cacheable(value = "pflists",key = "'pflist'+#categoryId") 31 | @Override 32 | public List getProductFootInfo(int categoryId) { 33 | 34 | ArrayList suggestBigs = new ArrayList<>(); 35 | if (categoryId == 1) { 36 | List suggestBig1 = suggest.getSuggestBig(1); 37 | suggestBigs.addAll(suggestBig1); 38 | } else if (categoryId == 2) { 39 | List suggestBig2 = suggest.getSuggestBig(2); 40 | List suggestBig4 = suggest.getSuggestBig(4); 41 | suggestBigs.addAll(suggestBig2); 42 | suggestBigs.addAll(suggestBig4); 43 | } else if (categoryId == 3) { 44 | List suggestBig5 = suggest.getSuggestBig(5); 45 | List suggestBig9 = suggest.getSuggestBig(9); 46 | suggestBigs.addAll(suggestBig5); 47 | suggestBigs.addAll(suggestBig9); 48 | } else if (categoryId == 4) { 49 | List suggestBig7 = suggest.getSuggestBig(7); 50 | suggestBigs.addAll(suggestBig7); 51 | } else if (categoryId == 5) { 52 | List suggestBig6 = suggest.getSuggestBig(6); 53 | suggestBigs.addAll(suggestBig6); 54 | } else if (categoryId == 6) { 55 | List suggestBig5 = suggest.getSuggestBig(5); 56 | List suggestBig8 = suggest.getSuggestBig(8); 57 | suggestBigs.addAll(suggestBig5); 58 | suggestBigs.addAll(suggestBig8); 59 | } 60 | 61 | ArrayList suggestBigNames = new ArrayList<>(); 62 | for (SuggestBig suggestBig : suggestBigs) { 63 | suggestBigNames.add(suggestBig.getName()); 64 | } 65 | 66 | //数据库查出的数据 67 | logger.info("findAll -> 从数据库中读取放入缓存中"); 68 | 69 | ArrayList productFootInfos = new ArrayList<>(); 70 | for (String suggestBigName : suggestBigNames) { 71 | ProductFootInfo productInfoById = productFootmapper.getProductFootInfo(suggestBigName); 72 | productFootInfos.add(productInfoById); 73 | } 74 | 75 | return productFootInfos; 76 | } 77 | 78 | @Override 79 | public List getProductFootInfoNormal(int category_id) throws IOException { 80 | List productFootInfoNormal = productFootmapper.getProductFootInfoNormal(category_id); 81 | return productFootInfoNormal; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/ProdHead/ProdHead.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.ProdHead; 2 | 3 | import com.zty.xiaomi.server.Entity.ProductHead.ProductHeadInfo; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | import java.util.List; 8 | 9 | public interface ProdHead { 10 | 11 | List getProductHeadInfo(int categoryId) throws IOException; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/ProdHead/ProductHeadImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.ProdHead; 2 | 3 | import com.zty.xiaomi.server.Mapper.ProductHead; 4 | import com.zty.xiaomi.server.Entity.ProductHead.ProductHeadInfo; 5 | 6 | import org.apache.ibatis.io.Resources; 7 | import org.apache.ibatis.session.SqlSession; 8 | import org.apache.ibatis.session.SqlSessionFactory; 9 | import org.apache.ibatis.session.SqlSessionFactoryBuilder; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.cache.annotation.Cacheable; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.util.List; 17 | 18 | @Service 19 | public class ProductHeadImp implements ProdHead { 20 | @Autowired 21 | private ProductHead productHead; 22 | 23 | @Cacheable(value = "phlist",key = "'phlist'+#categoryId") 24 | @Override 25 | public List getProductHeadInfo(int categoryId) throws IOException { 26 | 27 | List productInfoById = productHead.getProductHeadInfo(categoryId); 28 | return productInfoById; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Product/ProdService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Product; 2 | 3 | import com.zty.xiaomi.server.Entity.Product.ProductInfo; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | 8 | public interface ProdService { 9 | 10 | ProductInfo getProductInfo(int id) throws IOException; 11 | } 12 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Product/ProdServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Product; 2 | 3 | import com.zty.xiaomi.server.Entity.Product.ProductInfo; 4 | import com.zty.xiaomi.server.Mapper.Product; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | 8 | import java.io.IOException; 9 | 10 | @Service 11 | public class ProdServiceImp implements ProdService{ 12 | 13 | @Autowired 14 | private Product productmapper; 15 | 16 | @Override 17 | public ProductInfo getProductInfo(int id) throws IOException { 18 | ProductInfo productInfoById = productmapper.getProductInfoById(id); 19 | return productInfoById; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/RegLogin/RegLogService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.RegLogin; 2 | 3 | import com.zty.xiaomi.server.Entity.User; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | import java.util.Date; 8 | 9 | public interface RegLogService { 10 | 11 | User getUserByName(String email) throws IOException; 12 | 13 | User getUserByUserName(String username) throws IOException; 14 | 15 | void insertUser(String userid, String name, String email, String pwd, 16 | String phone, String status,String date,String prikey) throws IOException; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/RegLogin/RegLogServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.RegLogin; 2 | 3 | import com.zty.xiaomi.server.Entity.User; 4 | import com.zty.xiaomi.server.Mapper.RegLogUser; 5 | import org.springframework.beans.factory.annotation.Autowired; 6 | import org.springframework.stereotype.Service; 7 | import java.io.IOException; 8 | 9 | @Service 10 | public class RegLogServiceImp implements RegLogService { 11 | 12 | @Autowired 13 | private RegLogUser regLogUsermapper; 14 | @Override 15 | public User getUserByName(String username) { 16 | User user = regLogUsermapper.getUserByName(username); 17 | return user; 18 | } 19 | 20 | @Override 21 | public User getUserByUserName(String username) { 22 | User user = regLogUsermapper.getUserByUserName(username); 23 | return user; 24 | } 25 | 26 | @Override 27 | public void insertUser(String userid, String name, String email, String pwd, String phone,String status, String date,String prikey) throws IOException { 28 | regLogUsermapper.insertUser(userid,name,email,pwd,phone,status,date,prikey); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Suggest/SugFootService.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Suggest; 2 | 3 | import com.zty.xiaomi.server.Entity.Suggest.SuggestFoot; 4 | import org.apache.ibatis.session.SqlSession; 5 | 6 | import java.io.IOException; 7 | import java.util.List; 8 | 9 | public interface SugFootService { 10 | 11 | 12 | 13 | List getSugFoot() throws IOException; 14 | } 15 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Service/Suggest/SugFootServiceImp.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Service.Suggest; 2 | 3 | import com.zty.xiaomi.server.Mapper.Suggest; 4 | import com.zty.xiaomi.server.Entity.Suggest.SuggestFoot; 5 | 6 | import org.apache.ibatis.io.Resources; 7 | import org.apache.ibatis.session.SqlSession; 8 | import org.apache.ibatis.session.SqlSessionFactory; 9 | import org.apache.ibatis.session.SqlSessionFactoryBuilder; 10 | import org.springframework.beans.factory.annotation.Autowired; 11 | import org.springframework.cache.annotation.Cacheable; 12 | import org.springframework.stereotype.Service; 13 | 14 | import java.io.IOException; 15 | import java.io.InputStream; 16 | import java.util.List; 17 | 18 | @Service 19 | public class SugFootServiceImp implements SugFootService{ 20 | 21 | @Autowired 22 | private Suggest suggest; 23 | 24 | @Cacheable(value = "suggest",key = "'suggest'") 25 | @Override 26 | public List getSugFoot() throws IOException { 27 | List suggestFoots = suggest.getSuggest(); 28 | return suggestFoots; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Vo/LogOutResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Vo; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LogOutResult { 7 | private int code; 8 | private String msg; 9 | } 10 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Vo/LoginResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Vo; 2 | 3 | import com.zty.xiaomi.server.Entity.LoginData; 4 | import lombok.Data; 5 | 6 | //1010:成功登陆 2008:邮箱错误 2007:密码错误 7 | @Data 8 | public class LoginResult { 9 | private int status=0; 10 | private String msg; 11 | private LoginData data; 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Vo/RegResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Vo; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | //200注册成功,2002该邮箱已注册,404填写信息不全,注册失败 7 | @Data 8 | public class RegResult { 9 | private int status; 10 | private String msg; 11 | 12 | } 13 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/Vo/UserInfoChangeResult.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.Vo; 2 | 3 | import lombok.Data; 4 | import lombok.Setter; 5 | 6 | @Data 7 | public class UserInfoChangeResult { 8 | private int code; 9 | private String msg; 10 | private String image_name; 11 | 12 | public UserInfoChangeResult(int code, String msg, String image_name) { 13 | this.code=code; 14 | this.msg=msg; 15 | this.image_name=image_name; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/redis/JedisConfig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.redis; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | import org.springframework.beans.factory.annotation.Value; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.Configuration; 8 | import redis.clients.jedis.JedisPool; 9 | import redis.clients.jedis.JedisPoolConfig; 10 | 11 | /** 12 | * @auther TyCoding 13 | * @date 2018/10/8 14 | */ 15 | @Configuration 16 | public class JedisConfig { 17 | private Logger logger = LoggerFactory.getLogger(JedisConfig.class); 18 | 19 | @Value("${spring.redis.host}") 20 | private String host; 21 | 22 | @Value("${spring.redis.port}") 23 | private int port; 24 | 25 | @Value("${spring.redis.timeout}") 26 | private int timeout; 27 | 28 | @Value("${spring.redis.jedis.pool.max-active}") 29 | private int maxActive; 30 | 31 | @Value("${spring.redis.jedis.pool.max-idle}") 32 | private int maxIdle; 33 | 34 | @Value("${spring.redis.jedis.pool.min-idle}") 35 | private int minIdle; 36 | 37 | @Value("${spring.redis.jedis.pool.max-wait}") 38 | private long maxWaitMillis; 39 | 40 | @Bean 41 | public JedisPool redisPoolFactory(){ 42 | JedisPoolConfig jedisPoolConfig = new JedisPoolConfig(); 43 | jedisPoolConfig.setMaxIdle(maxIdle); 44 | jedisPoolConfig.setMaxWaitMillis(maxWaitMillis); 45 | jedisPoolConfig.setMaxTotal(maxActive); 46 | jedisPoolConfig.setMinIdle(minIdle); 47 | JedisPool jedisPool = new JedisPool(jedisPoolConfig, host, port, timeout, null); 48 | 49 | logger.info("JedisPool注入成功"); 50 | logger.info("redis地址:" + host + ":" + port); 51 | return jedisPool; 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/redis/RedisTemplateConfig.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.redis; 2 | 3 | import com.fasterxml.jackson.annotation.JsonAutoDetect; 4 | import com.fasterxml.jackson.annotation.PropertyAccessor; 5 | import com.fasterxml.jackson.databind.ObjectMapper; 6 | import org.slf4j.Logger; 7 | import org.slf4j.LoggerFactory; 8 | import org.springframework.context.annotation.Bean; 9 | import org.springframework.context.annotation.Configuration; 10 | import org.springframework.data.redis.connection.RedisConnectionFactory; 11 | import org.springframework.data.redis.core.RedisTemplate; 12 | import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; 13 | 14 | /** 15 | * @auther TyCoding 16 | * @date 2018/10/11 17 | */ 18 | @Configuration 19 | public class RedisTemplateConfig { 20 | 21 | private final Logger logger = LoggerFactory.getLogger(this.getClass()); 22 | 23 | @Bean 24 | public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory){ 25 | Jackson2JsonRedisSerializer jackson2JsonRedisSerializer = new Jackson2JsonRedisSerializer(Object.class); 26 | ObjectMapper objectMapper = new ObjectMapper(); 27 | objectMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.ANY); 28 | objectMapper.enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL); 29 | jackson2JsonRedisSerializer.setObjectMapper(objectMapper); 30 | RedisTemplate redisTemplate = new RedisTemplate(); 31 | redisTemplate.setConnectionFactory(redisConnectionFactory); 32 | redisTemplate.setKeySerializer(jackson2JsonRedisSerializer); 33 | redisTemplate.setHashKeySerializer(jackson2JsonRedisSerializer); 34 | redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer); 35 | redisTemplate.afterPropertiesSet(); 36 | logger.info("RedisTemplate序列化配置,转化方式:" + jackson2JsonRedisSerializer.getClass().getName()); 37 | return redisTemplate; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/utils/DateUtil.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.utils; 2 | 3 | import java.text.SimpleDateFormat; 4 | import java.util.Date; 5 | 6 | 7 | public class DateUtil { 8 | public static String ptfDate(){ 9 | //产生新的日期对象(使用Date生成 10 | Date currentTime = new Date(); 11 | //产生新的日期对象(使用System.currentTimeMillis() 12 | /* 13 | long currnetTime1 = System.currentTimeMillis(); 14 | */ 15 | //新建日期格式 16 | SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss"); 17 | //将日期对象格式化成指定格式并以String输出 18 | String date = simpleDateFormat.format(currentTime); 19 | return date; 20 | 21 | 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/utils/OrderNumUtil.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.utils; 2 | 3 | import java.util.UUID; 4 | 5 | public class OrderNumUtil { 6 | public static final int MACHINE_ID = 1; 7 | /** 8 | * 生成订单号 9 | */ 10 | public static int getOrderNumber() { 11 | int machineId = MACHINE_ID; 12 | int hashCodeV = UUID.randomUUID().toString().hashCode(); 13 | if (hashCodeV < 0) { 14 | hashCodeV = -hashCodeV; 15 | } 16 | // 0 代表前面补充0 17 | // 4 代表长度为4 18 | // d 代表参数为正整型 19 | //edit---20181203 hzj 20 | // Date date=new Date(); 21 | // return machineId + String.format("%015d", hashCodeV)+date.getTime(); 22 | return hashCodeV; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/utils/RSAUtils.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.utils; 2 | 3 | import org.apache.commons.codec.binary.Base64; 4 | import org.apache.commons.io.IOUtils; 5 | 6 | import javax.crypto.Cipher; 7 | import java.io.ByteArrayOutputStream; 8 | import java.security.*; 9 | import java.security.interfaces.RSAPrivateKey; 10 | import java.security.interfaces.RSAPublicKey; 11 | import java.security.spec.InvalidKeySpecException; 12 | import java.security.spec.PKCS8EncodedKeySpec; 13 | import java.security.spec.X509EncodedKeySpec; 14 | import java.util.HashMap; 15 | import java.util.Map; 16 | 17 | public class RSAUtils { 18 | 19 | public static final String CHARSET = "UTF-8"; 20 | public static final String RSA_ALGORITHM = "RSA"; 21 | 22 | 23 | public static Map createKeys(int keySize){ 24 | //为RSA算法创建一个KeyPairGenerator对象 25 | KeyPairGenerator kpg; 26 | try{ 27 | kpg = KeyPairGenerator.getInstance(RSA_ALGORITHM); 28 | }catch(NoSuchAlgorithmException e){ 29 | throw new IllegalArgumentException("No such algorithm-->[" + RSA_ALGORITHM + "]"); 30 | } 31 | 32 | //初始化KeyPairGenerator对象,密钥长度 33 | kpg.initialize(keySize); 34 | //生成密匙对 35 | KeyPair keyPair = kpg.generateKeyPair(); 36 | //得到公钥 37 | Key publicKey = keyPair.getPublic(); 38 | String publicKeyStr = Base64.encodeBase64URLSafeString(publicKey.getEncoded()); 39 | //得到私钥 40 | Key privateKey = keyPair.getPrivate(); 41 | String privateKeyStr = Base64.encodeBase64URLSafeString(privateKey.getEncoded()); 42 | Map keyPairMap = new HashMap(); 43 | keyPairMap.put("publicKey", publicKeyStr); 44 | keyPairMap.put("privateKey", privateKeyStr); 45 | 46 | return keyPairMap; 47 | } 48 | 49 | /** 50 | * 得到公钥 51 | * @param publicKey 密钥字符串(经过base64编码) 52 | * @throws Exception 53 | */ 54 | public static RSAPublicKey getPublicKey(String publicKey) throws NoSuchAlgorithmException, InvalidKeySpecException { 55 | //通过X509编码的Key指令获得公钥对象 56 | KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); 57 | X509EncodedKeySpec x509KeySpec = new X509EncodedKeySpec(Base64.decodeBase64(publicKey)); 58 | RSAPublicKey key = (RSAPublicKey) keyFactory.generatePublic(x509KeySpec); 59 | return key; 60 | } 61 | 62 | /** 63 | * 得到私钥 64 | * @param privateKey 密钥字符串(经过base64编码) 65 | * @throws Exception 66 | */ 67 | public static RSAPrivateKey getPrivateKey(String privateKey) throws NoSuchAlgorithmException, InvalidKeySpecException { 68 | //通过PKCS#8编码的Key指令获得私钥对象 69 | KeyFactory keyFactory = KeyFactory.getInstance(RSA_ALGORITHM); 70 | PKCS8EncodedKeySpec pkcs8KeySpec = new PKCS8EncodedKeySpec(Base64.decodeBase64(privateKey)); 71 | RSAPrivateKey key = (RSAPrivateKey) keyFactory.generatePrivate(pkcs8KeySpec); 72 | return key; 73 | } 74 | 75 | /** 76 | * 公钥加密 77 | * @param data 78 | * @param publicKey 79 | * @return 80 | */ 81 | public static String publicEncrypt(String data, RSAPublicKey publicKey){ 82 | try{ 83 | Cipher cipher = Cipher.getInstance(RSA_ALGORITHM); 84 | cipher.init(Cipher.ENCRYPT_MODE, publicKey); 85 | return Base64.encodeBase64URLSafeString(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(CHARSET), publicKey.getModulus().bitLength())); 86 | }catch(Exception e){ 87 | throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e); 88 | } 89 | } 90 | 91 | /** 92 | * 私钥解密 93 | * @param data 94 | * @param privateKey 95 | * @return 96 | */ 97 | 98 | public static String privateDecrypt(String data, RSAPrivateKey privateKey){ 99 | try{ 100 | Cipher cipher = Cipher.getInstance(RSA_ALGORITHM); 101 | cipher.init(Cipher.DECRYPT_MODE, privateKey); 102 | return new String(rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.decodeBase64(data), privateKey.getModulus().bitLength()), CHARSET); 103 | }catch(Exception e){ 104 | throw new RuntimeException("解密字符串[" + data + "]时遇到异常", e); 105 | } 106 | } 107 | 108 | /** 109 | * 私钥加密 110 | * @param data 111 | * @param privateKey 112 | * @return 113 | */ 114 | 115 | public static String privateEncrypt(String data, RSAPrivateKey privateKey){ 116 | try{ 117 | Cipher cipher = Cipher.getInstance(RSA_ALGORITHM); 118 | cipher.init(Cipher.ENCRYPT_MODE, privateKey); 119 | return Base64.encodeBase64URLSafeString(rsaSplitCodec(cipher, Cipher.ENCRYPT_MODE, data.getBytes(CHARSET), privateKey.getModulus().bitLength())); 120 | }catch(Exception e){ 121 | throw new RuntimeException("加密字符串[" + data + "]时遇到异常", e); 122 | } 123 | } 124 | 125 | /** 126 | * 公钥解密 127 | * @param data 128 | * @param publicKey 129 | * @return 130 | */ 131 | 132 | public static String publicDecrypt(String data, RSAPublicKey publicKey){ 133 | try{ 134 | Cipher cipher = Cipher.getInstance(RSA_ALGORITHM); 135 | cipher.init(Cipher.DECRYPT_MODE, publicKey); 136 | return new String(rsaSplitCodec(cipher, Cipher.DECRYPT_MODE, Base64.decodeBase64(data), publicKey.getModulus().bitLength()), CHARSET); 137 | }catch(Exception e){ 138 | throw new RuntimeException("解密字符串[" + data + "]时遇到异常", e); 139 | } 140 | } 141 | 142 | private static byte[] rsaSplitCodec(Cipher cipher, int opmode, byte[] datas, int keySize){ 143 | int maxBlock = 0; 144 | if(opmode == Cipher.DECRYPT_MODE){ 145 | maxBlock = keySize / 8; 146 | }else{ 147 | maxBlock = keySize / 8 - 11; 148 | } 149 | ByteArrayOutputStream out = new ByteArrayOutputStream(); 150 | int offSet = 0; 151 | byte[] buff; 152 | int i = 0; 153 | try{ 154 | while(datas.length > offSet){ 155 | if(datas.length-offSet > maxBlock){ 156 | buff = cipher.doFinal(datas, offSet, maxBlock); 157 | }else{ 158 | buff = cipher.doFinal(datas, offSet, datas.length-offSet); 159 | } 160 | out.write(buff, 0, buff.length); 161 | i++; 162 | offSet = i * maxBlock; 163 | } 164 | }catch(Exception e){ 165 | throw new RuntimeException("加解密阀值为["+maxBlock+"]的数据时发生异常", e); 166 | } 167 | byte[] resultDatas = out.toByteArray(); 168 | IOUtils.closeQuietly(out); 169 | return resultDatas; 170 | } 171 | 172 | public static void main (String[] args) throws Exception { 173 | Map keyMap = RSAUtils.createKeys(512); 174 | String publicKey = keyMap.get("publicKey"); 175 | String privateKey = keyMap.get("privateKey"); 176 | String str = "2000918131X"; 177 | System.out.println("\r明文:\r\n" + str); 178 | System.out.println("\r明文大小:\r\n" + str.getBytes().length); 179 | String encodedData = RSAUtils.publicEncrypt(str, RSAUtils.getPublicKey(publicKey)); 180 | System.out.println("密文:\r\n" + encodedData); 181 | String decodedData = RSAUtils.privateDecrypt(encodedData, RSAUtils.getPrivateKey(privateKey)); 182 | System.out.println("解密后文字: \r\n" + decodedData); 183 | 184 | } 185 | } -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/java/com/zty/xiaomi/server/utils/TokenUtil.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server.utils; 2 | 3 | import com.auth0.jwt.JWT; 4 | import com.auth0.jwt.JWTVerifier; 5 | import com.auth0.jwt.algorithms.Algorithm; 6 | import com.auth0.jwt.interfaces.DecodedJWT; 7 | 8 | import java.text.SimpleDateFormat; 9 | import java.util.*; 10 | 11 | public class TokenUtil { 12 | 13 | //token秘钥 14 | private static final String TOKEN_SECRET = "tongyige"; 15 | private static final String ISSUSER = "zhongtongyi"; 16 | // 签名的主题 17 | private static final String SUBJECT = "this is litemall token"; 18 | 19 | public static String token(String username) { 20 | 21 | String token = ""; 22 | try { 23 | //秘钥及加密算法 24 | Algorithm algorithm = Algorithm.HMAC256(TOKEN_SECRET); 25 | //设置头部信息 26 | Map header = new HashMap<>(); 27 | Date nowDate = new Date(); 28 | // 过期时间:2小时 29 | Date expireDate = getAfterDate(nowDate, 0, 0, 0, 2, 0, 0); 30 | header.put("typ", "JWT"); 31 | header.put("alg", "HS256"); 32 | //携带username,password信息,生成签名 33 | token = JWT.create() 34 | // 设置头部信息 Header 35 | .withHeader(header) 36 | // 设置 载荷 Payload 37 | .withClaim("username", username) 38 | .withIssuer(ISSUSER) 39 | .withSubject(SUBJECT) 40 | .withIssuedAt(nowDate) 41 | .withExpiresAt(expireDate) 42 | .sign(algorithm); 43 | } catch (Exception e) { 44 | e.printStackTrace(); 45 | return null; 46 | } 47 | return token; 48 | } 49 | 50 | public static boolean verify(String token) { 51 | /** 52 | * @desc 验证token,通过返回true 53 | * @params [token]需要校验的串 54 | **/ 55 | try { 56 | Algorithm algorithm = Algorithm.HMAC256(TOKEN_SECRET); 57 | JWTVerifier verifier = JWT.require(algorithm) 58 | .withIssuer(ISSUSER) 59 | .build(); 60 | DecodedJWT jwt = verifier.verify(token); 61 | return true; 62 | } catch (Exception e) { 63 | e.printStackTrace(); 64 | return false; 65 | } 66 | } 67 | 68 | public static Date getAfterDate(Date date, int year, int month, int day, int hour, int minute, int second) { 69 | if (date == null) { 70 | date = new Date(); 71 | } 72 | Calendar cal = new GregorianCalendar(); 73 | 74 | cal.setTime(date); 75 | if (year != 0) { 76 | cal.add(Calendar.YEAR, year); 77 | } 78 | if (month != 0) { 79 | cal.add(Calendar.MONTH, month); 80 | } 81 | if (day != 0) { 82 | cal.add(Calendar.DATE, day); 83 | } 84 | if (hour != 0) { 85 | cal.add(Calendar.HOUR_OF_DAY, hour); 86 | } 87 | if (minute != 0) { 88 | cal.add(Calendar.MINUTE, minute); 89 | } 90 | if (second != 0) { 91 | cal.add(Calendar.SECOND, second); 92 | } 93 | return cal.getTime(); 94 | } 95 | 96 | // public static void main(String[] args) { 97 | // String username = "ZTY"; 98 | // String token = token(username); 99 | // System.out.println(token); 100 | // boolean b = verify(token); 101 | // System.out.println(b); 102 | 103 | // } 104 | } -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | server: 2 | port: 8080 3 | 4 | spring: 5 | aop: 6 | proxy-target-class: true 7 | 8 | datasource: 9 | driver-class-name: com.mysql.cj.jdbc.Driver 10 | url: jdbc:mysql://localhost:3306/xiaomi?useSSL=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC 11 | username: root 12 | password: "2000918131X" # 4vm(pBK?Qih*! 13 | type: com.alibaba.druid.pool.DruidDataSource 14 | #Spring Boot 默认是不注入这些属性值的,需要自己绑定 15 | #druid 数据源专有配置 16 | initialSize: 5 #初始化时建立物理连接的个数 17 | minIdle: 5 #最小连接池数量 18 | maxActive: 20 #最大连接池数量 19 | maxWait: 60000 #获取连接时最大等待时间 20 | timeBetweenEvictionRunsMillis: 60000 #Destory线程检测连接的间隔时间 21 | minEvictableIdleTimeMillis: 300000 #连接保持空闲而不被驱逐的最长时间 22 | validationQuery: SELECT 1 FROM DUAL #检测连接是否有效的sql 23 | testWhileIdle: true 24 | testOnBorrow: false #申请连接时执行validationQuery检测连接是否有效 25 | testOnReturn: false #归还连接时执行validationQuery检测连接是否有效 26 | poolPreparedStatements: true #是否缓存preparedStatements 27 | 28 | #配置监控统计拦截的filters,stat:监控统计、log4j:日志记录、wall:防御sql注入 29 | #如果允许时报错 java.lang.ClassNotFoundException: org.apache.log4j.Priority 30 | #则导入 log4j 依赖即可 31 | filters: stat,wall,log4j 32 | maxPoolPreparedStatementPerConnectionSize: 20 33 | useGlobalDataSourceStat: true 34 | connectionProperties: druid.stat.mergeSql=true;druid.stat.slowSqlMillis=500 35 | 36 | 37 | redis: 38 | # redis数据库索引(默认为0),我们使用索引为3的数据库,避免和其他数据库冲突 39 | database: 1 40 | # redis服务器地址(默认为loaclhost) 41 | host: 192.168.159.133 # 42 | # redis端口(默认为6379) 43 | port: 6379 44 | # redis访问密码(默认为空) 45 | password: #4vm(pBK?Qih*! 46 | # redis连接超时时间(单位毫秒) 47 | timeout: 1000 48 | # redis连接池配置 49 | jedis: 50 | pool: 51 | # 最大可用连接数(默认为8,负数表示无限) 52 | max-active: 8 53 | # 最大空闲连接数(默认为8,负数表示无限) 54 | max-idle: -1 55 | # 最小空闲连接数(默认为0,该值只有为正数才有用) 56 | min-idle: 8 57 | # 从连接池中获取连接最大等待时间(默认为-1,单位为毫秒,负数表示无限) 58 | max-wait: 0 59 | 60 | alipay: 61 | #应用ID 62 | app_id: 2021000117694209 63 | #应用私钥 64 | merchant_private_key: MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCmwQ38tNiDHJ0SG5f32INMiVxf76pezb1ni1gK+DMnsarLpCSb+l4GIVYn1yMLr9ORdoCSh95TObcXPiLefAUzqiy2pMDzCKZPrC64yZ99rC4jy840MuaPSB1ntv8t2CRmvRHxtvl2/jjV00iNGYBgZr4MPqMlhq/cKjYOP1mc8hfHu7R2SUZGJ8bceOtu3MvSRnjb6hc9D+VnsuuxLFmt9XCdlRsK9QsFtLBz+TLQsaKndH6tjwPTDe4ix4hRt73QTotMeYntXXtbJ+J6F9LOS0QagrYKYmZXaeGCwysJjw6g0O6KLhRdf3IHAft9AsN8wXD3NOWlY+jtgsRUe+qDAgMBAAECggEBAIpeVWnk8mfRHXDCHtbU/RZMQK+GoptqIwlBcfwgOeptHak++fXHya9SiDgk53qyGl9wsn1kapIqqQeLUsnEpVhalCG2EjlYaxBfcqF5BHP2pI6ldeSQfApWr7e4/IOg/4uUxcgJqXUYvDaJzIDwsTrM5lQowZ3I5jJNgG9QF98HFzG7yrWru7ZK0gHc+2LD5gCoH7jNEiDxxN4HulqLOhNZ+5T8oUsr/Vz/FqWGMl74Sk0YwKWkQmg8kcZMxgm31Ona6EB3CZguThb/Pxklv7YI2b/3goztpXYWd4xk0SbIKAVAIW0zadOphPIJbKc/b00STiaOHCqZULNbAHoBvUECgYEA4/Zj40uJ+In9Wh7n/Nae5V/7BRxtr4bmGP88YAyq2dvgFjv1rfWEhXq5w6QCLO5Y3bSm6xEcVVxuRWTrlux0wbj7g0wUajlA9q8mJNyLI2aXLqsqG5Xq5DbNwLbCwku73LWGzpi3bpabNPwxNf8kGG/ueSE6k5kNKqW/OjtZ8yECgYEAu0N2hHhDl78jbFsgieR5YYDYWLyPEOs45+MHtuFEk4dAlliQgbLtsmys+sDP6Jyq5A8FCrlLz6wyB7xFJ5J5LfRnneRjedZpMXNpTRW5WJ0KstKR8+QkfnO57uSeyCo6e9gcQZOx6366bsi4WHZSvmeyAUU4W4tuLQpiP/H3DSMCgYEAqdB9kHBREygX5u5m+l4Wd+AL6j7HJp5jAfQAUbyd+TRltaps1W2zjothnm+qfzX+VQmh3jIc3SnBq0gGh6MVRso58hDWlFqaHilTTNpNe82MiWNQNsRy+hYpJ4n9gydPhpZjGbuByYu/irTjI8owZVPcXbd3H0RAHqjhzssvsoECgYEAmxbrYBjOOi4F42axUyKS2IrCIvO/NQ7qqTngmLiGd/xrJFkjDReoPr48oMvxJMAj1A8QaOo/fDYrlTZ6u6RWkhW5fw24yR4nLtpbmojkYRxm0OUOFcSb6NJlahGT40j9+LVp6XGtx9DEDJ5V9oXAT4tH5D90xnR6gfj4l+cIaasCgYAO/NPqmG8Bkf6RVQ2ynHSOiOIjtndkVFuGuYTDZCDPHZwIzNsWzzxBNYDoeFok1bzAh2tE/tUnHwbPK6xNNnJ+7foCPCbLWW8aBa28m6OJdGKLIQ7vg8pEDEOHEvDMWXOvGMhswuh2BNfGsqVSGPzH71NqvEYVnHT+iAiaHKCs/g== 65 | #支付宝公钥 66 | alipay_public_key: MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg3zYIb0Q4YSPBGNzEr/Dv5aC/OW1ndCB1xzKrUnafOUMiJtbxfhsd9OYqWrc+n2DgTZ02FbtdVr5v7zjFEe8c4EosliN9qzr6JJtedJgfSXV7lUkpksQn8pM0cAlCqo0NxdGYTKHeWZpCmmqQmTLVQvkLZKPEUSd68/diH9Zb8HtZ8iHuVlgOZjA93j/NTF4Y7ZHy2QVyX+w71FfZJstdNMzfmyqNGsATUXgN5ChZkgDYsX8e4/c/Cs24VZchgE/FoVf9m2m63G28VHCmJ9NXP8oCH1eNaCvX0sLghBZR6e5siipIrAJnIevo18HRssokF6rhabOf33SpFVGRsW1nQIDAQAB 67 | #format 68 | format: json 69 | #异步通知回调地址,不能加?id=123这类自定义参数 70 | notify_url: http://tongyi.site:8080/alipay/notify 71 | #即支付成功之后,需要跳转到的页面 72 | return_url: http://tongyi.site 73 | #签名方式 74 | sign_type: RSA2 75 | #字符编码格式 76 | charset: utf-8 77 | #支付宝网关,这一项是写死的,正式环境是openapi.alipay.com 78 | gatewayUrl: openapi.alipaydev.com 79 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/main/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | #log4j.rootLogger=DEBUG, stdout 2 | #log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | #log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | #log4j.appender.stdout.layout.ConversionPattern=%5p [%t] - %m%n 5 | -------------------------------------------------------------------------------- /高仿小米商城后台/src/test/java/com/zty/xiaomi/server/ServerApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.zty.xiaomi.server; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.springframework.boot.test.context.SpringBootTest; 5 | 6 | @SpringBootTest 7 | class ServerApplicationTests { 8 | 9 | @Test 10 | void contextLoads() { 11 | } 12 | 13 | } 14 | --------------------------------------------------------------------------------