Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:cos route, profile org_id #61

Merged
merged 1 commit into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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