Create & Init Project...
This commit is contained in:
32
app/admin/main/creative/model/material/BUILD
Normal file
32
app/admin/main/creative/model/material/BUILD
Normal 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 = [
|
||||
"category.go",
|
||||
"material.go",
|
||||
],
|
||||
importpath = "go-common/app/admin/main/creative/model/material",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = ["//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"],
|
||||
)
|
68
app/admin/main/creative/model/material/category.go
Normal file
68
app/admin/main/creative/model/material/category.go
Normal file
@ -0,0 +1,68 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
// consts for workflow event
|
||||
|
||||
// Category model is the model for material
|
||||
type Category struct {
|
||||
ID int64 `json:"id" gorm:"column:id"`
|
||||
Name string `json:"name" gorm:"column:name"`
|
||||
State int8 `json:"state" gorm:"column:state"`
|
||||
Type int64 `json:"type" gorm:"column:type"`
|
||||
Rank int64 `json:"rank" gorm:"column:rank"`
|
||||
New int64 `json:"new" gorm:"column:new"`
|
||||
CTime xtime.Time `json:"ctime" gorm:"column:ctime"`
|
||||
MTime xtime.Time `json:"mtime" gorm:"column:mtime"`
|
||||
}
|
||||
|
||||
// TableName is used to identify table name in gorm
|
||||
func (Category) TableName() string {
|
||||
return "material_category"
|
||||
}
|
||||
|
||||
// CategoryPager def.
|
||||
type CategoryPager struct {
|
||||
Items []*Category `json:"items"`
|
||||
Pager *Pager `json:"pager"`
|
||||
}
|
||||
|
||||
// WithCategory model is the model for material
|
||||
type WithCategory struct {
|
||||
ID int64 `json:"id" gorm:"column:id"`
|
||||
CategoryID int64 `json:"category_id" gorm:"column:category_id"`
|
||||
MaterialID int64 `json:"material_id" gorm:"column:material_id"`
|
||||
State int8 `json:"state" gorm:"column:state"`
|
||||
Index int64 `json:"index" gorm:"column:index"`
|
||||
}
|
||||
|
||||
// TableName is used to identify table name in gorm
|
||||
func (WithCategory) TableName() string {
|
||||
return "material_with_category"
|
||||
}
|
||||
|
||||
// WithCategoryPager def.
|
||||
type WithCategoryPager struct {
|
||||
TotalCount int64 `json:"total_count"`
|
||||
Pn int `json:"pn"`
|
||||
Ps int `json:"ps"`
|
||||
Items []*WithCategory `json:"items"`
|
||||
}
|
||||
|
||||
// CategoryParam is used to parse user request
|
||||
type CategoryParam struct {
|
||||
ID int64 `form:"id" gorm:"column:id"`
|
||||
Type int64 `form:"type" gorm:"column:type" validate:"required"`
|
||||
UID int64 `form:"uid" gorm:"column:uid"`
|
||||
Name string `form:"name" gorm:"column:name" validate:"required"`
|
||||
Rank int64 `form:"rank" gorm:"column:rank" validate:"required"`
|
||||
New int8 `form:"new" gorm:"column:new"`
|
||||
State int8 `form:"state" gorm:"column:state"`
|
||||
}
|
||||
|
||||
// TableName is used to identify table name in gorm
|
||||
func (CategoryParam) TableName() string {
|
||||
return "material_category"
|
||||
}
|
126
app/admin/main/creative/model/material/material.go
Normal file
126
app/admin/main/creative/model/material/material.go
Normal file
@ -0,0 +1,126 @@
|
||||
package material
|
||||
|
||||
import (
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
// consts .
|
||||
const (
|
||||
StateDelete = 2
|
||||
StateOff = 1
|
||||
StateOn = 0
|
||||
//注意 因为历史原因 bgm 和其他素材没能在bilibili_creative.material一个表集中管理 针对素材类型 为bgm保留了type=3
|
||||
//字幕库
|
||||
TypeSubTitle = int8(0)
|
||||
//字体库
|
||||
TypeFont = int8(1)
|
||||
//滤镜库
|
||||
TypeFilter = int8(2)
|
||||
//bgm库
|
||||
TypeBGM = int8(3)
|
||||
//热词
|
||||
TypeHotWord = int8(4)
|
||||
//拍摄贴纸 ext 新增贴纸类型 默认为0 普通贴纸,存储格式是bitmask参考属性位 0普通 1人脸 2手势 3画面效果 (不是自然数顺序 服务端不校验)
|
||||
TypeSticks = int8(5)
|
||||
//贴纸Icon
|
||||
TypeSticksIcon = int8(6)
|
||||
//投稿贴纸
|
||||
TypeCreativeSticks = int8(7)
|
||||
//投稿转场
|
||||
TypeCreativeTransition = int8(8)
|
||||
//合拍库
|
||||
TypeCooperate = int8(9)
|
||||
//主题库
|
||||
TypeTheme = int8(10)
|
||||
)
|
||||
|
||||
var (
|
||||
_materialtype = map[int8]string{
|
||||
TypeSubTitle: "字幕库",
|
||||
TypeFont: "字体库",
|
||||
TypeFilter: "滤镜库",
|
||||
TypeBGM: "bgm库",
|
||||
TypeHotWord: "热词",
|
||||
TypeSticks: "贴纸",
|
||||
TypeSticksIcon: "贴纸Icon",
|
||||
TypeCreativeSticks: "投稿贴纸",
|
||||
TypeCreativeTransition: "投稿转场",
|
||||
TypeCooperate: "合拍库",
|
||||
TypeTheme: "主题库",
|
||||
}
|
||||
)
|
||||
|
||||
// InMaterialType in correct materialtype.
|
||||
func InMaterialType(cate int8) (ok bool) {
|
||||
_, ok = _materialtype[cate]
|
||||
return
|
||||
}
|
||||
|
||||
// Material model is the model for Material
|
||||
type Material struct {
|
||||
ID int64 `json:"id" form:"id" gorm:"column:id"`
|
||||
UID int64 `json:"uid" form:"id" gorm:"column:uid"`
|
||||
Name string `json:"name" form:"name" gorm:"column:name"`
|
||||
Extra string `json:"extra" form:"extra" gorm:"column:extra"`
|
||||
Rank int `json:"rank" form:"rank" gorm:"column:rank"`
|
||||
Type int8 `json:"type" form:"type" gorm:"column:type"`
|
||||
Platform int `json:"platform" form:"platform" gorm:"column:platform"`
|
||||
Build string `json:"build" form:"build" gorm:"column:build"`
|
||||
State int8 `json:"state" form:"state" gorm:"column:state"`
|
||||
CategoryID int64 `json:"category_id" gorm:"-"`
|
||||
CategoryIndex int64 `json:"category_index" gorm:"-"`
|
||||
CategoryName string `json:"category_name" gorm:"-"`
|
||||
CTime xtime.Time `json:"ctime" form:"ctime" gorm:"column:ctime"`
|
||||
MTime xtime.Time `json:"mtime" form:"mtime" gorm:"column:mtime"`
|
||||
}
|
||||
|
||||
// TableName is used to identify table name in gorm
|
||||
func (Material) TableName() string {
|
||||
return "material"
|
||||
}
|
||||
|
||||
// Result def.
|
||||
type Result struct {
|
||||
Items []*Material `json:"items"`
|
||||
Pager *Pager `json:"pager"`
|
||||
}
|
||||
|
||||
// Pager Pager def.
|
||||
type Pager struct {
|
||||
Num int `json:"num"`
|
||||
Size int `json:"size"`
|
||||
Total int64 `json:"total"`
|
||||
}
|
||||
|
||||
// Param is used to parse user request
|
||||
type Param struct {
|
||||
ID int64 `form:"id" gorm:"column:id" json:"id"`
|
||||
Name string `form:"name" gorm:"column:name" json:"name"`
|
||||
Extra string `form:"extra" gorm:"column:extra" json:"extra"`
|
||||
Rank int `form:"rank" gorm:"column:rank" json:"rank"`
|
||||
Type int8 `form:"type" gorm:"column:type" json:"type"`
|
||||
Cover string `form:"cover" json:"cover"`
|
||||
Platform int `form:"platform" json:"platform"`
|
||||
Build string `form:"build" json:"build"`
|
||||
DownloadURL string `form:"download_url" json:"download_url"`
|
||||
ExtraURL string `form:"extra_url" json:"extra_url"`
|
||||
ExtraField string `form:"extra_field" json:"extra_field"`
|
||||
Max int8 `form:"max" json:"max"`
|
||||
CategoryID int64 `form:"category_id" json:"category_id"`
|
||||
CategoryIndex int64 `form:"category_index" json:"category_index"`
|
||||
SubType int8 `form:"sub_type" json:"sub_type"`
|
||||
Style int8 `form:"style" json:"style"`
|
||||
Tip string `form:"tip" json:"tip"`
|
||||
WhilteList int8 `form:"white_list" json:"white_list"`
|
||||
MaterialAID int64 `form:"material_aid" json:"material_aid"`
|
||||
MaterialCID int64 `form:"material_cid" json:"material_cid"`
|
||||
DemoAID int64 `form:"demo_aid" json:"demo_aid"`
|
||||
DemoCID int64 `form:"demo_cid" json:"demo_cid"`
|
||||
MissionID int64 `form:"mission_id" json:"mission_id"`
|
||||
FilterType int8 `form:"filter_type" json:"filter_type"`
|
||||
}
|
||||
|
||||
// TableName is used to identify table name in gorm
|
||||
func (Param) TableName() string {
|
||||
return "material"
|
||||
}
|
Reference in New Issue
Block a user