Feat: add logout bilibili

pull/31/head
zijiren233 2 years ago
parent 2047e676af
commit ff34f8209c

@ -63,3 +63,7 @@ func AssignFirstOrCreateVendorByUserIDAndVendor(userID string, vendor model.Stre
).FirstOrCreate(&vendorInfo).Error
return &vendorInfo, err
}
func DeleteVendorByUserIDAndVendor(userID string, vendor model.StreamingVendor) error {
return db.Where("user_id = ? AND vendor = ?", userID, vendor).Delete(&model.StreamingVendorInfo{}).Error
}

@ -164,6 +164,8 @@ func Init(e *gin.Engine) {
bilibili.POST("/parse", Vbilibili.Parse)
bilibili.GET("/me", Vbilibili.Me)
bilibili.POST("/logout", Vbilibili.Logout)
}
}
}

@ -172,3 +172,13 @@ func LoginWithSMS(ctx *gin.Context) {
}
ctx.Status(http.StatusNoContent)
}
func Logout(ctx *gin.Context) {
user := ctx.MustGet("user").(*op.User)
err := db.DeleteVendorByUserIDAndVendor(user.ID, dbModel.StreamingVendorBilibili)
if err != nil {
ctx.AbortWithStatusJSON(http.StatusInternalServerError, model.NewApiErrorResp(err))
return
}
ctx.Status(http.StatusNoContent)
}

Loading…
Cancel
Save