Skip to content
This repository has been archived by the owner on Nov 29, 2020. It is now read-only.

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
mohuishou committed Aug 30, 2018
1 parent b15fa65 commit 21af9ae
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
8 changes: 8 additions & 0 deletions api/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func Login(ctx iris.Context) {
})
}

// Remove 注销账号,所有数据会被移除
func Remove(ctx iris.Context) {
uid := middleware.GetUserID(ctx)
// 移除
model.RemoveAll(uid)
Success(ctx, "数据清除成功!如需继续使用,请退出小程序之后重新登录,再会", nil)
}

// BindJwc 教务处绑定
func BindJwc(ctx iris.Context) {
studentID := ctx.FormValue("student_id")
Expand Down
13 changes: 13 additions & 0 deletions model/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,19 @@ func GetLibrary(userID uint) (*library.Library, error) {
return library.NewLibrary(userLib.StudentID, userLib.Password)
}

func RemoveAll(uid uint) {
AfterUpdateBindJwc(uid)
AfterUpdateBindLibrary(uid)
AfterUpdateBindMy(uid)
// 用户相关
del := DB().Unscoped().Where("user_id = ?", uid).Delete
del(UserLibrary{})
del(UserConfig{})
del(UserInfo{})
del(Wechat{})
DB().Unscoped().Where("id = ?", uid).Delete(User{})
}

func AfterUpdateBindJwc(uid uint) {
del := DB().Unscoped().Where("user_id = ?", uid).Delete
// 清空成绩表
Expand Down
1 change: 1 addition & 0 deletions route/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

// Routes 路由
func Routes(app *iris.Application) {
app.Post("/goodbye", api.Remove)
app.Get("/notices", api.GetNotices)
app.Get("/notice/{id}", api.GetNotice)
app.Get("/notice/new", api.GetNewestNotice)
Expand Down

0 comments on commit 21af9ae

Please sign in to comment.