Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"basic.go",
"branch.go",
"config.go",
"job.go",
"mail.go",
"model.go",
"mr.go",
"project.go",
"statistics.go",
"sync.go",
"team.go",
"wechat.go",
],
importpath = "go-common/app/admin/ep/saga/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/ecode:go_default_library",
"//vendor/github.com/xanzy/go-gitlab:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,7 @@
package model
// QueryTypeItem ...
type QueryTypeItem struct {
Name interface{} `json:"name" validate:"required"`
Value interface{} `json:"value"`
}

View File

@@ -0,0 +1,61 @@
package model
import "time"
// BranchDeleted ...
const BranchDeleted = true
// BranchDiffWithRequest ...
type BranchDiffWithRequest struct {
ProjectID int `form:"project_id"`
Master string `form:"comparator"`
SortBy string `form:"sort_by"`
Branch string `form:"branch"`
Username string `form:"username"`
}
// BranchDiffWithResponse ...
type BranchDiffWithResponse struct {
Branch string `json:"branch"`
Behind int `json:"behind"`
Ahead int `json:"ahead"`
LatestSyncTime *time.Time `json:"latest_sync_time"`
LatestUpdateTime *time.Time `json:"latest_update_time"`
}
// CommitTreeNode ...
type CommitTreeNode struct {
CommitID string `json:"commit_id"`
Parents []string `json:"parents"`
CreatedAt *time.Time `json:"created_at"`
Author string `json:"author"`
}
// StatisticsBranches ...
type StatisticsBranches struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
CommitID string `json:"commit_id"`
BranchName string `json:"branch_name"`
Protected bool `json:"protected"`
Merged bool `json:"merged"`
DevelopersCanPush bool `json:"developers_can_push"`
DevelopersCanMerge bool `json:"developers_can_merge"`
IsDeleted bool `json:"is_deleted"`
}
// AggregateBranches ...
type AggregateBranches struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
BranchName string `json:"branch_name"`
BranchUserName string `json:"branch_user_name"`
BranchMaster string `json:"branch_master"`
Behind int `json:"behind"`
Ahead int `json:"ahead"`
LatestSyncTime *time.Time `json:"latest_sync_time"`
LatestUpdateTime *time.Time `json:"latest_update_time"`
IsDeleted bool `json:"is_deleted"`
}

View File

@@ -0,0 +1,166 @@
package model
import "time"
// CommonResp ...
type CommonResp struct {
Code int `json:"code"`
Message string `json:"message"`
Ttl int `json:"ttl"`
}
// BuildNewFile ...
type BuildNewFile struct {
ID int `json:"id"`
AppID int `json:"app_id"`
Name string `json:"name"`
Comment string `json:"comment"`
From int `json:"from"`
State int `json:"state"`
Mark string `json:"mark"`
Operator string `json:"operator"`
IsDelete int `json:"is_delete"`
NewCommon int `json:"new_common"`
Ctime int `json:"ctime"`
Mtime int `json:"mtime"`
}
// BuildFile ...
type BuildFile struct {
*BuildNewFile
LastConf *BuildNewFile `json:"last_conf"`
}
// ConfigData ...
type ConfigData struct {
Files []*BuildFile `json:"files"`
BuildFiles []*BuildFile `json:"build_files"`
BuildNewFile []*BuildNewFile `json:"build_new_file"`
}
// ConfigsParam ...
type ConfigsParam struct {
AppName string
TreeID int
Env string
Zone string
BuildId int
Build string
Token string
FilenameGo string
FilenameRunnerJava string
FilenameTokenJava string
FilenameRunnerCommon string
Increment int
Force int
AutoRequiredParams []string
RequiredParams []string
Comment *ConfigComment
}
// SagaConfigsParam ...
type SagaConfigsParam struct {
FileName string
AppName string
TreeID int
Env string
Zone string
BuildId int
Build string
Token string
Increment int
Force int
UserList []string
}
// ConfigComment ...
type ConfigComment struct {
CommentURL string
}
// TagUpdate ...
type TagUpdate struct {
Mark string `form:"mark"`
Names string `form:"names"`
}
// SvenResp ...
type SvenResp struct {
CommonResp
Data *ConfigData `json:"data"`
}
// ConfigValueResp ...
type ConfigValueResp struct {
CommonResp
Data *BuildNewFile `json:"data"`
}
// Config ...
type Config struct {
Property *Property
}
// Property ...
type Property struct {
Repos []*RepoConfig
}
// ConfigList ...
type ConfigList struct {
ProjectID int `json:"project_id" validate:"required"`
Configs []ConfigSagaItem `json:"configs"`
}
// ConfigSagaItem ...
type ConfigSagaItem struct {
Name string `json:"name" validate:"required"`
Value interface{} `json:"value"`
}
// SagaConfigLogResp ...
type SagaConfigLogResp struct {
Id int `form:"id" gorm:"column:id"`
Username string `form:"username" json:"username" gorm:"column:username"`
ProjectId int `form:"project_id" json:"project_id" gorm:"column:project_id"`
Content string `form:"content" json:"content" gorm:"column:content"`
Ctime time.Time `form:"ctime" json:"ctime" gorm:"column:ctime"`
Mtime time.Time `form:"mtime" json:"mtime" gorm:"column:mtime"`
UpdateUser string `form:"update_user" json:"update_user" gorm:"column:update_user"`
Status int `form:"status" json:"status" gorm:"column:status"` //1创建 2修改 3同步中 4同步完成 5同步失败
}
// UpdateConfigReq ...
type UpdateConfigReq struct {
Ids []int `json:"ids" validate:"required"`
ConfigID string `json:"config_id" validate:"required"`
ConfigName string `json:"config_name" validate:"required"`
Mark string `json:"mark" validate:"required"`
}
// OptionSagaItem ...
type OptionSagaItem struct {
ConfigSagaItem
CNName string `json:"cn_name"`
Remark string `json:"remark"`
Type string `json:"type"`
Require bool `json:"require"`
}
// RepoConfig ...
type RepoConfig struct {
URL string
Group string
Name string
GName string // gitlab仓库别名
Language string
AuthBranches []string // 鉴权分支
TargetBranches []string // 分支白名单
LockTimeout int32
MinReviewer int
RelatePipeline bool
DelayMerge bool
LimitAuth bool
AllowLabel string
SuperAuthUsers []string
}

View File

@@ -0,0 +1,44 @@
package model
import "time"
// ProjectJobRequest ...
type ProjectJobRequest struct {
ProjectID int `form:"project_id"`
Scope string `form:"state"`
User string `form:"user"`
Branch string `form:"branch"`
Machine string `form:"machine"`
StatisticsType int `form:"statistics_type"`
Username string `form:"username"`
}
// ProjectJobResp ...
type ProjectJobResp struct {
ProjectID int `json:"project_id"`
QueryDescription string `json:"query_description"`
TotalItem int `json:"total"`
State string `json:"state"`
DataInfo []*DateJobInfo `json:"data_info"`
}
// DateJobInfo ...
type DateJobInfo struct {
Date string `json:"date"`
JobTotal int `json:"total_num"`
StatusNum int `json:"status_num"`
PendingTime float64 `json:"pending_time"`
RunningTime float64 `json:"running_time"`
SlowestPendingJob []*ProjectJob `json:"slowest_pending_jobs"`
}
// ProjectJob ...
type ProjectJob struct {
Status string
User string
Branch string
Machine string
CreatedAt *time.Time
StartedAt *time.Time
FinishedAt *time.Time
}

View File

@@ -0,0 +1,27 @@
package model
// Mail def.
type Mail struct {
ToAddress []*MailAddress
Subject string
Body string
}
// MailAddress def.
type MailAddress struct {
Address string
Name string
}
// MailData def.
type MailData struct {
UserName string
SourceBranch string
TargetBranch string
Title string
Description string
URL string
Info string
PipelineStatus string
PipeStatus string
}

View File

@@ -0,0 +1,84 @@
package model
// pagination.
const (
DefaultPageSize = 10
DefaultPageNum = 1
)
// Pagination Pagination.
type Pagination struct {
PageSize int `form:"page_size"`
PageNum int `form:"page_num"`
}
// TeamParam struct for organization Info.
type TeamParam struct {
Department string `form:"department"`
Business string `form:"business"`
}
// EmptyReq params for request without params
type EmptyReq struct {
}
// EmptyResp resp for response without data
type EmptyResp struct {
}
// Task def
type Task struct {
ID int64 `json:"id,omitempty" gorm:"column:id"`
ProjID int `json:"proj_id,omitempty" gorm:"column:proj_id"`
EventType string `json:"event_type,omitempty" gorm:"column:event_type"`
Author string `json:"author,omitempty" gorm:"author"`
MRID int `json:"mr_id,omitempty" gorm:"column:mr_id"`
URL string `json:"url,omitempty" gorm:"column:url"`
Status int `json:"status,omitempty" gorm:"status"`
TaskDetails string `json:"task_details,omitempty" gorm:"task_details"`
SourceBranch string `json:"source_branch,omitempty" gorm:"source_branch"`
TargetBranch string `json:"target_branch,omitempty" gorm:"target_branch"`
Title string `json:"title,omitempty" gorm:"title"`
}
// TasksReq params for tasks
type TasksReq struct {
ProjID int `form:"proj_id" validate:"required"`
Statuses []int `form:"statuses,split" default:"3,4"` // 3 - running, 4 - waiting, 默认查运行中和等待的任务
}
// TasksResp resp for tasks
type TasksResp struct {
Tasks []*Task `json:"tasks,omitempty"`
}
// User User.
type User struct {
Name string `json:"username" gorm:"column:name"`
EMail string `json:"email" gorm:"column:email"`
}
// RequireVisibleUser def
type RequireVisibleUser struct {
UserName string
NickName string
}
// ContactInfo def
type ContactInfo struct {
ID string `json:"id,omitempty" gorm:"column:id"`
UserName string `json:"english_name" gorm:"column:user_name"`
UserID string `json:"userid" gorm:"column:user_id"`
NickName string `json:"name" gorm:"column:nick_name"`
VisibleSaga bool `json:"visible_saga" gorm:"column:visible_saga"`
}
// AlmostEqual return the compare result with fields
func (contact *ContactInfo) AlmostEqual(other *ContactInfo) bool {
if contact.UserID == other.UserID &&
contact.UserName == other.UserName &&
contact.NickName == other.NickName {
return true
}
return false
}

View File

@@ -0,0 +1,51 @@
package model
import "time"
// ProjectMrReportReq ...
type ProjectMrReportReq struct {
ProjectID int `form:"project_id"`
Member string `form:"member"`
Username string `form:"username"`
}
// ProjectMrReportResp ...
type ProjectMrReportResp struct {
ChangeAdd int `json:"change_add"`
ChangeDel int `json:"change_del"`
MrCount int `json:"mr_count"`
StateCount int `json:"merged_count"`
Discussion int `json:"discussion"`
Resolve int `json:"resolved_discussion"`
AverageMerge string `json:"average_merge_time"`
Reviewers []string `json:"reviewer"`
SpentTime string `json:"spent_time"`
ReviewerOther []string `json:"reviewer_other"`
ReviewChangeAdd int `json:"review_add"`
ReviewChangeDel int `json:"review_del"`
ReviewTotalTime string `json:"review_total_time"`
}
// MrReviewer ...
type MrReviewer struct {
ID int `json:"id"`
Name string `json:"name"`
FinishedAt *time.Time `json:"finished_at"`
UserType string `json:"type"`
// SpentTime 其实是反应时间+review时间
SpentTime int `json:"spent_time"`
}
// MrInfo ...
type MrInfo struct {
ProjectID int `json:"project_id"`
MrID int `json:"mr_id"`
State string `json:"state"`
SpentTime int `json:"spent_time"`
Author string `json:"author"`
ChangeAdd int `json:"change_add"`
ChangeDel int `json:"change_del"`
TotalDiscussion int `json:"total_discussion"`
SolvedDiscussion int `json:"solved_discussion"`
Reviewers []*MrReviewer `json:"reviewers"`
}

View File

@@ -0,0 +1,87 @@
package model
import "go-common/library/ecode"
// ProjectInfo def
type ProjectInfo struct {
ProjectID int `json:"project_id" gorm:"column:project_id"`
Name string `json:"name" gorm:"column:name"`
Description string `json:"description" gorm:"column:description"`
WebURL string `json:"web_url" gorm:"column:web_url"`
Repo string `json:"repo" gorm:"column:repo"`
DefaultBranch string `json:"default_branch" gorm:"column:default_branch"`
Owner string `json:"owner" gorm:"column:owner"`
SpaceName string `json:"namespace_name" gorm:"column:namespace_name"`
SpaceKind string `json:"namespace_kind" gorm:"column:namespace_kind"`
Saga bool `json:"saga" gorm:"column:saga"`
Runner bool `json:"runner" gorm:"column:runner"`
Department string `json:"department" gorm:"column:department"`
Business string `json:"business" gorm:"column:business"`
Language string `json:"language" gorm:"column:language"`
}
// ProjectInfoRequest Project Info Request.
type ProjectInfoRequest struct {
Pagination
TeamParam
Username string `form:"username"`
Name string `form:"name"`
}
// ProjectInfoResp ...
type ProjectInfoResp struct {
Total int `json:"total"`
Saga int `json:"saga"`
Runner int `json:"runner"`
SagaScale int `json:"saga_scale"`
RunnerScale int `json:"runner_scale"`
PageNum int `json:"page_num"`
PageSize int `json:"page_size"`
ProjectInfo []*MyProjectInfo `json:"ProjectInfo"`
}
// FavoriteProjectsResp resp for favorite projects
type FavoriteProjectsResp struct {
Total int `json:"total"`
Pagination
Projects []*MyProjectInfo `json:"projects,omitempty"`
}
// ProjectFavorite def
type ProjectFavorite struct {
ID int64 `json:"id,omitempty" gorm:"column:id"`
UserName string `json:"user_name,omitempty" gorm:"column:user_name"`
ProjID int `json:"proj_id,omitempty" gorm:"column:proj_id"`
}
// EditFavoriteReq params for edit favorite
type EditFavoriteReq struct {
ProjID int `json:"proj_id" validate:"required"`
Star bool `json:"star"`
}
// MyProjectInfo mask as star
type MyProjectInfo struct {
*ProjectInfo
Star bool `json:"is_star"`
}
// ProjectsInfoResp resp for query projects with start mark
type ProjectsInfoResp struct {
Projects []*MyProjectInfo `json:"projects"`
}
// Verify verify the value of pageNum and pageSize.
func (p *Pagination) Verify() error {
if p.PageNum < 0 {
return ecode.MerlinIllegalPageNumErr
} else if p.PageNum == 0 {
p.PageNum = DefaultPageNum
}
if p.PageSize < 0 {
return ecode.MerlinIllegalPageSizeErr
} else if p.PageSize == 0 {
p.PageSize = DefaultPageSize
}
return nil
}

View File

@@ -0,0 +1,195 @@
package model
// ExpiredOneDay ...
const ExpiredOneDay = 86400
// Status ...
const (
StatusCancel = "cancel"
StatusMerged = "merged"
StatusClosed = "closed"
)
// number per year.
const (
MonthNumPerYear = 12
DayNumPerYear = 365
DayNumPerWeek = 7
DayNumPerMonth = 30
)
// query type.
const (
LastYearPerMonth = iota
LastMonthPerDay
LastYearPerDay
LastWeekPerDay
)
// query type note.
const (
LastYearPerMonthNote = "最近一年每月数量"
LastMonthPerDayNote = "上一月每天数量"
LastYearPerDayNote = "最近一年每天数量"
)
// query object type.
const (
ObjectMR = "mr"
ObjectCommit = "commit"
ObjectSaga = "saga"
ObjectRunner = "runner"
)
// KeyTypeConst ...
var KeyTypeConst = map[int]string{
0: "LastYearPerMonth",
1: "LastMonthPerDay",
2: "LastYearPerDay",
3: "LastWeekPerDay",
}
// CommitRequest ...
type CommitRequest struct {
TeamParam
Since string `form:"since"`
Until string `form:"until"`
Username string `form:"username"`
}
// ProjectCommit ...
type ProjectCommit struct {
ProjectID int `json:"project_id"`
Name string `json:"name"`
CommitNum int `json:"commit_num"`
}
// CommitResp ...
type CommitResp struct {
Total int `json:"total"`
ProjectCommit []*ProjectCommit `json:"commit_per_project"`
}
// ProjectDataReq ...
type ProjectDataReq struct {
ProjectID int `form:"project_id" validate:"required"`
ProjectName string `form:"project_name"`
QueryType int `form:"query_type"`
Username string `form:"username"`
}
// ProjectDataResp ...
type ProjectDataResp struct {
ProjectName string `json:"project_name"`
QueryDes string `json:"query_description"`
Total int `json:"total"`
Data []*DataWithTime `json:"data_info"`
}
// TeamDataRequest ...
type TeamDataRequest struct {
TeamParam
QueryType int `form:"query_type"`
Username string `form:"username"`
}
// TeamDataResp ...
type TeamDataResp struct {
Department string `json:"department"`
Business string `json:"business"`
QueryDes string `json:"query_description"`
Total int `json:"total"`
Data []*DataWithTime `json:"data_info"`
}
// DataWithTime ...
type DataWithTime struct {
TotalItem int `json:"total_item"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
// PipelineDataTime ...
type PipelineDataTime struct {
TotalItem int `json:"total_item"`
SuccessItem int `json:"success_item"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
// PipelineDataResp ...
type PipelineDataResp struct {
Department string `json:"department"`
Business string `json:"business"`
QueryDes string `json:"query_description"`
Total int `json:"total"`
SuccessNum int `json:"success_num"`
SuccessScale int `json:"success_scale"`
Data []*PipelineDataTime `json:"data_info"`
}
// PipelineDataReq ...
type PipelineDataReq struct {
ProjectID int `form:"project_id" validate:"required"`
ProjectName string `form:"project_name"`
Branch string `form:"branch"`
State string `form:"state"`
User string `form:"user"`
Type int `form:"query_type"` //0 最近一年每月数量;1 上一月每天数量;2 最近一年每天数量
StatisticsType int `form:"statistics_type"`
Username string `form:"username"`
}
// PipelineDataAvgResp ...
type PipelineDataAvgResp struct {
ProjectName string `json:"project_name"`
QueryDes string `json:"query_description"`
Status string `json:"status"`
Total int `json:"total"`
TotalStatus int `json:"total_status"`
AvgDurationTime float64 `json:"avg_duration_time"`
AvgPendingTime float64 `json:"avg_pending_time"`
AvgRunningTime float64 `json:"avg_running_time"`
Data []*PipelineDataAvg `json:"data_info"`
}
// PipelineDataAvg ...
type PipelineDataAvg struct {
TotalItem int `json:"total_item"`
TotalStatusItem int `json:"total_status_item"`
AvgDurationTime float64 `json:"avg_total_time"`
MaxDurationTime float64 `json:"max_duration_time"`
MinDurationTime float64 `json:"min_duration_time"`
AvgPendingTime float64 `json:"avg_pending_time"`
MaxPendingTime float64 `json:"max_pending_time"`
MinPendingTime float64 `json:"min_pending_time"`
AvgRunningTime float64 `json:"avg_running_time"`
MaxRunningTime float64 `json:"max_running_time"`
MinRunningTime float64 `json:"min_running_time"`
StartTime string `json:"start_time"`
EndTime string `json:"end_time"`
}
// PipelineTime ...
type PipelineTime struct {
PendingMax float64
PendingMin float64
RunningMax float64
RunningMin float64
DurationMax float64
DurationMin float64
PendingList []float64
RunningList []float64
DurationList []float64
}
// AlertPipeline ...
type AlertPipeline struct {
ProjectName string
ProjectID int
RunningTimeout int
RunningRate int
RunningThreshold int
PendingTimeout int
PendingThreshold int
}

View File

@@ -0,0 +1,293 @@
package model
import (
"time"
"github.com/xanzy/go-gitlab"
)
// DatabaseErrorText ...
const (
DatabaseErrorText = "Incorrect string value"
DatabaseMaxLenthErrorText = "Data too long for column"
MessageMaxLen = 2048
JsonMarshalErrorText = "XXXXX"
)
// DataType ...
const (
DataTypePipeline = "pipeline"
DataTypeJob = "job"
DataTypeCommit = "commit"
DataTypeMR = "MR"
DataTypeBranch = "Branch"
)
// FailData ...
type FailData struct {
ChildID int
ChildIDStr string
SunID int
}
// SyncResult ...
type SyncResult struct {
TotalPage int
TotalNum int
FailData []*FailData
}
// StatisticsCommits ...
type StatisticsCommits struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
CommitID string `json:"commit_id"`
ProjectID int `json:"project_id" gorm:"column:project_id"`
ProjectName string `json:"project_name"`
ShortID string `json:"short_id"`
Title string `json:"title"`
AuthorName string `json:"author_name"`
AuthoredDate *time.Time `json:"authored_date"`
CommitterName string `json:"committer_name"`
CommittedDate *time.Time `json:"committed_date"`
CreatedAt *time.Time `json:"created_at"`
Message string `json:"message"`
ParentIDs string `json:"parent_ids"`
StatsAdditions int `json:"stats_additions"`
StatsDeletions int `json:"stats_deletions"`
Status string `json:"status" default:""`
}
// StatisticsIssues ...
type StatisticsIssues struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
IssueID int `json:"issue_id"`
IssueIID int `json:"issue_iid" gorm:"column:issue_iid"`
MilestoneID int `json:"milestone_id"`
AuthorID int `json:"author_id"`
AuthorName string `json:"author_name"`
Description string `json:"description"`
State string `json:"state"`
Assignees string `json:"assignees"`
AssigneeID int `json:"assignee_id"`
AssigneeName string `json:"assignee_name"`
Upvotes int `json:"upvotes"`
Downvotes int `json:"downvotes"`
Labels string `json:"labels"`
Title string `json:"title"`
UpdatedAt *time.Time `json:"updated_at"`
CreatedAt *time.Time `json:"created_at"`
ClosedAt *time.Time `json:"closed_at"`
Subscribed bool `json:"subscribed"`
UserNotesCount int `json:"user_notes_count"`
DueDate *gitlab.ISOTime `json:"due_date"`
WebURL string `json:"web_url"`
TimeStats string `json:"time_stats"`
Confidential bool `json:"confidential"`
Weight int `json:"weight"`
DiscussionLocked bool `json:"discussion_locked"`
IssueLinkID int `json:"issue_link_id"`
}
// StatisticsRunners ...
type StatisticsRunners struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
RunnerID int `json:"runner_id"`
Description string `json:"description"`
Active bool `json:"active"`
IsShared bool `json:"is_shared"`
IPAddress string `json:"ip_address"`
Name string `json:"name"`
Online bool `json:"online"`
Status string `json:"status"`
Token string `json:"token"`
}
// StatisticsJobs ...
type StatisticsJobs struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
CommitID string `json:"commit_id"`
CreatedAt *time.Time `json:"created_at"`
Coverage float64 `json:"coverage"`
ArtifactsFile string `json:"artifacts_file"`
FinishedAt *time.Time `json:"finished_at"`
JobID int `json:"job_id"`
Name string `json:"name"`
Ref string `json:"ref"`
RunnerID int `json:"runner_id"`
RunnerDescription string `json:"runner_description"`
Stage string `json:"stage"`
StartedAt *time.Time `json:"started_at"`
Status string `json:"status"`
Tag bool `json:"tag"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
WebURL string `json:"web_url"`
}
// StatisticsMrs ...
type StatisticsMrs struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
MRID int `json:"mr_id"`
MRIID int `json:"mr_iid" gorm:"column:mr_iid"`
TargetBranch string `json:"target_branch"`
SourceBranch string `json:"source_branch"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
Title string `json:"title"`
State string `json:"state"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
Upvotes int `json:"upvotes"`
Downvotes int `json:"downvotes"`
AuthorID int `json:"author_id"`
AuthorName string `json:"author_name"`
AssigneeID int `json:"assignee_id"`
AssigneeName string `json:"assignee_name"`
SourceProjectID int `json:"source_project_id"`
TargetProjectID int `json:"target_project_id"`
Labels string `json:"labels"`
Description string `json:"description"`
WorkInProgress bool `json:"work_in_progress"`
MilestoneID int `json:"milestone_id"`
MergeWhenPipelineSucceeds bool `json:"merge_when_pipeline_succeeds"`
MergeStatus string `json:"merge_status"`
MergedByID int `json:"merged_by_id"`
MergedByName string `json:"merged_by_name"`
MergedAt *time.Time `json:"merged_at"`
ClosedByID int `json:"closed_by_id"`
ClosedAt *time.Time `json:"closed_at"`
Subscribed bool `json:"subscribed"`
SHA string `json:"sha"`
MergeCommitSHA string `json:"merge_commit_sha"`
UserNotesCount int `json:"user_notes_count"`
ChangesCount string `json:"changes_count"`
ShouldRemoveSourceBranch bool `json:"should_remove_source_branch"`
ForceRemoveSourceBranch bool `json:"force_remove_source_branch"`
WebURL string `json:"web_url"`
DiscussionLocked bool `json:"discussion_locked"`
Changes string `json:"changes"`
TimeStatsHumanTimeEstimate string `json:"time_stats_human_time_estimate"`
TimeStatsHumanTotalTimeSpent string `json:"time_stats_human_total_time_spent"`
TimeStatsTimeEstimate int `json:"time_stats_time_estimate"`
TimeStatsTotalTimeSpent int `json:"time_stats_total_time_spent"`
Squash bool `json:"squash"`
PipelineID int `json:"pipeline_id"`
ChangeAdd int `json:"change_add"`
ChangeDel int `json:"change_del"`
TotalDiscussion int `json:"total_discussion"`
SolvedDiscussion int `json:"solved_discussion"`
}
// AggregateMrReviewer ...
type AggregateMrReviewer struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
Title string `json:"title"`
WebUrl string `json:"web_url"`
AuthorName string `json:"author_name"`
ReviewerID int `json:"reviewer_id"`
ReviewerName string `json:"reviewer_name"`
ReviewType string `json:"review_type"`
ReviewID int `json:"review_id"`
ReviewCommand string `json:"review_command"`
CreatedAt *time.Time `json:"created_at"`
UserType string `json:"type"`
ApproveTime int `json:"approve_time"` // SpentTime 其实是反应时间+review时间
MergeTime int `json:"merge_time"`
}
// StatisticsPipeline ...
type StatisticsPipeline struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
PipelineID int `json:"pipeline_id" gorm:"column:pipeline_id"`
ProjectName string `json:"project_name"`
ProjectID int `json:"project_id" gorm:"column:project_id"`
Status string `json:"status" gorm:"column:status" default:""`
Ref string `json:"ref" gorm:"column:ref"`
Tag bool `json:"tag" gorm:"column:tag"`
User string `json:"user" gorm:"column:user"`
UpdatedAt *time.Time `json:"updated_at" gorm:"column:updated_at"`
CreatedAt *time.Time `json:"created_at" gorm:"column:created_at"`
StartedAt *time.Time `json:"started_at" gorm:"column:started_at"`
FinishedAt *time.Time `json:"finished_at" gorm:"column:finished_at"`
CommittedAt *time.Time `json:"committed_at" gorm:"column:committed_at"`
Duration int `json:"duration" gorm:"column:duration"`
Coverage string `json:"coverage" gorm:"column:coverage"`
DurationTime int `json:"duration_time"`
}
// StatisticsNotes ...
type StatisticsNotes struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
IssueIID int `json:"issue_iid" gorm:"column:issue_iid"`
NoteID int `json:"note_id"`
Body string `json:"body"`
Attachment string `json:"attachment"`
Title string `json:"title"`
FileName string `json:"file_name"`
AuthorID int `json:"author_id"`
AuthorName string `json:"author_name"`
System bool `json:"system"`
ExpiresAt *time.Time `json:"expires_at"`
UpdatedAt *time.Time `json:"updated_at"`
CreatedAt *time.Time `json:"created_at"`
NoteableID int `json:"noteable_id"`
NoteableType string `json:"noteable_type"`
Position string `json:"position"`
Resolvable bool `json:"resolvable"`
Resolved bool `json:"resolved"`
ResolvedByID int `json:"resolved_by_id"`
ResolvedByName string `json:"resolved_by_name"`
NoteableIID int `json:"noteable_iid" gorm:"column:noteable_iid"`
}
// StatisticsMembers ...
type StatisticsMembers struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
MemberID int `json:"member_id"`
Username string `json:"username"`
Email string `json:"email"`
Name string `json:"name"`
State string `json:"state"`
CreatedAt *time.Time `json:"created_at"`
AccessLevel int `json:"access_level"`
}
// StatisticsMRAwardEmojis ...
type StatisticsMRAwardEmojis struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
AwardEmojiID int `json:"award_emoji_id"`
Name string `json:"name"`
UserID int `json:"user_id"`
UserName string `json:"user_name"`
CreatedAt *time.Time `json:"created_at"`
UpdatedAt *time.Time `json:"updated_at"`
AwardableID int `json:"awardable_id"`
AwardableType string `json:"awardable_type"`
}
// StatisticsDiscussions ...
type StatisticsDiscussions struct {
ID int `json:"id" gorm:"AUTO_INCREMENT;primary_key;" form:"id"`
ProjectID int `json:"project_id"`
ProjectName string `json:"project_name"`
MrIID int `json:"mr_iid" gorm:"column:mr_iid"`
DiscussionID string `json:"discussion_id"`
IndividualNote bool `json:"individual_note"`
Notes string `json:"notes"`
}

View File

@@ -0,0 +1,24 @@
package model
// PairKey def
type PairKey struct {
Label string `json:"label"`
Value string `json:"value"`
}
// TeamInfoResp def
type TeamInfoResp struct {
Department []*PairKey `json:"department"`
Business []*PairKey `json:"business"`
}
// Developer def
type Developer struct {
Department string `json:"department"`
Total int `json:"total"`
Android int `json:"android"`
Ios int `json:"ios"`
Web int `json:"web"`
Service int `json:"service"`
Other int `json:"other"`
}

View File

@@ -0,0 +1,191 @@
package model
import "time"
// MaxWechatLen ...
const MaxWechatLen = 254 //企业微信内容最大长度
// AppConfig def
type AppConfig struct {
AppID int // 企业微信SAGA应用的appId
AppSecret string // 企业微信SAGA应用的secret
}
// Notification def
type Notification struct {
ToUser string `json:"touser"`
ToParty string `json:"toparty"`
ToTag string `json:"totag"`
MsgType string `json:"msgtype"`
AgentID int `json:"agentid"`
}
// Text def
type Text struct {
Content string `json:"content"`
}
// TxtNotification 文本消息
type TxtNotification struct {
Notification
Body Text `json:"text"`
Safe int `json:"safe"`
}
// AllowUserInfo 应用可见名单列表
type AllowUserInfo struct {
Users []*UserInfo `json:"user"`
}
// UserInfo only contain userid now
type UserInfo struct {
UserID string `json:"userid"`
}
// QueryContactLogRequest Query Contact Log Request.
type QueryContactLogRequest struct {
Pagination
UserID int64 `form:"user_id"`
UserName string `form:"user_name"`
OperateUser string `form:"operate_user"`
OperateType string `form:"operate_type"`
}
// QueryContactRequest Query Contact Log Request.
type QueryContactRequest struct {
Pagination
}
// AboundContactLog Abound Contact Log.
type AboundContactLog struct {
ContactLog
Name string `json:"machine_name"`
}
// ContactLog Contact Log.
type ContactLog struct {
ID int64 `json:"-" gorm:"column:id"`
Username string `json:"username" gorm:"column:username"`
MachineID int64 `json:"machine_id" gorm:"column:machine_id"`
OperateType string `json:"operate_type" gorm:"column:operation_type"`
OperateResult string `json:"operate_result" gorm:"column:operation_result"`
OperateTime time.Time `json:"operate_time" gorm:"column:ctime;default:current_timestamp"`
UTime time.Time `json:"-" gorm:"column:mtime;default:current_timestamp on update current_timestamp"`
Type int `json:"type" gorm:"column:type"`
}
// Contact Contact info.
type Contact struct {
ID int64 `json:"-" gorm:"column:id"`
Username string `json:"user_name" gorm:"column:user_name"`
UserID string `json:"user_id" gorm:"column:user_id"`
}
// PaginateContactLog Paginate Contact Log.
type PaginateContactLog struct {
Total int64 `json:"total"`
PageNum int `json:"page_num"`
PageSize int `json:"page_size"`
MachineLogs []*AboundContactLog `json:"machine_logs"`
}
// PaginateContact Paginate Contact.
type PaginateContact struct {
Total int64 `json:"total"`
PageNum int `json:"page_num"`
PageSize int `json:"page_size"`
Contacts []*ContactInfo `json:"contacts"`
}
// CreateChatReq ...
type CreateChatReq struct {
Name string `json:"name" validate:"required"`
Owner string `json:"owner" validate:"required"`
UserList []string `json:"userlist" validate:"required"`
ChatID string `json:"chatid" validate:"required"`
}
// WechatCreateLog ...
type WechatCreateLog struct {
ID int `json:"id" gorm:"column:id"`
Name string `json:"name" gorm:"column:name"`
Owner string `json:"owner" gorm:"column:owner"`
ChatID string `json:"chatid" gorm:"column:chatid"`
Cuser string `json:"cuser" gorm:"column:cuser"`
Ctime time.Time `form:"ctime" json:"ctime" gorm:"column:ctime"`
Status int `form:"status" json:"status" gorm:"column:status"` //1创建 2修改 3同步中 4同步完成 5同步失败
}
// WechatChatLog ...
type WechatChatLog struct {
ID int `json:"id" gorm:"column:id"`
ChatID string `json:"chatid" gorm:"column:chatid"`
MsgType string `json:"msgtype" gorm:"column:msgtype"`
Content string `json:"content" gorm:"column:content"`
Safe int `json:"safe" gorm:"column:safe"`
Status int `form:"status" json:"status" gorm:"column:status"` //1成功 0失败
}
// WechatMessageLog ...
type WechatMessageLog struct {
ID int `json:"id" gorm:"column:id"`
Touser string `json:"touser" gorm:"column:touser"`
Content string `json:"content" gorm:"column:content"`
Status int `form:"status" json:"status" gorm:"column:status"` //1成功 0失败
}
// ChatResp ...
type ChatResp struct {
ErrCode int `json:"errcode"`
ErrMsg string `json:"errmsg"`
}
// CreateChatResp ...
type CreateChatResp struct {
*ChatResp
ChatID string `json:"chatid"`
}
// CreateChatLog ...
type CreateChatLog struct {
*WechatCreateLog
Buttons []string `json:"buttons"`
}
// CreateChatLogResp ...
type CreateChatLogResp struct {
Total int `json:"total"`
*Pagination
Logs []*CreateChatLog `json:"logs,omitempty"`
}
// GetChatResp ...
type GetChatResp struct {
*ChatResp
ChatInfo *CreateChatReq `json:"chat_info"`
}
// SendChatReq ...
type SendChatReq struct {
ChatID string `json:"chatid"`
MsgType string `json:"msgtype"`
Text struct {
Content string `json:"content"`
} `json:"text"`
Safe int `json:"safe"`
}
// SendMessageReq ...
type SendMessageReq struct {
Touser []string `json:"touser"`
Content string `json:"content"`
}
// UpdateChatReq ...
type UpdateChatReq struct {
ChatID string `json:"chatid"`
Name string `json:"name"`
Owner string `json:"owner"`
AddUserList []string `json:"add_user_list"`
DelUserList []string `json:"del_user_list"`
}