Create & Init Project...

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

View File

@@ -0,0 +1,44 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"creditlog.go",
"requestargs.go",
"score_section_history.go",
"task_info.go",
"up_base_info.go",
"up_play_info.go",
"up_rank.go",
"up_scores_history.go",
"up_stats_history.go",
],
importpath = "go-common/app/admin/main/up/model/upcrmmodel",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/up/model/datamodel:go_default_library",
"//app/admin/main/up/util:go_default_library",
"//library/time:go_default_library",
"//vendor/github.com/siddontang/go-mysql/mysql: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,28 @@
package upcrmmodel
import (
"go-common/library/time"
)
const (
//BusinessTypeArticleAudit 稿件的审核
BusinessTypeArticleAudit = 1
)
//SimpleCreditLog simple credit log
type SimpleCreditLog struct {
ID uint `json:"-"`
Type int `json:"type"`
OpType int `json:"op_type"`
Reason int `json:"reason"`
BusinessType int `json:"business_type"`
Mid int64 `json:"mid"`
Oid int64 `json:"oid"`
CTime time.Time `json:"ctime"`
}
//SimpleCreditLogWithContent simple credit log with content
type SimpleCreditLogWithContent struct {
SimpleCreditLog
Content string `form:"content" json:"content"` // 日志内容描述
}

View File

@@ -0,0 +1,364 @@
CREATE TABLE `up_base_info` (
`id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '自增ID',
`mid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`name` varchar(36) NOT NULL DEFAULT '' COMMENT '昵称',
`sex` tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别 0:保密 1:男 2:女',
`join_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '注册时间',
`first_up_time` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '第一次投稿时间',
`level` smallint(6) NOT NULL DEFAULT '0' COMMENT '等级',
`fans_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '粉丝量',
`account_state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '账号状态0正常1封禁',
`activity` int(11) NOT NULL DEFAULT '0' COMMENT '活跃度',
`article_count_30day` int(11) NOT NULL DEFAULT '0' COMMENT '30天内投稿量(所有业务)',
`article_count_accumulate` int(11) NOT NULL DEFAULT '0' COMMENT '累计投稿量(各业务累加)',
`verify_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '认证类型,0-个人1-企业',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
`business_type` tinyint(4) NOT NULL COMMENT '业务类型, 1视频/2音频/3专栏',
`credit_score` int(11) NOT NULL DEFAULT '500' COMMENT '信用分',
`pr_score` int(11) NOT NULL DEFAULT '0' COMMENT '影响分',
`quality_score` int(11) NOT NULL DEFAULT '0' COMMENT '质量分',
`active_tid` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '最多稿件分区',
`attr` int(11) NOT NULL DEFAULT '0' COMMENT '属性,以位区分',
`birthday` date NOT NULL DEFAULT '0000-00-00' COMMENT '生日',
`active_province` varchar(32) NOT NULL DEFAULT '' COMMENT '省份',
`active_city` varchar(32) NOT NULL DEFAULT '' COMMENT '城市',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mid_type` (`mid`,`business_type`),
KEY `ix_mtime` (`mtime`),
KEY `ix_uptime` (`first_up_time`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='up基本信息表';
CREATE TABLE `up_play_info` (
`id` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT '自增ID',
`mid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`business_type` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '业务类型, 1视频/2音频/3专栏',
`play_count_accumulate` bigint(20) NOT NULL DEFAULT '0' COMMENT '累计播放次数',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
`article_count` int(11) NOT NULL DEFAULT '0' COMMENT '总稿件数',
`play_count_90day` bigint(20) NOT NULL DEFAULT '0' COMMENT '90天内稿件总播放次数',
`play_count_30day` bigint(20) NOT NULL DEFAULT '0' COMMENT '30天内稿件总播放次数',
`play_count_7day` bigint(20) NOT NULL DEFAULT '0' COMMENT '7天内稿件总播放次数',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mid_bus` (`mid`,`business_type`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='up基本播放信息表';
CREATE TABLE `up_rank` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`mid` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`type` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT '排行榜类型',
`value` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '排行榜数值,根据type不同代表的含义不同',
`generate_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '排行榜日',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
`value2` int(11) NOT NULL DEFAULT '0' COMMENT '分数2',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_date_type_mid` (`generate_date`,`type`,`mid`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=35001 DEFAULT CHARSET=utf8 COMMENT='Up蹿升榜';
CREATE TABLE `task_info` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`generate_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '计算日',
`task_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型',
`start_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '开始时间',
`end_time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT '结束时间',
`task_state` smallint(6) NOT NULL DEFAULT '0' COMMENT '任务状态, 0表示初始化, 1表示结束其他状态根据task_type定义',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_date_type` (`generate_date`,`task_type`),
KEY `ix_mtime` (`mtime`),
KEY `ix_date` (`generate_date`)
) ENGINE=InnoDB AUTO_INCREMENT=27 DEFAULT CHARSET=utf8 COMMENT='计算任务信息表';
-- score_section_history: table
CREATE TABLE `score_section_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`generate_date` date NOT NULL COMMENT '生成日期',
`score_type` smallint(6) NOT NULL DEFAULT '0' COMMENT '类型, 1质量分2影响分3信用分',
`section_0` int(11) NOT NULL DEFAULT '0' COMMENT '0~100的人数',
`section_1` int(11) NOT NULL DEFAULT '0' COMMENT '101~200',
`section_2` int(11) NOT NULL DEFAULT '0' COMMENT '201~300',
`section_3` int(11) NOT NULL DEFAULT '0' COMMENT '301~400',
`section_4` int(11) NOT NULL DEFAULT '0' COMMENT '401~500',
`section_5` int(11) NOT NULL DEFAULT '0' COMMENT '501~600',
`section_6` int(11) NOT NULL DEFAULT '0' COMMENT '601~700',
`section_7` int(11) NOT NULL DEFAULT '0' COMMENT '701~800',
`section_8` int(11) NOT NULL DEFAULT '0' COMMENT '801~900',
`section_9` int(11) NOT NULL DEFAULT '0' COMMENT '901~1000',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_date_type` (`generate_date`,`score_type`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=79 DEFAULT CHARSET=utf8 COMMENT='up分数段人数分布表'
;
-- up_stats_history: table
CREATE TABLE `up_stats_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '1活跃、2新增可以通过累计来计算、3累计up主人数',
`sub_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '子类',
`value1` int(11) NOT NULL DEFAULT '0' COMMENT '分数',
`value2` int(11) NOT NULL DEFAULT '0' COMMENT '分数2,备用',
`generate_date` date NOT NULL DEFAULT '0000-00-00' COMMENT '生成日期',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_type_subtype_date` (`generate_date`,`type`,`sub_type`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=110 DEFAULT CHARSET=utf8 COMMENT='up主总数表'
;
-- up_scores_history_00: table
CREATE TABLE `up_scores_history_00` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`mid` int(11) unsigned NOT NULL COMMENT 'up主id',
`score_type` tinyint(4) NOT NULL COMMENT '1内容分2影响分3信用分',
`score` int(11) unsigned NOT NULL COMMENT '分数',
`generate_date` date NOT NULL COMMENT '生成日期',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
UNIQUE KEY `uk_mid_scoretype_date` (`mid`,`score_type`,`generate_date`),
KEY `ix_date` (`generate_date`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB AUTO_INCREMENT=101239 DEFAULT CHARSET=utf8 COMMENT='up分数表'
;
-- credit_log_00: table
CREATE TABLE `credit_log_00` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`type` smallint(6) unsigned NOT NULL COMMENT '日志类型',
`op_type` smallint(6) NOT NULL COMMENT '操作类型',
`reason` smallint(6) NOT NULL COMMENT '原因类型',
`business_type` smallint(6) unsigned NOT NULL COMMENT '业务类型',
`mid` int(11) NOT NULL COMMENT 'mid',
`oid` int(11) unsigned NOT NULL COMMENT 'oid',
`uid` smallint(6) unsigned NOT NULL COMMENT '操作人员id',
`content` varchar(255) NOT NULL COMMENT '操作内容',
`extra` varchar(2000) NOT NULL DEFAULT '' COMMENT '额外信息',
`ctime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
`mtime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '最后修改时间',
PRIMARY KEY (`id`),
KEY `ix_mtime` (`mtime`),
KEY `ix_mid` (`mid`)
) ENGINE=InnoDB AUTO_INCREMENT=394475 DEFAULT CHARSET=utf8 COMMENT='信用分日志表'
;
CREATE TABLE credit_log_00 LIKE credit_log_00;
CREATE TABLE credit_log_01 LIKE credit_log_00;
CREATE TABLE credit_log_02 LIKE credit_log_00;
CREATE TABLE credit_log_03 LIKE credit_log_00;
CREATE TABLE credit_log_04 LIKE credit_log_00;
CREATE TABLE credit_log_05 LIKE credit_log_00;
CREATE TABLE credit_log_06 LIKE credit_log_00;
CREATE TABLE credit_log_07 LIKE credit_log_00;
CREATE TABLE credit_log_08 LIKE credit_log_00;
CREATE TABLE credit_log_09 LIKE credit_log_00;
CREATE TABLE credit_log_10 LIKE credit_log_00;
CREATE TABLE credit_log_11 LIKE credit_log_00;
CREATE TABLE credit_log_12 LIKE credit_log_00;
CREATE TABLE credit_log_13 LIKE credit_log_00;
CREATE TABLE credit_log_14 LIKE credit_log_00;
CREATE TABLE credit_log_15 LIKE credit_log_00;
CREATE TABLE credit_log_16 LIKE credit_log_00;
CREATE TABLE credit_log_17 LIKE credit_log_00;
CREATE TABLE credit_log_18 LIKE credit_log_00;
CREATE TABLE credit_log_19 LIKE credit_log_00;
CREATE TABLE credit_log_20 LIKE credit_log_00;
CREATE TABLE credit_log_21 LIKE credit_log_00;
CREATE TABLE credit_log_22 LIKE credit_log_00;
CREATE TABLE credit_log_23 LIKE credit_log_00;
CREATE TABLE credit_log_24 LIKE credit_log_00;
CREATE TABLE credit_log_25 LIKE credit_log_00;
CREATE TABLE credit_log_26 LIKE credit_log_00;
CREATE TABLE credit_log_27 LIKE credit_log_00;
CREATE TABLE credit_log_28 LIKE credit_log_00;
CREATE TABLE credit_log_29 LIKE credit_log_00;
CREATE TABLE credit_log_30 LIKE credit_log_00;
CREATE TABLE credit_log_31 LIKE credit_log_00;
CREATE TABLE credit_log_32 LIKE credit_log_00;
CREATE TABLE credit_log_33 LIKE credit_log_00;
CREATE TABLE credit_log_34 LIKE credit_log_00;
CREATE TABLE credit_log_35 LIKE credit_log_00;
CREATE TABLE credit_log_36 LIKE credit_log_00;
CREATE TABLE credit_log_37 LIKE credit_log_00;
CREATE TABLE credit_log_38 LIKE credit_log_00;
CREATE TABLE credit_log_39 LIKE credit_log_00;
CREATE TABLE credit_log_40 LIKE credit_log_00;
CREATE TABLE credit_log_41 LIKE credit_log_00;
CREATE TABLE credit_log_42 LIKE credit_log_00;
CREATE TABLE credit_log_43 LIKE credit_log_00;
CREATE TABLE credit_log_44 LIKE credit_log_00;
CREATE TABLE credit_log_45 LIKE credit_log_00;
CREATE TABLE credit_log_46 LIKE credit_log_00;
CREATE TABLE credit_log_47 LIKE credit_log_00;
CREATE TABLE credit_log_48 LIKE credit_log_00;
CREATE TABLE credit_log_49 LIKE credit_log_00;
CREATE TABLE credit_log_50 LIKE credit_log_00;
CREATE TABLE credit_log_51 LIKE credit_log_00;
CREATE TABLE credit_log_52 LIKE credit_log_00;
CREATE TABLE credit_log_53 LIKE credit_log_00;
CREATE TABLE credit_log_54 LIKE credit_log_00;
CREATE TABLE credit_log_55 LIKE credit_log_00;
CREATE TABLE credit_log_56 LIKE credit_log_00;
CREATE TABLE credit_log_57 LIKE credit_log_00;
CREATE TABLE credit_log_58 LIKE credit_log_00;
CREATE TABLE credit_log_59 LIKE credit_log_00;
CREATE TABLE credit_log_60 LIKE credit_log_00;
CREATE TABLE credit_log_61 LIKE credit_log_00;
CREATE TABLE credit_log_62 LIKE credit_log_00;
CREATE TABLE credit_log_63 LIKE credit_log_00;
CREATE TABLE credit_log_64 LIKE credit_log_00;
CREATE TABLE credit_log_65 LIKE credit_log_00;
CREATE TABLE credit_log_66 LIKE credit_log_00;
CREATE TABLE credit_log_67 LIKE credit_log_00;
CREATE TABLE credit_log_68 LIKE credit_log_00;
CREATE TABLE credit_log_69 LIKE credit_log_00;
CREATE TABLE credit_log_70 LIKE credit_log_00;
CREATE TABLE credit_log_71 LIKE credit_log_00;
CREATE TABLE credit_log_72 LIKE credit_log_00;
CREATE TABLE credit_log_73 LIKE credit_log_00;
CREATE TABLE credit_log_74 LIKE credit_log_00;
CREATE TABLE credit_log_75 LIKE credit_log_00;
CREATE TABLE credit_log_76 LIKE credit_log_00;
CREATE TABLE credit_log_77 LIKE credit_log_00;
CREATE TABLE credit_log_78 LIKE credit_log_00;
CREATE TABLE credit_log_79 LIKE credit_log_00;
CREATE TABLE credit_log_80 LIKE credit_log_00;
CREATE TABLE credit_log_81 LIKE credit_log_00;
CREATE TABLE credit_log_82 LIKE credit_log_00;
CREATE TABLE credit_log_83 LIKE credit_log_00;
CREATE TABLE credit_log_84 LIKE credit_log_00;
CREATE TABLE credit_log_85 LIKE credit_log_00;
CREATE TABLE credit_log_86 LIKE credit_log_00;
CREATE TABLE credit_log_87 LIKE credit_log_00;
CREATE TABLE credit_log_88 LIKE credit_log_00;
CREATE TABLE credit_log_89 LIKE credit_log_00;
CREATE TABLE credit_log_90 LIKE credit_log_00;
CREATE TABLE credit_log_91 LIKE credit_log_00;
CREATE TABLE credit_log_92 LIKE credit_log_00;
CREATE TABLE credit_log_93 LIKE credit_log_00;
CREATE TABLE credit_log_94 LIKE credit_log_00;
CREATE TABLE credit_log_95 LIKE credit_log_00;
CREATE TABLE credit_log_96 LIKE credit_log_00;
CREATE TABLE credit_log_97 LIKE credit_log_00;
CREATE TABLE credit_log_98 LIKE credit_log_00;
CREATE TABLE credit_log_99 LIKE credit_log_00;
CREATE TABLE up_scores_history_00 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_01 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_02 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_03 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_04 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_05 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_06 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_07 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_08 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_09 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_10 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_11 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_12 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_13 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_14 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_15 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_16 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_17 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_18 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_19 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_20 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_21 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_22 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_23 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_24 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_25 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_26 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_27 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_28 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_29 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_30 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_31 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_32 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_33 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_34 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_35 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_36 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_37 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_38 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_39 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_40 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_41 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_42 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_43 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_44 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_45 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_46 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_47 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_48 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_49 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_50 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_51 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_52 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_53 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_54 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_55 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_56 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_57 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_58 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_59 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_60 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_61 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_62 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_63 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_64 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_65 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_66 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_67 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_68 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_69 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_70 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_71 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_72 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_73 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_74 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_75 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_76 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_77 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_78 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_79 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_80 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_81 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_82 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_83 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_84 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_85 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_86 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_87 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_88 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_89 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_90 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_91 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_92 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_93 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_94 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_95 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_96 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_97 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_98 LIKE up_scores_history_00;
CREATE TABLE up_scores_history_99 LIKE up_scores_history_00;
--------- 以上是建表语句 -----------
--------- 修改 up_play_info表字段有数据溢出 -----------
# (fat 1, uat 1, prod 1)
alter table up_play_info modify play_count_accumulate BIGINT(20) NOT NULL DEFAULT '0' COMMENT '累计播放次数';
alter table up_play_info modify play_count_90day BIGINT(20) NOT NULL DEFAULT '0' COMMENT '90天内稿件总播放次数';
alter table up_play_info modify play_count_30day BIGINT(20) NOT NULL DEFAULT '0' COMMENT '30天内稿件总播放次数';
alter table up_play_info modify play_count_7day BIGINT(20) NOT NULL DEFAULT '0' COMMENT '7天内稿件总播放次数';
--------- 修改 自增ID为bigint unsigned -----------
# (fat 1, uat 1, prod 1)
alter table up_play_info modify id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '自增ID';
alter table up_base_info modify id BIGINT(20) UNSIGNED NOT NULL DEFAULT '0' COMMENT '自增ID';

View File

@@ -0,0 +1,376 @@
package upcrmmodel
import (
"go-common/app/admin/main/up/model/datamodel"
"go-common/app/admin/main/up/util"
"go-common/library/time"
xtime "time"
)
const (
//CompareTypeNothing 0
CompareTypeNothing = 0
//CompareType7day 1
CompareType7day = 1
//CompareType30day 2
CompareType30day = 2
//CompareTypeMonthFirstDay 3
CompareTypeMonthFirstDay = 3
)
const (
//AttrBitVideo video
// see http://info.bilibili.co/pages/viewpage.action?pageId=9830931
AttrBitVideo = 0
//AttrBitAudio audio
AttrBitAudio = 1
//AttrBitArticle article
AttrBitArticle = 2
//AttrBitPhoto photo
AttrBitPhoto = 3
//AttrBitSign sign
AttrBitSign = 4
//AttrBitGrowup growup
AttrBitGrowup = 5
//AttrBitVerify verify
AttrBitVerify = 6
)
var (
//AttrGroup1 筛选用第一组attr
AttrGroup1 = map[int]int{AttrBitVideo: 0, AttrBitAudio: 0, AttrBitArticle: 0, AttrBitPhoto: 0}
//AttrGroup2 筛选用第二组attr 两组之间的关系是与
AttrGroup2 = map[int]int{AttrBitSign: 0, AttrBitGrowup: 0, AttrBitVerify: 0}
)
// ScoreQueryArgs ------------------------- requests ------------------------
type ScoreQueryArgs struct {
ScoreType int `form:"score_type"`
CompareType int `form:"compare_type"`
Export string `form:"export"`
}
//ScoreQueryUpArgs arg
type ScoreQueryUpArgs struct {
Mid int64 `form:"mid" validate:"required"`
Date string `form:"date"`
}
//ScoreQueryUpHistoryArgs arg
type ScoreQueryUpHistoryArgs struct {
Mid int64 `form:"mid" validate:"required"`
ScoreType int `form:"score_type"`
Day int `form:"day" default:"7"`
Date string `form:"date"`
}
//PlayQueryArgs arg
type PlayQueryArgs struct {
Mid int64 `form:"mid" validate:"required"`
BusinessType int `form:"business_type"`
}
//InfoQueryArgs arg
type InfoQueryArgs struct {
Mid int64 `form:"mid" validate:"required"`
}
//CreditLogQueryArgs arg
type CreditLogQueryArgs struct {
Mid int64 `form:"mid" validate:"required"`
Limit int `form:"limit"`
}
//UpRankQueryArgs arg
type UpRankQueryArgs struct {
Type int `form:"type" validate:"required"`
Page int `form:"page"` // (从1开始)
Size int `form:"size"` // 1 ~ 50
}
//InfoAccountInfoArgs arg
type InfoAccountInfoArgs struct {
Mids string `form:"mids" validate:"required"`
}
//InfoSearchArgs arg
type InfoSearchArgs struct {
AccountState int `json:"account_state"`
Activity int `json:"activity"`
Attrs UpAttr `json:"attrs"`
FirstDateBegin string `json:"first_date_begin"`
FirstDateEnd string `json:"first_date_end"`
Mid int64 `json:"mid"`
Order struct {
Field string `json:"field"`
Order string `json:"order"`
}
Page int `json:"page"`
Size int `json:"size"`
}
//TestGetViewBaseArgs test arg
type TestGetViewBaseArgs struct {
Mid int64 `form:"mid" validate:"required"`
}
// ------------------------- results ------------------------
//ScoreSection struct
type ScoreSection struct {
Section int `json:"-"`
Value int
Percent int
}
//ScoreQueryResult result
type ScoreQueryResult struct {
CompareAxis []ScoreSection `json:"compareAxis"`
XAxis []string `json:"xAxis"`
YAxis []ScoreSection `json:"yAxis"`
}
//NewEmptyScoreQueryResult make new result
func NewEmptyScoreQueryResult() ScoreQueryResult {
return ScoreQueryResult{
CompareAxis: []ScoreSection{},
XAxis: []string{},
YAxis: []ScoreSection{},
}
}
//ScoreInfo struct
type ScoreInfo struct {
Current int `json:"current"`
DiffLastDay int `json:"diff_last_day"`
}
//ScoreQueryUpResult result
type ScoreQueryUpResult struct {
PrScore ScoreInfo
QualityScore ScoreInfo
CreditScore ScoreInfo
Date time.Time
}
//ScoreHistoryInfo struct
type ScoreHistoryInfo struct {
Type int `json:"type"`
Score []int `json:"score"`
Date []time.Time `json:"date"`
}
//ScoreQueryUpHistoryResult result
type ScoreQueryUpHistoryResult struct {
ScoreData []ScoreHistoryInfo `json:"score_data"`
}
//PlayInfo struct
type PlayInfo struct {
Type int `json:"type"`
PlayCountAccumulate int64 `json:"play_count_accumulate"`
PlayCountAvg int64 `json:"play_count_avg"`
PlayCountAvg90Day int64 `json:"play_count_avg_90day"`
}
//PlayQueryResult result
type PlayQueryResult struct {
ArticleCount30Day int `json:"article_count_30day"`
ArticleCountAccumulate int `json:"article_count_accumulate"`
BusinessData []PlayInfo `json:"business_data"`
}
//CastUpPlayInfoToPlayInfo cast
func CastUpPlayInfoToPlayInfo(info UpPlayInfo) (r PlayInfo) {
r.Type = int(info.BusinessType)
r.PlayCountAccumulate = info.PlayCountAccumulate
r.PlayCountAvg = info.PlayCountAccumulate / info.ArticleCount
r.PlayCountAvg90Day = info.PlayCount90Day / info.ArticleCount
return
}
//UpAttr struct
type UpAttr struct {
AttrVerify int `json:"attr_verify"`
AttrVideo int `json:"attr_video"`
AttrAudio int `json:"attr_audio"`
AttrArticle int `json:"attr_article"`
AttrPhoto int `json:"attr_photo"`
AttrSign int `json:"attr_sign"`
AttrGrowup int `json:"attr_growup"`
}
//InfoQueryResult result
type InfoQueryResult struct {
ID uint32 `json:"-"`
Mid int64 `json:"mid"`
Name string `json:"name"`
Sex int8 `json:"sex"`
JoinTime time.Time `json:"join_time"`
FirstUpTime time.Time `json:"first_up_time"`
Level int16 `json:"level"`
FansCount int `json:"fans_count"`
AccountState int8 `json:"account_state"`
Activity int `json:"activity"`
ArticleCount30day int `json:"article_count_30day"`
ArticleCountAccumulate int `json:"article_count_accumulate"`
VerifyType int8 `json:"verify_type"`
BusinessType int8 `json:"business_type"`
CreditScore int `json:"credit_score"`
PrScore int `json:"pr_score"`
QualityScore int `json:"quality_score"`
ActiveTid int64 `json:"active_tid"`
ActiveSubtid int64 `json:"active_subtid"`
Region string `json:"region"`
Province string `json:"province"`
Age int `json:"age"`
Attr int `json:"-"`
Attrs UpAttr `json:"attrs"`
Birthday xtime.Time `json:"-"`
}
//CopyFromBaseInfo copy
func (i *InfoQueryResult) CopyFromBaseInfo(info UpBaseInfo) {
i.ID = info.ID
i.Mid = info.Mid
i.Name = info.Name
i.Sex = info.Sex
i.JoinTime = info.JoinTime
i.FirstUpTime = info.FirstUpTime
i.Level = info.Level
i.FansCount = info.FansCount
i.AccountState = info.AccountState
i.ArticleCount30day = info.ArticleCount30day
i.ArticleCountAccumulate = info.ArticleCountAccumulate
i.VerifyType = info.VerifyType
i.BusinessType = info.BusinessType
i.CreditScore = info.CreditScore
i.ActiveTid = info.ActiveTid
i.Birthday = info.Birthday
i.Region = info.ActiveCity
i.Province = info.ActiveProvince
i.Attr = info.Attr
i.PrScore = info.PrScore
i.QualityScore = info.QualityScore
i.Activity = info.Activity
}
// CalculateAttr 根据attr来计算各个attr_xx的属性
func (i *InfoQueryResult) CalculateAttr() {
// todo 计算attr属性
if util.IsBitSet(i.Attr, AttrBitVideo) {
i.Attrs.AttrVideo = 1
}
if util.IsBitSet(i.Attr, AttrBitAudio) {
i.Attrs.AttrAudio = 1
}
if util.IsBitSet(i.Attr, AttrBitArticle) {
i.Attrs.AttrArticle = 1
}
if util.IsBitSet(i.Attr, AttrBitPhoto) {
i.Attrs.AttrPhoto = 1
}
if util.IsBitSet(i.Attr, AttrBitSign) {
i.Attrs.AttrSign = 1
}
if util.IsBitSet(i.Attr, AttrBitGrowup) {
i.Attrs.AttrGrowup = 1
}
if util.IsBitSet(i.Attr, AttrBitVerify) {
i.Attrs.AttrVerify = 1
}
if !i.Birthday.IsZero() {
i.Age = int(xtime.Since(i.Birthday).Hours() / float64(24*365))
if i.Age < 0 {
i.Age = 0
}
}
}
//CreditLogInfo struct
type CreditLogInfo struct {
Time time.Time `json:"time"`
Log string `json:"log"`
}
//CreditLogUpResult result
type CreditLogUpResult struct {
Logs []CreditLogInfo `json:"logs"`
}
//UpRankInfo struct
type UpRankInfo struct {
InfoQueryResult
Rank int `json:"rank"`
Value uint `json:"value"`
Value2 int `json:"value_2"`
CompleteTime time.Time `json:"complete_time"`
RankType int16 `json:"-"`
}
//CopyFromUpRank copy
func (u *UpRankInfo) CopyFromUpRank(upRank *UpRank) {
u.Value = upRank.Value
u.Value2 = upRank.Value2
u.RankType = upRank.Type
}
//UpRankQueryResult result
type UpRankQueryResult struct {
Result []*UpRankInfo `json:"result"`
Date time.Time `json:"date"`
PageInfo
}
//PageInfo page info
type PageInfo struct {
TotalCount int `json:"total_count"`
Size int `json:"size"`
Page int `json:"page"`
}
//InfoSearchResult result
type InfoSearchResult struct {
Result []*InfoQueryResult `json:"result"`
PageInfo
}
//UpInfoWithViewerData up data with view data
type UpInfoWithViewerData struct {
Mid int64 `json:"mid"`
UpBaseInfo *InfoQueryResult `json:"up_base_info"`
ViewerTrend *datamodel.ViewerTrendInfo `json:"viewer_trend"`
ViewerArea *datamodel.ViewerAreaInfo `json:"viewer_area"`
ViewerBase *datamodel.ViewerBaseInfo `json:"viewer_base"`
UpPlayInfo *UpPlayInfo `json:"up_play_info"`
}
//UpInfoWithViewerResult info result
type UpInfoWithViewerResult struct {
Result []*UpInfoWithViewerData `json:"result"`
PageInfo
}
// -------------
const (
// FlagUpBaseData up base info
FlagUpBaseData = 1
// FlagUpPlayData up play info
FlagUpPlayData = 1 << 1
// FlagViewData view base data flag
FlagViewData = 1 << 2
)
//UpInfoWithViewerArg arg
type UpInfoWithViewerArg struct {
Mids string `form:"mids"`
Sort string `form:"sort" default:"fans_count"`
Order string `form:"order" default:"desc"`
Page int `form:"page" default:"1"`
Size int `form:"size" default:"20"`
// 需要的信息
Flag int `form:"flag" default:"0"`
}

View File

@@ -0,0 +1,22 @@
package upcrmmodel
import "go-common/library/time"
//ScoreSectionHistory score section
type ScoreSectionHistory struct {
ID uint32 `gorm:"column:id"`
GenerateDate time.Time `gorm:"column:generate_date"`
ScoreType int `gorm:"column:score_type"`
Section0 int `gorm:"column:section_0"`
Section1 int `gorm:"column:section_1"`
Section2 int `gorm:"column:section_2"`
Section3 int `gorm:"column:section_3"`
Section4 int `gorm:"column:section_4"`
Section5 int `gorm:"column:section_5"`
Section6 int `gorm:"column:section_6"`
Section7 int `gorm:"column:section_7"`
Section8 int `gorm:"column:section_8"`
Section9 int `gorm:"column:section_9"`
CTime time.Time `gorm:"column:ctime"`
Mtime time.Time `gorm:"column:mtime"`
}

View File

@@ -0,0 +1,35 @@
package upcrmmodel
import "go-common/library/time"
const (
//TaskStateStart 0
TaskStateStart = 0
//TaskStateFinish 1
TaskStateFinish = 1
//TaskStateError 2
TaskStateError = 2
)
const (
//TaskTypeCreditDaily 1
TaskTypeCreditDaily = 1
//TaskTypeScoreSectionDaily 2
TaskTypeScoreSectionDaily = 2
//TaskTypeSignTaskCalculate 3
TaskTypeSignTaskCalculate = 3
//TaskTypeSignCheckDue 4
TaskTypeSignCheckDue = 4
)
//TaskInfo struct
type TaskInfo struct {
ID uint32 `gorm:"column:id"`
GenerateDate string
TaskType int8
StartTime time.Time
EndTime time.Time
TaskState int16
CTime time.Time `gorm:"column:ctime"`
MTime time.Time `gorm:"column:mtime"`
}

View File

@@ -0,0 +1,32 @@
package upcrmmodel
import "go-common/library/time"
import xtime "time"
//UpBaseInfo struct
type UpBaseInfo struct {
ID uint32 `gorm:"column:id"`
Mid int64
Name string
Sex int8
JoinTime time.Time
FirstUpTime time.Time
Level int16
FansCount int
AccountState int8
Activity int
ArticleCount30day int `gorm:"column:article_count_30day"`
ArticleCountAccumulate int
Birthday xtime.Time
ActiveCity string // 市,存的是城市的名字
ActiveProvince string // 省,省的名字
VerifyType int8
BusinessType int8
CreditScore int
PrScore int
QualityScore int
ActiveTid int64
Attr int
CTime time.Time `gorm:"column:ctime"`
MTime time.Time `gorm:"column:mtime"`
}

View File

@@ -0,0 +1,26 @@
package upcrmmodel
import "go-common/library/time"
var (
//BusinessTypeVideo 1
BusinessTypeVideo = 1
//BusinessTypeAudio 2
BusinessTypeAudio = 2
//BusinessTypeArticle 3
BusinessTypeArticle = 3
)
//UpPlayInfo struct
type UpPlayInfo struct {
ID uint32 `gorm:"column:id" json:"-"`
Mid int64 `gorm:"column:mid" json:"mid"`
BusinessType int32 `gorm:"column:business_type" json:"-"`
PlayCountAccumulate int64 `gorm:"column:play_count_accumulate" json:"play_count_accumulate"`
ArticleCount int64 `gorm:"column:article_count" json:"article_count"`
PlayCount90Day int64 `gorm:"column:play_count_90day" json:"play_count_90_day"`
PlayCount30Day int64 `gorm:"column:play_count_30day" json:"play_count_30_day"`
PlayCount7Day int64 `gorm:"column:play_count_7day" json:"play_count_7_day"`
CTime time.Time `gorm:"column:ctime" json:"-"`
MTime time.Time `gorm:"column:mtime" json:"-"`
}

View File

@@ -0,0 +1,32 @@
package upcrmmodel
import "go-common/library/time"
const (
//UpRankTypeFans30day1k 7
UpRankTypeFans30day1k = 7 // 第一次投稿时间在30天内的UP主最快达到1k粉的top500UP列表
//UpRankTypeFans30day1w 8
UpRankTypeFans30day1w = 8 // 第一次投稿时间在30天内的UP主最快达到1w粉的top500UP列表
//UpRankTypePlay30day1k 9
UpRankTypePlay30day1k = 9 // 第一次投稿时间在30天内的UP主最快达到1k播放量的top500UP列表
//UpRankTypePlay30day1w 10
UpRankTypePlay30day1w = 10 // 第一次投稿时间在30天内的UP主最快达到1w播放量的top500UP列表
//UpRankTypePlay30day10k 11
UpRankTypePlay30day10k = 11 // 第一次投稿时间在30天内的UP主最快达到10w播放量的top500UP列表
//UpRankTypeFans30dayIncreaseCount 12
UpRankTypeFans30dayIncreaseCount = 12 //30天内粉丝增长绝对值最多的top500列表
//UpRankTypeFans30dayIncreasePercent 13
UpRankTypeFans30dayIncreasePercent = 13 // 30天内粉丝增长百分比最多30天前粉丝量超过100的top500列表
)
//UpRank struct
type UpRank struct {
ID uint64 `gorm:"column:id"`
Mid int64
Type int16 // 排行榜类型
Value uint
Value2 int
GenerateDate string
CTime time.Time `gorm:"column:ctime"`
MTime time.Time `gorm:"column:mtime"`
}

View File

@@ -0,0 +1,38 @@
package upcrmmodel
import (
"fmt"
"go-common/library/time"
"github.com/siddontang/go-mysql/mysql"
)
var (
// TimeFmtMysql mysql time format
TimeFmtMysql = mysql.TimeFormat
// TimeFmtDate with only date
TimeFmtDate = "2006-01-02"
// TimeFmtDateTime .
TimeFmtDateTime = "2006-01-02 15:04:05"
)
//UpScoreHistory struct
type UpScoreHistory struct {
ID uint32 `gorm:"column:id"`
Mid int64 `gorm:"column:mid"`
ScoreType int8 `gorm:"column:score_type"`
Score int `gorm:"column:score"`
GenerateDate time.Time `gorm:"column:generate_date"`
CTime time.Time `gorm:"column:ctime"`
MTime time.Time `gorm:"column:mtime"`
}
//TableName table name
func (u *UpScoreHistory) TableName() string {
return GetUpScoreHistoryTableName(u.Mid)
}
//GetUpScoreHistoryTableName table name
func GetUpScoreHistoryTableName(mid int64) string {
return fmt.Sprintf("up_scores_history_%02d", mid%100)
}

View File

@@ -0,0 +1,38 @@
package upcrmmodel
import "go-common/library/time"
// UpStatsHistory is table up_stats_history mapping
type UpStatsHistory struct {
ID uint32 `gorm:"column:id"`
Type int `gorm:"column:type"`
SubType int `gorm:"column:sub_type"`
Value1 int64 `gorm:"column:value1"`
Value2 int64 `gorm:"column:value2"`
GenerateDate time.Time `gorm:"column:generate_date"`
Ctime time.Time `gorm:"column:ctime"`
Mtime time.Time `gorm:"column:mtime"`
}
const (
//ActivityType 活跃Up主数量
ActivityType = iota + 1
//IncrType 新增
IncrType
//TotalType 总数
TotalType
)
//Activity 活跃度
type Activity int
const (
//HighActivity 1
HighActivity Activity = iota + 1
//MediumActivity 2
MediumActivity
//LowActivity 3
LowActivity
//LostActivity 4
LostActivity
)