Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
dm_project
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
姚本章
dm_project
Commits
644a8841
Commit
644a8841
authored
Dec 16, 2020
by
ysongq
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
commit
parent
436ffdf8
Changes
11
Show whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
85 additions
and
78 deletions
+85
-78
SMSUtils.java
jz-dm-common/src/main/java/com/jz/common/utils/SMSUtils.java
+43
-45
StatusCode.java
...-common/src/main/java/com/jz/common/utils/StatusCode.java
+2
-2
LoginController.java
...z/dm/mall/moduls/controller/customer/LoginController.java
+13
-11
MallCustomerController.java
...ll/moduls/controller/customer/MallCustomerController.java
+7
-7
PersonalUserController.java
...ll/moduls/controller/customer/PersonalUserController.java
+1
-1
ValidateCodeController.java
...ll/moduls/controller/customer/ValidateCodeController.java
+12
-7
DataGoodsApiController.java
.../mall/moduls/controller/goods/DataGoodsApiController.java
+2
-2
DataGoodsController.java
.../dm/mall/moduls/controller/goods/DataGoodsController.java
+2
-0
MallHotRecommendGoodsController.java
...uls/controller/goods/MallHotRecommendGoodsController.java
+1
-1
OrderController.java
...m/jz/dm/mall/moduls/controller/order/OrderController.java
+1
-1
DataGoodsApiController.java
...anage/moduls/controller/goods/DataGoodsApiController.java
+1
-1
No files found.
jz-dm-common/src/main/java/com/jz/common/utils/SMSUtils.java
View file @
644a8841
...
@@ -16,65 +16,63 @@ import com.aliyuncs.profile.IClientProfile;
...
@@ -16,65 +16,63 @@ import com.aliyuncs.profile.IClientProfile;
* @Version:
* @Version:
*/
*/
public
class
SMSUtils
{
public
class
SMSUtils
{
public
static
final
String
VALIDATE_CODE
=
"SMS_
198677589"
;
//发送短信验证码 验证码签名, 改成你的
public
static
final
String
VALIDATE_CODE
=
"SMS_
205878938"
;
//发送短信验证码模板编码 模版CODE
public
static
final
String
ORDER_NOTICE
=
"SMS_159771588"
;
//
成功通知, 通知类的模板(需要通用的签名)
public
static
final
String
ORDER_NOTICE
=
"SMS_159771588"
;
//
体检预约成功通知
private
static
final
String
SIGN_NAEM
=
"
ysongq
商城"
;
// 短信的签名
private
static
final
String
SIGN_NAEM
=
"
万家数据
商城"
;
// 短信的签名
private
static
final
String
PARAMETER_NAME
=
"code"
;
// 短信模板内容中的参数名
private
static
final
String
PARAMETER_NAME
=
"code"
;
private
static
final
String
ACCESS_KEY
=
"LTAI4G
AnKS1Gj2NwDepvyBuB"
;
//
AccessKey ID
private
static
final
String
ACCESS_KEY
=
"LTAI4G
KPoTkrT6n2fSV7ePEG"
;
//你的
AccessKey ID
private
static
final
String
SECRET_KEY
=
"
BIHOQP6muPtCz9YzrSQpSj0dJjZIET"
;
//
AccessKey Secret
private
static
final
String
SECRET_KEY
=
"
k8HcW3TxZzGxAetEpyDInZehip9MAE"
;
//你的
AccessKey Secret
public
static
void
main
(
String
[]
args
)
throws
ClientException
{
public
static
void
main
(
String
[]
args
)
throws
ClientException
{
SMSUtils
.
sendShortMessage
(
"VALIDATE_CODE"
,
"18279617424"
,
"666666
"
);
SMSUtils
.
sendShortMessage
(
VALIDATE_CODE
,
"19979232865"
,
"55555555
"
);
}
}
/**
/**
*
发送短信
*
* @param templateCode
验证码的模板code
* @param templateCode
* @param phoneNumbers
接收的手机号码
* @param phoneNumbers
* @param param
验证码
* @param param
* @throws ClientException
* @throws ClientException
*/
*/
public
static
void
sendShortMessage
(
String
templateCode
,
String
phoneNumbers
,
String
param
)
throws
ClientException
{
public
static
void
sendShortMessage
(
String
templateCode
,
String
phoneNumbers
,
String
param
)
throws
ClientException
{
//设置超时时间-可自行调整
//
设置超时时间-可自行调整
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultConnectTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
System
.
setProperty
(
"sun.net.client.defaultReadTimeout"
,
"10000"
);
//初始化ascClient需要的几个参数
// 初始化ascClient需要的几个参数
final
String
product
=
"Dysmsapi"
;
//短信API产品名称(短信产品名固定,无需修改)
final
String
product
=
"Dysmsapi"
;
// 短信API产品名称(短信产品名固定,无需修改)
final
String
domain
=
"dysmsapi.aliyuncs.com"
;
//短信API产品域名(接口地址固定,无需修改)
final
String
domain
=
"dysmsapi.aliyuncs.com"
;
// 短信API产品域名(接口地址固定,无需修改)
//替换成你的AK
// 替换成你的AK
final
String
accessKeyId
=
ACCESS_KEY
;
//你的accessKeyId,参考本文档步骤2
final
String
accessKeyId
=
"LTAIak3CfAehK7cE"
;
// 你的accessKeyId,参考本文档步骤2
final
String
accessKeySecret
=
SECRET_KEY
;
//你的accessKeySecret,参考本文档步骤2
final
String
accessKeySecret
=
"zsykwhTIFa48f8fFdU06GOKjHWHel4"
;
// 你的accessKeySecret,参考本文档步骤2
//初始化ascClient,暂时不支持多region(请勿修改)
// 初始化ascClient,暂时不支持多region(请勿修改)
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
accessKeyId
,
IClientProfile
profile
=
DefaultProfile
.
getProfile
(
"cn-hangzhou"
,
ACCESS_KEY
,
SECRET_KEY
);
accessKeySecret
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
product
,
domain
);
DefaultProfile
.
addEndpoint
(
"cn-hangzhou"
,
"cn-hangzhou"
,
product
,
domain
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
IAcsClient
acsClient
=
new
DefaultAcsClient
(
profile
);
// 组装请求对象
//组装请求对象
SendSmsRequest
request
=
new
SendSmsRequest
();
SendSmsRequest
request
=
new
SendSmsRequest
();
//使用post提交
//
使用post提交
request
.
setMethod
(
MethodType
.
POST
);
request
.
setMethod
(
MethodType
.
POST
);
//必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式;发送国际/港澳台消息时,接收号码格式为国际区号+号码,如“85200000000”
// 必填:待发送手机号。支持以逗号分隔的形式进行批量调用,批量上限为1000个手机号码,批量调用相对于单条调用及时性稍有延迟,验证码类型的短信推荐使用单条调用的方式
request
.
setPhoneNumbers
(
"1500000000"
);
request
.
setPhoneNumbers
(
phoneNumbers
);
//必填:短信签名-可在短信控制台中找到
// 必填:短信签名-可在短信控制台中找到
request
.
setSignName
(
"云通信"
);
request
.
setSignName
(
SIGN_NAEM
);
//必填:短信模板-可在短信控制台中找到,发送国际/港澳台消息时,请使用国际/港澳台短信模版
// 必填:短信模板-可在短信控制台中找到
request
.
setTemplateCode
(
"SMS_1000000"
);
request
.
setTemplateCode
(
templateCode
);
//可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
// 可选:模板中的变量替换JSON串,如模板内容为"亲爱的${name},您的验证码为${code}"时,此处的值为
//友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
// 友情提示:如果JSON中需要带换行符,请参照标准的JSON协议对换行符的要求,比如短信内容中包含\r\n的情况在JSON中需要表示成\\r\\n,否则会导致JSON在服务端解析失败
//参考:request.setTemplateParam("{\"变量1\":\"值1\",\"变量2\":\"值2\",\"变量3\":\"值3\"}")
//request.setTemplateParam("{\"code\":\""+param+"\"}");
request
.
setTemplateParam
(
"{\"name\":\"Tom\", \"code\":\"123\"}"
);
request
.
setTemplateParam
(
String
.
format
(
"{\"%s\":\"%s\"}"
,
PARAMETER_NAME
,
param
));
//可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段)
// 可选-上行短信扩展码(扩展码字段控制在7位或以下,无特殊需求用户请忽略此字段)
//request.setSmsUpExtendCode("90997");
// request.setSmsUpExtendCode("90997");
// 可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
//可选:outId为提供给业务方扩展字段,最终在短信回执消息中将此值带回给调用者
// request.setOutId("yourOutId");
request
.
setOutId
(
"yourOutId"
);
// 请求失败这里会抛ClientException异常
//请求失败这里会抛ClientException异常
SendSmsResponse
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
SendSmsResponse
sendSmsResponse
=
acsClient
.
getAcsResponse
(
request
);
if
(
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
if
(
sendSmsResponse
.
getCode
()
!=
null
&&
sendSmsResponse
.
getCode
().
equals
(
"OK"
))
{
//请求成功
// 请求成功
System
.
out
.
println
(
"请求成功"
);
}
else
{
System
.
out
.
println
(
sendSmsResponse
.
getMessage
());
}
}
}
}
}
}
jz-dm-common/src/main/java/com/jz/common/utils/StatusCode.java
View file @
644a8841
...
@@ -9,6 +9,6 @@ package com.jz.common.utils;
...
@@ -9,6 +9,6 @@ package com.jz.common.utils;
public
class
StatusCode
{
public
class
StatusCode
{
public
static
final
int
OK
=
200
;
// 成功
public
static
final
int
OK
=
200
;
// 成功
public
static
final
int
ERROR
=
201
;
// 失败
public
static
final
int
ERROR
=
201
;
// 失败
public
static
final
int
LOGINERROR
=
30
002
;
// 用户名或密码错误
public
static
final
int
LOGINERROR
=
30
1
;
// 用户名或密码错误
public
static
final
int
ACCESSERROR
=
30
003
;
// 权限不足
public
static
final
int
ACCESSERROR
=
30
2
;
// 权限不足
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/LoginController.java
View file @
644a8841
...
@@ -10,6 +10,7 @@ import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
...
@@ -10,6 +10,7 @@ import com.jz.dm.mall.moduls.controller.customer.bean.CustomerDto;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.entity.MallCustomer
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
com.jz.dm.mall.moduls.service.MallCustomerService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.apache.catalina.servlet4preview.http.HttpServletRequest
;
import
org.apache.catalina.servlet4preview.http.HttpServletRequest
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -28,7 +29,7 @@ import java.util.Map;
...
@@ -28,7 +29,7 @@ import java.util.Map;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/customer"
)
@RequestMapping
(
"/customer"
)
@Api
(
tags
=
"商城登陆
api
"
)
@Api
(
tags
=
"商城登陆
--controller
"
)
public
class
LoginController
{
public
class
LoginController
{
/**
/**
* 服务对象
* 服务对象
...
@@ -76,13 +77,14 @@ public class LoginController {
...
@@ -76,13 +77,14 @@ public class LoginController {
/**
/**
* 手机获取验证码
* 手机获取验证码
*
*
* @param
paramMap
* @param
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/getCode"
)
@PostMapping
(
value
=
"/getCode"
)
public
Result
loginCheck
(
@RequestParam
(
required
=
true
)
Map
<
String
,
String
>
paramMap
)
{
@ApiOperation
(
"通过手机号码获取验证码"
)
public
Result
loginCheck
(
@RequestParam
(
value
=
"telephone"
)
String
telephone
,
@RequestParam
(
value
=
"validateCode"
)
String
validateCode
)
{
// 获取手机号码
// 获取手机号码
String
telephone
=
paramMap
.
get
(
"telephone"
);
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
// 获取redis中key对应的值
// 获取redis中key对应的值
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
...
@@ -90,7 +92,7 @@ public class LoginController {
...
@@ -90,7 +92,7 @@ public class LoginController {
return
new
Result
(
false
,
"请重新获取验证码!"
,
StatusCode
.
ERROR
);
return
new
Result
(
false
,
"请重新获取验证码!"
,
StatusCode
.
ERROR
);
}
}
// 判断验证码是否一致
// 判断验证码是否一致
if
(!
codeInRedis
.
equals
(
paramMap
.
get
(
"validateCode"
)
))
{
if
(!
codeInRedis
.
equals
(
validateCode
))
{
return
new
Result
(
false
,
"验证码不正确!"
,
StatusCode
.
ERROR
);
return
new
Result
(
false
,
"验证码不正确!"
,
StatusCode
.
ERROR
);
}
}
// 删除redis的验证码
// 删除redis的验证码
...
@@ -109,13 +111,13 @@ public class LoginController {
...
@@ -109,13 +111,13 @@ public class LoginController {
@ApiOperation
(
value
=
"手机号码校验接口"
,
notes
=
"手机号码是否已注册"
)
@ApiOperation
(
value
=
"手机号码校验接口"
,
notes
=
"手机号码是否已注册"
)
public
Result
phoneCheck
(
@RequestParam
(
"telephone"
)
String
telephone
)
{
public
Result
phoneCheck
(
@RequestParam
(
"telephone"
)
String
telephone
)
{
if
(
telephone
==
null
)
{
if
(
telephone
==
null
)
{
return
new
Result
(
false
,
"请重新输入手机号!"
);
return
new
Result
(
false
,
"请重新输入手机号!"
,
StatusCode
.
ERROR
);
}
}
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
return
new
Result
(
false
,
"手机号码已注册!"
);
return
new
Result
(
false
,
"手机号码已注册!"
,
StatusCode
.
ERROR
);
}
}
return
new
Result
(
true
,
"手机号码未注册!"
);
return
new
Result
(
true
,
"手机号码未注册!"
,
StatusCode
.
OK
);
}
}
...
@@ -136,7 +138,7 @@ public class LoginController {
...
@@ -136,7 +138,7 @@ public class LoginController {
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
telephone
))
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
telephone
))
{
return
new
Result
(
false
,
"手机号相同"
);
return
new
Result
(
false
,
"手机号相同"
,
StatusCode
.
ERROR
);
}
}
}
}
}
}
...
@@ -144,9 +146,9 @@ public class LoginController {
...
@@ -144,9 +146,9 @@ public class LoginController {
CustomerDto
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
,
request
);
CustomerDto
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
,
request
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
))
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
))
{
return
new
Result
(
false
,
"用户名相同!"
);
return
new
Result
(
false
,
"用户名相同!"
,
StatusCode
.
ERROR
);
}
}
}
}
return
new
Result
(
true
,
"用户名不同!"
);
return
new
Result
(
true
,
"用户名不同!"
,
StatusCode
.
OK
);
}
}
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/MallCustomerController.java
View file @
644a8841
...
@@ -34,7 +34,7 @@ import java.util.Map;
...
@@ -34,7 +34,7 @@ import java.util.Map;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/mallCustomer"
)
@RequestMapping
(
"/mallCustomer"
)
@Api
(
tags
=
"商城用户
api
"
)
@Api
(
tags
=
"商城用户
--controller
"
)
public
class
MallCustomerController
extends
BaseController
{
public
class
MallCustomerController
extends
BaseController
{
/**
/**
* 服务对象
* 服务对象
...
@@ -61,7 +61,7 @@ public class MallCustomerController extends BaseController {
...
@@ -61,7 +61,7 @@ public class MallCustomerController extends BaseController {
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
MallCustomer
mallCustomer
=
mallCustomerService
.
selectByPhone
(
telephone
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
telephone
))
{
if
(
mallCustomer
.
getCustomerPhone
().
equals
(
telephone
))
{
return
new
Result
(
false
,
"手机号相同"
);
return
new
Result
(
false
,
"手机号相同"
,
StatusCode
.
ERROR
);
}
}
}
}
}
}
...
@@ -69,7 +69,7 @@ public class MallCustomerController extends BaseController {
...
@@ -69,7 +69,7 @@ public class MallCustomerController extends BaseController {
CustomerDto
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
,
request
);
CustomerDto
mallCustomer
=
mallCustomerService
.
selectByAccount
(
username
,
request
);
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
!=
null
)
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
))
{
if
(
mallCustomer
.
getCustomerAccount
().
equals
(
username
))
{
return
new
Result
(
false
,
"用户名相同"
);
return
new
Result
(
false
,
"用户名相同"
,
StatusCode
.
ERROR
);
}
}
}
}
mallCustomerService
.
saveCustomer
(
paramMap
);
mallCustomerService
.
saveCustomer
(
paramMap
);
...
@@ -95,12 +95,12 @@ public class MallCustomerController extends BaseController {
...
@@ -95,12 +95,12 @@ public class MallCustomerController extends BaseController {
return
new
Result
(
true
,
"获取用户信息成功!"
,
StatusCode
.
OK
,
user
);
return
new
Result
(
true
,
"获取用户信息成功!"
,
StatusCode
.
OK
,
user
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
new
Result
(
false
,
"获取用户信息失败"
);
return
new
Result
(
false
,
"获取用户信息失败"
,
StatusCode
.
ERROR
);
}
}
}
}
@PostMapping
(
value
=
"/updatePassword"
)
@PostMapping
(
value
=
"/updatePassword"
)
@Api
ModelProperty
(
value
=
"密码修改"
)
@Api
Operation
(
value
=
"密码修改"
)
public
Result
updatePassword
(
@RequestParam
(
value
=
"oldPassWard"
)
String
oldPassword
,
public
Result
updatePassword
(
@RequestParam
(
value
=
"oldPassWard"
)
String
oldPassword
,
@RequestParam
(
value
=
"newPassword"
)
String
newPassword
,
HttpServletRequest
request
)
throws
Exception
{
@RequestParam
(
value
=
"newPassword"
)
String
newPassword
,
HttpServletRequest
request
)
throws
Exception
{
// 获取用户信息
// 获取用户信息
...
@@ -110,8 +110,8 @@ public class MallCustomerController extends BaseController {
...
@@ -110,8 +110,8 @@ public class MallCustomerController extends BaseController {
// 修改密码
// 修改密码
Long
customerId
=
mallCustomer
.
getCustomerId
();
Long
customerId
=
mallCustomer
.
getCustomerId
();
mallCustomerService
.
updatePassword
(
customerId
,
newPassword
);
mallCustomerService
.
updatePassword
(
customerId
,
newPassword
);
return
new
Result
(
true
,
"密码修改成功"
);
return
new
Result
(
true
,
"密码修改成功"
,
StatusCode
.
OK
);
}
}
return
new
Result
(
false
,
"密码修改失败"
);
return
new
Result
(
false
,
"密码修改失败"
,
StatusCode
.
ERROR
);
}
}
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/PersonalUserController.java
View file @
644a8841
...
@@ -22,7 +22,7 @@ import reactor.core.publisher.Mono;
...
@@ -22,7 +22,7 @@ import reactor.core.publisher.Mono;
**/
**/
@RestController
@RestController
@RequestMapping
(
"/personalUser"
)
@RequestMapping
(
"/personalUser"
)
@Api
(
tags
=
"用户信息controller"
)
@Api
(
tags
=
"用户信息
--
controller"
)
public
class
PersonalUserController
{
public
class
PersonalUserController
{
@Autowired
@Autowired
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/customer/ValidateCodeController.java
View file @
644a8841
...
@@ -4,8 +4,11 @@ import com.aliyuncs.exceptions.ClientException;
...
@@ -4,8 +4,11 @@ import com.aliyuncs.exceptions.ClientException;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.constant.RedisMessageConstant
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.Result
;
import
com.jz.common.utils.SMSUtils
;
import
com.jz.common.utils.SMSUtils
;
import
com.jz.common.utils.StatusCode
;
import
com.jz.common.utils.ValidateCodeUtils
;
import
com.jz.common.utils.ValidateCodeUtils
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiModelProperty
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.data.redis.core.RedisTemplate
;
import
org.springframework.util.StringUtils
;
import
org.springframework.util.StringUtils
;
...
@@ -24,7 +27,7 @@ import java.util.concurrent.TimeUnit;
...
@@ -24,7 +27,7 @@ import java.util.concurrent.TimeUnit;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/validateCode"
)
@RequestMapping
(
"/validateCode"
)
@Api
(
tags
=
"短信发送
api
"
)
@Api
(
tags
=
"短信发送
--controller
"
)
public
class
ValidateCodeController
{
public
class
ValidateCodeController
{
@Autowired
@Autowired
...
@@ -36,13 +39,14 @@ public class ValidateCodeController {
...
@@ -36,13 +39,14 @@ public class ValidateCodeController {
* @return
* @return
*/
*/
@PostMapping
(
value
=
"/sendForLogin"
)
@PostMapping
(
value
=
"/sendForLogin"
)
@ApiOperation
(
value
=
"注册时发送的验证码"
)
public
Result
sendForLogin
(
String
telephone
)
{
public
Result
sendForLogin
(
String
telephone
)
{
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
// 通过手机号从redis获取验证码
// 通过手机号从redis获取验证码
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
if
(!
StringUtils
.
isEmpty
(
codeInRedis
))
{
if
(!
StringUtils
.
isEmpty
(
codeInRedis
))
{
return
new
Result
(
false
,
"验证码已发送,请注意查收!"
);
return
new
Result
(
false
,
"验证码已发送,请注意查收!"
,
StatusCode
.
ERROR
);
}
else
{
}
else
{
// 生成验证码
// 生成验证码
String
code
=
ValidateCodeUtils
.
generateValidateCode
(
6
)
+
""
;
String
code
=
ValidateCodeUtils
.
generateValidateCode
(
6
)
+
""
;
...
@@ -51,11 +55,11 @@ public class ValidateCodeController {
...
@@ -51,11 +55,11 @@ public class ValidateCodeController {
SMSUtils
.
sendShortMessage
(
SMSUtils
.
VALIDATE_CODE
,
telephone
,
code
);
SMSUtils
.
sendShortMessage
(
SMSUtils
.
VALIDATE_CODE
,
telephone
,
code
);
}
catch
(
ClientException
e
)
{
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
new
Result
(
false
,
"验证码发送失败!"
);
return
new
Result
(
false
,
"验证码发送失败!"
,
StatusCode
.
ERROR
);
}
}
// 存入redis, 有效期为5分钟
// 存入redis, 有效期为5分钟
redisTemplate
.
opsForValue
().
set
(
key
,
code
,
5
,
TimeUnit
.
MINUTES
);
redisTemplate
.
opsForValue
().
set
(
key
,
code
,
5
,
TimeUnit
.
MINUTES
);
return
new
Result
(
true
,
"验证码发送成功!"
);
return
new
Result
(
true
,
"验证码发送成功!"
,
StatusCode
.
OK
);
}
}
}
}
...
@@ -66,13 +70,14 @@ public class ValidateCodeController {
...
@@ -66,13 +70,14 @@ public class ValidateCodeController {
* @return
* @return
*/
*/
@PostMapping
(
"/send4Code"
)
@PostMapping
(
"/send4Code"
)
@ApiOperation
(
value
=
"修改密码发送验证码"
)
public
Result
send4Code
(
String
telephone
)
{
public
Result
send4Code
(
String
telephone
)
{
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
String
key
=
RedisMessageConstant
.
SENDTYPE_LOGIN
+
"_"
+
telephone
;
// 通过手机号从redis获取验证码
// 通过手机号从redis获取验证码
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
String
codeInRedis
=
(
String
)
redisTemplate
.
opsForValue
().
get
(
key
);
if
(!
StringUtils
.
isEmpty
(
codeInRedis
))
{
if
(!
StringUtils
.
isEmpty
(
codeInRedis
))
{
return
new
Result
(
false
,
"验证码已发送,请注意查收!"
);
return
new
Result
(
false
,
"验证码已发送,请注意查收!"
,
StatusCode
.
ERROR
);
}
else
{
}
else
{
// 生成验证码
// 生成验证码
String
code
=
ValidateCodeUtils
.
generateValidateCode
(
6
)
+
""
;
String
code
=
ValidateCodeUtils
.
generateValidateCode
(
6
)
+
""
;
...
@@ -81,11 +86,11 @@ public class ValidateCodeController {
...
@@ -81,11 +86,11 @@ public class ValidateCodeController {
SMSUtils
.
sendShortMessage
(
SMSUtils
.
VALIDATE_CODE
,
telephone
,
code
);
SMSUtils
.
sendShortMessage
(
SMSUtils
.
VALIDATE_CODE
,
telephone
,
code
);
}
catch
(
ClientException
e
)
{
}
catch
(
ClientException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
return
new
Result
(
false
,
"验证码发送失败!"
);
return
new
Result
(
false
,
"验证码发送失败!"
,
StatusCode
.
ERROR
);
}
}
// 存入redis, 有效期为5分钟
// 存入redis, 有效期为5分钟
redisTemplate
.
opsForValue
().
set
(
key
,
code
,
5
,
TimeUnit
.
MINUTES
);
redisTemplate
.
opsForValue
().
set
(
key
,
code
,
5
,
TimeUnit
.
MINUTES
);
return
new
Result
(
true
,
"验证码发送成功!"
);
return
new
Result
(
true
,
"验证码发送成功!"
,
StatusCode
.
OK
);
}
}
}
}
}
}
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/goods/DataGoodsApiController.java
View file @
644a8841
...
@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.RestController;
*/
*/
@RestController
@RestController
@RequestMapping
(
"dataGoodsApi"
)
@RequestMapping
(
"dataGoodsApi"
)
@Api
(
"api商品详情
"
)
@Api
(
tags
=
"商品详情--controller
"
)
public
class
DataGoodsApiController
extends
BaseController
{
public
class
DataGoodsApiController
extends
BaseController
{
/**
/**
* 服务对象
* 服务对象
...
@@ -44,6 +44,6 @@ public class DataGoodsApiController extends BaseController {
...
@@ -44,6 +44,6 @@ public class DataGoodsApiController extends BaseController {
DataGoodsApiDto
dataGoodsApi
=
tDataGoodsApiService
.
selectById
(
id
);
DataGoodsApiDto
dataGoodsApi
=
tDataGoodsApiService
.
selectById
(
id
);
return
new
Result
<
DataGoodsApiDto
>(
true
,
"查询商品详情成功!"
,
StatusCode
.
OK
,
dataGoodsApi
);
return
new
Result
<
DataGoodsApiDto
>(
true
,
"查询商品详情成功!"
,
StatusCode
.
OK
,
dataGoodsApi
);
}
}
return
new
Result
<>(
false
,
"查询商品详情失败!"
);
return
new
Result
<>(
false
,
"查询商品详情失败!"
,
StatusCode
.
ERROR
);
}
}
}
}
\ No newline at end of file
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/goods/DataGoodsController.java
View file @
644a8841
...
@@ -11,6 +11,7 @@ import com.jz.dm.mall.moduls.controller.goods.bean.request.DataGoodsListRequest;
...
@@ -11,6 +11,7 @@ import com.jz.dm.mall.moduls.controller.goods.bean.request.DataGoodsListRequest;
import
com.jz.dm.mall.moduls.controller.goods.bean.request.DataGoodsRequest
;
import
com.jz.dm.mall.moduls.controller.goods.bean.request.DataGoodsRequest
;
import
com.jz.dm.mall.moduls.entity.DataGoods
;
import
com.jz.dm.mall.moduls.entity.DataGoods
;
import
com.jz.dm.mall.moduls.service.DataGoodsService
;
import
com.jz.dm.mall.moduls.service.DataGoodsService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
...
@@ -26,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
...
@@ -26,6 +27,7 @@ import javax.servlet.http.HttpServletRequest;
*/
*/
@RestController
@RestController
@RequestMapping
(
"dataGoods"
)
@RequestMapping
(
"dataGoods"
)
@Api
(
tags
=
"数据商品--controller"
)
public
class
DataGoodsController
extends
BaseController
{
public
class
DataGoodsController
extends
BaseController
{
/**
/**
* 服务对象
* 服务对象
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/goods/MallHotRecommendGoodsController.java
View file @
644a8841
...
@@ -22,7 +22,7 @@ import java.util.List;
...
@@ -22,7 +22,7 @@ import java.util.List;
*/
*/
@RestController
@RestController
@RequestMapping
(
"mallHotRecommendGoods"
)
@RequestMapping
(
"mallHotRecommendGoods"
)
@Api
(
tags
=
"热门商品
api
"
)
@Api
(
tags
=
"热门商品
--controller
"
)
public
class
MallHotRecommendGoodsController
extends
BaseController
{
public
class
MallHotRecommendGoodsController
extends
BaseController
{
/**
/**
* 服务对象
* 服务对象
...
...
jz-dm-mall/src/main/java/com/jz/dm/mall/moduls/controller/order/OrderController.java
View file @
644a8841
...
@@ -25,7 +25,7 @@ import java.util.Map;
...
@@ -25,7 +25,7 @@ import java.util.Map;
*/
*/
@RestController
@RestController
@RequestMapping
(
"/order"
)
@RequestMapping
(
"/order"
)
@Api
(
tags
=
"订单管理"
)
@Api
(
tags
=
"订单管理
--controller
"
)
public
class
OrderController
{
public
class
OrderController
{
/**
/**
* 服务对象
* 服务对象
...
...
jz-dm-manage/src/main/java/com/jz/manage/moduls/controller/goods/DataGoodsApiController.java
View file @
644a8841
...
@@ -41,6 +41,6 @@ public class DataGoodsApiController extends BaseController {
...
@@ -41,6 +41,6 @@ public class DataGoodsApiController extends BaseController {
DataGoodsApiDto
dataGoodsApi
=
tDataGoodsApiService
.
selectById
(
id
);
DataGoodsApiDto
dataGoodsApi
=
tDataGoodsApiService
.
selectById
(
id
);
return
new
Result
<
DataGoodsApiDto
>(
true
,
"查询商品详情成功!"
,
StatusCode
.
OK
,
dataGoodsApi
);
return
new
Result
<
DataGoodsApiDto
>(
true
,
"查询商品详情成功!"
,
StatusCode
.
OK
,
dataGoodsApi
);
}
}
return
new
Result
<>(
false
,
"查询商品详情失败!"
);
return
new
Result
<>(
false
,
"查询商品详情失败!"
,
StatusCode
.
ERROR
);
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment