Skip to content

Commit

Permalink
Merge pull request #49 from NJUPT-SAST/dev-windpo
Browse files Browse the repository at this point in the history
fix:org_id bug when initProfile
  • Loading branch information
windpo authored Oct 12, 2023
2 parents f7d0b8f + 3e6c8d6 commit 073c4cd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
1 change: 0 additions & 1 deletion api/v1/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ func GetProfile(ctx *gin.Context) {
ctx.JSON(http.StatusOK, result.Failed(result.HandleError(serErr)))
return
}

if dep, org, getOrgErr := service.GetProfileOrg(profileInfo.OrgId); getOrgErr != nil {
controllerLogger.Errorln("GetProfileOrg Err", getOrgErr)
ctx.JSON(http.StatusOK, result.Failed(result.HandleError(getOrgErr)))
Expand Down
18 changes: 10 additions & 8 deletions service/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var cos = util.T_cos

func ChangeProfile(profile *model.Profile, uid string) error {
// check org_id
if profile.OrgId > 26 {
if profile.OrgId > 26 || profile.OrgId < 1 {
serviceLogger.Infof("org_id input Err")
return result.OrgIdError
}
Expand Down Expand Up @@ -80,14 +80,16 @@ func GetProfileOrg(OrgId int) (string, string, error) {
if OrgId > 26 {
serviceLogger.Errorln("org_id input Err")
return "", "", result.OrgIdError
}

//get dep and org
if dep, org, err := model.GetDepAndOrgByOrgId(OrgId); err != nil {
serviceLogger.Errorln("GetDepAndOrgByOrgId Err", err)
return "", "", err
} else if OrgId == 0 {
return "", "", nil
} else {
return dep, org, nil
//get dep and org
if dep, org, err := model.GetDepAndOrgByOrgId(OrgId); err != nil {
serviceLogger.Errorln("GetDepAndOrgByOrgId Err", err)
return "", "", err
} else {
return dep, org, nil
}
}
}

Expand Down

0 comments on commit 073c4cd

Please sign in to comment.