Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
8
8timerapiv200
Overview
Overview
Details
Activity
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
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
8timerv2
8timerapiv200
Commits
a3e5e76b
Commit
a3e5e76b
authored
May 25, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新添加了绑定邮箱业务
parent
4cffefae
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
199 additions
and
15 deletions
+199
-15
pom.xml
+4
-0
src/main/java/cn/timer/api/bean/qyzx/QyzxEmpLogin.java
+3
-0
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
+1
-5
src/main/java/cn/timer/api/controller/LoginController.java
+21
-10
src/main/java/cn/timer/api/controller/email/EmailController.java
+162
-0
src/main/resources/application-dev.yml
+8
-0
No files found.
pom.xml
View file @
a3e5e76b
...
...
@@ -94,6 +94,10 @@
<artifactId>spring-boot-starter-security</artifactId>
</dependency> -->
<dependency>
<groupId>
org.springframework.boot
</groupId>
<artifactId>
spring-boot-starter-mail
</artifactId>
</dependency>
<!-- 添加MySQL依赖 -->
<dependency>
...
...
src/main/java/cn/timer/api/bean/qyzx/QyzxEmpLogin.java
View file @
a3e5e76b
...
...
@@ -51,6 +51,9 @@ public class QyzxEmpLogin extends Model<QyzxEmpLogin> {
@ApiModelProperty
(
value
=
"邮箱地址 "
,
example
=
"邮箱地址"
)
private
String
email
;
@ApiModelProperty
(
value
=
"邮箱状态 "
,
example
=
"0-未激活 1-已绑定"
)
private
Integer
emailStatus
;
@ApiModelProperty
(
value
=
"微信openid "
,
example
=
"微信openid"
)
private
String
openid
;
...
...
src/main/java/cn/timer/api/config/interceptor/WebSecurityConfig.java
View file @
a3e5e76b
package
cn
.
timer
.
api
.
config
.
interceptor
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.Iterator
;
import
java.util.List
;
import
javax.annotation.Resource
;
...
...
@@ -11,13 +9,11 @@ import org.springframework.context.annotation.Bean;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.MediaType
;
import
org.springframework.http.converter.HttpMessageConverter
;
import
org.springframework.http.converter.json.MappingJackson2HttpMessageConverter
;
import
org.springframework.web.method.support.HandlerMethodArgumentResolver
;
import
org.springframework.web.servlet.config.annotation.InterceptorRegistry
;
import
org.springframework.web.servlet.config.annotation.WebMvcConfigurer
;
import
com.alibaba.fastjson.serializer.SerializerFeature
;
import
com.alibaba.fastjson.serializer.ValueFilter
;
import
com.alibaba.fastjson.support.config.FastJsonConfig
;
import
com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter
;
...
...
@@ -47,7 +43,7 @@ public class WebSecurityConfig implements WebMvcConfigurer {
.
excludePathPatterns
(
"/8timer/**"
)
.
excludePathPatterns
(
"/kqdk/punchclock/**"
)
.
excludePathPatterns
(
"/kqz/sauserregdata/**"
)
.
excludePathPatterns
(
"/login/*"
)
.
excludePathPatterns
(
"/login/*
*
"
)
.
excludePathPatterns
(
"/swagger*/**"
)
.
excludePathPatterns
(
"/v2/api-docs"
)
.
excludePathPatterns
(
"/druid/login*"
)
...
...
src/main/java/cn/timer/api/controller/LoginController.java
View file @
a3e5e76b
...
...
@@ -12,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.interceptor.TransactionAspectSupport
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
...
@@ -63,13 +65,13 @@ public class LoginController {
@Value
(
value
=
"${config-8timer.init-password}"
)
public
String
pwd
;
// 系统赠送时间
@Value
(
"${config-8timer.register-free-time}"
)
public
Integer
offset
;
// 系统赠送时间
@Value
(
"${config-8timer.register-company-max-num}"
)
public
Integer
max
;
@Value
(
"${config-8timer.register-childAccount-max-num}"
)
public
Integer
maxChildAccount
;
...
...
@@ -137,7 +139,7 @@ public class LoginController {
@Autowired
private
QyzxEmpEntAssoMapper
qyzxEmpEntAssoMapper
;
@Autowired
private
ZzglBmgwMMapper
zzglBmgwMMapper
;
...
...
@@ -438,7 +440,7 @@ public class LoginController {
@ApiOperation
(
value
=
"6.注册企业"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
@ApiOperationSupport
(
order
=
6
)
@Log
(
title
=
"企业注册"
,
businessType
=
BusinessType
.
INSERT
)
public
Result
<
String
>
register
(
@RequestBody
EntRegisterDto
entRegisterDto
)
throws
Exception
{
public
Result
<
String
>
register
(
@RequestBody
EntRegisterDto
entRegisterDto
)
throws
Exception
{
try
{
String
phone
=
entRegisterDto
.
getPhone
();
...
...
@@ -486,8 +488,9 @@ public class LoginController {
}
boolean
b4
=
YgglMainEmp
.
builder
().
orgCode
(
qyzxEntInfoM
.
getId
()).
empNum
(
login
.
getId
()).
rzTime
(
new
Date
())
.
isManager
(
CommonEnum
.
U_TYPE_ADMIN
.
getType
()).
name
(
username
).
phone
(
phone
).
jobType
(
YgJobType
.
QUANZHI
.
getType
()).
jobStatus
(
YgEnumInterface
.
jobStatus
.
ZHENSHI
.
getType
())
.
build
().
insert
();
.
isManager
(
CommonEnum
.
U_TYPE_ADMIN
.
getType
()).
name
(
username
).
phone
(
phone
)
.
jobType
(
YgJobType
.
QUANZHI
.
getType
()).
jobStatus
(
YgEnumInterface
.
jobStatus
.
ZHENSHI
.
getType
()).
build
()
.
insert
();
if
(!
b4
)
{
TransactionAspectSupport
.
currentTransactionStatus
().
setRollbackOnly
();
return
ResultUtil
.
error
(
"注册企业失败3"
);
...
...
@@ -504,10 +507,9 @@ public class LoginController {
SpmkService
.
createCustomApproval
(
qyzxEntInfoM
.
getId
());
QyzxAuthAccount
.
builder
().
createdTime
(
new
Date
()).
maxChildAccount
(
maxChildAccount
).
name
(
username
).
accountPhone
(
phone
).
empNum
(
login
.
getId
())
.
orgCode
(
qyzxEntInfoM
.
getId
()).
build
().
insert
();
// TODO 主账号权限表
QyzxAuthAccount
.
builder
().
createdTime
(
new
Date
()).
maxChildAccount
(
maxChildAccount
).
name
(
username
)
.
accountPhone
(
phone
).
empNum
(
login
.
getId
()).
orgCode
(
qyzxEntInfoM
.
getId
()).
build
().
insert
();
// TODO
// 主账号权限表
return
ResultUtil
.
success
(
"注册企业成功"
);
}
catch
(
Exception
e
)
{
...
...
@@ -640,4 +642,13 @@ public class LoginController {
}
@GetMapping
(
value
=
"/band/{empNum}"
)
public
Result
<
Object
>
bandEmail
(
@PathVariable
Integer
empNum
)
{
boolean
result
=
QyzxEmpLogin
.
builder
().
id
(
empNum
).
emailStatus
(
1
).
build
().
updateById
();
if
(
result
)
{
return
ResultUtil
.
success
(
"绑定成功"
);
}
return
ResultUtil
.
error
(
"绑定失败"
);
}
}
src/main/java/cn/timer/api/controller/email/EmailController.java
0 → 100644
View file @
a3e5e76b
/**
* <p>Title: EmailController.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月25日
* @version 1.0
*/
package
cn
.
timer
.
api
.
controller
.
email
;
import
java.io.File
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.FileSystemResource
;
import
org.springframework.mail.SimpleMailMessage
;
import
org.springframework.mail.javamail.JavaMailSender
;
import
org.springframework.mail.javamail.MimeMessageHelper
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RestController
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
import
cn.timer.api.utils.Result
;
import
cn.timer.api.utils.ResultUtil
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
/**
* <p>
* Title: EmailController.java
* </p>
* <p>
* Description:
* </p>
*
* @author dsc
* @date 2020年5月25日
* @version 1.0
*/
@RestController
@Api
(
tags
=
"1.1 邮件发送"
)
@Transactional
@RequestMapping
(
value
=
"/email"
,
produces
=
{
"application/json"
})
public
class
EmailController
{
private
final
Logger
logger
=
LoggerFactory
.
getLogger
(
this
.
getClass
());
@Value
(
"${spring.mail.username}"
)
private
String
from
;
@Autowired
JavaMailSender
mailSender
;
@PostMapping
(
"/sendSimpleMail"
)
@ApiOperation
(
value
=
"发送简单邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendSimpleMail
(
String
to
,
String
subject
,
String
content
)
{
SimpleMailMessage
message
=
new
SimpleMailMessage
();
message
.
setTo
(
to
);
message
.
setSubject
(
subject
);
message
.
setText
(
content
);
message
.
setFrom
(
from
);
mailSender
.
send
(
message
);
return
ResultUtil
.
success
();
}
@PostMapping
(
"/sendHtmlMail"
)
@ApiOperation
(
value
=
"发送html邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendHtmlMail
(
String
to
,
String
subject
,
String
content
)
{
MimeMessage
message
=
mailSender
.
createMimeMessage
();
try
{
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
helper
.
setFrom
(
from
);
helper
.
setTo
(
to
);
helper
.
setSubject
(
subject
);
helper
.
setText
(
content
,
true
);
mailSender
.
send
(
message
);
}
catch
(
MessagingException
e
)
{
e
.
printStackTrace
();
}
return
ResultUtil
.
success
();
}
@PostMapping
(
"/sendAttchmentMail"
)
@ApiOperation
(
value
=
"发送附件邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendAttchmentMail
(
String
to
,
String
subject
,
String
content
,
String
filePath
)
{
MimeMessage
message
=
mailSender
.
createMimeMessage
();
try
{
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
helper
.
setFrom
(
from
);
helper
.
setTo
(
to
);
helper
.
setSubject
(
subject
);
helper
.
setText
(
content
,
true
);
FileSystemResource
file
=
new
FileSystemResource
(
new
File
(
filePath
));
String
fileName
=
file
.
getFilename
();
helper
.
addAttachment
(
fileName
,
file
);
// 可将参数换成数组遍历传送多个附件
mailSender
.
send
(
message
);
}
catch
(
MessagingException
e
)
{
e
.
printStackTrace
();
}
return
ResultUtil
.
success
();
}
@PostMapping
(
"/sendInlinResourceMail"
)
@ApiOperation
(
value
=
"发送静态图片邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendInlinResourceMail
(
String
to
,
String
subject
,
String
content
,
String
rscPath
,
String
rscId
)
{
logger
.
info
(
"发送静态邮件开始:{},{},{},{},{}"
,
to
,
subject
,
content
,
rscPath
,
rscId
);
MimeMessage
message
=
mailSender
.
createMimeMessage
();
try
{
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
helper
.
setFrom
(
from
);
helper
.
setTo
(
to
);
helper
.
setSubject
(
subject
);
helper
.
setText
(
content
,
true
);
FileSystemResource
res
=
new
FileSystemResource
(
new
File
(
rscPath
));
helper
.
addInline
(
rscId
,
res
);
mailSender
.
send
(
message
);
logger
.
info
(
"发送成功"
);
}
catch
(
MessagingException
e
)
{
logger
.
error
(
"发送失败"
,
e
);
}
return
ResultUtil
.
success
();
}
@PostMapping
(
"/bindEmailAddress"
)
@ApiOperation
(
value
=
"绑定邮箱"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
bindEmailAddress
(
@CurrentUser
UserBean
userBean
,
String
to
)
{
QyzxEmpLogin
.
builder
().
id
(
userBean
.
getEmpNum
()).
email
(
to
).
emailStatus
(
0
).
build
().
updateById
();
return
sendHtmlMail
(
to
,
"8小时账号邮箱验证"
,
"<html>\r\n"
+
"<head>\r\n"
+
"<meta charset=\"UTF-8\">\r\n"
+
"</head>\r\n"
+
"<body>\r\n"
+
" <h1>您好,感谢绑定<a href=\"http://8timer.cn\">8小时人事管家</a>,点击下面链接完成验证,感谢支持!<h1>\r\n"
+
" <br />\r\n"
+
" <a href=\"http://test-8timer-api.youlingrc.com/login/band/"
+
userBean
.
getEmpNum
()+
"\">激活账户</a>\r\n"
+
"</body>\r\n"
+
"</html>"
);
}
@PostMapping
(
"/sendVerifyMail"
)
@ApiOperation
(
value
=
"发送注册验证邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendVerifyMail
(
@CurrentUser
UserBean
userBean
,
String
to
)
{
return
sendHtmlMail
(
to
,
"8小时账号邮箱验证"
,
"<html>\r\n"
+
"<head>\r\n"
+
"<meta charset=\"UTF-8\">\r\n"
+
"</head>\r\n"
+
"<body>\r\n"
+
" <h1>您好,感谢注册<a href=\"http://8timer.cn\">8小时人事管家</a>,点击下面链接完成验证,感谢支持!<h1>\r\n"
+
" <br />\r\n"
+
" <a href=\"https://www.4399.com\">激活账户</a>\r\n"
+
"</body>\r\n"
+
"</html>"
);
}
}
src/main/resources/application-dev.yml
View file @
a3e5e76b
...
...
@@ -86,6 +86,14 @@ spring:
margin
:
2
# Left hand image margin in chars.
invert
:
false
# Whether images should be inverted for dark terminal themes.
mail
:
host
:
smtp.qq.com
username
:
544939826@qq.com
#dsc
password
:
cxvkrjyjzfpbbbce
default-encoding
:
utf-8
######### Spring boot应用健康监控
management
:
server
:
...
...
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