当前位置: 首页>>代码示例>>Golang>>正文


Golang Team.Has方法代码示例

本文整理汇总了Golang中github.com/containerops/wharf/models.Team.Has方法的典型用法代码示例。如果您正苦于以下问题:Golang Team.Has方法的具体用法?Golang Team.Has怎么用?Golang Team.Has使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在github.com/containerops/wharf/models.Team的用法示例。


在下文中一共展示了Team.Has方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。

示例1: GetTeam

func (this *OrganizationWebV1Controller) GetTeam() {
	user := new(models.User)
	org := new(models.Organization)
	team := new(models.Team)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	if exist, _, err := team.Has(this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team")); err != nil {
		this.JSONOut(http.StatusBadRequest, "Search team error", nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Team not exist", nil)
		return
	}

	this.JSONOut(http.StatusOK, "", team)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:32,代码来源:orgwebv1.go

示例2: GetTeams

func (this *OrganizationWebV1Controller) GetTeams() {
	user := new(models.User)
	teams := make([]models.Team, 0)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	for _, name := range user.Teams {
		team := new(models.Team)
		if exist, _, err := team.Has(strings.Split(name, "-")[0], strings.Split(name, "-")[1]); err != nil {
			this.JSONOut(http.StatusBadRequest, "Get Team error", nil)
			return
		} else if exist == false {
			this.JSONOut(http.StatusBadRequest, "Team invalid", nil)
			return
		}

		teams = append(teams, *team)
	}

	this.JSONOut(http.StatusOK, "", teams)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:28,代码来源:orgwebv1.go

示例3: GetOrgTeams

func (this *OrganizationWebV1Controller) GetOrgTeams() {
	org := new(models.Organization)
	teams := make([]models.Team, 0)

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	for _, v := range org.Teams {
		team := new(models.Team)

		if exist, _, err := team.Has(strings.Split(v, "-")[0], strings.Split(v, "-")[1]); err != nil {
			this.JSONOut(http.StatusBadRequest, "Team invalid", nil)
			return
		} else if exist == false {
			this.JSONOut(http.StatusBadRequest, "Team invalid", nil)
			return
		}

		teams = append(teams, *team)
	}

	this.JSONOut(http.StatusOK, "", teams)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:29,代码来源:orgwebv1.go

示例4: PutTeam

func (this *OrganizationWebV1Controller) PutTeam() {
	user := new(models.User)
	org := new(models.Organization)
	team := new(models.Team)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	if exist, _, err := team.Has(this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team")); err != nil {
		this.JSONOut(http.StatusBadRequest, "Search team error", nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Team not exist", nil)
		return
	}

	if err := json.Unmarshal(this.Ctx.Input.CopyBody(), &team); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	}

	team.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := team.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "Team save error", nil)
		return
	}

	this.JSONOut(http.StatusOK, "Team update successfully", nil)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:44,代码来源:orgwebv1.go

示例5: PutMember

func (this *OrganizationWebV1Controller) PutMember() {
	user := new(models.User)
	org := new(models.Organization)
	team := new(models.Team)
	member := new(models.User)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	if exist, _, err := team.Has(this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team")); err != nil {
		this.JSONOut(http.StatusBadRequest, "Search team error", nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Team not exist", nil)
		return
	}

	if exist, _, err := user.Has(this.Ctx.Input.Param(":member")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	for i, v := range team.Users {
		if v == member.Username {
			team.Users = append(team.Users[:i], team.Users[i+1:]...)
			team.Updated = time.Now().UnixNano() / int64(time.Millisecond)

			if err := team.Save(); err != nil {
				this.JSONOut(http.StatusBadRequest, "Team save error", nil)
				return
			}
		}
	}

	for i, v := range user.JoinTeams {
		if v == team.Id {
			user.JoinTeams = append(user.JoinTeams[:i], user.JoinTeams[i+1:]...)
			user.Updated = time.Now().UnixNano() / int64(time.Millisecond)

			if err := user.Save(); err != nil {
				this.JSONOut(http.StatusBadRequest, "User save error", nil)
				return
			}
		}
	}

	for _, v := range org.Teams {
		t := new(models.Team)

		if exist, _, err := team.Has(strings.Split(v, "-")[0], strings.Split(v, "-")[1]); err != nil {
			this.JSONOut(http.StatusBadRequest, "Search team error", nil)
			return
		} else if exist == false {
			this.JSONOut(http.StatusBadRequest, "Team not exist", nil)
			return
		}

		for _, u := range t.Users {
			if u == member.Username {
				this.JSONOut(http.StatusOK, "User remove successfully.", nil)
				return
			}
		}
	}

	for i, v := range user.JoinOrganizations {
		if v == org.Name {
			user.JoinOrganizations = append(user.JoinOrganizations[:i], user.JoinOrganizations[i+1:]...)
			user.Updated = time.Now().UnixNano() / int64(time.Millisecond)

			if err := user.Save(); err != nil {
				this.JSONOut(http.StatusBadRequest, "User save error", nil)
				return
			}
		}
	}

	this.JSONOut(http.StatusOK, "User remove successfully.", nil)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:96,代码来源:orgwebv1.go

示例6: PostMember

func (this *OrganizationWebV1Controller) PostMember() {
	user := new(models.User)
	org := new(models.Organization)
	team := new(models.Team)
	member := new(models.User)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	if exist, _, err := team.Has(this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team")); err != nil {
		this.JSONOut(http.StatusBadRequest, "Search team error", nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Team not exist", nil)
		return
	}

	if exist, _, err := user.Has(this.Ctx.Input.Param(":member")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	team.Users = append(team.Users, member.Username)
	team.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := team.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "Team save error", nil)
		return
	}

	has := false
	for _, k := range member.JoinOrganizations {
		if k == org.Name {
			has = true
		}
	}

	if has == false {
		member.JoinOrganizations = append(member.JoinOrganizations, org.Name)
	}

	member.JoinTeams = append(member.JoinTeams, team.Id)
	member.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := member.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "User save error", nil)
		return
	}

	this.JSONOut(http.StatusOK, "User added to the team", nil)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:68,代码来源:orgwebv1.go

示例7: PostTeam

func (this *OrganizationWebV1Controller) PostTeam() {
	user := new(models.User)
	org := new(models.Organization)
	team := new(models.Team)

	if exist, _, err := user.Has(this.Ctx.Input.Param(":username")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "User not exist", nil)
		return
	}

	if exist, _, err := org.Has(this.Ctx.Input.Param(":org")); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	} else if exist == false {
		this.JSONOut(http.StatusBadRequest, "Organization not exist", nil)
		return
	}

	if exist, _, err := team.Has(this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team")); err != nil {
		this.JSONOut(http.StatusBadRequest, "Search team error", nil)
		return
	} else if exist == true {
		this.JSONOut(http.StatusBadRequest, "Team already exist", nil)
		return
	}

	if err := json.Unmarshal(this.Ctx.Input.CopyBody(), &team); err != nil {
		this.JSONOut(http.StatusBadRequest, err.Error(), nil)
		return
	}

	team.Id = fmt.Sprintf("%s-%s", this.Ctx.Input.Param(":org"), this.Ctx.Input.Param(":team"))
	team.Username = this.Ctx.Input.Param(":username")
	team.Users, team.Repositories = []string{this.Ctx.Input.Param(":username")}, []string{}
	team.Created = time.Now().UnixNano() / int64(time.Millisecond)
	team.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := team.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "Team save error", nil)
		return
	}

	org.Teams = append(org.Teams, team.Id)
	org.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := org.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "Organization save error", nil)
		return
	}

	user.Teams = append(user.Teams, team.Id)
	user.Updated = time.Now().UnixNano() / int64(time.Millisecond)

	if err := user.Save(); err != nil {
		this.JSONOut(http.StatusBadRequest, "User save error", nil)
		return
	}

	this.JSONOut(http.StatusOK, "Team create successfully", nil)
	return
}
开发者ID:rechen,项目名称:wharf,代码行数:64,代码来源:orgwebv1.go


注:本文中的github.com/containerops/wharf/models.Team.Has方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。