mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-11-15 21:53:48 +08:00
用户操作权限增加角色权限过滤,优化角色/部门关系树生成,修复验证码空参数不验证问题
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
//
|
||||
package consts
|
||||
|
||||
// 数据范围
|
||||
@@ -30,3 +29,62 @@ var RoleDataNameMap = map[int]string{
|
||||
RoleDataSelfAndSub: "自己和直属下级",
|
||||
RoleDataSelfAndAllSub: "自己和全部下级",
|
||||
}
|
||||
|
||||
type GroupScopeSelect struct {
|
||||
Type string `json:"type,omitempty"`
|
||||
Label string `json:"label"`
|
||||
Key int `json:"key"`
|
||||
Value int `json:"value,omitempty"`
|
||||
Children []ScopeSelect `json:"children,omitempty"`
|
||||
}
|
||||
|
||||
type ScopeSelect struct {
|
||||
Label string `json:"label"`
|
||||
Value int `json:"value"`
|
||||
}
|
||||
|
||||
var DataScopeSelect = []GroupScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataAll],
|
||||
Key: RoleDataAll,
|
||||
Value: RoleDataAll,
|
||||
},
|
||||
{
|
||||
Type: "group",
|
||||
Label: "按部门划分",
|
||||
Key: -1,
|
||||
Children: []ScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataNowDept],
|
||||
Value: RoleDataNowDept,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataDeptAndSub],
|
||||
Value: RoleDataDeptAndSub,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataDeptCustom],
|
||||
Value: RoleDataDeptCustom,
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Type: "group",
|
||||
Label: "按上下级关系划分",
|
||||
Key: -2,
|
||||
Children: []ScopeSelect{
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelf],
|
||||
Value: RoleDataSelf,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelfAndSub],
|
||||
Value: RoleDataSelfAndSub,
|
||||
},
|
||||
{
|
||||
Label: RoleDataNameMap[RoleDataSelfAndAllSub],
|
||||
Value: RoleDataSelfAndAllSub,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ package admin
|
||||
import (
|
||||
"context"
|
||||
"hotgo/api/admin/role"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
@@ -69,7 +70,7 @@ func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissio
|
||||
// DataScopeSelect 获取数据权限选项
|
||||
func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
|
||||
res = new(role.DataScopeSelectRes)
|
||||
res.List = service.AdminRole().DataScopeSelect()
|
||||
res.List = consts.DataScopeSelect //service.AdminRole().DataScopeSelect()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -99,9 +99,9 @@ func (c *cSite) AccountLogin(ctx context.Context, req *common.AccountLoginReq) (
|
||||
return
|
||||
}
|
||||
|
||||
if login.CaptchaSwitch == 1 {
|
||||
if !req.IsLock && login.CaptchaSwitch == 1 {
|
||||
// 校验 验证码
|
||||
if !req.IsLock && !captcha.Verify(req.Cid, req.Code) {
|
||||
if !captcha.Verify(req.Cid, req.Code) {
|
||||
err = gerror.New("验证码错误")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,15 +5,4 @@
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
package global
|
||||
|
||||
import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var (
|
||||
// RootPtah 运行根路径
|
||||
RootPtah string
|
||||
// SysType 操作系统类型 windows | linux
|
||||
SysType = runtime.GOOS
|
||||
// JaegerSwitch 链路追踪开关
|
||||
JaegerSwitch bool
|
||||
)
|
||||
// 在这里可以配置一些全局公用的变量
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
"hotgo/internal/service"
|
||||
"hotgo/utility/charset"
|
||||
"hotgo/utility/simple"
|
||||
"runtime"
|
||||
"strings"
|
||||
)
|
||||
|
||||
@@ -37,8 +38,7 @@ func Init(ctx context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
RootPtah = gfile.Pwd()
|
||||
fmt.Printf("欢迎使用HotGo!\r\n当前运行环境:%v, 运行根路径为:%v \r\nHotGo版本:v%v, gf版本:%v \n", SysType, RootPtah, consts.VersionApp, gf.VERSION)
|
||||
fmt.Printf("欢迎使用HotGo!\r\n当前运行环境:%v, 运行根路径为:%v \r\nHotGo版本:v%v, gf版本:%v \n", runtime.GOOS, gfile.Pwd(), consts.VersionApp, gf.VERSION)
|
||||
|
||||
// 初始化链路追踪
|
||||
InitTrace(ctx)
|
||||
@@ -121,8 +121,7 @@ func LoggingServeLogHandler(ctx context.Context, in *glog.HandlerInput) {
|
||||
|
||||
// InitTrace 初始化链路追踪
|
||||
func InitTrace(ctx context.Context) {
|
||||
JaegerSwitch = g.Cfg().MustGet(ctx, "jaeger.switch").Bool()
|
||||
if !JaegerSwitch {
|
||||
if !g.Cfg().MustGet(ctx, "jaeger.switch").Bool() {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -57,6 +57,9 @@ func Generate(ctx context.Context) (id string, base64 string) {
|
||||
|
||||
// Verify 验证输入的验证码是否正确
|
||||
func Verify(id, answer string) bool {
|
||||
if id == "" || answer == "" {
|
||||
return false
|
||||
}
|
||||
c := base64Captcha.NewCaptcha(new(base64Captcha.DriverString), base64Captcha.DefaultMemStore)
|
||||
return c.Verify(id, gstr.ToLower(answer), true)
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/database/gdb"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
@@ -63,6 +64,11 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
|
||||
g.Log().Panic(ctx, "failed to role information roleModel == nil")
|
||||
}
|
||||
|
||||
// 超管拥有全部权限
|
||||
if role.Key == consts.SuperRoleKey {
|
||||
return m
|
||||
}
|
||||
|
||||
getDeptIds := func(in interface{}) []gdb.Value {
|
||||
ds, err := g.Model("admin_member").Fields("id").Where("dept_id", in).Array()
|
||||
if err != nil {
|
||||
@@ -77,19 +83,18 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
|
||||
case consts.RoleDataNowDept: // 当前部门
|
||||
m = m.WhereIn(filterField, getDeptIds(co.User.DeptId))
|
||||
case consts.RoleDataDeptAndSub: // 当前部门及以下部门ds
|
||||
m = m.WhereIn(filterField, getDeptIds(GetDeptAndSub(co.User.DeptId)))
|
||||
m = m.WhereIn(filterField, getDeptIds(GetDeptAndSub(ctx, co.User.DeptId)))
|
||||
case consts.RoleDataDeptCustom: // 自定义部门
|
||||
m = m.WhereIn(filterField, getDeptIds(role.CustomDept.Var().Ints()))
|
||||
case consts.RoleDataSelf: // 仅自己
|
||||
m = m.Where(filterField, co.User.Id)
|
||||
case consts.RoleDataSelfAndSub: // 自己和直属下级
|
||||
m = m.WhereIn(filterField, GetSelfAndSub(co.User.Id))
|
||||
m = m.WhereIn(filterField, GetSelfAndSub(ctx, co.User.Id))
|
||||
case consts.RoleDataSelfAndAllSub: // 自己和全部下级
|
||||
m = m.WhereIn(filterField, GetSelfAndAllSub(co.User.Id))
|
||||
m = m.WhereIn(filterField, GetSelfAndAllSub(ctx, co.User.Id))
|
||||
default:
|
||||
g.Log().Panic(ctx, "dataScope is not registered")
|
||||
}
|
||||
|
||||
return m
|
||||
}
|
||||
}
|
||||
@@ -100,12 +105,13 @@ func escapeFieldsToSlice(s string) []string {
|
||||
}
|
||||
|
||||
// GetDeptAndSub 获取指定部门的所有下级,含本部门
|
||||
func GetDeptAndSub(deptId int64) (ids []int64) {
|
||||
func GetDeptAndSub(ctx context.Context, deptId int64) (ids []int64) {
|
||||
array, err := g.Model("admin_dept").
|
||||
WhereLike("tree", "%"+tree.GetIdLabel(deptId)+"%").
|
||||
Fields("id").
|
||||
Array()
|
||||
if err != nil {
|
||||
g.Log().Panicf(ctx, "GetDeptAndSub err:%+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -118,12 +124,13 @@ func GetDeptAndSub(deptId int64) (ids []int64) {
|
||||
}
|
||||
|
||||
// GetSelfAndSub 获取直属下级,包含自己
|
||||
func GetSelfAndSub(memberId int64) (ids []int64) {
|
||||
func GetSelfAndSub(ctx context.Context, memberId int64) (ids []int64) {
|
||||
array, err := g.Model("admin_member").
|
||||
Where("pid", memberId).
|
||||
Fields("id").
|
||||
Array()
|
||||
if err != nil {
|
||||
g.Log().Panicf(ctx, "GetSelfAndSub err:%+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -136,12 +143,13 @@ func GetSelfAndSub(memberId int64) (ids []int64) {
|
||||
}
|
||||
|
||||
// GetSelfAndAllSub 获取全部下级,包含自己
|
||||
func GetSelfAndAllSub(memberId int64) (ids []int64) {
|
||||
func GetSelfAndAllSub(ctx context.Context, memberId int64) (ids []int64) {
|
||||
array, err := g.Model("admin_member").
|
||||
WhereLike("tree", "%"+tree.GetIdLabel(memberId)+"%").
|
||||
Fields("id").
|
||||
Array()
|
||||
if err != nil {
|
||||
g.Log().Panicf(ctx, "GetSelfAndAllSub err:%+v", err)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -106,14 +106,6 @@ func (s *sAdminDept) Edit(ctx context.Context, in *adminin.DeptEditInp) (err err
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
// 获取父级tree
|
||||
var pTree gdb.Value
|
||||
pTree, err = dao.AdminDept.Ctx(ctx).WherePri(in.Pid).Fields("tree").Value()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
in.Tree = tree.GenLabel(pTree.String(), in.Id)
|
||||
|
||||
err = dao.AdminDept.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||
// 更新数据
|
||||
_, err = dao.AdminDept.Ctx(ctx).Fields(adminin.DeptUpdateFields{}).WherePri(in.Id).Data(in).Update()
|
||||
@@ -139,7 +131,7 @@ func updateChildrenTree(ctx context.Context, _id int64, _level int, _tree string
|
||||
}
|
||||
for _, child := range list {
|
||||
child.Level = _level + 1
|
||||
child.Tree = tree.GenLabel(_tree, child.Id)
|
||||
child.Tree = tree.GenLabel(_tree, child.Pid)
|
||||
|
||||
if _, err = dao.AdminDept.Ctx(ctx).Where("id", child.Id).Data("level", child.Level, "tree", child.Tree).Update(); err != nil {
|
||||
return
|
||||
|
||||
@@ -799,11 +799,31 @@ func (s *sAdminMember) ClusterSyncSuperAdmin(ctx context.Context, message *gredi
|
||||
s.LoadSuperAdmin(ctx)
|
||||
}
|
||||
|
||||
// FilterAuthModel 过滤查询权限,如果不是超管则排除掉自己
|
||||
// FilterAuthModel 过滤用户操作权限
|
||||
// 非超管用户只能操作自己的下级角色用户,并且需要满足自身角色的数据权限设置
|
||||
func (s *sAdminMember) FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model {
|
||||
m := dao.AdminMember.Ctx(ctx)
|
||||
if !s.VerifySuperId(ctx, memberId) {
|
||||
m = m.Where("id <> ?", memberId)
|
||||
if s.VerifySuperId(ctx, memberId) {
|
||||
return m
|
||||
}
|
||||
return m.Handler(handler.FilterAuthWithField("id"))
|
||||
|
||||
var roleId int64
|
||||
if contexts.GetUserId(ctx) == memberId {
|
||||
// 当前登录用户直接从上下文中取角色ID
|
||||
roleId = contexts.GetRoleId(ctx)
|
||||
} else {
|
||||
ro, err := dao.AdminMember.Ctx(ctx).Fields("role_id").Where("id", memberId).Value()
|
||||
if err != nil {
|
||||
g.Log().Panicf(ctx, "failed to get role information, err:%+v", err)
|
||||
return nil
|
||||
}
|
||||
roleId = ro.Int64()
|
||||
}
|
||||
|
||||
roleIds, err := service.AdminRole().GetSubRoleIds(ctx, roleId, false)
|
||||
if err != nil {
|
||||
g.Log().Panicf(ctx, "get the subordinate role permission exception, err:%+v", err)
|
||||
return nil
|
||||
}
|
||||
return m.Where("id <> ?", memberId).WhereIn("role_id", roleIds).Handler(handler.FilterAuthWithField("id"))
|
||||
}
|
||||
|
||||
@@ -174,14 +174,6 @@ func (s *sAdminRole) Edit(ctx context.Context, in *adminin.RoleEditInp) (err err
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
// 获取父级tree
|
||||
var pTree gdb.Value
|
||||
pTree, err = dao.AdminRole.Ctx(ctx).Where("id", in.Pid).Fields("tree").Value()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
in.Tree = tree.GenLabel(pTree.String(), in.Id)
|
||||
|
||||
err = dao.AdminRole.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
|
||||
// 更新数据
|
||||
_, err = dao.AdminRole.Ctx(ctx).Fields(adminin.RoleUpdateFields{}).WherePri(in.Id).Data(in).Update()
|
||||
@@ -211,7 +203,7 @@ func updateRoleChildrenTree(ctx context.Context, _id int64, _level int, _tree st
|
||||
}
|
||||
for _, child := range list {
|
||||
child.Level = _level + 1
|
||||
child.Tree = tree.GenLabel(_tree, child.Id)
|
||||
child.Tree = tree.GenLabel(_tree, child.Pid)
|
||||
|
||||
if _, err = dao.AdminRole.Ctx(ctx).Where("id", child.Id).Data("level", child.Level, "tree", child.Tree).Update(); err != nil {
|
||||
return
|
||||
@@ -313,32 +305,37 @@ func (s *sAdminRole) treeList(pid int64, nodes []*entity.AdminRole) (list []*adm
|
||||
|
||||
// VerifyRoleId 验证角色ID
|
||||
func (s *sAdminRole) VerifyRoleId(ctx context.Context, id int64) (err error) {
|
||||
var (
|
||||
pid int64 = 0
|
||||
mb = contexts.GetUser(ctx)
|
||||
mod = dao.AdminRole.Ctx(ctx).Fields(dao.AdminRole.Columns().Id)
|
||||
)
|
||||
|
||||
mb := contexts.GetUser(ctx)
|
||||
if mb == nil {
|
||||
err = gerror.New("用户信息获取失败!")
|
||||
return
|
||||
}
|
||||
|
||||
// 非超管只获取下级
|
||||
if !service.AdminMember().VerifySuperId(ctx, mb.Id) {
|
||||
pid = mb.RoleId
|
||||
mod = mod.WhereNot(dao.AdminRole.Columns().Id, pid).WhereLike(dao.AdminRole.Columns().Tree, "%"+tree.GetIdLabel(pid)+"%")
|
||||
}
|
||||
|
||||
columns, err := mod.Array()
|
||||
ids, err := s.GetSubRoleIds(ctx, mb.RoleId, service.AdminMember().VerifySuperId(ctx, mb.Id))
|
||||
if err != nil {
|
||||
return err
|
||||
err = gerror.New("验证角色信息失败!")
|
||||
return
|
||||
}
|
||||
|
||||
ids := g.NewVar(columns).Int64s()
|
||||
if !validate.InSlice(ids, id) {
|
||||
err = gerror.New("角色ID是无效的")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetSubRoleIds 获取所有下级角色ID
|
||||
func (s *sAdminRole) GetSubRoleIds(ctx context.Context, roleId int64, isSuper bool) (ids []int64, err error) {
|
||||
mod := dao.AdminRole.Ctx(ctx).Fields(dao.AdminRole.Columns().Id)
|
||||
if !isSuper {
|
||||
mod = mod.WhereNot(dao.AdminRole.Columns().Id, roleId).WhereLike(dao.AdminRole.Columns().Tree, "%"+tree.GetIdLabel(roleId)+"%")
|
||||
}
|
||||
|
||||
columns, err := mod.Array()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids = g.NewVar(columns).Int64s()
|
||||
return
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"go.opentelemetry.io/otel/attribute"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/global"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/response"
|
||||
@@ -27,12 +26,14 @@ import (
|
||||
"hotgo/utility/validate"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type sMiddleware struct {
|
||||
LoginUrl string // 登录路由地址
|
||||
DemoWhiteList g.Map // 演示模式放行的路由白名单
|
||||
FilterRoutes map[string]ghttp.RouterItem // 支持预处理的web路由
|
||||
routeMutex sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
@@ -52,7 +53,7 @@ func NewMiddleware() *sMiddleware {
|
||||
|
||||
// Ctx 初始化请求上下文
|
||||
func (s *sMiddleware) Ctx(r *ghttp.Request) {
|
||||
if global.JaegerSwitch {
|
||||
if g.Cfg().MustGet(r.Context(), "jaeger.switch").Bool() {
|
||||
ctx, span := gtrace.NewSpan(r.Context(), "middleware.ctx")
|
||||
span.SetAttributes(attribute.KeyValue{
|
||||
Key: "traceID",
|
||||
|
||||
@@ -13,6 +13,13 @@ import (
|
||||
func (s *sMiddleware) GetFilterRoutes(r *ghttp.Request) map[string]ghttp.RouterItem {
|
||||
// 首次访问时加载
|
||||
if s.FilterRoutes == nil {
|
||||
s.routeMutex.Lock()
|
||||
defer s.routeMutex.Unlock()
|
||||
|
||||
if s.FilterRoutes != nil {
|
||||
return s.FilterRoutes
|
||||
}
|
||||
|
||||
s.FilterRoutes = make(map[string]ghttp.RouterItem)
|
||||
for _, v := range r.Server.GetRoutes() {
|
||||
// 非规范路由不加载
|
||||
|
||||
@@ -33,7 +33,7 @@ func WebSocket(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
})
|
||||
|
||||
// 启动websocket监听
|
||||
websocket.Start(ctx)
|
||||
websocket.Start()
|
||||
|
||||
// 注册消息路由
|
||||
websocket.RegisterMsg(websocket.EventHandlers{
|
||||
|
||||
@@ -19,6 +19,162 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
IAdminRole interface {
|
||||
// Verify 验证权限
|
||||
Verify(ctx context.Context, path, method string) bool
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error)
|
||||
// GetName 获取指定角色的名称
|
||||
GetName(ctx context.Context, id int64) (name string, err error)
|
||||
// GetMemberList 获取指定用户的岗位列表
|
||||
GetMemberList(ctx context.Context, id int64) (list []*adminin.RoleListModel, err error)
|
||||
// GetPermissions 更改角色菜单权限
|
||||
GetPermissions(ctx context.Context, in *adminin.GetPermissionsInp) (res *adminin.GetPermissionsModel, err error)
|
||||
// UpdatePermissions 更改角色菜单权限
|
||||
UpdatePermissions(ctx context.Context, in *adminin.UpdatePermissionsInp) (err error)
|
||||
Edit(ctx context.Context, in *adminin.RoleEditInp) (err error)
|
||||
Delete(ctx context.Context, in *adminin.RoleDeleteInp) (err error)
|
||||
DataScopeSelect() (res form.Selects)
|
||||
DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error)
|
||||
// VerifyRoleId 验证角色ID
|
||||
VerifyRoleId(ctx context.Context, id int64) (err error)
|
||||
// GetSubRoleIds 获取所有下级角色ID
|
||||
GetSubRoleIds(ctx context.Context, roleId int64, isSuper bool) (ids []int64, err error)
|
||||
}
|
||||
IAdminCash interface {
|
||||
// View 获取指定提现信息
|
||||
View(ctx context.Context, in *adminin.CashViewInp) (res *adminin.CashViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error)
|
||||
// Apply 申请提现
|
||||
Apply(ctx context.Context, in *adminin.CashApplyInp) (err error)
|
||||
// Payment 提现打款处理
|
||||
Payment(ctx context.Context, in *adminin.CashPaymentInp) (err error)
|
||||
}
|
||||
IAdminCreditsLog interface {
|
||||
// Model 资产变动ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// SaveBalance 更新余额
|
||||
SaveBalance(ctx context.Context, in *adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error)
|
||||
// SaveIntegral 更新积分
|
||||
SaveIntegral(ctx context.Context, in *adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error)
|
||||
// List 获取资产变动列表
|
||||
List(ctx context.Context, in *adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error)
|
||||
// Export 导出资产变动
|
||||
Export(ctx context.Context, in *adminin.CreditsLogListInp) (err error)
|
||||
}
|
||||
IAdminDept interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.DeptDeleteInp) (err error)
|
||||
// VerifyUnique 验证部门唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.DeptEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *adminin.DeptStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error)
|
||||
// View 获取指定部门信息
|
||||
View(ctx context.Context, in *adminin.DeptViewInp) (res *adminin.DeptViewModel, err error)
|
||||
// Option 选项
|
||||
Option(ctx context.Context, in *adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.DeptListInp) (res *adminin.DeptListModel, err error)
|
||||
// GetName 获取部门名称
|
||||
GetName(ctx context.Context, id int64) (name string, err error)
|
||||
// VerifyDeptId 验证部门ID
|
||||
VerifyDeptId(ctx context.Context, id int64) (err error)
|
||||
}
|
||||
IAdminMember interface {
|
||||
// AddBalance 增加余额
|
||||
AddBalance(ctx context.Context, in *adminin.MemberAddBalanceInp) (err error)
|
||||
// AddIntegral 增加积分
|
||||
AddIntegral(ctx context.Context, in *adminin.MemberAddIntegralInp) (err error)
|
||||
// UpdateCash 修改提现信息
|
||||
UpdateCash(ctx context.Context, in *adminin.MemberUpdateCashInp) (err error)
|
||||
// UpdateEmail 换绑邮箱
|
||||
UpdateEmail(ctx context.Context, in *adminin.MemberUpdateEmailInp) (err error)
|
||||
// UpdateMobile 换绑手机号
|
||||
UpdateMobile(ctx context.Context, in *adminin.MemberUpdateMobileInp) (err error)
|
||||
// UpdateProfile 更新用户资料
|
||||
UpdateProfile(ctx context.Context, in *adminin.MemberUpdateProfileInp) (err error)
|
||||
// UpdatePwd 修改登录密码
|
||||
UpdatePwd(ctx context.Context, in *adminin.MemberUpdatePwdInp) (err error)
|
||||
// ResetPwd 重置密码
|
||||
ResetPwd(ctx context.Context, in *adminin.MemberResetPwdInp) (err error)
|
||||
// VerifyUnique 验证管理员唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Delete 删除用户
|
||||
Delete(ctx context.Context, in *adminin.MemberDeleteInp) (err error)
|
||||
// Edit 修改/新增用户
|
||||
Edit(ctx context.Context, in *adminin.MemberEditInp) (err error)
|
||||
// View 获取用户信息
|
||||
View(ctx context.Context, in *adminin.MemberViewInp) (res *adminin.MemberViewModel, err error)
|
||||
// List 获取用户列表
|
||||
List(ctx context.Context, in *adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *adminin.MemberStatusInp) (err error)
|
||||
// GenTree 生成关系树
|
||||
GenTree(ctx context.Context, pid int64) (level int, newTree string, err error)
|
||||
// LoginMemberInfo 获取登录用户信息
|
||||
LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error)
|
||||
// MemberLoginStat 用户登录统计
|
||||
MemberLoginStat(ctx context.Context, in *adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error)
|
||||
// GetIdByCode 通过邀请码获取用户ID
|
||||
GetIdByCode(ctx context.Context, in *adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error)
|
||||
// Select 获取可选的用户选项
|
||||
Select(ctx context.Context, in *adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error)
|
||||
// VerifySuperId 验证是否为超管
|
||||
VerifySuperId(ctx context.Context, verifyId int64) bool
|
||||
// LoadSuperAdmin 加载超管数据
|
||||
LoadSuperAdmin(ctx context.Context)
|
||||
// ClusterSyncSuperAdmin 集群同步
|
||||
ClusterSyncSuperAdmin(ctx context.Context, message *gredis.Message)
|
||||
// FilterAuthModel 过滤查询权限,如果不是超管则排除掉自己
|
||||
FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model
|
||||
}
|
||||
IAdminMemberPost interface {
|
||||
// UpdatePostIds 更新用户岗位
|
||||
UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
|
||||
}
|
||||
IAdminPost interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.PostDeleteInp) (err error)
|
||||
// VerifyUnique 验证部门唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.PostEditInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *adminin.PostMaxSortInp) (res *adminin.PostMaxSortModel, err error)
|
||||
// View 获取指定岗位信息
|
||||
View(ctx context.Context, in *adminin.PostViewInp) (res *adminin.PostViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.PostListInp) (list []*adminin.PostListModel, totalCount int, err error)
|
||||
// GetMemberByStartName 获取指定用户的第一岗位
|
||||
GetMemberByStartName(ctx context.Context, memberId int64) (name string, err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *adminin.PostStatusInp) (err error)
|
||||
}
|
||||
IAdminMenu interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.MenuDeleteInp) (err error)
|
||||
// VerifyUnique 验证菜单唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.MenuEditInp) (err error)
|
||||
// List 获取菜单列表
|
||||
List(ctx context.Context, in *adminin.MenuListInp) (res *adminin.MenuListModel, err error)
|
||||
// GetMenuList 获取菜单列表
|
||||
GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error)
|
||||
// LoginPermissions 获取登录成功后的细粒度权限
|
||||
LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error)
|
||||
}
|
||||
IAdminMonitor interface {
|
||||
// StartMonitor 启动服务监控
|
||||
StartMonitor(ctx context.Context)
|
||||
// GetMeta 获取监控元数据
|
||||
GetMeta(ctx context.Context) *model.MonitorData
|
||||
}
|
||||
IAdminNotice interface {
|
||||
// Model Orm模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
@@ -69,24 +225,6 @@ type (
|
||||
// Status 更新充值订单状态
|
||||
Status(ctx context.Context, in *adminin.OrderStatusInp) (err error)
|
||||
}
|
||||
IAdminPost interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.PostDeleteInp) (err error)
|
||||
// VerifyUnique 验证部门唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.PostEditInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *adminin.PostMaxSortInp) (res *adminin.PostMaxSortModel, err error)
|
||||
// View 获取指定岗位信息
|
||||
View(ctx context.Context, in *adminin.PostViewInp) (res *adminin.PostViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.PostListInp) (list []*adminin.PostListModel, totalCount int, err error)
|
||||
// GetMemberByStartName 获取指定用户的第一岗位
|
||||
GetMemberByStartName(ctx context.Context, memberId int64) (name string, err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *adminin.PostStatusInp) (err error)
|
||||
}
|
||||
IAdminSite interface {
|
||||
// Register 账号注册
|
||||
Register(ctx context.Context, in *adminin.RegisterInp) (err error)
|
||||
@@ -95,159 +233,45 @@ type (
|
||||
// MobileLogin 手机号登录
|
||||
MobileLogin(ctx context.Context, in *adminin.MobileLoginInp) (res *adminin.LoginModel, err error)
|
||||
}
|
||||
IAdminMember interface {
|
||||
// AddBalance 增加余额
|
||||
AddBalance(ctx context.Context, in *adminin.MemberAddBalanceInp) (err error)
|
||||
// AddIntegral 增加积分
|
||||
AddIntegral(ctx context.Context, in *adminin.MemberAddIntegralInp) (err error)
|
||||
// UpdateCash 修改提现信息
|
||||
UpdateCash(ctx context.Context, in *adminin.MemberUpdateCashInp) (err error)
|
||||
// UpdateEmail 换绑邮箱
|
||||
UpdateEmail(ctx context.Context, in *adminin.MemberUpdateEmailInp) (err error)
|
||||
// UpdateMobile 换绑手机号
|
||||
UpdateMobile(ctx context.Context, in *adminin.MemberUpdateMobileInp) (err error)
|
||||
// UpdateProfile 更新用户资料
|
||||
UpdateProfile(ctx context.Context, in *adminin.MemberUpdateProfileInp) (err error)
|
||||
// UpdatePwd 修改登录密码
|
||||
UpdatePwd(ctx context.Context, in *adminin.MemberUpdatePwdInp) (err error)
|
||||
// ResetPwd 重置密码
|
||||
ResetPwd(ctx context.Context, in *adminin.MemberResetPwdInp) (err error)
|
||||
// VerifyUnique 验证管理员唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Delete 删除用户
|
||||
Delete(ctx context.Context, in *adminin.MemberDeleteInp) (err error)
|
||||
// Edit 修改/新增用户
|
||||
Edit(ctx context.Context, in *adminin.MemberEditInp) (err error)
|
||||
// View 获取用户信息
|
||||
View(ctx context.Context, in *adminin.MemberViewInp) (res *adminin.MemberViewModel, err error)
|
||||
// List 获取用户列表
|
||||
List(ctx context.Context, in *adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *adminin.MemberStatusInp) (err error)
|
||||
// GenTree 生成关系树
|
||||
GenTree(ctx context.Context, pid int64) (level int, newTree string, err error)
|
||||
// LoginMemberInfo 获取登录用户信息
|
||||
LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error)
|
||||
// MemberLoginStat 用户登录统计
|
||||
MemberLoginStat(ctx context.Context, in *adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error)
|
||||
// GetIdByCode 通过邀请码获取用户ID
|
||||
GetIdByCode(ctx context.Context, in *adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error)
|
||||
// Select 获取可选的用户选项
|
||||
Select(ctx context.Context, in *adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error)
|
||||
// VerifySuperId 验证是否为超管
|
||||
VerifySuperId(ctx context.Context, verifyId int64) bool
|
||||
// LoadSuperAdmin 加载超管数据
|
||||
LoadSuperAdmin(ctx context.Context)
|
||||
// ClusterSyncSuperAdmin 集群同步
|
||||
ClusterSyncSuperAdmin(ctx context.Context, message *gredis.Message)
|
||||
// FilterAuthModel 过滤查询权限,如果不是超管则排除掉自己
|
||||
FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model
|
||||
}
|
||||
IAdminCreditsLog interface {
|
||||
// Model 资产变动ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// SaveBalance 更新余额
|
||||
SaveBalance(ctx context.Context, in *adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error)
|
||||
// SaveIntegral 更新积分
|
||||
SaveIntegral(ctx context.Context, in *adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error)
|
||||
// List 获取资产变动列表
|
||||
List(ctx context.Context, in *adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error)
|
||||
// Export 导出资产变动
|
||||
Export(ctx context.Context, in *adminin.CreditsLogListInp) (err error)
|
||||
}
|
||||
IAdminDept interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.DeptDeleteInp) (err error)
|
||||
// VerifyUnique 验证部门唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.DeptEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *adminin.DeptStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error)
|
||||
// View 获取指定部门信息
|
||||
View(ctx context.Context, in *adminin.DeptViewInp) (res *adminin.DeptViewModel, err error)
|
||||
// Option 选项
|
||||
Option(ctx context.Context, in *adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.DeptListInp) (res *adminin.DeptListModel, err error)
|
||||
// GetName 获取部门名称
|
||||
GetName(ctx context.Context, id int64) (name string, err error)
|
||||
// VerifyDeptId 验证用户权限内的部门ID
|
||||
VerifyDeptId(ctx context.Context, id int64) (err error)
|
||||
}
|
||||
IAdminMemberPost interface {
|
||||
// UpdatePostIds 更新用户岗位
|
||||
UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
|
||||
}
|
||||
IAdminMenu interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *adminin.MenuDeleteInp) (err error)
|
||||
// VerifyUnique 验证菜单唯一属性
|
||||
VerifyUnique(ctx context.Context, in *adminin.VerifyUniqueInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *adminin.MenuEditInp) (err error)
|
||||
// List 获取菜单列表
|
||||
List(ctx context.Context, in *adminin.MenuListInp) (res *adminin.MenuListModel, err error)
|
||||
// GetMenuList 获取菜单列表
|
||||
GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error)
|
||||
// LoginPermissions 获取登录成功后的细粒度权限
|
||||
LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error)
|
||||
}
|
||||
IAdminMonitor interface {
|
||||
// StartMonitor 启动服务监控
|
||||
StartMonitor(ctx context.Context)
|
||||
// GetMeta 获取监控元数据
|
||||
GetMeta(ctx context.Context) *model.MonitorData
|
||||
}
|
||||
IAdminRole interface {
|
||||
// Verify 验证权限
|
||||
Verify(ctx context.Context, path, method string) bool
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error)
|
||||
// GetName 获取指定角色的名称
|
||||
GetName(ctx context.Context, id int64) (name string, err error)
|
||||
// GetMemberList 获取指定用户的岗位列表
|
||||
GetMemberList(ctx context.Context, id int64) (list []*adminin.RoleListModel, err error)
|
||||
// GetPermissions 更改角色菜单权限
|
||||
GetPermissions(ctx context.Context, in *adminin.GetPermissionsInp) (res *adminin.GetPermissionsModel, err error)
|
||||
// UpdatePermissions 更改角色菜单权限
|
||||
UpdatePermissions(ctx context.Context, in *adminin.UpdatePermissionsInp) (err error)
|
||||
Edit(ctx context.Context, in *adminin.RoleEditInp) (err error)
|
||||
Delete(ctx context.Context, in *adminin.RoleDeleteInp) (err error)
|
||||
DataScopeSelect() (res form.Selects)
|
||||
DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error)
|
||||
// VerifyRoleId 验证用户权限内的角色ID
|
||||
VerifyRoleId(ctx context.Context, id int64) (err error)
|
||||
}
|
||||
IAdminCash interface {
|
||||
// View 获取指定提现信息
|
||||
View(ctx context.Context, in *adminin.CashViewInp) (res *adminin.CashViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error)
|
||||
// Apply 申请提现
|
||||
Apply(ctx context.Context, in *adminin.CashApplyInp) (err error)
|
||||
// Payment 提现打款处理
|
||||
Payment(ctx context.Context, in *adminin.CashPaymentInp) (err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localAdminOrder IAdminOrder
|
||||
localAdminPost IAdminPost
|
||||
localAdminSite IAdminSite
|
||||
localAdminMember IAdminMember
|
||||
localAdminNotice IAdminNotice
|
||||
localAdminCreditsLog IAdminCreditsLog
|
||||
localAdminDept IAdminDept
|
||||
localAdminMember IAdminMember
|
||||
localAdminMemberPost IAdminMemberPost
|
||||
localAdminMenu IAdminMenu
|
||||
localAdminMonitor IAdminMonitor
|
||||
localAdminPost IAdminPost
|
||||
localAdminRole IAdminRole
|
||||
localAdminCash IAdminCash
|
||||
localAdminCreditsLog IAdminCreditsLog
|
||||
localAdminMonitor IAdminMonitor
|
||||
localAdminNotice IAdminNotice
|
||||
localAdminOrder IAdminOrder
|
||||
localAdminSite IAdminSite
|
||||
localAdminMenu IAdminMenu
|
||||
)
|
||||
|
||||
func AdminRole() IAdminRole {
|
||||
if localAdminRole == nil {
|
||||
panic("implement not found for interface IAdminRole, forgot register?")
|
||||
}
|
||||
return localAdminRole
|
||||
}
|
||||
|
||||
func RegisterAdminRole(i IAdminRole) {
|
||||
localAdminRole = i
|
||||
}
|
||||
|
||||
func AdminCash() IAdminCash {
|
||||
if localAdminCash == nil {
|
||||
panic("implement not found for interface IAdminCash, forgot register?")
|
||||
}
|
||||
return localAdminCash
|
||||
}
|
||||
|
||||
func RegisterAdminCash(i IAdminCash) {
|
||||
localAdminCash = i
|
||||
}
|
||||
|
||||
func AdminCreditsLog() IAdminCreditsLog {
|
||||
if localAdminCreditsLog == nil {
|
||||
panic("implement not found for interface IAdminCreditsLog, forgot register?")
|
||||
@@ -270,6 +294,17 @@ func RegisterAdminDept(i IAdminDept) {
|
||||
localAdminDept = i
|
||||
}
|
||||
|
||||
func AdminMember() IAdminMember {
|
||||
if localAdminMember == nil {
|
||||
panic("implement not found for interface IAdminMember, forgot register?")
|
||||
}
|
||||
return localAdminMember
|
||||
}
|
||||
|
||||
func RegisterAdminMember(i IAdminMember) {
|
||||
localAdminMember = i
|
||||
}
|
||||
|
||||
func AdminMemberPost() IAdminMemberPost {
|
||||
if localAdminMemberPost == nil {
|
||||
panic("implement not found for interface IAdminMemberPost, forgot register?")
|
||||
@@ -281,6 +316,17 @@ func RegisterAdminMemberPost(i IAdminMemberPost) {
|
||||
localAdminMemberPost = i
|
||||
}
|
||||
|
||||
func AdminPost() IAdminPost {
|
||||
if localAdminPost == nil {
|
||||
panic("implement not found for interface IAdminPost, forgot register?")
|
||||
}
|
||||
return localAdminPost
|
||||
}
|
||||
|
||||
func RegisterAdminPost(i IAdminPost) {
|
||||
localAdminPost = i
|
||||
}
|
||||
|
||||
func AdminMenu() IAdminMenu {
|
||||
if localAdminMenu == nil {
|
||||
panic("implement not found for interface IAdminMenu, forgot register?")
|
||||
@@ -303,28 +349,6 @@ func RegisterAdminMonitor(i IAdminMonitor) {
|
||||
localAdminMonitor = i
|
||||
}
|
||||
|
||||
func AdminRole() IAdminRole {
|
||||
if localAdminRole == nil {
|
||||
panic("implement not found for interface IAdminRole, forgot register?")
|
||||
}
|
||||
return localAdminRole
|
||||
}
|
||||
|
||||
func RegisterAdminRole(i IAdminRole) {
|
||||
localAdminRole = i
|
||||
}
|
||||
|
||||
func AdminCash() IAdminCash {
|
||||
if localAdminCash == nil {
|
||||
panic("implement not found for interface IAdminCash, forgot register?")
|
||||
}
|
||||
return localAdminCash
|
||||
}
|
||||
|
||||
func RegisterAdminCash(i IAdminCash) {
|
||||
localAdminCash = i
|
||||
}
|
||||
|
||||
func AdminNotice() IAdminNotice {
|
||||
if localAdminNotice == nil {
|
||||
panic("implement not found for interface IAdminNotice, forgot register?")
|
||||
@@ -347,17 +371,6 @@ func RegisterAdminOrder(i IAdminOrder) {
|
||||
localAdminOrder = i
|
||||
}
|
||||
|
||||
func AdminPost() IAdminPost {
|
||||
if localAdminPost == nil {
|
||||
panic("implement not found for interface IAdminPost, forgot register?")
|
||||
}
|
||||
return localAdminPost
|
||||
}
|
||||
|
||||
func RegisterAdminPost(i IAdminPost) {
|
||||
localAdminPost = i
|
||||
}
|
||||
|
||||
func AdminSite() IAdminSite {
|
||||
if localAdminSite == nil {
|
||||
panic("implement not found for interface IAdminSite, forgot register?")
|
||||
@@ -368,14 +381,3 @@ func AdminSite() IAdminSite {
|
||||
func RegisterAdminSite(i IAdminSite) {
|
||||
localAdminSite = i
|
||||
}
|
||||
|
||||
func AdminMember() IAdminMember {
|
||||
if localAdminMember == nil {
|
||||
panic("implement not found for interface IAdminMember, forgot register?")
|
||||
}
|
||||
return localAdminMember
|
||||
}
|
||||
|
||||
func RegisterAdminMember(i IAdminMember) {
|
||||
localAdminMember = i
|
||||
}
|
||||
|
||||
@@ -18,6 +18,44 @@ import (
|
||||
)
|
||||
|
||||
type (
|
||||
ISysServeLicense interface {
|
||||
// Model 服务许可证ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// List 获取服务许可证列表
|
||||
List(ctx context.Context, in *sysin.ServeLicenseListInp) (list []*sysin.ServeLicenseListModel, totalCount int, err error)
|
||||
// Export 导出服务许可证
|
||||
Export(ctx context.Context, in *sysin.ServeLicenseListInp) (err error)
|
||||
// Edit 修改/新增服务许可证
|
||||
Edit(ctx context.Context, in *sysin.ServeLicenseEditInp) (err error)
|
||||
// Delete 删除服务许可证
|
||||
Delete(ctx context.Context, in *sysin.ServeLicenseDeleteInp) (err error)
|
||||
// View 获取服务许可证指定信息
|
||||
View(ctx context.Context, in *sysin.ServeLicenseViewInp) (res *sysin.ServeLicenseViewModel, err error)
|
||||
// Status 更新服务许可证状态
|
||||
Status(ctx context.Context, in *sysin.ServeLicenseStatusInp) (err error)
|
||||
// AssignRouter 分配服务许可证路由
|
||||
AssignRouter(ctx context.Context, in *sysin.ServeLicenseAssignRouterInp) (err error)
|
||||
}
|
||||
ISysSmsLog interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.SmsLogDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.SmsLogEditInp) (err error)
|
||||
// Status 更新短信状态
|
||||
Status(ctx context.Context, in *sysin.SmsLogStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error)
|
||||
// SendCode 发送验证码
|
||||
SendCode(ctx context.Context, in *sysin.SendCodeInp) (err error)
|
||||
// GetTemplate 获取指定短信模板
|
||||
GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error)
|
||||
// AllowSend 是否允许发送
|
||||
AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error)
|
||||
// VerifyCode 效验验证码
|
||||
VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error)
|
||||
}
|
||||
ISysConfig interface {
|
||||
// InitConfig 初始化系统配置
|
||||
InitConfig(ctx context.Context)
|
||||
@@ -60,29 +98,41 @@ type (
|
||||
// ClusterSync 集群同步
|
||||
ClusterSync(ctx context.Context, message *gredis.Message)
|
||||
}
|
||||
ISysDictType interface {
|
||||
// Tree 树
|
||||
Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
|
||||
ISysEmsLog interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.DictTypeDeleteInp) (err error)
|
||||
Delete(ctx context.Context, in *sysin.EmsLogDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.DictTypeEditInp) (err error)
|
||||
// TreeSelect 获取类型关系树选项
|
||||
TreeSelect(ctx context.Context, in *sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
|
||||
Edit(ctx context.Context, in *sysin.EmsLogEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.EmsLogStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error)
|
||||
// Send 发送邮件
|
||||
Send(ctx context.Context, in *sysin.SendEmsInp) (err error)
|
||||
// GetTemplate 获取指定邮件模板
|
||||
GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error)
|
||||
// AllowSend 是否允许发送
|
||||
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
|
||||
// VerifyCode 效验验证码
|
||||
VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error)
|
||||
}
|
||||
ISysServeLog interface {
|
||||
// Model 服务日志Orm模型
|
||||
ISysLoginLog interface {
|
||||
// Model 登录日志Orm模型
|
||||
Model(ctx context.Context) *gdb.Model
|
||||
// List 获取服务日志列表
|
||||
List(ctx context.Context, in *sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
|
||||
// Export 导出服务日志
|
||||
Export(ctx context.Context, in *sysin.ServeLogListInp) (err error)
|
||||
// Delete 删除服务日志
|
||||
Delete(ctx context.Context, in *sysin.ServeLogDeleteInp) (err error)
|
||||
// View 获取服务日志指定信息
|
||||
View(ctx context.Context, in *sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
|
||||
// List 获取登录日志列表
|
||||
List(ctx context.Context, in *sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
|
||||
// Export 导出登录日志
|
||||
Export(ctx context.Context, in *sysin.LoginLogListInp) (err error)
|
||||
// Delete 删除登录日志
|
||||
Delete(ctx context.Context, in *sysin.LoginLogDeleteInp) (err error)
|
||||
// View 获取登录日志指定信息
|
||||
View(ctx context.Context, in *sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
|
||||
// Push 推送登录日志
|
||||
Push(ctx context.Context, in *sysin.LoginLogPushInp)
|
||||
// RealWrite 真实写入
|
||||
RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
|
||||
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
|
||||
}
|
||||
ISysAddons interface {
|
||||
// List 获取列表
|
||||
@@ -98,51 +148,116 @@ type (
|
||||
// UnInstall 卸载模块
|
||||
UnInstall(ctx context.Context, in *sysin.AddonsUnInstallInp) (err error)
|
||||
}
|
||||
ISysAddonsConfig interface {
|
||||
// GetConfigByGroup 获取指定分组的配置
|
||||
GetConfigByGroup(ctx context.Context, in *sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
|
||||
// ConversionType 转换类型
|
||||
ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error)
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateAddonsConfigInp) (err error)
|
||||
}
|
||||
ISysBlacklist interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.BlacklistDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.BlacklistEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.BlacklistStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.BlacklistViewInp) (res *sysin.BlacklistViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.BlacklistListInp) (list []*sysin.BlacklistListModel, totalCount int, err error)
|
||||
// VariableLoad 变化加载
|
||||
VariableLoad(ctx context.Context, err error)
|
||||
// Load 加载黑名单
|
||||
Load(ctx context.Context)
|
||||
// VerifyRequest 验证请求的访问IP是否在黑名单,如果存在则返回错误
|
||||
VerifyRequest(r *ghttp.Request) (err error)
|
||||
// ClusterSync 集群同步
|
||||
ClusterSync(ctx context.Context, message *gredis.Message)
|
||||
}
|
||||
ISysServeLicense interface {
|
||||
// Model 服务许可证ORM模型
|
||||
ISysAttachment interface {
|
||||
// Model ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// List 获取服务许可证列表
|
||||
List(ctx context.Context, in *sysin.ServeLicenseListInp) (list []*sysin.ServeLicenseListModel, totalCount int, err error)
|
||||
// Export 导出服务许可证
|
||||
Export(ctx context.Context, in *sysin.ServeLicenseListInp) (err error)
|
||||
// Edit 修改/新增服务许可证
|
||||
Edit(ctx context.Context, in *sysin.ServeLicenseEditInp) (err error)
|
||||
// Delete 删除服务许可证
|
||||
Delete(ctx context.Context, in *sysin.ServeLicenseDeleteInp) (err error)
|
||||
// View 获取服务许可证指定信息
|
||||
View(ctx context.Context, in *sysin.ServeLicenseViewInp) (res *sysin.ServeLicenseViewModel, err error)
|
||||
// Status 更新服务许可证状态
|
||||
Status(ctx context.Context, in *sysin.ServeLicenseStatusInp) (err error)
|
||||
// AssignRouter 分配服务许可证路由
|
||||
AssignRouter(ctx context.Context, in *sysin.ServeLicenseAssignRouterInp) (err error)
|
||||
// Delete 删除附件
|
||||
Delete(ctx context.Context, in *sysin.AttachmentDeleteInp) (err error)
|
||||
// View 获取附件信息
|
||||
View(ctx context.Context, in *sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
|
||||
// List 获取附件列表
|
||||
List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
|
||||
// ClearKind 清空上传类型
|
||||
ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error)
|
||||
}
|
||||
ISysCurdDemo interface {
|
||||
// Model 生成演示ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// List 获取生成演示列表
|
||||
List(ctx context.Context, in *sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
|
||||
// Export 导出生成演示
|
||||
Export(ctx context.Context, in *sysin.CurdDemoListInp) (err error)
|
||||
// Edit 修改/新增生成演示
|
||||
Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error)
|
||||
// Delete 删除生成演示
|
||||
Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error)
|
||||
// MaxSort 获取生成演示最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
|
||||
// View 获取生成演示指定信息
|
||||
View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
|
||||
// Status 更新生成演示状态
|
||||
Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error)
|
||||
// Switch 更新生成演示开关
|
||||
Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error)
|
||||
}
|
||||
ISysGenCodes interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.GenCodesDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.GenCodesStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
|
||||
// Selects 选项
|
||||
Selects(ctx context.Context, in *sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
|
||||
// TableSelect 表选项
|
||||
TableSelect(ctx context.Context, in *sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
|
||||
// ColumnSelect 表字段选项
|
||||
ColumnSelect(ctx context.Context, in *sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
|
||||
// ColumnList 表字段列表
|
||||
ColumnList(ctx context.Context, in *sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
|
||||
// Preview 生成预览
|
||||
Preview(ctx context.Context, in *sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
|
||||
// Build 提交生成
|
||||
Build(ctx context.Context, in *sysin.GenCodesBuildInp) (err error)
|
||||
}
|
||||
ISysCron interface {
|
||||
StartCron(ctx context.Context)
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.CronDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.CronEditInp) (err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *sysin.CronStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
|
||||
// View 获取指定信息
|
||||
View(ctx context.Context, in *sysin.CronViewInp) (res *sysin.CronViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
|
||||
// OnlineExec 在线执行
|
||||
OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error)
|
||||
}
|
||||
ISysCronGroup interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.CronGroupDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.CronGroupEditInp) (err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *sysin.CronGroupStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error)
|
||||
// View 获取指定信息
|
||||
View(ctx context.Context, in *sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
|
||||
// Select 选项
|
||||
Select(ctx context.Context, in *sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
|
||||
}
|
||||
ISysDictData interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.DictDataDeleteInp) error
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.DictDataEditInp) (err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
|
||||
// Select 获取列表
|
||||
Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
|
||||
}
|
||||
ISysDictType interface {
|
||||
// Tree 树
|
||||
Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.DictTypeDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.DictTypeEditInp) (err error)
|
||||
// TreeSelect 获取类型关系树选项
|
||||
TreeSelect(ctx context.Context, in *sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
|
||||
}
|
||||
ISysLog interface {
|
||||
// Export 导出
|
||||
@@ -182,261 +297,80 @@ type (
|
||||
// Select 省市区选项
|
||||
Select(ctx context.Context, in *sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
|
||||
}
|
||||
ISysSmsLog interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.SmsLogDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.SmsLogEditInp) (err error)
|
||||
// Status 更新短信状态
|
||||
Status(ctx context.Context, in *sysin.SmsLogStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.SmsLogViewInp) (res *sysin.SmsLogViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.SmsLogListInp) (list []*sysin.SmsLogListModel, totalCount int, err error)
|
||||
// SendCode 发送验证码
|
||||
SendCode(ctx context.Context, in *sysin.SendCodeInp) (err error)
|
||||
// GetTemplate 获取指定短信模板
|
||||
GetTemplate(ctx context.Context, template string, config *model.SmsConfig) (val string, err error)
|
||||
// AllowSend 是否允许发送
|
||||
AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error)
|
||||
// VerifyCode 效验验证码
|
||||
VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error)
|
||||
}
|
||||
ISysCron interface {
|
||||
StartCron(ctx context.Context)
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.CronDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.CronEditInp) (err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *sysin.CronStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
|
||||
// View 获取指定信息
|
||||
View(ctx context.Context, in *sysin.CronViewInp) (res *sysin.CronViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
|
||||
// OnlineExec 在线执行
|
||||
OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error)
|
||||
}
|
||||
ISysCurdDemo interface {
|
||||
// Model 生成演示ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// List 获取生成演示列表
|
||||
List(ctx context.Context, in *sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
|
||||
// Export 导出生成演示
|
||||
Export(ctx context.Context, in *sysin.CurdDemoListInp) (err error)
|
||||
// Edit 修改/新增生成演示
|
||||
Edit(ctx context.Context, in *sysin.CurdDemoEditInp) (err error)
|
||||
// Delete 删除生成演示
|
||||
Delete(ctx context.Context, in *sysin.CurdDemoDeleteInp) (err error)
|
||||
// MaxSort 获取生成演示最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
|
||||
// View 获取生成演示指定信息
|
||||
View(ctx context.Context, in *sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
|
||||
// Status 更新生成演示状态
|
||||
Status(ctx context.Context, in *sysin.CurdDemoStatusInp) (err error)
|
||||
// Switch 更新生成演示开关
|
||||
Switch(ctx context.Context, in *sysin.CurdDemoSwitchInp) (err error)
|
||||
}
|
||||
ISysEmsLog interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.EmsLogDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.EmsLogEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.EmsLogStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.EmsLogViewInp) (res *sysin.EmsLogViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.EmsLogListInp) (list []*sysin.EmsLogListModel, totalCount int, err error)
|
||||
// Send 发送邮件
|
||||
Send(ctx context.Context, in *sysin.SendEmsInp) (err error)
|
||||
// GetTemplate 获取指定邮件模板
|
||||
GetTemplate(ctx context.Context, template string, config *model.EmailConfig) (val string, err error)
|
||||
// AllowSend 是否允许发送
|
||||
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
|
||||
// VerifyCode 效验验证码
|
||||
VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error)
|
||||
}
|
||||
ISysGenCodes interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.GenCodesDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.GenCodesStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
|
||||
// Selects 选项
|
||||
Selects(ctx context.Context, in *sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
|
||||
// TableSelect 表选项
|
||||
TableSelect(ctx context.Context, in *sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
|
||||
// ColumnSelect 表字段选项
|
||||
ColumnSelect(ctx context.Context, in *sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
|
||||
// ColumnList 表字段列表
|
||||
ColumnList(ctx context.Context, in *sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
|
||||
// Preview 生成预览
|
||||
Preview(ctx context.Context, in *sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
|
||||
// Build 提交生成
|
||||
Build(ctx context.Context, in *sysin.GenCodesBuildInp) (err error)
|
||||
}
|
||||
ISysLoginLog interface {
|
||||
// Model 登录日志Orm模型
|
||||
ISysServeLog interface {
|
||||
// Model 服务日志Orm模型
|
||||
Model(ctx context.Context) *gdb.Model
|
||||
// List 获取登录日志列表
|
||||
List(ctx context.Context, in *sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
|
||||
// Export 导出登录日志
|
||||
Export(ctx context.Context, in *sysin.LoginLogListInp) (err error)
|
||||
// Delete 删除登录日志
|
||||
Delete(ctx context.Context, in *sysin.LoginLogDeleteInp) (err error)
|
||||
// View 获取登录日志指定信息
|
||||
View(ctx context.Context, in *sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
|
||||
// Push 推送登录日志
|
||||
Push(ctx context.Context, in *sysin.LoginLogPushInp)
|
||||
// List 获取服务日志列表
|
||||
List(ctx context.Context, in *sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
|
||||
// Export 导出服务日志
|
||||
Export(ctx context.Context, in *sysin.ServeLogListInp) (err error)
|
||||
// Delete 删除服务日志
|
||||
Delete(ctx context.Context, in *sysin.ServeLogDeleteInp) (err error)
|
||||
// View 获取服务日志指定信息
|
||||
View(ctx context.Context, in *sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
|
||||
// RealWrite 真实写入
|
||||
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
|
||||
RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
|
||||
}
|
||||
ISysAttachment interface {
|
||||
// Model ORM模型
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
// Delete 删除附件
|
||||
Delete(ctx context.Context, in *sysin.AttachmentDeleteInp) (err error)
|
||||
// View 获取附件信息
|
||||
View(ctx context.Context, in *sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
|
||||
// List 获取附件列表
|
||||
List(ctx context.Context, in *sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
|
||||
// ClearKind 清空上传类型
|
||||
ClearKind(ctx context.Context, in *sysin.AttachmentClearKindInp) (err error)
|
||||
ISysAddonsConfig interface {
|
||||
// GetConfigByGroup 获取指定分组的配置
|
||||
GetConfigByGroup(ctx context.Context, in *sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
|
||||
// ConversionType 转换类型
|
||||
ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error)
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateAddonsConfigInp) (err error)
|
||||
}
|
||||
ISysCronGroup interface {
|
||||
ISysBlacklist interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.CronGroupDeleteInp) (err error)
|
||||
Delete(ctx context.Context, in *sysin.BlacklistDeleteInp) (err error)
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.CronGroupEditInp) (err error)
|
||||
// Status 更新状态
|
||||
Status(ctx context.Context, in *sysin.CronGroupStatusInp) (err error)
|
||||
// MaxSort 最大排序
|
||||
MaxSort(ctx context.Context, in *sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error)
|
||||
// View 获取指定信息
|
||||
View(ctx context.Context, in *sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
|
||||
Edit(ctx context.Context, in *sysin.BlacklistEditInp) (err error)
|
||||
// Status 更新部门状态
|
||||
Status(ctx context.Context, in *sysin.BlacklistStatusInp) (err error)
|
||||
// View 获取指定字典类型信息
|
||||
View(ctx context.Context, in *sysin.BlacklistViewInp) (res *sysin.BlacklistViewModel, err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
|
||||
// Select 选项
|
||||
Select(ctx context.Context, in *sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
|
||||
}
|
||||
ISysDictData interface {
|
||||
// Delete 删除
|
||||
Delete(ctx context.Context, in *sysin.DictDataDeleteInp) error
|
||||
// Edit 修改/新增
|
||||
Edit(ctx context.Context, in *sysin.DictDataEditInp) (err error)
|
||||
// List 获取列表
|
||||
List(ctx context.Context, in *sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
|
||||
// Select 获取列表
|
||||
Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
|
||||
List(ctx context.Context, in *sysin.BlacklistListInp) (list []*sysin.BlacklistListModel, totalCount int, err error)
|
||||
// VariableLoad 变化加载
|
||||
VariableLoad(ctx context.Context, err error)
|
||||
// Load 加载黑名单
|
||||
Load(ctx context.Context)
|
||||
// VerifyRequest 验证请求的访问IP是否在黑名单,如果存在则返回错误
|
||||
VerifyRequest(r *ghttp.Request) (err error)
|
||||
// ClusterSync 集群同步
|
||||
ClusterSync(ctx context.Context, message *gredis.Message)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSysCron ISysCron
|
||||
localSysCurdDemo ISysCurdDemo
|
||||
localSysConfig ISysConfig
|
||||
localSysEmsLog ISysEmsLog
|
||||
localSysLog ISysLog
|
||||
localSysProvinces ISysProvinces
|
||||
localSysServeLicense ISysServeLicense
|
||||
localSysSmsLog ISysSmsLog
|
||||
localSysAttachment ISysAttachment
|
||||
localSysCronGroup ISysCronGroup
|
||||
localSysDictData ISysDictData
|
||||
localSysGenCodes ISysGenCodes
|
||||
localSysLoginLog ISysLoginLog
|
||||
localSysAddons ISysAddons
|
||||
localSysAttachment ISysAttachment
|
||||
localSysLoginLog ISysLoginLog
|
||||
localSysCron ISysCron
|
||||
localSysCronGroup ISysCronGroup
|
||||
localSysCurdDemo ISysCurdDemo
|
||||
localSysGenCodes ISysGenCodes
|
||||
localSysProvinces ISysProvinces
|
||||
localSysServeLog ISysServeLog
|
||||
localSysAddonsConfig ISysAddonsConfig
|
||||
localSysBlacklist ISysBlacklist
|
||||
localSysConfig ISysConfig
|
||||
localSysDictData ISysDictData
|
||||
localSysDictType ISysDictType
|
||||
localSysServeLog ISysServeLog
|
||||
localSysServeLicense ISysServeLicense
|
||||
localSysLog ISysLog
|
||||
)
|
||||
|
||||
func SysServeLicense() ISysServeLicense {
|
||||
if localSysServeLicense == nil {
|
||||
panic("implement not found for interface ISysServeLicense, forgot register?")
|
||||
func SysAddons() ISysAddons {
|
||||
if localSysAddons == nil {
|
||||
panic("implement not found for interface ISysAddons, forgot register?")
|
||||
}
|
||||
return localSysServeLicense
|
||||
return localSysAddons
|
||||
}
|
||||
|
||||
func RegisterSysServeLicense(i ISysServeLicense) {
|
||||
localSysServeLicense = i
|
||||
}
|
||||
|
||||
func SysCron() ISysCron {
|
||||
if localSysCron == nil {
|
||||
panic("implement not found for interface ISysCron, forgot register?")
|
||||
}
|
||||
return localSysCron
|
||||
}
|
||||
|
||||
func RegisterSysCron(i ISysCron) {
|
||||
localSysCron = i
|
||||
}
|
||||
|
||||
func SysCurdDemo() ISysCurdDemo {
|
||||
if localSysCurdDemo == nil {
|
||||
panic("implement not found for interface ISysCurdDemo, forgot register?")
|
||||
}
|
||||
return localSysCurdDemo
|
||||
}
|
||||
|
||||
func RegisterSysCurdDemo(i ISysCurdDemo) {
|
||||
localSysCurdDemo = i
|
||||
}
|
||||
|
||||
func SysEmsLog() ISysEmsLog {
|
||||
if localSysEmsLog == nil {
|
||||
panic("implement not found for interface ISysEmsLog, forgot register?")
|
||||
}
|
||||
return localSysEmsLog
|
||||
}
|
||||
|
||||
func RegisterSysEmsLog(i ISysEmsLog) {
|
||||
localSysEmsLog = i
|
||||
}
|
||||
|
||||
func SysLog() ISysLog {
|
||||
if localSysLog == nil {
|
||||
panic("implement not found for interface ISysLog, forgot register?")
|
||||
}
|
||||
return localSysLog
|
||||
}
|
||||
|
||||
func RegisterSysLog(i ISysLog) {
|
||||
localSysLog = i
|
||||
}
|
||||
|
||||
func SysProvinces() ISysProvinces {
|
||||
if localSysProvinces == nil {
|
||||
panic("implement not found for interface ISysProvinces, forgot register?")
|
||||
}
|
||||
return localSysProvinces
|
||||
}
|
||||
|
||||
func RegisterSysProvinces(i ISysProvinces) {
|
||||
localSysProvinces = i
|
||||
}
|
||||
|
||||
func SysSmsLog() ISysSmsLog {
|
||||
if localSysSmsLog == nil {
|
||||
panic("implement not found for interface ISysSmsLog, forgot register?")
|
||||
}
|
||||
return localSysSmsLog
|
||||
}
|
||||
|
||||
func RegisterSysSmsLog(i ISysSmsLog) {
|
||||
localSysSmsLog = i
|
||||
func RegisterSysAddons(i ISysAddons) {
|
||||
localSysAddons = i
|
||||
}
|
||||
|
||||
func SysAttachment() ISysAttachment {
|
||||
@@ -450,6 +384,28 @@ func RegisterSysAttachment(i ISysAttachment) {
|
||||
localSysAttachment = i
|
||||
}
|
||||
|
||||
func SysLoginLog() ISysLoginLog {
|
||||
if localSysLoginLog == nil {
|
||||
panic("implement not found for interface ISysLoginLog, forgot register?")
|
||||
}
|
||||
return localSysLoginLog
|
||||
}
|
||||
|
||||
func RegisterSysLoginLog(i ISysLoginLog) {
|
||||
localSysLoginLog = i
|
||||
}
|
||||
|
||||
func SysCron() ISysCron {
|
||||
if localSysCron == nil {
|
||||
panic("implement not found for interface ISysCron, forgot register?")
|
||||
}
|
||||
return localSysCron
|
||||
}
|
||||
|
||||
func RegisterSysCron(i ISysCron) {
|
||||
localSysCron = i
|
||||
}
|
||||
|
||||
func SysCronGroup() ISysCronGroup {
|
||||
if localSysCronGroup == nil {
|
||||
panic("implement not found for interface ISysCronGroup, forgot register?")
|
||||
@@ -461,15 +417,15 @@ func RegisterSysCronGroup(i ISysCronGroup) {
|
||||
localSysCronGroup = i
|
||||
}
|
||||
|
||||
func SysDictData() ISysDictData {
|
||||
if localSysDictData == nil {
|
||||
panic("implement not found for interface ISysDictData, forgot register?")
|
||||
func SysCurdDemo() ISysCurdDemo {
|
||||
if localSysCurdDemo == nil {
|
||||
panic("implement not found for interface ISysCurdDemo, forgot register?")
|
||||
}
|
||||
return localSysDictData
|
||||
return localSysCurdDemo
|
||||
}
|
||||
|
||||
func RegisterSysDictData(i ISysDictData) {
|
||||
localSysDictData = i
|
||||
func RegisterSysCurdDemo(i ISysCurdDemo) {
|
||||
localSysCurdDemo = i
|
||||
}
|
||||
|
||||
func SysGenCodes() ISysGenCodes {
|
||||
@@ -483,26 +439,26 @@ func RegisterSysGenCodes(i ISysGenCodes) {
|
||||
localSysGenCodes = i
|
||||
}
|
||||
|
||||
func SysLoginLog() ISysLoginLog {
|
||||
if localSysLoginLog == nil {
|
||||
panic("implement not found for interface ISysLoginLog, forgot register?")
|
||||
func SysProvinces() ISysProvinces {
|
||||
if localSysProvinces == nil {
|
||||
panic("implement not found for interface ISysProvinces, forgot register?")
|
||||
}
|
||||
return localSysLoginLog
|
||||
return localSysProvinces
|
||||
}
|
||||
|
||||
func RegisterSysLoginLog(i ISysLoginLog) {
|
||||
localSysLoginLog = i
|
||||
func RegisterSysProvinces(i ISysProvinces) {
|
||||
localSysProvinces = i
|
||||
}
|
||||
|
||||
func SysAddons() ISysAddons {
|
||||
if localSysAddons == nil {
|
||||
panic("implement not found for interface ISysAddons, forgot register?")
|
||||
func SysServeLog() ISysServeLog {
|
||||
if localSysServeLog == nil {
|
||||
panic("implement not found for interface ISysServeLog, forgot register?")
|
||||
}
|
||||
return localSysAddons
|
||||
return localSysServeLog
|
||||
}
|
||||
|
||||
func RegisterSysAddons(i ISysAddons) {
|
||||
localSysAddons = i
|
||||
func RegisterSysServeLog(i ISysServeLog) {
|
||||
localSysServeLog = i
|
||||
}
|
||||
|
||||
func SysAddonsConfig() ISysAddonsConfig {
|
||||
@@ -527,15 +483,15 @@ func RegisterSysBlacklist(i ISysBlacklist) {
|
||||
localSysBlacklist = i
|
||||
}
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
func SysDictData() ISysDictData {
|
||||
if localSysDictData == nil {
|
||||
panic("implement not found for interface ISysDictData, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
return localSysDictData
|
||||
}
|
||||
|
||||
func RegisterSysConfig(i ISysConfig) {
|
||||
localSysConfig = i
|
||||
func RegisterSysDictData(i ISysDictData) {
|
||||
localSysDictData = i
|
||||
}
|
||||
|
||||
func SysDictType() ISysDictType {
|
||||
@@ -549,13 +505,57 @@ func RegisterSysDictType(i ISysDictType) {
|
||||
localSysDictType = i
|
||||
}
|
||||
|
||||
func SysServeLog() ISysServeLog {
|
||||
if localSysServeLog == nil {
|
||||
panic("implement not found for interface ISysServeLog, forgot register?")
|
||||
func SysLog() ISysLog {
|
||||
if localSysLog == nil {
|
||||
panic("implement not found for interface ISysLog, forgot register?")
|
||||
}
|
||||
return localSysServeLog
|
||||
return localSysLog
|
||||
}
|
||||
|
||||
func RegisterSysServeLog(i ISysServeLog) {
|
||||
localSysServeLog = i
|
||||
func RegisterSysLog(i ISysLog) {
|
||||
localSysLog = i
|
||||
}
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
}
|
||||
|
||||
func RegisterSysConfig(i ISysConfig) {
|
||||
localSysConfig = i
|
||||
}
|
||||
|
||||
func SysEmsLog() ISysEmsLog {
|
||||
if localSysEmsLog == nil {
|
||||
panic("implement not found for interface ISysEmsLog, forgot register?")
|
||||
}
|
||||
return localSysEmsLog
|
||||
}
|
||||
|
||||
func RegisterSysEmsLog(i ISysEmsLog) {
|
||||
localSysEmsLog = i
|
||||
}
|
||||
|
||||
func SysServeLicense() ISysServeLicense {
|
||||
if localSysServeLicense == nil {
|
||||
panic("implement not found for interface ISysServeLicense, forgot register?")
|
||||
}
|
||||
return localSysServeLicense
|
||||
}
|
||||
|
||||
func RegisterSysServeLicense(i ISysServeLicense) {
|
||||
localSysServeLicense = i
|
||||
}
|
||||
|
||||
func SysSmsLog() ISysSmsLog {
|
||||
if localSysSmsLog == nil {
|
||||
panic("implement not found for interface ISysSmsLog, forgot register?")
|
||||
}
|
||||
return localSysSmsLog
|
||||
}
|
||||
|
||||
func RegisterSysSmsLog(i ISysSmsLog) {
|
||||
localSysSmsLog = i
|
||||
}
|
||||
|
||||
@@ -33,9 +33,8 @@ type login struct {
|
||||
}
|
||||
|
||||
// GetKey 读取客户端数据
|
||||
func (l *login) GetKey() (key string) {
|
||||
key = GetUserKey(l.UserId)
|
||||
return
|
||||
func (l *login) GetKey() string {
|
||||
return GetUserKey(l.UserId)
|
||||
}
|
||||
|
||||
// Client 客户端连接
|
||||
@@ -77,7 +76,7 @@ func NewClient(r *ghttp.Request, socket *websocket.Conn, firstTime uint64) (clie
|
||||
func (c *Client) read() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Warningf(ctxManager, "client read err: %+v, stack:%+v, user:%+v", r, string(debug.Stack()), c.User)
|
||||
g.Log().Warningf(mctx, "client read err: %+v, stack:%+v, user:%+v", r, string(debug.Stack()), c.User)
|
||||
}
|
||||
}()
|
||||
|
||||
@@ -97,7 +96,7 @@ func (c *Client) read() {
|
||||
func (c *Client) write() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Warningf(ctxManager, "client write err: %+v, stack:%+v, user:%+v", r, string(debug.Stack()), c.User)
|
||||
g.Log().Warningf(mctx, "client write err: %+v, stack:%+v, user:%+v", r, string(debug.Stack()), c.User)
|
||||
}
|
||||
}()
|
||||
defer func() {
|
||||
@@ -107,12 +106,12 @@ func (c *Client) write() {
|
||||
for {
|
||||
select {
|
||||
case <-c.closeSignal:
|
||||
g.Log().Infof(ctxManager, "websocket client quit, user:%+v", c.User)
|
||||
g.Log().Infof(mctx, "websocket client quit, user:%+v", c.User)
|
||||
return
|
||||
case message, ok := <-c.Send:
|
||||
if !ok {
|
||||
// 发送数据错误 关闭连接
|
||||
g.Log().Warningf(ctxManager, "client write message, user:%+v", c.User)
|
||||
g.Log().Warningf(mctx, "client write message, user:%+v", c.User)
|
||||
return
|
||||
}
|
||||
_ = c.Socket.WriteJSON(message)
|
||||
@@ -127,7 +126,7 @@ func (c *Client) SendMsg(msg *WResponse) {
|
||||
}
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Infof(ctxManager, "SendMsg err:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
g.Log().Infof(mctx, "SendMsg err:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
c.Send <- msg
|
||||
|
||||
@@ -205,7 +205,7 @@ func (manager *ClientManager) clearTimeoutConnections() {
|
||||
func (manager *ClientManager) ping() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Warningf(ctxManager, "websocket gcron ping recover:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
g.Log().Warningf(mctx, "websocket gcron ping recover:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
return
|
||||
}
|
||||
}()
|
||||
@@ -220,7 +220,7 @@ func (manager *ClientManager) ping() {
|
||||
// })
|
||||
|
||||
// 定时任务,清理超时连接
|
||||
_, _ = gcron.Add(ctxManager, "*/30 * * * * *", func(ctx context.Context) {
|
||||
_, _ = gcron.Add(mctx, "*/30 * * * * *", func(ctx context.Context) {
|
||||
manager.clearTimeoutConnections()
|
||||
})
|
||||
}
|
||||
@@ -229,7 +229,7 @@ func (manager *ClientManager) ping() {
|
||||
func (manager *ClientManager) start() {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Warningf(ctxManager, "websocket start recover:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
g.Log().Warningf(mctx, "websocket start recover:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
return
|
||||
}
|
||||
}()
|
||||
@@ -287,7 +287,7 @@ func (manager *ClientManager) start() {
|
||||
}
|
||||
}
|
||||
case <-manager.closeSignal:
|
||||
g.Log().Debug(ctxManager, "websocket closeSignal quit..")
|
||||
g.Log().Debug(mctx, "websocket closeSignal quit..")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
package websocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"github.com/gogf/gf/v2/os/grpool"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"github.com/gorilla/websocket"
|
||||
@@ -16,18 +16,17 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
ctxManager context.Context // 主上下文
|
||||
mctx = gctx.GetInitCtx() // 上下文
|
||||
clientManager = NewClientManager() // 客户端管理
|
||||
routers = make(map[string]EventHandler) // 消息路由
|
||||
msgGo = grpool.New(20) // 消息处理协程池
|
||||
)
|
||||
|
||||
// Start 启动
|
||||
func Start(c context.Context) {
|
||||
ctxManager = c
|
||||
func Start() {
|
||||
go clientManager.start()
|
||||
go clientManager.ping()
|
||||
g.Log().Debug(ctxManager, "start websocket..")
|
||||
g.Log().Debug(mctx, "start websocket..")
|
||||
}
|
||||
|
||||
// Stop 关闭
|
||||
|
||||
@@ -16,38 +16,38 @@ import (
|
||||
func handlerMsg(client *Client, message []byte) {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
g.Log().Warningf(ctxManager, "handlerMsg recover, err:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
g.Log().Warningf(mctx, "handlerMsg recover, err:%+v, stack:%+v", r, string(debug.Stack()))
|
||||
}
|
||||
}()
|
||||
|
||||
var request *WRequest
|
||||
if err := gconv.Struct(message, &request); err != nil {
|
||||
g.Log().Warningf(ctxManager, "handlerMsg 数据解析失败,err:%+v, message:%+v", err, string(message))
|
||||
g.Log().Warningf(mctx, "handlerMsg 数据解析失败,err:%+v, message:%+v", err, string(message))
|
||||
return
|
||||
}
|
||||
|
||||
if request.Event == "" {
|
||||
g.Log().Warning(ctxManager, "handlerMsg request.Event is null")
|
||||
g.Log().Warning(mctx, "handlerMsg request.Event is null")
|
||||
return
|
||||
}
|
||||
|
||||
fun, ok := routers[request.Event]
|
||||
if !ok {
|
||||
g.Log().Warningf(ctxManager, "handlerMsg function id %v: not registered", request.Event)
|
||||
g.Log().Warningf(mctx, "handlerMsg function id %v: not registered", request.Event)
|
||||
return
|
||||
}
|
||||
|
||||
err := msgGo.AddWithRecover(ctxManager,
|
||||
err := msgGo.AddWithRecover(mctx,
|
||||
func(ctx context.Context) {
|
||||
fun(client, request)
|
||||
},
|
||||
func(ctx context.Context, err error) {
|
||||
g.Log().Warningf(ctxManager, "handlerMsg msgGo exec err:%+v", err)
|
||||
g.Log().Warningf(mctx, "handlerMsg msgGo exec err:%+v", err)
|
||||
},
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
g.Log().Warningf(ctxManager, "handlerMsg msgGo Add err:%+v", err)
|
||||
g.Log().Warningf(mctx, "handlerMsg msgGo Add err:%+v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
@@ -56,7 +56,7 @@ func handlerMsg(client *Client, message []byte) {
|
||||
func RegisterMsg(handlers EventHandlers) {
|
||||
for id, f := range handlers {
|
||||
if _, ok := routers[id]; ok {
|
||||
g.Log().Fatalf(ctxManager, "RegisterMsg function id %v: already registered", id)
|
||||
g.Log().Fatalf(mctx, "RegisterMsg function id %v: already registered", id)
|
||||
return
|
||||
}
|
||||
routers[id] = f
|
||||
|
||||
Reference in New Issue
Block a user