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:fix org_id bug when initProfile #49

Merged
merged 1 commit into from
Oct 12, 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
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