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,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["share.go"],
importpath = "go-common/app/interface/main/web-goblin/model/share",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/usersuit/model:go_default_library",
"//library/time: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,31 @@
package share
import (
suitmdl "go-common/app/service/main/usersuit/model"
xtime "go-common/library/time"
)
// Share share .
type Share struct {
ID int64 `json:"id"`
Mid int64 `json:"mid"`
DayCount int64 `json:"day_count"`
Cycle int64 `json:"cycle"`
ShareDate int64 `json:"share_date"`
Ctime xtime.Time `json:"ctime"`
Mtime xtime.Time `json:"mtime"`
}
// Encourage encourage .
type Encourage struct {
UserInfo interface{} `json:"user_info"`
TodayShare int64 `json:"today_share"`
ShareDays int64 `json:"share_days"`
Pendants interface{} `json:"pendants"`
}
// GroupPendant groupPendant .
type GroupPendant struct {
NeedDays int64 `json:"need_days"`
Pendant *suitmdl.GroupPendantList `json:"pendant"`
}

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 = [
"channel.go",
"full.go",
"recruit.go",
],
importpath = "go-common/app/interface/main/web-goblin/model/web",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/interface/main/tag/model:go_default_library",
"//app/interface/main/web-goblin/conf:go_default_library",
"//app/service/main/archive/api: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,25 @@
package web
import (
tagmdl "go-common/app/interface/main/tag/model"
"go-common/app/service/main/archive/api"
)
// ChCard channel card .
type ChCard struct {
ID int64 `json:"-"`
Title string `json:"-"`
ChannelID int64 `json:"-"`
Type string `json:"-"`
Value int64 `json:"-"`
Reason string `json:"-"`
ReasonType int8 `json:"-"`
Pos int `json:"-"`
FromType string `json:"-"`
}
// Channel .
type Channel struct {
*tagmdl.Tag
Archives []*api.Arc `json:"archives"`
}

View File

@@ -0,0 +1,122 @@
package web
import (
"fmt"
"math/rand"
"time"
"go-common/app/interface/main/web-goblin/conf"
"go-common/app/service/main/archive/api"
)
const (
_deal = 100
)
// Mi mi common .
type Mi struct {
ID int64 `json:"id"`
Name string `json:"name"`
Op string `json:"op"`
AlternativeNames string `json:"alternative_names"`
Cover Img `json:"cover"`
Thumbnail Img `json:"thumbnail"`
Description string `json:"description"`
Tags string `json:"tags"`
CreateTime string `json:"create_time"`
ModifyTime string `json:"modify_time"`
PublishTime string `json:"publish_time"`
Author string `json:"author"`
Category string `json:"category"`
Rating float32 `json:"rating"`
PlayCount int32 `json:"play_count"`
PlayCountMonth int `json:"play_count_month"`
PlayCountWeek int `json:"play_count_week"`
PlayLength int64 `json:"play_length"`
Language string `json:"language"`
Images Img `json:"images"`
Weburl string `json:"weburl"`
Appurl string `json:"appurl"`
MinVersion int `json:"min_version"`
Pages []*PageInfo `json:"pages"`
CommentCount int32 `json:"comment_count"`
LikeCount int32 `json:"like_count"`
}
// PageInfo page3 .
type PageInfo struct {
Cid int64 `json:"cid"`
Page int32 `json:"page"`
}
// Img img .
type Img struct {
URL string `json:"url"`
Height int `json:"height"`
Width int `json:"width"`
}
// SearchAids return aids .
type SearchAids struct {
Aid int64 `json:"aid"`
Action string `json:"action"`
}
// FromArchive .
func (f *Mi) FromArchive(a *api.Arc, p []*api.Page, op, source string) {
f.ID = a.Aid
f.Name = a.Title
f.Author = a.Author.Name
f.Category = a.TypeName
f.Weburl = fmt.Sprintf("https://www.bilibili.com/video/av%d%s", a.Aid, source)
f.Appurl = fmt.Sprintf("bilibili://video/%d", a.Aid)
f.ModifyTime = a.PubDate.Time().Format("2006-01-02 15:04:05")
f.Description = a.Desc
f.CreateTime = a.Ctime.Time().Format("2006-01-02 15:04:05")
f.Images.URL = a.Pic
f.PlayLength = a.Duration
f.Cover.URL = a.Pic
f.Thumbnail.URL = a.Pic
f.PlayCount = a.Stat.View
f.PublishTime = a.PubDate.Time().Format("2006-01-02 15:04:05")
f.MinVersion = 1
f.Op = op
f.CommentCount = a.Stat.Reply
f.LikeCount = a.Stat.Like
pLen := len(p)
if pLen > 0 {
f.Pages = make([]*PageInfo, pLen)
for i := 0; i < pLen; i++ {
f.Pages[i] = &PageInfo{}
f.Pages[i].Page = p[i].Page
f.Pages[i].Cid = p[i].Cid
}
} else {
f.Pages = []*PageInfo{}
}
}
// UgcFullDeal .
func (f *Mi) UgcFullDeal() {
var (
lCount = conf.Conf.OutSearch.DealLikeFull
commCount = conf.Conf.OutSearch.DealCommFull
commRes = f.CommentCount + commCount
likeRes = f.LikeCount + lCount
)
if f.PlayCount+f.CommentCount > 0 {
commRes = commRes + (f.PlayCount/(f.PlayCount+f.CommentCount))*f.CommentCount
}
if f.PlayCount+f.LikeCount > 0 {
likeRes = likeRes + (f.PlayCount/(f.PlayCount+f.LikeCount))*f.LikeCount
}
f.CommentCount = commRes
f.LikeCount = likeRes
}
// UgcIncreDeal .
func (f *Mi) UgcIncreDeal() {
rand.Seed(time.Now().UnixNano())
f.CommentCount = int32(rand.Intn(_deal))
f.LikeCount = int32(rand.Intn(_deal)) + _deal
}

View File

@@ -0,0 +1,8 @@
package web
// Params .
type Params struct {
Route string `form:"route" validate:"required"`
Mode string `form:"mode" validate:"required"`
JobID string `form:"job_id"`
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["wechat.go"],
importpath = "go-common/app/interface/main/web-goblin/model/wechat",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
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 wechat
// AccessToken wechat access token.
type AccessToken struct {
AccessToken string `json:"access_token"`
ExpiresIn int64 `json:"expires_in"`
}