dao

package
v1.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2021 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BULK_INSERT_CHUNK_SIZE = 3000
View Source
const DIALECT = "mysql"

DIALECT db 类型

Variables

View Source
var (
	ErrNotFoundOrg         = errors.New("org not found")
	ErrNotFoundProject     = errors.New("project not found")
	ErrNotFoundApplication = errors.New("application not found")
	ErrNotFoundMember      = errors.New("member not found")
	ErrNotFoundTicket      = errors.New("ticket not found")
	ErrNotFoundPublisher   = errors.New("publisher not found")
	ErrNotFoundCertificate = errors.New("certificate not found")
	ErrNotFoundApprove     = errors.New("approve not found")
	ErrNotFoundUsecase     = errors.New("usecase not found")
)

dao层错误码统一定义

Functions

func Count

func Count()

Count 记录cmdb运行时间,获取的容器数量,主机数量

func Round

func Round(f float64, n int) float64

Round 保留小数点计算

Types

type BaseModel

type BaseModel struct {
	ID        int64     `json:"id" gorm:"primary_key"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

BaseModel common info for all models

type DBClient

type DBClient struct {
	*gorm.DB
}

DBClient db client

func NewDBClient

func NewDBClient() (*DBClient, error)

NewDBClient create new db client

func (*DBClient) ArchiveAuditsByTimeAndOrg

func (client *DBClient) ArchiveAuditsByTimeAndOrg() error

ArchiveAuditsByTimeAndOrg 归档某个企业的审计事件

func (*DBClient) BatchCreateAudit

func (client *DBClient) BatchCreateAudit(audits []model.Audit) error

BatchCreateAudit 批量传教审计

func (*DBClient) BatchCreateMemberExtra

func (client *DBClient) BatchCreateMemberExtra(memberExtras []model.MemberExtra) error

BatchCreateMemberExtra 批量创建成员关联关系

func (*DBClient) BatchGetNotifyGroup

func (client *DBClient) BatchGetNotifyGroup(ids []int64) ([]*apistructs.NotifyGroup, error)

BatchGetNotifyGroup 批量获取通知组

func (*DBClient) BatchQueryIssueLabelIDMap

func (client *DBClient) BatchQueryIssueLabelIDMap(issueIDs []int64) (map[uint64][]uint64, error)

BatchQueryIssueLabelIDMap 批量查询 issue label id

func (*DBClient) BulkInsert

func (client *DBClient) BulkInsert(objects interface{}, excludeColumns ...string) error

func (*DBClient) CheckNotifyGroupNameExist

func (client *DBClient) CheckNotifyGroupNameExist(scopeType, scopeID, name string) (bool, error)

func (*DBClient) CheckNotifyNameExist

func (client *DBClient) CheckNotifyNameExist(scopeType, scopeID, name, label string) (bool, error)

func (*DBClient) CreateApplication

func (client *DBClient) CreateApplication(application *model.Application) error

CreateApplication 创建应用

func (*DBClient) CreateApprove

func (client *DBClient) CreateApprove(approve *model.Approve) error

CreateApprove 创建Approve

func (*DBClient) CreateAudit

func (client *DBClient) CreateAudit(audit *model.Audit) error

CreateAudit 创建审计

func (*DBClient) CreateCurrentOrg

func (client *DBClient) CreateCurrentOrg(orgRelation *model.CurrentOrg) error

CreateCurrentOrg 添加用户当前所属企业

func (*DBClient) CreateErrorLog

func (client *DBClient) CreateErrorLog(errorLog *model.ErrorLog) error

CreateErrorLog 创建错误日志

func (*DBClient) CreateFavoritedResource

func (client *DBClient) CreateFavoritedResource(resource *model.FavoritedResource) error

CreateFavoritedResource 创建收藏关系

func (*DBClient) CreateFile

func (client *DBClient) CreateFile(file *File) error

func (*DBClient) CreateLabel

func (client *DBClient) CreateLabel(label *Label) error

CreateLabel 创建 label

func (*DBClient) CreateLabelRelation

func (client *DBClient) CreateLabelRelation(lr *LabelRelation) error

CreateLabelRelation 创建标签关联关系

func (*DBClient) CreateMBox

func (client *DBClient) CreateMBox(mbox *model.MBox) error

func (*DBClient) CreateMember

func (client *DBClient) CreateMember(member *model.Member) error

CreateMember 创建成员

func (*DBClient) CreateMemberExtra

func (client *DBClient) CreateMemberExtra(memberExtra *model.MemberExtra) error

CreateMemberExtra 创建成员关联关系

func (*DBClient) CreateNotice

func (client *DBClient) CreateNotice(notice *Notice) error

CreateNotice 创建公告

func (*DBClient) CreateNotify

func (client *DBClient) CreateNotify(request *apistructs.CreateNotifyRequest) (int64, error)

func (*DBClient) CreateNotifyGroup

func (client *DBClient) CreateNotifyGroup(request *apistructs.CreateNotifyGroupRequest) (int64, error)

CreateNotifyGroup 创建通知组

func (*DBClient) CreateNotifyHistory

func (client *DBClient) CreateNotifyHistory(request *apistructs.CreateNotifyHistoryRequest) (int64, error)

func (*DBClient) CreateNotifyItem

func (client *DBClient) CreateNotifyItem(request *apistructs.CreateNotifyItemRequest) (int64, error)

func (*DBClient) CreateOrUpdateNexusRepository

func (client *DBClient) CreateOrUpdateNexusRepository(repo *NexusRepository) error

func (*DBClient) CreateOrUpdateNexusUser

func (client *DBClient) CreateOrUpdateNexusUser(user *NexusUser) error

func (*DBClient) CreateOrg

func (client *DBClient) CreateOrg(org *model.Org) error

CreateOrg 创建企业

func (*DBClient) CreateOrgClusterRelation

func (client *DBClient) CreateOrgClusterRelation(relation *model.OrgClusterRelation) error

CreateOrgClusterRelation 创建企业集群关系

func (*DBClient) CreateProject

func (client *DBClient) CreateProject(project *model.Project) error

CreateProject 创建项目

func (*DBClient) CreateReview

func (client *DBClient) CreateReview(review *model.ManualReview) error

func (*DBClient) CreateReviewUser

func (client *DBClient) CreateReviewUser(review *model.ReviewUser) error

CreateReviewUser 创建成员

func (*DBClient) CreateRolePermission

func (client *DBClient) CreateRolePermission(permission *model.RolePermission) error

CreateRolePermission 创建角色权限

func (*DBClient) DeleteApplication

func (client *DBClient) DeleteApplication(applicationID int64) error

DeleteApplication 删除应用

func (*DBClient) DeleteApprove

func (client *DBClient) DeleteApprove(approveID int64) error

DeleteApprove 删除Approve

func (*DBClient) DeleteAuditsByTimeAndOrg

func (client *DBClient) DeleteAuditsByTimeAndOrg(startTime time.Time, orgIDs []uint64) error

DeleteAuditsByTimeAndOrg 软删除某个企业的审计事件

func (*DBClient) DeleteAuditsByTimeAndSys

func (client *DBClient) DeleteAuditsByTimeAndSys(startTime time.Time) error

DeleteAuditsByTimeAndSys 软删除系统级别的审计事件

func (*DBClient) DeleteCurrentOrg

func (client *DBClient) DeleteCurrentOrg(userID string) error

DeleteCurrentOrg 删除当前用户所属企业

func (*DBClient) DeleteFavoritedResource

func (client *DBClient) DeleteFavoritedResource(id uint64) error

DeleteFavoritedResource 删除收藏关系

func (*DBClient) DeleteFavoritedResourcesByTarget

func (client *DBClient) DeleteFavoritedResourcesByTarget(target string, targetID uint64) error

DeleteFavoritedResourcesByTarget 根据 target 删除收藏关系

func (*DBClient) DeleteFile

func (client *DBClient) DeleteFile(id uint64) error

func (*DBClient) DeleteLabel

func (client *DBClient) DeleteLabel(labelID int64) error

DeleteLabel 删除标签

func (*DBClient) DeleteLabelRelations

func (client *DBClient) DeleteLabelRelations(refType apistructs.ProjectLabelType, refID uint64) error

DeleteLabelRelations 删除标签关联关系

func (*DBClient) DeleteLabelRelationsByLabel

func (client *DBClient) DeleteLabelRelationsByLabel(labelID uint64) error

DeleteLabelRelationsByLabel 根据 labelID 删除标签

func (*DBClient) DeleteMBox

func (client *DBClient) DeleteMBox(id int64) error

func (*DBClient) DeleteMember

func (client *DBClient) DeleteMember(memberID int64) error

DeleteMember 删除成员

func (*DBClient) DeleteMemberByScopeAndUsersAndRole

func (client *DBClient) DeleteMemberByScopeAndUsersAndRole(userIDs []string, scopeType apistructs.ScopeType, scopeID int64, role string) error

DeleteMemberByScopeAndUsersAndRole 根据scope, userID, role删除成员,多角色状态下,更新用户角色时用到, todo delete

func (*DBClient) DeleteMemberExtraByIDsANDResourceValues

func (client *DBClient) DeleteMemberExtraByIDsANDResourceValues(userIDs []string, scopeType apistructs.ScopeType,
	scopeIDs []int64, resourceValues []string) error

DeleteMemberExtraByIDsANDResourceValues 根据userIDs, scope和resourceValues删除成员标签

func (*DBClient) DeleteMemberExtraByParentID

func (client *DBClient) DeleteMemberExtraByParentID(userIDs []string, scopeType apistructs.ScopeType, parentID int64) error

DeleteMemberExtraByParentID 根据parentID删除成员关联关系

func (*DBClient) DeleteMemberExtraByParentIDs

func (client *DBClient) DeleteMemberExtraByParentIDs(userID []string, scopeType apistructs.ScopeType, parentIDs []int64) error

DeleteMemberExtraByParentIDs 根据多个parentID删除成员关联关系

func (*DBClient) DeleteMemberExtraByScope

func (client *DBClient) DeleteMemberExtraByScope(scopeType apistructs.ScopeType, scopeID int64) error

DeleteMemberExtraByScope 根据scope信息删除成员

func (*DBClient) DeleteMemberExtraByUserIDsAndScope

func (client *DBClient) DeleteMemberExtraByUserIDsAndScope(scopeType apistructs.ScopeType, scopeID int64,
	userIDs []string) error

DeleteMemberExtraByUserIDsAndScope 根据userID和scope删除成员关联关系

func (*DBClient) DeleteMemberExtraByUserIDsAndScopeIDs

func (client *DBClient) DeleteMemberExtraByUserIDsAndScopeIDs(scopeType apistructs.ScopeType, scopeIDs []int64,
	userIDs []string) error

DeleteMemberExtraByUserIDsAndScopeIDs 根据userID和多个scopeID删除成员关联关系

func (*DBClient) DeleteMemberExtraByUxerIDANDResourceValues

func (client *DBClient) DeleteMemberExtraByUxerIDANDResourceValues(userID string, scopeType apistructs.ScopeType,
	scopeIDs []int64, resourceValues []string) error

DeleteMemberExtraByUxerIDANDResourceValues 根据userID, scope和resourceValues删除成员标签

func (*DBClient) DeleteMembersByOrgAndUsers

func (client *DBClient) DeleteMembersByOrgAndUsers(orgID string, userIDs []string) error

DeleteMembersByOrgAndUsers 根据 userIDs 删除成员信息 (用户踢出企业时使用)

func (*DBClient) DeleteMembersByScope

func (client *DBClient) DeleteMembersByScope(scopeType apistructs.ScopeType, scopeID int64) error

DeleteMembersByScope 根据scope删除成员

func (*DBClient) DeleteMembersByScopeAndUsers

func (client *DBClient) DeleteMembersByScopeAndUsers(userIDs []string, scopeType apistructs.ScopeType, scopeID int64) error

DeleteMembersByScopeAndUsers 根据scope & userID删除成员

func (*DBClient) DeleteNotice

func (client *DBClient) DeleteNotice(noticeID uint64) error

DeleteNotice 删除公告

func (*DBClient) DeleteNotify

func (client *DBClient) DeleteNotify(id int64, withGroup bool, orgID int64) error

func (*DBClient) DeleteNotifyGroup

func (client *DBClient) DeleteNotifyGroup(id int64, orgID int64) error

func (*DBClient) DeleteNotifyItem

func (client *DBClient) DeleteNotifyItem(id int64) error

func (*DBClient) DeleteNotifyRelationsByScope

func (client *DBClient) DeleteNotifyRelationsByScope(scopeType apistructs.ScopeType, scopeID string) error

DeleteNotifyRelationsByScope 删除对应关联的通知信息

func (*DBClient) DeleteNotifySource

func (client *DBClient) DeleteNotifySource(request *apistructs.DeleteNotifySourceRequest) error

func (*DBClient) DeleteOrg

func (client *DBClient) DeleteOrg(orgID int64) error

DeleteOrg 删除企业

func (*DBClient) DeleteOrgClusterRelationByCluster

func (client *DBClient) DeleteOrgClusterRelationByCluster(clusterName string) error

DeleteOrgClusterRelationByCluster 根据 clusterName 删除企业集群关联关系

func (*DBClient) DeleteOrgClusterRelationByClusterAndOrg

func (client *DBClient) DeleteOrgClusterRelationByClusterAndOrg(clusterName string, orgID int64) error

DeleteOrgClusterRelationByClusterAndOrg 根据 clusterName、orgID 删除企业集群关联关系

func (*DBClient) DeleteProject

func (client *DBClient) DeleteProject(projectID int64) error

DeleteProject 删除项目

func (*DBClient) DeleteProjectAppsMembers

func (client *DBClient) DeleteProjectAppsMembers(userIDs []string, projectID int64) error

DeleteProjectAppsMembers 删除该用户对应项目下的应用权限

func (*DBClient) FuzzyQueryNotifiesBySource

func (client *DBClient) FuzzyQueryNotifiesBySource(req apistructs.FuzzyQueryNotifiesBySourceRequest) ([]*apistructs.NotifyDetail, int, error)

func (*DBClient) GetActivitiesByRuntime

func (client *DBClient) GetActivitiesByRuntime(runtimeID int64, pageNo, pageSize int) (int, []model.Activity, error)

GetActivitiesByRuntime 根据runtimeID获取活动列表

func (*DBClient) GetAllApps

func (client *DBClient) GetAllApps() ([]model.Application, error)

GetAllApps 获取所有app列表

func (*DBClient) GetAllProjects

func (client *DBClient) GetAllProjects() ([]model.Project, error)

GetAllProjects get all projects

func (*DBClient) GetAppMembersByUser

func (client *DBClient) GetAppMembersByUser(userID string) ([]model.MemberExtra, error)

GetAppMembersByUser 根据userID查询应用权限

func (*DBClient) GetApplicationByID

func (client *DBClient) GetApplicationByID(applicationID int64) (model.Application, error)

GetApplicationByID 根据applicationID获取应用信息

func (*DBClient) GetApplicationByName

func (client *DBClient) GetApplicationByName(projectID int64, name string) (model.Application, error)

GetApplicationByName 根据projectID & name获取应用

func (*DBClient) GetApplicationByOrgAndName

func (client *DBClient) GetApplicationByOrgAndName(orgID int64, name string) (*model.Application, error)

GetApplicationByOrgAndName 根据orgID & 应用名称获取应用

func (*DBClient) GetApplicationCountByProjectID

func (client *DBClient) GetApplicationCountByProjectID(projectID int64) (int64, error)

GetApplicationCountByProjectID 根据projectID获取应用总数

func (*DBClient) GetApplicationsByIDs

func (client *DBClient) GetApplicationsByIDs(orgID *int64, projectID *int64, applicationIDs []int64, request *apistructs.ApplicationListRequest) (
	int, []model.Application, error)

GetApplicationsByIDs 根据applicationIDs & 名称模糊匹配获取应用列表

func (*DBClient) GetApplicationsByProjectID

func (client *DBClient) GetApplicationsByProjectID(projectID, pageNum, pageSize int64) ([]model.Application, error)

GetApplicationsByProjectID 根据projectID获取应用列表

func (*DBClient) GetApplicationsByProjectIDs

func (client *DBClient) GetApplicationsByProjectIDs(projectIDs []uint64) ([]model.Application, error)

GetApplicationsByProjectIDs 根据项目ID列表批量查询应用

func (*DBClient) GetApproveByID

func (client *DBClient) GetApproveByID(approveID int64) (model.Approve, error)

GetApproveByID 根据approveID获取Approve信息

func (*DBClient) GetApproveByOrgAndID

func (client *DBClient) GetApproveByOrgAndID(approveType apistructs.ApproveType,
	orgID, targetTD, entityID uint64) (*model.Approve, error)

GetApproveByOrgAndID 根据orgID & Approve名称 获取证书信息

func (*DBClient) GetApprovesByOrgIDAndStatus

func (client *DBClient) GetApprovesByOrgIDAndStatus(params *apistructs.ApproveListRequest) (
	int, []model.Approve, error)

GetApprovesByOrgIDAndStatus 根据orgID与审批状态获取Approve列表

func (*DBClient) GetAuditCleanCron

func (client *DBClient) GetAuditCleanCron(orgID int64) (*model.Org, error)

GetAuditCleanCron 获取企业事件清理周期

func (*DBClient) GetAuditSettings

func (client *DBClient) GetAuditSettings() ([]model.AuditSettings, error)

GetAuditSettings 从 dice_org 获取审计事件清理周期

func (*DBClient) GetAuditsByParam

func (client *DBClient) GetAuditsByParam(param *apistructs.AuditsListRequest) (int, []model.Audit, error)

GetAuditsByParam 通过参数查询成员

func (*DBClient) GetCurrentOrgByUser

func (client *DBClient) GetCurrentOrgByUser(userID string) (int64, error)

GetCurrentOrgByUser 根据userID获取当前所属企业ID

func (*DBClient) GetErrorLogByDedupIndex

func (client *DBClient) GetErrorLogByDedupIndex(resourceID string, resourceType apistructs.ErrorResourceType,
	dedupID string) (*model.ErrorLog, error)

GetErrorLogByDedupIndex 根据唯一索引获取错误日志记录

func (*DBClient) GetFavoritedResource

func (client *DBClient) GetFavoritedResource(target string, targetID uint64, userID string) (*model.FavoritedResource, error)

GetFavoritedResource 查询收藏关系

func (*DBClient) GetFavoritedResourcesByUser

func (client *DBClient) GetFavoritedResourcesByUser(target, userID string) ([]model.FavoritedResource, error)

GetFavoritedResourcesByUser 查询收藏关系

func (*DBClient) GetFile

func (client *DBClient) GetFile(id uint64) (File, error)

func (*DBClient) GetFileByUUID

func (client *DBClient) GetFileByUUID(uuid string) (File, error)

func (*DBClient) GetJoinedAppNumByUserId

func (client *DBClient) GetJoinedAppNumByUserId(userID, orgID string) (int, error)

GetJoinedAppNumByUserId get joined apps num by user and org

func (*DBClient) GetJoinedProjectNumByUserID

func (client *DBClient) GetJoinedProjectNumByUserID(userID string, orgID string) (int, []string, error)

GetJoinedProjectNumByUserID get projects by userID and orgID

func (*DBClient) GetLabel

func (client *DBClient) GetLabel(labelID int64) (*Label, error)

GetLabel 根据标签ID获取标签详情

func (*DBClient) GetLabelByName

func (client *DBClient) GetLabelByName(projectID uint64, name string) (*Label, error)

GetLabelByName 根据 name 获取标签详情

func (*DBClient) GetLabelRelationsByLabels

func (client *DBClient) GetLabelRelationsByLabels(refType apistructs.ProjectLabelType, labelIDs []uint64) ([]LabelRelation, error)

GetLabelRelationsByLabels 获取标签关联关系列表

func (*DBClient) GetLabelRelationsByRef

func (client *DBClient) GetLabelRelationsByRef(refType apistructs.ProjectLabelType, refID uint64) ([]LabelRelation, error)

GetLabelRelationsByRef 获取标签关联关系列表

func (*DBClient) GetLabels

func (client *DBClient) GetLabels(labelIDs []uint64) ([]Label, error)

GetLabels 根据 labelID 获取标签列表

func (*DBClient) GetMBox

func (client *DBClient) GetMBox(id int64, orgID int64, userID string) (*apistructs.MBox, error)

func (*DBClient) GetMBoxStats

func (client *DBClient) GetMBoxStats(orgID int64, userID string) (*apistructs.QueryMBoxStatsData, error)

func (*DBClient) GetManagerMemberCountByUserID

func (client *DBClient) GetManagerMemberCountByUserID(userIDs []string, scopeID int64,
	scopeType apistructs.ScopeType) (uint64, error)

GetManagerMemberCountByUserID 获取某个用户的企业/项目/应用管理员数量

func (*DBClient) GetManagerMembersCount

func (client *DBClient) GetManagerMembersCount(scopeID int64, scopeType apistructs.ScopeType) (uint64, error)

GetManagerMembersCount 根据scopeID获取企业/项目/应用管理员的数量,todo delete

func (*DBClient) GetMboxByDeduplicateID

func (client *DBClient) GetMboxByDeduplicateID(orgID int64, deduplicateID, userID string) (*model.MBox, error)

GetMboxByDeduplicateID get a mbox by deduplicate_id

func (*DBClient) GetMeberExtraByParentID

func (client *DBClient) GetMeberExtraByParentID(userIDs []string, scopeType apistructs.ScopeType, parentID int64) ([]model.MemberExtra, error)

GetMeberExtraByParentID 通过父scope获取成员extra

func (*DBClient) GetMeberRoleByParentID

func (client *DBClient) GetMeberRoleByParentID(userID string, scopeType apistructs.ScopeType, parentID int64) ([]model.MemberExtra, error)

GetMeberRoleByParentID 通过父scope获取成员extra

func (*DBClient) GetMemberByID

func (client *DBClient) GetMemberByID(memberID int64) (*model.Member, error)

GetMemberByID 根据memberID获取成员

func (*DBClient) GetMemberByIDs

func (client *DBClient) GetMemberByIDs(memberIDs []int64) ([]model.Member, error)

GetMemberByIDs 根据memberID列表获取成员列表

func (*DBClient) GetMemberByScopeAndRole

func (client *DBClient) GetMemberByScopeAndRole(scopeType apistructs.ScopeType, scopeIDs []uint64,
	roles []string) ([]model.MemberExtra, error)

GetMemberByScopeAndRole 根据Scope和角色获取成员

func (*DBClient) GetMemberByScopeAndUserID

func (client *DBClient) GetMemberByScopeAndUserID(userID string, scopeType apistructs.ScopeType,
	scopeID int64) ([]model.MemberJoin, error)

GetMemberByScopeAndUserID 根据scope & userID过滤

func (*DBClient) GetMemberByToken

func (client *DBClient) GetMemberByToken(token string) (*model.Member, error)

GetMemberByToken 根据token获取成员

func (*DBClient) GetMemberByUserID

func (client *DBClient) GetMemberByUserID(userID string) ([]model.Member, error)

GetMemberByUserID 通过 user_id 获取成员

func (*DBClient) GetMemberByUserIDAndScopeIDs

func (client *DBClient) GetMemberByUserIDAndScopeIDs(userID string, scopeType apistructs.ScopeType, scopeIDs []int64) ([]model.Member, error)

GetMemberByUserIDAndScopeIDs 通过 user_id 和 scopeIDs 信息获取成员

func (*DBClient) GetMemberByUserIDsAndScope

func (client *DBClient) GetMemberByUserIDsAndScope(userIDs []string, scopeType apistructs.ScopeType, scopeID int64) ([]model.Member, error)

GetMemberByUserIDsAndScope 通过 user_id 和 scope 信息获取成员

func (*DBClient) GetMemberExtra

func (client *DBClient) GetMemberExtra(userIDs []string, scopeType apistructs.ScopeType, scopeID int64,
	resourceKey []apistructs.ExtraResourceKey) ([]model.MemberExtra, error)

GetMemberExtra 根据UserID, Scope和resourceKey获取成员关联关系

func (*DBClient) GetMemberExtraByIDs

func (client *DBClient) GetMemberExtraByIDs(userIDs []string, scopeType apistructs.ScopeType, scopeIDs []int64,
	resourceKey []apistructs.ExtraResourceKey) ([]model.MemberExtra, error)

GetMemberExtraByIDs 根据多个userid和scopeid查询memberextra

func (*DBClient) GetMembersByOrgAndUser

func (client *DBClient) GetMembersByOrgAndUser(orgID int64, userID string) ([]model.MemberJoin, error)

GetMembersByOrgAndUser 根据userID查询成员

func (*DBClient) GetMembersByParam

func (client *DBClient) GetMembersByParam(param *apistructs.MemberListRequest) (
	int, []model.Member, error)

GetMembersByParam 根据查询参数获取企业成员列表

func (*DBClient) GetMembersByParentID

func (client *DBClient) GetMembersByParentID(scopeType apistructs.ScopeType, parentID int64, userID string) (
	[]model.MemberJoin, error)

GetMembersByParentID 根据parentID & userID等信息查询权限

func (*DBClient) GetMembersByScope

func (client *DBClient) GetMembersByScope(scopeType apistructs.ScopeType, scopeIDs []string, roles []string) ([]model.Member, error)

GetMembersByScope 查询指定scope和role的用户,todo delete

func (*DBClient) GetMembersByScopeType

func (client *DBClient) GetMembersByScopeType(scopeType apistructs.ScopeType) ([]model.Member, error)

GetMembersByScopeType 根据scopeType获取所有对应的成员列表,todo delete

func (*DBClient) GetMembersByScopeTypeAndUser

func (client *DBClient) GetMembersByScopeTypeAndUser(scopeType apistructs.ScopeType, userID string) ([]model.Member, error)

GetMembersByScopeTypeAndUser 根据scopeType & user获取成员

func (*DBClient) GetMembersWithoutExtraByScope

func (client *DBClient) GetMembersWithoutExtraByScope(scopeType apistructs.ScopeType, scopeID int64) (
	int, []model.Member, error)

GetMembersWithoutExtraByScope 根据parentID 信息查询成员,不带角色label等信息

func (*DBClient) GetNexusRepository

func (client *DBClient) GetNexusRepository(id uint64) (*NexusRepository, error)

func (*DBClient) GetNexusRepositoryByName

func (client *DBClient) GetNexusRepositoryByName(name string) (*NexusRepository, error)

func (*DBClient) GetNexusUser

func (client *DBClient) GetNexusUser(id uint64) (*NexusUser, error)

func (*DBClient) GetNexusUserByName

func (client *DBClient) GetNexusUserByName(name string) (*NexusUser, error)

func (*DBClient) GetNotice

func (client *DBClient) GetNotice(noticeID uint64) (*Notice, error)

func (*DBClient) GetNotifyByGroupID

func (client *DBClient) GetNotifyByGroupID(groupID int64) (*model.Notify, error)

func (*DBClient) GetNotifyDetail

func (client *DBClient) GetNotifyDetail(id int64, orgID int64) (*apistructs.NotifyDetail, error)

func (*DBClient) GetNotifyGroupByID

func (client *DBClient) GetNotifyGroupByID(id int64, orgID int64) (*apistructs.NotifyGroup, error)

GetNotifyGroupByID 获取通知组

func (*DBClient) GetNotifyGroupByIDWithoutOrgID

func (client *DBClient) GetNotifyGroupByIDWithoutOrgID(id int64) (*apistructs.NotifyGroup, error)

GetNotifyGroupByIDWithoutOrgID 直接通过ID获取通知组

func (*DBClient) GetNotifyGroupNameByID

func (client *DBClient) GetNotifyGroupNameByID(id int64, orgID int64) (*apistructs.NotifyGroup, error)

func (*DBClient) GetNotifyItemsByNotifyID

func (client *DBClient) GetNotifyItemsByNotifyID(notifyID int64) ([]*apistructs.NotifyItem, error)

func (*DBClient) GetNotifyItemsByNotifyIDAndItemName

func (client *DBClient) GetNotifyItemsByNotifyIDAndItemName(notifyID int64, itemName string) ([]*apistructs.NotifyItem, error)

func (*DBClient) GetNotifySourcesByNotifyID

func (client *DBClient) GetNotifySourcesByNotifyID(notifyID int64) ([]*apistructs.NotifySource, error)

func (*DBClient) GetOperatorByTaskID

func (client *DBClient) GetOperatorByTaskID(taskID []int) ([]model.ReviewUser, error)

func (*DBClient) GetOrg

func (client *DBClient) GetOrg(orgID int64) (model.Org, error)

GetOrg 根据orgID获取企业信息

func (*DBClient) GetOrgByName

func (client *DBClient) GetOrgByName(orgName string) (*model.Org, error)

GetOrgByName 根据 orgName 获取企业信息

func (*DBClient) GetOrgByUserIDs

func (client *DBClient) GetOrgByUserIDs(userIDs []string) ([]model.Member, error)

GetOrgByUserIDs 根据用户id获取对应的企业

func (*DBClient) GetOrgClusterRelationByOrgAndCluster

func (client *DBClient) GetOrgClusterRelationByOrgAndCluster(orgID, clusterID int64) (*model.OrgClusterRelation, error)

GetOrgClusterRelationByOrgAndCluster 获取企业集群关系

func (*DBClient) GetOrgClusterRelationsByOrg

func (client *DBClient) GetOrgClusterRelationsByOrg(orgID int64) ([]model.OrgClusterRelation, error)

GetOrgClusterRelationsByOrg 根据 orgID 获取企业对应集群关系

func (*DBClient) GetOrgList

func (client *DBClient) GetOrgList() ([]model.Org, error)

GetOrgList 获取所有企业列表(仅供内部用户使用)

func (*DBClient) GetOrgsByIDsAndName

func (client *DBClient) GetOrgsByIDsAndName(orgIDs []int64, name string, pageNo, pageSize int) (
	int, []model.Org, error)

GetOrgsByIDsAndName 根据企业ID列表 & 企业名称获取企业列表

func (*DBClient) GetOrgsByParam

func (client *DBClient) GetOrgsByParam(name string, pageNum, pageSize int) (int, []model.Org, error)

GetOrgsByParam 获取企业列表

func (*DBClient) GetOrgsByUserID

func (client *DBClient) GetOrgsByUserID(userID string) ([]model.Org, error)

GetOrgsByUserID 根据userID获取企业列表

func (*DBClient) GetOwnerMemberCountByUserID

func (client *DBClient) GetOwnerMemberCountByUserID(userIDs []string, scopeID int64,
	scopeType apistructs.ScopeType) (uint64, error)

GetOwnerMemberCountByUserID 获取某个用户的项目/应用所有者的数量

func (*DBClient) GetOwnerMembersCount

func (client *DBClient) GetOwnerMembersCount(scopeID int64, scopeType apistructs.ScopeType) (uint64, error)

GetOwnerMembersCount 根据scopeID获取项目/应用所有者的数量

func (*DBClient) GetPermissionList

func (client *DBClient) GetPermissionList(roles []string) ([]model.RolePermission, []model.RolePermission)

GetPermissionList 获取角色权限列表

func (*DBClient) GetProjectApplications

func (client *DBClient) GetProjectApplications(projectID int64) ([]model.Application, error)

GetProjectApplications 根据projectID获取所有应用列表

func (*DBClient) GetProjectByID

func (client *DBClient) GetProjectByID(projectID int64) (model.Project, error)

GetProjectByID 根据projectID获取项目信息

func (*DBClient) GetProjectByOrgAndName

func (client *DBClient) GetProjectByOrgAndName(orgID int64, name string) (*model.Project, error)

GetProjectByOrgAndName 根据orgID & 项目名称 获取项目

func (*DBClient) GetProjectIDListByStates

func (client *DBClient) GetProjectIDListByStates(req apistructs.IssuePagingRequest, projectIDList []uint64) (int, []model.Project, error)

GetProjectIDListByStates get states by projectID list

func (*DBClient) GetProjectMembersByUser

func (client *DBClient) GetProjectMembersByUser(userID string) ([]model.MemberExtra, error)

GetProjectMembersByUser 根据userID查询项目权限,todo delete

func (*DBClient) GetProjectsByIDs

func (client *DBClient) GetProjectsByIDs(projectIDs []uint64, params *apistructs.ProjectListRequest) (
	int, []model.Project, error)

GetProjectsByIDs 根据projectIDs获取项目列表

func (*DBClient) GetProjectsByOrgIDAndName

func (client *DBClient) GetProjectsByOrgIDAndName(orgID int64, params *apistructs.ProjectListRequest) (
	int, []model.Project, error)

GetProjectsByOrgIDAndName 根据orgID与名称获取项目列表

func (*DBClient) GetPublicOrgsByParam

func (client *DBClient) GetPublicOrgsByParam(name string, pageNum, pageSize int) (int, []model.Org, error)

Get public orgs list

func (*DBClient) GetReviewByID

func (client *DBClient) GetReviewByID(id int64) (review model.ManualReview, err error)

GetReviewByID get review by id

func (*DBClient) GetReviewByTaskId

func (*DBClient) GetReviewsBySponsorId

func (client *DBClient) GetReviewsBySponsorId(param *apistructs.GetReviewsBySponsorIdRequest) (int, []model.ManualReview, error)

func (*DBClient) GetReviewsByUserId

func (client *DBClient) GetReviewsByUserId(param *apistructs.GetReviewsByUserIdRequest, tasks []int64) (int, []model.ManualReview, error)

func (*DBClient) GetRolePermission

func (client *DBClient) GetRolePermission(roles []string, permissionInfo *apistructs.PermissionCheckRequest) (*model.RolePermission, error)

GetRolePermission 获取角色权限

func (*DBClient) GetScopeManagersByScopeID

func (client *DBClient) GetScopeManagersByScopeID(scopeType apistructs.ScopeType, scopeID int64) ([]apistructs.Member, error)

GetScopeManagersByScopeID 根据 scopeID 获取 scope 对应的管理员列表

func (*DBClient) GetScopeNameByScope

func (client *DBClient) GetScopeNameByScope(scopeType apistructs.ScopeType, scopeID int64) string

GetScopeNameByScope 根据scope获取名称

func (*DBClient) GetTaskIDByOperator

func (client *DBClient) GetTaskIDByOperator(param *apistructs.GetReviewsByUserIdRequest) ([]int64, error)

func (*DBClient) GetUcUserID added in v1.3.0

func (client *DBClient) GetUcUserID(uuid string) (string, error)

func (*DBClient) GetUcUserList added in v1.3.0

func (client *DBClient) GetUcUserList() ([]model.User, error)

func (*DBClient) InitOrgAuditInterval

func (client *DBClient) InitOrgAuditInterval(orgIDs []uint64) error

InitOrgAuditInterval 初始化企业的审计事件清理周期

func (*DBClient) InsertMapping added in v1.3.0

func (client *DBClient) InsertMapping(userID, uuid, hash string) error

func (*DBClient) IsSysAdmin

func (client *DBClient) IsSysAdmin(userID string) (bool, error)

IsSysAdmin 判断用户是否为系统管理员

func (*DBClient) ListAllOrgClusterRelations

func (client *DBClient) ListAllOrgClusterRelations() ([]model.OrgClusterRelation, error)

ListAllOrgClusterRelations 获取所有企业对应集群关系

func (*DBClient) ListErrorLogByResources

func (client *DBClient) ListErrorLogByResources(resourceTypes []apistructs.ErrorResourceType, resourceIDs []string) ([]model.ErrorLog, error)

ListErrorLogByResources 根据多个resource信息查看错误日志

func (*DBClient) ListErrorLogByResourcesAndStartTime

func (client *DBClient) ListErrorLogByResourcesAndStartTime(resourceTypes []apistructs.ErrorResourceType,
	resourceIDs []string, startTime time.Time) ([]model.ErrorLog, error)

ListErrorLogByResourcesAndStartTime 根据多个resource信息和开始时间查看错误日志

func (*DBClient) ListExpiredFiles

func (client *DBClient) ListExpiredFiles(expiredAt time.Time) ([]File, error)

func (*DBClient) ListLabel

func (client *DBClient) ListLabel(req *apistructs.ProjectLabelListRequest) (int64, []Label, error)

ListLabel 获取标签列表

func (*DBClient) ListLabelByNames

func (client *DBClient) ListLabelByNames(projectID uint64, names []string) ([]Label, error)

ListLabelByNames 根据 name 列表获取标签列表

func (*DBClient) ListNexusRepositories

func (client *DBClient) ListNexusRepositories(req apistructs.NexusRepositoryListRequest) ([]*NexusRepository, error)

func (*DBClient) ListNexusUsers

func (client *DBClient) ListNexusUsers(req apistructs.NexusUserListRequest) ([]NexusUser, error)

func (*DBClient) ListNotice

func (client *DBClient) ListNotice(req *apistructs.NoticeListRequest) (uint64, []Notice, error)

ListNotice 公告列表

func (*DBClient) ListProjectByCluster

func (client *DBClient) ListProjectByCluster(clusterName string) ([]model.Project, error)

ListProjectByCluster 根据clusterName 获取项目列表

func (*DBClient) ListProjectByOrgID

func (client *DBClient) ListProjectByOrgID(orgID uint64) ([]model.Project, error)

ListProjectByOrgID 根据 orgID 获取项目列表

func (*DBClient) ListUnblockApplicationApprove

func (client *DBClient) ListUnblockApplicationApprove(orgID uint64) ([]model.Approve, error)

func (*DBClient) PageMeberRoleByParentID

func (client *DBClient) PageMeberRoleByParentID(req apistructs.ListMemberRolesByUserRequest) (int, []model.Member, error)

PageMeberRoleByParentID 通过用户和父scope分页查询成员角色

func (*DBClient) QueryAppPublishItemRelations

func (client *DBClient) QueryAppPublishItemRelations(req apistructs.QueryAppPublishItemRelationRequest) ([]apistructs.AppPublishItemRelation, error)

func (*DBClient) QueryMBox

func (client *DBClient) QueryMBox(request *apistructs.QueryMBoxRequest) (*apistructs.QueryMBoxData, error)

func (*DBClient) QueryNotifies

func (client *DBClient) QueryNotifies(request *apistructs.QueryNotifyRequest) (*apistructs.QueryNotifyData, error)

func (*DBClient) QueryNotifiesBySource

func (client *DBClient) QueryNotifiesBySource(sourceType, sourceID, itemName string, orgID int64, clusterName string, label string) ([]*apistructs.NotifyDetail, error)

func (*DBClient) QueryNotifyGroup

func (client *DBClient) QueryNotifyGroup(request *apistructs.QueryNotifyGroupRequest, orgID int64) (*apistructs.QueryNotifyGroupData, error)

QueryNotifyGroup 查询通知组

func (*DBClient) QueryNotifyHistories

func (client *DBClient) QueryNotifyHistories(request *apistructs.QueryNotifyHistoryRequest) (*apistructs.QueryNotifyHistoryData, error)

func (*DBClient) QueryNotifyItems

func (client *DBClient) QueryNotifyItems(request *apistructs.QueryNotifyItemRequest) (*apistructs.QueryNotifyItemData, error)

func (*DBClient) QuerytNotifyItemsByNotifyIDAndItemName

func (client *DBClient) QuerytNotifyItemsByNotifyIDAndItemName(notifyID int64, itemName string) ([]*apistructs.NotifyItem, error)

func (*DBClient) ReadAll added in v1.3.0

func (client *DBClient) ReadAll(orgID int64, userID string) error

ReadAll read all unread mbox with one click

func (*DBClient) RemovePublishItemRelations

func (client *DBClient) RemovePublishItemRelations(request *apistructs.RemoveAppPublishItemRelationsRequest) error

func (*DBClient) SetMBoxReadStatus

func (client *DBClient) SetMBoxReadStatus(request *apistructs.SetMBoxReadStatusRequest) error

func (*DBClient) Transaction added in v1.3.0

func (db *DBClient) Transaction(f func(tx *gorm.DB) error) error

func (*DBClient) UpdateAppPublishItemRelations

func (client *DBClient) UpdateAppPublishItemRelations(request *apistructs.UpdateAppPublishItemRelationRequest) error

func (*DBClient) UpdateApplication

func (client *DBClient) UpdateApplication(application *model.Application) error

UpdateApplication 更新应用

func (*DBClient) UpdateApproval

func (client *DBClient) UpdateApproval(param *apistructs.UpdateApproval) error

func (*DBClient) UpdateApprove

func (client *DBClient) UpdateApprove(approve *model.Approve) error

UpdateApprove 更新Approve

func (*DBClient) UpdateAuditCleanCron

func (client *DBClient) UpdateAuditCleanCron(orgID, interval int64) error

UpdateAuditCleanCron 修改企业事件清理周期

func (*DBClient) UpdateCurrentOrg

func (client *DBClient) UpdateCurrentOrg(userID string, orgID int64) error

UpdateCurrentOrg 更新用户当前所属企业

func (*DBClient) UpdateErrorLog

func (client *DBClient) UpdateErrorLog(errorLog *model.ErrorLog) error

UpdateErrorLog 更新错误日志记录

func (*DBClient) UpdateLabel

func (client *DBClient) UpdateLabel(label *Label) error

UpdateLabel 更新 label

func (*DBClient) UpdateMbox

func (client *DBClient) UpdateMbox(mbox *model.MBox) error

UpdateMbox update mbox

func (*DBClient) UpdateMember

func (client *DBClient) UpdateMember(member *model.Member) error

UpdateMember 更新成员

func (*DBClient) UpdateMemberUserInfo

func (client *DBClient) UpdateMemberUserInfo(ids []int64, fields map[string]interface{}) error

UpdateMemberUserInfo 更新成员 userinfo 信息

func (*DBClient) UpdateNotice

func (client *DBClient) UpdateNotice(notice *Notice) error

UpdateNotice 编辑公告

func (*DBClient) UpdateNotify

func (client *DBClient) UpdateNotify(request *apistructs.UpdateNotifyRequest) error

func (*DBClient) UpdateNotifyEnable

func (client *DBClient) UpdateNotifyEnable(id int64, enabled bool, orgID int64) error

func (*DBClient) UpdateNotifyGroup

func (client *DBClient) UpdateNotifyGroup(request *apistructs.UpdateNotifyGroupRequest) error

UpdateNotifyGroup 更新通知组

func (*DBClient) UpdateNotifyItem

func (client *DBClient) UpdateNotifyItem(request *apistructs.UpdateNotifyItemRequest) error

func (*DBClient) UpdateOrg

func (client *DBClient) UpdateOrg(org *model.Org) error

UpdateOrg 更新企业元信息,不可更改企业名称

func (*DBClient) UpdateProject

func (client *DBClient) UpdateProject(project *model.Project) error

UpdateProject 更新项目

func (*DBClient) UpdateProjectQuota

func (client *DBClient) UpdateProjectQuota(clusterName string, cpuOverSellChangeRatio float64) error

UpdateProjectQuota 更新项目配额

type File

type File struct {
	BaseModel

	UUID             string       // UUID,解决重名问题;用自增 id 在存储介质上容易冲突
	DisplayName      string       // 文件名,用于下载的时候展示
	Ext              string       // 文件后缀,带 dot
	ByteSize         int64        // 文件大小,Byte
	StorageType      storage.Type // 存储类型
	FullRelativePath string       // 文件相对路径,不包含 网盘挂载点 或 oss bucket
	From             string       // 文件来源,例如 issue / gittar mr
	Creator          string       // 文件创建者 ID
	Extra            FileExtra    // 额外信息,包括存储介质关键信息快照等
	ExpiredAt        *time.Time   // 文件超时自动删除
}

func (File) TableName

func (File) TableName() string

type FileExtra

type FileExtra struct {
	OSSSnapshot OSSSnapshot `json:"ossSnapshot,omitempty"`
	IsPublic    bool        `json:"isPublic,omitempty"`

	Encrypt             bool   `json:"encrypt,omitempty"`
	KMSKeyID            string `json:"kmsKeyID,omitempty"`
	DEKCiphertextBase64 string `json:"dekCiphertextBase64,omitempty"`
}

func (*FileExtra) Scan

func (ex *FileExtra) Scan(value interface{}) error

func (FileExtra) Value

func (ex FileExtra) Value() (driver.Value, error)

type Int64Slice

type Int64Slice []int64

Int64Slice 自定义 interface{},用于实现 []int64 的排序

func SortInt64Map

func SortInt64Map(m map[int64]int64) Int64Slice

func (Int64Slice) Len

func (c Int64Slice) Len() int

func (Int64Slice) Less

func (c Int64Slice) Less(i, j int) bool

func (Int64Slice) Swap

func (c Int64Slice) Swap(i, j int)

type Label

type Label struct {
	BaseModel
	Name      string                      // 标签名称
	Type      apistructs.ProjectLabelType // 标签作用类型
	Color     string                      // 标签颜色
	ProjectID uint64                      // 标签所属项目
	Creator   string                      // 创建人
}

Label 标签

func (Label) TableName

func (Label) TableName() string

TableName 表名

type LabelRelation

type LabelRelation struct {
	BaseModel
	LabelID uint64                      `json:"label_id"` // 标签 id
	RefType apistructs.ProjectLabelType `json:"ref_type"` // 标签作用类型, eg: issue
	RefID   uint64                      `json:"ref_id"`   // 标签关联目标 id
}

LabelRelation 标签关联关系

func (LabelRelation) TableName

func (LabelRelation) TableName() string

TableName 表名

type NexusRepository

type NexusRepository struct {
	BaseModel

	OrgID       *uint64 `json:"orgID"`       // 所属 org ID
	PublisherID *uint64 `json:"publisherID"` // 所属 publisher ID
	ClusterName string  `json:"clusterName"` // 所属集群

	Name   string                 `json:"name"`   // unique name
	Format nexus.RepositoryFormat `json:"format"` // maven2 / npm / ...
	Type   nexus.RepositoryType   `json:"type"`   // group / proxy / hosted
	Config NexusRepositoryConfig  `json:"config"` // repo config
}

func (NexusRepository) TableName

func (NexusRepository) TableName() string

type NexusRepositoryConfig

type NexusRepositoryConfig nexus.Repository

func (*NexusRepositoryConfig) Scan

func (config *NexusRepositoryConfig) Scan(value interface{}) error

func (NexusRepositoryConfig) Value

func (config NexusRepositoryConfig) Value() (driver.Value, error)

type NexusUser

type NexusUser struct {
	BaseModel

	RepoID      *uint64 `json:"repoID"`      // 所属 repo,可以为空
	PublisherID *uint64 `json:"publisherID"` // 所属 publisher,可以为空
	OrgID       *uint64 `json:"orgID"`       // 所属 org,可以为空
	ClusterName string  `json:"clusterName"` // 所属集群

	Name     string          `json:"name"`
	Password string          `json:"password"` // 加密存储
	Config   NexusUserConfig `json:"config"`
}

func (NexusUser) TableName

func (NexusUser) TableName() string

type NexusUserConfig

type NexusUserConfig nexus.User

func (*NexusUserConfig) Scan

func (config *NexusUserConfig) Scan(value interface{}) error

func (NexusUserConfig) Value

func (config NexusUserConfig) Value() (driver.Value, error)

type Notice

type Notice struct {
	BaseModel
	OrgID   uint64
	Content string
	Status  apistructs.NoticeStatus
	Creator string
}

Notice 平台公告

func (Notice) TableName

func (Notice) TableName() string

TableName 表名

type OSSSnapshot

type OSSSnapshot struct {
	OSSEndpoint string `json:"ossEndpoint,omitempty"`
	OSSBucket   string `json:"ossBucket,omitempty"`
}

type ProjectID

type ProjectID struct {
	ProjectID string `json:"project_id"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL