Skip to content

Commit

Permalink
fix:fix org_id bug when initProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
windpo committed Oct 12, 2023
1 parent 7c6e93f commit c17a7c5
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 c17a7c5

Please sign in to comment.