Create & Init Project...
This commit is contained in:
41
app/admin/main/usersuit/model/BUILD
Normal file
41
app/admin/main/usersuit/model/BUILD
Normal file
@ -0,0 +1,41 @@
|
||||
package(default_visibility = ["//visibility:public"])
|
||||
|
||||
load(
|
||||
"@io_bazel_rules_go//go:def.bzl",
|
||||
"go_library",
|
||||
)
|
||||
|
||||
go_library(
|
||||
name = "go_default_library",
|
||||
srcs = [
|
||||
"invite.go",
|
||||
"log.go",
|
||||
"manager.go",
|
||||
"medal.go",
|
||||
"msg.go",
|
||||
"notify.go",
|
||||
"param.go",
|
||||
"pendant.go",
|
||||
],
|
||||
importpath = "go-common/app/admin/main/usersuit/model",
|
||||
tags = ["automanaged"],
|
||||
visibility = ["//visibility:public"],
|
||||
deps = [
|
||||
"//app/service/main/account/model: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"],
|
||||
)
|
123
app/admin/main/usersuit/model/invite.go
Normal file
123
app/admin/main/usersuit/model/invite.go
Normal file
@ -0,0 +1,123 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"net"
|
||||
"strconv"
|
||||
|
||||
accmdl "go-common/app/service/main/account/model"
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
const (
|
||||
// StatusOK status ok
|
||||
StatusOK = 0
|
||||
// StatusUsed status used
|
||||
StatusUsed = 1
|
||||
// StatusExpires status expires
|
||||
StatusExpires = 2
|
||||
)
|
||||
|
||||
// Invite invite.
|
||||
type Invite struct {
|
||||
Status int64 `json:"status"`
|
||||
Mid int64 `json:"mid"`
|
||||
Code string `json:"invite_code"`
|
||||
IP uint32 `json:"-"` // legacy IP field
|
||||
IPng []byte `json:"-"`
|
||||
Ctime xtime.Time `json:"buy_time"`
|
||||
Expires int64 `json:"expires"`
|
||||
Imid int64 `json:"invited_mid,omitempty"`
|
||||
UsedAt int64 `json:"used_at,omitempty"`
|
||||
}
|
||||
|
||||
// BuyIPString is
|
||||
func (inv *Invite) BuyIPString() string {
|
||||
if inv.IP != 0 {
|
||||
return inetNtoA(inv.IP)
|
||||
}
|
||||
return net.IP(inv.IPng).String()
|
||||
}
|
||||
|
||||
func inetNtoA(sum uint32) string {
|
||||
ip := make(net.IP, net.IPv4len)
|
||||
ip[0] = byte((sum >> 24) & 0xFF)
|
||||
ip[1] = byte((sum >> 16) & 0xFF)
|
||||
ip[2] = byte((sum >> 8) & 0xFF)
|
||||
ip[3] = byte(sum & 0xFF)
|
||||
return ip.String()
|
||||
}
|
||||
|
||||
// FillStatus fill status.
|
||||
func (inv *Invite) FillStatus(now int64) {
|
||||
if inv.Used() {
|
||||
inv.Status = StatusUsed
|
||||
return
|
||||
}
|
||||
if inv.Expired(now) {
|
||||
inv.Status = StatusExpires
|
||||
return
|
||||
}
|
||||
inv.Status = StatusOK
|
||||
}
|
||||
|
||||
// Used check if used.
|
||||
func (inv *Invite) Used() bool {
|
||||
return inv.UsedAt > 0 && inv.Imid > 0
|
||||
}
|
||||
|
||||
// Expired check if expired.
|
||||
func (inv *Invite) Expired(now int64) bool {
|
||||
return now > inv.Expires
|
||||
}
|
||||
|
||||
// RichInvite rich invite with invitee info.
|
||||
type RichInvite struct {
|
||||
Status int64 `json:"status"`
|
||||
Mid int64 `json:"mid"`
|
||||
Code string `json:"invite_code"`
|
||||
BuyIP string `json:"buy_ip"`
|
||||
Ctime xtime.Time `json:"buy_time"`
|
||||
Expires int64 `json:"expires"`
|
||||
Invitee *Invitee `json:"invitee,omitempty"`
|
||||
UsedAt int64 `json:"used_at,omitempty"`
|
||||
}
|
||||
|
||||
// NewRichInvite new a rich invite.
|
||||
func NewRichInvite(inv *Invite, info *accmdl.Info) *RichInvite {
|
||||
if inv == nil {
|
||||
return nil
|
||||
}
|
||||
var invt *Invitee
|
||||
if inv.Used() {
|
||||
if info != nil {
|
||||
invt = &Invitee{
|
||||
Mid: inv.Imid,
|
||||
Uname: info.Name,
|
||||
Face: info.Face,
|
||||
}
|
||||
} else {
|
||||
invt = &Invitee{
|
||||
Mid: inv.Imid,
|
||||
Uname: "用户" + strconv.FormatInt(inv.Imid, 10),
|
||||
Face: "http://static.hdslb.com/images/member/noface.gif",
|
||||
}
|
||||
}
|
||||
}
|
||||
return &RichInvite{
|
||||
Status: inv.Status,
|
||||
Mid: inv.Mid,
|
||||
Code: inv.Code,
|
||||
Ctime: inv.Ctime,
|
||||
Expires: inv.Expires,
|
||||
Invitee: invt,
|
||||
UsedAt: inv.UsedAt,
|
||||
BuyIP: inv.BuyIPString(),
|
||||
}
|
||||
}
|
||||
|
||||
// Invitee invited.
|
||||
type Invitee struct {
|
||||
Mid int64 `json:"mid"`
|
||||
Uname string `json:"uname"`
|
||||
Face string `json:"face"`
|
||||
}
|
14
app/admin/main/usersuit/model/log.go
Normal file
14
app/admin/main/usersuit/model/log.go
Normal file
@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
// OperationLog operation log .
|
||||
type OperationLog struct {
|
||||
ID int64 `json:"id"`
|
||||
OID int64 `json:"oid"`
|
||||
Action string `json:"action"`
|
||||
CTime xtime.Time `json:"ctime"`
|
||||
MTime xtime.Time `json:"mtime"`
|
||||
}
|
7
app/admin/main/usersuit/model/manager.go
Normal file
7
app/admin/main/usersuit/model/manager.go
Normal file
@ -0,0 +1,7 @@
|
||||
package model
|
||||
|
||||
// MangerInfo struct
|
||||
type MangerInfo struct {
|
||||
OID int64 `json:"id"`
|
||||
Uname string `json:"username"`
|
||||
}
|
90
app/admin/main/usersuit/model/medal.go
Normal file
90
app/admin/main/usersuit/model/medal.go
Normal file
@ -0,0 +1,90 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
xtime "go-common/library/time"
|
||||
)
|
||||
|
||||
const (
|
||||
// OwnerActivated medal_owner is_activated=1 .
|
||||
OwnerActivated = int8(1)
|
||||
// OwnerNotActivated medal_owner is_activated=0 .
|
||||
OwnerNotActivated = int8(0)
|
||||
// MaxCount medal batch add max.
|
||||
MaxCount = 2000
|
||||
// MedalSourceTypeAdmin medal source type admin.
|
||||
MedalSourceTypeAdmin = int8(1)
|
||||
)
|
||||
|
||||
// Medal medal info .
|
||||
type Medal struct {
|
||||
ID int64 `form:"id" json:"id"`
|
||||
GID int64 `form:"gid" validate:"required" json:"gid"`
|
||||
Name string `form:"name" validate:"required" json:"name"`
|
||||
Description string `form:"description" validate:"required" json:"description"`
|
||||
Image string `form:"image" validate:"required" json:"image"`
|
||||
ImageSmall string `form:"image_small" validate:"required" json:"image_small"`
|
||||
Condition string `form:"condition" validate:"required" json:"condition"`
|
||||
Level int8 `form:"level" validate:"min=1,max=3" json:"level"`
|
||||
LevelRank string `form:"level_rank" validate:"required" json:"level_rank"`
|
||||
Sort int `form:"sort" validate:"required" json:"sort"`
|
||||
IsOnline int `form:"is_online" json:"is_online"`
|
||||
CTime xtime.Time `json:"ctime,omitempty"`
|
||||
MTime xtime.Time `json:"mtime,omitempty"`
|
||||
}
|
||||
|
||||
// MedalGroup nameplate group .
|
||||
type MedalGroup struct {
|
||||
ID int64 `form:"id" json:"id"`
|
||||
PID int64 `form:"pid" json:"pid"`
|
||||
Rank int8 `form:"rank" validate:"required" json:"rank"`
|
||||
IsOnline int8 `form:"is_online" json:"is_online"`
|
||||
Name string `form:"name" validate:"required" json:"name"`
|
||||
PName string `form:"pname" json:"pname,omitempty"`
|
||||
CTime xtime.Time `json:"ctime,omitempty"`
|
||||
MTime xtime.Time `json:"mtime,omitempty"`
|
||||
}
|
||||
|
||||
// MedalOwner nameplate owner .
|
||||
type MedalOwner struct {
|
||||
ID int64 `json:"id"`
|
||||
MID int64 `json:"mid"`
|
||||
NID int64 `json:"nid"`
|
||||
IsActivated int8 `json:"is_activated"`
|
||||
IsDel int8 `json:"is_del"`
|
||||
CTime xtime.Time `json:"ctime"`
|
||||
MTime xtime.Time `json:"mtime"`
|
||||
}
|
||||
|
||||
// MedalInfo struct.
|
||||
type MedalInfo struct {
|
||||
*Medal
|
||||
GroupName string `json:"group_name"`
|
||||
ParentGroupName string `json:"parent_group_name"`
|
||||
}
|
||||
|
||||
// MedalMemberMID struct.
|
||||
type MedalMemberMID struct {
|
||||
ID int64 `json:"id"`
|
||||
NID int64 `json:"nid"`
|
||||
MedalName string `json:"medal_name"`
|
||||
IsActivated int8 `json:"is_activated"`
|
||||
IsDel int8 `json:"is_del"`
|
||||
}
|
||||
|
||||
// MedalMemberAddList struct.
|
||||
type MedalMemberAddList struct {
|
||||
ID int64 `json:"id"`
|
||||
MedalName string `json:"medal_name"`
|
||||
}
|
||||
|
||||
// MedalOperLog struct.
|
||||
type MedalOperLog struct {
|
||||
OID int64 `json:"oper_id"`
|
||||
Action string `json:"action"`
|
||||
CTime xtime.Time `json:"ctime"`
|
||||
MTime xtime.Time `json:"mtime"`
|
||||
OperName string `json:"oper_name"`
|
||||
MID int64 `json:"mid"`
|
||||
MedalID int64 `json:"medal_id"`
|
||||
SourceType int8 `json:"source_type"`
|
||||
}
|
27
app/admin/main/usersuit/model/msg.go
Normal file
27
app/admin/main/usersuit/model/msg.go
Normal file
@ -0,0 +1,27 @@
|
||||
package model
|
||||
|
||||
// const msg
|
||||
const (
|
||||
MsgTypeCustom = int8(1)
|
||||
)
|
||||
|
||||
// SysMsg msg struct
|
||||
type SysMsg struct {
|
||||
IsMsg bool
|
||||
Type int8
|
||||
MID int64
|
||||
Title string
|
||||
Content string
|
||||
RemoteIP string
|
||||
}
|
||||
|
||||
// MsgInfo get msg info
|
||||
func MsgInfo(msg *SysMsg) (title, content, ip string) {
|
||||
switch msg.Type {
|
||||
case MsgTypeCustom:
|
||||
title = msg.Title
|
||||
content = msg.Content
|
||||
ip = msg.RemoteIP
|
||||
}
|
||||
return
|
||||
}
|
14
app/admin/main/usersuit/model/notify.go
Normal file
14
app/admin/main/usersuit/model/notify.go
Normal file
@ -0,0 +1,14 @@
|
||||
package model
|
||||
|
||||
//const
|
||||
const (
|
||||
AccountNotifyUpdatePendant = "updatePendant"
|
||||
AccountNotifyUpdateMedal = "updateMedal"
|
||||
)
|
||||
|
||||
// AccountNotify .
|
||||
type AccountNotify struct {
|
||||
UID int64 `json:"mid"`
|
||||
Type string `json:"type"`
|
||||
Action string `json:"action"`
|
||||
}
|
79
app/admin/main/usersuit/model/param.go
Normal file
79
app/admin/main/usersuit/model/param.go
Normal file
@ -0,0 +1,79 @@
|
||||
package model
|
||||
|
||||
import xtime "go-common/library/time"
|
||||
|
||||
// Pager .
|
||||
type Pager struct {
|
||||
Total int64 `json:"total"`
|
||||
PN int `json:"page"`
|
||||
PS int `json:"pagesize"`
|
||||
Order string `json:"order"`
|
||||
Sort string `json:"sort"`
|
||||
}
|
||||
|
||||
// ArgPendantGroupList .
|
||||
type ArgPendantGroupList struct {
|
||||
GID int64 `form:"gid"`
|
||||
PN int `form:"pn"`
|
||||
PS int `form:"ps" validate:"max=100"`
|
||||
}
|
||||
|
||||
// ArgPendantInfo .
|
||||
type ArgPendantInfo struct {
|
||||
PID int64 `form:"pid"`
|
||||
GID int64 `form:"gid" validate:"required"`
|
||||
Name string `form:"name" validate:"required"`
|
||||
Image string `form:"image"`
|
||||
ImageModel string `form:"image_model"`
|
||||
Rank int16 `form:"rank"`
|
||||
Status int8 `form:"status"`
|
||||
IntegralPrice int `form:"integral_price"` // 积分
|
||||
BcoinPrice int `form:"bcoin_price"` // B币
|
||||
CoinPrice int `form:"coin_price"` // 硬币
|
||||
}
|
||||
|
||||
// ArgPendantGroup .
|
||||
type ArgPendantGroup struct {
|
||||
GID int64 `form:"gid"`
|
||||
Name string `form:"name" validate:"required"`
|
||||
Rank int16 `form:"rank"`
|
||||
Status int8 `form:"status"`
|
||||
}
|
||||
|
||||
// ArgPendantOrder .
|
||||
type ArgPendantOrder struct {
|
||||
Start xtime.Time `form:"start_time"`
|
||||
End xtime.Time `form:"end_time"`
|
||||
Status int8 `form:"status"`
|
||||
PID int64 `form:"pid"`
|
||||
PayID string `form:"pay_id"`
|
||||
UID int64 `form:"uid"`
|
||||
PN int `form:"pn"`
|
||||
PS int `form:"ps" validate:"max=100"`
|
||||
}
|
||||
|
||||
// ArgPendantPKG .
|
||||
type ArgPendantPKG struct {
|
||||
UID int64 `form:"uid" validate:"required"`
|
||||
PID int64 `form:"pid" validate:"required"`
|
||||
Day int64 `form:"day" validate:"required"`
|
||||
Type int8 `form:"type"`
|
||||
IsMsg bool `form:"is_msg"`
|
||||
Title string `form:"title"`
|
||||
Content string `form:"content"`
|
||||
OID int64 `form:"oper_id" validate:"required"`
|
||||
}
|
||||
|
||||
// ArgMedal medal struct .
|
||||
type ArgMedal struct {
|
||||
GID int64 `json:"gid"`
|
||||
Name string `json:"name"`
|
||||
Description string `json:"description"`
|
||||
Image string `json:"image"`
|
||||
ImageSmall string `json:"image_small"`
|
||||
Condition string `json:"condition"`
|
||||
Level string `json:"level"`
|
||||
LevelRank string `json:"level_rank"`
|
||||
Sort int `json:"sort"`
|
||||
IsOnline int `json:"is_online"`
|
||||
}
|
131
app/admin/main/usersuit/model/pendant.go
Normal file
131
app/admin/main/usersuit/model/pendant.go
Normal file
@ -0,0 +1,131 @@
|
||||
package model
|
||||
|
||||
import xtime "go-common/library/time"
|
||||
|
||||
// const .
|
||||
const (
|
||||
// pendant type
|
||||
PendantCoinPrice = int8(0)
|
||||
PendantBCoinPrice = int8(1)
|
||||
PendantIntegralPrice = int8(2)
|
||||
// order plat
|
||||
PendantOrderPlatDefault = int8(-1)
|
||||
PendantOrderPlatPCAndH5 = int8(0)
|
||||
PendantOrderPlatPhone = int8(1)
|
||||
// pkg status
|
||||
PendantPKGInvalid = int8(0)
|
||||
PendantPKGValid = int8(1)
|
||||
PendantPKGOnEquip = int8(2)
|
||||
// pendant add style
|
||||
PendantAddStyleDay = int8(1)
|
||||
PendantAddStyleDate = int8(2)
|
||||
|
||||
// sourceType
|
||||
PendantSourceTypeAdmin = int8(1)
|
||||
PendantSourceTypePGC = int8(2)
|
||||
)
|
||||
|
||||
// var .
|
||||
var (
|
||||
PriceTypes = []int8{PendantCoinPrice, PendantBCoinPrice, PendantIntegralPrice}
|
||||
)
|
||||
|
||||
// PendantGroup .
|
||||
type PendantGroup struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Rank int16 `json:"rank"`
|
||||
Status int8 `json:"status"`
|
||||
}
|
||||
|
||||
// PendantPrice .
|
||||
type PendantPrice struct {
|
||||
PID int64 `json:"pid"`
|
||||
TP int8 `json:"type"`
|
||||
Price int `json:"price"`
|
||||
}
|
||||
|
||||
// PendantInfo .
|
||||
type PendantInfo struct {
|
||||
ID int64 `json:"id"`
|
||||
Name string `json:"name"`
|
||||
Image string `json:"image"`
|
||||
ImageModel string `json:"image_model"`
|
||||
Status int8 `json:"status"`
|
||||
Rank int16 `json:"rank"`
|
||||
GID int64 `json:"gid"`
|
||||
GroupName string `json:"group_name"`
|
||||
GroupRank int16 `json:"group_rank"`
|
||||
Prices []*PendantPrice `json:"prices"`
|
||||
}
|
||||
|
||||
// PendantGroupRef .
|
||||
type PendantGroupRef struct {
|
||||
GID int64 `json:"gid"`
|
||||
PID int64 `json:"pid"`
|
||||
}
|
||||
|
||||
// PendantOrder .
|
||||
type PendantOrder struct {
|
||||
BuyTime int64 `json:"buy_time"`
|
||||
OrderID string `json:"order_id"`
|
||||
PayID string `json:"pay_id"`
|
||||
UID int64 `json:"uid"`
|
||||
PID int64 `json:"-"`
|
||||
PName string `json:"pendant_name"`
|
||||
TimeLength int64 `json:"time_length"`
|
||||
Cost string `json:"cost"`
|
||||
PayType int8 `json:"pay_type"`
|
||||
Status int8 `json:"status"`
|
||||
AppID int8 `json:"appid"`
|
||||
Platform string `json:"platform"`
|
||||
}
|
||||
|
||||
// CoverToPlatform .
|
||||
func (p *PendantOrder) CoverToPlatform() {
|
||||
switch p.AppID {
|
||||
case PendantOrderPlatDefault:
|
||||
p.Platform = "默认"
|
||||
case PendantOrderPlatPCAndH5:
|
||||
p.Platform = "PC/H5"
|
||||
case PendantOrderPlatPhone:
|
||||
p.Platform = "手机客户端"
|
||||
}
|
||||
}
|
||||
|
||||
// PendantPKG .
|
||||
type PendantPKG struct {
|
||||
ID int64 `json:"id"`
|
||||
UID int64 `json:"uid"`
|
||||
PID int64 `json:"pid"`
|
||||
Expires int64 `json:"expires"`
|
||||
TP int8 `json:"type"`
|
||||
Status int8 `json:"status"`
|
||||
IsVip int8 `json:"is_vip"`
|
||||
}
|
||||
|
||||
// PendantOperLog .
|
||||
type PendantOperLog struct {
|
||||
OID int64 `json:"oper_id"`
|
||||
Action string `json:"action"`
|
||||
CTime xtime.Time `json:"ctime"`
|
||||
MTime xtime.Time `json:"mtime"`
|
||||
OperName string `json:"oper_name"`
|
||||
UID int64 `json:"uid"`
|
||||
PID int64 `json:"pid"`
|
||||
SourceType int8 `json:"source_type"`
|
||||
}
|
||||
|
||||
// BulidPendantPrice .
|
||||
func (pp *PendantPrice) BulidPendantPrice(arg *ArgPendantInfo, tp int8) {
|
||||
switch tp {
|
||||
case PendantCoinPrice:
|
||||
pp.Price = arg.CoinPrice
|
||||
case PendantBCoinPrice:
|
||||
pp.Price = arg.BcoinPrice
|
||||
case PendantIntegralPrice:
|
||||
pp.Price = arg.IntegralPrice
|
||||
}
|
||||
pp.TP = tp
|
||||
pp.PID = arg.PID
|
||||
}
|
Reference in New Issue
Block a user