Skip to content

Commit c6c7fc4

Browse files
authored
fix_content (#150)
Co-authored-by: eryajf <[email protected]>
1 parent 4bde323 commit c6c7fc4

File tree

5 files changed

+35
-17
lines changed

5 files changed

+35
-17
lines changed

README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
- [🔗 文档快链](#-%E6%96%87%E6%A1%A3%E5%BF%AB%E9%93%BE)
3232
- [🥰 感谢](#-%E6%84%9F%E8%B0%A2)
3333
- [🤗 另外](#-%E5%8F%A6%E5%A4%96)
34-
- [⚡ 加群](#-%E5%8A%A0%E7%BE%A4)
3534
- [🤑 捐赠](#-%E6%8D%90%E8%B5%A0)
3635
- [📝 使用登记](#-%E4%BD%BF%E7%94%A8%E7%99%BB%E8%AE%B0)
3736
- [💎 优秀软件推荐](#-%E4%BC%98%E7%A7%80%E8%BD%AF%E4%BB%B6%E6%8E%A8%E8%8D%90)
@@ -96,12 +95,6 @@
9695

9796
- 如果觉得项目不错,麻烦动动小手点个⭐️star⭐️!
9897
- 如果你还有其他想法或者需求,欢迎在issue中交流!
99-
- 程序还有很多bug,欢迎各位朋友一起协同共建!
100-
101-
102-
## ⚡ 加群
103-
104-
如果想要加群交流,可通过搜索 cWN3ZDg4NDgK (base64)添加我的微信,备注 ldap 拉你进群。
10598

10699
## 🤑 捐赠
107100

controller/base_controller.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,18 @@ func (m *BaseController) Dashboard(c *gin.Context) {
2525
})
2626
}
2727

28-
// GetPasswd 生成加密密码
29-
func (m *BaseController) GetPasswd(c *gin.Context) {
30-
req := new(request.GetPasswdReq)
28+
// EncryptPasswd 生成加密密码
29+
func (m *BaseController) EncryptPasswd(c *gin.Context) {
30+
req := new(request.EncryptPasswdReq)
3131
Run(c, req, func() (interface{}, interface{}) {
32-
return logic.Base.GetPasswd(c, req)
32+
return logic.Base.EncryptPasswd(c, req)
33+
})
34+
}
35+
36+
// DecryptPasswd 密码解密为明文
37+
func (m *BaseController) DecryptPasswd(c *gin.Context) {
38+
req := new(request.DecryptPasswdReq)
39+
Run(c, req, func() (interface{}, interface{}) {
40+
return logic.Base.DecryptPasswd(c, req)
3341
})
3442
}

logic/base_logic.go

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,24 @@ func (l BaseLogic) Dashboard(c *gin.Context, req interface{}) (data interface{},
136136
return rst, nil
137137
}
138138

139-
// GetPasswd
140-
func (l BaseLogic) GetPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
141-
r, ok := req.(*request.GetPasswdReq)
139+
// EncryptPasswd
140+
func (l BaseLogic) EncryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
141+
r, ok := req.(*request.EncryptPasswdReq)
142142
if !ok {
143143
return nil, ReqAssertErr
144144
}
145145
_ = c
146146

147147
return tools.NewGenPasswd(r.Passwd), nil
148148
}
149+
150+
// DecryptPasswd
151+
func (l BaseLogic) DecryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
152+
r, ok := req.(*request.DecryptPasswdReq)
153+
if !ok {
154+
return nil, ReqAssertErr
155+
}
156+
_ = c
157+
158+
return tools.NewParPasswd(r.Passwd), nil
159+
}

model/request/base_req.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ type BaseChangePwdReq struct {
99
type BaseDashboardReq struct {
1010
}
1111

12-
// GetPasswdReq
13-
type GetPasswdReq struct {
12+
// EncryptPasswdReq
13+
type EncryptPasswdReq struct {
14+
Passwd string `json:"passwd" form:"passwd" validate:"required"`
15+
}
16+
17+
// DecryptPasswdReq
18+
type DecryptPasswdReq struct {
1419
Passwd string `json:"passwd" form:"passwd" validate:"required"`
1520
}

routes/base_routes.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ func InitBaseRoutes(r *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) gi
1212
base := r.Group("/base")
1313
{
1414
base.GET("ping", controller.Demo)
15-
base.GET("getpasswd", controller.Base.GetPasswd) // 将明文字符串转为MySQL识别的密码
15+
base.GET("encryptpwd", controller.Base.EncryptPasswd) // 生成加密密码
16+
base.GET("decryptpwd", controller.Base.DecryptPasswd) // 密码解密为明文
1617
// 登录登出刷新token无需鉴权
1718
base.POST("/login", authMiddleware.LoginHandler)
1819
base.POST("/logout", authMiddleware.LogoutHandler)

0 commit comments

Comments
 (0)