diff --git a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go index 55f23fe0..fe62fe88 100644 --- a/dsSso/Controller/ControllerOauth2/ControllerOauth2.go +++ b/dsSso/Controller/ControllerOauth2/ControllerOauth2.go @@ -52,6 +52,8 @@ func Routers(r *gin.RouterGroup) { r.GET("/checkOpenId", checkOpenId) //绑定用户 r.POST("/bindWxUser", bindWxUser) + //解除绑定 + r.POST("/unBindWxUser", unBindWxUser) return } @@ -705,3 +707,28 @@ func bindWxUser(context *gin.Context) { return } } + +// @Summary 解除绑定微信用户 +// @Description 绑定微信用户 +// @Tags 解除登录验证类 +// @Accept application/x-www-form-urlencoded +// @Produce json +// @Success 200 {string} string +// @Router /oauth2/unBindWxUser [get] +func unBindWxUser(context *gin.Context) { + identityId, _ := context.Cookie("identity_id") + personId, _ := context.Cookie("person_id") + //进行两者之间的解除绑定 + _, err := ServiceLoginPerson.UnBindWxUser(identityId, personId) + if err != nil { + context.JSON(http.StatusOK, Model.Res{ + Code: http.StatusNotImplemented, + Msg: "在执行unBindWxUser函数时出错!", + }) + return + } + context.JSON(http.StatusOK, Model.Res{ + Code: http.StatusOK, + Msg: "解除绑定成功!", + }) +} diff --git a/dsSso/Service/ServiceLoginPerson/ServiceLoginPerson.go b/dsSso/Service/ServiceLoginPerson/ServiceLoginPerson.go index 4c8967ba..3c2a5c84 100644 --- a/dsSso/Service/ServiceLoginPerson/ServiceLoginPerson.go +++ b/dsSso/Service/ServiceLoginPerson/ServiceLoginPerson.go @@ -61,3 +61,8 @@ func BindWxUser(identityId string, personId string, openid string) (bool, error) success, err := DaoSysLoginPerson.BindWxUser(identityId, personId, openid) return success, err } +//解除绑定微信的用户 +func UnBindWxUser(identityId string, personId string) (bool, error) { + success, err := DaoSysLoginPerson.UnBindWxUser(identityId, personId) + return success, err +}