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,74 @@
load(
"@io_bazel_rules_go//proto:def.bzl",
"go_proto_library",
)
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
proto_library(
name = "model_proto",
srcs = ["model.proto"],
tags = ["automanaged"],
deps = ["@gogo_special_proto//github.com/gogo/protobuf/gogoproto"],
)
go_proto_library(
name = "model_go_proto",
compilers = ["@io_bazel_rules_go//proto:gogofast_proto"],
importpath = "go-common/app/service/main/member/model",
proto = ":model_proto",
tags = ["automanaged"],
deps = [
"//library/time:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
],
)
go_library(
name = "go_default_library",
srcs = [
"base.go",
"log.go",
"member.go",
"moral.go",
"official.go",
"property_review.go",
"realname.go",
"rpc.go",
"search.go",
"user_flag.go",
],
embed = [":model_go_proto"],
importpath = "go-common/app/service/main/member/model",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//library/log:go_default_library",
"//library/time:go_default_library",
"//vendor/github.com/satori/go.uuid:go_default_library",
"@com_github_gogo_protobuf//gogoproto:go_default_library",
"@com_github_golang_protobuf//proto:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/service/main/member/model/block:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,72 @@
package model
import (
"fmt"
"math/rand"
)
// consts
const (
URLNoFace = "http://static.hdslb.com/images/member/noface.gif"
ActUpdateByAdmin = "updateByAdmin"
ActUpdatePersonInfo = "updatePersonInfo"
ActUpdateFace = "updateFace"
ActUpdateUname = "updateUname"
ActBlockUser = "blockUser"
CertNO = -1 // 未认证
DefaultRank = 5000 // default rank
DefaultTime = -28800 // default time
DefaultMoral = 7000 // default moral
MaxMoral = 10000 // max moral
CacheKeyBase = "bs_%d" // key of baseInfo
)
// RandFaceURL get face URL
func (b *BaseInfo) RandFaceURL() {
if b.Face == "" {
b.Face = URLNoFace
return
}
b.Face = fmt.Sprintf("http://i%d.hdslb.com%s", rand.Int63n(3), b.Face)
}
// SexStr get sex str
func (b *BaseInfo) SexStr() string {
switch b.Sex {
case 0:
return "保密"
case 1:
return "男"
case 2:
return "女"
default:
return "保密"
}
}
// NotifyInfo notify info.
type NotifyInfo struct {
Uname string `json:"uname"`
Mid int64 `json:"mid"`
Type string `json:"type"`
NewName string `json:"newName"`
Action string `json:"action"`
}
// Equal is.
func (of *OfficialInfo) Equal(cof *OfficialInfo) bool {
return of.Role == cof.Role && of.Title == cof.Title && of.Desc == cof.Desc
}
// BaseExp exp and base info.
type BaseExp struct {
*BaseInfo
*LevelInfo
}
// Member is the full information within member-service.
type Member struct {
*BaseInfo
*LevelInfo
*OfficialInfo
}

View File

@@ -0,0 +1,33 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"dao.go",
"http.go",
"model.go",
"notify.go",
"rpc.go",
],
importpath = "go-common/app/service/main/member/model/block",
tags = ["automanaged"],
)
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,53 @@
package block
import (
"time"
)
// DBUser .
type DBUser struct {
ID int64
MID int64
Status BlockStatus
CTime time.Time
MTime time.Time
}
// DBUserDetail .
type DBUserDetail struct {
ID int64
MID int64
BlockCount int64
CTime time.Time
MTime time.Time
}
// DBHistory .
type DBHistory struct {
ID int64
MID int64
AdminID int64
AdminName string
Source BlockSource
Area BlockArea
Reason string
Comment string
Action BlockAction
StartTime time.Time
Duration int64
Notify bool
CTime time.Time
MTime time.Time
}
// MCBlockInfo .
type MCBlockInfo struct {
BlockStatus BlockStatus `json:"bs"`
StartTime int64 `json:"st"`
EndTime int64 `json:"et"`
}
// MCUserDetail .
type MCUserDetail struct {
BlockCount int64 `json:"block_count"`
}

View File

@@ -0,0 +1,160 @@
package block
// ParamValidator .
type ParamValidator interface {
Validate() bool
}
// ParamInfo .
type ParamInfo struct {
MID int64 `form:"mid"`
}
// Validate .
func (p *ParamInfo) Validate() bool {
return p.MID > 0
}
// ParamBatchInfo .
type ParamBatchInfo struct {
MIDs []int64 `form:"mids,split"`
}
// Validate .
func (p *ParamBatchInfo) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
return true
}
// ParamBatchDetail .
type ParamBatchDetail struct {
MIDs []int64 `form:"mids,split"`
}
// Validate .
func (p *ParamBatchDetail) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
return true
}
// ParamBlock .
type ParamBlock struct {
MID int64 `form:"mid"`
Source BlockSource `form:"source"`
Area BlockArea `form:"area"`
Action BlockAction `form:"action"`
Duration int64 `form:"duration"` // unix time
StartTime int64 `form:"start_time"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBlock) Validate() bool {
if p.MID <= 0 {
return false
}
if !p.Source.Contain() {
return false
}
if p.Action != BlockActionLimit && p.Action != BlockActionForever {
return false
}
if p.StartTime <= 0 {
return false
}
if p.Action == BlockActionLimit {
if p.Duration <= 0 {
return false
}
}
return true
}
// ParamBatchBlock .
type ParamBatchBlock struct {
MIDs []int64 `form:"mids,split"`
Source BlockSource `form:"source"`
Area BlockArea `form:"area"`
Action BlockAction `form:"action"`
Duration int64 `form:"duration"` // unix time
StartTime int64 `form:"start_time"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBatchBlock) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
if !p.Source.Contain() {
return false
}
if p.Action != BlockActionLimit && p.Action != BlockActionForever {
return false
}
if p.StartTime <= 0 {
return false
}
if p.Action == BlockActionLimit {
if p.Duration <= 0 {
return false
}
}
return true
}
// ParamRemove .
type ParamRemove struct {
MID int64 `form:"mid"`
Source BlockSource `form:"source"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamRemove) Validate() bool {
if p.MID <= 0 {
return false
}
if !p.Source.Contain() {
return false
}
return true
}
// ParamBatchRemove .
type ParamBatchRemove struct {
MIDs []int64 `form:"mids,split"`
Source BlockSource `form:"source"`
OperatorID int `form:"op_id"`
Operator string `form:"operator"`
Reason string `form:"reason"`
Comment string `form:"comment"`
Notify bool `form:"notify"`
}
// Validate .
func (p *ParamBatchRemove) Validate() bool {
if len(p.MIDs) == 0 || len(p.MIDs) > 20 {
return false
}
if !p.Source.Contain() {
return false
}
return true
}

View File

@@ -0,0 +1,231 @@
package block
import (
"time"
)
// BlockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
type BlockStatus uint8
const (
// BlockStatusFalse 未封禁
BlockStatusFalse BlockStatus = iota
// BlockStatusForever 永久封禁
BlockStatusForever
// BlockStatusLimit 限时封禁
BlockStatusLimit
// BlockStatusCredit 小黑屋封禁
BlockStatusCredit
)
// BlockSource 封禁来源 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.管理后台 4.B+
type BlockSource uint8
// Contain .
func (b BlockSource) Contain() bool {
switch b {
case BlockSourceBlackHouse, BlockSourceSys, BlockSourceManager, BlockSourceBplus:
return true
default:
return false
}
}
const (
// BlockSourceBlackHouse 小黑屋封禁
BlockSourceBlackHouse BlockSource = iota + 1
// BlockSourceSys 系统封禁
BlockSourceSys
// BlockSourceManager 管理后台
BlockSourceManager
// BlockSourceBplus B+相关(动态、im、小视频)
BlockSourceBplus
)
// String .
func (b BlockSource) String() string {
switch b {
case BlockSourceBlackHouse:
return "小黑屋"
case BlockSourceSys:
return "系统封禁"
case BlockSourceManager:
return "管理后台"
case BlockSourceBplus:
return "Bplus"
default:
return ""
}
}
const (
// BlockLogBizID 用户审核日志
BlockLogBizID int = 122
)
// BlockArea 封禁业务
type BlockArea uint8
// Contain .
func (b BlockArea) Contain() bool {
switch b {
case BlockAreaNone, BlockAreaReply, BlockAreaDanmaku, BlockAreaMessage, BlockAreaTag, BlockAreaProfile, BlockAreaArchive, BlockAreaMusic, BlockAreaArticle, BlockAreaSpaceBanner, BlockAreaDynamic, BlockAreaAlbum, BlockAreaQuickVideo:
return true
default:
return false
}
}
func (b BlockArea) String() string {
switch b {
case BlockAreaReply:
return "评论"
case BlockAreaDanmaku:
return "弹幕"
case BlockAreaMessage:
return "私信"
case BlockAreaTag:
return "标签"
case BlockAreaProfile:
return "个人资料"
case BlockAreaArchive:
return "投稿"
case BlockAreaMusic:
return "音频"
case BlockAreaArticle:
return "专栏"
case BlockAreaSpaceBanner:
return "空间头图"
case BlockAreaDynamic:
return "动态"
case BlockAreaAlbum:
return "相册"
case BlockAreaQuickVideo:
return "小视频"
default:
return ""
}
}
// const .
const (
BlockAreaNone BlockArea = iota
BlockAreaReply
BlockAreaDanmaku
BlockAreaMessage
BlockAreaTag
BlockAreaProfile // 个人资料
BlockAreaArchive
BlockAreaMusic
BlockAreaArticle
BlockAreaSpaceBanner // 空间头图
BlockAreaDynamic // 动态
BlockAreaAlbum // 相册
BlockAreaQuickVideo //小视频
)
// BlockAction .
type BlockAction uint8
const (
// BlockActionLimit 限时封禁
BlockActionLimit BlockAction = iota + 1
// BlockActionForever 永久封禁
BlockActionForever
// BlockActionAdminRemove 后台解封
BlockActionAdminRemove
// BlockActionSelfRemove 自助解封
BlockActionSelfRemove
)
// String .
func (b BlockAction) String() string {
switch b {
case BlockActionLimit:
return "限时封禁"
case BlockActionForever:
return "永久封禁"
case BlockActionAdminRemove:
return "后台解封"
case BlockActionSelfRemove:
return "自动解封"
default:
return ""
}
}
// BlockInfo 封禁信息
type BlockInfo struct {
MID int64 `json:"mid"`
BlockStatus BlockStatus `json:"status"` // status 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
StartTime int64 `json:"start_time"` // 开始封禁时间 unix time 未封禁为 -1
EndTime int64 `json:"end_time"` // 结束封禁时间 unix time 永久封禁为 -1
}
// ParseDB .
func (b *BlockInfo) ParseDB(data *DBHistory) {
b.MID = data.MID
switch data.Action {
case BlockActionForever:
b.BlockStatus = BlockStatusForever
case BlockActionLimit:
b.BlockStatus = BlockStatusLimit
default:
b.BlockStatus = BlockStatusFalse
}
switch b.BlockStatus {
case BlockStatusForever:
b.StartTime = data.StartTime.Unix()
b.EndTime = -1
case BlockStatusLimit:
b.StartTime = data.StartTime.Unix()
b.EndTime = data.StartTime.Add(time.Duration(data.Duration) * time.Second).Unix()
default:
b.StartTime = -1
b.EndTime = -1
}
}
// ParseMC .
func (b *BlockInfo) ParseMC(data *MCBlockInfo, mid int64) {
b.MID = mid
b.BlockStatus = data.BlockStatus
b.StartTime = data.StartTime
b.EndTime = data.EndTime
}
// BlockHistory 封禁历史
type BlockHistory struct {
Area BlockArea `json:"type"`
Operator string `json:"operator"` // 操作人
Reason string `json:"reason"` // 封禁原因
Action BlockAction `json:"action"` // 操作类型
ActionTime int64 `json:"action_time"` // 操作时间
RemoveTime int64 `json:"remove_time"` // 解封时间
Comment string `json:"comment"`
}
// ParseDB .
func (b *BlockHistory) ParseDB(data *DBHistory) {
b.Area = data.Area
b.Operator = data.AdminName
b.Reason = data.Reason
b.Action = data.Action
b.ActionTime = data.StartTime.Unix()
b.RemoveTime = data.StartTime.Add(time.Second * time.Duration(data.Duration)).Unix()
b.Comment = data.Comment
}
// BlockMessage 通知消息体
type BlockMessage struct {
MID int64 `json:"mid"` // 用户mid
Area BlockArea `json:"area"` // BlockArea 封禁类型 1. 小黑屋(小黑屋和manager后台封禁) 2. 系统封禁(反作弊及监控系统上报) 3.解封 (所有后台,用户前台自助的解封)
Status BlockStatus `json:"status"` // blockStatus 封禁状态 0. 未封禁 1. 永久封禁 2. 限时封禁
}
// BlockUserDetail .
type BlockUserDetail struct {
MID int64 `json:"mid"` // 用户mid
BlockCount int64 `json:"block_count"` // 封禁次数
}

View File

@@ -0,0 +1,8 @@
package block
// AccountNotify .
type AccountNotify struct {
UID int64 `json:"mid"`
Type string `json:"type"`
Action string `json:"action"`
}

View File

@@ -0,0 +1,43 @@
package block
// RPCArgInfo .
type RPCArgInfo struct {
MID int64
}
// RPCArgBatchInfo .
type RPCArgBatchInfo struct {
MIDs []int64
}
// RPCResInfo .
type RPCResInfo struct {
MID int64
BlockStatus BlockStatus
StartTime int64
EndTime int64
}
// Parse .
func (r *RPCResInfo) Parse(b *BlockInfo) {
r.MID = b.MID
r.BlockStatus = b.BlockStatus
r.StartTime = b.StartTime
r.EndTime = b.EndTime
}
// RPCArgBlock .
// type RPCArgBlock struct {
// }
// RPCArgBatchBlock .
// type RPCArgBatchBlock struct {
// }
// RPCArgRemove .
// type RPCArgRemove struct {
// }
// RPCArgBatchRemove .RPCArgBatchRemove
// type RPCArgBatchRemove struct {
// }

View File

@@ -0,0 +1,19 @@
package model
import (
"github.com/satori/go.uuid"
)
// UserLog log info.
type UserLog struct {
Mid int64 `json:"mid"`
IP string `json:"ip"`
TS int64 `json:"ts"`
LogID string `json:"log_id"`
Content map[string]string `json:"content"`
}
// UUID4 is generate uuid
func UUID4() string {
return uuid.NewV4().String()
}

View File

@@ -0,0 +1,52 @@
package model
const (
// ExpMulti exp multi
ExpMulti = 100
// level floor conf.
level1 = 1
level2 = 200
level3 = 1500
level4 = 4500
level5 = 10800
level6 = 28800
levelMax = -1
)
// BuildLevel build level by LevelInfo
func (lv *LevelInfo) BuildLevel(exp int64, sexp bool) {
exp = exp / ExpMulti
switch {
case exp < level1:
lv.Cur = 0
lv.Min = 0
lv.NextExp = level1
case exp < level2:
lv.Cur = 1
lv.Min = level1
lv.NextExp = level2
case exp < level3:
lv.Cur = 2
lv.Min = level2
lv.NextExp = level3
case exp < level4:
lv.Cur = 3
lv.Min = level3
lv.NextExp = level4
case exp < level5:
lv.Cur = 4
lv.Min = level4
lv.NextExp = level5
case exp < level6:
lv.Cur = 5
lv.Min = level5
lv.NextExp = level6
default:
lv.Cur = 6
lv.Min = level6
lv.NextExp = levelMax
}
if sexp {
lv.NowExp = int32(exp)
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,37 @@
syntax = "proto3";
package account.service.member;
import "github.com/gogo/protobuf/gogoproto/gogo.proto";
option go_package = "model";
message BaseInfo {
int64 mid = 1 [(gogoproto.jsontag) = "mid"];
string name = 2 [(gogoproto.jsontag) = "name"];
int64 sex = 3 [(gogoproto.jsontag) = "sex"];
string face = 4 [(gogoproto.jsontag) = "face"];
string sign = 5 [(gogoproto.jsontag) = "sign"];
int64 rank = 6 [(gogoproto.jsontag) = "rank"];
int64 birthday = 7 [(gogoproto.jsontag) = "birthday", (gogoproto.casttype) = "go-common/library/time.Time"];
}
message LevelInfo {
int32 cur = 1 [(gogoproto.jsontag) = "current_level"];
int32 min = 2 [(gogoproto.jsontag) = "current_min"];
int32 now_exp = 3 [(gogoproto.jsontag) = "current_exp"];
int32 next_exp = 4 [(gogoproto.jsontag) = "next_exp"];
}
message OfficialInfo {
int32 role = 1 [(gogoproto.jsontag) = "role",(gogoproto.casttype) = "int8"];
string title = 2 [(gogoproto.jsontag) = "title"];
string desc = 3 [(gogoproto.jsontag) = "desc"];
}
message Moral {
int64 mid = 1 [(gogoproto.jsontag) = "mid"];
int64 moral = 2 [(gogoproto.jsontag) = "moral"];
int64 added = 3 [(gogoproto.jsontag) = "added"];
int64 deducted = 4 [(gogoproto.jsontag) = "deducted"];
int64 last_recover_date = 5 [(gogoproto.jsontag) = "last_recover_date", (gogoproto.casttype) = "go-common/library/time.Time"];
}

View File

@@ -0,0 +1,123 @@
package model
const (
// DMReasonType is.
DMReasonType = 1
// ReplyReasonType is.
ReplyReasonType = 2
// TagReasonType is.
TagReasonType = 3
// ElecReasonType is.
ElecReasonType = 4
// AccountReasonType is.
AccountReasonType = 5
// SysReasonType is.
SysReasonType = 6
// RevocableMoralStatus is.
RevocableMoralStatus = 0
// RevokedMoralStatus is.
RevokedMoralStatus = 1
// IrrevocableMoralStatus is.
IrrevocableMoralStatus = 2
// ReportRewardType is.
ReportRewardType = 1
// PunishmentType is.
PunishmentType = 2
// CancelRewardType is.
CancelRewardType = 3
// CancelPunishType is.
CancelPunishType = 4
// ManualRecoveryType is.
ManualRecoveryType = 5
// ManualChangeType is.
ManualChangeType = 6
)
//ArgUpdateMorals argUpdateMorals.
type ArgUpdateMorals struct {
Mids []int64 `form:"mids,split" validate:"required"`
Delta int64 `form:"delta" validate:"required"`
Origin int64 `form:"origin" validate:"required"`
Reason string `form:"reason" validate:"required"`
ReasonType int64 `form:"reason_type"`
Operator string `form:"operator" validate:"required"`
Remark string `form:"remark" validate:"required"`
Status int64 `form:"status"`
IsNotify bool `form:"is_notify"`
IP string `form:"ip"`
}
//ArgUpdateMoral argUpdateMoral.
type ArgUpdateMoral struct {
Mid int64 `form:"mid" validate:"required"`
Delta int64 `form:"delta" validate:"required"`
Origin int64 `form:"origin" validate:"required"`
Reason string `form:"reason" validate:"required"`
ReasonType int64 `form:"reason_type"`
Operator string `form:"operator" validate:"required"`
Remark string `form:"remark" validate:"required"`
Status int64 `form:"status"`
IsNotify bool `form:"is_notify"`
IP string `form:"ip"`
}
//ArgUndo argUndo.
type ArgUndo struct {
LogID string `form:"log_id" validate:"required"`
Remark string `form:"remark" validate:"required"`
Operator string `form:"operator" validate:"required"`
}
//ReasonType reasonType
type ReasonType struct {
Name string
NotifyType string
}
//OriginType originType
type OriginType struct {
Name string
NeedReason bool
}
//Notice notice
type Notice struct {
Title string
Message string
NoticeType string
}
var (
// ReasonTypes ...
ReasonTypes = map[int64]*ReasonType{
DMReasonType: {"弹幕", "2_1_4"},
ReplyReasonType: {"评论", "2_1_3"},
TagReasonType: {"TAG", ""},
ElecReasonType: {"电波", ""},
AccountReasonType: {"账号", ""},
SysReasonType: {"管理系统", ""},
}
// OriginTypes ...
OriginTypes = map[int64]*OriginType{
ReportRewardType: {"举报奖励", true},
PunishmentType: {"违规惩罚", true},
CancelRewardType: {"撤销奖励", true},
CancelPunishType: {"撤销惩罚", true},
ManualRecoveryType: {"自动恢复", true},
ManualChangeType: {"手动修改", false},
}
// Less6000Notice is.
Less6000Notice = &Notice{Title: "你的节操值已低于60", Message: "抱歉你的节操值已低于60社交类功能将不能正常使用更多加减明细请查看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}", NoticeType: "2_1_5"}
// Less3000Notice is.
Less3000Notice = &Notice{Title: "你的节操值已低于30", Message: "抱歉你的节操值已低于30社交类功能将不能正常使用更多加减明细请查看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}", NoticeType: "2_1_6"}
// Greater6000Notice is .
Greater6000Notice = &Notice{Title: "你的节操值已恢复至60以上", Message: "恭喜你的节操值已恢复至60以上所有功能将回复正常使用更多加减明细请查看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}", NoticeType: "2_1_7"}
// PunishmentNotice is.
PunishmentNotice = &Notice{Title: "你被举报处理扣除了%s节操值", Message: "由于发布了违规内容,你被举报处理扣除了%s节操值具体原因请看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}"}
// SysPunishmentNotice is.
SysPunishmentNotice = &Notice{Title: "你被举报处理扣除了%s节操值", Message: "由于发布了违规内容,你被系统处理扣除了%s节操值具体原因请看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}"}
// RewardNotice is.
RewardNotice = &Notice{Title: "你举报的%s已被处理", Message: "您举报的%s已被管理员处理获得了%s节操值奖励具体详情请看 #{节操记录}{\"https://account.bilibili.com/site/record?type=moral\"}"}
)

View File

@@ -0,0 +1,93 @@
package model
import (
"encoding/json"
xtime "go-common/library/time"
)
// official state const.
const (
OfficialStateWait = iota
OfficialStatePass
OfficialStateNoPass
OfficialStateReWait
)
// official role const.
const (
OfficialRoleUnauth = iota
OfficialRoleUp
OfficialRoleIdentify
OfficialRoleBusiness
OfficialRoleGov
OfficialRoleMedia
OfficialRoleOther
)
// OfficialDoc official doc.
type OfficialDoc struct {
Mid int64 `json:"mid"`
Name string `json:"name"`
State int8 `json:"state"`
Role int8 `json:"role"`
Title string `json:"title"`
Desc string `json:"desc"`
Extra string `json:"-"`
RejectReason string `json:"reject_reason"` // 被拒绝理由
SubmitSource string `json:"submit_source"` // 提交来源
SubmitTime xtime.Time `json:"submit_time"` // 最后提交时间
OfficialExtra
}
// OfficialExtra official extra.
type OfficialExtra struct {
Realname int8 `json:"realname"`
Operator string `json:"operator"` // 经营人
Telephone string `json:"telephone"` // 电话号码
Email string `json:"email"` // 邮箱
Address string `json:"address"` // 地址
Company string `json:"company"` // 公司
CreditCode string `json:"credit_code"` // 社会信用代码
Organization string `json:"organization"` // 政府或组织名称
OrganizationType string `json:"organization_type"` // 组织或机构类型
BusinessLicense string `json:"business_license"` // 企业营业执照
BusinessScale string `json:"business_scale"` // 企业规模
BusinessLevel string `json:"business_level"` // 企业登记
BusinessAuth string `json:"business_auth"` // 企业授权函
Supplement string `json:"supplement"` // 其他补充材料
Professional string `json:"professional"` // 专业资质
Identification string `json:"identification"` // 身份证明
OfficialSite string `json:"official_site"` // 官网地址
RegisteredCapital string `json:"registered_capital"` // 注册资金
}
// ParseExtra parse extra.
func (oc *OfficialDoc) ParseExtra() {
oe := OfficialExtra{}
if len(oc.Extra) > 0 {
json.Unmarshal([]byte(oc.Extra), &oe)
}
oc.OfficialExtra = oe
}
// String is
func (oe OfficialExtra) String() string {
bs, _ := json.Marshal(oe)
if len(bs) == 0 {
bs = []byte("{}")
}
return string(bs)
}
// Validate is.
func (oc OfficialDoc) Validate() bool {
if oc.Mid <= 0 ||
oc.Name == "" ||
oc.Role <= 0 ||
oc.Title == "" {
return false
}
return true
}

View File

@@ -0,0 +1,7 @@
#! /bin/sh
# proto.sh https://github.com/google/protobuf/releases 下载release包解压后将include中的文件夹拖到/usr/local/include即可
gopath=$GOPATH/src
gogopath=$GOPATH/src/go-common/vendor/github.com/gogo/protobuf
protoc --gofast_out=. --proto_path=/usr/local/include:$gopath:$gogopath:. *.proto

View File

@@ -0,0 +1,29 @@
package model
// review state const.
const (
ReviewStateWait = iota
ReviewStatePass
ReviewStateNoPass
ReviewStateArchived
ReviewStateQueuing = 10
)
// review property const.
const (
ReviewProperty = iota
ReviewPropertyFace
ReviewPropertySign
ReviewPropertyName
)
// UserPropertyReview is.
type UserPropertyReview struct {
Mid int64
Old string
New string
State int8
Property int8
IsMonitor bool
Extra string
}

View File

@@ -0,0 +1,208 @@
package model
import (
"time"
)
// RealnameStatus is.
type RealnameStatus int8
const (
// RealnameStatusFalse is.
RealnameStatusFalse RealnameStatus = 0
// RealnameStatusTrue is.
RealnameStatusTrue RealnameStatus = 1
)
// RealnameApplyStatus is.
type RealnameApplyStatus int8
const (
// RealnameApplyStatusPending is.
RealnameApplyStatusPending RealnameApplyStatus = iota
// RealnameApplyStatusPass is.
RealnameApplyStatusPass
// RealnameApplyStatusBack is.
RealnameApplyStatusBack
// RealnameApplyStatusNone is.
RealnameApplyStatusNone
)
// IsPass return is apply passed
func (r RealnameApplyStatus) IsPass() bool {
switch r {
case RealnameApplyStatusPass:
return true
default:
return false
}
}
// RealnameChannel is
type RealnameChannel int8
// RealnameChannel enum
const (
RealnameChannelMain RealnameChannel = iota
RealnameChannelAlipay
)
// RealnameApplyStatusInfo is.
type RealnameApplyStatusInfo struct {
Status RealnameApplyStatus `json:"status"`
Remark string `json:"remark"`
Realname string `json:"realname"`
Card string `json:"card"`
}
// RealnameCacheInfo model in cache
type RealnameCacheInfo struct {
*RealnameInfo
RealCard string `json:"real_card"`
}
// RealnameBrief is.
type RealnameBrief struct {
Realname string `json:"realname"`
Card string `json:"card"`
CardType int `json:"card_type"`
Status RealnameStatus `json:"status"`
}
// RealnameInfo is.
type RealnameInfo struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
Channel RealnameChannel `json:"channel"`
Realname string `json:"realname"`
Country int `json:"country"`
CardType int `json:"card_type"`
Card string `json:"card"`
CardMD5 string `json:"card_md5"`
Status RealnameApplyStatus `json:"status"`
Reason string `json:"reason"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
// RealnameDetail is.
type RealnameDetail struct {
*RealnameBrief
Gender string `json:"gender"`
HandIMG string `json:"hand_img"`
}
// RealnameApply is.
type RealnameApply struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
Realname string `json:"realname"`
Country int16 `json:"country"`
CardType int8 `json:"card_type"`
CardNum string `json:"card_num"`
CardMD5 string `json:"card_md5"`
HandIMG int `json:"hand_img"`
FrontIMG int `json:"front_img"`
BackIMG int `json:"back_img"`
Status RealnameApplyStatus `json:"status"`
Operator string `json:"operator"`
OperatorID int64 `json:"operator_id"`
OperatorTime time.Time `json:"operator_time"`
Remark string `json:"remark"`
RemarkStatus int8 `json:"remark_status"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
// IsPass is.
func (r *RealnameApply) IsPass() bool {
switch r.Status {
case RealnameApplyStatusPass:
return true
default:
return false
}
}
// RealnameApplyImage is.
type RealnameApplyImage struct {
ID int64
IMGData string
CTime time.Time
MTime time.Time
}
// RealnameCapture is.
type RealnameCapture struct {
Code int
CodeCTime time.Time
Times []time.Time
}
// RealnameAlipayApply is
type RealnameAlipayApply struct {
ID int64 `json:"id"`
MID int64 `json:"mid"`
Realname string `json:"realname"`
Card string `json:"card"`
IMG string `json:"img"`
Status RealnameApplyStatus `json:"status"`
Reason string `json:"reason"`
Bizno string `json:"bizno"`
CTime time.Time `json:"ctime"`
MTime time.Time `json:"mtime"`
}
// IsPass is.
func (r *RealnameAlipayApply) IsPass() bool {
switch r.Status {
case RealnameApplyStatusPass:
return true
default:
return false
}
}
// RealnameAlipayInfo is
type RealnameAlipayInfo struct {
Bizno string
}
const (
// RealnameCountryChina is.
RealnameCountryChina = 0
// RealnameCardTypeIdentity is.
RealnameCardTypeIdentity = 0
)
// RealnameAdultType is.
type RealnameAdultType uint8
const (
// RealnameAdultTypeFalse is.
RealnameAdultTypeFalse RealnameAdultType = iota // 未成年
// RealnameAdultTypeTrue is.
RealnameAdultTypeTrue // 已成年
//RealnameAdultTypeUnknown is.
RealnameAdultTypeUnknown // 未知(未绑定身份证)
)
// http param
// ParamRealnameCheck is.
type ParamRealnameCheck struct {
MID int64 `form:"mid" validate:"required"`
CardType int8 `form:"card_type" default:"-1"`
CardCode string `form:"card_code" validate:"required"`
}
// ParamRealnameSyncImage is.
type ParamRealnameSyncImage struct {
Data string `form:"data" validate:"required"`
}
// ParamRealnameTelCaptureCheck is.
type ParamRealnameTelCaptureCheck struct {
MID int64 `form:"mid" validate:"required"`
Capture int `form:"capture" validate:"required"`
}

View File

@@ -0,0 +1,196 @@
package model
import (
"encoding/json"
"go-common/library/log"
"go-common/library/time"
)
// ArgMid arg mid.
type ArgMid struct {
Mid int64
RealIP string
}
// ArgMid2 arg mid2.
type ArgMid2 struct {
Mid int64 `form:"mid" validate:"min=1,required"` // 用户mid
RealIP string
}
// ArgMemberMid is.
type ArgMemberMid struct {
Mid int64 `json:"mid"`
RemoteIP string `json:"remoteIP"`
}
// ArgMemberMids are.
type ArgMemberMids struct {
Mids []int64 `json:"mids"`
RemoteIP string `json:"remoteIP"`
}
// ArgOfficialDoc arg official doc
type ArgOfficialDoc struct {
Mid int64 `json:"mid"`
Name string `json:"name"`
Role int8 `json:"role"`
Title string `json:"title"`
Desc string `json:"desc"`
Realname int8 `json:"realname"`
Operator string `json:"operator"`
Telephone string `json:"telephone"`
Email string `json:"email"`
Address string `json:"address"`
Company string `json:"company"`
CreditCode string `json:"credit_code"` // 社会信用代码
Organization string `json:"organization"` // 政府或组织名称
OrganizationType string `json:"organization_type"` // 组织或机构类型
BusinessLicense string `json:"business_license"` // 企业营业执照
BusinessScale string `json:"business_scale"` // 企业规模
BusinessLevel string `json:"business_level"` // 企业登记
BusinessAuth string `json:"business_auth"` // 企业授权函
Supplement string `json:"supplement"` // 其他补充材料
Professional string `json:"professional"` // 专业资质
Identification string `json:"identification"` // 身份证明
OfficialSite string `json:"official_site"` // 官网地址
RegisteredCapital string `json:"registered_capital"` // 注册资金
SubmitSource string `json:"submit_source"` // 提交来源
}
// Log define user login log.
type Log struct {
Mid int64 `json:"mid,omitempty"`
IP uint32 `json:"loginip"`
Location string `json:"location"`
LocationID int64 `json:"location_id,omitempty"`
Time time.Time `json:"timestamp,omitempty"`
Type int8 `json:"type,omitempty"`
}
// Msg is user login status msg.
type Msg struct {
Notify bool `json:"notify"`
Log *Log `json:"log"`
}
// ArgUpdateSex is.
type ArgUpdateSex struct {
Mid int64 `json:"mid"`
Sex int64 `json:"sex"`
RemoteIP string `json:"remoteIP"`
}
// ArgUpdateFace is.
type ArgUpdateFace struct {
Mid int64 `json:"mid"`
Face string `json:"face"`
RemoteIP string `json:"remoteIP"`
}
// ArgUpdateRank is.
type ArgUpdateRank struct {
Mid int64 `json:"mid"`
Rank int64 `json:"rank"`
RemoteIP string `json:"remoteIP"`
}
// ArgUpdateBirthday is.
type ArgUpdateBirthday struct {
Mid int64 `json:"mid"`
Birthday time.Time `json:"birthday"`
RemoteIP string `json:"remoteIP"`
}
// ArgUpdateUname arg for update uname.
type ArgUpdateUname struct {
Mid int64 `json:"mid"`
Name string `json:"name"`
RemoteIP string `json:"remoteIP"`
}
// ArgUpdateSign arg for udpate sign.
type ArgUpdateSign struct {
Mid int64 `json:"mid"`
Sign string `json:"sign"`
RemoteIP string `json:"remoteIP"`
}
// ArgAddExp addexp arg.
type ArgAddExp struct {
Mid int64 `json:"mid,omitempty" form:"mid" validate:"min=1,required"` // 用户mid
Count float64 `json:"count,omitempty" form:"count" validate:"required"` // 修改数量
Reason string `json:"reason,omitempty" form:"reason" validate:"required"` // 修改原因
Operate string `json:"operate,omitempty" form:"operate" validate:"required"` // 操作类型
IP string `json:"ip" form:"ip"`
}
// ExpStat user exp stat.
type ExpStat struct {
Login bool `json:"login"`
Watch bool `json:"watch_av"`
Coin int64 `json:"coins_av"`
Share bool `json:"share_av"`
}
// ArgRealnameApply realname apply
type ArgRealnameApply struct {
MID int64
CaptureCode int
Realname string
CardType int8
CardCode string
Country int16
HandIMGToken string
FrontIMGToken string
BackIMGToken string
}
// ArgRealnameAlipayConfirm is
type ArgRealnameAlipayConfirm struct {
MID int64
Pass bool
Reason string
}
// ArgRealnameAlipayApply is
type ArgRealnameAlipayApply struct {
MID int64
CaptureCode int
Realname string
CardCode string
IMGToken string
Bizno string
}
// ArgAddUserMonitor is
type ArgAddUserMonitor struct {
Mid int64
Operator string
Remark string
}
// ArgAddPropertyReview is.
type ArgAddPropertyReview struct {
Mid int64 `form:"mid" validate:"min=1,required"` // 用户mid
New string `form:"new"` // 新的值
State int8 `form:"state"` // 0 待审核1 通过2 驳回10 自动审核中
Property int8 `form:"property"` // 0 无意义1 头像2 签名3 昵称
Extra map[string]interface{} // 审核扩展字段 extra
}
// ExtraStr is.
func (arg *ArgAddPropertyReview) ExtraStr() string {
if arg.Extra == nil {
return "{}"
}
bs, err := json.Marshal(arg.Extra)
if err != nil {
log.Error("Failed to marshal extra: %+v, error: %+v", arg.Extra, err)
return "{}"
}
return string(bs)
}

View File

@@ -0,0 +1,31 @@
package model
// SearchResult is
type SearchResult struct {
Code int `json:"code"`
Data struct {
Debug string `json:"debug"`
Order string `json:"order"`
Page struct {
Num int64 `json:"num"`
Size int64 `json:"size"`
Total int64 `json:"total"`
} `json:"page"`
Result []struct {
Action string `json:"action"`
Build int64 `json:"build"`
Business int64 `json:"business"`
Buvid string `json:"buvid"`
Ctime string `json:"ctime"`
ExtraData string `json:"extra_data"`
IP string `json:"ip"`
Mid int64 `json:"mid"`
Oid int64 `json:"oid"`
Platform string `json:"platform"`
Type int64 `json:"type"`
} `json:"result"`
Sort string `json:"sort"`
} `json:"data"`
Message string `json:"message"`
TTL int64 `json:"ttl"`
}

View File

@@ -0,0 +1,16 @@
package model
const (
// NickUpdated 首次改昵称
NickUpdated = uint(1)
)
// HasAttr get attr.
func HasAttr(flag uint, bit uint) bool {
return flag&bit == bit
}
// SetAttr set attr.
func SetAttr(flag uint, bit uint) uint {
return flag | bit
}