Create & Init Project...
This commit is contained in:
66
app/interface/main/app-card/model/card/BUILD
Normal file
66
app/interface/main/app-card/model/card/BUILD
Normal file
@ -0,0 +1,66 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"card.go",
|
||||
"double.go",
|
||||
"ipad.go",
|
||||
"single.go",
|
||||
],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/main/app-card/model:go_default_library",
|
||||
"//app/interface/main/app-card/model/bplus:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/ai:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/audio:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/bangumi:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/banner:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/cm:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/live:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/operate:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/show:go_default_library",
|
||||
"//app/interface/main/tag/model:go_default_library",
|
||||
"//app/interface/openplatform/article/model:go_default_library",
|
||||
"//app/service/main/account/model:go_default_library",
|
||||
"//app/service/main/archive/api:go_default_library",
|
||||
"//app/service/main/archive/model/archive:go_default_library",
|
||||
"//app/service/main/relation/model:go_default_library",
|
||||
"//app/service/openplatform/pgc-season/api/grpc/episode/v1:go_default_library",
|
||||
"//app/service/openplatform/pgc-season/api/grpc/season/v1:go_default_library",
|
||||
"//library/log:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "package-srcs",
|
||||
srcs = glob(["**"]),
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:private"],
|
||||
)
|
||||
|
||||
filegroup(
|
||||
name = "all-srcs",
|
||||
srcs = [
|
||||
":package-srcs",
|
||||
"//app/interface/main/app-card/model/card/ai:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/audio:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/bangumi:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/banner:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/cm:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/live:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/operate:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/rank:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/show:all-srcs",
|
||||
"//app/interface/main/app-card/model/card/topic:all-srcs",
|
||||
],
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
)
|
34
app/interface/main/app-card/model/card/ai/BUILD
Normal file
34
app/interface/main/app-card/model/card/ai/BUILD
Normal file
@ -0,0 +1,34 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["ai.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/ai",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/main/app-card/model/card/banner:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/cm:go_default_library",
|
||||
"//app/interface/main/tag/model:go_default_library",
|
||||
"//app/service/main/archive/model/archive: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"],
|
||||
)
|
52
app/interface/main/app-card/model/card/ai/ai.go
Normal file
52
app/interface/main/app-card/model/card/ai/ai.go
Normal file
@ -0,0 +1,52 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go-common/app/interface/main/app-card/model/card/banner"
|
||||
"go-common/app/interface/main/app-card/model/card/cm"
|
||||
tag "go-common/app/interface/main/tag/model"
|
||||
"go-common/app/service/main/archive/model/archive"
|
||||
)
|
||||
|
||||
type Item struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
TrackID string `json:"trackid,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Goto string `json:"goto,omitempty"`
|
||||
Tid int64 `json:"tid,omitempty"`
|
||||
From int8 `json:"from,omitempty"`
|
||||
Source string `json:"source,omitempty"`
|
||||
AvFeature json.RawMessage `json:"av_feature,omitempty"`
|
||||
Config *Config `json:"config,omitempty"`
|
||||
RcmdReason *RcmdReason `json:"rcmd_reason,omitempty"`
|
||||
StatType int8 `json:"stat_type,omitempty"`
|
||||
Style int8 `json:"style,omitempty"`
|
||||
// extra
|
||||
Archive *archive.Archive3 `json:"archive,omitempty"`
|
||||
Tag *tag.Tag `json:"tag,omitempty"`
|
||||
Ad *cm.AdInfo `json:"-"`
|
||||
Banners []*banner.Banner `json:"-"`
|
||||
Version string `json:"-"`
|
||||
HideButton bool `json:"-"`
|
||||
CornerMark int8 `json:"corner_mark,omitempty"`
|
||||
}
|
||||
|
||||
type Config struct {
|
||||
URI string `json:"uri,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
}
|
||||
|
||||
type RcmdReason struct {
|
||||
ID int `json:"id,omitempty"`
|
||||
Content string `json:"content,omitempty"`
|
||||
BgColor string `json:"bg_color,omitempty"`
|
||||
IconLocation string `json:"icon_location,omitempty"`
|
||||
Style int `json:"style,omitempty"`
|
||||
Font int `json:"font,omitempty"`
|
||||
Position string `json:"position,omitempty"`
|
||||
Grounding string `json:"grounding,omitempty"`
|
||||
CornerMark int8 `json:"corner_mark,omitempty"`
|
||||
FollowedMid int64 `json:"followed_mid,omitempty"`
|
||||
}
|
28
app/interface/main/app-card/model/card/audio/BUILD
Normal file
28
app/interface/main/app-card/model/card/audio/BUILD
Normal 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 = ["audio.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/audio",
|
||||
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"],
|
||||
)
|
23
app/interface/main/app-card/model/card/audio/audio.go
Normal file
23
app/interface/main/app-card/model/card/audio/audio.go
Normal file
@ -0,0 +1,23 @@
|
||||
package audio
|
||||
|
||||
type Audio struct {
|
||||
MenuID int64 `json:"menu_id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
CoverURL string `json:"cover_url,omitempty"`
|
||||
RecordNum int `json:"record_num,omitempty"`
|
||||
PlayNum int32 `json:"play_num,omitempty"`
|
||||
FavoriteNum int32 `json:"favorite_num,omitempty"`
|
||||
Face string `json:"face,omitempty"`
|
||||
Songs []*struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
} `json:"songs,omitempty"`
|
||||
PaTime int64 `json:"pa_time,omitempty"`
|
||||
Type int8 `json:"type,omitempty"`
|
||||
Ctgs []*Ctg `json:"ctgs,omitempty"`
|
||||
}
|
||||
|
||||
type Ctg struct {
|
||||
ItemID int64 `json:"item_id,omitempty"`
|
||||
ItemVal string `json:"item_val,omitempty"`
|
||||
Schema string `json:"schema,omitempty"`
|
||||
}
|
28
app/interface/main/app-card/model/card/bangumi/BUILD
Normal file
28
app/interface/main/app-card/model/card/bangumi/BUILD
Normal 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 = ["bangumi.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/bangumi",
|
||||
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"],
|
||||
)
|
31
app/interface/main/app-card/model/card/bangumi/bangumi.go
Normal file
31
app/interface/main/app-card/model/card/bangumi/bangumi.go
Normal file
@ -0,0 +1,31 @@
|
||||
package bangumi
|
||||
|
||||
type Season struct {
|
||||
Aid int64 `json:"aid,omitempty"`
|
||||
SeasonID int64 `json:"season_id,omitempty"`
|
||||
EpisodeID string `json:"episode_id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
PlayCount int32 `json:"play_count,omitempty"`
|
||||
Favorites int32 `json:"favorites,omitempty"`
|
||||
SeasonType int8 `json:"season_type,omitempty"`
|
||||
TypeBadge string `json:"type_badge,omitempty"`
|
||||
SeasonCover string `json:"season_cover,omitempty"`
|
||||
UpdateDesc string `json:"update_desc,omitempty"`
|
||||
}
|
||||
|
||||
type Update struct {
|
||||
SquareCover string `json:"square_cover"`
|
||||
Title string `json:"title"`
|
||||
Updates int `json:"updates"`
|
||||
}
|
||||
|
||||
type Moe struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
Square string `json:"square,omitempty"`
|
||||
}
|
29
app/interface/main/app-card/model/card/banner/BUILD
Normal file
29
app/interface/main/app-card/model/card/banner/BUILD
Normal file
@ -0,0 +1,29 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = ["banner.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/banner",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//app/service/main/resource/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"],
|
||||
)
|
51
app/interface/main/app-card/model/card/banner/banner.go
Normal file
51
app/interface/main/app-card/model/card/banner/banner.go
Normal file
@ -0,0 +1,51 @@
|
||||
package banner
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
resource "go-common/app/service/main/resource/model"
|
||||
)
|
||||
|
||||
type Banner struct {
|
||||
ID int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Image string `json:"image"`
|
||||
Hash string `json:"hash"`
|
||||
URI string `json:"uri"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
CreativeID int `json:"creative_id,omitempty"`
|
||||
SrcID int `json:"src_id,omitempty"`
|
||||
IsAd bool `json:"is_ad,omitempty"`
|
||||
IsAdLoc bool `json:"is_ad_loc,omitempty"`
|
||||
AdCb string `json:"ad_cb,omitempty"`
|
||||
ShowURL string `json:"show_url,omitempty"`
|
||||
ClickURL string `json:"click_url,omitempty"`
|
||||
ClientIP string `json:"client_ip,omitempty"`
|
||||
ServerType int `json:"server_type"`
|
||||
ResourceID int `json:"resource_id,omitempty"`
|
||||
Index int `json:"index,omitempty"`
|
||||
CmMark int `json:"cm_mark"`
|
||||
Extra json.RawMessage `json:"extra,omitempty"`
|
||||
}
|
||||
|
||||
func (b *Banner) Change(banner *resource.Banner) {
|
||||
b.ID = int64(banner.ID)
|
||||
b.Title = banner.Title
|
||||
b.Image = banner.Image
|
||||
b.Hash = banner.Hash
|
||||
b.URI = banner.URI
|
||||
b.ResourceID = banner.ResourceID
|
||||
b.RequestID = banner.RequestId
|
||||
b.CreativeID = banner.CreativeId
|
||||
b.SrcID = banner.SrcId
|
||||
b.IsAd = banner.IsAd
|
||||
b.IsAdLoc = banner.IsAdLoc
|
||||
b.CmMark = banner.CmMark
|
||||
b.AdCb = banner.AdCb
|
||||
b.ShowURL = banner.ShowUrl
|
||||
b.ClickURL = banner.ClickUrl
|
||||
b.ClientIP = banner.ClientIp
|
||||
b.Index = banner.Index
|
||||
b.ServerType = banner.ServerType
|
||||
b.Extra = banner.Extra
|
||||
}
|
636
app/interface/main/app-card/model/card/card.go
Normal file
636
app/interface/main/app-card/model/card/card.go
Normal file
@ -0,0 +1,636 @@
|
||||
package card
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/app/interface/main/app-card/model/bplus"
|
||||
"go-common/app/interface/main/app-card/model/card/ai"
|
||||
"go-common/app/interface/main/app-card/model/card/audio"
|
||||
"go-common/app/interface/main/app-card/model/card/cm"
|
||||
"go-common/app/interface/main/app-card/model/card/live"
|
||||
"go-common/app/interface/main/app-card/model/card/operate"
|
||||
"go-common/app/interface/main/app-card/model/card/show"
|
||||
tag "go-common/app/interface/main/tag/model"
|
||||
article "go-common/app/interface/openplatform/article/model"
|
||||
account "go-common/app/service/main/account/model"
|
||||
"go-common/app/service/main/archive/model/archive"
|
||||
relation "go-common/app/service/main/relation/model"
|
||||
"go-common/library/log"
|
||||
)
|
||||
|
||||
// ButtonStatus is
|
||||
type ButtonStatus struct {
|
||||
Text string
|
||||
Goto model.Gt
|
||||
Param string
|
||||
IsAtten int8
|
||||
Type model.Type
|
||||
Event model.Event
|
||||
}
|
||||
|
||||
// AvatarStatus is
|
||||
type AvatarStatus struct {
|
||||
Cover string
|
||||
Text string
|
||||
Goto model.Gt
|
||||
Param string
|
||||
Type model.Type
|
||||
}
|
||||
|
||||
// Base is
|
||||
type Base struct {
|
||||
CardType model.CardType `json:"card_type,omitempty"`
|
||||
CardGoto model.CardGt `json:"card_goto,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
DescButton *Button `json:"desc_button,omitempty"`
|
||||
ThreePoint *ThreePoint `json:"three_point,omitempty"`
|
||||
Args Args `json:"args,omitempty"`
|
||||
PlayerArgs *PlayerArgs `json:"player_args,omitempty"`
|
||||
Idx int64 `json:"idx,omitempty"`
|
||||
AdInfo *cm.AdInfo `json:"ad_info,omitempty"`
|
||||
Right bool `json:"-"`
|
||||
Rcmd *ai.Item `json:"-"`
|
||||
Tagm map[int64]*tag.Tag `json:"-"`
|
||||
IsAttenm map[int64]int8 `json:"-"`
|
||||
Statm map[int64]*relation.Stat `json:"-"`
|
||||
Cardm map[int64]*account.Card `json:"-"`
|
||||
CardLen int `json:"-"`
|
||||
Columnm model.ColumnStatus `json:"-"`
|
||||
FromType string `json:"from_type,omitempty"`
|
||||
}
|
||||
|
||||
// ThreePoint is
|
||||
type ThreePoint struct {
|
||||
DislikeReasons []*DislikeReason `json:"dislike_reasons,omitempty"`
|
||||
Feedbacks []*Feedback `json:"feedbacks,omitempty"`
|
||||
WatchLater int8 `json:"watch_later,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Base) from(param, cover, title string, gt model.Gt, uri string, f func(uri string) string) {
|
||||
c.URI = model.FillURI(gt, uri, f)
|
||||
c.Cover = cover
|
||||
c.Title = title
|
||||
if gt != "" {
|
||||
c.Goto = gt
|
||||
} else {
|
||||
c.Goto = model.Gt(c.CardGoto)
|
||||
}
|
||||
c.Param = param
|
||||
}
|
||||
|
||||
// Handler is
|
||||
type Handler interface {
|
||||
From(main interface{}, op *operate.Card)
|
||||
Get() *Base
|
||||
}
|
||||
|
||||
// Handle is
|
||||
func Handle(plat int8, cardGoto model.CardGt, cardType model.CardType, column model.ColumnStatus, rcmd *ai.Item, tagm map[int64]*tag.Tag, isAttenm map[int64]int8, statm map[int64]*relation.Stat, cardm map[int64]*account.Card) (hander Handler) {
|
||||
if model.IsIPad(plat) {
|
||||
return ipadHandle(cardGoto, cardType, rcmd, nil, isAttenm, statm, cardm)
|
||||
}
|
||||
switch model.Columnm[column] {
|
||||
case model.ColumnSvrSingle:
|
||||
return singleHandle(cardGoto, cardType, rcmd, tagm, isAttenm, statm, cardm)
|
||||
case model.ColumnSvrDouble:
|
||||
return doubleHandle(cardGoto, cardType, rcmd, tagm, isAttenm, statm, cardm)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// SwapTwoItem is
|
||||
func SwapTwoItem(rs []Handler, i Handler) (is []Handler) {
|
||||
is = append(rs, rs[len(rs)-1])
|
||||
is[len(is)-2] = i
|
||||
return
|
||||
}
|
||||
|
||||
func SwapThreeItem(rs []Handler, i Handler) (is []Handler) {
|
||||
is = append(rs, rs[len(rs)-1])
|
||||
is[len(is)-2] = i
|
||||
is[len(is)-3], is[len(is)-2] = is[len(is)-2], is[len(is)-3]
|
||||
return
|
||||
}
|
||||
|
||||
func SwapFourItem(rs []Handler, i Handler) (is []Handler) {
|
||||
is = append(rs, rs[len(rs)-1])
|
||||
is[len(is)-2] = i
|
||||
is[len(is)-3], is[len(is)-2] = is[len(is)-2], is[len(is)-3]
|
||||
is[len(is)-4], is[len(is)-3] = is[len(is)-3], is[len(is)-4]
|
||||
return
|
||||
}
|
||||
|
||||
// TopBottomRcmdReason is
|
||||
func TopBottomRcmdReason(r *ai.RcmdReason, isAtten int8, cardm map[int64]*account.Card) (topRcmdReason, bottomRcomdReason string) {
|
||||
if r == nil {
|
||||
if isAtten == 1 {
|
||||
bottomRcomdReason = "已关注"
|
||||
}
|
||||
return
|
||||
}
|
||||
switch r.Style {
|
||||
case 3:
|
||||
if isAtten != 1 {
|
||||
return
|
||||
}
|
||||
bottomRcomdReason = r.Content
|
||||
case 4:
|
||||
_, ok := cardm[r.FollowedMid]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
topRcmdReason = "关注的人赞过"
|
||||
default:
|
||||
topRcmdReason = r.Content
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Button is
|
||||
type Button struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
Event model.Event `json:"event,omitempty"`
|
||||
Selected int8 `json:"selected,omitempty"`
|
||||
Type model.Type `json:"type,omitempty"`
|
||||
}
|
||||
|
||||
func buttonFrom(v interface{}, plat int8) (button *Button) {
|
||||
switch v.(type) {
|
||||
case *tag.Tag:
|
||||
t := v.(*tag.Tag)
|
||||
if t != nil {
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: t.Name,
|
||||
URI: model.FillURI(model.GotoTag, strconv.FormatInt(t.ID, 10), nil),
|
||||
Event: model.EventChannelClick,
|
||||
}
|
||||
}
|
||||
case []*audio.Ctg:
|
||||
ctgs := v.([]*audio.Ctg)
|
||||
if len(ctgs) > 1 {
|
||||
var name string
|
||||
if ctgs[0] != nil {
|
||||
name = ctgs[0].ItemVal
|
||||
if ctgs[1] != nil {
|
||||
name += " · " + ctgs[1].ItemVal
|
||||
}
|
||||
}
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: name,
|
||||
URI: model.FillURI(model.GotoAudioTag, "", model.AudioTagHandler(ctgs)),
|
||||
Event: model.EventChannelClick,
|
||||
}
|
||||
}
|
||||
case []*article.Category:
|
||||
ctgs := v.([]*article.Category)
|
||||
if len(ctgs) > 1 {
|
||||
var name string
|
||||
if ctgs[0] != nil {
|
||||
name = ctgs[0].Name
|
||||
if ctgs[1] != nil {
|
||||
name += " · " + ctgs[1].Name
|
||||
}
|
||||
}
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: name,
|
||||
URI: model.FillURI(model.GotoArticleTag, "", model.ArticleTagHandler(ctgs, plat)),
|
||||
Event: model.EventChannelClick,
|
||||
}
|
||||
}
|
||||
case *live.Room:
|
||||
r := v.(*live.Room)
|
||||
if r != nil {
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: r.AreaV2Name,
|
||||
URI: model.FillURI(model.GotoLiveTag, strconv.FormatInt(r.AreaV2ParentID, 10), model.LiveRoomTagHandler(r)),
|
||||
Event: model.EventChannelClick,
|
||||
}
|
||||
}
|
||||
case *live.Card:
|
||||
card := v.(*live.Card)
|
||||
if card != nil {
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: card.Uname,
|
||||
URI: model.FillURI(model.GotoMid, strconv.FormatInt(card.UID, 10), nil),
|
||||
Event: model.EventUpClick,
|
||||
}
|
||||
}
|
||||
case *bplus.Picture:
|
||||
p := v.(*bplus.Picture)
|
||||
if p != nil {
|
||||
if len(p.Topics) == 0 {
|
||||
return
|
||||
}
|
||||
button = &Button{
|
||||
Type: model.ButtonGrey,
|
||||
Text: p.Topics[0],
|
||||
URI: model.FillURI(model.GotoPictureTag, p.Topics[0], nil),
|
||||
Event: model.EventChannelClick,
|
||||
}
|
||||
}
|
||||
case *ButtonStatus:
|
||||
b := v.(*ButtonStatus)
|
||||
if b != nil {
|
||||
event, ok := model.ButtonEvent[b.Goto]
|
||||
if ok {
|
||||
button = &Button{
|
||||
Text: model.ButtonText[b.Goto],
|
||||
Event: event,
|
||||
Selected: b.IsAtten,
|
||||
Type: model.ButtonTheme,
|
||||
}
|
||||
} else {
|
||||
button = &Button{
|
||||
Text: b.Text,
|
||||
Param: b.Param,
|
||||
URI: model.FillURI(b.Goto, b.Param, nil),
|
||||
}
|
||||
if b.Event != "" {
|
||||
button.Event = b.Event
|
||||
} else {
|
||||
button.Event = model.EventChannelClick
|
||||
}
|
||||
if b.Type != 0 {
|
||||
button.Type = b.Type
|
||||
} else {
|
||||
button.Type = model.ButtonGrey
|
||||
}
|
||||
}
|
||||
}
|
||||
case nil:
|
||||
default:
|
||||
log.Warn("buttonFrom: unexpected type %T", v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Avatar is
|
||||
type Avatar struct {
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Text string `json:"text,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
Type model.Type `json:"type,omitempty"`
|
||||
Event model.Event `json:"event,omitempty"`
|
||||
}
|
||||
|
||||
func avatarFrom(status *AvatarStatus) (avatar *Avatar) {
|
||||
if status == nil {
|
||||
return
|
||||
}
|
||||
avatar = &Avatar{
|
||||
Cover: status.Cover,
|
||||
Text: status.Text,
|
||||
URI: model.FillURI(status.Goto, status.Param, nil),
|
||||
Type: status.Type,
|
||||
Event: model.AvatarEvent[status.Goto],
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// DislikeReason is
|
||||
type DislikeReason struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// Feedback is
|
||||
type Feedback struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
}
|
||||
|
||||
// ThreePointFrom is
|
||||
func (c *Base) ThreePointFrom() {
|
||||
const (
|
||||
_noSeason = 1
|
||||
_region = 2
|
||||
_channel = 3
|
||||
_upper = 4
|
||||
)
|
||||
if c.CardGoto == model.CardGotoLogin || c.CardGoto == model.CardGotoBanner || c.CardGoto == model.CardGotoRank || c.CardGoto == model.CardGotoConverge || c.CardGoto == model.CardGotoBangumiRcmd || c.CardGoto == model.CardGotoInterest || c.CardGoto == model.CardGotoFollowMode {
|
||||
return
|
||||
}
|
||||
c.ThreePoint = &ThreePoint{}
|
||||
if c.CardGoto == model.CardGotoAv || c.CardGoto == model.CardGotoPlayer || c.CardGoto == model.CardGotoUpRcmdAv || c.CardGoto == model.CardGotoChannelRcmd {
|
||||
dislikeReasons := make([]*DislikeReason, 0, 4)
|
||||
if c.Args.UpName != "" {
|
||||
dislikeReasons = append(dislikeReasons, &DislikeReason{ID: _upper, Name: "UP主:" + c.Args.UpName})
|
||||
}
|
||||
if c.Args.Rname != "" {
|
||||
dislikeReasons = append(dislikeReasons, &DislikeReason{ID: _region, Name: "分区:" + c.Args.Rname})
|
||||
}
|
||||
if c.Args.Tname != "" {
|
||||
dislikeReasons = append(dislikeReasons, &DislikeReason{ID: _channel, Name: "频道:" + c.Args.Tname})
|
||||
}
|
||||
c.ThreePoint.DislikeReasons = append(dislikeReasons, &DislikeReason{ID: _noSeason, Name: "不感兴趣"})
|
||||
c.ThreePoint.Feedbacks = []*Feedback{{ID: 1, Name: "恐怖血腥"}, {ID: 2, Name: "色情低俗"}, {ID: 3, Name: "封面恶心"}, {ID: 4, Name: "标题党/封面党"}}
|
||||
c.ThreePoint.WatchLater = 1
|
||||
} else {
|
||||
c.ThreePoint.DislikeReasons = []*DislikeReason{{ID: _noSeason, Name: "不感兴趣"}}
|
||||
}
|
||||
}
|
||||
|
||||
// ThreePointChannel is
|
||||
func (c *Base) ThreePointChannel() {
|
||||
const (
|
||||
_noSeason = 1
|
||||
_upper = 4
|
||||
)
|
||||
if c.CardGoto == model.CardGotoAv || c.CardGoto == model.CardGotoPlayer || c.CardGoto == model.CardGotoUpRcmdAv {
|
||||
c.ThreePoint = &ThreePoint{}
|
||||
if c.Args.UpName != "" {
|
||||
c.ThreePoint.DislikeReasons = append(c.ThreePoint.DislikeReasons, &DislikeReason{ID: _upper, Name: "UP主:" + c.Args.UpName})
|
||||
}
|
||||
c.ThreePoint.DislikeReasons = append(c.ThreePoint.DislikeReasons, &DislikeReason{ID: _noSeason, Name: "不感兴趣"})
|
||||
c.ThreePoint.WatchLater = 1
|
||||
}
|
||||
}
|
||||
|
||||
// ThreePointWatchLater is
|
||||
func (c *Base) ThreePointWatchLater() {
|
||||
if c.CardGoto == model.CardGotoAv || c.CardGoto == model.CardGotoPlayer || c.CardGoto == model.CardGotoUpRcmdAv || c.Goto == model.GotoAv {
|
||||
c.ThreePoint = &ThreePoint{}
|
||||
c.ThreePoint.WatchLater = 1
|
||||
}
|
||||
}
|
||||
|
||||
// TabThreePointWatchLater is
|
||||
func (c *Base) TabThreePointWatchLater() {
|
||||
if c.Goto == model.GotoAv && c.CardGoto != model.CardGotoPlayer {
|
||||
c.ThreePoint = &ThreePoint{}
|
||||
c.ThreePoint.WatchLater = 1
|
||||
}
|
||||
}
|
||||
|
||||
// Args is
|
||||
type Args struct {
|
||||
Type int8 `json:"type,omitempty"`
|
||||
UpID int64 `json:"up_id,omitempty"`
|
||||
UpName string `json:"up_name,omitempty"`
|
||||
Rid int32 `json:"rid,omitempty"`
|
||||
Rname string `json:"rname,omitempty"`
|
||||
Tid int64 `json:"tid,omitempty"`
|
||||
Tname string `json:"tname,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Args) fromShopping(s *show.Shopping) {
|
||||
c.Type = s.Type
|
||||
}
|
||||
|
||||
func (c *Args) fromArchive(a *archive.Archive3, t *tag.Tag) {
|
||||
if a != nil {
|
||||
c.UpID = a.Author.Mid
|
||||
c.UpName = a.Author.Name
|
||||
c.Rid = a.TypeID
|
||||
c.Rname = a.TypeName
|
||||
}
|
||||
if t != nil {
|
||||
c.Tid = t.ID
|
||||
c.Tname = t.Name
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Args) fromLiveRoom(r *live.Room) {
|
||||
if r == nil {
|
||||
return
|
||||
}
|
||||
c.UpID = r.UID
|
||||
c.UpName = r.Uname
|
||||
c.Rid = int32(r.AreaV2ParentID)
|
||||
c.Rname = r.AreaV2ParentName
|
||||
c.Tid = r.AreaV2ID
|
||||
c.Tname = r.AreaV2Name
|
||||
}
|
||||
|
||||
func (c *Args) fromLiveUp(card *live.Card) {
|
||||
if card == nil {
|
||||
return
|
||||
}
|
||||
c.UpID = card.UID
|
||||
c.UpName = card.Uname
|
||||
}
|
||||
|
||||
func (c *Args) fromAudio(a *audio.Audio) {
|
||||
if a == nil {
|
||||
return
|
||||
}
|
||||
c.Type = a.Type
|
||||
if len(a.Ctgs) != 0 {
|
||||
c.Rid = int32(a.Ctgs[0].ItemID)
|
||||
c.Rname = a.Ctgs[0].ItemVal
|
||||
if len(a.Ctgs) > 1 {
|
||||
c.Tid = a.Ctgs[1].ItemID
|
||||
c.Tname = a.Ctgs[1].ItemVal
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Args) fromArticle(m *article.Meta) {
|
||||
if m == nil {
|
||||
return
|
||||
}
|
||||
if m.Author != nil {
|
||||
c.UpID = m.Author.Mid
|
||||
c.UpName = m.Author.Name
|
||||
}
|
||||
if len(m.Categories) != 0 {
|
||||
if m.Categories[0] != nil {
|
||||
c.Rid = int32(m.Categories[0].ID)
|
||||
c.Rname = m.Categories[0].Name
|
||||
}
|
||||
if len(m.Categories) > 1 {
|
||||
if m.Categories[1] != nil {
|
||||
c.Tid = m.Categories[1].ID
|
||||
c.Tname = m.Categories[1].Name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// PlayerArgs is
|
||||
type PlayerArgs struct {
|
||||
IsLive int8 `json:"is_live,omitempty"`
|
||||
Aid int64 `json:"aid,omitempty"`
|
||||
Cid int64 `json:"cid,omitempty"`
|
||||
RoomID int64 `json:"room_id,omitempty"`
|
||||
}
|
||||
|
||||
func playerArgsFrom(v interface{}) (playerArgs *PlayerArgs) {
|
||||
switch v.(type) {
|
||||
case *archive.Archive3:
|
||||
a := v.(*archive.Archive3)
|
||||
if a == nil || (a.AttrVal(archive.AttrBitIsPGC) == archive.AttrNo && a.Rights.Autoplay != 1) || (a.AttrVal(archive.AttrBitIsPGC) == archive.AttrYes && a.AttrVal(archive.AttrBitBadgepay) == archive.AttrYes) {
|
||||
return
|
||||
}
|
||||
playerArgs = &PlayerArgs{Aid: a.Aid, Cid: a.FirstCid}
|
||||
case *live.Room:
|
||||
r := v.(*live.Room)
|
||||
if r == nil || r.LiveStatus != 1 {
|
||||
return
|
||||
}
|
||||
playerArgs = &PlayerArgs{RoomID: r.RoomID, IsLive: 1}
|
||||
case nil:
|
||||
default:
|
||||
log.Warn("playerArgsFrom: unexpected type %T", v)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// rcmdReason
|
||||
func rcmdReason(r *ai.RcmdReason, name string, isAtten int8, cardm map[int64]*account.Card) (rcmdReason, desc string) {
|
||||
// "rcmd_reason":{"content":"已关注","font":1,"grounding":"yellow","id":3,"position":"bottom","style":3}
|
||||
if r == nil {
|
||||
if isAtten == 1 {
|
||||
rcmdReason = "已关注"
|
||||
desc = name
|
||||
}
|
||||
return
|
||||
}
|
||||
switch r.Style {
|
||||
case 3:
|
||||
if isAtten != 1 {
|
||||
return
|
||||
}
|
||||
rcmdReason = r.Content
|
||||
desc = name
|
||||
case 4:
|
||||
_, ok := cardm[r.FollowedMid]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
if r.Content == "" {
|
||||
r.Content = "关注的人赞过"
|
||||
}
|
||||
rcmdReason = r.Content
|
||||
default:
|
||||
rcmdReason = r.Content
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// ReasonStyle reason style
|
||||
type ReasonStyle struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
TextColor string `json:"text_color,omitempty"`
|
||||
BgColor string `json:"bg_color,omitempty"`
|
||||
BorderColor string `json:"border_color,omitempty"`
|
||||
BgStyle int8 `json:"bg_style,omitempty"`
|
||||
NightAlphaPercent int `json:"night_alpha_percent,omitempty"`
|
||||
}
|
||||
|
||||
func topReasonStyleFrom(rcmd *ai.Item, text string, gt model.Gt) (res *ReasonStyle) {
|
||||
if text == "" || rcmd == nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
style, bgstyle int8
|
||||
)
|
||||
if style = rcmd.CornerMark; style == 0 {
|
||||
if rcmd.RcmdReason != nil {
|
||||
if rcmd.RcmdReason.Content == "" {
|
||||
style = 0
|
||||
} else {
|
||||
style = rcmd.RcmdReason.CornerMark
|
||||
}
|
||||
}
|
||||
}
|
||||
switch style {
|
||||
case 0, 2:
|
||||
bgstyle = model.BgColorOrange
|
||||
case 1:
|
||||
bgstyle = model.BgColorTransparentOrange
|
||||
case 3:
|
||||
bgstyle = model.BgTransparentTextOrange
|
||||
case 4:
|
||||
bgstyle = model.BgColorRed
|
||||
default:
|
||||
bgstyle = model.BgColorOrange
|
||||
}
|
||||
res = reasonStyleFrom(bgstyle, text)
|
||||
return
|
||||
}
|
||||
|
||||
func bottomReasonStyleFrom(rcmd *ai.Item, text string, gt model.Gt) (res *ReasonStyle) {
|
||||
if text == "" || rcmd == nil {
|
||||
return
|
||||
}
|
||||
var (
|
||||
style, bgstyle int8
|
||||
)
|
||||
if style = rcmd.CornerMark; style == 0 {
|
||||
if rcmd.RcmdReason != nil {
|
||||
if rcmd.RcmdReason.Content == "" {
|
||||
style = 0
|
||||
} else {
|
||||
style = rcmd.RcmdReason.CornerMark
|
||||
}
|
||||
}
|
||||
}
|
||||
switch style {
|
||||
case 1:
|
||||
bgstyle = model.BgColorTransparentOrange
|
||||
case 3:
|
||||
bgstyle = model.BgTransparentTextOrange
|
||||
default:
|
||||
bgstyle = model.BgColorOrange
|
||||
}
|
||||
res = reasonStyleFrom(bgstyle, text)
|
||||
return
|
||||
}
|
||||
|
||||
func reasonStyleFrom(style int8, text string) (res *ReasonStyle) {
|
||||
res = &ReasonStyle{
|
||||
Text: text,
|
||||
}
|
||||
switch style {
|
||||
case model.BgColorOrange: //defalut
|
||||
res.TextColor = "#FFFFFFFF"
|
||||
res.BgColor = "#FFFB9E60"
|
||||
res.BorderColor = "#FFFB9E60"
|
||||
res.BgStyle = model.BgStyleFill
|
||||
case model.BgColorTransparentOrange:
|
||||
res.TextColor = "#FFFB9E60"
|
||||
res.BorderColor = "#FFFB9E60"
|
||||
res.BgStyle = model.BgStyleStroke
|
||||
case model.BgColorBlue:
|
||||
res.TextColor = "#FF23ADE5"
|
||||
res.BgColor = "#3323ADE5"
|
||||
res.BorderColor = "#3323ADE5"
|
||||
res.BgStyle = model.BgStyleFill
|
||||
case model.BgColorRed:
|
||||
res.TextColor = "#FFFFFFFF"
|
||||
res.BgColor = "#FFFB7299"
|
||||
res.BorderColor = "#FFFB7299"
|
||||
res.BgStyle = model.BgStyleFill
|
||||
case model.BgTransparentTextOrange:
|
||||
res.TextColor = "#FFFB9E60"
|
||||
res.BgStyle = model.BgStyleNoFillAndNoStroke
|
||||
case model.BgColorPurple:
|
||||
res.TextColor = "#FFFFFFFF"
|
||||
res.BgColor = "#FF7D75F2"
|
||||
res.BorderColor = "#FF7D75F2"
|
||||
res.BgStyle = model.BgStyleFill
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func unionAuthor(a *archive.ArchiveWithPlayer) (name string) {
|
||||
if a.Rights.IsCooperation == 1 {
|
||||
name = a.Author.Name + " 等联合创作"
|
||||
return
|
||||
}
|
||||
name = a.Author.Name
|
||||
return
|
||||
}
|
28
app/interface/main/app-card/model/card/cm/BUILD
Normal file
28
app/interface/main/app-card/model/card/cm/BUILD
Normal 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 = ["cm.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/cm",
|
||||
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"],
|
||||
)
|
49
app/interface/main/app-card/model/card/cm/cm.go
Normal file
49
app/interface/main/app-card/model/card/cm/cm.go
Normal file
@ -0,0 +1,49 @@
|
||||
package cm
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Ad struct {
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
AdsInfo map[int64]map[int]*AdsInfo `json:"ads_info,omitempty"`
|
||||
ClientIP string `json:"-"`
|
||||
}
|
||||
|
||||
type AdsInfo struct {
|
||||
Index int `json:"index,omitempty"`
|
||||
IsAd bool `json:"is_ad,omitempty"`
|
||||
CmMark int64 `json:"cm_mark,omitempty"`
|
||||
AdInfo *AdInfo `json:"ad_info,omitempty"`
|
||||
CardIndex int `json:"card_index,omitempty"`
|
||||
}
|
||||
|
||||
type AdInfo struct {
|
||||
CreativeID int64 `json:"creative_id,omitempty"`
|
||||
CreativeType int `json:"creative_type,omitempty"`
|
||||
CardType int `json:"card_type,omitempty"`
|
||||
CreativeContent *struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Desc string `json:"description,omitempty"`
|
||||
VideoID int64 `json:"video_id,omitempty"`
|
||||
UserName string `json:"username,omitempty"`
|
||||
ImageURL string `json:"image_url,omitempty"`
|
||||
ImageMD5 string `json:"image_md5,omitempty"`
|
||||
LogURL string `json:"log_url,omitempty"`
|
||||
LogMD5 string `json:"log_md5,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
ClickURL string `json:"click_url,omitempty"`
|
||||
ShowURL string `json:"show_url,omitempty"`
|
||||
} `json:"creative_content,omitempty"`
|
||||
AdCb string `json:"ad_cb,omitempty"`
|
||||
Resource int64 `json:"resource,omitempty"`
|
||||
Source int `json:"source,omitempty"`
|
||||
RequestID string `json:"request_id,omitempty"`
|
||||
IsAd bool `json:"is_ad,omitempty"`
|
||||
CmMark int64 `json:"cm_mark,omitempty"`
|
||||
Index int `json:"index,omitempty"`
|
||||
IsAdLoc bool `json:"is_ad_loc,omitempty"`
|
||||
CardIndex int `json:"card_index,omitempty"`
|
||||
ClientIP string `json:"client_ip,omitempty"`
|
||||
Extra json.RawMessage `json:"extra,omitempty"`
|
||||
}
|
1130
app/interface/main/app-card/model/card/double.go
Normal file
1130
app/interface/main/app-card/model/card/double.go
Normal file
File diff suppressed because it is too large
Load Diff
136
app/interface/main/app-card/model/card/ipad.go
Normal file
136
app/interface/main/app-card/model/card/ipad.go
Normal file
@ -0,0 +1,136 @@
|
||||
package card
|
||||
|
||||
import (
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/app/interface/main/app-card/model/card/ai"
|
||||
"go-common/app/interface/main/app-card/model/card/operate"
|
||||
tag "go-common/app/interface/main/tag/model"
|
||||
account "go-common/app/service/main/account/model"
|
||||
"go-common/app/service/main/archive/model/archive"
|
||||
relation "go-common/app/service/main/relation/model"
|
||||
"go-common/library/log"
|
||||
)
|
||||
|
||||
func ipadHandle(cardGoto model.CardGt, cardType model.CardType, rcmd *ai.Item, tagm map[int64]*tag.Tag, isAttenm map[int64]int8, statm map[int64]*relation.Stat, cardm map[int64]*account.Card) (hander Handler) {
|
||||
base := &Base{CardGoto: cardGoto, Rcmd: rcmd, Tagm: tagm, IsAttenm: isAttenm, Statm: statm, Cardm: cardm, Columnm: model.ColumnSvrSingle}
|
||||
switch cardType {
|
||||
default:
|
||||
switch cardGoto {
|
||||
case model.CardGotoAv, model.CardGotoBangumi, model.CardGotoLive, model.CardGotoPGC:
|
||||
base.CardType = model.LargeCoverV1
|
||||
base.CardLen = 1
|
||||
hander = &LargeCoverV1{Base: base}
|
||||
case model.CardGotoBangumiRcmd:
|
||||
base.CardType = model.SmallCoverV1
|
||||
hander = &SmallCoverV1{Base: base}
|
||||
case model.CardGotoRank:
|
||||
base.CardType = model.FourItemHV3
|
||||
hander = &FourItemV3{Base: base}
|
||||
case model.CardGotoLogin:
|
||||
base.CardType = model.CoverOnlyV3
|
||||
base.CardLen = 1
|
||||
hander = &CoverOnly{Base: base}
|
||||
case model.CardGotoBanner:
|
||||
base.CardType = model.BannerV3
|
||||
hander = &Banner{Base: base}
|
||||
case model.CardGotoAdAv:
|
||||
base.CardType = model.CmV1
|
||||
base.CardLen = 1
|
||||
hander = &LargeCoverV1{Base: base}
|
||||
case model.CardGotoAdWebS:
|
||||
base.CardType = model.CmV1
|
||||
base.CardLen = 1
|
||||
hander = &SmallCoverV1{Base: base}
|
||||
case model.CardGotoAdWeb:
|
||||
base.CardType = model.CmV1
|
||||
base.CardLen = 2
|
||||
hander = &SmallCoverV1{Base: base}
|
||||
case model.CardGotoSearchUpper:
|
||||
base.CardType = model.ThreeItemAll
|
||||
hander = &ThreeItemAll{Base: base}
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type FourItemV3 struct {
|
||||
*Base
|
||||
TitleIcon model.Icon `json:"title_icon,omitempty"`
|
||||
BannerCover string `json:"banner_cover,omitempty"`
|
||||
BannerURI string `json:"banner_uri,omitempty"`
|
||||
MoreURI string `json:"more_uri,omitempty"`
|
||||
MoreText string `json:"more_text,omitempty"`
|
||||
Items []*FourItemV3Item `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
type FourItemV3Item struct {
|
||||
Base
|
||||
CoverLeftText string `json:"cover_left_text,omitempty"`
|
||||
CoverLeftIcon model.Icon `json:"cover_left_icon,omitempty"`
|
||||
Desc1 string `json:"desc_1,omitempty"`
|
||||
Desc2 string `json:"desc_2,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
}
|
||||
|
||||
func (c *FourItemV3) From(main interface{}, op *operate.Card) {
|
||||
switch main.(type) {
|
||||
case map[model.Gt]interface{}:
|
||||
intfcm := main.(map[model.Gt]interface{})
|
||||
if op == nil {
|
||||
return
|
||||
}
|
||||
switch op.CardGoto {
|
||||
case model.CardGotoRank:
|
||||
const (
|
||||
_title = "全站排行榜"
|
||||
_limit = 4
|
||||
)
|
||||
c.Base.from("0", "", _title, "", "", nil)
|
||||
// c.TitleIcon = model.IconRank
|
||||
c.MoreURI = model.FillURI(op.Goto, op.URI, nil)
|
||||
c.MoreText = "查看更多"
|
||||
c.Items = make([]*FourItemV3Item, 0, _limit)
|
||||
for _, v := range op.Items {
|
||||
if v == nil {
|
||||
continue
|
||||
}
|
||||
intfc, ok := intfcm[v.Goto]
|
||||
if !ok {
|
||||
continue
|
||||
}
|
||||
am := intfc.(map[int64]*archive.ArchiveWithPlayer)
|
||||
a, ok := am[v.ID]
|
||||
if !ok || !model.AvIsNormal(a) {
|
||||
continue
|
||||
}
|
||||
item := &FourItemV3Item{
|
||||
CoverLeftText: model.DurationString(a.Duration),
|
||||
Desc1: model.ScoreString(v.Score),
|
||||
}
|
||||
item.Base.from(v.Param, a.Pic, a.Title, model.GotoAv, v.URI, model.AvPlayHandler(a.Archive3, a.PlayerInfo, op.TrackID))
|
||||
item.Args.fromArchive(a.Archive3, nil)
|
||||
c.Items = append(c.Items, item)
|
||||
if len(c.Items) == _limit {
|
||||
break
|
||||
}
|
||||
}
|
||||
if len(c.Items) < _limit {
|
||||
return
|
||||
}
|
||||
c.Items[0].CoverLeftIcon = model.IconGoldMedal
|
||||
c.Items[1].CoverLeftIcon = model.IconSilverMedal
|
||||
c.Items[2].CoverLeftIcon = model.IconBronzeMedal
|
||||
default:
|
||||
log.Warn("FourItemV3 From: unexpected card_goto %s", op.CardGoto)
|
||||
return
|
||||
}
|
||||
default:
|
||||
log.Warn("FourItemV3 From: unexpected type %T", main)
|
||||
return
|
||||
}
|
||||
c.Right = true
|
||||
}
|
||||
|
||||
func (c *FourItemV3) Get() *Base {
|
||||
return c.Base
|
||||
}
|
28
app/interface/main/app-card/model/card/live/BUILD
Normal file
28
app/interface/main/app-card/model/card/live/BUILD
Normal 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 = ["live.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/live",
|
||||
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"],
|
||||
)
|
71
app/interface/main/app-card/model/card/live/live.go
Normal file
71
app/interface/main/app-card/model/card/live/live.go
Normal file
@ -0,0 +1,71 @@
|
||||
package live
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type Room struct {
|
||||
UID int64 `json:"uid,omitempty"`
|
||||
RoomID int64 `json:"room_id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Uname string `json:"uname,omitempty"`
|
||||
Face string `json:"face,omitempty"`
|
||||
Online int32 `json:"online,omitempty"`
|
||||
LiveStatus int8 `json:"live_status,omitempty"`
|
||||
AreaV2ParentID int64 `json:"area_v2_parent_id,omitempty"`
|
||||
AreaV2ParentName string `json:"area_v2_parent_name,omitempty"`
|
||||
AreaV2ID int64 `json:"area_v2_id,omitempty"`
|
||||
AreaV2Name string `json:"area_v2_name,omitempty"`
|
||||
BroadcastType int `json:"broadcast_type,omitempty"`
|
||||
}
|
||||
|
||||
type Card struct {
|
||||
RoomID int64 `json:"roomid,omitempty"`
|
||||
UID int64 `json:"uid,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Uname string `json:"uname,omitempty"`
|
||||
ShowCover string `json:"show_cover,omitempty"`
|
||||
Online int32 `json:"online,omitempty"`
|
||||
LiveStatus int8 `json:"live_status,omitempty"`
|
||||
BroadcastType int `json:"broadcast_type,omitempty"`
|
||||
}
|
||||
|
||||
type TopicHot struct {
|
||||
TID int `json:"topic_id"`
|
||||
TName string `json:"topic_name"`
|
||||
Picture string `json:"picture"`
|
||||
ImageURL string `json:"-"`
|
||||
}
|
||||
|
||||
type TopicImage struct {
|
||||
ImageSrc string `json:"image_src"`
|
||||
ImageWidth int `json:"image_width"`
|
||||
ImageHeight int `json:"image_height"`
|
||||
}
|
||||
|
||||
type DynamicHot struct {
|
||||
ID int64 `json:"dynamic_id"`
|
||||
AuditStatus int `json:"audit_status"`
|
||||
DeleteStatus int `json:"delete_status"`
|
||||
MID int64 `json:"mid"`
|
||||
NickName string `json:"nick_name"`
|
||||
FaceImg string `json:"face_img"`
|
||||
RidType int `json:"rid_type"`
|
||||
RID int64 `json:"rid"`
|
||||
ViewCount int64 `json:"view_count"`
|
||||
CommentCount int64 `json:"comment_count"`
|
||||
RcmdReason string `json:"rcmd_reason"`
|
||||
DynamicText string `json:"dynamic_text"`
|
||||
ImgCount int `json:"img_count"`
|
||||
Imgs []string `json:"imgs"`
|
||||
}
|
||||
|
||||
func (t *TopicHot) TopicJSONChange() (err error) {
|
||||
var tmp TopicImage
|
||||
if err = json.Unmarshal([]byte(t.Picture), &tmp); err != nil {
|
||||
return
|
||||
}
|
||||
t.ImageURL = tmp.ImageSrc
|
||||
return
|
||||
}
|
45
app/interface/main/app-card/model/card/operate/BUILD
Normal file
45
app/interface/main/app-card/model/card/operate/BUILD
Normal 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 = [
|
||||
"cardset.go",
|
||||
"converge.go",
|
||||
"download.go",
|
||||
"eventtopic.go",
|
||||
"follow.go",
|
||||
"operate.go",
|
||||
"special.go",
|
||||
"tab.go",
|
||||
],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/operate",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/interface/main/app-card/model:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/banner:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/cm:go_default_library",
|
||||
"//app/interface/main/app-card/model/card/rank:go_default_library",
|
||||
"//library/log: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"],
|
||||
)
|
14
app/interface/main/app-card/model/card/operate/cardset.go
Normal file
14
app/interface/main/app-card/model/card/operate/cardset.go
Normal file
@ -0,0 +1,14 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
)
|
||||
|
||||
type CardSet struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Value int64 `json:"value,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
LongTitle string `json:"long_title,omitempty"`
|
||||
Content json.RawMessage `json:"content,omitempty"`
|
||||
}
|
57
app/interface/main/app-card/model/card/operate/converge.go
Normal file
57
app/interface/main/app-card/model/card/operate/converge.go
Normal file
@ -0,0 +1,57 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"strconv"
|
||||
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/library/log"
|
||||
)
|
||||
|
||||
type Converge struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
ReType int `json:"re_type,omitempty"`
|
||||
ReValue string `json:"re_value,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Content json.RawMessage `json:"content,omitempty"`
|
||||
// extra
|
||||
Items []*Converge `json:"contents,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Pid int64 `json:"pid,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Converge) Change() {
|
||||
var contents []*struct {
|
||||
Ctype string `json:"ctype,omitempty"`
|
||||
Cvalue string `json:"cvalue,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(c.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
c.Goto = model.OperateType[c.ReType]
|
||||
c.Param = c.ReValue
|
||||
c.URI = model.FillURI(c.Goto, c.Param, nil)
|
||||
c.Items = make([]*Converge, 0, len(contents))
|
||||
for _, content := range contents {
|
||||
var gt model.Gt
|
||||
id, _ := strconv.ParseInt(content.Cvalue, 10, 64)
|
||||
if id == 0 {
|
||||
continue
|
||||
}
|
||||
switch content.Ctype {
|
||||
case "0":
|
||||
gt = model.GotoAv
|
||||
case "1":
|
||||
gt = model.GotoLive
|
||||
case "2":
|
||||
gt = model.GotoArticle
|
||||
default:
|
||||
continue
|
||||
}
|
||||
c.Items = append(c.Items, &Converge{Pid: id, Goto: gt})
|
||||
}
|
||||
}
|
35
app/interface/main/app-card/model/card/operate/download.go
Normal file
35
app/interface/main/app-card/model/card/operate/download.go
Normal file
@ -0,0 +1,35 @@
|
||||
package operate
|
||||
|
||||
import "go-common/app/interface/main/app-card/model"
|
||||
|
||||
type Download struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
URLType int `json:"url_type,omitempty"`
|
||||
URLValue string `json:"url_value,omitempty"`
|
||||
BtnTxt int `json:"btn_txt,omitempty"`
|
||||
ReType int `json:"re_type,omitempty"`
|
||||
ReValue string `json:"re_value,omitempty"`
|
||||
DoubleCover string `json:"double_cover,omitempty"`
|
||||
Number int32 `json:"number,omitempty"`
|
||||
// extra
|
||||
ButtonText string `json:"button_text,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Download) Change() {
|
||||
switch c.BtnTxt {
|
||||
case 0:
|
||||
c.ButtonText = "下载"
|
||||
case 1:
|
||||
c.ButtonText = "预约"
|
||||
case 2:
|
||||
c.ButtonText = "查看详情"
|
||||
}
|
||||
c.Goto = model.OperateType[c.URLType]
|
||||
c.Param = c.URLValue
|
||||
}
|
11
app/interface/main/app-card/model/card/operate/eventtopic.go
Normal file
11
app/interface/main/app-card/model/card/operate/eventtopic.go
Normal file
@ -0,0 +1,11 @@
|
||||
package operate
|
||||
|
||||
type EventTopic struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
ReType int8 `json:"re_type,omitempty"`
|
||||
ReValue string `json:"re_value,omitempty"`
|
||||
Corner string `json:"corner,omitempty"`
|
||||
}
|
60
app/interface/main/app-card/model/card/operate/follow.go
Normal file
60
app/interface/main/app-card/model/card/operate/follow.go
Normal file
@ -0,0 +1,60 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/library/log"
|
||||
)
|
||||
|
||||
type Follow struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Content json.RawMessage `json:"content,omitempty"`
|
||||
// extra
|
||||
Items []*Follow `json:"items,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Pid int64 `json:"pid,omitempty"`
|
||||
Tid int64 `json:"tid,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Follow) Change() {
|
||||
switch c.Type {
|
||||
case "upper", "channel_three":
|
||||
var contents []*struct {
|
||||
Ctype string `json:"ctype,omitempty"`
|
||||
Cvalue int64 `json:"cvalue,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(c.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
items := make([]*Follow, 0, len(contents))
|
||||
for _, content := range contents {
|
||||
item := &Follow{Type: content.Ctype, Pid: content.Cvalue}
|
||||
switch content.Ctype {
|
||||
case "mid":
|
||||
item.Goto = model.GotoMid
|
||||
case "channel_id":
|
||||
item.Goto = model.GotoTag
|
||||
}
|
||||
items = append(items, item)
|
||||
}
|
||||
if len(items) < 3 {
|
||||
return
|
||||
}
|
||||
c.Items = items
|
||||
case "channel_single":
|
||||
var content struct {
|
||||
Aid int64 `json:"aid"`
|
||||
ChannelID int64 `json:"channel_id"`
|
||||
}
|
||||
if err := json.Unmarshal(c.Content, &content); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
c.Pid = content.Aid
|
||||
c.Tid = content.ChannelID
|
||||
}
|
||||
}
|
463
app/interface/main/app-card/model/card/operate/operate.go
Normal file
463
app/interface/main/app-card/model/card/operate/operate.go
Normal file
@ -0,0 +1,463 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/app/interface/main/app-card/model/card/banner"
|
||||
"go-common/app/interface/main/app-card/model/card/cm"
|
||||
"go-common/app/interface/main/app-card/model/card/rank"
|
||||
"go-common/library/log"
|
||||
"sort"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type Card struct {
|
||||
Plat int8 `json:"plat,omitempty"`
|
||||
Build int `json:"build,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
CardGoto model.CardGt `json:"card_goto,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
URI string `json:"uri,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Coverm map[model.ColumnStatus]string `json:"coverm,omitempty"`
|
||||
Avatar string `json:"avatar,omitempty"`
|
||||
Download int32 `json:"download,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
Ratio int `json:"ratio,omitempty"`
|
||||
Score int32 `json:"score,omitempty"`
|
||||
Tid int64 `json:"tid,omitempty"`
|
||||
Subtitle string `json:"subtitle,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
Items []*Card `json:"items,omitempty"`
|
||||
AdInfo *cm.AdInfo `json:"ad_info,omitempty"`
|
||||
Banner []*banner.Banner `json:"banner,omitempty"`
|
||||
Hash string `json:"verson,omitempty"`
|
||||
TrackID string `json:"trackid,omitempty"`
|
||||
FromType string `json:"from_type,omitempty"`
|
||||
ShowUGCPay bool `json:"show_ucg_pay,omitempty"`
|
||||
Switch model.Switch `json:"switch,omitempty"`
|
||||
SwitchLike model.Switch `json:"switch_like,omitempty"`
|
||||
Buttons []*Button `json:"buttons,omitempty"`
|
||||
}
|
||||
|
||||
type Button struct {
|
||||
Text string `json:"text,omitempty"`
|
||||
Event string `json:"event,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Card) From(cardGoto model.CardGt, id int64, tid int64, plat int8, build int) {
|
||||
c.CardGoto = cardGoto
|
||||
c.ID = id
|
||||
c.Tid = tid
|
||||
c.Goto = model.Gt(cardGoto)
|
||||
c.Param = strconv.FormatInt(id, 10)
|
||||
c.URI = strconv.FormatInt(id, 10)
|
||||
c.Plat = plat
|
||||
c.Build = build
|
||||
}
|
||||
|
||||
func (c *Card) FromSwitch(sw model.Switch) {
|
||||
c.SwitchLike = sw
|
||||
}
|
||||
|
||||
func (c *Card) FromDownload(o *Download) {
|
||||
c.CardGoto = model.CardGotoDownload
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.Coverm = map[model.ColumnStatus]string{model.ColumnSvrSingle: o.Cover, model.ColumnSvrDouble: o.DoubleCover}
|
||||
c.Title = o.Title
|
||||
c.Goto = model.OperateType[o.URLType]
|
||||
c.URI = o.URLValue
|
||||
c.Avatar = o.Icon
|
||||
c.Download = o.Number
|
||||
c.Desc = o.Desc
|
||||
}
|
||||
|
||||
func (c *Card) FromSpecial(o *Special) {
|
||||
c.CardGoto = model.CardGotoSpecial
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.Coverm = map[model.ColumnStatus]string{model.ColumnSvrSingle: o.SingleCover, model.ColumnSvrDouble: o.Cover}
|
||||
c.Title = o.Title
|
||||
c.Goto = model.OperateType[o.ReType]
|
||||
c.URI = o.ReValue
|
||||
c.Desc = o.Desc
|
||||
c.Badge = o.Badge
|
||||
if o.Size == "1020x300" {
|
||||
c.Ratio = 34
|
||||
} else if o.Size == "1020x378" {
|
||||
c.Ratio = 27
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Card) FromTopstick(o *Special) {
|
||||
c.CardGoto = model.CardGotoTopstick
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.Title = o.Title
|
||||
c.Goto = model.OperateType[o.ReType]
|
||||
c.URI = o.ReValue
|
||||
c.Desc = o.Desc
|
||||
c.Badge = o.Badge
|
||||
}
|
||||
|
||||
func (c *Card) FromFollow(o *Follow) {
|
||||
switch o.Type {
|
||||
case "upper", "channel_three":
|
||||
var contents []*struct {
|
||||
Ctype string `json:"ctype,omitempty"`
|
||||
Cvalue int64 `json:"cvalue,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
items := make([]*Card, 0, len(contents))
|
||||
for _, content := range contents {
|
||||
var gt model.Gt
|
||||
switch content.Ctype {
|
||||
case "mid":
|
||||
gt = model.GotoMid
|
||||
case "channel_id":
|
||||
gt = model.GotoTag
|
||||
default:
|
||||
continue
|
||||
}
|
||||
items = append(items, &Card{ID: content.Cvalue, Goto: gt, Param: strconv.FormatInt(content.Cvalue, 10), URI: strconv.FormatInt(content.Cvalue, 10)})
|
||||
}
|
||||
if len(items) < 3 {
|
||||
return
|
||||
}
|
||||
c.Items = items
|
||||
c.CardGoto = model.CardGotoSubscribe
|
||||
c.Title = o.Title
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
case "channel_single":
|
||||
var content struct {
|
||||
Aid int64 `json:"aid"`
|
||||
ChannelID int64 `json:"channel_id"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &content); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
c.CardGoto = model.CardGotoChannelRcmd
|
||||
c.Title = o.Title
|
||||
c.ID = content.Aid
|
||||
c.Tid = content.ChannelID
|
||||
c.Goto = model.GotoAv
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.URI = strconv.FormatInt(content.Aid, 10)
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Card) FromConverge(o *Converge) {
|
||||
c.CardGoto = model.CardGotoConverge
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.Coverm = map[model.ColumnStatus]string{model.ColumnSvrSingle: o.Cover, model.ColumnSvrDouble: o.Cover}
|
||||
c.Title = o.Title
|
||||
c.Goto = model.OperateType[o.ReType]
|
||||
c.URI = o.ReValue
|
||||
var contents []*struct {
|
||||
Ctype string `json:"ctype,omitempty"`
|
||||
Cvalue string `json:"cvalue,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
c.Items = make([]*Card, 0, len(contents))
|
||||
for _, content := range contents {
|
||||
var (
|
||||
gt model.Gt
|
||||
cardGt model.CardGt
|
||||
)
|
||||
id, _ := strconv.ParseInt(content.Cvalue, 10, 64)
|
||||
if id == 0 {
|
||||
continue
|
||||
}
|
||||
switch content.Ctype {
|
||||
case "0":
|
||||
gt = model.GotoAv
|
||||
cardGt = model.CardGotoAv
|
||||
case "1":
|
||||
gt = model.GotoLive
|
||||
cardGt = model.CardGotoLive
|
||||
case "2":
|
||||
gt = model.GotoArticle
|
||||
cardGt = model.CardGotoArticleS
|
||||
default:
|
||||
continue
|
||||
}
|
||||
c.Items = append(c.Items, &Card{ID: id, CardGoto: cardGt, Goto: gt, Param: content.Cvalue, URI: content.Cvalue})
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Card) FromRank(os []*rank.Rank) {
|
||||
c.CardGoto = model.CardGotoRank
|
||||
c.Goto = model.GotoRank
|
||||
c.Items = make([]*Card, 0, len(os))
|
||||
for _, o := range os {
|
||||
c.Items = append(c.Items, &Card{Goto: model.GotoAv, ID: o.Aid, Param: strconv.FormatInt(o.Aid, 10), URI: strconv.FormatInt(o.Aid, 10), Score: o.Score})
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Card) FromActive(o *Active) {
|
||||
switch o.Type {
|
||||
case "live", "player_live", "converge", "special", "archive", "player":
|
||||
var id int64
|
||||
if err := json.Unmarshal(o.Content, &id); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
if id < 1 {
|
||||
return
|
||||
}
|
||||
c.ID = id
|
||||
c.Param = strconv.FormatInt(id, 10)
|
||||
switch o.Type {
|
||||
case "live":
|
||||
c.CardGoto = model.CardGotoPlayerLive
|
||||
case "converge":
|
||||
c.CardGoto = model.CardGotoConverge
|
||||
case "special":
|
||||
c.CardGoto = model.CardGotoSpecial
|
||||
case "archive":
|
||||
c.CardGoto = model.CardGotoPlayer
|
||||
}
|
||||
case "basic", "content_rcmd":
|
||||
var basic struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Subtitle string `json:"subtitle,omitempty"`
|
||||
Sublink string `json:"sublink,omitempty"`
|
||||
Content []*struct {
|
||||
LinkType string `json:"link_type,omitempty"`
|
||||
LinkValue string `json:"link_value,omitempty"`
|
||||
} `json:"content,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &basic); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
items := make([]*Card, 0, len(basic.Content))
|
||||
for _, c := range basic.Content {
|
||||
typ, _ := strconv.Atoi(c.LinkType)
|
||||
id, _ := strconv.ParseInt(c.LinkValue, 10, 64)
|
||||
ri := &Card{Goto: model.OperateType[typ], ID: id, Param: c.LinkValue}
|
||||
if ri.Goto != "" {
|
||||
items = append(items, ri)
|
||||
}
|
||||
}
|
||||
if len(items) == 0 {
|
||||
return
|
||||
}
|
||||
c.Items = items
|
||||
c.Title = basic.Title
|
||||
c.Subtitle = basic.Subtitle
|
||||
c.URI = basic.Sublink
|
||||
c.CardGoto = model.CardGotoContentRcmd
|
||||
case "shortcut", "entrance", "banner":
|
||||
var card struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
CardItem []*CardItem `json:"card_item,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &card); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
items := make([]*Card, 0, len(card.CardItem))
|
||||
sort.Sort(CardItems(card.CardItem))
|
||||
for _, v := range card.CardItem {
|
||||
typ, _ := strconv.Atoi(v.LinkType)
|
||||
id, _ := strconv.ParseInt(v.LinkValue, 10, 64)
|
||||
item := &Card{Goto: model.OperateType[typ], ID: id, Param: v.LinkValue, URI: v.LinkValue, Title: v.Title, Cover: v.Cover}
|
||||
if item.Goto != "" {
|
||||
items = append(items, item)
|
||||
}
|
||||
}
|
||||
if len(items) == 0 {
|
||||
return
|
||||
}
|
||||
c.Items = items
|
||||
switch o.Type {
|
||||
case "shortcut", "entrance":
|
||||
c.CardGoto = model.CardGotoEntrance
|
||||
case "banner":
|
||||
c.CardGoto = model.CardGotoBanner
|
||||
}
|
||||
case "common", "background":
|
||||
c.Title = o.Name
|
||||
c.Cover = o.Background
|
||||
case "tag", "tag_rcmd":
|
||||
var tag struct {
|
||||
AidStr string `json:"aid,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
NumberStr string `json:"number,omitempty"`
|
||||
Tid int64 `json:"-"`
|
||||
Number int `json:"-"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &tag); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
tag.Tid, _ = strconv.ParseInt(tag.AidStr, 10, 64)
|
||||
tag.Number, _ = strconv.Atoi(tag.NumberStr)
|
||||
if tag.Tid == 0 {
|
||||
return
|
||||
}
|
||||
c.ID = tag.Tid
|
||||
c.Limit = tag.Number
|
||||
c.Goto = model.GotoTag
|
||||
c.CardGoto = model.CardGotoTagRcmd
|
||||
c.Subtitle = "查看更多"
|
||||
case "news":
|
||||
var news struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &news); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
if news.Body == "" {
|
||||
return
|
||||
}
|
||||
c.Title = news.Title
|
||||
c.Desc = news.Body
|
||||
c.URI = news.Link
|
||||
c.Goto = model.GotoWeb
|
||||
c.CardGoto = model.CardGotoNews
|
||||
}
|
||||
c.Title = o.Title
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
}
|
||||
|
||||
func (c *Card) FromAdAv(o *cm.AdInfo) {
|
||||
c.CardGoto = model.CardGotoAdAv
|
||||
c.AdInfo = o
|
||||
}
|
||||
|
||||
func (c *Card) FromActiveBanner(os []*Active, hash string) {
|
||||
c.Banner = make([]*banner.Banner, 0, len(os))
|
||||
for _, o := range os {
|
||||
banner := &banner.Banner{ID: o.Pid, Title: o.Title, Image: o.Cover, URI: model.FillURI(o.Goto, o.Param, nil)}
|
||||
c.Banner = append(c.Banner, banner)
|
||||
}
|
||||
c.CardGoto = model.CardGotoBanner
|
||||
c.Hash = hash
|
||||
}
|
||||
|
||||
func (c *Card) FromBanner(os []*banner.Banner, hash string) {
|
||||
if len(os) == 0 {
|
||||
return
|
||||
}
|
||||
c.Banner = os
|
||||
c.CardGoto = model.CardGotoBanner
|
||||
c.Hash = hash
|
||||
}
|
||||
|
||||
func (c *Card) FromLogin(o int64) {
|
||||
if !model.IsIPad(c.Plat) {
|
||||
if o != 0 {
|
||||
c.Param = strconv.FormatInt(o, 10)
|
||||
} else {
|
||||
c.Param = "1"
|
||||
}
|
||||
} else {
|
||||
c.Param = "5"
|
||||
}
|
||||
c.CardGoto = model.CardGotoLogin
|
||||
}
|
||||
|
||||
func (c *Card) FromCardSet(o *CardSet) {
|
||||
switch o.Type {
|
||||
case "pgcs_rcmd":
|
||||
var contents []*struct {
|
||||
ID interface{} `json:"id,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
for _, content := range contents {
|
||||
var cid int64
|
||||
switch v := content.ID.(type) {
|
||||
case string:
|
||||
cid, _ = strconv.ParseInt(v, 10, 64)
|
||||
case float64:
|
||||
cid = int64(v)
|
||||
}
|
||||
item := &Card{ID: cid, Goto: model.GotoPGC}
|
||||
c.Items = append(c.Items, item)
|
||||
}
|
||||
c.Title = o.Title
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.CardGoto = model.CardGotoPgcsRcmd
|
||||
case "up_rcmd_new":
|
||||
var contents []*struct {
|
||||
ID interface{} `json:"id,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(o.Content, &contents); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
for _, content := range contents {
|
||||
var aid int64
|
||||
switch v := content.ID.(type) {
|
||||
case string:
|
||||
aid, _ = strconv.ParseInt(v, 10, 64)
|
||||
case float64:
|
||||
aid = int64(v)
|
||||
}
|
||||
item := &Card{ID: aid, Goto: model.GotoAv}
|
||||
c.Items = append(c.Items, item)
|
||||
}
|
||||
c.Title = "新星卡片"
|
||||
c.Desc = o.Title
|
||||
c.Param = strconv.FormatInt(o.Value, 10)
|
||||
c.ID = o.Value
|
||||
c.CardGoto = model.CardGotoUpRcmdNew
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Card) FromFollowMode(title, desc string, button []string) {
|
||||
c.Title = title
|
||||
if c.Title == "" {
|
||||
c.Title = "启用首页推荐 - 关注模式(内测版)"
|
||||
}
|
||||
c.Desc = desc
|
||||
if c.Desc == "" {
|
||||
c.Desc = "我们根据你对bilibili推荐的反馈,为你定制了关注模式。开启后,仅为你显示关注UP主更新的视频哦。尝试体验一下?"
|
||||
}
|
||||
if len(button) == 2 {
|
||||
c.Buttons = []*Button{
|
||||
{Text: button[0], Event: "close"},
|
||||
{Text: button[1], Event: "follow_mode"},
|
||||
}
|
||||
} else {
|
||||
c.Buttons = []*Button{
|
||||
{Text: "暂不需要", Event: "close"},
|
||||
{Text: "立即开启", Event: "follow_mode"},
|
||||
}
|
||||
}
|
||||
c.CardGoto = model.CardGotoFollowMode
|
||||
}
|
||||
|
||||
func (c *Card) FromEventTopic(o *EventTopic) {
|
||||
c.Title = o.Title
|
||||
c.Desc = o.Desc
|
||||
c.Cover = o.Cover
|
||||
switch o.ReType {
|
||||
case 1:
|
||||
c.Goto = model.Gt("topic")
|
||||
case 2:
|
||||
c.Goto = model.Gt("broadcast")
|
||||
case 3:
|
||||
c.Goto = model.Gt("channel")
|
||||
}
|
||||
c.Param = strconv.FormatInt(o.ID, 10)
|
||||
c.URI = o.ReValue
|
||||
c.Badge = o.Corner
|
||||
}
|
38
app/interface/main/app-card/model/card/operate/special.go
Normal file
38
app/interface/main/app-card/model/card/operate/special.go
Normal file
@ -0,0 +1,38 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
)
|
||||
|
||||
type Special struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
SingleCover string `json:"single_cover,omitempty"`
|
||||
ReType int `json:"re_type,omitempty"`
|
||||
ReValue string `json:"re_value,omitempty"`
|
||||
Badge string `json:"badge,omitempty"`
|
||||
Size string `json:"size,omitempty"`
|
||||
// extra
|
||||
Ratio int `json:"ratio,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
Pid int64 `json:"pid,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Special) Change() {
|
||||
if c.SingleCover == "" {
|
||||
c.SingleCover = c.Cover
|
||||
}
|
||||
if c.Size == "1020x300" {
|
||||
c.Ratio = 34
|
||||
} else if c.Size == "1020x378" {
|
||||
c.Ratio = 24
|
||||
}
|
||||
c.Goto = model.OperateType[c.ReType]
|
||||
c.Param = c.ReValue
|
||||
c.Pid, _ = strconv.ParseInt(c.Param, 10, 64)
|
||||
}
|
230
app/interface/main/app-card/model/card/operate/tab.go
Normal file
230
app/interface/main/app-card/model/card/operate/tab.go
Normal file
@ -0,0 +1,230 @@
|
||||
package operate
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"sort"
|
||||
"strconv"
|
||||
|
||||
"go-common/app/interface/main/app-card/model"
|
||||
"go-common/library/log"
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
type Menu struct {
|
||||
TabID int64 `json:"tab_id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Img string `json:"img,omitempty"`
|
||||
Icon string `json:"icon,omitempty"`
|
||||
Color string `json:"color,omitempty"`
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Plat int `json:"-"`
|
||||
CType int `json:"-"`
|
||||
CValue string `json:"-"`
|
||||
PlatVersion json.RawMessage `json:"-"`
|
||||
STime xtime.Time `json:"-"`
|
||||
ETime xtime.Time `json:"-"`
|
||||
Status int `json:"-"`
|
||||
Badge string `json:"-"`
|
||||
Versions map[int8][]*Version `json:"-"`
|
||||
}
|
||||
|
||||
type Version struct {
|
||||
PlatStr string `json:"plat,omitempty"`
|
||||
BuildStr string `json:"build,omitempty"`
|
||||
Condition string `json:"conditions,omitempty"`
|
||||
Plat int8 `json:"-"`
|
||||
Build int `json:"-"`
|
||||
}
|
||||
|
||||
func (m *Menu) Change() {
|
||||
m.Icon = m.Badge
|
||||
var vs []*Version
|
||||
if err := json.Unmarshal(m.PlatVersion, &vs); err != nil {
|
||||
log.Error("json.Unmarshal(%s) error(%v)", m.PlatVersion, err)
|
||||
return
|
||||
}
|
||||
vm := make(map[int8][]*Version, len(vs))
|
||||
for _, v := range vs {
|
||||
if v.PlatStr == "" || v.BuildStr == "" {
|
||||
continue
|
||||
}
|
||||
if plat, err := strconv.ParseInt(v.PlatStr, 10, 8); err != nil {
|
||||
log.Error("strconv.ParseInt(%s,10,8) error(%v)", v.PlatStr, err)
|
||||
continue
|
||||
} else {
|
||||
v.Plat = int8(plat)
|
||||
}
|
||||
if build, err := strconv.Atoi(v.BuildStr); err != nil {
|
||||
log.Error("strconv.Atoi(%s) error(%v)", v.BuildStr, err)
|
||||
continue
|
||||
} else {
|
||||
v.Build = build
|
||||
}
|
||||
vm[v.Plat] = append(vm[v.Plat], v)
|
||||
}
|
||||
m.Versions = vm
|
||||
if m.CType == 1 {
|
||||
var err error
|
||||
if m.ID, err = strconv.ParseInt(m.CValue, 10, 64); err != nil {
|
||||
log.Error("strconv.ParseInt(%s) error(%v)", m.CValue, err)
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Active struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
ParentID int64 `json:"parent_id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
Background string `json:"background,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
Content json.RawMessage `json:"content,omitempty"`
|
||||
// Extra
|
||||
Pid int64 `json:"pid,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Subtitle string `json:"subtitle,omitempty"`
|
||||
Desc string `json:"desc,omitempty"`
|
||||
Param string `json:"param,omitempty"`
|
||||
Goto model.Gt `json:"goto,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
Limit int `json:"limit,omitempty"`
|
||||
Items []*Active `json:"items,omitempty"`
|
||||
}
|
||||
|
||||
type Actives []*Active
|
||||
|
||||
func (is Actives) Len() int { return len(is) }
|
||||
func (is Actives) Less(i, j int) bool { return is[i].ID < is[j].ID }
|
||||
func (is Actives) Swap(i, j int) { is[i], is[j] = is[j], is[i] }
|
||||
|
||||
type CardItem struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Cover string `json:"cover,omitempty"`
|
||||
LinkType string `json:"link_type,omitempty"`
|
||||
LinkValue string `json:"link_value,omitempty"`
|
||||
Weight int `json:"weight,omitempty"`
|
||||
}
|
||||
|
||||
type CardItems []*CardItem
|
||||
|
||||
func (is CardItems) Len() int { return len(is) }
|
||||
func (is CardItems) Less(i, j int) bool { return is[i].Weight < is[j].Weight }
|
||||
func (is CardItems) Swap(i, j int) { is[i], is[j] = is[j], is[i] }
|
||||
|
||||
func (a *Active) Change() {
|
||||
switch a.Type {
|
||||
case "archive":
|
||||
a.Type = "player"
|
||||
case "live":
|
||||
a.Type = "player_live"
|
||||
case "basic":
|
||||
a.Type = "content_rcmd"
|
||||
case "shortcut":
|
||||
a.Type = "entrance"
|
||||
case "common":
|
||||
a.Type = "background"
|
||||
case "tag":
|
||||
a.Type = "tag_rcmd"
|
||||
}
|
||||
switch a.Type {
|
||||
// 基本类型
|
||||
case "player_live", "converge", "special", "article_s", "player":
|
||||
var id int64
|
||||
if err := json.Unmarshal(a.Content, &id); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
if id > 0 {
|
||||
a.Pid = id
|
||||
}
|
||||
// 新增类型
|
||||
case "content_rcmd":
|
||||
var basic struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Title string `json:"title,omitempty"`
|
||||
Subtitle string `json:"subtitle,omitempty"`
|
||||
Sublink string `json:"sublink,omitempty"`
|
||||
Content []*struct {
|
||||
LinkType string `json:"link_type,omitempty"`
|
||||
LinkValue string `json:"link_value,omitempty"`
|
||||
} `json:"content,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(a.Content, &basic); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
ris := make([]*Active, 0, len(basic.Content))
|
||||
for _, c := range basic.Content {
|
||||
typ, _ := strconv.Atoi(c.LinkType)
|
||||
id, _ := strconv.ParseInt(c.LinkValue, 10, 64)
|
||||
ri := &Active{Goto: model.OperateType[typ], Pid: id}
|
||||
if ri.Goto != "" {
|
||||
ris = append(ris, ri)
|
||||
}
|
||||
}
|
||||
if len(ris) != 0 {
|
||||
a.Items = ris
|
||||
a.Title = basic.Title
|
||||
a.Subtitle = basic.Subtitle
|
||||
a.Param = basic.Sublink
|
||||
}
|
||||
case "entrance", "banner":
|
||||
var card struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
CardItem []*CardItem `json:"card_item,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(a.Content, &card); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
ris := make([]*Active, 0, len(card.CardItem))
|
||||
sort.Sort(CardItems(card.CardItem))
|
||||
for _, item := range card.CardItem {
|
||||
typ, _ := strconv.Atoi(item.LinkType)
|
||||
id, _ := strconv.ParseInt(item.LinkValue, 10, 64)
|
||||
ri := &Active{Goto: model.OperateType[typ], Pid: id, Param: item.LinkValue, Title: item.Title, Cover: item.Cover}
|
||||
if ri.Goto != "" {
|
||||
ris = append(ris, ri)
|
||||
}
|
||||
}
|
||||
if len(ris) != 0 {
|
||||
a.Items = ris
|
||||
}
|
||||
case "tag_rcmd":
|
||||
var tag struct {
|
||||
AidStr string `json:"aid,omitempty"`
|
||||
Type string `json:"type,omitempty"`
|
||||
NumberStr string `json:"number,omitempty"`
|
||||
Tid int64 `json:"-"`
|
||||
Number int `json:"-"`
|
||||
}
|
||||
if err := json.Unmarshal(a.Content, &tag); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
tag.Tid, _ = strconv.ParseInt(tag.AidStr, 10, 64)
|
||||
tag.Number, _ = strconv.Atoi(tag.NumberStr)
|
||||
if tag.Tid != 0 {
|
||||
a.Pid = tag.Tid
|
||||
a.Limit = tag.Number
|
||||
}
|
||||
case "background":
|
||||
a.Title = a.Name
|
||||
a.Cover = a.Background
|
||||
case "news":
|
||||
var news struct {
|
||||
Title string `json:"title,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
Link string `json:"link,omitempty"`
|
||||
}
|
||||
if err := json.Unmarshal(a.Content, &news); err != nil {
|
||||
log.Error("%+v", err)
|
||||
return
|
||||
}
|
||||
if news.Body != "" {
|
||||
a.Title = news.Title
|
||||
a.Desc = news.Body
|
||||
a.Param = news.Link
|
||||
}
|
||||
}
|
||||
}
|
28
app/interface/main/app-card/model/card/rank/BUILD
Normal file
28
app/interface/main/app-card/model/card/rank/BUILD
Normal 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 = ["rank.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/rank",
|
||||
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"],
|
||||
)
|
6
app/interface/main/app-card/model/card/rank/rank.go
Normal file
6
app/interface/main/app-card/model/card/rank/rank.go
Normal file
@ -0,0 +1,6 @@
|
||||
package rank
|
||||
|
||||
type Rank struct {
|
||||
Aid int64 `json:"aid,omitempty"`
|
||||
Score int32 `json:"score,omitempty"`
|
||||
}
|
28
app/interface/main/app-card/model/card/show/BUILD
Normal file
28
app/interface/main/app-card/model/card/show/BUILD
Normal 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 = ["show.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/show",
|
||||
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"],
|
||||
)
|
20
app/interface/main/app-card/model/card/show/show.go
Normal file
20
app/interface/main/app-card/model/card/show/show.go
Normal file
@ -0,0 +1,20 @@
|
||||
package show
|
||||
|
||||
type Shopping struct {
|
||||
ID int64 `json:"id,omitempty"`
|
||||
Name string `json:"name,omitempty"`
|
||||
PerformanceImage string `json:"performance_image,omitempty"`
|
||||
PerformanceImageP string `json:"performance_imagep,omitempty"`
|
||||
STime string `json:"stime,omitempty"`
|
||||
ETime string `json:"etime,omitempty"`
|
||||
Tags []*struct {
|
||||
TagID int64 `json:"tag_id,omitempty"`
|
||||
TagName string `json:"tag_name,omitempty"`
|
||||
} `json:"tags,omitempty"`
|
||||
CityName string `json:"city_name,omitempty"`
|
||||
URL string `json:"url,omitempty"`
|
||||
Subname string `json:"subname,omitempty"`
|
||||
Pricelt string `json:"pricelt,omitempty"`
|
||||
Want string `json:"want,omitempty"`
|
||||
Type int8 `json:"type,omitempty"`
|
||||
}
|
1777
app/interface/main/app-card/model/card/single.go
Normal file
1777
app/interface/main/app-card/model/card/single.go
Normal file
File diff suppressed because it is too large
Load Diff
28
app/interface/main/app-card/model/card/topic/BUILD
Normal file
28
app/interface/main/app-card/model/card/topic/BUILD
Normal 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 = ["topic.go"],
|
||||
importpath = "go-common/app/interface/main/app-card/model/card/topic",
|
||||
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"],
|
||||
)
|
9
app/interface/main/app-card/model/card/topic/topic.go
Normal file
9
app/interface/main/app-card/model/card/topic/topic.go
Normal file
@ -0,0 +1,9 @@
|
||||
package topic
|
||||
|
||||
type Topic struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
H5URL string `json:"h5_url"`
|
||||
H5Cover string `json:"h5_cover"`
|
||||
Desc string `json:"desc"`
|
||||
}
|
Reference in New Issue
Block a user