Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,37 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"audit_log.go",
"report.go",
"search.go",
"search2.go",
],
importpath = "go-common/app/admin/main/workflow/model/search",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/workflow/model:go_default_library",
"//library/xstr: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,151 @@
package search
import (
"fmt"
"net/url"
"strconv"
"strings"
"go-common/app/admin/main/workflow/model"
"go-common/library/xstr"
)
// AuditLogGroupSearchCond is the common condition model to send challenge search request
type AuditLogGroupSearchCond struct {
Group []string
UNames []string
Uids []int64
Businesses []int64
Type []int64
Oids []int64
Actions []string
CTimeFrom string
CTimeTo string
Int0 []int64
Int0From int64
Int0To int64
Int1 []int64
Int1From int64
Int1To int64
Int2 []int64
Int2From int64
Int2To int64
Str0 string
Str1 string
Str2 string
PN int64
PS int64
Order string
Sort string
}
// AuditLogSearchResult is the model to parse search challenge common result
type AuditLogSearchResult struct {
Code int `json:"code"`
Message string `json:"message"`
TTL int32 `json:"ttl"`
Data struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page model.Page `json:"page"`
Result []struct {
Action string `json:"action"`
Business int64 `json:"business"`
CTime string `json:"ctime"`
ExtraData string `json:"extra_data"`
Str0 string `json:"str_0"`
Str1 string `json:"str_1"`
Str2 string `json:"str_2"`
Oid int64 `json:"oid"`
Type int64 `json:"type"`
UID int64 `json:"uid"`
UName string `json:"uname"`
} `json:"result"`
} `json:"data"`
}
// ArchiveAuditLogExtra archive audit log extra message
type ArchiveAuditLogExtra struct {
Content struct {
ID int64 `json:"id"` //oid
UID int64 `json:"uid"`
UName string `json:"uname"`
Note string `json:"note"`
Content string `json:"content"`
} `json:"content"`
Diff string `json:"diff"`
}
// Query make query for AuditLogGroupSearchCond
func (alsc *AuditLogGroupSearchCond) Query() (uv url.Values) {
uv = url.Values{}
// AppID
uv.Set("appid", _auditLogSrhComID)
// Common
uv.Set("pn", "1")
uv.Set("ps", "20")
uv.Set("order", "ctime")
uv.Set("sort", "desc")
if alsc.PN != 0 {
uv.Set("pn", fmt.Sprintf("%d", alsc.PN))
}
if alsc.PS != 0 {
uv.Set("ps", fmt.Sprintf("%d", alsc.PS))
}
if alsc.Order != "" {
uv.Set("order", alsc.Order)
}
if alsc.Sort != "" {
uv.Set("sort", alsc.Sort)
}
if alsc.Int0From != 0 {
uv.Set("int_0_from", strconv.FormatInt(alsc.Int0From, 10))
}
if alsc.Int0To != 0 {
uv.Set("int_0_to", strconv.FormatInt(alsc.Int0To, 10))
}
if alsc.Int1From != 0 {
uv.Set("int_1_from", strconv.FormatInt(alsc.Int1From, 10))
}
if alsc.Int1To != 0 {
uv.Set("int_1_to", strconv.FormatInt(alsc.Int1To, 10))
}
if alsc.Int2From != 0 {
uv.Set("int_2_from", strconv.FormatInt(alsc.Int2From, 10))
}
if alsc.Int2To != 0 {
uv.Set("int_2_to", strconv.FormatInt(alsc.Int2To, 10))
}
// Group related
uv.Set("group", strings.Join(alsc.Group, ","))
uv.Set("uname", strings.Join(alsc.UNames, ","))
uv.Set("uid", xstr.JoinInts(alsc.Uids))
uv.Set("business", xstr.JoinInts(alsc.Businesses))
uv.Set("type", xstr.JoinInts(alsc.Type))
uv.Set("oid", xstr.JoinInts(alsc.Oids))
uv.Set("action", strings.Join(alsc.Actions, ","))
uv.Set("ctime_from", alsc.CTimeFrom)
uv.Set("ctime_to", alsc.CTimeTo)
uv.Set("int_0", xstr.JoinInts(alsc.Int0))
uv.Set("int_1", xstr.JoinInts(alsc.Int1))
uv.Set("int_2", xstr.JoinInts(alsc.Int2))
uv.Set("str_0", alsc.Str0)
uv.Set("str_1", alsc.Str1)
uv.Set("str_2", alsc.Str2)
return uv
}

View File

@@ -0,0 +1,75 @@
package search
import (
"time"
"go-common/app/admin/main/workflow/model"
)
// business id const
const (
Archive = 3
Workflow = 11
LogAuditAction = "log_audit"
_auditLogSrhComID = "log_audit_group"
//// IndexTypeYear index by year
//IndexTypeYear indexType = "year"
//// IndexTypeMonth index by month
//IndexTypeMonth indexType = "month"
//// IndexTypeWeek index by week
//IndexTypeWeek indexType = "week"
//// IndexTypeDay index by day
//IndexTypeDay indexType = "day"
)
// AuditReportSearchCond .
type AuditReportSearchCond struct {
AppID string `json:"app_id"`
Fields []string `json:"fields"`
IndexTimeType string `json:"index_time_type"`
IndexTimeFrom time.Time `json:"index_time_from"`
IndexTimeEnd time.Time `json:"index_time_end"`
Business int `json:"business"`
UName string `json:"uname"`
UID []int64 `json:"uid"`
Oid []int64 `json:"oid"`
Type []int `json:"type"`
Action string `json:"action"`
CTime string `json:"ctime"`
Order string `json:"order"`
Sort string `json:"sort"`
Int0 []int64 `json:"int_0"`
Int1 []int64 `json:"int_1"`
Int2 []int64 `json:"int_2"`
Str0 string `json:"str_0"`
Str1 string `json:"str_1"`
Str2 string `json:"str_2"`
Group string `json:"group"`
Distinct string `json:"distinct"`
}
// AuditLogSearchCommonResult .
type AuditLogSearchCommonResult struct {
Page *model.Page `json:"page"`
Result []*ReportLog `json:"result"`
}
// ReportLog .
type ReportLog struct {
Action string `json:"action"`
Business int64 `json:"business"`
CTime string `json:"ctime"`
ExtraData string `json:"extra_data"`
Str0 string `json:"str_0"`
Str1 string `json:"str_1"`
Str2 string `json:"str_2"`
Int0 int64 `json:"int_0"`
Int1 int64 `json:"int_1"`
Int2 int64 `json:"int_2"`
Int3 int64 `json:"int_3"`
Oid int64 `json:"oid"`
Type int64 `json:"type"`
UID int64 `json:"uid"`
UName string `json:"uname"`
}

View File

@@ -0,0 +1,92 @@
package search
import (
"go-common/app/admin/main/workflow/model"
)
// ChallSearchCond is the condition model to send challenge search request
type ChallSearchCond struct {
// Using int64 directly
Cids []int64
Gids []int64
Mids []int64
Tids []int64
TagRounds []int64
States []int64
Keyword string
CTimeFrom string
CTimeTo string
PN int64
PS int64
Order string
Sort string
}
// FormatState .
func (cc *ChallSearchCond) FormatState() {
for _, st := range cc.States {
if st == model.QueueStateBefore {
cc.States = append(cc.States, model.QueueState)
}
}
}
// ArcSearchResult is the model to parse search archive appeal result
type ArcSearchResult struct {
Code int32 `json:"code"`
Message string `json:"message"`
TTL int32 `json:"ttl"`
Data struct {
Page *model.Page `json:"page"`
Result []GroupSearchCommonData `json:"result"`
} `json:"data"`
}
// ChallSearchResult is the model to parse search challenge result
type ChallSearchResult struct {
Code int32 `json:"code"`
Message string `json:"message"`
TTL int32 `json:"ttl"`
Data struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
} `json:"page"`
Result []struct {
ID int64 `json:"id"`
Gid int64 `json:"gid"`
Mid int64 `json:"mid"`
Tid int64 `json:"tid"`
CTime string `json:"ctime"`
} `json:"result"`
} `json:"data"`
}
// ChallListPage is the model for challenge list result
type ChallListPage struct {
Items []*model.Chall `json:"items"`
TotalCount int32 `json:"total_count"`
PN int32 `json:"pn"`
PS int32 `json:"ps"`
}
// ChallListPageCommon model for challenge/list2 result
type ChallListPageCommon struct {
Items []*model.Chall `json:"items"`
Page *model.Page `json:"page"`
}
// ChallCount is the model for challenge count result
type ChallCount struct {
TotalCount int64 `json:"total_count"`
BusinessCount map[int8]int64 `json:"business_count"`
}

View File

@@ -0,0 +1,148 @@
package search
import (
"go-common/app/admin/main/workflow/model"
)
// search appid
const (
GroupSrhComID = "workflow_group_common"
ChallSrhComID = "workflow_chall_common"
)
// GroupSearchCommonCond is the common condition model to send group search request
type GroupSearchCommonCond struct {
Fields []string
Business int8
IDs []int64
Oids []string
Tids []int64
States []int8
Mids []int64
Rounds []int64
TypeIDs []int64
FID []int64
RID []int8
EID []int64
TagRounds []int64
FirstUserTid []int64
ReportMID []int64 // report_mid
AuthorMID []int64 // mid
KWPriority bool
KW []string
KWFields []string
CTimeFrom string
CTimeTo string
PN int64
PS int64
Order string
Sort string
}
// GroupSearchCommonData .
type GroupSearchCommonData struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Mid int64 `json:"mid"`
TypeID int64 `json:"typeid"`
Eid int64 `json:"eid"`
FirstUserTid int64 `json:"first_user_tid"`
}
// GroupSearchCommonResp .
type GroupSearchCommonResp struct {
Page *model.Page `json:"page"`
Result []*GroupSearchCommonData `json:"result"`
}
// ChallSearchCommonCond is the common condition model to send challenge search request
type ChallSearchCommonCond struct {
// Using int64 directly
Fields []string
Business int8
IDs []int64
Gids []int64
Oids []string
Tids []int64
Mids []int64
ObjectMids []int64
Rounds []int64
TypeIDs []int64
AssigneeAdminIDs []int64
AssigneeAdminNames []string
AdminIDs []int64
States []int64
BusinessStates []int64
CTimeFrom string
CTimeTo string
KW []string
KWFields []string
Distinct []string
PN int
PS int
Order string
Sort string
}
// FormatState transform add state in queue into search cond
func (csc *ChallSearchCommonCond) FormatState() {
for _, busState := range csc.BusinessStates {
if busState == model.QueueBusinessStateBefore {
csc.BusinessStates = append(csc.BusinessStates, model.QueueBusinessState)
}
}
for _, st := range csc.States {
if st == model.QueueStateBefore {
csc.States = append(csc.States, model.QueueState)
}
}
}
// ChallSearchCommonData .
type ChallSearchCommonData struct {
ID int64 `json:"id"`
Oid int64 `json:"oid"`
Mid int64 `json:"mid"`
Gid int64 `json:"gid"`
Tid int64 `json:"tid"`
CountTid int64 `json:"count_tid"`
State interface{} `json:"state"` //兼容 int string
Title string `json:"title"`
Business int8 `json:"business"`
TypeID int64 `json:"typeid"`
CTime string `json:"ctime"`
}
// ChallSearchCommonResp .
type ChallSearchCommonResp struct {
Page *model.Page `json:"page"`
Result []*ChallSearchCommonData `json:"result"`
}
// ChallReleaseUpSearchCond .
type ChallReleaseUpSearchCond struct {
Cids []int64 `json:"id"`
AssigneeAdminID int64 `json:"assignee_adminid"`
BusinessState int64 `json:"business_state"`
}
// ChallReleaseUpSearchCondItem .
type ChallReleaseUpSearchCondItem struct {
Cid int64 `json:"id"`
AssigneeAdminID int64 `json:"assignee_adminid"`
BusinessState int64 `json:"business_state"`
}
// ChallUpSearchResult .
type ChallUpSearchResult struct {
Code int32 `json:"code"`
Message string `json:"message"`
TTL int32 `json:"ttl"`
}