添加第三方登录信息查询与删除
This commit is contained in:
parent
13e115f2e0
commit
5aa47993c0
|
|
@ -258,3 +258,11 @@ func DeleteThirdPartyUserInfoByID(id int) int {
|
|||
}
|
||||
return id
|
||||
}
|
||||
|
||||
func DeleteThirdPartyLoginByID(id int, userID int) error {
|
||||
res := DB.Where("id = ? and user_id = ?", id, userID).Delete(&ThirdPartyUserInfo{})
|
||||
if res.Error != nil {
|
||||
return res.Error
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ func SetUpUserGroup(router *gin.Engine) {
|
|||
userGroup.GET("/oAuth", LoginOAuth) //第三方登录
|
||||
userGroup.GET("/oAuth_uuid", GetOAuthUUID)
|
||||
userGroup.POST("/statistic", GetUserStatistic)
|
||||
userGroup.POST("/third_party_login_list", GetThirdPartyLoginList) //获取绑定的第三方登录账号
|
||||
userGroup.DELETE("/delete_third_party_login", DeleteThirdPartyLogin) //删除绑定的第三方登录账号
|
||||
}
|
||||
|
||||
type RLReq struct {
|
||||
|
|
@ -586,3 +588,37 @@ func GetOAuthUUID(c *gin.Context) {
|
|||
resp.Data = uuid
|
||||
c.JSON(200, resp)
|
||||
}
|
||||
|
||||
func GetThirdPartyLoginList(c *gin.Context) {
|
||||
var resp proto.GenerateResp
|
||||
//获取用户信息
|
||||
id, _ := c.Get("id")
|
||||
userId := int(id.(float64))
|
||||
thirdPartyLoginList := dao.FindThirdPartyUserInfoByUserID(userId)
|
||||
resp.Code = proto.SuccessCode
|
||||
resp.Message = "success"
|
||||
resp.Data = thirdPartyLoginList
|
||||
c.JSON(200, resp)
|
||||
}
|
||||
|
||||
func DeleteThirdPartyLogin(c *gin.Context) {
|
||||
var resp proto.GenerateResp
|
||||
//获取用户信息
|
||||
id, _ := c.Get("id")
|
||||
userId := int(id.(float64))
|
||||
var req proto.DeleteThirdPartyLoginReq
|
||||
if err := c.ShouldBind(&req); err == nil {
|
||||
err2 := dao.DeleteThirdPartyLoginByID(req.ID, userId)
|
||||
if err2 != nil {
|
||||
resp.Code = proto.OperationFailed
|
||||
resp.Message = "删除失败!请检查是否属于或者已被删除"
|
||||
} else {
|
||||
resp.Code = proto.SuccessCode
|
||||
resp.Message = "success"
|
||||
}
|
||||
} else {
|
||||
resp.Code = proto.ParameterError
|
||||
resp.Message = "error"
|
||||
}
|
||||
c.JSON(200, resp)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,3 +118,7 @@ type ResponseOAuth struct {
|
|||
Email string `json:"email" form:"email"`
|
||||
Token string `json:"token" form:"token"`
|
||||
}
|
||||
|
||||
type DeleteThirdPartyLoginReq struct {
|
||||
ID int `json:"id" form:"id"` //用户第三方登录信息表ID
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue