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
1ab8b8ae
Commit
1ab8b8ae
authored
May 26, 2020
by
邓实川
Committed by
chenzg
Jul 05, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
邮箱数据保存,企业邮箱账号设置
parent
12a68dfc
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
132 additions
and
37 deletions
+132
-37
src/main/java/cn/timer/api/bean/email/SendMessage.java
+67
-0
src/main/java/cn/timer/api/controller/LoginController.java
+16
-3
src/main/java/cn/timer/api/controller/email/EmailController.java
+28
-23
src/main/java/cn/timer/api/dao/email/SendMessageMapper.java
+12
-0
src/main/resources/application-dev.yml
+3
-5
src/main/resources/application-pro.yml
+3
-3
src/main/resources/application-test.yml
+3
-3
No files found.
src/main/java/cn/timer/api/bean/email/SendMessage.java
0 → 100644
View file @
1ab8b8ae
/**
* <p>Title: SendMessage.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月26日
* @version 1.0
*/
package
cn
.
timer
.
api
.
bean
.
email
;
import
java.util.Date
;
import
javax.persistence.Entity
;
import
javax.persistence.GeneratedValue
;
import
javax.persistence.Id
;
import
javax.persistence.Table
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.extension.activerecord.Model
;
import
io.swagger.annotations.ApiModel
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
/**
* <p>Title: SendMessage.java</p>
* <p>Description: </p>
* @author dsc
* @date 2020年5月26日
* @version 1.0
*/
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table
(
name
=
"send_message"
)
@ApiModel
(
"企业邮箱信息表"
)
public
class
SendMessage
extends
Model
<
SendMessage
>{
private
static
final
long
serialVersionUID
=
-
1599962875587367209L
;
@Id
@GeneratedValue
@TableId
(
type
=
IdType
.
AUTO
)
@ApiModelProperty
(
value
=
"编号"
)
private
Integer
id
;
@ApiModelProperty
(
value
=
"创建id"
)
private
Integer
createdUser
;
@ApiModelProperty
(
value
=
"创建时间"
)
private
Date
createdTime
;
@ApiModelProperty
(
value
=
"邮件主题"
)
private
String
subject
;
@ApiModelProperty
(
value
=
"邮件内容"
)
private
String
content
;
@ApiModelProperty
(
value
=
"收件人邮箱"
)
private
String
receiverEmail
;
}
src/main/java/cn/timer/api/controller/LoginController.java
View file @
1ab8b8ae
...
...
@@ -642,11 +642,24 @@ public class LoginController {
}
/**
* 绑定邮箱
*
* @param empNum
* @return
*/
@GetMapping
(
value
=
"/band/{empNum}"
)
public
Result
<
Object
>
bandEmail
(
@PathVariable
Integer
empNum
)
{
if
(
QyzxEmpLogin
.
builder
().
id
(
empNum
).
emailStatus
(
1
).
build
().
updateById
())
{
return
ResultUtil
.
success
(
"绑定成功"
);
}
QyzxEmpLogin
qyzxEmpLogin
=
QyzxEmpLogin
.
builder
().
id
(
empNum
).
build
().
selectById
();
if
(
qyzxEmpLogin
==
null
)
return
ResultUtil
.
error
(
"员工不存在"
);
Integer
emailStatus
=
qyzxEmpLogin
.
getEmailStatus
();
if
(
emailStatus
!=
0
&&
emailStatus
!=
1
)
return
ResultUtil
.
error
(
"请确认邮箱绑定状态"
);
if
(
emailStatus
==
1
)
return
ResultUtil
.
error
(
"邮箱已绑定,请勿重复绑定"
);
if
(
QyzxEmpLogin
.
builder
().
id
(
empNum
).
emailStatus
(
1
).
build
().
updateById
())
return
ResultUtil
.
error
(
"绑定成功"
);
return
ResultUtil
.
error
(
"绑定失败"
);
}
...
...
src/main/java/cn/timer/api/controller/email/EmailController.java
View file @
1ab8b8ae
...
...
@@ -8,6 +8,7 @@
package
cn
.
timer
.
api
.
controller
.
email
;
import
java.io.File
;
import
java.util.Date
;
import
javax.mail.MessagingException
;
import
javax.mail.internet.MimeMessage
;
...
...
@@ -25,6 +26,7 @@ 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.email.SendMessage
;
import
cn.timer.api.bean.qyzx.QyzxEmpLogin
;
import
cn.timer.api.config.annotation.CurrentUser
;
import
cn.timer.api.config.annotation.UserBean
;
...
...
@@ -72,7 +74,7 @@ public class EmailController {
@PostMapping
(
"/sendHtmlMail"
)
@ApiOperation
(
value
=
"发送html邮件"
,
httpMethod
=
"POST"
,
notes
=
"接口发布说明"
)
public
Result
<
Void
>
sendHtmlMail
(
String
to
,
String
subject
,
String
content
)
{
public
Result
<
Void
>
sendHtmlMail
(
@CurrentUser
UserBean
userBean
,
String
to
,
String
subject
,
String
content
)
{
MimeMessage
message
=
mailSender
.
createMimeMessage
();
try
{
MimeMessageHelper
helper
=
new
MimeMessageHelper
(
message
,
true
);
...
...
@@ -81,10 +83,14 @@ public class EmailController {
helper
.
setSubject
(
subject
);
helper
.
setText
(
content
,
true
);
mailSender
.
send
(
message
);
}
catch
(
MessagingException
e
)
{
e
.
printStackTrace
();
}
return
ResultUtil
.
success
();
if
(
SendMessage
.
builder
().
content
(
content
).
createdTime
(
new
Date
()).
createdUser
(
userBean
.
getEmpNum
())
.
receiverEmail
(
to
).
subject
(
subject
).
build
().
insert
())
return
ResultUtil
.
success
(
"邮件发送成功"
);
return
ResultUtil
.
error
(
"邮件发送失败"
);
}
@PostMapping
(
"/sendAttchmentMail"
)
...
...
@@ -128,35 +134,34 @@ public class EmailController {
return
ResultUtil
.
success
();
}
@Transactional
@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>"
);
Integer
empNum
=
userBean
.
getEmpNum
();
QyzxEmpLogin
qyzxEmpLogin
=
QyzxEmpLogin
.
builder
().
id
(
empNum
).
build
().
selectById
();
if
(
qyzxEmpLogin
==
null
)
return
ResultUtil
.
error
(
"请确认员工状态"
);
if
(
qyzxEmpLogin
.
getEmail
()
!=
null
&&
qyzxEmpLogin
.
getEmailStatus
()
!=
null
&&
qyzxEmpLogin
.
getEmailStatus
()
==
1
)
return
ResultUtil
.
error
(
"该账号已绑定过邮箱"
);
qyzxEmpLogin
.
setEmail
(
to
);
qyzxEmpLogin
.
setEmailStatus
(
0
);
qyzxEmpLogin
.
updateById
();
return
sendHtmlMail
(
userBean
,
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/"
+
empNum
+
"\">激活账户</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>"
);
return
sendHtmlMail
(
userBean
,
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/java/cn/timer/api/dao/email/SendMessageMapper.java
0 → 100644
View file @
1ab8b8ae
package
cn
.
timer
.
api
.
dao
.
email
;
import
org.springframework.stereotype.Repository
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
cn.timer.api.bean.email.SendMessage
;
@Repository
public
interface
SendMessageMapper
extends
BaseMapper
<
SendMessage
>
{
}
src/main/resources/application-dev.yml
View file @
1ab8b8ae
...
...
@@ -87,13 +87,11 @@ spring:
invert
:
false
# Whether images should be inverted for dark terminal themes.
mail
:
host
:
smtp.
qq
.com
username
:
544939826@qq.com
#dsc
password
:
cxvkrjyjzfpbbbce
host
:
smtp.
youlingrc
.com
username
:
postmaster@youlingrc.com
password
:
YoulingRC2020
default-encoding
:
utf-8
######### Spring boot应用健康监控
management
:
server
:
...
...
src/main/resources/application-pro.yml
View file @
1ab8b8ae
...
...
@@ -86,9 +86,9 @@ 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
:
password
:
host
:
smtp.
youlingrc
.com
username
:
postmaster@youlingrc.com
password
:
YoulingRC2020
default-encoding
:
utf-8
# mybatis-plus
...
...
src/main/resources/application-test.yml
View file @
1ab8b8ae
...
...
@@ -86,9 +86,9 @@ 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
password
:
cxvkrjyjzfpbbbce
host
:
smtp.
youlingrc
.com
username
:
postmaster@youlingrc
.com
password
:
YoulingRC2020
default-encoding
:
utf-8
# mybatis-plus
...
...
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