Skip to content

Commit

Permalink
✨重构代码
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakura-LF committed Oct 14, 2024
1 parent 51239c5 commit 88bd6bd
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 69 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@ go.work.sum
.env

logs/
.idea/
.idea/

configs/config.yaml
2 changes: 1 addition & 1 deletion common/message/sendEmailCode.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var htmlContent = `
</div>
</body>
</html>
`
`

func NewEmailClient() (gomail.SendCloser, error) {
// 读取配置
Expand Down
1 change: 1 addition & 0 deletions configs/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,4 @@ email:
port: 465
userName: 1808479176@qq.com
password: kvkqbbpbqrgbeeic
jwt:
56 changes: 0 additions & 56 deletions configs/localConfig.yaml
Original file line number Diff line number Diff line change
@@ -1,56 +0,0 @@
server:
http:
addr: 0.0.0.0:8080
timeout: 1s
# grpc:
# addr: 0.0.0.0:20012
# timeout: 1s
data:
database:
driver: mysql
source: root:mysql_TcKPjC@tcp(192.168.233.128:3306)/ai_server?parseTime=True&loc=Local
reconnection_num: 10
reconnection_time: 5s
redis:
addr: 192.168.233.128:6379
username: default
password: redis_jFFiD3
read_timeout: 0.2s
write_timeout: 0.2s
# 日志配置
log:
ZeroLogConfig:
Level: debug
# development or production
Pattern: development
OutPut: logs
# 日志轮换(分割配置)
LogRotate:
Filename: service.log
MaxSize: 1
MaxBackups: 3
MaxAge: 7
Compress: true
siteInfo:
site:
title: "Sakuras的AI小站"
enTitle: "Sakuras's AI Site"
logo: "logo"
slogan: "智能AI"
abstract: "智能AI"
beian: "1234"
project:
title: "Sakuras的AI小站"
icon: "icon"
webPath: "/"
seo:
keywords: "1"
description: "2"
register:
isEmailRegister: true
isWxLoginRegister: true
isSmsRegister: true
login:
isUserNameLogin: true
isEmailLogin: true
isTelLogin: true
19 changes: 8 additions & 11 deletions internal/api/userApi/register.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func (userApi *UserApi) Register(c fiber.Ctx) error {
if err := c.Bind().Body(&req); err != nil {
return res.FailWithMsgAndReason(c, err.Error(), "请求参数错误")
}
// 打印请求参数
// 根据 RegisterType 校验 邮箱/电话
switch req.RegisterType {
case modeles.EmailRegister:
Expand All @@ -54,16 +53,14 @@ func (userApi *UserApi) Register(c fiber.Ctx) error {
if !ok {
return res.FailWithMsg(c, "图形验证码错误")
}
if req.RegisterType == modeles.EmailRegister {
// 发邮件
go func() {
err := message.SendCode(modeles.EmailRegister, req.Value)
if err != nil {
return
}
}()
return res.OkWithMsg(c, "发送验证码成功,请注意查收")
}
// 根据注册类型发送验证码
go func() {
err := message.SendCode(modeles.EmailRegister, req.Value)
if err != nil {
return
}
}()
return res.OkWithMsg(c, "发送验证码成功,请注意查收")
case 2:
if req.Code == "" {
return res.FailWithMsg(c, "验证码不能为空")
Expand Down

0 comments on commit 88bd6bd

Please sign in to comment.