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,65 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_test",
"go_library",
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/admin/main/workflow/model/manager:all-srcs",
"//app/admin/main/workflow/model/param:all-srcs",
"//app/admin/main/workflow/model/search:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
go_test(
name = "go_default_test",
srcs = ["challenge_test.go"],
embed = [":go_default_library"],
rundir = ".",
tags = ["automanaged"],
deps = ["//vendor/github.com/smartystreets/goconvey/convey:go_default_library"],
)
go_library(
name = "go_default_library",
srcs = [
"activity.go",
"block.go",
"business.go",
"business_attr.go",
"callback.go",
"challenge.go",
"common.go",
"event.go",
"extra.go",
"group.go",
"message.go",
"platform_meta.go",
"reply.go",
"state.go",
"tag.go",
"wlog.go",
],
importpath = "go-common/app/admin/main/workflow/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/workflow/model/param:go_default_library",
"//app/job/main/credit/model:go_default_library",
"//library/time:go_default_library",
],
)

View File

@@ -0,0 +1,7 @@
package model
// Activities is the model for all challenge activities
type Activities struct {
Logs []*WLog `json:"logs"`
Events []*Event `json:"events"`
}

View File

@@ -0,0 +1,39 @@
package model
import credit "go-common/app/job/main/credit/model"
// BlockReason 封禁理由
var BlockReason = map[int8]string{
credit.ReasonOtherType: "其他",
credit.ReasonBrushScreen: "刷屏",
credit.ReasonGrabFloor: "抢楼",
credit.ReasonGamblingFraud: "发布赌博诈骗信息",
credit.ReasonProhibited: "发布违禁相关信息",
credit.ReasonGarbageAds: "发布垃圾广告信息",
credit.ReasonPersonalAttacks: "发布人身攻击言论",
credit.ReasonViolatePrivacy: "发布侵犯他人隐私信息",
credit.ReasonLeadBattle: "发布引战言论",
credit.ReasonSpoiler: "发布剧透信息",
credit.ReasonAddUnrelatedTags: "恶意添加无关标签",
credit.ReasonDelOtherTags: "恶意删除他人标签",
credit.ReasonPornographic: "发布色情信息",
credit.ReasonVulgar: "发布低俗信息",
credit.ReasonBloodyViolence: "发布暴力血腥信息",
credit.ReasonAnimusVideoUp: "涉及恶意投稿行为",
credit.ReasonIllegalWebsite: "发布非法网站信息",
credit.ReasonSpreadErrinfo: "发布传播不实信息",
credit.ReasonAbettingEncouragement: "发布怂恿教唆信息",
credit.ReasonAnimusBrushScreen: "恶意刷屏",
credit.ReasonAccountViolation: "账号违规",
credit.ReasonMaliciousPlagiarism: "恶意抄袭",
credit.ReasonPosingAsHomemade: "冒充自制原创",
credit.ReasonPostTeenBadContent: "发布青少年不良内容",
credit.ReasonDestroyCyberSecurity: "破坏网络安全",
credit.ReasonPostingMisleadingInfo: "发布虚假误导信息",
credit.ReasonCounterfeitOfficialAuth: "仿冒官方认证账号",
credit.ReasonPublishInappropriateContent: "发布不适宜内容",
credit.ReasonViolationOperatingRules: "违反运营规则",
credit.ReasonIllegalCreateTopic: "恶意创建话题",
credit.ReasonIllegalDrawLottery: "发布违规抽奖",
credit.ReasonIllegalFakeMan: "恶意冒充他人",
}

View File

@@ -0,0 +1,88 @@
package model
import xtime "go-common/library/time"
const (
// 业务bid 对应manager项目子业务
// ArchiveComplain 稿件投诉
ArchiveComplain = 1
// ArchiveAppeal 稿件申诉
ArchiveAppeal = 2
// ReviewShortComplain 短点评投诉
ReviewShortComplain = 3
// ReviewLongComplain 长点评投诉
ReviewLongComplain = 4
// CreditAppeal 小黑屋申诉
CreditAppeal = 5
// ArchiveAudit 稿件审核
ArchiveAudit = 6
// ArchiveVT 任务质检
ArchiveVT = 7
// ChannelComplain 频道举报
ChannelComplain = 9
// CommentComplain 评论举报
CommentComplain = 13
// SubtitleComplain 字幕举报
SubtitleComplain = 14
)
// Business will record any business properties
type Business struct {
Bid int32 `json:"-" gorm:"column:id"`
Gid int64 `json:"gid" gorm:"column:gid"`
Cid int64 `json:"cid" gorm:"column:cid"`
Oid int64 `json:"oid" gorm:"column:oid"`
Business int8 `json:"business" gorm:"column:business"`
TypeID int32 `json:"typeid" gorm:"column:typeid"`
Title string `json:"title" gorm:"column:title"`
Content string `json:"content" gorm:"column:content"`
Mid int64 `json:"mid" gorm:"column:mid"`
Extra string `json:"extra" gorm:"column:extra"`
CTime xtime.Time `json:"-" gorm:"column:ctime"`
MTime xtime.Time `json:"-" gorm:"column:mtime"`
}
// Meta is the model to store business metadata
type Meta struct {
Business int8 `json:"business"`
Name string `json:"name"`
ItemType string `json:"item_type"`
Rounds []*Round `json:"rounds"`
Attr *BusinessAttr `json:"attr"`
}
// MetaSlice is used to support sort Metas
type MetaSlice []*Meta
func (ms MetaSlice) Len() int {
return len(ms)
}
func (ms MetaSlice) Swap(i, j int) {
ms[i], ms[j] = ms[j], ms[i]
}
func (ms MetaSlice) Less(i, j int) bool {
return ms[i].Business < ms[j].Business
}
// Round is the model to describe how many business rounds are
type Round struct {
ID int8 `json:"id"`
Name string `json:"name"`
}
// RoundSlice is used to support sort Rounds
type RoundSlice []*Round
func (rs RoundSlice) Len() int {
return len(rs)
}
func (rs RoundSlice) Swap(i, j int) {
rs[i], rs[j] = rs[j], rs[i]
}
func (rs RoundSlice) Less(i, j int) bool {
return rs[i].ID < rs[j].ID
}

View File

@@ -0,0 +1,34 @@
package model
import xtime "go-common/library/time"
// BusinessAttr will record business attributes
type BusinessAttr struct {
ID int64 `json:"id" gorm:"column:id"`
BID int64 `json:"bid" gorm:"column:bid"`
BusinessName string `json:"business_name" gorm:"business_name"`
Name string `json:"name" gorm:"column:name"`
DealType int8 `json:"deal_type" gorm:"column:deal_type"`
ExpireTime int64 `json:"expire_time" gorm:"column:expire_time"`
AssignType int8 `json:"assign_type" gorm:"column:assign_type"`
AssignMax int8 `json:"assign_max" gorm:"column:assign_max"`
GroupType int8 `json:"group_type" gorm:"column:group_type"`
Button uint8 `json:"-" gorm:"button"`
ButtonKey string `json:"-" gorm:"button_key"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
Buttons []*Button `json:"button" gorm:"-"`
}
// TableName is used to identify chall table name in gorm
func (BusinessAttr) TableName() string {
return "workflow_business_attr"
}
// Button .
type Button struct {
Index int `json:"index"`
Name string `json:"name"`
State bool `json:"state"`
Key string `json:"key"`
}

View File

@@ -0,0 +1,58 @@
package model
import (
xtime "go-common/library/time"
)
// consts for callback
const (
GroupSetResult = "group.SetResult"
BatchGroupSetResult = "group.BatchSetResult"
ChallSetResult = "chall.SetResult"
BatchChallSetResult = "chall.BatchSetResult"
GroupSetState = "group.SetState"
GroupSetPublicReferee = "group.SetPublicReferee"
CallbackDisable = 0
CallbackEnable = 1
)
// Slice is the slice model for callback
type CallbackSlice []*Callback
// Callback is the workflow callback model
type Callback struct {
CbID int32 `json:"cbid" gorm:"column:id"`
URL string `json:"url" gorm:"column:url"`
Business int8 `json:"business" gorm:"column:business"`
IsSobot bool `json:"is_sobot" gorm:"column:is_sobot"`
State int8 `json:"state" gorm:"column:state"`
ExternalAPI string `json:"external_api" gorm:"column:external_api"`
SourceAPI string `json:"source_api" gorm:"column:source_api"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
}
// Actor for callback payload
type Actor struct {
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
}
// Payload is the payload model for callback
type Payload struct {
Bid int `json:"bid"`
Verb string `json:"verb"`
Actor Actor `json:"actor"`
CTime xtime.Time `json:"ctime"`
Object interface{} `json:"object"` //处理请求参数
Target interface{} `json:"target"` //被修改的工单或工单详情
Targets []interface{} `json:"targets"` //所有被修改的工单或工单详情
Influence interface{} `json:"influence"` //业务自定义 Deprecated
Extra interface{} `json:"extra"` //业务自定义
}
// TableName is used to identify table name for gorm
func (Callback) TableName() string {
return "workflow_callback"
}

View File

@@ -0,0 +1,150 @@
package model
import (
"net/url"
xtime "go-common/library/time"
)
// Chall is the row view for every challenge
type Chall struct {
Cid int64 `json:"cid" gorm:"column:id"`
Gid int64 `json:"gid" gorm:"column:gid"`
Oid int64 `json:"oid" gorm:"column:oid"`
OidStr string `json:"oid_str" gorm:"-"`
Business int8 `json:"business" gorm:"column:business"`
Mid int64 `json:"mid" gorm:"column:mid"`
MName string `json:"m_name" gorm:"-"`
Tid int64 `json:"tid" gorm:"column:tid"`
State int8 `json:"state"`
BusinessState int8 `json:"business_state"`
DispatchState uint32 `json:"-" gorm:"column:dispatch_state"`
DispatchTime xtime.Time `json:"dispatch_time" gorm:"column:dispatch_time"`
Description string `json:"description" gorm:"column:description"`
Metadata string `json:"metadata" gorm:"column:metadata"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
BusinessObject *Business `json:"business_object,omitempty" gorm:"-"`
AssigneeAdminID int64 `json:"assignee_adminid" gorm:"column:assignee_adminid"`
AdminID int64 `json:"adminid" gorm:"column:adminid"`
AssigneeAdminName string `json:"assignee_admin_name" gorm:"-"`
AdminName string `json:"admin_name" gorm:"-"`
TotalStates string `json:"total_states" gorm:"-"`
// tag related fields
Tag string `json:"tag" gorm:"-"`
Round int8 `json:"round" gorm:"-"`
// log related
LastLog string `json:"last_log" gorm:"-"`
// event related
LastEvent *Event `json:"last_event" gorm:"-"`
// Attachments
Attachments []string `json:"attachments" gorm:"-"`
// linked group object
Group *Group `json:"group,omitempty" gorm:"-"`
Meta interface{} `json:"meta" gorm:"-"`
AuditLog interface{} `json:"audit_log" gorm:"-"`
Producer *Account `json:"producer" gorm:"-"` //举报人
// business table
Title string `json:"title,omitempty" gorm:"-"`
TypeID int64 `json:"type_id,omitempty" gorm:"-"`
}
// TinyChall is the tiny row view for every challenge
type TinyChall struct {
Cid int64 `json:"cid" gorm:"column:id"`
Gid int64 `json:"gid" gorm:"column:gid"`
Mid int64 `json:"mid" gorm:"column:mid"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
State int8 `json:"state" gorm:"-"`
Title string `json:"title" gorm:"-"`
}
// ChallTagSlice is the slice to ChallTag
type ChallTagSlice []*ChallTag
// ChallTag is the model to retrive user submitted tags in group view
type ChallTag struct {
ID int64 `json:"id"`
Tag string `json:"tag"`
Round int8 `json:"round"`
Count int64 `json:"count"`
Percent int32 `json:"percent"`
}
// TableName is used to identify chall table name in gorm
func (Chall) TableName() string {
return "workflow_chall"
}
func (c ChallTagSlice) Len() int {
return len(c)
}
func (c ChallTagSlice) Swap(i, j int) {
c[i], c[j] = c[j], c[i]
}
func (c ChallTagSlice) Less(i, j int) bool {
return c[i].Percent < c[j].Percent
}
// FixAttachments will fix attachments url as user friendly
// ignore https case
// FIXME: this should be removed after attachment url is be normed
func (c *Chall) FixAttachments() {
if c.Attachments == nil {
return
}
fixed := make([]string, 0, len(c.Attachments))
for _, a := range c.Attachments {
u, err := url.Parse(a)
if err != nil {
continue
}
u.Scheme = "http"
fixed = append(fixed, u.String())
}
c.Attachments = fixed
}
// SetState update state of a role
// ex. oldState=0x3a4b5c6d, state=15, role=1 then result is 0x3a4b5cfd
func (c *Chall) SetState(state uint32, role uint8) {
oldState := c.DispatchState
mod := uint32(^(0xf << (4 * role)))
oldState = oldState & mod // all bit keep unchanged and bits you want update change to 0
c.DispatchState = oldState + state<<(4*role)
}
// getState return state of a role from dispatchState field
// ex. dispatchState=0x3a4b5c6d, role=1 then result is 0x6
func (c *Chall) getState(role uint8) (result int8) {
dispatchState := c.DispatchState
mod := uint32(0xf << (4 * role))
dispatchState &= mod
result = int8(dispatchState >> (4 * role))
return
}
// FromState set State and BusinessState field from DispatchState field
func (c *Chall) FromState() {
c.State = c.getState(uint8(0))
c.BusinessState = c.getState(uint8(1))
}
// FormatState transform state in queue
func (c *Chall) FormatState() {
if c.State == QueueState {
c.State = QueueStateBefore
}
if c.BusinessState == QueueBusinessState {
c.BusinessState = QueueBusinessStateBefore
}
}

View File

@@ -0,0 +1,44 @@
package model
import (
"testing"
"github.com/smartystreets/goconvey/convey"
)
var c *Chall
func init() {
c = new(Chall)
}
func TestSetState(t *testing.T) {
convey.Convey("SetState", t, func() {
c.DispatchState = uint32(0x3a4b5c6d)
state := uint32(0xf)
role := uint8(1)
c.SetState(state, role)
convey.So(c.DispatchState, convey.ShouldEqual, uint32(0x3a4b5cfd))
})
}
func TestGetState(t *testing.T) {
convey.Convey("GetState", t, func() {
c.DispatchState = uint32(0x3a4b5c6d)
role := uint8(2)
result := c.getState(role)
convey.So(result, convey.ShouldEqual, uint32(0xc))
})
}
func TestFormatState(t *testing.T) {
convey.Convey("FormatState", t, func() {
c.FormatState()
})
}
func TestFromState(t *testing.T) {
convey.Convey("FromState", t, func() {
c.FromState()
})
}

View File

@@ -0,0 +1,27 @@
package model
// Page common page struct for list api
type Page struct {
Num int `json:"num"`
Size int `json:"size"`
Total int `json:"total"`
}
// CommonResponse .
type CommonResponse struct {
Code int `json:"code"`
Message string `json:"message"`
TTL int `json:"ttl"`
}
// CommonExtraDataResponse .
type CommonExtraDataResponse struct {
*CommonResponse
Data map[string]interface{} `json:"data"` //map[gid]interface{}
}
// SourceQueryResponse
type SourceQueryResponse struct {
*CommonResponse
Data map[string]interface{} `json:"data"`
}

View File

@@ -0,0 +1,62 @@
package model
import (
"net/url"
"strings"
xtime "go-common/library/time"
)
// consts for workflow event
const (
// EventAdminReply 管理员回复
EventAdminReply = 1
// EventAdminNote 管理员回复并记录
EventAdminNote = 2
// EventUserReply 用户回复
EventUserReply = 3
// EventSystem 系统回复
EventSystem = 4
)
// EventSlice is a Event slice struct
type EventSlice []*Event
// Event model is the model for challenge changes
type Event struct {
Eid int64 `json:"eid" gorm:"column:id"`
Cid int64 `json:"cid" gorm:"column:cid"`
AdminID int64 `json:"adminid" gorm:"column:adminid"`
Content string `json:"content" gorm:"column:content"`
Attachments string `json:"attachments" gorm:"column:attachments"`
Event int8 `json:"event" gorm:"column:event"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
Admin string `json:"admin" gorm:"-"`
}
// TableName is used to identify table name in gorm
func (Event) TableName() string {
return "workflow_event"
}
// FixAttachments will fix attachments url as user friendly
// ignore https case
// FIXME: this should be removed after attachment url is be normed
func (e *Event) FixAttachments() {
if len(e.Attachments) <= 0 {
return
}
sep := ";"
atts := strings.Split(e.Attachments, sep)
fixed := make([]string, 0, len(atts))
for _, a := range atts {
u, err := url.Parse(a)
if err != nil {
continue
}
u.Scheme = "http"
fixed = append(fixed, u.String())
}
e.Attachments = strings.Join(fixed, sep)
}

View File

@@ -0,0 +1,242 @@
package model
import (
"net/url"
xtime "go-common/library/time"
)
// ChannelInfoResult .
type ChannelInfoResult struct {
*CommonResponse
Data map[int64]*ArchiveChannelData
}
// ArchiveChannelData .
type ArchiveChannelData struct {
Tids []int64 `json:"tids"`
ChannelMap map[int64]*Channel `json:"channels"`
Archive *Archive `json:"-"`
}
// Channel .
type Channel struct {
//Tid int64 `json:"tid"`
TName string `json:"tname"`
//HitRule string `json:"hit_rule"`
//HitNames []string `json:"hit_names"`
HitRules []string `json:"hit_rules"`
Archive *Archive `json:"archive"`
}
// Review review struct
// http://info.bilibili.co/pages/viewpage.action?pageId=5417343
type Review struct {
ReviewID int64 `json:"review_id"`
Type int8 `json:"type"`
Mid int64 `json:"mid"`
MediaName string `json:"media_name"`
Title string `json:"title"`
Content string `json:"content"`
Status int8 `json:"status"`
IsDelete int8 `json:"is_delete"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"mtime"`
TypeName string `json:"type_name"`
Author string `json:"author"`
Composer *Account `json:"-"`
}
// MultiReviewInfoResult response of multi review info api
type MultiReviewInfoResult struct {
Code int `json:"code"`
Result map[int64]*Review `json:"result"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
}
// SpecialTag .
type SpecialTag struct {
MID int64 `json:"mid"`
GroupTag string `json:"group_tag"`
BGColor string `json:"bg_color"`
FontColor string `json:"font_color"`
GroupID int `json:"group_id"`
}
// UperSpecial .
// http://info.bilibili.co/pages/viewpage.action?pageId=8479274
type UperSpecial struct {
Code int `json:"code"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
Data struct {
Page Page `json:"page"`
Items []*SpecialTag `json:"items"`
} `json:"data"`
}
// Account account info struct
// http://info.bilibili.co/pages/viewpage.action?pageId=8465956#V3HTTP接口-用户全量信息含计数ProfileStat
// ignore unused field
type Account struct {
Mid int64 `json:"mid"`
Name string `json:"name"`
Rank int32 `json:"rank"`
Follower int64 `json:"follower"`
Official *Official `json:"official"`
SpecialTag []*SpecialTag `json:"special_tag"`
}
// Official .
type Official struct {
Role int8 `json:"role"`
}
// Relation .
// http://info.bilibili.co/pages/viewpage.action?pageId=8742464
type Relation struct {
Follower int `json:"follower"`
}
// AccountInfosResult response of account info api
type AccountInfosResult struct {
Code int `json:"code"`
Data *Account `json:"data"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
}
// ArchiveComplainGroup is the model for archvie appeal group view
type ArchiveComplainGroup struct {
Group
Archive *Archive `json:"archive"`
ChallengeTags ChallTagSlice `json:"challenge_tags"`
}
// ArchiveAppealGroup is the model for archvie appeal group view
type ArchiveAppealGroup struct {
ArchiveComplainGroup
// Appeal Related
Cid int64 `json:"cid"`
AppealReason string `json:"appeal_reason"`
AppealAttachments []string `json:"appeal_attachments"`
}
// ArchiveListPage is the model for archive list result
type ArchiveListPage struct {
Items interface{} `json:"items"`
Page *Page `json:"page"`
}
// Archive is archive info struct
// http://info.bilibili.co/pages/viewpage.action?pageId=3686646
type Archive struct {
Author string `json:"author"`
State int32 `json:"state"`
Mid int64 `json:"mid"`
TypeID int32 `json:"tid"`
Type string `json:"type"`
Title string `json:"title"`
RejectReason string `json:"reject_reason"`
Composer *Account `json:"-"`
OPName string `json:"op_name"`
OPContent string `json:"op_content"`
OPRemark string `json:"op_remark"`
}
// ArchiveResult is response of archive info api
type ArchiveResult struct {
*Archive `json:"archive"`
}
// MultiArchiveInfoResult is response of multi archive info api
type MultiArchiveInfoResult struct {
Code int `json:"code"`
Data map[int64]*ArchiveResult `json:"data"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
}
// ArchiveType archive type struct
type ArchiveType struct {
ID int64 `json:"id"`
PID int64 `json:"pid"`
Name string `json:"name"`
Description string `json:"description"`
}
// ArchiveTypeResult response of archive type api
type ArchiveTypeResult struct {
Code int `json:"code"`
Data map[int32]*ArchiveType `json:"data"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
}
// FixAttachments will fix attachments url as user friendly
// ignore https case
// FIXME: this should be removed after attachment url is be normed
func (ag *ArchiveAppealGroup) FixAttachments() {
if ag.AppealAttachments == nil {
return
}
fixed := make([]string, 0, len(ag.AppealAttachments))
for _, a := range ag.AppealAttachments {
u, err := url.Parse(a)
if err != nil {
continue
}
u.Scheme = "http"
fixed = append(fixed, u.String())
}
ag.AppealAttachments = fixed
}
// CreditMeta .
type CreditMeta struct {
*Business
Producer *Account `json:"producer"`
}
// BlockInfoResp .
type BlockInfoResp struct {
*CommonResponse
Data *struct {
Mid int64 `json:"mid"`
Status int64 `json:"status"`
StartTime int64 `json:"start_time"`
EndTime int64 `json:"end_time"`
BlockedSum int64 `json:"blocked_sum"`
} `json:"data"`
}
// BlockNumResp .
type BlockNumResp struct {
*CommonResponse
Data *struct {
BlockedSum int64 `json:"blockedSum"`
} `json:"data"`
}
// BlockCaseAdd .
// http://info.bilibili.co/pages/viewpage.action?pageId=5417571
type BlockCaseAdd struct {
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
Operator string `json:"operator"`
OperID int64 `json:"oper_id"`
OriginType int64 `json:"origin_type"`
OriginContent string `json:"origin_content"`
OriginTitle string `json:"origin_title"`
OriginURL string `json:"origin_url"`
ReasonType int64 `json:"reason_type"`
Oid int64 `json:"oid"`
RpID int64 `json:"rp_id"`
TagID int64 `json:"tag_id"`
Type int64 `json:"type"`
Page int64 `json:"page"`
BusinessTime int64 `json:"business_time"`
}

View File

@@ -0,0 +1,69 @@
package model
import (
xtime "go-common/library/time"
)
// Group model is the group view for several challanges
type Group struct {
ID int64 `json:"id" gorm:"column:id"`
Oid int64 `json:"oid" gorm:"column:oid"`
OidStr string `json:"oid_str" gorm:"-"`
Business int8 `json:"business" gorm:"column:business"`
Fid int64 `json:"fid" gorm:"column:fid"`
Rid int8 `json:"rid" gorm:"column:rid"`
Eid int64 `json:"eid" gorm:"eid"`
EidStr string `json:"eid_str" gorm:"-"`
State int8 `json:"state" gorm:"column:state"`
Tid int64 `json:"tid" gorm:"column:tid"`
FirstUserTid int64 `json:"first_user_tid" gorm:"-"`
Note string `json:"note" gorm:"column:note"`
Score int64 `json:"score" gorm:"column:score"`
// Stat fields
// this is a workround solution for calcuating appeals
Count int32 `json:"count" gorm:"column:count"`
Handling int32 `json:"handling" gorm:"column:handling"`
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
LastTime xtime.Time `json:"last_time" gorm:"column:lasttime"`
LastLog string `json:"last_log" gorm:"-"`
BusinessObject *Business `json:"business_object,omitempty" gorm:"-"`
// Tags related to Group
Tag string `json:"tag" gorm:"-"`
Round int8 `json:"round" gorm:"-"`
ChallengeTags ChallTagSlice `json:"challenge_tags" gorm:"-"`
Meta interface{} `json:"meta" gorm:"-"`
MetaData interface{} `json:"meta_data" gorm:""`
TypeID int64 `json:"type_id" gorm:"-"`
LastProducer *Account `json:"last_producer" gorm:"-"`
Defendant *Account `json:"defendant" gorm:"-"`
}
// GroupListPage is the model for group list result
type GroupListPage struct {
Items []*Group `json:"items"`
Page *Page `json:"page"`
}
// GroupPendingCount .
type GroupPendingCount struct {
Total int `json:"total"`
}
// GroupMeta .
type GroupMeta struct {
Archive *Archive `json:"archive"`
Object *Business `json:"object"`
External interface{} `json:"external"`
}
// TableName is used to identify group table name in gorm
func (Group) TableName() string {
return "workflow_group"
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"admin.go",
"business.go",
],
importpath = "go-common/app/admin/main/workflow/model/manager",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//app/admin/main/workflow/model: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,9 @@
package manager
// UNameSearchResult .
type UNameSearchResult struct {
Code int `json:"code"`
Data map[int64]string `json:"data"`
Message string `json:"message"`
TTL int32 `json:"ttl"`
}

View File

@@ -0,0 +1,43 @@
package manager
import "go-common/app/admin/main/workflow/model"
// Meta business meta
// http://info.bilibili.co/pages/viewpage.action?pageId=9846887
type Meta struct {
ID int `json:"id"`
PID int `json:"pid"`
Name string `json:"name"`
Flow int `json:"flow"`
FlowState int `json:"flow_state"`
State int `json:"state"`
FlowChild []*Flow `json:"flowchild"`
}
// Flow is child flow meta
type Flow struct {
FlowState int `json:"flow_state"`
Child []*Meta `json:"child"`
}
// ListResponse .
type ListResponse struct {
*model.CommonResponse
Data []*Meta `json:"data"`
}
// Role .
type Role struct {
ID int `json:"id"`
Bid int8 `json:"bid"`
Rid int8 `json:"rid"`
Name string `json:"name"`
Type int `json:"type"`
State int `json:"state"`
}
// RoleResponse .
type RoleResponse struct {
*model.CommonResponse
Data []*Role
}

View File

@@ -0,0 +1,40 @@
package model
import (
"fmt"
"go-common/app/admin/main/workflow/model/param"
)
// message mc
const (
ArcComplainDealMC = "1_13_1"
ArcComplainRevMC = "1_15_1"
WkfNotifyMC = "1_5_3"
)
// DealArcComplainMsg generate archive complain deal message param
func DealArcComplainMsg(aid int64, mids []int64) *param.MessageParam {
return &param.MessageParam{
Type: "json",
Source: 1,
DataType: 4,
MC: ArcComplainDealMC,
Title: "您的投诉已被受理",
Context: fmt.Sprintf("您对稿件av%d的投诉已被受理。感谢您对 bilibili 社区秩序的维护,哔哩哔哩 (゜-゜)つロ 干杯~ ", aid),
MidList: mids,
}
}
// ReceivedArcComplainMsg generate archive complain received message param
func ReceivedArcComplainMsg(aid int64, mids []int64) *param.MessageParam {
return &param.MessageParam{
Type: "json",
Source: 1,
DataType: 4,
MC: ArcComplainRevMC,
Title: "您的投诉已收到",
Context: fmt.Sprintf("您对稿件av%d的投诉我们已经收到。感谢您对 bilibili 社区秩序的维护,哔哩哔哩 (゜-゜)つロ 干杯~", aid),
MidList: mids,
}
}

View File

@@ -0,0 +1,36 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"callback.go",
"challenge.go",
"group.go",
"param.go",
"platform.go",
"wlog.go",
],
importpath = "go-common/app/admin/main/workflow/model/param",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//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,11 @@
package param
// AddCallbackParam is the model to create callback
type AddCallbackParam struct {
Business int8 `json:"business"`
URL string `json:"url"`
IsSobot bool `json:"is_sobot"`
State int8 `json:"state"`
ExternalAPI string `json:"external_api"`
SourceAPI string `json:"source_api"`
}

View File

@@ -0,0 +1,227 @@
package param
import (
"net/url"
"strconv"
"go-common/library/xstr"
)
// ChallengeListCommonParam .
type ChallengeListCommonParam struct {
Business int8 `form:"business" validate:"required"`
IDs []int64 `form:"ids,split"`
Oids []string `form:"oids,split"`
ObjectMids []int64 `form:"object_mids,split"`
Mids []int64 `form:"mids,split"`
Gids []int64 `form:"gids,split"`
States []int64 `form:"states,split"`
TypeIDs []int64 `form:"typeids,split"`
Tids []int64 `form:"tids,split" validate:"dive,gt=0"`
Rounds []int64 `form:"rounds,split"`
AssigneeAdminIDs []int64 `form:"assignee_adminids,split"`
AssigneeAdminNames []string `form:"assignee_adminnames,split"`
AdminIDs []int64 `form:"adminids,split"`
BusinessStates []int64 `form:"business_states,split"`
DispatchStates []int64 `form:"dispatch_states,split"`
Title string `form:"title"`
Content string `form:"content"`
AdminReply string `form:"admin_reply"`
UserReply string `form:"user_reply"`
CTimeFrom string `form:"ctime_from"`
CTimeTo string `form:"ctime_to"`
Order string `form:"order" default:"ctime"`
Sort string `form:"sort_order" default:"desc"`
PS int `form:"ps" default:"50"`
PN int `form:"pn" default:"1"`
}
// ChallengeListV3Param .
type ChallengeListV3Param struct {
Business int8 `form:"business" validate:"required"`
IDs []int64 `form:"cid,split"`
Oids []string `form:"oid,split"`
Mids []int64 `form:"mid,split"`
Gids []int64 `form:"gid,split"`
States []int64 `form:"state,split"`
TypeIDs []int64 `form:"typeid,split"`
Tids []int64 `form:"tid,split"`
Roles []int64 `form:"role,split"`
AssigneeAdminIDs []int64 `form:"assignee_adminid,split"`
AssigneeAdminNames []string `form:"assignee_admin_name,split"`
AdminIDs []int64 `form:"adminid,split"`
AdminNames []string `form:"admin_name,split"`
BusinessStates []int64 `form:"business_state,split"`
KW []string `form:"kw,split"`
KWField []string `form:"kw_field,split"`
CTimeFrom string `form:"ctime_from"`
CTimeTo string `form:"ctime_to"`
Order string `form:"order" default:"id"`
Sort string `form:"sort" default:"desc"`
PS int `form:"ps" default:"50"`
PN int `form:"pn" default:"1"`
}
// ChallRstParam describe the reset request params to a challenge row
type ChallRstParam struct {
Cid int64 `form:"cid" json:"cid" validate:"required,min=1"`
State int8 `form:"state" json:"state" validate:"min=0,max=14"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
Reason string `form:"reason" json:"reason"`
Business int8 `form:"business" json:"business"`
}
// ChallUpParam describe the update request params to a challenge row
type ChallUpParam struct {
Cid int64 `form:"cid" json:"cid" validate:"required,min=1"`
Tid int64 `form:"tid" json:"tid"`
Note string `form:"note" json:"note"`
AdminID int64 `form:"adminid" json:"adminid"`
AdminName string `json:"admin_name"`
Business int8 `form:"business" json:"business"`
Role int8 `form:"role" json:"role"`
}
// ChallResParam describe the set result request params to a challenge row
type ChallResParam struct {
Cid int64 `json:"cid" form:"cid" validate:"required,min=1"`
State int8 `json:"state" form:"state" validate:"min=0,max=14"`
Reason string `json:"reason" form:"reason"`
AdminID int64 `json:"adminid" form:"adminid"`
AdminName string `json:"admin_name"`
}
// BatchChallResParam describe the set result request params to a set of challenges
type BatchChallResParam struct {
Cids []int64 `json:"cids" form:"cid,split" validate:"required,gt=0"`
State int8 `json:"state" form:"state" validate:"min=0,max=14"`
Business int8 `form:"business" json:"business"`
Role int8 `form:"role" json:"role"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
Reason string `json:"reason" form:"reason"`
}
// ChallSetParamV3 .
type ChallSetParamV3 struct {
ID []int64 `json:"id" form:"id,split" validate:"required,gt=0"`
State int8 `json:"state" form:"state" validate:"min=0,max=14"`
AdminID int64 `json:"adminid"`
Reason string `json:"reason" form:"reason"`
}
// BatchChallBusStateParam .
type BatchChallBusStateParam struct {
Cids []int64 `form:"cid,split" json:"cid" validate:"required,gt=0"`
AssigneeAdminID int64 `json:"assignee_admin_id"`
AssigneeAdminName string `json:"assignee_admin_name"`
Business int8 `form:"business"`
Role int8 `form:"role"`
BusState int8 `form:"business_state" json:"business_state" validate:"min=0,max=14"`
}
// EventParam is used to parse user request
type EventParam struct {
Cid int64 `json:"cid" form:"cid" validate:"required,min=1"`
AdminID int64 `json:"adminid" form:"adminid"`
AdminName string `json:"admin_name"`
Content string `json:"content" form:"content"`
Attachments string `json:"attachments" form:"attachments"`
Event int8 `json:"event" form:"event" validate:"required,min=1"`
}
// BatchEventParam is used to parse user request
type BatchEventParam struct {
Cids []int64 `json:"cids,split" form:"cids,split" validate:"required,dive,gt=0"`
AdminID int64 `json:"adminid" form:"adminid"`
AdminName string `json:"admin_name"`
Content string `json:"content" form:"content"`
Attachments string `json:"attachments" form:"attachments"`
Event int8 `json:"event" form:"event" validate:"required,min=1"`
}
// ChallExtraParam describe the request params to update challenge extra data
type ChallExtraParam struct {
Cid int64 `json:"cid" validate:"required,min=1"`
AdminID int64 `json:"adminid" validate:"required,min=1"`
AdminName string `json:"admin_name"`
Extra map[string]interface{} `json:"extra" validate:"required"`
}
// ChallExtraParamV3 .
type ChallExtraParamV3 struct {
Cids []int64 `json:"cid" form:"cid,split" validate:"required,dive,gt=0"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
Extra string `json:"extra" form:"extra" validate:"required"`
}
// BatchChallExtraParam describe the request params to batch update challenges extra data
type BatchChallExtraParam struct {
Cids []int64 `json:"cid" form:"cid" validate:"required,min=1"`
Business int8 `json:"business" form:"business"`
AdminID int64 `json:"adminid" validate:"required,min=1"`
AdminName string `json:"admin_name"`
Extra map[string]interface{} `json:"extra" form:"extra" validate:"required"`
}
// BusChallsBusStateParam describe the request params to update business state of challenges in business
type BusChallsBusStateParam struct {
Business int8 `json:"business" validate:"required,min=1"`
Oid int64 `json:"oid" validate:"required,min=1"`
AdminID int64 `json:"adminid" validate:"required,min=1"`
BusState int8 `json:"business_state" validate:"min=0,max=14"`
PreBusStates []int8 `json:"pre_business_states" validate:"dive,gt=-1"`
Extra map[string]interface{} `json:"extra"`
}
// ValidComponent will verify the component field is valid
func (e *EventParam) ValidComponent() bool {
if e.Cid > 0 &&
e.AdminID > 0 &&
e.Content != "" &&
e.Event > 0 {
return true
}
return false
}
// ValidComponent will verify the component field is valid
func (be *BatchEventParam) ValidComponent() bool {
if len(be.Cids) > 0 &&
be.AdminID > 0 &&
be.Content != "" &&
be.Event > 0 {
return true
}
return false
}
// MessageParam is the model to send message to end user
type MessageParam struct {
Type string
Source int8
DataType int8
MC string
Title string
Context string
MidList []int64
}
// Query method will serialize all conditions into a url.Values struct
func (mp *MessageParam) Query() (uv url.Values) {
uv = url.Values{}
uv.Set("type", mp.Type)
uv.Set("source", strconv.Itoa(int(mp.Source)))
uv.Set("data_type", strconv.Itoa(int(mp.DataType)))
uv.Set("mc", mp.MC)
uv.Set("title", mp.Title)
uv.Set("context", mp.Context)
uv.Set("mid_list", xstr.JoinInts(mp.MidList))
return uv
}

View File

@@ -0,0 +1,130 @@
package param
// GroupParam describe the group param
type GroupParam struct {
Oid int64 `form:"oid" json:"oid" validate:"required,min=1"`
Business int8 `form:"business" json:"business" validate:"required,min=1"`
Rid int8 `form:"rid" json:"rid"`
State int8 `form:"state" json:"state"`
Tid int64 `form:"tid" json:"tid" validate:"required,min=1"`
Note string `form:"note" json:"note"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
}
// GroupRoleSetParam .
type GroupRoleSetParam struct {
GID []int64 `form:"id,split" json:"id" validate:"required"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
BID int8 `form:"bid" json:"bid" validate:"required,min=1"`
RID int8 `json:"rid"`
TID int64 `form:"tid" json:"tid" validate:"min=-1"`
Note string `form:"note" json:"note"`
}
// GroupResParam describe the set result request params to a group row
type GroupResParam struct {
Oid int64 `form:"oid" json:"oid" validate:"required,min=1"`
Business int8 `form:"business" json:"business" validate:"required,min=1"`
State int8 `form:"state" json:"state" validate:"required,min=1,max=14"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
Reason string `form:"reason" json:"reason"`
ISDisplay bool `form:"is_display" json:"is_display"`
IsMessage bool `form:"is_message" json:"is_message"`
ReviewState int `form:"review_state" json:"review_state"`
Extra *GroupExtra `json:"extra"`
}
// BatchGroupResParam describe the set result request params to a set of groups
type BatchGroupResParam struct {
GID []int64 `form:"id,split" json:"id"`
Oids []int64 `form:"oids,split" json:"oids" validate:"required,gt=0"`
Business int8 `form:"business" json:"business" validate:"required,min=1"`
Role int8 `form:"role" json:"role"`
State int8 `form:"state" json:"state" validate:"required,min=1,max=14"`
AdminID int64 `json:"adminid"`
AdminName string `json:"admin_name"`
Reason string `form:"reason" json:"reason"`
ISDisplay bool `form:"is_display" json:"is_display"`
IsMessage bool `form:"is_message" json:"is_message"`
ReviewState int `form:"review_state" json:"review_state"`
Extra *GroupExtra `json:"extra"`
}
// GroupExtra .
type GroupExtra struct {
ISDisplay bool `form:"is_display" json:"is_display"`
IsMessage bool `form:"is_message" json:"is_message"`
ReviewState int `form:"review_state" json:"review_state"`
}
// GroupListParamV3 .
type GroupListParamV3 struct {
Business int8 `form:"business" validate:"required"`
Oid []string `form:"oid,split"`
Rid []int8 `form:"rid,split"` //role
Fid []int64 `form:"fid,split"` //flow
Eid []int64 `form:"eid,split"`
Mid []int64 `form:"mid,split"` // workflow_business mid
ReportMid []int64 `form:"report_mid,split"` // workflow_chall mid
FirstUserTid []int64 `form:"first_user_tid"`
State []int8 `form:"state,split"`
Tid []int64 `form:"tid,split"`
Round []int64 `form:"round,split"`
TypeID []int64 `form:"typeid,split"`
KWPriority bool `form:"kw_priority"`
KW []string `form:"kw,split"`
KWField []string `form:"kw_field,split"`
Order string `form:"order" default:"lasttime"`
Sort string `form:"sort" default:"desc"`
PN int64 `form:"pn" default:"1"`
PS int64 `form:"ps" default:"50"`
AdminName []string `form:"admin_name,split"`
CTimeFrom string `form:"ctime_from"`
CTimeTo string `form:"ctime_to"`
}
// GroupStateSetParam .
type GroupStateSetParam struct {
ID []int64 `form:"id,split" json:"id" validate:"required"`
Business int8 `form:"business" json:"business" validate:"required"`
State int8 `form:"state" json:"state" validate:"required"`
Tid int64 `form:"tid" json:"tid"` //处理理由tag_id
Rid int8 `form:"rid" json:"rid" validate:"required"`
Reason string `form:"reason" json:"reason"`
IsDisplay bool `form:"is_display" json:"is_display"`
IsMessage bool `form:"is_message" json:"is_message"` //通知举报人
IsMessageUper bool `form:"is_message_uper" json:"is_message_uper"` //通知被举报人(up主)
ReviewState int `form:"review_state" json:"review_state"`
DecreaseMoral int64 `form:"decrease_moral" json:"decrease_moral" validate:"max=0"` //扣节操
DisposeMode int `form:"dispose_mode" json:"dispose_mode" validate:"min=0"` //内容处理方式,批量操作不支持处理内容
BlockDay int64 `form:"block_day" json:"block_day"` //封禁时间
BlockReason int8 `form:"block_reason" json:"block_reason"` //封禁理由
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
}
// GroupStatePublicReferee .
type GroupStatePublicReferee struct {
ID []int64 `form:"id,split" json:"id" validate:"required"`
Business int8 `form:"business" json:"business" validate:"required"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
State int8 `json:"state"`
}
// UpExtraParam describe the request params to batch update group extra data
type UpExtraParam struct {
Gids []int64 `form:"gid,split" json:"gid" validate:"required,min=1"`
Extra string `form:"extra" json:"extra" validate:"required"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
}
// GroupPendingParam .
type GroupPendingParam struct {
Business int8 `form:"business" json:"business" validate:"required,min=1"`
Rid []int8 `form:"rid,split" json:"rid"`
}

View File

@@ -0,0 +1,44 @@
package param
// AddBusAttrParam describe params of add or update business attrs
type AddBusAttrParam struct {
ID int64 `form:"id" json:"id"`
Bid int64 `form:"bid" json:"bid"`
Name string `form:"name" json:"name"`
DealType int8 `form:"deal_type" json:"deal_type"`
ExpireTime int64 `form:"expire_time" json:"expire_time"`
AssignType int8 `form:"assign_type" json:"assign_type"`
AssignMax int8 `form:"assign_max" json:"assign_max"`
GroupType int8 `form:"group_type" json:"group_type"`
BusinessName string `form:"business_name" json:"business_name"`
}
// BusAttrButtonSwitch .
type BusAttrButtonSwitch struct {
Bid int8 `form:"bid" json:"bid" validate:"required"`
Index uint8 `form:"index" json:"index" validate:"min=0,max=7"`
Switch uint8 `form:"switch" json:"switch" validate:"min=0,max=1"`
}
// BusAttrButtonShortCut .
type BusAttrButtonShortCut struct {
Bid int8 `form:"bid" json:"bid" validate:"required"`
Index int8 `form:"index" json:"index" validate:"min=0,max=7"`
ShortCut string `form:"short_cut" json:"short_cut" validate:"required"`
}
// BusAttrExtAPI .
type BusAttrExtAPI struct {
Bid int8 `form:"bid" json:"bid" validate:"required"`
ExternalAPI string `form:"external_api" json:"external_api"`
}
// BlockInfo .
type BlockInfo struct {
Mid int64 `form:"mid" json:"mid" validate:"required"`
}
// Source .
type Source struct {
Bid int8 `form:"bid" json:"bid" validate:"required"`
}

View File

@@ -0,0 +1,36 @@
package param
// ChallListParam describe challenge list search params of a business
type ChallListParam struct {
Businesses []int8 `form:"businesses" validate:"required,min=1"`
AssignNum []int8 `form:"assign_num" validate:"required,min=0"`
Order string `form:"order" default:"id"`
Sort string `form:"sort" default:"desc"`
PN int `form:"pn"`
PS int `form:"ps"`
R int64 `form:"r" validate:"required"`
}
// ChallHandlingDoneListParam describe params challenge list handling of admin
type ChallHandlingDoneListParam struct {
Businesses int8 `form:"businesses" validate:"required,min=1"`
Order string `form:"order"`
Sort string `form:"sort"`
PN int `form:"pn"`
PS int `form:"ps"`
}
// ChallCountParam describe challenge count in some states of a business
type ChallCountParam struct {
Business int64 `form:"business" validate:"required,min=1"`
States []int64 `form:"states,split" validate:"dive,gt=-1"`
}
// ChallCreatedListParam return challenge list created by an admin
type ChallCreatedListParam struct {
Businesses int8 `form:"businesses" validate:"required,min=1"`
Order string `form:"order"`
Sort string `form:"sort"`
PN int `form:"pn"`
PS int `form:"ps"`
}

View File

@@ -0,0 +1,22 @@
package param
// TargetLogParam log/target/list api param
type TargetLogParam struct {
Target int64 `form:"target" validate:"required,min=1"`
Module int8 `form:"module" validate:"required,min=1"`
}
// LogListParam .
type LogListParam struct {
Business int64 `form:"business" validate:"required"`
AdminIDs []int64 `form:"adminid,split"`
OIDs []int64 `form:"oid,split"`
MIDs []int64 `form:"up_mid,split"`
TypeIDs []int64 `form:"typeids,split"`
CTimeFrom string `form:"optctime_from"`
CTimeTo string `form:"optctime_to"`
Order string `form:"order" default:"opt_ctime"`
Sort string `form:"sort_order" default:"desc"`
PN int64 `form:"page" default:"1"`
PS int64 `form:"ps" default:"50"`
}

View File

@@ -0,0 +1,64 @@
package model
// challenge audit state mapping to platform state map[business][platform_state][flow]chall_state
// business > 100 means feedback flow of business%100
// platform state 0.pending 1.handling 2.done 3.close
const (
_AuditFlow = 0
_FeedbcakFlow = 1
_PlatPending = 0
_PlatHandling = 1
_PlatDone = 2
_PlatClosed = 3
)
var pMetas map[int8]map[int8]map[int64][]int64
func init() {
pMetas = map[int8]map[int8]map[int64][]int64{
// 稿件申诉
2: {
_PlatPending: {
_AuditFlow: {},
_FeedbcakFlow: {0, 1},
},
_PlatHandling: {
_AuditFlow: {},
_FeedbcakFlow: {2, 6},
},
_PlatDone: {
_AuditFlow: {},
_FeedbcakFlow: {3, 4, 5, 7, 8},
},
_PlatClosed: { // 关闭状态合并到已办
_AuditFlow: {},
_FeedbcakFlow: {5, 7, 8},
},
},
//稿件审核
6: {
_PlatPending: {
_AuditFlow: {0},
_FeedbcakFlow: {},
},
_PlatDone: {
_AuditFlow: {1, 2, 3},
_FeedbcakFlow: {},
},
_PlatClosed: {
_AuditFlow: {3},
_FeedbcakFlow: {},
},
},
}
}
// PlatformMetas return platform meta data
func PlatformMetas() map[int8]map[int8]map[int64][]int64 {
return pMetas
}

View File

@@ -0,0 +1,18 @@
package model
const (
// NotifyComRules 社区规则
NotifyComRules = `评论区是公众场所,而非私人场所,具体规范烦请参阅#{《社区规则》}{"http://www.bilibili.com/blackboard/blackroom.html"},良好的社区氛围需要大家一起维护!`
// NotifyComRulesReport NotifyComRulesReport
NotifyComRulesReport = "感谢您对bilibili社区秩序的维护哔哩哔哩 (゜-゜)つロ 干杯~"
// NotifyComUnrelated NotifyComUnrelated
NotifyComUnrelated = "bilibili倡导发送与视频相关的评论希望大家尊重作品尊重UP主。良好的社区氛围需要大家一起维护"
// NotifyComProvoke NotifyComProvoke
NotifyComProvoke = "bilibili倡导平等友善的交流。良好的社区氛围需要大家一起维护"
// NofityComProhibited NofityComProhibited
NofityComProhibited = `请自觉遵守国家相关法律法规及#{《社区规则》}{"http://www.bilibili.com/blackboard/blackroom.html"}bilibili良好的社区氛围需要大家一起维护`
)
const (
ReplyFidManga = 22
)

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"`
}

View File

@@ -0,0 +1,39 @@
package model
// consts for state
const (
// Group and Challenge State field
Pending = int8(0) // 未处理
Effective = int8(1) // 有效
Invalid = int8(2) // 无效
RoleShift = int8(3) // 流转
Deleted = int8(9) // 已删除
PublicReferee = int8(10) // 移交众裁
// dispatch_state offset bit
AuditorStateOffset = 0
CSStateOffset = 4
QueueState = 15 // 队列中审核状态
QueueBusinessState = 15 // 队列中客服状态
QueueStateBefore = 0 // 默认审核状态
QueueBusinessStateBefore = 1 // 默认客服状态
// 反馈状态
FeedbackReplyNotRead = 6 // 已回复未读
)
// platform state
const (
PlatformStateHandling = iota + 1
PlatformStateDone
PlatformStateClosed
)
// business round
const (
AuditRoundMin = 1
AuditRoundMax = 10
FeedbackRound = 11
)

View File

@@ -0,0 +1,29 @@
package model
// TagMeta tag from manager/list
type TagMeta struct {
ID int64 `json:"id"`
Bid int8 `json:"bid"`
Tid int64 `json:"tid"`
TagID int64 `json:"tag_id"` //map to old workflow tag id
TName string `json:"tname"`
RID int8 `json:"rid"`
RName string `json:"rname"`
Name string `json:"name"`
Weight int64 `json:"weight"`
State int8 `json:"state"`
UID int64 `json:"uid"`
UName string `json:"uname"`
Description string `json:"description"`
CTime int `json:"ctime"`
MTime int `json:"mtime"`
}
// TagListResult .
type TagListResult struct {
*CommonResponse
Data struct {
Tags []*TagMeta `json:"data"`
Page `json:"page"`
} `json:"data"`
}

View File

@@ -0,0 +1,53 @@
package model
import (
xtime "go-common/library/time"
)
// Log Module Field defination
const (
// report business = 12
WLogModuleChallenge = 1
WLogModuleTag = 2
WLogModuleControl = 3
WLogModuleGroup = 4
WLogModuleReply = 5 // modify business_state
WLogModulePublicReferee = 6
WLogModuleRoleShift = 7 // 流转 (同一个执行方)
WLogModuleDispose = 8 // content dispose 操作内容对象
WLogModuleAddMoral = 20 // 扣节操
WLogModuleBlock = 21 // 封禁
// report business = 11
FeedBackTypeNotifyUserReceived = 2
FeedBackTypeNotifyUserDisposed = 3
FeedBackTypeReply = 5
)
// LogSlice is a Log slice struct
type LogSlice []*WLog
// Log model is the universal model
// Will record any management actions
type WLog struct {
Lid int32 `json:"lid"`
AdminID int64 `json:"adminid"`
Admin string `json:"admin"`
Oid int64 `json:"oid"`
Business int8 `json:"business"`
Target int64 `json:"target"`
Module int8 `json:"module"`
Remark string `json:"remark"`
Note string `json:"note"`
CTime xtime.Time `json:"ctime"`
MTime xtime.Time `json:"mtime"`
Meta interface{} `json:"meta"`
ReportCTime string `json:"report_ctime"`
Mid int64 `json:"mid"`
TypeID int64 `json:"type_id"`
TimeConsume int64 `json:"time_consume"`
OpType string `json:"op_type"`
PreRid string `json:"pre_rid"`
Param interface{} `json:"param"`
Mids []int64 `json:"mids"` //对被举报人的批量操作
}