🎨 improvement of comment-related code and database structure
This commit is contained in:
@@ -107,7 +107,7 @@ func (l *GiteeCallbackLogic) GiteeCallback(w http.ResponseWriter, r *http.Reques
|
||||
tx := l.svcCtx.DB.Begin()
|
||||
|
||||
userSocial := l.svcCtx.DB.ScaAuthUserSocial
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(Id), userSocial.Source.Eq(constant.OAuthSourceGitee), userSocial.Deleted.Eq(constant.NotDeleted)).First()
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(Id), userSocial.Source.Eq(constant.OAuthSourceGitee)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
@@ -123,7 +123,6 @@ func (l *GiteeCallbackLogic) GiteeCallback(w http.ResponseWriter, r *http.Reques
|
||||
Nickname: giteeUser.Name,
|
||||
Blog: giteeUser.Blog,
|
||||
Email: giteeUser.Email,
|
||||
Deleted: constant.NotDeleted,
|
||||
Gender: constant.Male,
|
||||
}
|
||||
err = tx.ScaAuthUser.Create(addUser)
|
||||
@@ -154,7 +153,7 @@ func (l *GiteeCallbackLogic) GiteeCallback(w http.ResponseWriter, r *http.Reques
|
||||
} else {
|
||||
authUser := l.svcCtx.DB.ScaAuthUser
|
||||
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID), authUser.Deleted.Eq(constant.NotDeleted)).First()
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
|
@@ -106,7 +106,7 @@ func (l *GithubCallbackLogic) GithubCallback(w http.ResponseWriter, r *http.Requ
|
||||
tx := l.svcCtx.DB.Begin()
|
||||
|
||||
userSocial := l.svcCtx.DB.ScaAuthUserSocial
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(Id), userSocial.Source.Eq(constant.OAuthSourceGithub), userSocial.Deleted.Eq(constant.NotDeleted)).First()
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(Id), userSocial.Source.Eq(constant.OAuthSourceGithub)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
@@ -116,7 +116,6 @@ func (l *GithubCallbackLogic) GithubCallback(w http.ResponseWriter, r *http.Requ
|
||||
uid := idgen.NextId()
|
||||
uidStr := strconv.FormatInt(uid, 10)
|
||||
|
||||
notDeleted := constant.NotDeleted
|
||||
male := constant.Male
|
||||
addUser := &model.ScaAuthUser{
|
||||
UID: uidStr,
|
||||
@@ -125,8 +124,8 @@ func (l *GithubCallbackLogic) GithubCallback(w http.ResponseWriter, r *http.Requ
|
||||
Nickname: gitHubUser.Name,
|
||||
Blog: gitHubUser.Blog,
|
||||
Email: gitHubUser.Email,
|
||||
Deleted: notDeleted,
|
||||
Gender: male,
|
||||
|
||||
Gender: male,
|
||||
}
|
||||
err = tx.ScaAuthUser.Create(addUser)
|
||||
if err != nil {
|
||||
@@ -157,7 +156,7 @@ func (l *GithubCallbackLogic) GithubCallback(w http.ResponseWriter, r *http.Requ
|
||||
} else {
|
||||
authUser := l.svcCtx.DB.ScaAuthUser
|
||||
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID), authUser.Deleted.Eq(constant.NotDeleted)).First()
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
|
@@ -103,7 +103,7 @@ func (l *QqCallbackLogic) QqCallback(w http.ResponseWriter, r *http.Request, req
|
||||
tx := l.svcCtx.DB.Begin()
|
||||
|
||||
userSocial := l.svcCtx.DB.ScaAuthUserSocial
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(authQQme.OpenID), userSocial.Source.Eq(constant.OAuthSourceQQ), userSocial.Deleted.Eq(constant.NotDeleted)).First()
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(authQQme.OpenID), userSocial.Source.Eq(constant.OAuthSourceQQ)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
@@ -113,14 +113,12 @@ func (l *QqCallbackLogic) QqCallback(w http.ResponseWriter, r *http.Request, req
|
||||
uid := idgen.NextId()
|
||||
uidStr := strconv.FormatInt(uid, 10)
|
||||
|
||||
notDeleted := constant.NotDeleted
|
||||
male := constant.Male
|
||||
addUser := &model.ScaAuthUser{
|
||||
UID: uidStr,
|
||||
Avatar: qqUserInfo.FigureurlQq1,
|
||||
Username: authQQme.OpenID,
|
||||
Nickname: qqUserInfo.Nickname,
|
||||
Deleted: notDeleted,
|
||||
Gender: male,
|
||||
}
|
||||
err = tx.ScaAuthUser.Create(addUser)
|
||||
@@ -153,7 +151,7 @@ func (l *QqCallbackLogic) QqCallback(w http.ResponseWriter, r *http.Request, req
|
||||
} else {
|
||||
authUser := l.svcCtx.DB.ScaAuthUser
|
||||
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID), authUser.Deleted.Eq(constant.NotDeleted)).First()
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
|
@@ -117,7 +117,7 @@ func (l *WechatCallbackLogic) HandlerWechatLogin(openId string, clientId string,
|
||||
tx := l.svcCtx.DB.Begin()
|
||||
|
||||
userSocial := l.svcCtx.DB.ScaAuthUserSocial
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(openId), userSocial.Source.Eq(constant.OAuthSourceWechat), userSocial.Deleted.Eq(constant.NotDeleted)).First()
|
||||
socialUser, err := tx.ScaAuthUserSocial.Where(userSocial.OpenID.Eq(openId), userSocial.Source.Eq(constant.OAuthSourceWechat)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
return err
|
||||
}
|
||||
@@ -129,14 +129,12 @@ func (l *WechatCallbackLogic) HandlerWechatLogin(openId string, clientId string,
|
||||
avatar := utils.GenerateAvatar(uidStr)
|
||||
name := randomname.GenerateName()
|
||||
|
||||
notDeleted := constant.NotDeleted
|
||||
male := constant.Male
|
||||
addUser := &model.ScaAuthUser{
|
||||
UID: uidStr,
|
||||
Avatar: avatar,
|
||||
Username: openId,
|
||||
Nickname: name,
|
||||
Deleted: notDeleted,
|
||||
Gender: male,
|
||||
}
|
||||
err = tx.ScaAuthUser.Create(addUser)
|
||||
@@ -181,7 +179,7 @@ func (l *WechatCallbackLogic) HandlerWechatLogin(openId string, clientId string,
|
||||
} else {
|
||||
authUser := l.svcCtx.DB.ScaAuthUser
|
||||
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID), authUser.Deleted.Eq(constant.NotDeleted)).First()
|
||||
authUserInfo, err := tx.ScaAuthUser.Where(authUser.UID.Eq(socialUser.UserID)).First()
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
_ = tx.Rollback()
|
||||
return err
|
||||
|
Reference in New Issue
Block a user