初始化提交

This commit is contained in:
USER-20221017CE\Administrator
2022-11-01 12:14:54 +08:00
commit d31fad2aa9
1733 changed files with 370203 additions and 0 deletions

31
.gitignore vendored Normal file
View File

@@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea/
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

441
doc/htmljss/common.css Normal file
View File

@@ -0,0 +1,441 @@
body,
div,
p,
h1,
h2,
h3,
h4,
h5,
h6,
ul,
li,
dl,
dt,
a,
input,
button,
textarea,
select {
margin: 0;
padding: 0;
outline: none;
}
html,
body {
font-family: Helvetica Neue, Helvetica, Arial, Microsoft Yahei, Hiragino Sans GB, Heiti SC, WenQuanYi Micro Hei, sans-serif;
color: #333333;
background-color: #ffffff;
min-width: 1226px;
font-size: 12px;
}
a {
text-decoration: none;
}
ul,
li {
list-style: none;
}
input {
font: normal;
}
input:focus,
a:focus {
outline: none;
}
.container {
position: relative;
width: 1226px;
margin-right: auto;
margin-left: auto;
}
input {
outline: none;
-webkit-box-sizing: border-box;
box-sizing: border-box;
font-size: 14px;
}
.fl {
float: left;
}
.fr {
float: right;
}
.clearfix:before,
.clearfix:after {
content: ' ';
display: table;
}
.clearfix:after {
clear: both;
}
.header-logo {
display: inline-block;
width: 55px;
height: 55px;
background-color: #FF6600;
}
.header-logo a {
display: inline-block;
width: 110px;
height: 55px;
}
.header-logo a:before {
content: ' ';
display: inline-block;
width: 55px;
height: 55px;
background: url("/imgs/mi-logo.png") no-repeat center;
background-size: 55px;
-webkit-transition: margin .2s;
transition: margin .2s;
}
.header-logo a:after {
content: ' ';
display: inline-block;
width: 55px;
height: 55px;
background: url("/imgs/mi-home.png") no-repeat center;
background-size: 55px;
}
.header-logo a:hover:before {
margin-left: -55px;
-webkit-transition: margin .2s;
transition: margin .2s;
}
/* 样式规范表 */
.header .nav-topbar {
height: 39px;
line-height: 39px;
background-color: #333333;
color: #B0B0B0;
}
.header .nav-topbar .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.header .nav-topbar .container a {
display: inline-block;
color: #B0B0B0;
margin-right: 17px;
}
.header .nav-topbar .container .my-cart {
width: 110px;
background-color: #FF6600;
text-align: center;
color: #ffffff;
margin-right: 0;
}
.header .nav-topbar .container .my-cart .icon-cart {
display: inline-block;
width: 16px;
height: 12px;
background: url("/imgs/icon-cart-checked.png") no-repeat center;
background-size: contain;
margin-right: 4px;
}
.header .nav-header .container {
position: relative;
height: 112px;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.header .nav-header .container .header-menu {
display: inline-block;
width: 643px;
padding-left: 209px;
}
.header .nav-header .container .header-menu .item-menu {
display: inline-block;
color: #333333;
font-weight: bold;
font-size: 16px;
line-height: 112px;
margin-right: 20px;
}
.header .nav-header .container .header-menu .item-menu span {
cursor: pointer;
}
.header .nav-header .container .header-menu .item-menu:hover {
color: #FF6600;
}
.header .nav-header .container .header-menu .item-menu:hover .children {
height: 220px;
opacity: 1;
}
.header .nav-header .container .header-menu .item-menu .children {
position: absolute;
top: 112px;
left: 0;
width: 1226px;
height: 0;
opacity: 0;
overflow: hidden;
border-top: 1px solid #E5E5E5;
-webkit-box-shadow: 0px 7px 6px 0px rgba(0, 0, 0, 0.11);
box-shadow: 0px 7px 6px 0px rgba(0, 0, 0, 0.11);
z-index: 10;
-webkit-transition: all .5s;
transition: all .5s;
background-color: #ffffff;
}
.header .nav-header .container .header-menu .item-menu .children .product {
position: relative;
float: left;
width: 16.6%;
height: 220px;
font-size: 12px;
line-height: 12px;
text-align: center;
}
.header .nav-header .container .header-menu .item-menu .children .product a {
display: inline-block;
}
.header .nav-header .container .header-menu .item-menu .children .product img {
width: auto;
height: 111px;
margin-top: 26px;
}
.header .nav-header .container .header-menu .item-menu .children .product .pro-img {
height: 137px;
}
.header .nav-header .container .header-menu .item-menu .children .product .pro-name {
font-weight: bold;
margin-top: 19px;
margin-bottom: 8px;
color: #333333;
}
.header .nav-header .container .header-menu .item-menu .children .product .pro-price {
color: #FF6600;
}
.header .nav-header .container .header-menu .item-menu .children .product:before {
content: ' ';
position: absolute;
top: 28px;
right: 0;
border-left: 1px solid #d7d7d7;
height: 100px;
width: 1px;
}
.header .nav-header .container .header-menu .item-menu .children .product:last-child:before {
display: none;
}
.header .nav-header .container .header-search {
width: 319px;
}
.header .nav-header .container .header-search .wrapper {
height: 50px;
border: 1px solid #E0E0E0;
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.header .nav-header .container .header-search .wrapper input {
border: none;
-webkit-box-sizing: border-box;
box-sizing: border-box;
border-right: 1px solid #E0E0E0;
width: 264px;
height: 50px;
padding-left: 14px;
}
.header .nav-header .container .header-search .wrapper a {
color: #333333;
background-color: #ffffff;
display: block;
width: 57px;
height: 100%;
line-height: 50px;
text-align: center;
}
.header .nav-header .container .header-search .wrapper a:hover {
color: #ffffff;
background-color: #FF6600;
}
.footer[data-v-b07fc4c4] {
height: 234px;
border-top: 4px solid #FF6600;
background-color: #333333;
color: #999999;
font-size: 16px;
text-align: center;
}
.footer .footer-logo[data-v-b07fc4c4] {
margin-top: 46px;
margin-bottom: 31px;
}
.footer .footer-logo img[data-v-b07fc4c4] {
width: 53px;
height: 36px;
margin-bottom: 13px;
}
.footer .footer-link[data-v-b07fc4c4] {
margin-bottom: 13px;
}
.footer .footer-link a[data-v-b07fc4c4] {
color: #999999;
display: inline-block;
}
.footer .footer-link span[data-v-b07fc4c4] {
margin: 0 10px;
}
.footer .copyright .domain[data-v-b07fc4c4] {
color: #FF6600;
}
/* 样式规范表 */
.btn {
display: inline-block;
width: 110px;
line-height: 30px;
text-align: center;
background-color: #FF6600;
color: #ffffff;
border: none;
cursor: pointer;
}
.btn-default {
background-color: #B0B0B0;
color: #ffffff;
}
.btn-large {
width: 202px;
height: 50px;
line-height: 50px;
font-size: 18px;
}
.btn-huge {
width: 300px;
height: 54px;
line-height: 54px;
font-size: 16px;
}
.btn-group .btn {
margin-right: 20px;
}
.btn-group .btn:last-child {
margin-right: 0;
}
/* 样式规范表 */
.nav-bar {
height: 70px;
line-height: 70px;
border-top: 1px solid #e5e5e5;
background-color: #ffffff;
z-index: 10;
}
.nav-bar.is_fixed {
position: fixed;
top: 0;
width: 100%;
-webkit-box-shadow: 0 5px 5px #cccccc;
box-shadow: 0 5px 5px #cccccc;
}
.nav-bar .container {
display: -webkit-box;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: justify;
-ms-flex-pack: justify;
justify-content: space-between;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
}
.nav-bar .container .pro-title {
font-size: 18px;
color: #333333;
font-weight: bold;
}
.nav-bar .container .pro-param {
font-size: 14px;
}
.nav-bar .container .pro-param span {
margin: 0 10px;
}
.nav-bar .container .pro-param a {
color: #666666;
}

BIN
doc/htmljss/ewm.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

3
doc/htmljss/jquery-1.9.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

136
doc/htmljss/order.css Normal file
View File

@@ -0,0 +1,136 @@
.order-pay .wrapper {
background-color: #F5F5F5;
padding-top: 30px;
padding-bottom: 61px;
}
.order-pay .wrapper .order-wrap {
padding: 62px 50px;
background-color: #fff;
font-size: 14px;
margin-bottom: 30px;
width: 1028px;
margin: 0px auto;
}
.order-pay .wrapper .order-wrap .item-order {
display: flex;
align-items: center;
}
.order-pay .wrapper .order-wrap .item-order .icon-succ {
width: 90px;
height: 90px;
border-radius: 50%;
background: url("/imgs/icon-gou.png") #80c58a no-repeat center;
background-size: 60px;
margin-right: 40px;
}
.order-pay .wrapper .order-wrap .item-order .order-info {
margin-right: 248px;
}
.order-pay .wrapper .order-wrap .item-order .order-info h2 {
font-size: 24px;
color: #333333;
margin-bottom: 20px;
}
.order-pay .wrapper .order-wrap .item-order .order-info p {
color: #666666;
}
.order-pay .wrapper .order-wrap .item-order .order-info p span {
color: #FF6700;
}
.order-pay .wrapper .order-wrap .item-order .order-total > p:first-child {
margin-bottom: 30px;
}
.order-pay .wrapper .order-wrap .item-order .order-total span {
font-size: 28px;
color: #FF6700;
}
.order-pay .wrapper .order-wrap .item-order .order-total .icon-down {
display: inline-block;
width: 14px;
height: 10px;
background: url("/imgs/icon-down.png") no-repeat center;
background-size: contain;
margin-left: 9px;
transition: all 0.5s;
cursor: pointer;
}
.order-pay .wrapper .order-wrap .item-order .order-total .icon-down.up {
transform: rotate(180deg);
}
.order-pay .wrapper .order-wrap .item-order .order-total .icon-up {
transform: rotate(180deg);
}
.order-pay .wrapper .order-wrap .item-detail {
border-top: 1px solid #D7D7D7;
padding-top: 47px;
padding-left: 130px;
font-size: 14px;
margin-top: 45px;
}
.order-pay .wrapper .order-wrap .item-detail .item {
margin-bottom: 19px;
}
.order-pay .wrapper .order-wrap .item-detail .item .detail-title {
float: left;
width: 100px;
}
.order-pay .wrapper .order-wrap .item-detail .item .detail-info {
display: inline-block;
}
.order-pay .wrapper .order-wrap .item-detail .item .detail-info img {
width: 30px;
vertical-align: middle;
}
.order-pay .wrapper .item-pay {
padding: 26px 50px 72px;
background-color: #ffffff;
color: #333333;
}
.order-pay .wrapper .item-pay h3 {
font-size: 20px;
font-weight: 200;
color: #333333;
padding-bottom: 24px;
border-bottom: 1px solid #D7D7D7;
margin-bottom: 26px;
}
.order-pay .wrapper .item-pay .pay-way {
font-size: 18px;
}
.order-pay .wrapper .item-pay .pay-way .pay {
display: inline-block;
width: 188px;
height: 64px;
border: 1px solid #D7D7D7;
cursor: pointer;
}
.order-pay .wrapper .item-pay .pay-way .pay:last-child {
margin-left: 20px;
}
.order-pay .wrapper .item-pay .pay-way .pay.checked {
border: 1px solid #FF6700;
}
.order-pay .wrapper .item-pay .pay-way .pay-ali {
background: url("/imgs/pay/icon-ali.png") no-repeat center;
background-size: 103px 38px;
margin-top: 19px;
}
.order-pay .wrapper .item-pay .pay-way .pay-wechat {
background: url("/imgs/pay/icon-wechat.png") no-repeat center;
background-size: 103px 38px;
}
.subpay{
text-align: center;
margin: 20px;
}
.pay {
padding: 62px 50px;
background-color: #fff;
font-size: 14px;
margin-bottom: 30px;
width: 1028px;
margin: 0px auto;
height: 400px;
}

22293
doc/htmljss/product.css Normal file

File diff suppressed because it is too large Load Diff

220
doc/htmljss/product.ftl Normal file
View File

@@ -0,0 +1,220 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>图灵商城商品详情页</title>
<link rel="stylesheet" type="text/css" href="static/product.css">
<link rel="stylesheet" type="text/css" href="static/common.css">
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id="app">
<div>
<div class="header">
<div class="nav-topbar">
<div class="container">
<div class="topbar-menu">
<a href="javascript:;">图灵商城</a></div>
<div class="topbar-user">
<a href="javascript:;">admin</a>
<!---->
<a href="javascript:;">退出</a>
<a href="http://localhost:8081/#/order/list">我的订单</a>
<a href="javascript:;" class="my-cart">
<span class="icon-cart"></span>购物车</a>
</div>
</div>
</div>
<div class="nav-header">
<div class="container">
<div class="header-logo">
<a href="http://localhost:8081/#/index"></a>
</div>
<div class="header-search">
<div class="wrapper">
<input type="text" name="keyword" placeholder="请输入产品关键字">
<a href="javascript:;" class="fa fa-search fa-2x"></a>
</div>
</div>
</div>
</div>
</div>
<div class="detail">
<div class="nav-bar">
<div class="container">
<div class="pro-title">${fpp.name}</div>
<div class="pro-param">
<a href="javascript:;">概述</a>
<span>|</span>
<a href="javascript:;">参数</a>
<span>|</span>
<a href="javascript:;">用户评价</a></div>
</div>
</div>
<div class="wrapper">
<div class="container clearfix">
<div class="swiper">
<div class="swiper-container swiper-container-initialized swiper-container-horizontal">
<div class="swiper-wrapper" style="transform: translate3d(-1284px, 0px, 0px); transition-duration: 0ms;">
<#list imageList as image>
<img src="${image}"/><br>
</#list>
</div>
<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets">
<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 1"></span>
<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 2"></span>
<span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button" aria-label="Go to slide 3"></span>
</div>
<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
</div>
</div>
<div class="content">
<h2 class="item-title">${fpp.name}</h2>
<p class="item-info">AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待</p>
<div class="item-price">${fpp.flashPromotionPrice}元</div>
<div class="line"></div>
<div class="item-version clearfix">
<h2>选择规格</h2>
<div skuid="143" class="phone fl">金色16G</div>
<div skuid="144" class="phone fl">金色32G</div>
<div skuid="145" class="phone fl">银色16G</div>
<div skuid="146" class="phone fl">银色32G</div></div>
<div class="item-total">
<div class="phone-info clearfix">
<div class="stock">
<i aria-hidden="true" class="fa fa-exclamation-triangle f2"></i>请选择规格</div>
<!----></div>
<!----></div>
<div class="btn-group">
<a href="javascript:;" class="btn btn-huge fl" onclick="secKill()" disabled="true" id="secKillbtn">立即秒杀</a></div>
<div class="btn-group">
<span>
<em>库存数量</em>
</span>
<span>
<input id="flashPromotionCount" type="text" readonly value="${fpp.flashPromotionCount}">
</span>
</div>
<div class="input" id="verifyCodeArea" hidden="true">
<img id="verifyCodeImg" src="">
<input id="verifyCodeText" type="text" placeholder="请输入验证码">
</div>
<div class="after-sale-info">
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>无忧退货</em></a>
</span>
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>快速退款</em></a>
</span>
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>免费包邮</em></a>
</span>
</div>
</div>
</div>
</div>
<div class="price-info">
<div class="container">
<h2>商品介绍</h2>
<div class="desc">
<p>
<!--{* detailHtml *}-->
</p>
</div>
</div>
</div>
<div class="service">
<div class="container">
<ul>
<li>
<span class="icon-setting"></span>预约维修服务</li>
<li>
<span class="icon-7day"></span>7天无理由退货</li>
<li>
<span class="icon-15day"></span>15天免费换货</li>
<li>
<span class="icon-post"></span>满150元包邮</li>
</ul>
</div>
</div>
</div>
<div data-v-b07fc4c4="" class="footer">
<div data-v-b07fc4c4="" class="footer-logo">
<p data-v-b07fc4c4="">图灵商城</p></div>
<div data-v-b07fc4c4="" class="footer-link">
<a data-v-b07fc4c4="" href="http://www.tulingxueyuan.cn/" target="_blank">图灵学院</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/231516?tuin=a6505b53" target="_blank">腾讯课堂java架构师培训</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/429988" target="_blank">数据结构与算法</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://tuling.ke.qq.com/" target="_blank">腾讯课堂图灵学院</a></div>
<div data-v-b07fc4c4="" class="copyright">Copyright ©2019
<span data-v-b07fc4c4="" class="domain">图灵学院</span>All Rights Reserved.</div></div>
</div>
<input id="memberId" type="hidden" value="{* memberId *}">
<input id="productId" type="hidden" value="{* productId *}">
<input id="flashPromotionId" type="hidden" value="{* flashPromotionId *}">
</div>
<script type="text/javascript" src="static/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function secKill(){
if ($("#verifyCodeText").val() == "") {
console.log("请输入验证码!");
showVerifyCode();
} else {
$.post("skcart/checkCode?verifyCode="+$("#verifyCodeText").val(),function (data) {
console.log(data);
if(data.code == 200){
console.log("验证码通过,提交请求!");
localStorage.setItem("productId", $("#productId").val());
localStorage.setItem("flashPromotionId", $("#flashPromotionId").val());
localStorage.setItem("memberId", $("#memberId").val());
window.location.href = "static/secKillConfirmOrder.html";
}else{
alert("验证码不正确!");
$("#verifyCodeText").val("");
}
})
}
}
function showVerifyCode(){
$("#verifyCodeImg").attr("src","skcart/verifyCode");
$("#verifyCodeArea").attr("hidden",false);
}
function getProductStock(){
console.log("productId:" + $("#productId").val());
console.log("flashPromotionId:" + $("#flashPromotionId").val());
console.log("memberId:" + $("#memberId").val());
$.get("cache/stock?productId="+$("#productId").val(),function (data) {
console.log(data);
if(data > 0){
$("#secKillbtn").disabled=false;
$("#flashPromotionCount").val(data);
}else{
console.log("秒杀商品已无库存,秒杀结束!");
$("#secKillbtn").disabled=true;
}
})
}
getProductStock();
</script>
</body>
</html>

41
doc/htmljss/product.js Normal file
View File

@@ -0,0 +1,41 @@
function secKill(){
if ($("#verifyCodeText").val() == "") {
console.log("请输入验证码!");
showVerifyCode();
} else {
$.post("skcart/checkCode?verifyCode="+$("#verifyCodeText").val(),function (data) {
console.log(data);
if(data.code == 200){
console.log("验证码通过,提交请求!");
localStorage.setItem("productId", $("#productId").val());
localStorage.setItem("flashPromotionId", $("#flashPromotionId").val());
localStorage.setItem("memberId", $("#memberId").val());
window.location.href = "secKillConfirmOrder.html";
}else{
alert("验证码不正确!");
$("#verifyCodeText").val("");
}
})
}
}
function showVerifyCode(){
$("#verifyCodeImg").src="skcart/verifyCode";
$("#verifyCodeArea").attr("hidden",false);
}
function getProductStock(){
console.log("productId:" + $("#productId").val());
console.log("flashPromotionId:" + $("#flashPromotionId").val());
console.log("memberId:" + $("#memberId").val());
$.get("cache/stock?productId="+$("#productId").val(),function (data) {
console.log(data);
if(data > 0){
$("#secKillbtn").disabled=false;
$("#flashPromotionCount").val(data);
}else{
console.log("秒杀商品已无库存,秒杀结束!");
$("#secKillbtn").disabled=true;
}
})
}

219
doc/htmljss/product.noftl Normal file
View File

@@ -0,0 +1,219 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>图灵商城商品详情页</title>
<link rel="stylesheet" type="text/css" href="static/product.css">
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id="app">
<div>
<div class="header">
<div class="nav-topbar">
<div class="container">
<div class="topbar-menu">
<a href="javascript:;">图灵商城</a></div>
<div class="topbar-user">
<a href="javascript:;">admin</a>
<!---->
<a href="javascript:;">退出</a>
<a href="http://localhost:8081/#/order/list">我的订单</a>
<a href="javascript:;" class="my-cart">
<span class="icon-cart"></span>购物车</a>
</div>
</div>
</div>
<div class="nav-header">
<div class="container">
<div class="header-logo">
<a href="http://localhost:8081/#/index"></a>
</div>
<div class="header-search">
<div class="wrapper">
<input type="text" name="keyword" placeholder="请输入产品关键字">
<a href="javascript:;" class="fa fa-search fa-2x"></a>
</div>
</div>
</div>
</div>
</div>
<div class="detail">
<div class="nav-bar">
<div class="container">
<div class="pro-title">${fpp.name}</div>
<div class="pro-param">
<a href="javascript:;">概述</a>
<span>|</span>
<a href="javascript:;">参数</a>
<span>|</span>
<a href="javascript:;">用户评价</a></div>
</div>
</div>
<div class="wrapper">
<div class="container clearfix">
<div class="swiper">
<div class="swiper-container swiper-container-initialized swiper-container-horizontal">
<div class="swiper-wrapper" style="transform: translate3d(-1284px, 0px, 0px); transition-duration: 0ms;">
<#list imageList as image>
<img src="${image}"/><br>
</#list>
</div>
<div class="swiper-pagination swiper-pagination-clickable swiper-pagination-bullets">
<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 1"></span>
<span class="swiper-pagination-bullet" tabindex="0" role="button" aria-label="Go to slide 2"></span>
<span class="swiper-pagination-bullet swiper-pagination-bullet-active" tabindex="0" role="button" aria-label="Go to slide 3"></span>
</div>
<span class="swiper-notification" aria-live="assertive" aria-atomic="true"></span>
</div>
</div>
<div class="content">
<h2 class="item-title">${fpp.name}</h2>
<p class="item-info">AI智慧全面屏 6GB +64GB 亮黑色 全网通版 移动联通电信4G手机 双卡双待手机 双卡双待</p>
<div class="item-price">${fpp.flashPromotionPrice}元</div>
<div class="line"></div>
<div class="item-version clearfix">
<h2>选择规格</h2>
<div skuid="143" class="phone fl">金色16G</div>
<div skuid="144" class="phone fl">金色32G</div>
<div skuid="145" class="phone fl">银色16G</div>
<div skuid="146" class="phone fl">银色32G</div></div>
<div class="item-total">
<div class="phone-info clearfix">
<div class="stock">
<i aria-hidden="true" class="fa fa-exclamation-triangle f2"></i>请选择规格</div>
<!----></div>
<!----></div>
<div class="btn-group">
<a href="javascript:;" class="btn btn-huge fl" onclick="secKill()" disabled="true" id="secKillbtn">立即秒杀</a></div>
<div class="btn-group">
<span>
<em class="item-price">库存数量</em>
</span>
<span>
<input id="flashPromotionCount" type="text" readonly value="${fpp.flashPromotionCount}">
</span>
</div>
<div class="input" id="verifyCodeArea" hidden="true">
<img id="verifyCodeImg" src="">
<input id="verifyCodeText" type="text" placeholder="请输入验证码">
</div>
<div class="after-sale-info">
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>无忧退货</em></a>
</span>
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>快速退款</em></a>
</span>
<span>
<a href="javascript:void(0);" class="support">
<i aria-hidden="true" class="fa fa-check-circle-o f2"></i>
<em>免费包邮</em></a>
</span>
</div>
</div>
</div>
</div>
<div class="price-info">
<div class="container">
<h2>商品介绍</h2>
<div class="desc">
<p>
<!--{* detailHtml *}-->
</p>
</div>
</div>
</div>
<div class="service">
<div class="container">
<ul>
<li>
<span class="icon-setting"></span>预约维修服务</li>
<li>
<span class="icon-7day"></span>7天无理由退货</li>
<li>
<span class="icon-15day"></span>15天免费换货</li>
<li>
<span class="icon-post"></span>满150元包邮</li>
</ul>
</div>
</div>
</div>
<div data-v-b07fc4c4="" class="footer">
<div data-v-b07fc4c4="" class="footer-logo">
<p data-v-b07fc4c4="">图灵商城</p></div>
<div data-v-b07fc4c4="" class="footer-link">
<a data-v-b07fc4c4="" href="http://www.tulingxueyuan.cn/" target="_blank">图灵学院</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/231516?tuin=a6505b53" target="_blank">腾讯课堂java架构师培训</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/429988" target="_blank">数据结构与算法</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://tuling.ke.qq.com/" target="_blank">腾讯课堂图灵学院</a></div>
<div data-v-b07fc4c4="" class="copyright">Copyright ©2019
<span data-v-b07fc4c4="" class="domain">图灵学院</span>All Rights Reserved.</div></div>
</div>
<input id="memberId" type="hidden" value="{* memberId *}">
<input id="productId" type="hidden" value="{* productId *}">
<input id="flashPromotionId" type="hidden" value="{* flashPromotionId *}">
</div>
<script type="text/javascript" src="static/jquery-1.9.1.min.js"></script>
<script type="text/javascript">
function secKill(){
if ($("#verifyCodeText").val() == "") {
console.log("请输入验证码!");
showVerifyCode();
} else {
$.post("skcart/checkCode?verifyCode="+$("#verifyCodeText").val(),function (data) {
console.log(data);
if(data.code == 200){
console.log("验证码通过,提交请求!");
localStorage.setItem("productId", $("#productId").val());
localStorage.setItem("flashPromotionId", $("#flashPromotionId").val());
localStorage.setItem("memberId", $("#memberId").val());
window.location.href = "static/secKillConfirmOrder.html";
}else{
alert("验证码不正确!");
$("#verifyCodeText").val("");
}
})
}
}
function showVerifyCode(){
$("#verifyCodeImg").attr("src","skcart/verifyCode");
$("#verifyCodeArea").attr("hidden",false);
}
function getProductStock(){
console.log("productId:" + $("#productId").val());
console.log("flashPromotionId:" + $("#flashPromotionId").val());
console.log("memberId:" + $("#memberId").val());
$.get("cache/stock?productId="+$("#productId").val(),function (data) {
console.log(data);
if(data > 0){
$("#secKillbtn").disabled=false;
$("#flashPromotionCount").val(data);
}else{
console.log("秒杀商品已无库存,秒杀结束!");
$("#secKillbtn").disabled=true;
}
})
}
getProductStock();
</script>
</body>
</html>

View File

@@ -0,0 +1,237 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>秒杀订单确认页</title>
<link rel="stylesheet" type="text/css" href="order.css">
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id="app">
<div class="header">
<div class="nav-topbar">
<div class="container">
<div class="topbar-menu">
<a href="javascript:;">图灵商城</a></div>
<div class="topbar-user">
<a href="javascript:;">admin</a>
<!---->
<a href="javascript:;">退出</a>
<a href="http://localhost:8081/#/order/list">我的订单</a>
<a href="javascript:;" class="my-cart">
<span class="icon-cart"></span>购物车</a>
</div>
</div>
</div>
<div class="nav-header">
<div class="container">
<div class="header-logo">
<a href="http://localhost:8081/#/index"></a>
</div>
<div class="header-search">
<div class="wrapper">
<input type="text" name="keyword" placeholder="请输入产品关键字">
<a href="javascript:;" class="fa fa-search fa-2x"></a>
</div>
</div>
</div>
</div>
</div>
<div class="order-pay">
<div class="wrapper">
<div class="order-wrap">
<div class="item-order">
<div class="icon-succ"></div>
<div class="order-info">
<h4>订单号:{{orderSn}}</h4>
<h2>秒杀成功!去付款咯~</h2>
<p>请在<span>30分</span>内完成支付, 超时后将取消订单</p>
<p>收货信息:{{addressInfo}}</p>
</div>
<div class="order-total">
<p>应付总额:</p>
<input id="calcAmount" type="text" readonly>
<p>订单详情<em class="icon-down" :class="{'up':showDetail}" @click="showDetail=!showDetail"></em></p>
<input id="cartPromotionItemList" type="textarea" readonly autoHeight="true">
<span><em>订单详情ID</em></span>
<input id="orderItemId" type="text" readonly>
</div>
</div>
<div class="item-detail" v-if="showDetail">
<div class="item">
<div class="detail-title">订单号:</div>
<div class="detail-info theme-color">
<input id="orderId" type="text" readonly>
</div>
</div>
<div class="item">
<div class="detail-title">收货信息:</div>
<div class="detail-info">
<input id="memberReceiveAddressList" type="textarea" readonly autoHeight="true">
<span><em>实际使用用户地址:</em></span>
<input id="factAddress" type="text" readonly>
</div>
</div>
<div class="item good">
<div class="detail-title">商品名称:</div>
<div class="detail-info">
<ul>
<li v-for="(item,index) in orderDetail" :key="index">
<img v-lazy="item.productImage" />{{item.productName}}
</li>
</ul>
</div>
</div>
<div class="item">
<div class="detail-title">发票信息:</div>
<div class="detail-info">电子发票 个人</div>
</div>
</div>
</div>
<div class="subpay">
<a href="javascript:;" class="btn btn-large " onclick="submitOrder()">提交订单</a>
</div>
</div>
</div>
<!-- <div id="showOrder">
<div>
<span><em>订单ID</em></span>
<input id="orderId" type="text" readonly>
</div>
<div>
<span><em>购买商品:</em></span>
<input id="cartPromotionItemList" type="textarea" readonly autoHeight="true">
<span><em>订单详情ID</em></span>
<input id="orderItemId" type="text" readonly>
</div>
<div>
<span><em>用户地址:</em></span>
<input id="memberReceiveAddressList" type="textarea" readonly autoHeight="true">
<span><em>实际使用用户地址:</em></span>
<input id="factAddress" type="text" readonly>
</div>
<div>
<span><em>金额:</em></span>
<input id="calcAmount" type="text" readonly>
</div>
</div> -->
<div data-v-b07fc4c4="" class="footer">
<div data-v-b07fc4c4="" class="footer-logo">
<p data-v-b07fc4c4="">图灵商城</p></div>
<div data-v-b07fc4c4="" class="footer-link">
<a data-v-b07fc4c4="" href="http://www.tulingxueyuan.cn/" target="_blank">图灵学院</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/231516?tuin=a6505b53" target="_blank">腾讯课堂java架构师培训</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/429988" target="_blank">数据结构与算法</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://tuling.ke.qq.com/" target="_blank">腾讯课堂图灵学院</a></div>
<div data-v-b07fc4c4="" class="copyright">Copyright ©2019
<span data-v-b07fc4c4="" class="domain">图灵学院</span>All Rights Reserved.</div></div>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var lProductId="";
var lFlashPromotionId="";
var lMemberId="";
var lmemberReceiveAddress;
function submitOrder(){
var data = {
orderId: $("#orderId").val(),
orderItemId: $("#orderItemId").val(),
flashPromotionId: lFlashPromotionId,
memberReceiveAddress: lmemberReceiveAddress,
payType: "1",
productId: lProductId
};
$.ajax({
type: "post",
headers: {"memberId": lMemberId},//设置请求头
url: "/seckillOrder/generateOrder",
contentType:"application/json",
dataType: "json",
data: JSON.stringify(data),
success: function(result){
if(result.code==200){
console.log("下订单成功!");
window.location.href = "secKillPay.html";
}else{
alert("下订单失败!");
}
},
error:function(result){
alert("下订单错误!");
}
});
}
function showConfirmOrder(){
lProductId=localStorage.getItem("productId");
lMemberId=localStorage.getItem("memberId");
lFlashPromotionId=localStorage.getItem("flashPromotionId");
$.ajax({
type: "post",
headers:{"memberId": lMemberId},//设置请求头
url:"/skcart/generateConfirmOrder?" +
"productId="+lProductId
+"&flashPromotionId="+lFlashPromotionId,
success:function(commonresult){
if(commonresult.code == 200){
console.log("成功获得秒杀确认单!");
var data = commonresult.data;
console.log(commonresult);
$("#orderId").val(data.orderId);
localStorage.setItem("orderId",data.orderId);
var calcAmount = data.calcAmount;
$("#calcAmount").val(calcAmount.totalAmount);
var cartPromotionItem = data.cartPromotionItemList;
var productN = "";
$.each(cartPromotionItem,function (i,item) {
productN = productN + item.productName + "&&";
$("#orderItemId").val(item.orderItemId);
});
$("#cartPromotionItemList").val(productN);
var umsMemberReceiveAddress = data.memberReceiveAddressList;
var addrs = "";
$.each(umsMemberReceiveAddress,function (i,item) {
addrs = addrs + item.detailAddress + "&&";
lmemberReceiveAddress = item;
$("#factAddress").val(item.detailAddress);
});
$("#memberReceiveAddressList").val(addrs);
}else{
console.log(commonresult);
alert("获得秒杀确认单失败!");
}
},
error:function(data){
console.log(data);
alert("获得秒杀确认单异常!");
}
});
}
showConfirmOrder();
</script>
</body>
</html>

View File

@@ -0,0 +1,128 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<title>秒杀订单确认页</title>
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id="app">
<div id="showOrder">
<div>
<span><em>订单ID</em></span>
<input id="orderId" type="text" readonly>
</div>
<div>
<span><em>购买商品:</em></span>
<input id="cartPromotionItemList" type="textarea" readonly autoHeight="true">
<span><em>订单详情ID</em></span>
<input id="orderItemId" type="text" readonly>
</div>
<div>
<span><em>用户地址:</em></span>
<input id="memberReceiveAddressList" type="textarea" readonly autoHeight="true">
<span><em>实际使用用户地址:</em></span>
<input id="factAddress" type="text" readonly>
</div>
<div>
<span><em>金额:</em></span>
<input id="calcAmount" type="text" readonly>
</div>
</div>
<div>
<a href="javascript:;" onclick="submitOrder()">提交订单</a>
</div>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var lProductId="";
var lFlashPromotionId="";
var lMemberId="";
var lmemberReceiveAddress;
function submitOrder(){
var data = {
orderId: $("#orderId").val(),
orderItemId: $("#orderItemId").val(),
flashPromotionId: lFlashPromotionId,
memberReceiveAddress: lmemberReceiveAddress,
payType: "1",
productId: lProductId
};
$.ajax({
type: "post",
headers: {"memberId": lMemberId},//设置请求头
url: "/seckillOrder/generateOrder",
contentType:"application/json",
dataType: "json",
data: JSON.stringify(data),
success: function(result){
if(result.code==200){
console.log("下订单成功!");
window.location.href = "secKillPay.html";
}else{
alert("下订单失败!");
}
},
error:function(result){
alert("下订单错误!");
}
});
}
function showConfirmOrder(){
lProductId=localStorage.getItem("productId");
lMemberId=localStorage.getItem("memberId");
lFlashPromotionId=localStorage.getItem("flashPromotionId");
$.ajax({
type: "post",
headers:{"memberId": lMemberId},//设置请求头
url:"/skcart/generateConfirmOrder?" +
"productId="+lProductId
+"&flashPromotionId="+lFlashPromotionId,
success:function(commonresult){
if(commonresult.code == 200){
console.log("成功获得秒杀确认单!");
var data = commonresult.data;
console.log(commonresult);
$("#orderId").val(data.orderId);
localStorage.setItem("orderId",data.orderId);
var calcAmount = data.calcAmount;
$("#calcAmount").val(calcAmount.totalAmount);
var cartPromotionItem = data.cartPromotionItemList;
var productN = "";
$.each(cartPromotionItem,function (i,item) {
productN = productN + item.productName + "&&";
$("#orderItemId").val(item.orderItemId);
});
$("#cartPromotionItemList").val(productN);
var umsMemberReceiveAddress = data.memberReceiveAddressList;
var addrs = "";
$.each(umsMemberReceiveAddress,function (i,item) {
addrs = addrs + item.detailAddress + "&&";
lmemberReceiveAddress = item;
$("#factAddress").val(item.detailAddress);
});
$("#memberReceiveAddressList").val(addrs);
}else{
console.log(commonresult);
alert("获得秒杀确认单失败!");
}
},
error:function(data){
console.log(data);
alert("获得秒杀确认单异常!");
}
});
}
showConfirmOrder();
</script>
</body>
</html>

120
doc/htmljss/secKillPay.html Normal file
View File

@@ -0,0 +1,120 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<title>秒杀支付</title>
<link rel="stylesheet" type="text/css" href="order.css">
<link rel="stylesheet" type="text/css" href="common.css">
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div id="app">
<div class="header">
<div class="nav-topbar">
<div class="container">
<div class="topbar-menu">
<a href="javascript:;">图灵商城</a></div>
<div class="topbar-user">
<a href="javascript:;">admin</a>
<!---->
<a href="javascript:;">退出</a>
<a href="http://localhost:8081/#/order/list">我的订单</a>
<a href="javascript:;" class="my-cart">
<span class="icon-cart"></span>购物车</a>
</div>
</div>
</div>
<div class="nav-header">
<div class="container">
<div class="header-logo">
<a href="http://localhost:8081/#/index"></a>
</div>
<div class="header-search">
<div class="wrapper">
<input type="text" name="keyword" placeholder="请输入产品关键字">
<a href="javascript:;" class="fa fa-search fa-2x"></a>
</div>
</div>
</div>
</div>
</div>
<div class="pay">
<div id="payImage" hidden="true">
<h2>请扫码支付,以下为模拟演示图片</h2>
<img src="ewm.jpg" alt="">
</div>
<div id="showProgress">
<h2>请稍候,订单正在生成....</h2>
</div>
</div>
<div data-v-b07fc4c4="" class="footer">
<div data-v-b07fc4c4="" class="footer-logo">
<p data-v-b07fc4c4="">图灵商城</p></div>
<div data-v-b07fc4c4="" class="footer-link">
<a data-v-b07fc4c4="" href="http://www.tulingxueyuan.cn/" target="_blank">图灵学院</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/231516?tuin=a6505b53" target="_blank">腾讯课堂java架构师培训</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://ke.qq.com/course/429988" target="_blank">数据结构与算法</a>
<span data-v-b07fc4c4="">|</span>
<a data-v-b07fc4c4="" href="https://tuling.ke.qq.com/" target="_blank">腾讯课堂图灵学院</a></div>
<div data-v-b07fc4c4="" class="copyright">Copyright ©2019
<span data-v-b07fc4c4="" class="domain">图灵学院</span>All Rights Reserved.</div></div>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var lProductId=localStorage.getItem("productId");
var lFlashPromotionId=localStorage.getItem("memberId");
var lMemberId=localStorage.getItem("flashPromotionId");
var orderId=localStorage.getItem("orderId");
var timer;
var checkCount = 0;
function checkOrder(){
if(checkCount == 10){
alert("检查秒杀订单生成情况已达最大次数,请稍后再试!");
clearInterval(timer);
return;
}
$.ajax({
type: "post",
headers:{"memberId": lMemberId},//设置请求头
url:"/seckillOrder/checkOrder?" + "orderId="+orderId,
success:function(commonresult){
if(commonresult.code==200){
console.log("秒杀订单已生成!");
$("payImage").attr("hidden",false);
$("showProgress").attr("hidden",true);
}else if(commonresult.code==202){
console.log("秒杀订单还未生成,继续检查!");
checkCount++;
}else{
alert("检查秒杀订单生成情况失败!");
}
},
error:function(data){
alert("检查秒杀订单生成情况异常!");
}
});
}
timer = setInterval(checkOrder,5000);
</script>
</body>
</html>

View File

@@ -0,0 +1,64 @@
<!DOCTYPE html>
<!-- saved from url=(0040)http://localhost:8081/#/secKillDetail/26 -->
<html lang="en">
<head>
<title>秒杀支付</title>
</head>
<body>
<noscript>
<strong>We're sorry but mall doesn't work properly without JavaScript enabled. Please enable it to continue.</strong></noscript>
<div>
<div id="payImage" hidden="true">
<h2>请扫码支付,以下为模拟演示图片</h2>
<img src="ewm.jpg" alt="">
</div>
<div id="showProgress">
<h2>请稍候,订单正在生成....</h2>
</div>
</div>
<script type="text/javascript" src="jquery-1.9.1.min.js"></script>
<script type="text/javascript">
var lProductId=localStorage.getItem("productId");
var lFlashPromotionId=localStorage.getItem("memberId");
var lMemberId=localStorage.getItem("flashPromotionId");
var orderId=localStorage.getItem("orderId");
var timer;
var checkCount = 0;
function checkOrder(){
if(checkCount == 10){
alert("检查秒杀订单生成情况已达最大次数,请稍后再试!");
clearInterval(timer);
return;
}
$.ajax({
type: "post",
headers:{"memberId": lMemberId},//设置请求头
url:"/seckillOrder/checkOrder?" + "orderId="+orderId,
success:function(commonresult){
if(commonresult.code==200){
console.log("秒杀订单已生成!");
$("payImage").attr("hidden",false);
$("showProgress").attr("hidden",true);
}else if(commonresult.code==202){
console.log("秒杀订单还未生成,继续检查!");
checkCount++;
}else{
alert("检查秒杀订单生成情况失败!");
}
},
error:function(data){
alert("检查秒杀订单生成情况异常!");
}
});
}
timer = setInterval(checkOrder,5000);
</script>
</body>
</html>

110
doc/nginx/lua/MySQLOps.lua Normal file
View File

@@ -0,0 +1,110 @@
---
--- Created by mark.
--- Desc: 演示对OpenResty中使用Lua对MySQL操作
--- Note本Lua脚本借鉴了网络未经测试仅供参考也不提供任何技术支持
---
local function close_db(db)
if not db then
return
end
db:close()
end
local mysql = require("resty.mysql")
local db, err = mysql:new()
if not db then
ngx.say("new mysql error : ", err)
return
end
db:set_timeout(1000)
local props = {
host = "127.0.0.1",
port = 3306,
database = "mysql",
user = "root",
password = "123"
}
local res, err, errno, sqlstate = db:connect(props)
if not res then
ngx.say("connect to mysql error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
---------------------------------------
-- 执行SQL语句范例
local create_table_sql = "create table test(id int primary key auto_increment, ch varchar(100))"
res, err, errno, sqlstate = db:query(create_table_sql)
if not res then
ngx.say("create table error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
local drop_table_sql = "drop table if exists test"
res, err, errno, sqlstate = db:query(drop_table_sql)
if not res then
ngx.say("drop table error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
local insert_sql = "insert into test (ch) values('hello')"
res, err, errno, sqlstate = db:query(insert_sql)
if not res then
ngx.say("insert error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
res, err, errno, sqlstate = db:query(insert_sql)
ngx.say("insert rows : ", res.affected_rows, " , id : ", res.insert_id, "<br/>")
local update_sql = "update test set ch = 'hello2' where id =" .. res.insert_id
res, err, errno, sqlstate = db:query(update_sql)
if not res then
ngx.say("update error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
ngx.say("update rows : ", res.affected_rows, "<br/>")
local select_sql = "select id, ch from test"
res, err, errno, sqlstate = db:query(select_sql)
if not res then
ngx.say("select error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
for i, row in ipairs(res) do
for name, value in pairs(row) do
ngx.say("select row ", i, " : ", name, " = ", value, "<br/>")
end
end
ngx.say("<br/>")
local ch_param = ngx.req.get_uri_args()["ch"] or ''
local query_sql = "select id, ch from test where ch = " .. ngx.quote_sql_str(ch_param)
res, err, errno, sqlstate = db:query(query_sql)
if not res then
ngx.say("select error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
for i, row in ipairs(res) do
for name, value in pairs(row) do
ngx.say("select row ", i, " : ", name, " = ", value, "<br/>")
end
end
local delete_sql = "delete from test"
res, err, errno, sqlstate = db:query(delete_sql)
if not res then
ngx.say("delete error : ", err, " , errno : ", errno, " , sqlstate : ", sqlstate)
return close_db(db)
end
ngx.say("delete rows : ", res.affected_rows, "<br/>")
close_db(db)

View File

@@ -0,0 +1,320 @@
---
--- Desc: 对OpenResty中使用Lua对Redis操作的封装库支持订阅、管道等功能
--- Note本Lua脚本借鉴了网络未经测试仅供参考也不提供任何技术支持
---
local redis_c = require "resty.redis"
local ok, new_tab = pcall(require, "table.new")
if not ok or type(new_tab) ~= "function" then
new_tab = function (narr, nrec) return {} end
end
local _M = new_tab(0, 155)
_M._VERSION = '0.01'
local commands = {
"append", "auth", "bgrewriteaof",
"bgsave", "bitcount", "bitop",
"blpop", "brpop",
"brpoplpush", "client", "config",
"dbsize",
"debug", "decr", "decrby",
"del", "discard", "dump",
"echo",
"eval", "exec", "exists",
"expire", "expireat", "flushall",
"flushdb", "get", "getbit",
"getrange", "getset", "hdel",
"hexists", "hget", "hgetall",
"hincrby", "hincrbyfloat", "hkeys",
"hlen",
"hmget", "hmset", "hscan",
"hset",
"hsetnx", "hvals", "incr",
"incrby", "incrbyfloat", "info",
"keys",
"lastsave", "lindex", "linsert",
"llen", "lpop", "lpush",
"lpushx", "lrange", "lrem",
"lset", "ltrim", "mget",
"migrate",
"monitor", "move", "mset",
"msetnx", "multi", "object",
"persist", "pexpire", "pexpireat",
"ping", "psetex", "psubscribe",
"pttl",
"publish", --[[ "punsubscribe", ]] "pubsub",
"quit",
"randomkey", "rename", "renamenx",
"restore",
"rpop", "rpoplpush", "rpush",
"rpushx", "sadd", "save",
"scan", "scard", "script",
"sdiff", "sdiffstore",
"select", "set", "setbit",
"setex", "setnx", "setrange",
"shutdown", "sinter", "sinterstore",
"sismember", "slaveof", "slowlog",
"smembers", "smove", "sort",
"spop", "srandmember", "srem",
"sscan",
"strlen", --[[ "subscribe", ]] "sunion",
"sunionstore", "sync", "time",
"ttl",
"type", --[[ "unsubscribe", ]] "unwatch",
"watch", "zadd", "zcard",
"zcount", "zincrby", "zinterstore",
"zrange", "zrangebyscore", "zrank",
"zrem", "zremrangebyrank", "zremrangebyscore",
"zrevrange", "zrevrangebyscore", "zrevrank",
"zscan",
"zscore", "zunionstore", "evalsha"
}
local mt = { __index = _M }
local function is_redis_null( res )
if type(res) == "table" then
for k,v in pairs(res) do
if v ~= ngx.null then
return false
end
end
return true
elseif res == ngx.null then
return true
elseif res == nil then
return true
end
return false
end
function _M.close_redis(self, redis)
if not redis then
return
end
--释放连接(连接池实现)
local pool_max_idle_time = self.pool_max_idle_time --最大空闲时间 毫秒
local pool_size = self.pool_size --连接池大小
local ok, err = redis:set_keepalive(pool_max_idle_time, pool_size)
if not ok then
ngx.say("set keepalive error : ", err)
end
end
-- change connect address as you need
function _M.connect_mod( self, redis )
redis:set_timeout(self.timeout)
local ok, err = redis:connect(self.ip, self.port)
if not ok then
ngx.say("connect to redis error : ", err)
return self:close_redis(redis)
end
if self.password then ----密码认证
local count, err = redis:get_reused_times()
if 0 == count then ----新建连接,需要认证密码
ok, err = redis:auth(self.password)
if not ok then
ngx.say("failed to auth: ", err)
return
end
elseif err then ----从连接池中获取连接,无需再次认证密码
ngx.say("failed to get reused times: ", err)
return
end
end
return ok,err;
end
function _M.init_pipeline( self )
self._reqs = {}
end
function _M.commit_pipeline( self )
local reqs = self._reqs
if nil == reqs or 0 == #reqs then
return {}, "no pipeline"
else
self._reqs = nil
end
local redis, err = redis_c:new()
if not redis then
return nil, err
end
local ok, err = self:connect_mod(redis)
if not ok then
return {}, err
end
redis:init_pipeline()
for _, vals in ipairs(reqs) do
local fun = redis[vals[1]]
table.remove(vals , 1)
fun(redis, unpack(vals))
end
local results, err = redis:commit_pipeline()
if not results or err then
return {}, err
end
if is_redis_null(results) then
results = {}
ngx.log(ngx.WARN, "is null")
end
-- table.remove (results , 1)
--self.set_keepalive_mod(redis)
self:close_redis(redis)
for i,value in ipairs(results) do
if is_redis_null(value) then
results[i] = nil
end
end
return results, err
end
local function do_command(self, cmd, ... )
if self._reqs then
table.insert(self._reqs, {cmd, ...})
return
end
local redis, err = redis_c:new()
if not redis then
return nil, err
end
local ok, err = self:connect_mod(redis)
if not ok or err then
return nil, err
end
redis:select(self.db_index)
local fun = redis[cmd]
local result, err = fun(redis, ...)
if not result or err then
-- ngx.log(ngx.ERR, "pipeline result:", result, " err:", err)
return nil, err
end
if is_redis_null(result) then
result = nil
end
--self.set_keepalive_mod(redis)
self:close_redis(redis)
return result, err
end
for i = 1, #commands do
local cmd = commands[i]
_M[cmd] =
function (self, ...)
return do_command(self, cmd, ...)
end
end
function _M.new(self, opts)
opts = opts or {}
local timeout = (opts.timeout and opts.timeout * 1000) or 1000
local db_index= opts.db_index or 0
local ip = opts.ip or '127.0.0.1'
local port = opts.port or 6379
local password = opts.password
local pool_max_idle_time = opts.pool_max_idle_time or 60000
local pool_size = opts.pool_size or 100
return setmetatable({
timeout = timeout,
db_index = db_index,
ip = ip,
port = port,
password = password,
pool_max_idle_time = pool_max_idle_time,
pool_size = pool_size,
_reqs = nil }, mt)
end
function _M.subscribe( self, channel )
local redis, err = redis_c:new()
if not redis then
return nil, err
end
local ok, err = self:connect_mod(redis)
if not ok or err then
return nil, err
end
local res, err = redis:subscribe(channel)
if not res then
return nil, err
end
local function do_read_func ( do_read )
if do_read == nil or do_read == true then
res, err = redis:read_reply()
if not res then
return nil, err
end
return res
end
redis:unsubscribe(channel)
self.set_keepalive_mod(redis)
return
end
return do_read_func
end
return _M
---------------------------------------
-- 调用案例
local redis = require "RedisExtOps"
local opts = {
ip = "10.11.0.215",
port = "6379",
password = "redis123",
db_index = 1
}
local red = redis:new(opts)
local ok, err = red:set("dog", "an animal")
if not ok then
ngx.say("failed to set dog: ", err)
return
end
ngx.say("set result: ", ok)
---------------------------------------
-- 管道
red:init_pipeline()
red:set("cat", "Marry")
red:set("horse", "Bob")
red:get("cat")
red:get("horse")
local results, err = red:commit_pipeline()
if not results then
ngx.say("failed to commit the pipelined requests: ", err)
return
end
for i, res in ipairs(results) do
ngx.say(res,"<br/>");
end

14
doc/nginx/lua/product.lua Normal file
View File

@@ -0,0 +1,14 @@
-- 导入lua-resty-template函数库
local template = require('resty.template')
local flashPromotionId = ngx.var.arg_flashPromotionId
ngx.log(ngx.ERR, "秒杀活动ID: ", flashPromotionId)
local promotionProductId = ngx.var.arg_promotionProductId
ngx.log(ngx.ERR, "秒杀产品ID: ", promotionProductId)
local templateName = "seckill_"..flashPromotionId.."_"..promotionProductId..".html"
local context = {
memberId = ngx.var.arg_memberId,
productId = promotionProductId,
flashPromotionId = flashPromotionId
}
ngx.log(ngx.ERR, "渲染页面输出获得当前用户ID: ", context.memberId)
template.render(templateName, context)

View File

@@ -0,0 +1,58 @@
-- 导入redis的Lua模块
local redis = require('resty.redis')
-- 初始化redis
local red = redis:new()
red:set_timeouts(1000, 1000, 1000)
-- 关闭redis连接的工具方法其实是放入连接池
local function close_redis(red)
local pool_max_idle_time = 10000 -- 连接的空闲时间,单位是毫秒
local pool_size = 100 --连接池大小
local ok, err = red:set_keepalive(pool_max_idle_time, pool_size)
if not ok then
ngx.log(ngx.ERR, "放入redis连接池失败: ", err)
end
end
-- 查询redis的方法 ip和port是redis地址key是查询的key
local function read_redis(ip, port, key)
-- 获取一个连接
local ok, err = red:connect(ip, port)
if not ok then
ngx.log(ngx.ERR, "连接redis失败 : ", err)
return nil
end
-- 查询redis
local resp, err = red:get(key)
-- 查询失败处理
if not resp then
ngx.log(ngx.ERR, "查询Redis失败: ", err, ", key = " , key)
end
--得到的数据为空处理
if resp == ngx.null then
resp = nil
ngx.log(ngx.ERR, "查询Redis数据为空, key = ", key)
end
close_redis(red)
return resp
end
-- 封装函数发送http请求并解析响应
local function read_http(path, params)
local resp = ngx.location.capture(path,{
method = ngx.HTTP_GET,
args = params,
})
if not resp then
-- 记录错误信息返回404
ngx.log(ngx.ERR, "http查询失败, path: ", path , ", args: ", args)
ngx.exit(404)
end
return resp.body
end
-- 将方法导出
local _M = {
read_http = read_http,
read_redis = read_redis
}
return _M

42
doc/nginx/lua/stock.lua Normal file
View File

@@ -0,0 +1,42 @@
-- 导入redisOps函数库
local redisOps = require('redisOps')
local read_redis = redisOps.read_redis
-- 导入cjson库
local cjson = require('cjson')
-- 导入共享词典,本地缓存
-- 本地缓存的主要目的为库存检查,当商品的库存<=0时提前终止秒杀
-- 这里从业务上来说,同样需要解决退单等引发的库存增加允许重新秒杀的情况,
-- 解决思路同样可以订阅对应的Redis的channel本次不做具体实现Lua订阅Redis的Channel的参考代码写在RedisExtOps.lua中
local item_cache = ngx.shared.stock_cache
-- 封装查询函数
function read_data(key, expire)
-- 查询本地缓存
local val = item_cache:get(key)
if not val then
ngx.log(ngx.ERR, "本地缓存查询失败尝试查询Redis key: ", key)
-- 查询redis
val = read_redis("127.0.0.1", 6379, key)
-- 判断查询结果
if not val then
ngx.log(ngx.ERR, "redis查询失败key: ", key)
-- redis查询失败给一个缺省值
val = 0
end
end
-- 查询成功,把数据写入本地缓存,expire秒后过期
if tonumber(val) <= 0 then
item_cache:set(key, val, expire)
end
-- 返回数据
return val
end
-- 获取请求参数中的productId也可以使用ngx.req.get_uri_args["productId"]req.get_uri_args在productId有多个时会返回一个table
local product_id = ngx.var.arg_productId
-- 查询库存信息
local stock = read_data("miaosha:stock:cache:"..product_id, 3600)
-- 返回结果
ngx.say(cjson.encode(stock))

94
doc/nginx/nginx.conf Normal file
View File

@@ -0,0 +1,94 @@
worker_processes 7; #nginx worker 数量
error_log logs/error.log; #指定错误日志文件路径
events {
worker_connections 1024;
}
http {
include mime.types;
# 这个将为打开文件指定缓存默认是没有启用的max 指定缓存数量,
# 建议和打开文件数一致inactive 是指经过多长时间文件没被请求后删除缓存。
open_file_cache max=100 inactive=30s;
# open_file_cache 指令中的inactive 参数时间内文件的最少使用次数,
# 如果超过这个数字,文件描述符一直是在缓存中打开的,如上例,如果有一个
# 文件在inactive 时间内一次没被使用,它将被移除。
open_file_cache_min_uses 1;
# 这个是指多长时间检查一次缓存的有效信息
open_file_cache_valid 60s;
#开启高效文件传输模式
sendfile on;
#提高I/O性能
tcp_nodelay on;
access_log logs/access.log;
#lua 模块
lua_package_path "/usr/local/openresty/lua/?.lua;/usr/local/openresty/lualib/?.lua;;";
#c模块
lua_package_cpath "/usr/local/openresty/lualib/?.so;;";
lua_code_cache on;
# 共享字典也就是本地缓存名称叫做stock_cache大小1m
lua_shared_dict stock_cache 1m;
#秒杀确认页相关负载均衡
upstream confirm {
server 192.168.65.155:8855;
}
#秒杀订单相关负载均衡
upstream order {
server 192.168.65.133:8844;
}
server {
#监听端口
listen 80;
charset utf-8;
set $template_root /usr/local/openresty/tpl;
location /test {
default_type text/html;
content_by_lua_block {
ngx.say("泰勒斯说万物充满了神明,是让我们把神明拉下神座,从此诸神迎来了他们的黄昏")
}
}
#产品静态模板化网页访问
location /product {
default_type text/html;
content_by_lua_file lua/product.lua;
}
#静态资源访问
location /static {
root /usr/local/openresty;
index index.html index.htm;
}
#秒杀确认页反向代理
location /skcart {
proxy_pass http://confirm;
}
#秒杀订单反向代理
location /seckillOrder {
proxy_pass http://order;
}
#秒杀产品当前库存
location /cache/stock {
# 默认的响应类型
default_type application/json;
# 响应结果由lua/stock.lua文件来处理
content_by_lua_file lua/stock.lua;
}
}
}

View File

@@ -0,0 +1,688 @@
local setmetatable = setmetatable
local loadstring = loadstring
local tostring = tostring
local setfenv = setfenv
local require = require
local concat = table.concat
local assert = assert
local write = io.write
local pcall = pcall
local phase
local open = io.open
local load = load
local type = type
local dump = string.dump
local find = string.find
local gsub = string.gsub
local byte = string.byte
local null
local sub = string.sub
local ngx = ngx
local jit = jit
local var
local _VERSION = _VERSION
local _ENV = _ENV -- luacheck: globals _ENV
local _G = _G
local HTML_ENTITIES = {
["&"] = "&amp;",
["<"] = "&lt;",
[">"] = "&gt;",
['"'] = "&quot;",
["'"] = "&#39;",
["/"] = "&#47;"
}
local CODE_ENTITIES = {
["{"] = "&#123;",
["}"] = "&#125;",
["&"] = "&amp;",
["<"] = "&lt;",
[">"] = "&gt;",
['"'] = "&quot;",
["'"] = "&#39;",
["/"] = "&#47;"
}
local VAR_PHASES
local ESC = byte("\27")
local NUL = byte("\0")
local HT = byte("\t")
local VT = byte("\v")
local LF = byte("\n")
local SOL = byte("/")
local BSOL = byte("\\")
local SP = byte(" ")
local AST = byte("*")
local NUM = byte("#")
local LPAR = byte("(")
local LSQB = byte("[")
local LCUB = byte("{")
local MINUS = byte("-")
local PERCNT = byte("%")
local EMPTY = ""
local VIEW_ENV
if _VERSION == "Lua 5.1" then
VIEW_ENV = { __index = function(t, k)
return t.context[k] or t.template[k] or _G[k]
end }
else
VIEW_ENV = { __index = function(t, k)
return t.context[k] or t.template[k] or _ENV[k]
end }
end
local newtab
do
local ok
ok, newtab = pcall(require, "table.new")
if not ok then newtab = function() return {} end end
end
local function enabled(val)
if val == nil then return true end
return val == true or (val == "1" or val == "true" or val == "on")
end
local function trim(s)
return gsub(gsub(s, "^%s+", EMPTY), "%s+$", EMPTY)
end
local function rpos(view, s)
while s > 0 do
local c = byte(view, s, s)
if c == SP or c == HT or c == VT or c == NUL then
s = s - 1
else
break
end
end
return s
end
local function escaped(view, s)
if s > 1 and byte(view, s - 1, s - 1) == BSOL then
if s > 2 and byte(view, s - 2, s - 2) == BSOL then
return false, 1
else
return true, 1
end
end
return false, 0
end
local function read_file(path)
local file, err = open(path, "rb")
if not file then return nil, err end
local content
content, err = file:read "*a"
file:close()
return content, err
end
local print_view
local load_view
if ngx then
print_view = ngx.print or write
var = ngx.var
null = ngx.null
phase = ngx.get_phase
VAR_PHASES = {
set = true,
rewrite = true,
access = true,
content = true,
header_filter = true,
body_filter = true,
log = true,
preread = true
}
local capture = ngx.location.capture
local prefix = ngx.config.prefix()
load_view = function(template)
return function(view, plain)
if plain == true then return view end
local vars = VAR_PHASES[phase()]
local path = view
local root = template.location
if (not root or root == EMPTY) and vars then
root = var.template_location
end
if root and root ~= EMPTY then
if byte(root, -1) == SOL then root = sub(root, 1, -2) end
if byte(path, 1) == SOL then path = sub(path, 2) end
path = root .. "/" .. path
local res = capture(path)
if res.status == 200 then return res.body end
end
path = view
root = template.root
if (not root or root == EMPTY) and vars then
root = var.template_root
if not root or root == EMPTY then root = var.document_root or prefix end
end
if root and root ~= EMPTY then
if byte(root, -1) == SOL then root = sub(root, 1, -2) end
if byte(path, 1) == SOL then path = sub(path, 2) end
path = root .. "/" .. path
end
return plain == false and assert(read_file(path)) or read_file(path) or view
end
end
else
print_view = write
load_view = function(template)
return function(view, plain)
if plain == true then return view end
local path, root = view, template.root
if root and root ~= EMPTY then
if byte(root, -1) == SOL then root = sub(root, 1, -2) end
if byte(view, 1) == SOL then path = sub(view, 2) end
path = root .. "/" .. path
end
return plain == false and assert(read_file(path)) or read_file(path) or view
end
end
end
local function load_file(func)
return function(view) return func(view, false) end
end
local function load_string(func)
return function(view) return func(view, true) end
end
local loader
if jit or _VERSION ~= "Lua 5.1" then
loader = function(template)
return function(view)
return assert(load(view, nil, nil, setmetatable({ template = template }, VIEW_ENV)))
end
end
else
loader = function(template)
return function(view)
local func = assert(loadstring(view))
setfenv(func, setmetatable({ template = template }, VIEW_ENV))
return func
end
end
end
local function visit(visitors, content, tag, name)
if not visitors then
return content
end
for i = 1, visitors.n do
content = visitors[i](content, tag, name)
end
return content
end
local function new(template, safe)
template = template or newtab(0, 26)
template._VERSION = "2.0"
template.cache = {}
template.load = load_view(template)
template.load_file = load_file(template.load)
template.load_string = load_string(template.load)
template.print = print_view
local load_chunk = loader(template)
local caching
if VAR_PHASES and VAR_PHASES[phase()] then
caching = enabled(var.template_cache)
else
caching = true
end
local visitors
function template.visit(func)
if not visitors then
visitors = { func, n = 1 }
return
end
visitors.n = visitors.n + 1
visitors[visitors.n] = func
end
function template.caching(enable)
if enable ~= nil then caching = enable == true end
return caching
end
function template.output(s)
if s == nil or s == null then return EMPTY end
if type(s) == "function" then return template.output(s()) end
return tostring(s)
end
function template.escape(s, c)
if type(s) == "string" then
if c then return gsub(s, "[}{\">/<'&]", CODE_ENTITIES) end
return gsub(s, "[\">/<'&]", HTML_ENTITIES)
end
return template.output(s)
end
function template.new(view, layout)
local vt = type(view)
if vt == "boolean" then return new(nil, view) end
if vt == "table" then return new(view, safe) end
if vt == "nil" then return new(nil, safe) end
local render
local process
if layout then
if type(layout) == "table" then
render = function(self, context)
context = context or self
context.blocks = context.blocks or {}
context.view = function(ctx) return template.process(view, ctx or context) end
layout.blocks = context.blocks or {}
layout.view = context.view or EMPTY
layout:render()
end
process = function(self, context)
context = context or self
context.blocks = context.blocks or {}
context.view = function(ctx) return template.process(view, ctx or context) end
layout.blocks = context.blocks or {}
layout.view = context.view
return tostring(layout)
end
else
render = function(self, context)
context = context or self
context.blocks = context.blocks or {}
context.view = function(ctx) return template.process(view, ctx or context) end
template.render(layout, context)
end
process = function(self, context)
context = context or self
context.blocks = context.blocks or {}
context.view = function(ctx) return template.process(view, ctx or context) end
return template.process(layout, context)
end
end
else
render = function(self, context)
return template.render(view, context or self)
end
process = function(self, context)
return template.process(view, context or self)
end
end
if safe then
return setmetatable({
render = function(...)
local ok, err = pcall(render, ...)
if not ok then
return nil, err
end
end,
process = function(...)
local ok, output = pcall(process, ...)
if not ok then
return nil, output
end
return output
end,
}, {
__tostring = function(...)
local ok, output = pcall(process, ...)
if not ok then
return ""
end
return output
end })
end
return setmetatable({
render = render,
process = process
}, {
__tostring = process
})
end
function template.precompile(view, path, strip, plain)
local chunk = dump(template.compile(view, nil, plain), strip ~= false)
if path then
local file = open(path, "wb")
file:write(chunk)
file:close()
end
return chunk
end
function template.precompile_string(view, path, strip)
return template.precompile(view, path, strip, true)
end
function template.precompile_file(view, path, strip)
return template.precompile(view, path, strip, false)
end
function template.compile(view, cache_key, plain)
assert(view, "view was not provided for template.compile(view, cache_key, plain)")
if cache_key == "no-cache" then
return load_chunk(template.parse(view, plain)), false
end
cache_key = cache_key or view
local cache = template.cache
if cache[cache_key] then return cache[cache_key], true end
local func = load_chunk(template.parse(view, plain))
if caching then cache[cache_key] = func end
return func, false
end
function template.compile_file(view, cache_key)
return template.compile(view, cache_key, false)
end
function template.compile_string(view, cache_key)
return template.compile(view, cache_key, true)
end
function template.parse(view, plain)
assert(view, "view was not provided for template.parse(view, plain)")
if plain ~= true then
view = template.load(view, plain)
if byte(view, 1, 1) == ESC then return view end
end
local j = 2
local c = {[[
context=... or {}
local ___,blocks,layout={},blocks or {}
local function include(v, c) return template.process(v, c or context) end
local function echo(...) for i=1,select("#", ...) do ___[#___+1] = tostring(select(i, ...)) end end
]] }
local i, s = 1, find(view, "{", 1, true)
while s do
local t, p = byte(view, s + 1, s + 1), s + 2
if t == LCUB then
local e = find(view, "}}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=template.escape("
c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "{")
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == AST then
local e = find(view, "*}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=template.output("
c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "*")
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == PERCNT then
local e = find(view, "%}", p, true)
if e then
local z, w = escaped(view, s)
if z then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
i = s
else
local n = e + 2
if byte(view, n, n) == LF then
n = n + 1
end
local r = rpos(view, s - 1)
if i <= r then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, r))
c[j+2] = "]=]\n"
j=j+3
end
c[j] = visit(visitors, trim(sub(view, p, e - 1)), "%")
c[j+1] = "\n"
j=j+2
s, i = n - 1, n
end
end
elseif t == LPAR then
local e = find(view, ")}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
local f = visit(visitors, sub(view, p, e - 1), "(")
local x = find(f, ",", 2, true)
if x then
c[j] = "___[#___+1]=include([=["
c[j+1] = trim(sub(f, 1, x - 1))
c[j+2] = "]=],"
c[j+3] = trim(sub(f, x + 1))
c[j+4] = ")\n"
j=j+5
else
c[j] = "___[#___+1]=include([=["
c[j+1] = trim(f)
c[j+2] = "]=])\n"
j=j+3
end
s, i = e + 1, e + 2
end
end
elseif t == LSQB then
local e = find(view, "]}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
c[j] = "___[#___+1]=include("
c[j+1] = visit(visitors, trim(sub(view, p, e - 1)), "[")
c[j+2] = ")\n"
j=j+3
s, i = e + 1, e + 2
end
end
elseif t == MINUS then
local e = find(view, "-}", p, true)
if e then
local x, y = find(view, sub(view, s, e + 1), e + 2, true)
if x then
local z, w = escaped(view, s)
if z then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
i = s
else
y = y + 1
x = x - 1
if byte(view, y, y) == LF then
y = y + 1
end
local b = trim(sub(view, p, e - 1))
if b == "verbatim" or b == "raw" then
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
c[j] = "___[#___+1]=[=["
c[j+1] = visit(visitors, sub(view, e + 2, x))
c[j+2] = "]=]\n"
j=j+3
else
if byte(view, x, x) == LF then
x = x - 1
end
local r = rpos(view, s - 1)
if i <= r then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, r))
c[j+2] = "]=]\n"
j=j+3
end
c[j] = 'blocks["'
c[j+1] = b
c[j+2] = '"]=include[=['
c[j+3] = visit(visitors, sub(view, e + 2, x), "-", b)
c[j+4] = "]=]\n"
j=j+5
end
s, i = y - 1, y
end
end
end
elseif t == NUM then
local e = find(view, "#}", p, true)
if e then
local z, w = escaped(view, s)
if i < s - w then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, sub(view, i, s - 1 - w))
c[j+2] = "]=]\n"
j=j+3
end
if z then
i = s
else
e = e + 2
if byte(view, e, e) == LF then
e = e + 1
end
s, i = e - 1, e
end
end
end
s = find(view, "{", s + 1, true)
end
s = sub(view, i)
if s and s ~= EMPTY then
c[j] = "___[#___+1]=[=[\n"
c[j+1] = visit(visitors, s)
c[j+2] = "]=]\n"
j=j+3
end
c[j] = "return layout and include(layout,setmetatable({view=table.concat(___),blocks=blocks},{__index=context})) or table.concat(___)" -- luacheck: ignore
return concat(c)
end
function template.parse_file(view)
return template.parse(view, false)
end
function template.parse_string(view)
return template.parse(view, true)
end
function template.process(view, context, cache_key, plain)
assert(view, "view was not provided for template.process(view, context, cache_key, plain)")
return template.compile(view, cache_key, plain)(context)
end
function template.process_file(view, context, cache_key)
assert(view, "view was not provided for template.process_file(view, context, cache_key)")
return template.compile(view, cache_key, false)(context)
end
function template.process_string(view, context, cache_key)
assert(view, "view was not provided for template.process_string(view, context, cache_key)")
return template.compile(view, cache_key, true)(context)
end
function template.render(view, context, cache_key, plain)
assert(view, "view was not provided for template.render(view, context, cache_key, plain)")
template.print(template.process(view, context, cache_key, plain))
end
function template.render_file(view, context, cache_key)
assert(view, "view was not provided for template.render_file(view, context, cache_key)")
template.render(view, context, cache_key, false)
end
function template.render_string(view, context, cache_key)
assert(view, "view was not provided for template.render_string(view, context, cache_key)")
template.render(view, context, cache_key, true)
end
if safe then
return setmetatable({}, {
__index = function(_, k)
if type(template[k]) == "function" then
return function(...)
local ok, a, b = pcall(template[k], ...)
if not ok then
return nil, a
end
return a, b
end
end
return template[k]
end,
__new_index = function(_, k, v)
template[k] = v
end,
})
end
return template
end
return new()

View File

@@ -0,0 +1,52 @@
local template = require "resty.template"
local setmetatable = setmetatable
local escape = template.escape
local concat = table.concat
local pairs = pairs
local type = type
local function tag(name, content, attr)
local r, a = {}, {}
content = content or attr
r[#r + 1] = "<"
r[#r + 1] = name
if attr then
for k, v in pairs(attr) do
if type(k) == "number" then
a[#a + 1] = escape(v)
else
a[#a + 1] = k .. '="' .. escape(v) .. '"'
end
end
if #a > 0 then
r[#r + 1] = " "
r[#r + 1] = concat(a, " ")
end
end
if type(content) == "string" then
r[#r + 1] = ">"
r[#r + 1] = escape(content)
r[#r + 1] = "</"
r[#r + 1] = name
r[#r + 1] = ">"
else
r[#r + 1] = " />"
end
return concat(r)
end
local html = { __index = function(_, name)
return function(attr)
if type(attr) == "table" then
return function(content)
return tag(name, content, attr)
end
else
return tag(name, attr)
end
end
end }
template.html = setmetatable(html, html)
return template.html

View File

@@ -0,0 +1,153 @@
local template = require "resty.template"
local ok, new_tab = pcall(require, "table.new")
if not ok then
new_tab = function() return {} end
end
local function run(iterations)
local gc, total, print, parse, compile, clock, format = collectgarbage, 0, ngx and ngx.say or print, template.parse,
template.compile, os.clock, string.format
iterations = iterations or 1000
local view = [[
<ul>
{% for _, v in ipairs(context) do %}
<li>{{v}}</li>
{% end %}
</ul>]]
print(format("Running %d iterations in each test", iterations))
gc()
gc()
local x = clock()
for _ = 1, iterations do
parse(view, true)
end
local z = clock() - x
print(format(" Parsing Time: %.6f", z))
total = total + z
gc()
gc()
x = clock()
for _ = 1, iterations do
compile(view, nil, true)
template.cache = {}
end
z = clock() - x
print(format("Compilation Time: %.6f (template)", z))
total = total + z
compile(view, nil, true)
gc()
gc()
x = clock()
for _ = 1, iterations do
compile(view, 1, true)
end
z = clock() - x
print(format("Compilation Time: %.6f (template, cached)", z))
total = total + z
local context = { "Emma", "James", "Nicholas", "Mary" }
template.cache = {}
gc()
gc()
x = clock()
for _ = 1, iterations do
compile(view, 1, true)(context)
template.cache = {}
end
z = clock() - x
print(format(" Execution Time: %.6f (same template)", z))
total = total + z
template.cache = {}
compile(view, 1, true)
gc()
gc()
x = clock()
for _ = 1, iterations do
compile(view, 1, true)(context)
end
z = clock() - x
print(format(" Execution Time: %.6f (same template, cached)", z))
total = total + z
template.cache = {}
local views = new_tab(iterations, 0)
for i = 1, iterations do
views[i] = "<h1>Iteration " .. i .. "</h1>\n" .. view
end
gc()
gc()
x = clock()
for i = 1, iterations do
compile(views[i], i, true)(context)
end
z = clock() - x
print(format(" Execution Time: %.6f (different template)", z))
total = total + z
gc()
gc()
x = clock()
for i = 1, iterations do
compile(views[i], i, true)(context)
end
z = clock() - x
print(format(" Execution Time: %.6f (different template, cached)", z))
total = total + z
local contexts = new_tab(iterations, 0)
for i = 1, iterations do
contexts[i] = { "Emma", "James", "Nicholas", "Mary" }
end
template.cache = {}
gc()
gc()
x = clock()
for i = 1, iterations do
compile(views[i], i, true)(contexts[i])
end
z = clock() - x
print(format(" Execution Time: %.6f (different template, different context)", z))
total = total + z
gc()
gc()
x = clock()
for i = 1, iterations do
compile(views[i], i, true)(contexts[i])
end
z = clock() - x
print(format(" Execution Time: %.6f (different template, different context, cached)", z))
total = total + z
print(format(" Total Time: %.6f", total))
end
return {
run = run
}

View File

@@ -0,0 +1,2 @@
return require "resty.template".new(true)

275
pom.xml Normal file
View File

@@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.tuling</groupId>
<artifactId>tuling-mall</artifactId>
<version>0.0.5</version>
<name>tuling-mall</name>
<packaging>pom</packaging>
<description>图灵电商项目</description>
<modules>
<module>tulingmall-admin</module>
<module>tulingmall-common</module>
<module>tulingmall-product</module>
<module>tulingmall-security</module>
<module>tulingmall-search</module>
<module>tulingmall-member</module>
<module>tulingmall-gateway</module>
<module>tulingmall-promotion</module>
<module>tulingmall-canal</module>
<module>tulingmall-authcenter</module>
<module>tulingmall-portal</module>
<module>tulingmall-order</module>
<module>tulingmall-cart</module>
<module>tulingmall-core</module>
<module>tulingmall-unqid</module>
<module>tulingmall-redis-comm</module>
<module>tulingmall-redis-multi</module>
<module>tulingmall-sk</module>
</modules>
<properties>
<skipTests>true</skipTests>
<docker.host>http://192.168.6.132:2375</docker.host>
<docker.maven.plugin.version>1.1.0</docker.maven.plugin.version>
<java.version>1.8</java.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<pagehelper-starter.version>1.2.10</pagehelper-starter.version>
<pagehelper.version>5.1.8</pagehelper.version>
<druid.version>1.1.10</druid.version>
<freemarker.version>2.3.30</freemarker.version>
<hutool.version>4.5.7</hutool.version>
<swagger2.version>2.7.0</swagger2.version>
<mybatis-generator.version>1.3.7</mybatis-generator.version>
<mybatis.version>3.5.3</mybatis.version>
<mybatis-plus.version>3.3.2</mybatis-plus.version>
<dynamic-datasource.version>3.3.2</dynamic-datasource.version>
<mysql-connector.version>8.0.15</mysql-connector.version>
<commons-pool2.version>2.4.3</commons-pool2.version>
<dungproxy-client.version>0.0.4</dungproxy-client.version>
<rocketmq-spring-boot-starter.version>2.2.1</rocketmq-spring-boot-starter.version>
<mongodb-spring-boot-starter.version>2.3.2.RELEASE</mongodb-spring-boot-starter.version>
<jjwt.version>0.9.0</jjwt.version>
<aliyun-oss.version>2.5.0</aliyun-oss.version>
<logstash-logback.version>5.3</logstash-logback.version>
<tulingmall-common.version>${project.version}</tulingmall-common.version>
<tulingmall-admin.version>${project.version}</tulingmall-admin.version>
<tulingmall-core.version>${project.version}</tulingmall-core.version>
<tulingmall-security.version>${project.version}</tulingmall-security.version>
<tulingmall-redis-comm.version>${project.version}</tulingmall-redis-comm.version>
<tulingmall-redis-multi.version>${project.version}</tulingmall-redis-multi.version>
<spring-cloud.version>Hoxton.SR9</spring-cloud.version>
<spring-cloud-alibaba.version>2.2.6.RELEASE</spring-cloud-alibaba.version>
</properties>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.2.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--Spring Cloud 相关依赖-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<!--Spring Cloud Alibaba 相关依赖-->
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
<version>${spring-cloud-alibaba.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
<version>2.1.1.RELEASE</version>
</dependency>
<!--mall通用模块-->
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-common</artifactId>
<version>${tulingmall-common.version}</version>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-security</artifactId>
<version>${tulingmall-security.version}</version>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-core</artifactId>
<version>${tulingmall-core.version}</version>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-admin</artifactId>
<version>${tulingmall-admin.version}</version>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-redis-comm</artifactId>
<version>${tulingmall-redis-comm.version}</version>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-redis-multi</artifactId>
<version>${tulingmall-redis-multi.version}</version>
</dependency>
<!--MyBatis分页插件starter-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>${pagehelper-starter.version}</version>
</dependency>
<!--MyBatis分页插件-->
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper</artifactId>
<version>${pagehelper.version}</version>
</dependency>
<!--集成druid连接池-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid-spring-boot-starter</artifactId>
<version>${druid.version}</version>
</dependency>
<!--Hutool Java工具包-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
<!--Swagger-UI API文档生产工具-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${swagger2.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${swagger2.version}</version>
</dependency>
<!-- MyBatis 生成器 -->
<dependency>
<groupId>org.mybatis.generator</groupId>
<artifactId>mybatis-generator-core</artifactId>
<version>${mybatis-generator.version}</version>
</dependency>
<!-- MyBatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>${mybatis.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>${mybatis-plus.version}</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>${dynamic-datasource.version}</version>
</dependency>
<!--Mysql数据库驱动-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql-connector.version}</version>
</dependency>
<!--JWT(Json Web Token)登录支持-->
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>${jjwt.version}</version>
</dependency>
<!-- 阿里云OSS -->
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>${aliyun-oss.version}</version>
</dependency>
<!--集成logstash-->
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
<version>${logstash-logback.version}</version>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
<version>${freemarker.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-pool2</artifactId>
<version>${commons-pool2.version}</version>
</dependency>
<dependency>
<groupId>org.apache.rocketmq</groupId>
<artifactId>rocketmq-spring-boot-starter</artifactId>
<version>${rocketmq-spring-boot-starter.version}</version>
</dependency>
<dependency>
<groupId>com.virjar</groupId>
<artifactId>dungproxy-client</artifactId>
<version>${dungproxy-client.version}</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
<version>${mongodb-spring-boot-starter.version}</version>
</dependency>
</dependencies>
</dependencyManagement>
<repositories>
<repository>
<id>maven-public</id>
<url>http://192.168.65.203:8081/repository/maven-public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>maven-public</id>
<name>release</name>
<url>http://192.168.65.203:8081/repository/maven-releases/</url>
</repository>
<snapshotRepository>
<id>maven-public-snapshot</id>
<name>snapshot</name>
<url>http://192.168.65.203:8081/repository/maven-snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>

31
readme.md Normal file
View File

@@ -0,0 +1,31 @@
### 模块说明
tulingmall-admin 后台管理程序
tulingmall-authcenter 认证中心程序
tulingmall-canal 数据同步程序
tulingmall-cart 购物车程序
tulingmall-common 通用模块被其他程序以jar包形式使用
tulingmall-core 四期遗留模块主要包含model的声明被其他程序以jar包形式使用
tulingmall-gateway 网关程序
tulingmall-member 用户管理程序
tulingmall-order-curr 订单程序
tulingmall-order-history 历史订单处理程序
tulingmall-portal 商城首页入口程序
tulingmall-product 商品管理程序
tulingmall-promotion 促销管理程序
tulingmall-redis-comm 缓存模块被其他程序以jar包形式使用
tulingmall-redis-multi 多源缓存模块被其他程序以jar包形式使用
tulingmall-search 商品搜索程序
tulingmall-security 安全模块被其他程序以jar包形式使用
tulingmall-sk-cart 秒杀确认单处理
tulingmall-sk-order 秒杀订单处理
tulingmall-unqid 分布式ID生成程序
### 关键服务建议启动顺序
tulingmall-unqid、tulingmall-member、tulingmall-product、tulingmall-cart
tulingmall-promotion、tulingmall-authcenter
tulingmall-order-curr、tulingmall-portal、tulingmall-gateway
### doc目录说明
htmljss 秒杀静态网页、JS文件、CSS文件等
nginx 秒杀nginx配置、Lua脚本、第三方Lua库
### 本地运行
商城在本地运行需要本地存在MySQL、Nacos、Canal等基础服务
秒杀系统牵涉较复杂,暂不提供本地完整运行版本

31
tulingmall-admin/.gitignore vendored Normal file
View File

@@ -0,0 +1,31 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**
!**/src/test/**
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
### VS Code ###
.vscode/

187
tulingmall-admin/pom.xml Normal file
View File

@@ -0,0 +1,187 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.tuling</groupId>
<artifactId>tuling-mall</artifactId>
<version>0.0.5</version>
</parent>
<artifactId>tulingmall-admin</artifactId>
<name>tulingmall-admin</name>
<description>商城统一管理后台</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.cloud</groupId>
<artifactId>spring-cloud-alibaba-nacos-discovery</artifactId>
</dependency>
<dependency>
<groupId>com.tuling</groupId>
<artifactId>tulingmall-security</artifactId>
<exclusions>
<exclusion>
<artifactId>mybatis</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>mybatis-spring</artifactId>
<groupId>org.mybatis</groupId>
</exclusion>
<exclusion>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<groupId>com.github.pagehelper</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.4.3</version>
</dependency>
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
</dependency>
<dependency>
<groupId>net.logstash.logback</groupId>
<artifactId>logstash-logback-encoder</artifactId>
</dependency>
<dependency>
<groupId>org.freemarker</groupId>
<artifactId>freemarker</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-generator</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.8.RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>2.3.2.RELEASE</version>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
<!-- 解决运行包不能被其他包依赖的问题 -->
<!-- <configuration>-->
<!-- <classifier>exec</classifier>-->
<!-- </configuration>-->
</plugin>
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-jar-plugin</artifactId>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>com.spotify</groupId>-->
<!-- <artifactId>docker-maven-plugin</artifactId>-->
<!-- <version>${docker.maven.plugin.version}</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>build-image</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>build</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <configuration>-->
<!-- <imageName>mall/${project.artifactId}:${project.version}</imageName>-->
<!-- <dockerHost>${docker.host}</dockerHost>-->
<!-- <baseImage>java:8</baseImage>-->
<!-- <entryPoint>["java", "-jar", "-Dspring.profiles.active=prod","/${project.build.finalName}.jar"]</entryPoint>-->
<!-- <resources>-->
<!-- <resource>-->
<!-- <targetPath>/</targetPath>-->
<!-- <directory>${project.build.directory}</directory>-->
<!-- <include>${project.build.finalName}.jar</include>-->
<!-- </resource>-->
<!-- </resources>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>org.apache.maven.plugins</groupId>-->
<!-- <artifactId>maven-dependency-plugin</artifactId>-->
<!-- &lt;!&ndash; <version>2.10</version> &ndash;&gt;-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <id>copy-dependencies</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>copy-dependencies</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <outputDirectory>export</outputDirectory> &lt;!&ndash; 将依赖包放入export文件夹 &ndash;&gt;-->
<!-- <excludeTransitive>false</excludeTransitive>-->
<!-- <stripVersion>true</stripVersion>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- </plugin>-->
</plugins>
</build>
</project>

View File

@@ -0,0 +1,22 @@
package com.tuling.tulingmall;
import com.alibaba.druid.spring.boot.autoconfigure.DruidDataSourceAutoConfigure;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.transaction.annotation.EnableTransactionManagement;
/**
* 应用启动入口
* Created on 2018/4/26.
*/
@SpringBootApplication(exclude = DruidDataSourceAutoConfigure.class)
@EnableTransactionManagement
@EnableFeignClients
@MapperScan({"com.tuling.tulingmall.mapper","com.tuling.tulingmall.dao"})
public class MallAdminApplication {
public static void main(String[] args) {
SpringApplication.run(MallAdminApplication.class, args);
}
}

View File

@@ -0,0 +1,63 @@
package com.tuling.tulingmall.bo;
import com.tuling.tulingmall.model.UmsAdmin;
import com.tuling.tulingmall.model.UmsPermission;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
/**
* SpringSecurity需要的用户详情
* Created on 2018/4/26.
*/
public class AdminUserDetails implements UserDetails {
private UmsAdmin umsAdmin;
private List<UmsPermission> permissionList;
public AdminUserDetails(UmsAdmin umsAdmin,List<UmsPermission> permissionList) {
this.umsAdmin = umsAdmin;
this.permissionList = permissionList;
}
@Override
public Collection<? extends GrantedAuthority> getAuthorities() {
//返回当前用户的权限
return permissionList.stream()
.filter(permission -> permission.getValue()!=null)
.map(permission ->new SimpleGrantedAuthority(permission.getValue()))
.collect(Collectors.toList());
}
@Override
public String getPassword() {
return umsAdmin.getPassword();
}
@Override
public String getUsername() {
return umsAdmin.getUsername();
}
@Override
public boolean isAccountNonExpired() {
return true;
}
@Override
public boolean isAccountNonLocked() {
return true;
}
@Override
public boolean isCredentialsNonExpired() {
return true;
}
@Override
public boolean isEnabled() {
return umsAdmin.getStatus().equals(1);
}
}

View File

@@ -0,0 +1,144 @@
package com.tuling.tulingmall.bo;
/**
* Controller层的日志封装类
* Created on 2018/4/26.
*/
public class WebLog {
/**
* 操作描述
*/
private String description;
/**
* 操作用户
*/
private String username;
/**
* 操作时间
*/
private Long startTime;
/**
* 消耗时间
*/
private Integer spendTime;
/**
* 根路径
*/
private String basePath;
/**
* URI
*/
private String uri;
/**
* URL
*/
private String url;
/**
* 请求类型
*/
private String method;
/**
* IP地址
*/
private String ip;
private Object parameter;
private Object result;
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getUsername() {
return username;
}
public void setUsername(String username) {
this.username = username;
}
public Long getStartTime() {
return startTime;
}
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
public Integer getSpendTime() {
return spendTime;
}
public void setSpendTime(Integer spendTime) {
this.spendTime = spendTime;
}
public String getBasePath() {
return basePath;
}
public void setBasePath(String basePath) {
this.basePath = basePath;
}
public String getUri() {
return uri;
}
public void setUri(String uri) {
this.uri = uri;
}
public String getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getIp() {
return ip;
}
public void setIp(String ip) {
this.ip = ip;
}
public Object getParameter() {
return parameter;
}
public void setParameter(Object parameter) {
this.parameter = parameter;
}
public Object getResult() {
return result;
}
public void setResult(Object result) {
this.result = result;
}
}

View File

@@ -0,0 +1,34 @@
package com.tuling.tulingmall.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
* 全局跨域配置
* Created on 2019/7/27.
*/
@Configuration
public class GlobalCorsConfig {
/**
* 允许跨域调用的过滤器
*/
@Bean
public CorsFilter corsFilter() {
CorsConfiguration config = new CorsConfiguration();
//允许所有域名进行跨域调用
config.addAllowedOrigin("*");
//允许跨越发送cookie
config.setAllowCredentials(true);
//放行全部原始头信息
config.addAllowedHeader("*");
//允许所有请求方法跨域调用
config.addAllowedMethod("*");
UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
source.registerCorsConfiguration("/**", config);
return new CorsFilter(source);
}
}

View File

@@ -0,0 +1,29 @@
package com.tuling.tulingmall.config;
import com.tuling.tulingmall.security.config.SecurityConfig;
import com.tuling.tulingmall.service.UmsAdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;
/**
* mall-security模块相关配置
* Created on 2019/11/5.
*/
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class MallSecurityConfig extends SecurityConfig {
@Autowired
private UmsAdminService adminService;
@Bean
public UserDetailsService userDetailsService() {
//获取登录用户信息
return username -> adminService.loadUserByUsername(username);
}
}

View File

@@ -0,0 +1,23 @@
package com.tuling.tulingmall.config;
import com.aliyun.oss.OSSClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Created on 2018/5/17.
*/
@Configuration
public class OssConfig {
@Value("${aliyun.oss.endpoint}")
private String ALIYUN_OSS_ENDPOINT;
@Value("${aliyun.oss.accessKeyId}")
private String ALIYUN_OSS_ACCESSKEYID;
@Value("${aliyun.oss.accessKeySecret}")
private String ALIYUN_OSS_ACCESSKEYSECRET;
@Bean
public OSSClient ossClient(){
return new OSSClient(ALIYUN_OSS_ENDPOINT,ALIYUN_OSS_ACCESSKEYID,ALIYUN_OSS_ACCESSKEYSECRET);
}
}

View File

@@ -0,0 +1,62 @@
package com.tuling.tulingmall.config;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.util.unit.DataSize;
import org.springframework.util.unit.DataUnit;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import javax.servlet.MultipartConfigElement;
/**
* ,;,,;
* ,;;'( 社
* __ ,;;' ' \ 会
* /' '\'~~'~' \ /'\.) 主
* ,;( ) / |. 义
*,;' \ /-.,,( ) \ 码
* ) / ) / )| 农
* || || \)
* (_\ (_\
* @author :图灵学院
* @date Created in 2020/1/12 22:12
* @version: V1.0
* @slogan: 天下风云出我辈,一入代码岁月催
* @description: 资源访问路径配置
**/
@Configuration
public class ResourceConfig implements WebMvcConfigurer {
@Value("${upload.product.images}")
private String uploadBasePath;
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
String os = System.getProperty("os.name");
if(os.toLowerCase().startsWith("win")){ //windows系统
/** 产品图片资源网络路径映射到本地路径 */
registry.addResourceHandler("/upload/product/images/**")
.addResourceLocations("file:" + uploadBasePath + "/");
}else{ //linux或者mac
}
}
/**
* 设置上传的文件大小不超过10MB 大小
* @return
*/
@Bean
public MultipartConfigElement multipartConfigElement() {
MultipartConfigFactory factory = new MultipartConfigFactory();
//文件最大10M,DataUnit提供5中类型B,KB,MB,GB,TB
factory.setMaxFileSize(DataSize.of(10, DataUnit.MEGABYTES));
/// 设置总上传数据总大小10M
factory.setMaxRequestSize(DataSize.of(10, DataUnit.MEGABYTES));
return factory.createMultipartConfig();
}
}

View File

@@ -0,0 +1,80 @@
package com.tuling.tulingmall.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.ApiKey;
import springfox.documentation.service.AuthorizationScope;
import springfox.documentation.service.SecurityReference;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.List;
/**
* Swagger2API文档的配置
* Created on 2018/4/26.
*/
@Configuration
@EnableSwagger2
public class Swagger2Config {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.macro.mall.controller"))
.paths(PathSelectors.any())
.build()
.securitySchemes(securitySchemes())
.securityContexts(securityContexts());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("mall后台系统")
.description("mall后台模块")
.contact("macro")
.version("1.0")
.build();
}
private List<ApiKey> securitySchemes() {
//设置请求头信息
List<ApiKey> result = new ArrayList<>();
ApiKey apiKey = new ApiKey("Authorization", "Authorization", "header");
result.add(apiKey);
return result;
}
private List<SecurityContext> securityContexts() {
//设置需要登录认证的路径
List<SecurityContext> result = new ArrayList<>();
result.add(getContextByPath("/brand/.*"));
result.add(getContextByPath("/product/.*"));
result.add(getContextByPath("/productCategory/.*"));
return result;
}
private SecurityContext getContextByPath(String pathRegex){
return SecurityContext.builder()
.securityReferences(defaultAuth())
.forPaths(PathSelectors.regex(pathRegex))
.build();
}
private List<SecurityReference> defaultAuth() {
List<SecurityReference> result = new ArrayList<>();
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEverything");
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
authorizationScopes[0] = authorizationScope;
result.add(new SecurityReference("Authorization", authorizationScopes));
return result;
}
}

View File

@@ -0,0 +1,34 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.CmsPrefrenceArea;
import com.tuling.tulingmall.service.CmsPrefrenceAreaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 商品优选管理Controller
* Created on 2018/6/1.
*/
@Controller
@Api(tags = "CmsPrefrenceAreaController", description = "商品优选管理")
@RequestMapping("/prefrenceArea")
public class CmsPrefrenceAreaController {
@Autowired
private CmsPrefrenceAreaService prefrenceAreaService;
@ApiOperation("获取所有商品优选")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<CmsPrefrenceArea>> listAll() {
List<CmsPrefrenceArea> prefrenceAreaList = prefrenceAreaService.listAll();
return CommonResult.success(prefrenceAreaList);
}
}

View File

@@ -0,0 +1,46 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.CmsSubject;
import com.tuling.tulingmall.service.CmsSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 商品专题Controller
* Created on 2018/6/1.
*/
@Controller
@Api(tags = "CmsSubjectController", description = "商品专题管理")
@RequestMapping("/subject")
public class CmsSubjectController {
@Autowired
private CmsSubjectService subjectService;
@ApiOperation("获取全部商品专题")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<CmsSubject>> listAll() {
List<CmsSubject> subjectList = subjectService.listAll();
return CommonResult.success(subjectList);
}
@ApiOperation(value = "根据专题名称分页获取专题")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<CmsSubject>> getList(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
List<CmsSubject> subjectList = subjectService.list(keyword, pageNum, pageSize);
return CommonResult.success(CommonPage.restPage(subjectList));
}
}

View File

@@ -0,0 +1,34 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.service.ItemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
@RestController
@Api(description = "商品列表信息")
@RequestMapping("/item")
public class ItemController {
@Autowired
@Qualifier("tulingItemServiceImpl")
ItemService itemService;
@RequestMapping(value = "/static/{id}",method = RequestMethod.GET)
@ApiOperation(value = "静态化商品")
public CommonResult<String> buildStatic(@PathVariable Long id){
String path = itemService.toStatic(id);
if(StringUtils.isEmpty(path)){
return CommonResult.failed("静态化商品页面出现异常");
}
return CommonResult.success(path);
}
}

View File

@@ -0,0 +1,34 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.OmsCompanyAddress;
import com.tuling.tulingmall.service.OmsCompanyAddressService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 收货地址管理Controller
* Created on 2018/10/18.
*/
@Controller
@Api(tags = "OmsCompanyAddressController", description = "收货地址管理")
@RequestMapping("/companyAddress")
public class OmsCompanyAddressController {
@Autowired
private OmsCompanyAddressService companyAddressService;
@ApiOperation("获取所有收货地址")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<OmsCompanyAddress>> list() {
List<OmsCompanyAddress> companyAddressList = companyAddressService.list();
return CommonResult.success(companyAddressList);
}
}

View File

@@ -0,0 +1,86 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.*;
import com.tuling.tulingmall.feignapi.OmsOrderApi;
import com.tuling.tulingmall.model.OmsOrder;
import com.tuling.tulingmall.service.OmsOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 订单管理Controller
* Created on 2018/10/11.
*/
@Controller
@Api(tags = "OmsOrderController", description = "订单管理")
@RequestMapping("/order")
public class OmsOrderController {
@Autowired
private OmsOrderApi omsOrderApi;
@ApiOperation("查询订单")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<OmsOrder>> list(OmsOrderQueryParam queryParam,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
return omsOrderApi.list(queryParam,pageSize,pageNum);
}
@ApiOperation("批量发货")
@RequestMapping(value = "/update/delivery", method = RequestMethod.POST)
@ResponseBody
public CommonResult delivery(@RequestBody List<OmsOrderDeliveryParam> deliveryParamList) {
return omsOrderApi.delivery(deliveryParamList);
}
@ApiOperation("批量关闭订单")
@RequestMapping(value = "/update/close", method = RequestMethod.POST)
@ResponseBody
public CommonResult close(@RequestParam("ids") List<Long> ids, @RequestParam String note) {
return omsOrderApi.close(ids,note);
}
@ApiOperation("批量删除订单")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
return omsOrderApi.delete(ids);
}
@ApiOperation("获取订单详情:订单信息、商品信息、操作记录")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<OmsOrderDetail> detail(@PathVariable Long id) {
return omsOrderApi.detail(id);
}
@ApiOperation("修改收货人信息")
@RequestMapping(value = "/update/receiverInfo", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateReceiverInfo(@RequestBody OmsReceiverInfoParam receiverInfoParam) {
return omsOrderApi.updateReceiverInfo(receiverInfoParam);
}
@ApiOperation("修改订单费用信息")
@RequestMapping(value = "/update/moneyInfo", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateMoneyInfo(@RequestBody OmsMoneyInfoParam moneyInfoParam) {
return omsOrderApi.updatMoneyInfo(moneyInfoParam);
}
@ApiOperation("备注订单")
@RequestMapping(value = "/update/note", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateNote(@RequestParam("id") Long id,
@RequestParam("note") String note,
@RequestParam("status") Integer status) {
return omsOrderApi.updateNote(id, note, status);
}
}

View File

@@ -0,0 +1,58 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.OmsOrderReturnApplyResult;
import com.tuling.tulingmall.dto.OmsReturnApplyQueryParam;
import com.tuling.tulingmall.dto.OmsUpdateStatusParam;
import com.tuling.tulingmall.feignapi.OmsOrderReturnApplyApi;
import com.tuling.tulingmall.model.OmsOrderReturnApply;
import com.tuling.tulingmall.service.OmsOrderReturnApplyService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 订单退货申请管理
* Created on 2018/10/18.
*/
@Controller
@Api(tags = "OmsOrderReturnApplyController", description = "订单退货申请管理")
@RequestMapping("/returnApply")
public class OmsOrderReturnApplyController {
@Autowired
private OmsOrderReturnApplyApi omsOrderReturnApplyApi;
@ApiOperation("分页查询退货申请")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<OmsOrderReturnApply>> list(OmsReturnApplyQueryParam queryParam,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
return omsOrderReturnApplyApi.list(queryParam, pageSize, pageNum);
}
@ApiOperation("批量删除申请")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
return omsOrderReturnApplyApi.delete(ids);
}
@ApiOperation("获取退货申请详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult getItem(@PathVariable Long id) {
return omsOrderReturnApplyApi.getItem(id);
}
@ApiOperation("修改申请状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateStatus(@PathVariable Long id, @RequestBody OmsUpdateStatusParam statusParam) {
return omsOrderReturnApplyApi.updateStatus(id, statusParam);
}
}

View File

@@ -0,0 +1,71 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.feignapi.OmsOrderReturnApplyApi;
import com.tuling.tulingmall.feignapi.OmsOrderReturnReasonApi;
import com.tuling.tulingmall.model.OmsOrderReturnReason;
import com.tuling.tulingmall.service.OmsOrderReturnReasonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 退货原因管理Controller
* Created on 2018/10/17.
*/
@Controller
@Api(tags = "OmsOrderReturnReasonController", description = "退货原因管理")
@RequestMapping("/returnReason")
public class OmsOrderReturnReasonController {
@Autowired
private OmsOrderReturnReasonApi omsOrderReturnReasonApi;
@ApiOperation("添加退货原因")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody OmsOrderReturnReason returnReason) {
return omsOrderReturnReasonApi.create(returnReason);
}
@ApiOperation("修改退货原因")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody OmsOrderReturnReason returnReason) {
return omsOrderReturnReasonApi.update(id, returnReason);
}
@ApiOperation("批量删除退货原因")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
return omsOrderReturnReasonApi.delete(ids);
}
@ApiOperation("分页查询全部退货原因")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<OmsOrderReturnReason>> list(@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
return omsOrderReturnReasonApi.list(pageSize, pageNum);
}
@ApiOperation("获取单个退货原因详情信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<OmsOrderReturnReason> getItem(@PathVariable Long id) {
return omsOrderReturnReasonApi.getItem(id);
}
@ApiOperation("修改退货原因启用状态")
@RequestMapping(value = "/update/status", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateStatus(@RequestParam(value = "status") Integer status,
@RequestParam("ids") List<Long> ids) {
return omsOrderReturnReasonApi.updateStatus(status, ids);
}
}

View File

@@ -0,0 +1,38 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.feignapi.OmsOrderSettingApi;
import com.tuling.tulingmall.model.OmsOrderSetting;
import com.tuling.tulingmall.service.OmsOrderSettingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
/**
* 订单设置Controller
* Created on 2018/10/16.
*/
@Controller
@Api(tags = "OmsOrderSettingController", description = "订单设置管理")
@RequestMapping("/orderSetting")
public class OmsOrderSettingController {
@Autowired
private OmsOrderSettingApi omsOrderSettingApi;
@ApiOperation("获取指定订单设置")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<OmsOrderSetting> getItem(@PathVariable Long id) {
return omsOrderSettingApi.getItem(id);
}
@ApiOperation("修改指定订单设置")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody OmsOrderSetting orderSetting) {
return omsOrderSettingApi.update(id, orderSetting);
}
}

View File

@@ -0,0 +1,88 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.OssCallbackResult;
import com.tuling.tulingmall.dto.OssPolicyResult;
import com.tuling.tulingmall.service.impl.OssServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletRequest;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.UUID;
/**
* Oss相关操作接口
* Created on 2018/4/26.
*/
@Slf4j
@Controller
@Api(tags = "OssController", description = "Oss管理")
@RequestMapping("/aliyun/oss")
public class OssController {
@Autowired
private OssServiceImpl ossService;
@ApiOperation(value = "oss上传签名生成")
@RequestMapping(value = "/policy", method = RequestMethod.GET)
@ResponseBody
public CommonResult<OssPolicyResult> policy() {
OssPolicyResult result = ossService.policy();
return CommonResult.success(result);
}
@ApiOperation(value = "oss上传成功回调")
@RequestMapping(value = "callback", method = RequestMethod.POST)
@ResponseBody
public CommonResult<OssCallbackResult> callback(HttpServletRequest request) {
log.info("oss callback回调成功......");
OssCallbackResult ossCallbackResult = ossService.callback(request);
return CommonResult.success(ossCallbackResult);
}
@Value("${upload.product.images}")
private String uploadBasePath;
/**
* add by 杨过,图片上传到本地不上传到aliyun-OSS
* @param multiFile
* @param req
* @return
* @throws IOException
*/
@RequestMapping(value = "/upload",method = RequestMethod.POST)
@CrossOrigin
@ResponseBody
public CommonResult<String> importData(@RequestParam("image-file") MultipartFile multiFile, HttpServletRequest req) throws IOException {
SimpleDateFormat sdf = new SimpleDateFormat("/yyyy/MM/dd/");
String format = sdf.format(new Date());
/*
* 按日期分类
*/
String realPath = uploadBasePath + format;
File folder = new File(realPath);
if (!folder.exists()) {
folder.mkdirs();
}
String oldName = multiFile.getOriginalFilename();
String newName = UUID.randomUUID().toString() + oldName.substring(oldName.lastIndexOf("."));
multiFile.transferTo(new File(folder,newName));
//String url = req.getScheme() + "://" + req.getServerName() + ":" + req.getServerPort() + "/upload" + format + newName;
String httpBasePath = "/upload/product/images" + format + newName;
return CommonResult.success(httpBasePath);
}
}

View File

@@ -0,0 +1,142 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.PmsBrandParam;
import com.tuling.tulingmall.model.PmsBrand;
import com.tuling.tulingmall.service.PmsBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 品牌功能Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "PmsBrandController", description = "商品品牌管理")
@RequestMapping("/brand")
public class PmsBrandController {
@Autowired
private PmsBrandService brandService;
@ApiOperation(value = "获取全部品牌列表")
@RequestMapping(value = "/listAll", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:read')")
public CommonResult<List<PmsBrand>> getList() {
return CommonResult.success(brandService.listAllBrand());
}
@ApiOperation(value = "添加品牌")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:create')")
public CommonResult create(@Validated @RequestBody PmsBrandParam pmsBrand, BindingResult result) {
CommonResult commonResult;
int count = brandService.createBrand(pmsBrand);
if (count == 1) {
commonResult = CommonResult.success(count);
} else {
commonResult = CommonResult.failed();
}
return commonResult;
}
@ApiOperation(value = "更新品牌")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:update')")
public CommonResult update(@PathVariable("id") Long id,
@Validated @RequestBody PmsBrandParam pmsBrandParam,
BindingResult result) {
CommonResult commonResult;
int count = brandService.updateBrand(id, pmsBrandParam);
if (count == 1) {
commonResult = CommonResult.success(count);
} else {
commonResult = CommonResult.failed();
}
return commonResult;
}
@ApiOperation(value = "删除品牌")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:delete')")
public CommonResult delete(@PathVariable("id") Long id) {
int count = brandService.deleteBrand(id);
if (count == 1) {
return CommonResult.success(null);
} else {
return CommonResult.failed();
}
}
@ApiOperation(value = "根据品牌名称分页获取品牌列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:read')")
public CommonResult<CommonPage<PmsBrand>> getList(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize) {
List<PmsBrand> brandList = brandService.listBrand(keyword, pageNum, pageSize);
return CommonResult.success(CommonPage.restPage(brandList));
}
@ApiOperation(value = "根据编号查询品牌信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:read')")
public CommonResult<PmsBrand> getItem(@PathVariable("id") Long id) {
return CommonResult.success(brandService.getBrand(id));
}
@ApiOperation(value = "批量删除品牌")
@RequestMapping(value = "/delete/batch", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:delete')")
public CommonResult deleteBatch(@RequestParam("ids") List<Long> ids) {
int count = brandService.deleteBrand(ids);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation(value = "批量更新显示状态")
@RequestMapping(value = "/update/showStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:update')")
public CommonResult updateShowStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("showStatus") Integer showStatus) {
int count = brandService.updateShowStatus(ids, showStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation(value = "批量更新厂家制造商状态")
@RequestMapping(value = "/update/factoryStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:brand:update')")
public CommonResult updateFactoryStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("factoryStatus") Integer factoryStatus) {
int count = brandService.updateFactoryStatus(ids, factoryStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
}

View File

@@ -0,0 +1,86 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.PmsProductAttributeCategoryItem;
import com.tuling.tulingmall.model.PmsProductAttributeCategory;
import com.tuling.tulingmall.service.PmsProductAttributeCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品属性分类Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "PmsProductAttributeCategoryController", description = "商品属性分类管理")
@RequestMapping("/productAttribute/category")
public class PmsProductAttributeCategoryController {
@Autowired
private PmsProductAttributeCategoryService productAttributeCategoryService;
@ApiOperation("添加商品属性分类")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestParam String name) {
int count = productAttributeCategoryService.create(name);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("修改商品属性分类")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestParam String name) {
int count = productAttributeCategoryService.update(id, name);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("删除单个商品属性分类")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = productAttributeCategoryService.delete(id);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("获取单个商品属性分类信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<PmsProductAttributeCategory> getItem(@PathVariable Long id) {
PmsProductAttributeCategory productAttributeCategory = productAttributeCategoryService.getItem(id);
return CommonResult.success(productAttributeCategory);
}
@ApiOperation("分页获取所有商品属性分类")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<PmsProductAttributeCategory>> getList(@RequestParam(defaultValue = "5") Integer pageSize, @RequestParam(defaultValue = "1") Integer pageNum) {
List<PmsProductAttributeCategory> productAttributeCategoryList = productAttributeCategoryService.getList(pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(productAttributeCategoryList));
}
@ApiOperation("获取所有商品属性分类及其下属性")
@RequestMapping(value = "/list/withAttr", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsProductAttributeCategoryItem>> getListWithAttr() {
List<PmsProductAttributeCategoryItem> productAttributeCategoryResultList = productAttributeCategoryService.getListWithAttr();
return CommonResult.success(productAttributeCategoryResultList);
}
}

View File

@@ -0,0 +1,94 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.PmsProductAttributeParam;
import com.tuling.tulingmall.dto.ProductAttrInfo;
import com.tuling.tulingmall.model.PmsProductAttribute;
import com.tuling.tulingmall.service.PmsProductAttributeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品属性管理Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "PmsProductAttributeController", description = "商品属性管理")
@RequestMapping("/productAttribute")
public class PmsProductAttributeController {
@Autowired
private PmsProductAttributeService productAttributeService;
@ApiOperation("根据分类查询属性列表或参数列表")
@ApiImplicitParams({@ApiImplicitParam(name = "type", value = "0表示属性1表示参数", required = true, paramType = "query", dataType = "integer")})
@RequestMapping(value = "/list/{cid}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<PmsProductAttribute>> getList(@PathVariable Long cid,
@RequestParam(value = "type") Integer type,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<PmsProductAttribute> productAttributeList = productAttributeService.getList(cid, type, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(productAttributeList));
}
@ApiOperation("添加商品属性信息")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody PmsProductAttributeParam productAttributeParam, BindingResult bindingResult) {
int count = productAttributeService.create(productAttributeParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("修改商品属性信息")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody PmsProductAttributeParam productAttributeParam, BindingResult bindingResult) {
int count = productAttributeService.update(id, productAttributeParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("查询单个商品属性")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<PmsProductAttribute> getItem(@PathVariable Long id) {
PmsProductAttribute productAttribute = productAttributeService.getItem(id);
return CommonResult.success(productAttribute);
}
@ApiOperation("批量删除商品属性")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = productAttributeService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("根据商品分类的id获取商品属性及属性分类")
@RequestMapping(value = "/attrInfo/{productCategoryId}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<ProductAttrInfo>> getAttrInfo(@PathVariable Long productCategoryId) {
List<ProductAttrInfo> productAttrInfoList = productAttributeService.getProductAttrInfo(productCategoryId);
return CommonResult.success(productAttrInfoList);
}
}

View File

@@ -0,0 +1,128 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.PmsProductCategoryParam;
import com.tuling.tulingmall.dto.PmsProductCategoryWithChildrenItem;
import com.tuling.tulingmall.model.PmsProductCategory;
import com.tuling.tulingmall.service.PmsProductCategoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品分类模块Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "PmsProductCategoryController", description = "商品分类管理")
@RequestMapping("/productCategory")
public class PmsProductCategoryController {
@Autowired
private PmsProductCategoryService productCategoryService;
@ApiOperation("添加产品分类")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:create')")
public CommonResult create(@Validated @RequestBody PmsProductCategoryParam productCategoryParam,
BindingResult result) {
int count = productCategoryService.create(productCategoryParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("修改商品分类")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:update')")
public CommonResult update(@PathVariable Long id,
@Validated
@RequestBody PmsProductCategoryParam productCategoryParam,
BindingResult result) {
int count = productCategoryService.update(id, productCategoryParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("分页查询商品分类")
@RequestMapping(value = "/list/{parentId}", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:read')")
public CommonResult<CommonPage<PmsProductCategory>> getList(@PathVariable Long parentId,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<PmsProductCategory> productCategoryList = productCategoryService.getList(parentId, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(productCategoryList));
}
@ApiOperation("根据id获取商品分类")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:read')")
public CommonResult<PmsProductCategory> getItem(@PathVariable Long id) {
PmsProductCategory productCategory = productCategoryService.getItem(id);
return CommonResult.success(productCategory);
}
@ApiOperation("删除商品分类")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:delete')")
public CommonResult delete(@PathVariable Long id) {
int count = productCategoryService.delete(id);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("修改导航栏显示状态")
@RequestMapping(value = "/update/navStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:update')")
public CommonResult updateNavStatus(@RequestParam("ids") List<Long> ids, @RequestParam("navStatus") Integer navStatus) {
int count = productCategoryService.updateNavStatus(ids, navStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("修改显示状态")
@RequestMapping(value = "/update/showStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:update')")
public CommonResult updateShowStatus(@RequestParam("ids") List<Long> ids, @RequestParam("showStatus") Integer showStatus) {
int count = productCategoryService.updateShowStatus(ids, showStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("查询所有一级分类及子分类")
@RequestMapping(value = "/list/withChildren", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:productCategory:read')")
public CommonResult<List<PmsProductCategoryWithChildrenItem>> listWithChildren() {
List<PmsProductCategoryWithChildrenItem> list = productCategoryService.listWithChildren();
return CommonResult.success(list);
}
}

View File

@@ -0,0 +1,155 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.PmsProductParam;
import com.tuling.tulingmall.dto.PmsProductQueryParam;
import com.tuling.tulingmall.dto.PmsProductResult;
import com.tuling.tulingmall.model.PmsProduct;
import com.tuling.tulingmall.service.PmsProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 商品管理Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "PmsProductController", description = "商品管理")
@RequestMapping("/product")
public class PmsProductController {
@Autowired
private PmsProductService productService;
@ApiOperation("创建商品")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:create')")
public CommonResult create(@RequestBody PmsProductParam productParam, BindingResult bindingResult) {
int count = productService.create(productParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("根据商品id获取商品编辑信息")
@RequestMapping(value = "/updateInfo/{id}", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:read')")
public CommonResult<PmsProductResult> getUpdateInfo(@PathVariable Long id) {
PmsProductResult productResult = productService.getUpdateInfo(id);
return CommonResult.success(productResult);
}
@ApiOperation("更新商品")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:update')")
public CommonResult update(@PathVariable Long id, @RequestBody PmsProductParam productParam, BindingResult bindingResult) {
int count = productService.update(id, productParam);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("查询商品")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:read')")
public CommonResult<CommonPage<PmsProduct>> getList(PmsProductQueryParam productQueryParam,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<PmsProduct> productList = productService.list(productQueryParam, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(productList));
}
@ApiOperation("根据商品名称或货号模糊查询")
@RequestMapping(value = "/simpleList", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsProduct>> getList(String keyword) {
List<PmsProduct> productList = productService.list(keyword);
return CommonResult.success(productList);
}
@ApiOperation("批量修改审核状态")
@RequestMapping(value = "/update/verifyStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:update')")
public CommonResult updateVerifyStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("verifyStatus") Integer verifyStatus,
@RequestParam("detail") String detail) {
int count = productService.updateVerifyStatus(ids, verifyStatus, detail);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("批量上下架")
@RequestMapping(value = "/update/publishStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:update')")
public CommonResult updatePublishStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("publishStatus") Integer publishStatus) {
int count = productService.updatePublishStatus(ids, publishStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("批量推荐商品")
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:update')")
public CommonResult updateRecommendStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("recommendStatus") Integer recommendStatus) {
int count = productService.updateRecommendStatus(ids, recommendStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("批量设为新品")
@RequestMapping(value = "/update/newStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:update')")
public CommonResult updateNewStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("newStatus") Integer newStatus) {
int count = productService.updateNewStatus(ids, newStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
@ApiOperation("批量修改删除状态")
@RequestMapping(value = "/update/deleteStatus", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasAuthority('pms:product:delete')")
public CommonResult updateDeleteStatus(@RequestParam("ids") List<Long> ids,
@RequestParam("deleteStatus") Integer deleteStatus) {
int count = productService.updateDeleteStatus(ids, deleteStatus);
if (count > 0) {
return CommonResult.success(count);
} else {
return CommonResult.failed();
}
}
}

View File

@@ -0,0 +1,43 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.PmsSkuStock;
import com.tuling.tulingmall.service.PmsSkuStockService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* sku库存Controller
* Created on 2018/4/27.
*/
@Controller
@Api(tags = "PmsSkuStockController", description = "sku商品库存管理")
@RequestMapping("/sku")
public class PmsSkuStockController {
@Autowired
private PmsSkuStockService skuStockService;
@ApiOperation("根据商品编号及编号模糊搜索sku库存")
@RequestMapping(value = "/{pid}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<PmsSkuStock>> getList(@PathVariable Long pid, @RequestParam(value = "keyword",required = false) String keyword) {
List<PmsSkuStock> skuStockList = skuStockService.getList(pid, keyword);
return CommonResult.success(skuStockList);
}
@ApiOperation("批量更新库存信息")
@RequestMapping(value ="/update/{pid}",method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long pid,@RequestBody List<PmsSkuStock> skuStockList){
int count = skuStockService.update(pid,skuStockList);
if(count>0){
return CommonResult.success(count);
}else{
return CommonResult.failed();
}
}
}

View File

@@ -0,0 +1,78 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.SmsCouponParam;
import com.tuling.tulingmall.model.SmsCoupon;
import com.tuling.tulingmall.service.SmsCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 优惠券管理Controller
* Created on 2018/8/28.
*/
@Controller
@Api(tags = "SmsCouponController", description = "优惠券管理")
@RequestMapping("/coupon")
public class SmsCouponController {
@Autowired
private SmsCouponService couponService;
@ApiOperation("添加优惠券")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult add(@RequestBody SmsCouponParam couponParam) {
int count = couponService.create(couponParam);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("删除优惠券")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = couponService.delete(id);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改优惠券")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id,@RequestBody SmsCouponParam couponParam) {
int count = couponService.update(id,couponParam);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("根据优惠券名称和类型分页获取优惠券列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsCoupon>> list(
@RequestParam(value = "name",required = false) String name,
@RequestParam(value = "type",required = false) Integer type,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsCoupon> couponList = couponService.list(name,type,pageSize,pageNum);
return CommonResult.success(CommonPage.restPage(couponList));
}
@ApiOperation("获取单个优惠券的详细信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<SmsCouponParam> getItem(@PathVariable Long id) {
SmsCouponParam couponParam = couponService.getItem(id);
return CommonResult.success(couponParam);
}
}

View File

@@ -0,0 +1,40 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsCouponHistory;
import com.tuling.tulingmall.service.SmsCouponHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 优惠券领取记录管理Controller
* Created on 2018/11/6.
*/
@Controller
@Api(tags = "SmsCouponHistoryController", description = "优惠券领取记录管理")
@RequestMapping("/couponHistory")
public class SmsCouponHistoryController {
@Autowired
private SmsCouponHistoryService historyService;
@ApiOperation("根据优惠券id使用状态订单编号分页获取领取记录")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsCouponHistory>> list(@RequestParam(value = "couponId", required = false) Long couponId,
@RequestParam(value = "useStatus", required = false) Integer useStatus,
@RequestParam(value = "orderSn", required = false) String orderSn,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsCouponHistory> historyList = historyService.list(couponId, useStatus, orderSn, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(historyList));
}
}

View File

@@ -0,0 +1,87 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsFlashPromotion;
import com.tuling.tulingmall.service.SmsFlashPromotionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 限时购活动管理Controller
* Created on 2018/11/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionController", description = "限时购活动管理")
@RequestMapping("/flash")
public class SmsFlashPromotionController {
@Autowired
private SmsFlashPromotionService flashPromotionService;
@ApiOperation("添加活动")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody SmsFlashPromotion flashPromotion) {
int count = flashPromotionService.create(flashPromotion);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("编辑活动信息")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id, @RequestBody SmsFlashPromotion flashPromotion) {
int count = flashPromotionService.update(id, flashPromotion);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("删除活动信息")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public Object delete(@PathVariable Long id) {
int count = flashPromotionService.delete(id);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改上下线状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public Object update(@PathVariable Long id, Integer status) {
int count = flashPromotionService.updateStatus(id, status);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取活动详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@PathVariable Long id) {
SmsFlashPromotion flashPromotion = flashPromotionService.getItem(id);
return CommonResult.success(flashPromotion);
}
@ApiOperation("根据活动名称分页查询")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object getItem(@RequestParam(value = "keyword", required = false) String keyword,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsFlashPromotion> flashPromotionList = flashPromotionService.list(keyword, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(flashPromotionList));
}
}

View File

@@ -0,0 +1,78 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.SmsFlashPromotionProduct;
import com.tuling.tulingmall.model.SmsFlashPromotionProductRelation;
import com.tuling.tulingmall.service.SmsFlashPromotionProductRelationService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 限时购和商品关系管理Controller
* Created on 2018/11/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionProductRelationController", description = "限时购和商品关系管理")
@RequestMapping("/flashProductRelation")
public class SmsFlashPromotionProductRelationController {
@Autowired
private SmsFlashPromotionProductRelationService relationService;
@ApiOperation("批量选择商品添加关联")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody List<SmsFlashPromotionProductRelation> relationList) {
int count = relationService.create(relationList);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改关联相关信息")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody SmsFlashPromotionProductRelation relation) {
int count = relationService.update(id, relation);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("删除关联")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = relationService.delete(id);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取管理商品促销信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<SmsFlashPromotionProductRelation> getItem(@PathVariable Long id) {
SmsFlashPromotionProductRelation relation = relationService.getItem(id);
return CommonResult.success(relation);
}
@ApiOperation("分页查询不同场次关联及商品信息")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsFlashPromotionProduct>> list(@RequestParam(value = "flashPromotionId") Long flashPromotionId,
@RequestParam(value = "flashPromotionSessionId") Long flashPromotionSessionId,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsFlashPromotionProduct> flashPromotionProductList = relationService.list(flashPromotionId, flashPromotionSessionId, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(flashPromotionProductList));
}
}

View File

@@ -0,0 +1,93 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.SmsFlashPromotionSessionDetail;
import com.tuling.tulingmall.model.SmsFlashPromotionSession;
import com.tuling.tulingmall.service.SmsFlashPromotionSessionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 限时购场次管理Controller
* Created on 2018/11/16.
*/
@Controller
@Api(tags = "SmsFlashPromotionSessionController", description = "限时购场次管理")
@RequestMapping("/flashSession")
public class SmsFlashPromotionSessionController {
@Autowired
private SmsFlashPromotionSessionService flashPromotionSessionService;
@ApiOperation("添加场次")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody SmsFlashPromotionSession promotionSession) {
int count = flashPromotionSessionService.create(promotionSession);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改场次")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody SmsFlashPromotionSession promotionSession) {
int count = flashPromotionSessionService.update(id, promotionSession);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改启用状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateStatus(@PathVariable Long id, Integer status) {
int count = flashPromotionSessionService.updateStatus(id, status);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("删除场次")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = flashPromotionSessionService.delete(id);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取场次详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<SmsFlashPromotionSession> getItem(@PathVariable Long id) {
SmsFlashPromotionSession promotionSession = flashPromotionSessionService.getItem(id);
return CommonResult.success(promotionSession);
}
@ApiOperation("获取全部场次")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<SmsFlashPromotionSession>> list() {
List<SmsFlashPromotionSession> promotionSessionList = flashPromotionSessionService.list();
return CommonResult.success(promotionSessionList);
}
@ApiOperation("获取全部可选场次及其数量")
@RequestMapping(value = "/selectList", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<SmsFlashPromotionSessionDetail>> selectList(Long flashPromotionId) {
List<SmsFlashPromotionSessionDetail> promotionSessionList = flashPromotionSessionService.selectList(flashPromotionId);
return CommonResult.success(promotionSessionList);
}
}

View File

@@ -0,0 +1,85 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsHomeAdvertise;
import com.tuling.tulingmall.service.SmsHomeAdvertiseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 首页轮播广告管理Controller
* Created on 2018/11/7.
*/
@Controller
@Api(tags = "SmsHomeAdvertiseController", description = "首页轮播广告管理")
@RequestMapping("/home/advertise")
public class SmsHomeAdvertiseController {
@Autowired
private SmsHomeAdvertiseService advertiseService;
@ApiOperation("添加广告")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody SmsHomeAdvertise advertise) {
int count = advertiseService.create(advertise);
if (count > 0)
return CommonResult.success(count);
return CommonResult.failed();
}
@ApiOperation("删除广告")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = advertiseService.delete(ids);
if (count > 0)
return CommonResult.success(count);
return CommonResult.failed();
}
@ApiOperation("修改上下线状态")
@RequestMapping(value = "/update/status/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateStatus(@PathVariable Long id, Integer status) {
int count = advertiseService.updateStatus(id, status);
if (count > 0)
return CommonResult.success(count);
return CommonResult.failed();
}
@ApiOperation("获取广告详情")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<SmsHomeAdvertise> getItem(@PathVariable Long id) {
SmsHomeAdvertise advertise = advertiseService.getItem(id);
return CommonResult.success(advertise);
}
@ApiOperation("修改广告")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody SmsHomeAdvertise advertise) {
int count = advertiseService.update(id, advertise);
if (count > 0)
return CommonResult.success(count);
return CommonResult.failed();
}
@ApiOperation("分页查询广告")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsHomeAdvertise>> list(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "type", required = false) Integer type,
@RequestParam(value = "endTime", required = false) String endTime,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsHomeAdvertise> advertiseList = advertiseService.list(name, type, endTime, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(advertiseList));
}
}

View File

@@ -0,0 +1,80 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsHomeBrand;
import com.tuling.tulingmall.service.SmsHomeBrandService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 首页品牌管理Controller
* Created on 2018/11/6.
*/
@Controller
@Api(tags = "SmsHomeBrandController", description = "首页品牌管理")
@RequestMapping("/home/brand")
public class SmsHomeBrandController {
@Autowired
private SmsHomeBrandService homeBrandService;
@ApiOperation("添加首页推荐品牌")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody List<SmsHomeBrand> homeBrandList) {
int count = homeBrandService.create(homeBrandList);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改品牌排序")
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateSort(@PathVariable Long id, Integer sort) {
int count = homeBrandService.updateSort(id, sort);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量删除推荐品牌")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = homeBrandService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量修改推荐状态")
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
int count = homeBrandService.updateRecommendStatus(ids, recommendStatus);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("分页查询推荐品牌")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsHomeBrand>> list(@RequestParam(value = "brandName", required = false) String brandName,
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsHomeBrand> homeBrandList = homeBrandService.list(brandName, recommendStatus, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(homeBrandList));
}
}

View File

@@ -0,0 +1,80 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsHomeNewProduct;
import com.tuling.tulingmall.service.SmsHomeNewProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 首页新品管理Controller
* Created on 2018/11/6.
*/
@Controller
@Api(tags = "SmsHomeNewProductController", description = "首页新品管理")
@RequestMapping("/home/newProduct")
public class SmsHomeNewProductController {
@Autowired
private SmsHomeNewProductService homeNewProductService;
@ApiOperation("添加首页推荐品牌")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody List<SmsHomeNewProduct> homeBrandList) {
int count = homeNewProductService.create(homeBrandList);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改推荐排序")
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateSort(@PathVariable Long id, Integer sort) {
int count = homeNewProductService.updateSort(id, sort);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量删除推荐")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = homeNewProductService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量修改推荐状态")
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
int count = homeNewProductService.updateRecommendStatus(ids, recommendStatus);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("分页查询推荐")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsHomeNewProduct>> list(@RequestParam(value = "productName", required = false) String productName,
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsHomeNewProduct> homeBrandList = homeNewProductService.list(productName, recommendStatus, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(homeBrandList));
}
}

View File

@@ -0,0 +1,80 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsHomeRecommendProduct;
import com.tuling.tulingmall.service.SmsHomeRecommendProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 首页人气推荐管理Controller
* Created on 2018/11/6.
*/
@Controller
@Api(tags = "SmsHomeRecommendProductController", description = "首页人气推荐管理")
@RequestMapping("/home/recommendProduct")
public class SmsHomeRecommendProductController {
@Autowired
private SmsHomeRecommendProductService recommendProductService;
@ApiOperation("添加首页推荐")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody List<SmsHomeRecommendProduct> homeBrandList) {
int count = recommendProductService.create(homeBrandList);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改推荐排序")
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateSort(@PathVariable Long id, Integer sort) {
int count = recommendProductService.updateSort(id, sort);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量删除推荐")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = recommendProductService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量修改推荐状态")
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
int count = recommendProductService.updateRecommendStatus(ids, recommendStatus);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("分页查询推荐")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsHomeRecommendProduct>> list(@RequestParam(value = "productName", required = false) String productName,
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsHomeRecommendProduct> homeBrandList = recommendProductService.list(productName, recommendStatus, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(homeBrandList));
}
}

View File

@@ -0,0 +1,80 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.SmsHomeRecommendSubject;
import com.tuling.tulingmall.service.SmsHomeRecommendSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 首页专题推荐管理Controller
* Created on 2018/11/6.
*/
@Controller
@Api(tags = "SmsHomeRecommendSubjectController", description = "首页专题推荐管理")
@RequestMapping("/home/recommendSubject")
public class SmsHomeRecommendSubjectController {
@Autowired
private SmsHomeRecommendSubjectService recommendSubjectService;
@ApiOperation("添加首页推荐专题")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody List<SmsHomeRecommendSubject> homeBrandList) {
int count = recommendSubjectService.create(homeBrandList);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改推荐排序")
@RequestMapping(value = "/update/sort/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateSort(@PathVariable Long id, Integer sort) {
int count = recommendSubjectService.updateSort(id, sort);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量删除推荐")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = recommendSubjectService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量修改推荐状态")
@RequestMapping(value = "/update/recommendStatus", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateRecommendStatus(@RequestParam("ids") List<Long> ids, @RequestParam Integer recommendStatus) {
int count = recommendSubjectService.updateRecommendStatus(ids, recommendStatus);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("分页查询推荐")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<SmsHomeRecommendSubject>> list(@RequestParam(value = "subjectName", required = false) String subjectName,
@RequestParam(value = "recommendStatus", required = false) Integer recommendStatus,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<SmsHomeRecommendSubject> homeBrandList = recommendSubjectService.list(subjectName, recommendStatus, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(homeBrandList));
}
}

View File

@@ -0,0 +1,179 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonPage;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.UmsAdminLoginParam;
import com.tuling.tulingmall.dto.UmsAdminParam;
import com.tuling.tulingmall.model.UmsAdmin;
import com.tuling.tulingmall.model.UmsPermission;
import com.tuling.tulingmall.model.UmsRole;
import com.tuling.tulingmall.service.UmsAdminService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.security.Principal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* 后台用户管理
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "UmsAdminController", description = "后台用户管理")
@RequestMapping("/admin")
public class UmsAdminController {
@Autowired
private UmsAdminService adminService;
@Value("${jwt.tokenHeader}")
private String tokenHeader;
@Value("${jwt.tokenHead}")
private String tokenHead;
@ApiOperation(value = "用户注册")
@RequestMapping(value = "/register", method = RequestMethod.POST)
@ResponseBody
public CommonResult<UmsAdmin> register(@RequestBody UmsAdminParam umsAdminParam, BindingResult result) {
UmsAdmin umsAdmin = adminService.register(umsAdminParam);
if (umsAdmin == null) {
CommonResult.failed();
}
return CommonResult.success(umsAdmin);
}
@ApiOperation(value = "登录以后返回token")
@RequestMapping(value = "/login", method = RequestMethod.POST)
@ResponseBody
public CommonResult login(@RequestBody UmsAdminLoginParam umsAdminLoginParam, BindingResult result) {
String token = adminService.login(umsAdminLoginParam.getUsername(), umsAdminLoginParam.getPassword());
if (token == null) {
return CommonResult.validateFailed("用户名或密码错误");
}
Map<String, String> tokenMap = new HashMap<>();
tokenMap.put("token", token);
tokenMap.put("tokenHead", tokenHead);
return CommonResult.success(tokenMap);
}
@ApiOperation(value = "刷新token")
@RequestMapping(value = "/refreshToken", method = RequestMethod.GET)
@ResponseBody
public CommonResult refreshToken(HttpServletRequest request) {
String token = request.getHeader(tokenHeader);
String refreshToken = adminService.refreshToken(token);
if (refreshToken == null) {
return CommonResult.failed("token已经过期");
}
Map<String, String> tokenMap = new HashMap<>();
tokenMap.put("token", refreshToken);
tokenMap.put("tokenHead", tokenHead);
return CommonResult.success(tokenMap);
}
@ApiOperation(value = "获取当前登录用户信息")
@RequestMapping(value = "/info", method = RequestMethod.GET)
@ResponseBody
public CommonResult getAdminInfo(Principal principal) {
String username = principal.getName();
UmsAdmin umsAdmin = adminService.getAdminByUsername(username);
Map<String, Object> data = new HashMap<>();
data.put("username", umsAdmin.getUsername());
data.put("roles", new String[]{"TEST"});
data.put("icon", umsAdmin.getIcon());
return CommonResult.success(data);
}
@ApiOperation(value = "登出功能")
@RequestMapping(value = "/logout", method = RequestMethod.POST)
@ResponseBody
public CommonResult logout() {
return CommonResult.success(null);
}
@ApiOperation("根据用户名或姓名分页获取用户列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<CommonPage<UmsAdmin>> list(@RequestParam(value = "name", required = false) String name,
@RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
List<UmsAdmin> adminList = adminService.list(name, pageSize, pageNum);
return CommonResult.success(CommonPage.restPage(adminList));
}
@ApiOperation("获取指定用户信息")
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<UmsAdmin> getItem(@PathVariable Long id) {
UmsAdmin admin = adminService.getItem(id);
return CommonResult.success(admin);
}
@ApiOperation("修改指定用户信息")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody UmsAdmin admin) {
int count = adminService.update(id, admin);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("删除指定用户信息")
@RequestMapping(value = "/delete/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@PathVariable Long id) {
int count = adminService.delete(id);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("给用户分配角色")
@RequestMapping(value = "/role/update", method = RequestMethod.POST)
@ResponseBody
public CommonResult updateRole(@RequestParam("adminId") Long adminId,
@RequestParam("roleIds") List<Long> roleIds) {
int count = adminService.updateRole(adminId, roleIds);
if (count >= 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取指定用户的角色")
@RequestMapping(value = "/role/{adminId}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsRole>> getRoleList(@PathVariable Long adminId) {
List<UmsRole> roleList = adminService.getRoleList(adminId);
return CommonResult.success(roleList);
}
@ApiOperation("给用户分配+-权限")
@RequestMapping(value = "/permission/update", method = RequestMethod.POST)
@ResponseBody
public CommonResult updatePermission(@RequestParam Long adminId,
@RequestParam("permissionIds") List<Long> permissionIds) {
int count = adminService.updatePermission(adminId, permissionIds);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取用户所有权限(包括+-权限)")
@RequestMapping(value = "/permission/{adminId}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermission>> getPermissionList(@PathVariable Long adminId) {
List<UmsPermission> permissionList = adminService.getPermissionList(adminId);
return CommonResult.success(permissionList);
}
}

View File

@@ -0,0 +1,35 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.UmsMemberLevel;
import com.tuling.tulingmall.service.UmsMemberLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.List;
/**
* 会员等级管理Controller
* Created on 2018/4/26.
*/
@Controller
@Api(tags = "UmsMemberLevelController", description = "会员等级管理")
@RequestMapping("/memberLevel")
public class UmsMemberLevelController {
@Autowired
private UmsMemberLevelService memberLevelService;
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ApiOperation("查询所有会员等级")
@ResponseBody
public CommonResult<List<UmsMemberLevel>> list(@RequestParam("defaultStatus") Integer defaultStatus) {
List<UmsMemberLevel> memberLevelList = memberLevelService.list(defaultStatus);
return CommonResult.success(memberLevelList);
}
}

View File

@@ -0,0 +1,73 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.dto.UmsPermissionNode;
import com.tuling.tulingmall.model.UmsPermission;
import com.tuling.tulingmall.service.UmsPermissionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 后台用户权限管理
* Created on 2018/9/29.
*/
@Controller
@Api(tags = "UmsPermissionController", description = "后台用户权限管理")
@RequestMapping("/permission")
public class UmsPermissionController {
@Autowired
private UmsPermissionService permissionService;
@ApiOperation("添加权限")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody UmsPermission permission) {
int count = permissionService.create(permission);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改权限")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody UmsPermission permission) {
int count = permissionService.update(id,permission);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("根据id批量删除权限")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = permissionService.delete(ids);
if(count>0){
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("以层级结构返回所有权限")
@RequestMapping(value = "/treeList", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermissionNode>> treeList() {
List<UmsPermissionNode> permissionNodeList = permissionService.treeList();
return CommonResult.success(permissionNodeList);
}
@ApiOperation("获取所有权限列表")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermission>> list() {
List<UmsPermission> permissionList = permissionService.list();
return CommonResult.success(permissionList);
}
}

View File

@@ -0,0 +1,87 @@
package com.tuling.tulingmall.controller;
import com.tuling.tulingmall.common.api.CommonResult;
import com.tuling.tulingmall.model.UmsPermission;
import com.tuling.tulingmall.model.UmsRole;
import com.tuling.tulingmall.service.UmsRoleService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* 后台用户角色管理
* Created on 2018/9/30.
*/
@Controller
@Api(tags = "UmsRoleController", description = "后台用户角色管理")
@RequestMapping("/role")
public class UmsRoleController {
@Autowired
private UmsRoleService roleService;
@ApiOperation("添加角色")
@RequestMapping(value = "/create", method = RequestMethod.POST)
@ResponseBody
public CommonResult create(@RequestBody UmsRole role) {
int count = roleService.create(role);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("修改角色")
@RequestMapping(value = "/update/{id}", method = RequestMethod.POST)
@ResponseBody
public CommonResult update(@PathVariable Long id, @RequestBody UmsRole role) {
int count = roleService.update(id, role);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("批量删除角色")
@RequestMapping(value = "/delete", method = RequestMethod.POST)
@ResponseBody
public CommonResult delete(@RequestParam("ids") List<Long> ids) {
int count = roleService.delete(ids);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取相应角色权限")
@RequestMapping(value = "/permission/{roleId}", method = RequestMethod.GET)
@ResponseBody
public CommonResult<List<UmsPermission>> getPermissionList(@PathVariable Long roleId) {
List<UmsPermission> permissionList = roleService.getPermissionList(roleId);
return CommonResult.success(permissionList);
}
@ApiOperation("修改角色权限")
@RequestMapping(value = "/permission/update", method = RequestMethod.POST)
@ResponseBody
public CommonResult updatePermission(@RequestParam Long roleId,
@RequestParam("permissionIds") List<Long> permissionIds) {
int count = roleService.updatePermission(roleId, permissionIds);
if (count > 0) {
return CommonResult.success(count);
}
return CommonResult.failed();
}
@ApiOperation("获取所有角色")
@RequestMapping(value = "/list", method = RequestMethod.GET)
@ResponseBody
public Object list() {
List<UmsRole> roleList = roleService.list();
return CommonResult.success(roleList);
}
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.CmsPrefrenceAreaProductRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义优选和商品关系操作
* Created on 2018/4/26.
*/
public interface CmsPrefrenceAreaProductRelationDao {
int insertList(@Param("list") List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.CmsSubjectProductRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义商品和专题关系操作
* Created on 2018/4/26.
*/
public interface CmsSubjectProductRelationDao {
int insertList(@Param("list") List<CmsSubjectProductRelation> subjectProductRelationList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsMemberPrice;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义会员价格Dao
* Created on 2018/4/26.
*/
public interface PmsMemberPriceDao {
int insertList(@Param("list") List<PmsMemberPrice> memberPriceList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.dto.ProductAttrInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义商品属性Dao
* Created on 2018/5/23.
*/
public interface PmsProductAttributeDao {
List<ProductAttrInfo> getProductAttrInfo(@Param("id") Long productCategoryId);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsProductAttributeValue;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 商品参数商品自定义规格属性Dao
* Created on 2018/4/26.
*/
public interface PmsProductAttributeValueDao {
int insertList(@Param("list")List<PmsProductAttributeValue> productAttributeValueList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsProductCategoryAttributeRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义商品分类和属性关系Dao
* Created on 2018/5/23.
*/
public interface PmsProductCategoryAttributeRelationDao {
int insertList(@Param("list") List<PmsProductCategoryAttributeRelation> productCategoryAttributeRelationList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsProductFullReduction;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义商品满减Dao
* Created on 2018/4/26.
*/
public interface PmsProductFullReductionDao {
int insertList(@Param("list") List<PmsProductFullReduction> productFullReductionList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsProductLadder;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义会员阶梯价格Dao
* Created on 2018/4/26.
*/
public interface PmsProductLadderDao {
int insertList(@Param("list") List<PmsProductLadder> productLadderList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsProductVertifyRecord;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 商品审核日志自定义dao
* Created on 2018/4/27.
*/
public interface PmsProductVertifyRecordDao {
int insertList(@Param("list") List<PmsProductVertifyRecord> list);
}

View File

@@ -0,0 +1,22 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.PmsSkuStock;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 自定义商品sku库存Dao
* Created on 2018/4/26.
*/
public interface PmsSkuStockDao {
/**
* 批量插入操作
*/
int insertList(@Param("list")List<PmsSkuStock> skuStockList);
/**
* 批量插入或替换操作
*/
int replaceList(@Param("list")List<PmsSkuStock> skuStockList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.SmsCouponProductCategoryRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 优惠券和商品分类关系自定义Dao
* Created on 2018/8/28.
*/
public interface SmsCouponProductCategoryRelationDao {
int insertList(@Param("list")List<SmsCouponProductCategoryRelation> productCategoryRelationList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.SmsCouponProductRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 优惠券和产品关系自定义Dao
* Created on 2018/8/28.
*/
public interface SmsCouponProductRelationDao {
int insertList(@Param("list")List<SmsCouponProductRelation> productRelationList);
}

View File

@@ -0,0 +1,14 @@
package com.tuling.tulingmall.dao;
import com.tuling.tulingmall.model.UmsAdminPermissionRelation;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* 用户权限自定义Dao
* Created on 2018/10/8.
*/
public interface UmsAdminPermissionRelationDao {
int insertList(@Param("list") List<UmsAdminPermissionRelation> list);
}

View File

@@ -0,0 +1,19 @@
package com.tuling.tulingmall.dto;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
/**
* 修改订单费用信息参数
* Created on 2018/10/29.
*/
@Getter
@Setter
public class OmsMoneyInfoParam {
private Long orderId;
private BigDecimal freightAmount;
private BigDecimal discountAmount;
private Integer status;
}

View File

@@ -0,0 +1,20 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* 订单发货参数
* Created on 2018/10/12.
*/
@Getter
@Setter
public class OmsOrderDeliveryParam {
@ApiModelProperty("订单id")
private Long orderId;
@ApiModelProperty("物流公司")
private String deliveryCompany;
@ApiModelProperty("物流单号")
private String deliverySn;
}

View File

@@ -0,0 +1,22 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.OmsOrder;
import com.tuling.tulingmall.model.OmsOrderItem;
import com.tuling.tulingmall.model.OmsOrderOperateHistory;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
/**
* 订单详情信息
* Created on 2018/10/11.
*/
public class OmsOrderDetail extends OmsOrder {
@Getter
@Setter
private List<OmsOrderItem> orderItemList;
@Getter
@Setter
private List<OmsOrderOperateHistory> historyList;
}

View File

@@ -0,0 +1,28 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* 订单查询参数
* Created on 2018/10/11.
*/
@Getter
@Setter
public class OmsOrderQueryParam {
@ApiModelProperty(value = "订单编号")
private String orderSn;
@ApiModelProperty(value = "客户ID")
private String memberId;
@ApiModelProperty(value = "收货人姓名/号码")
private String receiverKeyword;
@ApiModelProperty(value = "订单状态0->待付款1->待发货2->已发货3->已完成4->已关闭5->无效订单")
private Integer status;
@ApiModelProperty(value = "订单类型0->正常订单1->秒杀订单")
private Integer orderType;
@ApiModelProperty(value = "订单来源0->PC订单1->app订单")
private Integer sourceType;
@ApiModelProperty(value = "订单提交时间")
private String createTime;
}

View File

@@ -0,0 +1,16 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.OmsCompanyAddress;
import com.tuling.tulingmall.model.OmsOrderReturnApply;
import lombok.Getter;
import lombok.Setter;
/**
* 申请信息封装
* Created on 2018/10/18.
*/
public class OmsOrderReturnApplyResult extends OmsOrderReturnApply {
@Getter
@Setter
private OmsCompanyAddress companyAddress;
}

View File

@@ -0,0 +1,22 @@
package com.tuling.tulingmall.dto;
import lombok.Getter;
import lombok.Setter;
/**
* 订单修改收货人信息参数
* Created on 2018/10/29.
*/
@Getter
@Setter
public class OmsReceiverInfoParam {
private Long orderId;
private String receiverName;
private String receiverPhone;
private String receiverPostCode;
private String receiverDetailAddress;
private String receiverProvince;
private String receiverCity;
private String receiverRegion;
private Integer status;
}

View File

@@ -0,0 +1,26 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* 订单退货申请查询参数
* Created on 2018/10/18.
*/
@Getter
@Setter
public class OmsReturnApplyQueryParam {
@ApiModelProperty("服务单号")
private Long id;
@ApiModelProperty(value = "收货人姓名/号码")
private String receiverKeyword;
@ApiModelProperty(value = "申请状态0->待处理1->退货中2->已完成3->已拒绝")
private Integer status;
@ApiModelProperty(value = "申请时间")
private String createTime;
@ApiModelProperty(value = "处理人员")
private String handleMan;
@ApiModelProperty(value = "处理时间")
private String handleTime;
}

View File

@@ -0,0 +1,32 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import java.math.BigDecimal;
/**
* 确认收货提交参数
* Created on 2018/10/18.
*/
@Getter
@Setter
public class OmsUpdateStatusParam {
@ApiModelProperty("服务单号")
private Long id;
@ApiModelProperty("收货地址关联id")
private Long companyAddressId;
@ApiModelProperty("确认退款金额")
private BigDecimal returnAmount;
@ApiModelProperty("处理备注")
private String handleNote;
@ApiModelProperty("处理人")
private String handleMan;
@ApiModelProperty("收货备注")
private String receiveNote;
@ApiModelProperty("收货人")
private String receiveMan;
@ApiModelProperty("申请状态1->退货中2->已完成3->已拒绝")
private Integer status;
}

View File

@@ -0,0 +1,40 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
/**
* oss上传成功后的回调参数
* Created on 2018/5/17.
*/
public class OssCallbackParam {
@ApiModelProperty("请求的回调地址")
private String callbackUrl;
@ApiModelProperty("回调是传入request中的参数")
private String callbackBody;
@ApiModelProperty("回调时传入参数的格式,比如表单提交形式")
private String callbackBodyType;
public String getCallbackUrl() {
return callbackUrl;
}
public void setCallbackUrl(String callbackUrl) {
this.callbackUrl = callbackUrl;
}
public String getCallbackBody() {
return callbackBody;
}
public void setCallbackBody(String callbackBody) {
this.callbackBody = callbackBody;
}
public String getCallbackBodyType() {
return callbackBodyType;
}
public void setCallbackBodyType(String callbackBodyType) {
this.callbackBodyType = callbackBodyType;
}
}

View File

@@ -0,0 +1,60 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
/**
* oss上传文件的回调结果
* Created on 2018/5/17.
*/
public class OssCallbackResult {
@ApiModelProperty("文件名称")
private String filename;
@ApiModelProperty("文件大小")
private String size;
@ApiModelProperty("文件的mimeType")
private String mimeType;
@ApiModelProperty("图片文件的宽")
private String width;
@ApiModelProperty("图片文件的高")
private String height;
public String getFilename() {
return filename;
}
public void setFilename(String filename) {
this.filename = filename;
}
public String getSize() {
return size;
}
public void setSize(String size) {
this.size = size;
}
public String getMimeType() {
return mimeType;
}
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public String getWidth() {
return width;
}
public void setWidth(String width) {
this.width = width;
}
public String getHeight() {
return height;
}
public void setHeight(String height) {
this.height = height;
}
}

View File

@@ -0,0 +1,70 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
/**
* 获取OSS上传文件授权返回结果
* Created on 2018/5/17.
*/
public class OssPolicyResult {
@ApiModelProperty("访问身份验证中用到用户标识")
private String accessKeyId;
@ApiModelProperty("用户表单上传的策略,经过base64编码过的字符串")
private String policy;
@ApiModelProperty("对policy签名后的字符串")
private String signature;
@ApiModelProperty("上传文件夹路径前缀")
private String dir;
@ApiModelProperty("oss对外服务的访问域名")
private String host;
@ApiModelProperty("上传成功后的回调设置")
private String callback;
public String getAccessKeyId() {
return accessKeyId;
}
public void setAccessKeyId(String accessKeyId) {
this.accessKeyId = accessKeyId;
}
public String getPolicy() {
return policy;
}
public void setPolicy(String policy) {
this.policy = policy;
}
public String getSignature() {
return signature;
}
public void setSignature(String signature) {
this.signature = signature;
}
public String getDir() {
return dir;
}
public void setDir(String dir) {
this.dir = dir;
}
public String getHost() {
return host;
}
public void setHost(String host) {
this.host = host;
}
public String getCallback() {
return callback;
}
public void setCallback(String callback) {
this.callback = callback;
}
}

View File

@@ -0,0 +1,99 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotEmpty;
import javax.validation.constraints.Min;
/**
* 品牌传递参数
* Created on 2018/4/26.
*/
public class PmsBrandParam {
@ApiModelProperty(value = "品牌名称",required = true)
@NotEmpty(message = "名称不能为空")
private String name;
@ApiModelProperty(value = "品牌首字母")
private String firstLetter;
@ApiModelProperty(value = "排序字段")
@Min(value = 0, message = "排序最小为0")
private Integer sort;
@ApiModelProperty(value = "是否为厂家制造商")
@FlagValidator(value = {"0","1"}, message = "厂家状态不正确")
private Integer factoryStatus;
@ApiModelProperty(value = "是否进行显示")
@FlagValidator(value = {"0","1"}, message = "显示状态不正确")
private Integer showStatus;
@ApiModelProperty(value = "品牌logo",required = true)
@NotEmpty(message = "品牌logo不能为空")
private String logo;
@ApiModelProperty(value = "品牌大图")
private String bigPic;
@ApiModelProperty(value = "品牌故事")
private String brandStory;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getFirstLetter() {
return firstLetter;
}
public void setFirstLetter(String firstLetter) {
this.firstLetter = firstLetter;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getFactoryStatus() {
return factoryStatus;
}
public void setFactoryStatus(Integer factoryStatus) {
this.factoryStatus = factoryStatus;
}
public Integer getShowStatus() {
return showStatus;
}
public void setShowStatus(Integer showStatus) {
this.showStatus = showStatus;
}
public String getLogo() {
return logo;
}
public void setLogo(String logo) {
this.logo = logo;
}
public String getBigPic() {
return bigPic;
}
public void setBigPic(String bigPic) {
this.bigPic = bigPic;
}
public String getBrandStory() {
return brandStory;
}
public void setBrandStory(String brandStory) {
this.brandStory = brandStory;
}
}

View File

@@ -0,0 +1,22 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.PmsProductAttribute;
import com.tuling.tulingmall.model.PmsProductAttributeCategory;
import java.util.List;
/**
* 包含有分类下属性的dto
* Created on 2018/5/24.
*/
public class PmsProductAttributeCategoryItem extends PmsProductAttributeCategory {
private List<PmsProductAttribute> productAttributeList;
public List<PmsProductAttribute> getProductAttributeList() {
return productAttributeList;
}
public void setProductAttributeList(List<PmsProductAttribute> productAttributeList) {
this.productAttributeList = productAttributeList;
}
}

View File

@@ -0,0 +1,131 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
import org.hibernate.validator.constraints.NotEmpty;
/**
* 商品属性参数
* Created on 2018/4/26.
*/
public class PmsProductAttributeParam {
@ApiModelProperty("属性分类ID")
@NotEmpty(message = "属性分类不能为空")
private Long productAttributeCategoryId;
@ApiModelProperty("属性名称")
@NotEmpty(message = "属性名称不能为空")
private String name;
@ApiModelProperty("属性选择类型0->唯一1->单选2->多选")
@FlagValidator({"0","1","2"})
private Integer selectType;
@ApiModelProperty("属性录入方式0->手工录入1->从列表中选取")
@FlagValidator({"0","1"})
private Integer inputType;
@ApiModelProperty("可选值列表,以逗号隔开")
private String inputList;
private Integer sort;
@ApiModelProperty("分类筛选样式0->普通1->颜色")
@FlagValidator({"0","1"})
private Integer filterType;
@ApiModelProperty("检索类型0->不需要进行检索1->关键字检索2->范围检索")
@FlagValidator({"0","1","2"})
private Integer searchType;
@ApiModelProperty("相同属性产品是否关联0->不关联1->关联")
@FlagValidator({"0","1"})
private Integer relatedStatus;
@ApiModelProperty("是否支持手动新增0->不支持1->支持")
@FlagValidator({"0","1"})
private Integer handAddStatus;
@ApiModelProperty("属性的类型0->规格1->参数")
@FlagValidator({"0","1"})
private Integer type;
public Long getProductAttributeCategoryId() {
return productAttributeCategoryId;
}
public void setProductAttributeCategoryId(Long productAttributeCategoryId) {
this.productAttributeCategoryId = productAttributeCategoryId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Integer getSelectType() {
return selectType;
}
public void setSelectType(Integer selectType) {
this.selectType = selectType;
}
public Integer getInputType() {
return inputType;
}
public void setInputType(Integer inputType) {
this.inputType = inputType;
}
public String getInputList() {
return inputList;
}
public void setInputList(String inputList) {
this.inputList = inputList;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public Integer getFilterType() {
return filterType;
}
public void setFilterType(Integer filterType) {
this.filterType = filterType;
}
public Integer getSearchType() {
return searchType;
}
public void setSearchType(Integer searchType) {
this.searchType = searchType;
}
public Integer getRelatedStatus() {
return relatedStatus;
}
public void setRelatedStatus(Integer relatedStatus) {
this.relatedStatus = relatedStatus;
}
public Integer getHandAddStatus() {
return handAddStatus;
}
public void setHandAddStatus(Integer handAddStatus) {
this.handAddStatus = handAddStatus;
}
public Integer getType() {
return type;
}
public void setType(Integer type) {
this.type = type;
}
}

View File

@@ -0,0 +1,119 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.validator.FlagValidator;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import java.util.List;
/**
* 添加更新产品分类的参数
* Created on 2018/4/26.
*/
public class PmsProductCategoryParam {
@ApiModelProperty("父分类的编号")
private Long parentId;
@ApiModelProperty(value = "商品分类名称",required = true)
@NotEmpty(message = "商品分类名称不能为空")
private String name;
@ApiModelProperty("分类单位")
private String productUnit;
@ApiModelProperty("是否在导航栏显示")
@FlagValidator(value = {"0","1"},message = "状态只能为0或1")
private Integer navStatus;
@ApiModelProperty("是否进行显示")
@FlagValidator(value = {"0","1"},message = "状态只能为0或1")
private Integer showStatus;
@ApiModelProperty("排序")
@Min(value = 0,message = "排序最小为0")
private Integer sort;
@ApiModelProperty("图标")
private String icon;
@ApiModelProperty("关键字")
private String keywords;
@ApiModelProperty("描述")
private String description;
@ApiModelProperty("产品相关筛选属性集合")
private List<Long> productAttributeIdList;
public Long getParentId() {
return parentId;
}
public void setParentId(Long parentId) {
this.parentId = parentId;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getProductUnit() {
return productUnit;
}
public void setProductUnit(String productUnit) {
this.productUnit = productUnit;
}
public Integer getNavStatus() {
return navStatus;
}
public void setNavStatus(Integer navStatus) {
this.navStatus = navStatus;
}
public Integer getShowStatus() {
return showStatus;
}
public void setShowStatus(Integer showStatus) {
this.showStatus = showStatus;
}
public Integer getSort() {
return sort;
}
public void setSort(Integer sort) {
this.sort = sort;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public List<Long> getProductAttributeIdList() {
return productAttributeIdList;
}
public void setProductAttributeIdList(List<Long> productAttributeIdList) {
this.productAttributeIdList = productAttributeIdList;
}
}

View File

@@ -0,0 +1,20 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.PmsProductCategory;
import java.util.List;
/**
* Created on 2018/5/25.
*/
public class PmsProductCategoryWithChildrenItem extends PmsProductCategory {
private List<PmsProductCategory> children;
public List<PmsProductCategory> getChildren() {
return children;
}
public void setChildren(List<PmsProductCategory> children) {
this.children = children;
}
}

View File

@@ -0,0 +1,83 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.*;
import io.swagger.annotations.ApiModelProperty;
import java.util.List;
/**
* 创建和修改商品时使用的参数
* Created on 2018/4/26.
*/
public class PmsProductParam extends PmsProduct{
@ApiModelProperty("商品阶梯价格设置")
private List<PmsProductLadder> productLadderList;
@ApiModelProperty("商品满减价格设置")
private List<PmsProductFullReduction> productFullReductionList;
@ApiModelProperty("商品会员价格设置")
private List<PmsMemberPrice> memberPriceList;
@ApiModelProperty("商品的sku库存信息")
private List<PmsSkuStock> skuStockList;
@ApiModelProperty("商品参数及自定义规格属性")
private List<PmsProductAttributeValue> productAttributeValueList;
@ApiModelProperty("专题和商品关系")
private List<CmsSubjectProductRelation> subjectProductRelationList;
@ApiModelProperty("优选专区和商品的关系")
private List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList;
public List<PmsProductLadder> getProductLadderList() {
return productLadderList;
}
public void setProductLadderList(List<PmsProductLadder> productLadderList) {
this.productLadderList = productLadderList;
}
public List<PmsProductFullReduction> getProductFullReductionList() {
return productFullReductionList;
}
public void setProductFullReductionList(List<PmsProductFullReduction> productFullReductionList) {
this.productFullReductionList = productFullReductionList;
}
public List<PmsMemberPrice> getMemberPriceList() {
return memberPriceList;
}
public void setMemberPriceList(List<PmsMemberPrice> memberPriceList) {
this.memberPriceList = memberPriceList;
}
public List<PmsSkuStock> getSkuStockList() {
return skuStockList;
}
public void setSkuStockList(List<PmsSkuStock> skuStockList) {
this.skuStockList = skuStockList;
}
public List<PmsProductAttributeValue> getProductAttributeValueList() {
return productAttributeValueList;
}
public void setProductAttributeValueList(List<PmsProductAttributeValue> productAttributeValueList) {
this.productAttributeValueList = productAttributeValueList;
}
public List<CmsSubjectProductRelation> getSubjectProductRelationList() {
return subjectProductRelationList;
}
public void setSubjectProductRelationList(List<CmsSubjectProductRelation> subjectProductRelationList) {
this.subjectProductRelationList = subjectProductRelationList;
}
public List<CmsPrefrenceAreaProductRelation> getPrefrenceAreaProductRelationList() {
return prefrenceAreaProductRelationList;
}
public void setPrefrenceAreaProductRelationList(List<CmsPrefrenceAreaProductRelation> prefrenceAreaProductRelationList) {
this.prefrenceAreaProductRelationList = prefrenceAreaProductRelationList;
}
}

View File

@@ -0,0 +1,70 @@
package com.tuling.tulingmall.dto;
import io.swagger.annotations.ApiModelProperty;
/**
* 产品查询参数
* Created on 2018/4/27.
*/
public class PmsProductQueryParam {
@ApiModelProperty("上架状态")
private Integer publishStatus;
@ApiModelProperty("审核状态")
private Integer verifyStatus;
@ApiModelProperty("商品名称模糊关键字")
private String keyword;
@ApiModelProperty("商品货号")
private String productSn;
@ApiModelProperty("商品分类编号")
private Long productCategoryId;
@ApiModelProperty("商品品牌编号")
private Long brandId;
public Integer getPublishStatus() {
return publishStatus;
}
public void setPublishStatus(Integer publishStatus) {
this.publishStatus = publishStatus;
}
public Integer getVerifyStatus() {
return verifyStatus;
}
public void setVerifyStatus(Integer verifyStatus) {
this.verifyStatus = verifyStatus;
}
public String getKeyword() {
return keyword;
}
public void setKeyword(String keyword) {
this.keyword = keyword;
}
public String getProductSn() {
return productSn;
}
public void setProductSn(String productSn) {
this.productSn = productSn;
}
public Long getProductCategoryId() {
return productCategoryId;
}
public void setProductCategoryId(Long productCategoryId) {
this.productCategoryId = productCategoryId;
}
public Long getBrandId() {
return brandId;
}
public void setBrandId(Long brandId) {
this.brandId = brandId;
}
}

View File

@@ -0,0 +1,18 @@
package com.tuling.tulingmall.dto;
/**
* 查询单个产品进行修改时返回的结果
* Created on 2018/4/26.
*/
public class PmsProductResult extends PmsProductParam {
//商品所选分类的父id
private Long cateParentId;
public Long getCateParentId() {
return cateParentId;
}
public void setCateParentId(Long cateParentId) {
this.cateParentId = cateParentId;
}
}

View File

@@ -0,0 +1,27 @@
package com.tuling.tulingmall.dto;
/**
* 商品分类对应属性信息
* Created on 2018/5/23.
*/
public class ProductAttrInfo {
private Long attributeId;
private Long attributeCategoryId;
public Long getAttributeId() {
return attributeId;
}
public void setAttributeId(Long attributeId) {
this.attributeId = attributeId;
}
public Long getAttributeCategoryId() {
return attributeCategoryId;
}
public void setAttributeCategoryId(Long attributeCategoryId) {
this.attributeCategoryId = attributeCategoryId;
}
}

View File

@@ -0,0 +1,34 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.SmsCoupon;
import com.tuling.tulingmall.model.SmsCouponProductCategoryRelation;
import com.tuling.tulingmall.model.SmsCouponProductRelation;
import java.util.List;
/**
* 优惠券信息封装,包括绑定商品和绑定分类
* Created on 2018/8/28.
*/
public class SmsCouponParam extends SmsCoupon {
//优惠券绑定的商品
private List<SmsCouponProductRelation> productRelationList;
//优惠券绑定的商品分类
private List<SmsCouponProductCategoryRelation> productCategoryRelationList;
public List<SmsCouponProductRelation> getProductRelationList() {
return productRelationList;
}
public void setProductRelationList(List<SmsCouponProductRelation> productRelationList) {
this.productRelationList = productRelationList;
}
public List<SmsCouponProductCategoryRelation> getProductCategoryRelationList() {
return productCategoryRelationList;
}
public void setProductCategoryRelationList(List<SmsCouponProductCategoryRelation> productCategoryRelationList) {
this.productCategoryRelationList = productCategoryRelationList;
}
}

View File

@@ -0,0 +1,16 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.PmsProduct;
import com.tuling.tulingmall.model.SmsFlashPromotionProductRelation;
import lombok.Getter;
import lombok.Setter;
/**
* 限时购及商品信息封装
* Created on 2018/11/16.
*/
public class SmsFlashPromotionProduct extends SmsFlashPromotionProductRelation{
@Getter
@Setter
private PmsProduct product;
}

View File

@@ -0,0 +1,15 @@
package com.tuling.tulingmall.dto;
import com.tuling.tulingmall.model.SmsFlashPromotionSession;
import lombok.Getter;
import lombok.Setter;
/**
* 包含商品数量的场次信息
* Created on 2018/11/19.
*/
public class SmsFlashPromotionSessionDetail extends SmsFlashPromotionSession {
@Setter
@Getter
private Long productCount;
}

Some files were not shown because too many files have changed in this diff Show More