Skip to content

Commit

Permalink
fix_content (#150)
Browse files Browse the repository at this point in the history
Co-authored-by: eryajf <[email protected]>
  • Loading branch information
eryajf and eryajf authored Feb 14, 2023
1 parent 4bde323 commit c6c7fc4
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 17 deletions.
7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
- [🔗 文档快链](#-%E6%96%87%E6%A1%A3%E5%BF%AB%E9%93%BE)
- [🥰 感谢](#-%E6%84%9F%E8%B0%A2)
- [🤗 另外](#-%E5%8F%A6%E5%A4%96)
- [⚡ 加群](#-%E5%8A%A0%E7%BE%A4)
- [🤑 捐赠](#-%E6%8D%90%E8%B5%A0)
- [📝 使用登记](#-%E4%BD%BF%E7%94%A8%E7%99%BB%E8%AE%B0)
- [💎 优秀软件推荐](#-%E4%BC%98%E7%A7%80%E8%BD%AF%E4%BB%B6%E6%8E%A8%E8%8D%90)
Expand Down Expand Up @@ -96,12 +95,6 @@

- 如果觉得项目不错,麻烦动动小手点个⭐️star⭐️!
- 如果你还有其他想法或者需求,欢迎在issue中交流!
- 程序还有很多bug,欢迎各位朋友一起协同共建!


## ⚡ 加群

如果想要加群交流,可通过搜索 cWN3ZDg4NDgK (base64)添加我的微信,备注 ldap 拉你进群。

## 🤑 捐赠

Expand Down
16 changes: 12 additions & 4 deletions controller/base_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ func (m *BaseController) Dashboard(c *gin.Context) {
})
}

// GetPasswd 生成加密密码
func (m *BaseController) GetPasswd(c *gin.Context) {
req := new(request.GetPasswdReq)
// EncryptPasswd 生成加密密码
func (m *BaseController) EncryptPasswd(c *gin.Context) {
req := new(request.EncryptPasswdReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Base.GetPasswd(c, req)
return logic.Base.EncryptPasswd(c, req)
})
}

// DecryptPasswd 密码解密为明文
func (m *BaseController) DecryptPasswd(c *gin.Context) {
req := new(request.DecryptPasswdReq)
Run(c, req, func() (interface{}, interface{}) {
return logic.Base.DecryptPasswd(c, req)
})
}
17 changes: 14 additions & 3 deletions logic/base_logic.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,24 @@ func (l BaseLogic) Dashboard(c *gin.Context, req interface{}) (data interface{},
return rst, nil
}

// GetPasswd
func (l BaseLogic) GetPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
r, ok := req.(*request.GetPasswdReq)
// EncryptPasswd
func (l BaseLogic) EncryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
r, ok := req.(*request.EncryptPasswdReq)
if !ok {
return nil, ReqAssertErr
}
_ = c

return tools.NewGenPasswd(r.Passwd), nil
}

// DecryptPasswd
func (l BaseLogic) DecryptPasswd(c *gin.Context, req interface{}) (data interface{}, rspError interface{}) {
r, ok := req.(*request.DecryptPasswdReq)
if !ok {
return nil, ReqAssertErr
}
_ = c

return tools.NewParPasswd(r.Passwd), nil
}
9 changes: 7 additions & 2 deletions model/request/base_req.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ type BaseChangePwdReq struct {
type BaseDashboardReq struct {
}

// GetPasswdReq
type GetPasswdReq struct {
// EncryptPasswdReq
type EncryptPasswdReq struct {
Passwd string `json:"passwd" form:"passwd" validate:"required"`
}

// DecryptPasswdReq
type DecryptPasswdReq struct {
Passwd string `json:"passwd" form:"passwd" validate:"required"`
}
3 changes: 2 additions & 1 deletion routes/base_routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ func InitBaseRoutes(r *gin.RouterGroup, authMiddleware *jwt.GinJWTMiddleware) gi
base := r.Group("/base")
{
base.GET("ping", controller.Demo)
base.GET("getpasswd", controller.Base.GetPasswd) // 将明文字符串转为MySQL识别的密码
base.GET("encryptpwd", controller.Base.EncryptPasswd) // 生成加密密码
base.GET("decryptpwd", controller.Base.DecryptPasswd) // 密码解密为明文
// 登录登出刷新token无需鉴权
base.POST("/login", authMiddleware.LoginHandler)
base.POST("/logout", authMiddleware.LogoutHandler)
Expand Down

0 comments on commit c6c7fc4

Please sign in to comment.