Initial commit

This commit is contained in:
Donny
2019-04-22 20:46:32 +08:00
commit 49ab8aadd1
25441 changed files with 4055000 additions and 0 deletions

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"],
importpath = "go-common/app/admin/main/feed/util",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/admin/main/feed/model/common:go_default_library",
"//library/net/http/blademaster:go_default_library",
"//library/queue/databus/report: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,83 @@
package util
import (
"strconv"
"strings"
"time"
"go-common/app/admin/main/feed/model/common"
bm "go-common/library/net/http/blademaster"
"go-common/library/queue/databus/report"
)
//AddLog add action log
func AddLog(id int, uname string, uid int64, oid int64, action string, obj interface{}) (err error) {
report.Manager(&report.ManagerInfo{
Uname: uname,
UID: uid,
Business: id,
Type: 0,
Oid: oid,
Action: action,
Ctime: time.Now(),
// extra
Index: []interface{}{},
Content: map[string]interface{}{
"json": obj,
},
})
return
}
//AddLogs add action logs
func AddLogs(logtype int, uname string, uid int64, oid int64, action string, obj interface{}) (err error) {
report.Manager(&report.ManagerInfo{
Uname: uname,
UID: uid,
Business: common.BusinessID,
Type: logtype,
Oid: oid,
Action: action,
Ctime: time.Now(),
// extra
Index: []interface{}{},
Content: map[string]interface{}{
"json": obj,
},
})
return
}
//UserInfo get login userinfo
func UserInfo(c *bm.Context) (uid int64, username string) {
if nameInter, ok := c.Get("username"); ok {
username = nameInter.(string)
}
if uidInter, ok := c.Get("uid"); ok {
uid = uidInter.(int64)
}
if username == "" {
cookie, _ := c.Request.Cookie("username")
if cookie == nil || cookie.Value == "" {
return
}
username = cookie.Value
cookie, _ = c.Request.Cookie("uid")
if cookie == nil || cookie.Value == "" {
return
}
uidInt, _ := strconv.Atoi(cookie.Value)
uid = int64(uidInt)
}
return
}
//TrimStrSpace trim string space
func TrimStrSpace(v string) string {
return strings.TrimSpace(v)
}
//CTimeStr current time string
func CTimeStr() (cTime string) {
return time.Unix(time.Now().Unix(), 0).Format("2006-01-02 15:04:05")
}