Skip to content

Commit

Permalink
Merge pull request #61 from NJUPT-SAST/dev-windpo
Browse files Browse the repository at this point in the history
fix:cos route, profile org_id
  • Loading branch information
windpo authored Nov 3, 2023
2 parents df1711f + 82ec8b6 commit 8a85e41
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion model/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func SelectProfileByUid(uid string) (*Profile, error) {

func UpdateProfile(oldProfile, newProfile *Profile) error {
newProfile.ID = oldProfile.ID
if err := Db.Table("profile").Model(&Profile{}).Where("profile.id = ?", oldProfile.ID).Updates(newProfile).Error; err != nil {
if err := Db.Debug().Table("profile").Model(&Profile{}).Where("profile.id = ?", oldProfile.ID).Updates(newProfile).Error; err != nil {
profileLogger.Errorln("updateProfile Err", err)
return err
}
Expand Down
8 changes: 4 additions & 4 deletions service/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const picSensitiveMsg = `{

func ChangeProfile(profile *model.Profile, uid string) error {
// check org_id
if profile.OrgId > 26 || profile.OrgId < 1 {
if profile.OrgId > 26 || profile.OrgId < -1 {
serviceLogger.Infof("org_id input Err")
return result.OrgIdError
}
Expand Down Expand Up @@ -143,7 +143,7 @@ func GetProfileOrg(OrgId int) (string, string, error) {
if OrgId > 26 {
serviceLogger.Errorln("org_id input Err,ErrMsg:")
return "", "", result.OrgIdError
} else if OrgId == 0 {
} else if OrgId == -1 || OrgId == 0 {
return "", "", nil
} else {
//get dep and org
Expand Down Expand Up @@ -181,7 +181,7 @@ func UploadAvatar(avatar *multipart.FileHeader, uid string, ctx *gin.Context) (s
}

//write to database, file url refer:tencent cos bucket file
if dBUpErr := model.UpdateAvatar("https://sast-link-1309205610.cos.ap-shanghai.myqcloud.com"+uploadKey, userInfo.ID); dBUpErr != nil {
if dBUpErr := model.UpdateAvatar("https://sast-link-1309205610.cos.ap-shanghai.myqcloud.com/"+uploadKey, userInfo.ID); dBUpErr != nil {
//del cos file
if _, cosDelErr := cos.Object.Delete(ctx, uploadKey); cosDelErr != nil {
serviceLogger.Errorln("upload avatar to cos fail,ErrMsg:", cosDelErr)
Expand All @@ -192,7 +192,7 @@ func UploadAvatar(avatar *multipart.FileHeader, uid string, ctx *gin.Context) (s
return "", dBUpErr
}

return "https://sast-link-1309205610.cos.ap-shanghai.myqcloud.com" + uploadKey, nil
return "https://sast-link-1309205610.cos.ap-shanghai.myqcloud.com/" + uploadKey, nil
}

func checkHideLegal(hide []string) error {
Expand Down
1 change: 1 addition & 0 deletions service/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func CreateUserAndProfile(email string, password string) error {
}, &model.Profile{
Nickname: &uid,
Email: &email,
OrgId: -1,
})

if err != nil {
Expand Down

0 comments on commit 8a85e41

Please sign in to comment.