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,40 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"command_arg.go",
"errorcode.go",
"monitor.go",
"msg.go",
"rpc.go",
],
importpath = "go-common/app/admin/main/up/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/admin/main/up/model/datamodel:all-srcs",
"//app/admin/main/up/model/signmodel:all-srcs",
"//app/admin/main/up/model/upcrmmodel:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,8 @@
package model
//Archive for db.
type Archive struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
State int `json:"state"`
}

View File

@@ -0,0 +1,9 @@
package model
//CommandCommonArg common arg for command
type CommandCommonArg struct {
}
//CommandCommonResult common result for command
type CommandCommonResult struct {
}

View File

@@ -0,0 +1,32 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"requestargs.go",
"upinfo.go",
"viewer.go",
],
importpath = "go-common/app/admin/main/up/model/datamodel",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,62 @@
package datamodel
type commonArg struct {
Mid int64 `form:"mid"`
}
//GetFansSummaryArg arg to get fans
type GetFansSummaryArg struct {
Mid int64 `form:"mid"`
}
//FansSummaryResult result for fans result
type FansSummaryResult struct {
FanSummary FanSummaryData `json:"fan_summary"`
}
const (
//DataType30Day 30 day
DataType30Day = 1
//DataTypeMonth by month
DataTypeMonth = 2
)
//GetRelationFansHistoryArg arg
type GetRelationFansHistoryArg struct {
Mid int64 `form:"mid"`
DataType int `form:"data_type"`
}
//GetRelationFansHistoryResult relation fan history
type GetRelationFansHistoryResult struct {
RelationFanHistoryData
}
// GetRelationFansMonthArg arg
type GetRelationFansMonthArg = GetFansSummaryArg
// GetRelationFansMonthResult relation fan history
type GetRelationFansMonthResult struct {
RelationFanHistoryData
}
//GetUpArchiveInfoArg arg
type GetUpArchiveInfoArg struct {
Mids string `form:"mids" validate:"required"`
DataType int `form:"data_type"`
}
//GetUpArchiveInfoResult result, key = mid, value = data
type GetUpArchiveInfoResult = map[int64]*UpArchiveData
//GetUpArchiveTagInfoArg tag info
type GetUpArchiveTagInfoArg = commonArg
//GetUpArchiveTagInfoResult resutl
type GetUpArchiveTagInfoResult = []*ViewerTagData
//GetUpArchiveTypeInfoArg arg to get type
type GetUpArchiveTypeInfoArg = commonArg
//GetUpViewInfoArg get up view info data
type GetUpViewInfoArg = commonArg

View File

@@ -0,0 +1,31 @@
package datamodel
//UpArchiveData hbase up archive info table
type UpArchiveData struct {
Avs int64 `json:"avs" qualifier:"avs"` // 稿件数
Play int64 `json:"play" qualifier:"play"` // 播放数
Likes int64 `json:"likes" qualifier:"likes"` // 点赞数
Danmu int64 `json:"danmu" qualifier:"danmu"` //弹幕
Reply int64 `json:"reply" qualifier:"reply"` //评论
Share int64 `json:"share" qualifier:"share"` //分享
Fav int64 `json:"fav" qualifier:"fav"` //收藏
Coin int64 `json:"coin" qualifier:"coin"` //硬币
MaxPlayAid int64 `json:"max_play_aid" qualifier:"aid"` //最高播放的aid
MaxPlay int64 `json:"max_play" qualifier:"playest"` //最高播放次数
}
//UpArchiveTagData tag data
type UpArchiveTagData struct {
// key-> index, value-> tagid
TagMap map[string]int64 `family:"tag"`
}
//UpArchiveTypeData type data
type UpArchiveTypeData struct {
Tid int64 `json:"tid" qualifier:"tid"` // 一级分区
TidName string `json:"tid_name"` // 分区名字
Count int64 `json:"count" qualifier:"cnt"` // 稿件数量
SubTid int64 `json:"sub_tid" qualifier:"sub_tid"` //二级分区
SubCount int64 `json:"sub_count" qualifier:"sub_cnt"` //稿件数量
SubTidName string `json:"sub_tid_name"` // 分区名字
}

View File

@@ -0,0 +1,123 @@
package datamodel
//for fan manager top mids.
const (
//Total 粉丝管理-累计数据
Total = iota
//Seven 粉丝管理-7日数据
Seven
//Thirty 粉丝管理-30日数据
Thirty
//Ninety 粉丝管理-90日数据
Ninety
//PlayDuration 播放时长
PlayDuration = "video_play"
//VideoAct 视频互动
VideoAct = "video_act"
//DynamicAct 动态互动
DynamicAct = "dynamic_act"
)
/* ------------- */
//ViewerTypeData type's play count
type ViewerTypeData struct {
Tid int `json:"tid"`
Name string `json:"name"`
Play int64 `json:"play"`
}
//ViewerTagData viewer tag struct
type ViewerTagData struct {
Idx int `json:"idx"`
TagID int `json:"tag_id"`
Name string `json:"name"`
}
//ViewerTypeTagInfo struct for viewer type and tag
type ViewerTypeTagInfo struct {
Type []*ViewerTypeData `json:"type"`
Tag []*ViewerTagData `json:"tag"`
}
// ViewerTrendInfo struct for viewer trend
type ViewerTrendInfo struct {
Fans *ViewerTypeTagInfo `json:"fans"`
Guest *ViewerTypeTagInfo `json:"guest"`
}
/* ------------- */
//ViewerAreaData viewer area data
type ViewerAreaData struct {
Area string `json:"area"`
Viewers int64 `json:"viewers"`
}
//ViewerAreaInfo viewer area info
type ViewerAreaInfo struct {
Fans []ViewerAreaData `json:"fans"`
Guest []ViewerAreaData `json:"guest"`
}
/* ------------- */
//ViewerBaseData base data
//f:plat0 web-pc播放
//f:plat1 web-h5播放
//f:plat2 站外播放
//f:plat3 ios播放
//f:plat4 android播放
type ViewerBaseData struct {
Male int64 `json:"male"`
Female int64 `json:"female"`
Age1 int64 `json:"age_1"` //0~16岁
Age2 int64 `json:"age_2"` // 16~25
Age3 int64 `json:"age_3"` //25~40
Age4 int64 `json:"age_4"` // 40+
PlatPC int64 `json:"plat_pc"` // pc
PlatH5 int64 `json:"plat_h5"` // h5
PlatOut int64 `json:"plat_out"` // 站外播放
PlatIOS int64 `json:"plat_ios"` // ios播放
PlatAndroid int64 `json:"plat_android"` // android播放
PlatOtherApp int64 `json:"plat_other_app"` // 其他播放
}
//ViewerBaseInfo base info
type ViewerBaseInfo struct {
Fans *ViewerBaseData `json:"fans"`
Guest *ViewerBaseData `json:"guest"`
}
/* ------------- */
//FanSummaryData fans summary data
type FanSummaryData struct {
Total int32 `json:"total" family:"f" qualifier:"all"` // 粉丝总数
Active int32 `json:"active" family:"f" qualifier:"act"` // 活跃粉丝数
Inc int32 `json:"inc" family:"f" qualifier:"inc"` // 新增粉丝
Medal int32 `json:"medal" family:"f" qualifier:"mdl"` // 领取勋章粉丝
Elec int32 `json:"elec" family:"f" qualifier:"elec"` //充电粉丝
MedalDiff int32 `json:"medal_diff" family:"f" qualifier:"mdl_diff"` //活跃粉丝(增量)
ActiveDiff int32 `json:"active_diff" family:"f" qualifier:"act_diff"` //领取勋章粉丝(增量)
ElecDiff int32 `json:"elec_diff" family:"f" qualifier:"elec_diff"` //充电粉丝(增量)
Inter int32 `json:"inter" family:"f" qualifier:"inter"` //观看活跃度*10000
ViewPercent int32 `json:"view_percent" family:"f" qualifier:"v"` //播放粉丝占比*10000
DmPercent int32 `json:"dm_percent" family:"f" qualifier:"da"` //弹幕粉丝占比*10000
ReplyPercent int32 `json:"reply_percent" family:"f" qualifier:"re"` //评论粉丝占比*10000
CoinPercent int32 `json:"coin_percent" family:"f" qualifier:"co"` //投币粉丝占比*10000
FavorPercent int32 `json:"favor_percent" family:"f" qualifier:"fv"` //收藏粉丝占比*10000
SharePercent int32 `json:"share_percent" family:"f" qualifier:"sh"` //分享粉丝占比*10000
LikePercent int32 `json:"like_percent" family:"f" qualifier:"lk"` //点赞粉丝占比*10000
}
//FanInfo fans info
type FanInfo struct {
Summary FanSummaryData `json:"summary"`
}
//RelationFanHistoryData data for relation fans follow and unfollow
type RelationFanHistoryData struct {
FollowData map[string]int `family:"a"`
UnfollowData map[string]int `family:"u"`
}

View File

@@ -0,0 +1,8 @@
package model
import "fmt"
var (
//ErrNoFileLink no update contract
ErrNoFileLink = fmt.Errorf("未上传完成!请点击上传按钮完成上传!")
)

View File

@@ -0,0 +1,13 @@
package model
// BAP for wechat msg.
type BAP struct {
UserName string `json:"username"`
Title string `json:"title"`
Content string `json:"content"`
URL string `json:"url"`
Ty string `json:"type"`
Token string `json:"token"`
Signature string `json:"signature"`
TimeStamp int64 `json:"timestamp"`
}

View File

@@ -0,0 +1,10 @@
package model
//Msg for databus consume.
type Msg struct {
MID int64 `json:"mid"`
From int `json:"from"`
IsAuthor int `json:"is_author"`
TimeStamp int64 `json:"timestamp"`
ConsumeTime int64 `json:"consume_time,omitempty"`
}

View File

@@ -0,0 +1,5 @@
gopath="$GOPATH/src"
protobuf_path="$gopath/go-common/vendor/github.com/gogo/protobuf"
echo $protobuf_path
ls "$gopath/go-common/vendor/github.com/gogo/protobuf/gogoproto/"
protoc --gofast_out=".." -I"../" -I"$gopath/go-common/vendor/" ../*.proto

View File

@@ -0,0 +1,20 @@
package model
import "time"
//ArgSpecial arg
type ArgSpecial struct {
GroupID int64
}
//ArgInfo arg
type ArgInfo struct {
Mid int64
From int
}
//ArgMidWithDate arg
type ArgMidWithDate struct {
Mid int64
Date time.Time // 需要查询的时间,如果不填,会使用当前最新的数据
}

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"requestargs.go",
"sign_up.go",
],
importpath = "go-common/app/admin/main/up/model/signmodel",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/up/conf:go_default_library",
"//app/admin/main/up/dao:go_default_library",
"//app/admin/main/up/util/now: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"],
)

View File

@@ -0,0 +1,87 @@
CREATE TABLE `sign_task_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '任务ID',
`mid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`sign_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
`task_template_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'sign_task模板表中的任务ID',
`task_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型 0累积 1日 2周 3月 4季度',
`task_counter` int(11) NOT NULL DEFAULT '0' COMMENT '任务计数器',
`task_condition` int(11) NOT NULL DEFAULT '0' COMMENT '任务条件',
`attribute` bigint(20) NOT NULL DEFAULT '0' COMMENT '属性位',
`task_data` varchar(1024) NOT NULL DEFAULT '' COMMENT '任务存储相关数据',
`state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '状态1、未完成2、完成 100、删除',
`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_task_template_id_generate_date` (`task_template_id`,`generate_date`),
KEY `ix_mid` (`mid`),
KEY `ix_sign_id` (`sign_id`),
KEY `ix_generate_date` (`generate_date`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务历史数据表';
CREATE TABLE `sign_task_absence` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '自增ID',
`sign_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
`mid` bigint(20) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
`task_history_id` int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'sign_task_history表中ID',
`absence_count` int(11) unsigned NOT NULL DEFAULT '0' COMMENT '请假数量',
`reason` varchar(255) NOT NULL DEFAULT '' COMMENT '请假理由',
`state` tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
`admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '管理员id',
`admin_name` varchar(32) NOT NULL DEFAULT '' COMMENT '管理员name',
`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_mid` (`mid`),
KEY `ix_sign_id` (`sign_id`),
KEY `ix_task_history_id` (`task_history_id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务请假表';
CREATE TABLE `sign_violation_history` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '主键id',
`sign_id` int(11) NOT NULL DEFAULT '0' COMMENT '签约id',
`mid` bigint(20) NOT NULL DEFAULT '0' COMMENT '违约人',
`admin_id` int(11) NOT NULL DEFAULT '0' COMMENT '操作人id',
`admin_name` varchar(32) NOT NULL DEFAULT '' COMMENT '操作人名字',
`violation_reason` varchar(255) NOT NULL DEFAULT '' COMMENT '违约原因',
`state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '违约状态 1:违约 100:删除',
`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_sign_id` (`sign_id`),
KEY `ix_mtime` (`mtime`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT '违约历史表';
#新增字段
alter table sign_task add column attribute bigint(20) not null default '0' comment '属性位';
alter table sign_task add column finish_note varchar(255) NOT NULL DEFAULT '' COMMENT '任务完成方式';
alter table sign_pay add column `in_tax` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是否含税:1 不含税 2含税';
alter table sign_up add column `organization` tinyint(4) NOT NULL DEFAULT '1' COMMENT '组织属性: 1个人 2公司';
alter table sign_up add column `sign_type` tinyint(4) NOT NULL DEFAULT '0' COMMENT '签约类型: 0 其他 、1独家、2首发、3独家系列、4独家双微除外、5独家微博除外';
alter table sign_up add column `age` tinyint(4) unsigned NOT NULL DEFAULT '0' COMMENT '年龄';
alter table sign_up add column `residence` varchar(255) NOT NULL DEFAULT '' COMMENT '居住地';
alter table sign_up add column `id_card` varchar(20) NOT NULL DEFAULT '' COMMENT '身份证';
alter table sign_up add column `phone` varchar(16) NOT NULL DEFAULT '' COMMENT '联系方式';
alter table sign_up add column `qq` bigint(20) unsigned NOT NULL COMMENT 'qq号';
alter table sign_up add column `wechat` varchar(16) NOT NULL DEFAULT '' COMMENT '微信号';
alter table sign_up add column `is_economic` tinyint(4) NOT NULL DEFAULT '1' COMMENT '是非签署经济约 1否 2是';
alter table sign_up add column `economic_company` varchar(16) NOT NULL DEFAULT '' COMMENT '签约的经济公司';
alter table sign_up add column `task_state` tinyint(4) NOT NULL DEFAULT '1' COMMENT '任务完成度: 1 未完成 2 已完成';
alter table sign_up add column `wechat` varchar(16) NOT NULL DEFAULT '' COMMENT '微信号';
alter table sign_up add column `leave_times` int(11) NOT NULL COMMENT '请假次数';
alter table sign_up add column `violation_times` int(11) NOT NULL COMMENT '违约次数';
alter table sign_up add column `active_tid` smallint(6) unsigned NOT NULL DEFAULT '0' COMMENT 'up所属主分区';
#新增索引
ALTER TABLE sign_up ADD INDEX ix_active_tid(`active_tid`);
ALTER TABLE sign_up ADD INDEX ix_sex(`sex`);
ALTER TABLE sign_up ADD INDEX ix_country(`country`);
ALTER TABLE sign_up ADD INDEX ix_task_state(`task_state`);
ALTER TABLE sign_up ADD INDEX ix_sign_type(`sign_type`);
alter table sign_up add `economic_begin` date NOT NULL DEFAULT '0000-00-00' COMMENT '经济约的签约开始时间';
alter table sign_up add `economic_end` date NOT NULL DEFAULT '0000-00-00' COMMENT '经济约的签约结束时间';

View File

@@ -0,0 +1,538 @@
package signmodel
import (
"fmt"
"net/url"
"strings"
"time"
"go-common/app/admin/main/up/conf"
"go-common/app/admin/main/up/dao"
xtime "go-common/library/time"
)
// const .
const (
SignUpList = 0
SignUpDetail = 1
)
// -------------------------------------------------
// CommonResponse result
type CommonResponse struct {
}
// CommonArg arg
type CommonArg struct {
}
// SignUpBaseInfo struct
type SignUpBaseInfo struct {
ID int64 `json:"id"`
Name string `json:"name"`
Sex int8 `json:"sex"`
Mid int64 `json:"mid"`
BeginDate xtime.Time `json:"begin_date"`
EndDate xtime.Time `json:"end_date"`
State int8 `json:"state"`
Country string `json:"country"`
Province string `json:"province"`
City string `json:"city"`
Note string `json:"note"`
TypeName string `json:"type_name"`
ActiveTid int16 `json:"active_tid"`
AdminID int `json:"admin_id"`
AdminName string `json:"admin_name"`
CreateTime xtime.Time `json:"create_time"`
Organization int8 `json:"organization"`
SignType int8 `json:"sign_type"`
Age int8 `json:"age"`
Residence string `json:"residence"`
IDCard string `json:"id_card"`
Phone string `json:"phone"`
QQ int64 `json:"qq"`
Wechat string `json:"wechat"`
IsEconomic int8 `json:"is_economic"`
EconomicCompany string `json:"economic_company"`
EconomicBegin xtime.Time `json:"economic_begin"`
EconomicEnd xtime.Time `json:"economic_end"`
ViolationTimes int `json:"violation_times"`
LeaveTimes int `json:"leave_times"`
}
// CopyTo copy
func (s *SignUpBaseInfo) CopyTo(dbstruct *SignUp) {
dbstruct.ID = s.ID
dbstruct.Mid = s.Mid
dbstruct.Sex = s.Sex
dbstruct.BeginDate = s.BeginDate
dbstruct.EndDate = s.EndDate
dbstruct.Country = s.Country
dbstruct.Province = s.Province
dbstruct.City = s.City
dbstruct.Note = s.Note
dbstruct.AdminID = s.AdminID
dbstruct.AdminName = s.AdminName
dbstruct.Organization = s.Organization
dbstruct.SignType = s.SignType
dbstruct.Age = s.Age
dbstruct.Residence = s.Residence
dbstruct.IDCard = s.IDCard
dbstruct.Phone = s.Phone
dbstruct.QQ = s.QQ
dbstruct.Wechat = s.Wechat
dbstruct.IsEconomic = s.IsEconomic
if s.IsEconomic == ContainEconomic {
dbstruct.EconomicCompany = s.EconomicCompany
dbstruct.EconomicBegin = s.EconomicBegin
dbstruct.EconomicEnd = s.EconomicEnd
}
}
// CopyFrom copy
func (s *SignUpBaseInfo) CopyFrom(dbstruct *SignUp) {
s.ID = dbstruct.ID
s.Mid = dbstruct.Mid
s.Sex = dbstruct.Sex
s.BeginDate = dbstruct.BeginDate
s.EndDate = dbstruct.EndDate
s.Country = dbstruct.Country
s.Province = dbstruct.Province
s.City = dbstruct.City
s.Note = dbstruct.Note
s.AdminID = dbstruct.AdminID
s.AdminName = dbstruct.AdminName
s.Organization = dbstruct.Organization
s.SignType = dbstruct.SignType
s.Age = dbstruct.Age
s.Residence = dbstruct.Residence
s.IDCard = dbstruct.IDCard
s.Phone = dbstruct.Phone
s.QQ = dbstruct.QQ
s.Wechat = dbstruct.Wechat
s.IsEconomic = dbstruct.IsEconomic
if dbstruct.IsEconomic == ContainEconomic {
s.EconomicCompany = dbstruct.EconomicCompany
s.EconomicBegin = dbstruct.EconomicBegin
s.EconomicEnd = dbstruct.EconomicEnd
}
s.State = dbstruct.State
s.ActiveTid = dbstruct.ActiveTid
s.LeaveTimes = dbstruct.LeaveTimes
s.ViolationTimes = dbstruct.ViolationTimes
s.CreateTime = dbstruct.Ctime
}
// CopyFrom .
func (t *SignTaskHistoryArg) CopyFrom(st *SignTaskHistory, absenceCounter int) {
var taskBegin, taskEnd time.Time
taskBegin, taskEnd = GetTaskDuration(st.GenerateDate.Time(), st.TaskType)
t.TaskBegin = xtime.Time(taskBegin.Unix())
t.TaskEnd = xtime.Time(taskEnd.Unix())
t.TaskType = st.TaskType
t.TaskState = int8(st.State)
t.TaskCounter = st.TaskCounter
t.TaskCondition = st.TaskCondition
t.AbsenceCounter = absenceCounter
t.IsBusinessArchive = st.AttrVal(AttrBitIsBusinessArchive)
}
// SignUpArg struct
type SignUpArg struct {
SignUpBaseInfo
PayInfo []*SignPayInfoArg `json:"pay_info"`
TaskInfo []*SignTaskInfoArg `json:"task_info"`
ContractInfo []*SignContractInfoArg `json:"contract_info"`
}
// SignUpsArg struct
type SignUpsArg struct {
SignUpBaseInfo
TaskHistoryInfo []*SignTaskHistoryArg `json:"task_history_info"`
PayInfo []*SignPayInfoArg `json:"pay_info"`
ContractInfo []*SignContractInfoArg `json:"contract_info"`
}
// SignQueryResult result
type SignQueryResult struct {
SignBaseInfo *SignUpBaseInfo `json:"sign_base_info"`
Result []*SignUpsArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// SignTaskHistoryArg struct
type SignTaskHistoryArg struct {
TaskBegin xtime.Time `json:"task_begin"`
TaskEnd xtime.Time `json:"task_end"`
TaskType int8 `json:"task_type"`
TaskState int8 `json:"task_state"`
TaskCounter int `json:"task_counter"`
TaskCondition int `json:"task_condition"`
AbsenceCounter int `json:"absence_counter"`
IsBusinessArchive int64 `json:"is_business_archive"`
}
// ViolationArg struct
type ViolationArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
ViolationReason string `json:"violation_reason"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
OpTime xtime.Time `json:"op_time"`
State int8 `json:"state"`
}
// ViolationResult result
type ViolationResult struct {
Result []*ViolationArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// CopyTo violationArg.
func (a *ViolationArg) CopyTo(v *SignViolationHistory) {
v.SignID = a.SignID
v.Mid = a.Mid
v.AdminID = a.AdminID
v.AdminName = a.AdminName
v.ViolationReason = a.ViolationReason
}
// CopyFrom violationArg.
func (a *ViolationArg) CopyFrom(v *SignViolationHistory) {
a.ID = v.ID
a.SignID = v.SignID
a.Mid = v.Mid
a.AdminID = v.AdminID
a.AdminName = v.AdminName
a.ViolationReason = v.ViolationReason
a.OpTime = v.Mtime
a.State = v.State
}
// AbsenceArg struct
type AbsenceArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
AbsenceCount int `json:"absence_count"`
Reason string `json:"reason"`
AdminID int64 `json:"admin_id"`
AdminName string `json:"admin_name"`
OpTime xtime.Time `json:"op_time"`
TaskBegin xtime.Time `json:"task_begin"`
TaskEnd xtime.Time `json:"task_end"`
State int8 `json:"state"`
}
// CopyTo AbsenceArg.
func (a *AbsenceArg) CopyTo(v *SignTaskAbsence) {
v.SignID = a.SignID
v.Mid = a.Mid
v.AdminID = a.AdminID
v.AdminName = a.AdminName
v.AbsenceCount = a.AbsenceCount
v.Reason = a.Reason
}
// CopyFrom AbsenceArg.
func (a *AbsenceArg) CopyFrom(v *SignTaskAbsence) {
a.ID = v.ID
a.SignID = v.SignID
a.Mid = v.Mid
a.AdminID = v.AdminID
a.AdminName = v.AdminName
a.AbsenceCount = v.AbsenceCount
a.Reason = v.Reason
a.State = v.State
a.OpTime = v.Mtime
}
// AbsenceResult result
type AbsenceResult struct {
Result []*AbsenceArg `json:"result"`
TotalCount int `json:"total_count"`
Page int `json:"page"`
Size int `json:"size"`
}
// PageArg .
type PageArg struct {
SignID int64 `form:"sign_id"`
Page int `form:"page"`
Size int `form:"size"`
}
// IDArg .
type IDArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
AdminID int64
AdminName string
}
// PowerCheckArg .
type PowerCheckArg struct {
TIDs []int16 `form:"tids,split"`
Mid int64 `form:"mid"`
}
// PowerCheckReply .
type PowerCheckReply struct {
IsPower bool `json:"is_power"`
IsSign bool `json:"is_sign"`
}
// SignPayInfoArg =============
type SignPayInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
DueDate xtime.Time `json:"due_date"`
PayValue int64 `json:"pay_value"`
Note string `json:"note"`
State int8 `json:"state"`
InTax int8 `json:"in_tax"`
}
// CopyTo copy
func (s *SignPayInfoArg) CopyTo(dbstruct *SignPay) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.DueDate = s.DueDate
dbstruct.PayValue = s.PayValue
dbstruct.Note = s.Note
dbstruct.InTax = s.InTax
}
// CopyFrom copy
func (s *SignPayInfoArg) CopyFrom(dbstruct *SignPay) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.DueDate = dbstruct.DueDate
s.PayValue = dbstruct.PayValue
s.Note = dbstruct.Note
s.State = dbstruct.State
s.InTax = dbstruct.InTax
}
// SignTaskInfoArg =============
type SignTaskInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
TaskType int8 `json:"task_type"`
TaskCondition int `json:"task_condition"`
TaskCounter int `json:"task_counter"`
TaskState int8 `json:"task_state"`
IsBusinessArchive int64 `json:"is_business_archive"`
}
// CopyTo copy
func (s *SignTaskInfoArg) CopyTo(dbstruct *SignTask) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.TaskType = s.TaskType
dbstruct.TaskCondition = s.TaskCondition
dbstruct.AttrSet(s.IsBusinessArchive, AttrBitIsBusinessArchive)
dbstruct.TaskData = ""
}
// CopyFrom copy
func (s *SignTaskInfoArg) CopyFrom(dbstruct *SignTask) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.TaskType = dbstruct.TaskType
s.TaskCondition = dbstruct.TaskCondition
s.TaskCounter = dbstruct.TaskCounter
s.IsBusinessArchive = dbstruct.AttrVal(AttrBitIsBusinessArchive)
if s.TaskCounter >= s.TaskCondition {
s.TaskState = 1
}
}
// SignContractInfoArg =============
type SignContractInfoArg struct {
ID int64 `json:"id"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
Filename string `json:"filename"`
Filelink string `json:"filelink"`
}
// CopyTo copy
func (s *SignContractInfoArg) CopyTo(dbstruct *SignContract) {
dbstruct.ID = s.ID
dbstruct.SignID = s.SignID
dbstruct.Mid = s.Mid
dbstruct.Filelink = BuildOrcBfsURL(s.Filelink)
dbstruct.Filename = s.Filename
}
// CopyFrom copy
func (s *SignContractInfoArg) CopyFrom(dbstruct *SignContract) {
s.ID = dbstruct.ID
s.SignID = dbstruct.SignID
s.Mid = dbstruct.Mid
s.Filelink = BuildDownloadURL(dbstruct.Filename, dbstruct.Filelink)
s.Filename = dbstruct.Filename
}
// SignQueryArg =============
type SignQueryArg struct {
Tids []int64 `form:"tids,split"` // 权限tid
Mid int64 `form:"mid"`
DueSign int8 `form:"due_sign"` // 签约即将过期
DuePay int8 `form:"due_pay"` // 支付周期即将过期
ExpireSign int8 `form:"expire_sign"` // 签约已过期
Sex int8 `form:"sex" default:"-1"`
Country []string `form:"country,split"`
ActiveTID int16 `form:"active_tid"`
SignType int8 `form:"sign_type"`
TaskState int8 `form:"task_state"`
SignBegin xtime.Time `form:"sign_begin"`
SignEnd xtime.Time `form:"sign_end"`
IsDetail int8 `form:"is_detail"` // 是否详情
Page int `form:"page"`
Size int `form:"size"`
}
// SignIDArg .
type SignIDArg struct {
ID int64 `form:"id" validate:"required"`
}
// SignPayCompleteArg ==============
type SignPayCompleteArg struct {
IDs []int64 `json:"ids"`
}
// SignPayCompleteResult result
type SignPayCompleteResult struct {
}
// SignCheckTaskArg ==============
type SignCheckTaskArg struct {
Date string `form:"date"`
}
// SignCheckExsitArg ==============
type SignCheckExsitArg struct {
Mid int64 `form:"mid"`
}
// SignCheckExsitResult result
type SignCheckExsitResult struct {
Exist bool `json:"exist"`
}
// SignOpSearchArg .
type SignOpSearchArg struct {
Mid int64 `form:"mid"`
OpID int64 `form:"oper_id"` // 操作人
SignID int64 `form:"sign_id"`
Tp int8 `form:"type" default:"2"` // 操作类型 1:新增 2:修改
Order string `form:"order" default:"ctime"`
Sort string `form:"sort" default:"desc"`
PN int `form:"page" default:"1"`
PS int `form:"size" default:"50"`
}
// BaseAuditReply .
type BaseAuditReply struct {
CTime string `json:"ctime"`
IntOne int64 `json:"int_0"`
OID int64 `json:"oid"`
Tp int8 `json:"type"`
UID int64 `json:"uid"`
UName string `json:"uname"`
ExtraData string `json:"extra_data"`
}
// BaseAuditListReply .
type BaseAuditListReply struct {
Order string `json:"order"`
Sort string `json:"sort"`
Pager *pager `json:"page"`
Result []*BaseAuditReply `json:"result"`
}
type pager struct {
Page int `json:"num"`
Size int `json:"size"`
TotalCount int `json:"total"`
}
// SignAuditReply .
type SignAuditReply struct {
CTime xtime.Time `json:"ctime"`
SignID int64 `json:"sign_id"`
Mid int64 `json:"mid"`
Tp int8 `json:"type"`
OperID int64 `json:"oper_id"`
OperName string `json:"oper_name"`
Content *SignContentReply `json:"content"`
}
// SignAuditListReply .
type SignAuditListReply struct {
Order string `json:"order"`
Sort string `json:"sort"`
Page int `json:"page"`
Size int `json:"size"`
TotalCount int `json:"total_count"`
Result []*SignAuditReply `json:"result"`
}
// SignContentReply .
type SignContentReply struct {
New *SignUpArg `json:"new"`
Old *SignUpArg `json:"old"`
ChangeType []int8 `json:"change_type"`
}
// SignCountrysReply .
type SignCountrysReply struct {
List []string `json:"list"`
}
// SignTidsReply .
type SignTidsReply struct {
List map[int64]string `json:"list"`
}
// BuildOrcBfsURL orc bfs url.
func BuildOrcBfsURL(raw string) string {
if raw == "" {
return ""
}
ori, err := url.Parse(raw)
if err != nil {
return raw
}
values := ori.Query()
values.Del("token")
ori.RawQuery = values.Encode()
return ori.String()
}
// BuildDownloadURL .
func BuildDownloadURL(fileName string, bfsurl string) (finalurl string) {
var bfsConf = conf.Conf.BfsConf
var index = strings.LastIndex(bfsurl, "/")
if index >= 0 && index+1 < len(bfsurl) {
fileName = bfsurl[index+1:]
}
finalurl = fmt.Sprintf("%s?token=%s", bfsurl, url.QueryEscape(dao.Authorize(bfsConf.Key, bfsConf.Secret, "GET", bfsConf.Bucket, fileName, time.Now().Unix())))
return
}

View File

@@ -0,0 +1,441 @@
package signmodel
import (
"strings"
"time"
"go-common/app/admin/main/up/util/now"
"go-common/library/log"
xtime "go-common/library/time"
)
const (
// TableSignPay table name
TableSignPay = "sign_pay"
// TableSignUp table name
TableSignUp = "sign_up"
// TableSignTask table name
TableSignTask = "sign_task"
// TableSignContract table name
TableSignContract = "sign_contract"
// TableSignTaskAbsence table name
TableSignTaskAbsence = "sign_task_absence"
// TableSignTaskHistory table name
TableSignTaskHistory = "sign_task_history"
// TableSignViolationHistory table name
TableSignViolationHistory = "sign_violation_history"
)
const (
// DateDefualtFromDB .
DateDefualtFromDB = -28800
// DateDefualt .
DateDefualt = "0000-00-00"
)
const (
//TaskTypeAccumulate 0
TaskTypeAccumulate = 0
//TaskTypeDay 1
TaskTypeDay = 1
//TaskTypeWeek 2
TaskTypeWeek = 2
//TaskTypeMonth 3
TaskTypeMonth = 3
//TaskTypeQuarter 4 季度
TaskTypeQuarter = 4
)
const (
//TaskStateRunning 0
TaskStateRunning = 0
//TaskStateExpire 1
TaskStateExpire = 1
//TaskStateFinish 2
TaskStateFinish = 2
)
// const .
const (
SignUpMidAdd = 1
SignUpMidUpdate = 2
)
// const 。
const (
NotContainEconomic = 1
ContainEconomic = 2
)
const (
// SignUpLogBizID 签约up信息修改日志
SignUpLogBizID int = 261
)
const (
//SignTaskStateInit init
SignTaskStateInit = 0
//SignTaskStateRunning task running
SignTaskStateRunning = 1
//SignTaskStateFinish finish
SignTaskStateFinish = 2
//SignTaskStateDelete delete
SignTaskStateDelete = 100
)
// const 变更类型.
const (
// 年龄
ChangeSexHistory = iota + 1
// 用户id
ChangeMidHistory
// 签约周期
ChangeSignDateHistory
// 地区
ChangeAreaHistory
// 组织
ChangeOrganizationHistory
// 签约类型
ChangeSignTypeHistory
// 年龄
ChangeAgeHistory
// 居住地
ChangeResidenceHistory
// 身份证
ChangeIDCardHistory
// 联系方式
ChangePhoneHistory
// QQ
ChangeQQHistory
// 微信
ChangeWechatHistory
// 经济公司
ChangeEconomicHistory
// 签约付款周期
ChangeSignPayHistory
// 签约任务
ChangeSignTaskHistory
// 签约合同
ChangeSignContractHistory
// 签约备注
ChangeSignNoteHistory
)
const (
//EmailStateNotSend 0
EmailStateNotSend = 0
//EmailStateSendSucc 1
EmailStateSendSucc = 1
)
const (
// AttrYes on
AttrYes = int64(1)
// AttrNo off
AttrNo = int64(0)
// AttrBitIsBusinessArchive bit
AttrBitIsBusinessArchive = uint(0)
)
// SignUpOnlyID struct
type SignUpOnlyID struct {
ID uint32
}
// SignUpOnlySignID struct
type SignUpOnlySignID struct {
SignID uint32
}
// SignUp struct
type SignUp struct {
ID int64
Sex int8
Mid int64
BeginDate xtime.Time
EndDate xtime.Time
State int8
Country string
Province string
City string
Note string
AdminID int
AdminName string
EmailState int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
Organization int8
SignType int8
Age int8
Residence string
IDCard string `gorm:"column:id_card"`
Phone string
QQ int64 `gorm:"column:qq"`
Wechat string `gorm:"column:wechat"`
IsEconomic int8
EconomicCompany string
EconomicBegin xtime.Time
EconomicEnd xtime.Time
TaskState int8
LeaveTimes int
ViolationTimes int
ActiveTid int16
}
// Diff .
func (su *SignUp) Diff(oriSu *SignUp, fields map[int8]struct{}) {
if oriSu.Sex != su.Sex {
fields[ChangeSexHistory] = struct{}{}
}
if oriSu.Mid != su.Mid {
fields[ChangeMidHistory] = struct{}{}
}
if oriSu.BeginDate != su.BeginDate || oriSu.EndDate != su.EndDate {
fields[ChangeSignDateHistory] = struct{}{}
}
if !strings.EqualFold(oriSu.Country, su.Country) || !strings.EqualFold(oriSu.Province, su.Province) || !strings.EqualFold(oriSu.City, su.City) {
fields[ChangeAreaHistory] = struct{}{}
}
if oriSu.Organization != su.Organization {
fields[ChangeOrganizationHistory] = struct{}{}
}
if oriSu.SignType != su.SignType {
fields[ChangeSignTypeHistory] = struct{}{}
}
if oriSu.Age != su.Age {
fields[ChangeAgeHistory] = struct{}{}
}
if oriSu.Residence != su.Residence {
fields[ChangeResidenceHistory] = struct{}{}
}
if oriSu.IDCard != su.IDCard {
fields[ChangeIDCardHistory] = struct{}{}
}
if oriSu.Phone != su.Phone {
fields[ChangePhoneHistory] = struct{}{}
}
if oriSu.QQ != su.QQ {
fields[ChangeQQHistory] = struct{}{}
}
if oriSu.Wechat != su.Wechat {
fields[ChangeWechatHistory] = struct{}{}
}
if oriSu.EconomicBegin == DateDefualtFromDB {
oriSu.EconomicBegin = 0
}
if oriSu.EconomicEnd == DateDefualtFromDB {
oriSu.EconomicEnd = 0
}
if oriSu.IsEconomic != su.IsEconomic || !strings.EqualFold(oriSu.EconomicCompany, su.EconomicCompany) ||
oriSu.EconomicBegin != su.EconomicBegin || oriSu.EconomicEnd != su.EconomicEnd {
fields[ChangeEconomicHistory] = struct{}{}
}
if !strings.EqualFold(oriSu.Note, su.Note) {
fields[ChangeSignNoteHistory] = struct{}{}
}
su.State = oriSu.State
su.EmailState = oriSu.EmailState
su.TaskState = oriSu.TaskState
su.LeaveTimes = oriSu.LeaveTimes
su.ViolationTimes = oriSu.ViolationTimes
su.ActiveTid = oriSu.ActiveTid
su.Ctime = oriSu.Ctime
}
// SignPay struct
type SignPay struct {
ID int64
Mid int64
SignID int64
DueDate xtime.Time
PayValue int64
State int8
Note string
EmailState int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
InTax int8
}
// Diff .
func (sp *SignPay) Diff(mOriSp map[int64]*SignPay, fields map[int8]struct{}) {
var (
ok bool
oriSp *SignPay
)
if oriSp, ok = mOriSp[sp.ID]; !ok {
fields[ChangeSignPayHistory] = struct{}{}
return
}
if sp.DueDate != oriSp.DueDate || sp.PayValue != oriSp.PayValue || sp.InTax != oriSp.InTax {
fields[ChangeSignPayHistory] = struct{}{}
}
sp.Mid = oriSp.Mid
sp.SignID = oriSp.SignID
sp.State = oriSp.State
sp.Note = oriSp.Note
sp.EmailState = oriSp.EmailState
sp.Ctime = oriSp.Ctime
}
// SignTask struct
type SignTask struct {
ID int64 `gorm:"column:id"`
Mid int64 `gorm:"column:mid"`
SignID int64 `gorm:"column:sign_id"`
TaskType int8 `gorm:"column:task_type"`
TaskCounter int `gorm:"column:task_counter"`
TaskCondition int `gorm:"column:task_condition"`
TaskData string `gorm:"column:task_data"`
State int8 `gorm:"column:state"`
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
Attribute int64 `gorm:"column:attribute"`
FinishNote string `gorm:"column:finish_note"`
}
// Diff .
func (st *SignTask) Diff(mOriSt map[int64]*SignTask, fields map[int8]struct{}) {
var (
ok bool
oriSt *SignTask
)
if oriSt, ok = mOriSt[st.ID]; !ok {
fields[ChangeSignTaskHistory] = struct{}{}
return
}
if st.TaskType != oriSt.TaskType || st.TaskCondition != oriSt.TaskCondition ||
st.AttrVal(AttrBitIsBusinessArchive) != oriSt.AttrVal(AttrBitIsBusinessArchive) {
fields[ChangeSignTaskHistory] = struct{}{}
}
st.Mid = oriSt.Mid
st.SignID = oriSt.SignID
st.TaskCounter = oriSt.TaskCounter
st.TaskData = oriSt.TaskData
st.State = oriSt.State
st.Ctime = oriSt.Ctime
}
// AttrVal get attribute value.
func (st *SignTask) AttrVal(bit uint) int64 {
return (st.Attribute >> bit) & int64(1)
}
// AttrSet set attribute value.
func (st *SignTask) AttrSet(v int64, bit uint) {
st.Attribute = st.Attribute&(^(1 << bit)) | (v << bit)
}
// SignTaskHistory .
type SignTaskHistory struct {
ID int64 `gorm:"column:id"`
Mid int64 `gorm:"column:mid"`
SignID int64 `gorm:"column:sign_id"`
TaskTemplateID int `gorm:"column:task_template_id"`
TaskType int8 `gorm:"column:task_type"`
TaskCounter int `gorm:"column:task_counter"`
TaskCondition int `gorm:"column:task_condition"`
TaskData string `gorm:"column:task_data"`
Attribute int64 `gorm:"column:attribute"`
State int `gorm:"column:state"`
GenerateDate xtime.Time `gorm:"column:generate_date"`
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// AttrVal get attribute value.
func (sth *SignTaskHistory) AttrVal(bit uint) int64 {
return (sth.Attribute >> bit) & int64(1)
}
// AttrSet set attribute value.
func (sth *SignTaskHistory) AttrSet(v int64, bit uint) {
sth.Attribute = sth.Attribute&(^(1 << bit)) | (v << bit)
}
//SignContract struct
type SignContract struct {
ID int64 `gorm:"column:id"`
Mid int64
SignID int64
Filename string
Filelink string
State int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// Diff .
func (sc *SignContract) Diff(mOriSc map[int64]*SignContract, fields map[int8]struct{}) {
var (
ok bool
oriSc *SignContract
)
if oriSc, ok = mOriSc[sc.ID]; !ok {
log.Error("OriSc(%d) no exsits", sc.ID)
fields[ChangeSignContractHistory] = struct{}{}
return
}
if !strings.EqualFold(sc.Filelink, oriSc.Filelink) {
log.Error("file(%s)----orc_file(%s) no exsits", sc.Filelink, oriSc.Filelink)
fields[ChangeSignContractHistory] = struct{}{}
}
if !strings.EqualFold(sc.Filename, oriSc.Filename) {
log.Error("filename(%s)----orc_filename(%s) no exsits", sc.Filename, oriSc.Filename)
fields[ChangeSignContractHistory] = struct{}{}
}
sc.Mid = oriSc.Mid
sc.SignID = oriSc.SignID
sc.State = oriSc.State
sc.Ctime = oriSc.Ctime
}
// SignTaskAbsence struct
type SignTaskAbsence struct {
ID int64 `gorm:"column:id"`
SignID int64
Mid int64
TaskHistoryID int64
AbsenceCount int
Reason string
State int8
AdminID int64
AdminName string
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// SignViolationHistory struct
type SignViolationHistory struct {
ID int64 `gorm:"column:id"`
SignID int64
Mid int64
AdminID int64
AdminName string
ViolationReason string
State int8
Ctime xtime.Time `gorm:"column:ctime"`
Mtime xtime.Time `gorm:"column:mtime"`
}
// GetTaskDuration this will return task duration, [startDate, endDate)
func GetTaskDuration(date time.Time, taskType int8) (startDate, endDate time.Time) {
var ndate = now.New(date)
now.WeekStartDay = time.Monday
switch taskType {
case TaskTypeDay:
var begin = ndate.BeginningOfDay()
return begin, begin.AddDate(0, 0, 1)
case TaskTypeWeek:
var begin = ndate.BeginningOfWeek()
return begin, begin.AddDate(0, 0, 7)
case TaskTypeMonth:
var begin = ndate.BeginningOfMonth()
return begin, begin.AddDate(0, 1, 0)
case TaskTypeQuarter:
var begin = ndate.BeginningOfQuarter()
return begin, begin.AddDate(0, 3, 0)
}
return
}

View File

@@ -0,0 +1,84 @@
# (fat 1, uat 1, prod 0)
CREATE TABLE `sign_up` (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '签约ID',
sex tinyint(4) NOT NULL DEFAULT '0' COMMENT '性别,性别 0:保密 1:男 2:女',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
begin_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约开始时间',
end_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约结束时间',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
country varchar(16) NOT NULL DEFAULT '' COMMENT '国家',
province varchar(16) NOT NULL DEFAULT '' COMMENT '',
city varchar(16) NOT NULL DEFAULT '' COMMENT '',
note varchar(255) 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_mid (mid),
KEY ix_begin_date (begin_date),
KEY ix_end_date (end_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='签约表';
-- 付款表
CREATE TABLE sign_pay (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT 'ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
due_date date NOT NULL DEFAULT '0000-00-00' COMMENT '签约结束时间',
pay_value BIGINT(20) NOT NULL DEFAULT '0' COMMENT '金额',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0未支付1已支付100删除',
note varchar(255) 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_signid (sign_id),
KEY ix_mid (mid),
KEY ix_date (due_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='付款表';
CREATE TABLE sign_task (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '任务ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
task_type tinyint(4) NOT NULL DEFAULT '0' COMMENT '任务类型',
task_counter int(11) NOT NULL DEFAULT '0' COMMENT '任务计数器',
task_condition int(11) NOT NULL DEFAULT '0' COMMENT '任务条件',
task_data varchar(1024) NOT NULL DEFAULT '' COMMENT '任务存储相关数据', -- 任务数据比如用来存已经投过的稿件id
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常1过期100删除',
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),
KEY ix_mid (mid),
KEY ix_signid (sign_id),
KEY ix_date (generate_date),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='任务表';
-- 合同表
CREATE TABLE sign_contract (
id int(11) unsigned NOT NULL AUTO_INCREMENT COMMENT '合同ID',
sign_id int(11) unsigned NOT NULL DEFAULT '0' COMMENT '签约ID',
mid int(11) unsigned NOT NULL DEFAULT '0' COMMENT 'up主id',
filename varchar(255) NOT NULL DEFAULT '' COMMENT '合同名',
filelink varchar(255) NOT NULL DEFAULT '' COMMENT '文件链接地址',
state tinyint(4) NOT NULL DEFAULT '0' COMMENT '状态0正常100删除',
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_mid (mid),
KEY ix_signid (sign_id),
KEY ix_mtime (mtime)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='合同表';
# (fat 1, uat 1, prod 1)
alter table sign_up add column admin_id int(11) not null default 0 comment '管理员id';
alter table sign_up add column admin_name varchar(32) not null default '' comment '管理员name';
# (fat 1, uat 1, prod 1) --2018.06.26
alter table sign_up add column email_state tinyint(4) not null default 0 comment '邮件发送情况0未发送1已发送过提醒邮件';
alter table sign_pay add column email_state tinyint(4) not null default 0 comment '邮件发送情况0未发送1已发送过提醒邮件';

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
)