Merge pull request #42 from bufanyun/v2.0

优化服务监控定时器,移除notify功能包,修复部门和角色树列表部分情况无法自动展开问题
This commit is contained in:
maxbad 2023-08-08 10:44:20 +08:00 committed by GitHub
commit 1207cb2829
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
92 changed files with 460 additions and 751 deletions

View File

@ -1,3 +1,8 @@
// Package smslog
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package smslog package smslog
import ( import (

View File

@ -1,3 +1,8 @@
// Package pay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package pay package pay
import ( import (

View File

@ -1,3 +1,8 @@
// Package servmsg
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package servmsg package servmsg
import ( import (

View File

@ -1,3 +1,8 @@
// Package servmsg
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package servmsg package servmsg
import ( import (

View File

@ -1,3 +1,8 @@
// Package servmsg
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package servmsg package servmsg
import ( import (

View File

@ -1,3 +1,8 @@
// Package base
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package base package base
import ( import (

View File

@ -1,3 +1,8 @@
// Package consts
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts package consts
const ( const (

View File

@ -1,3 +1,8 @@
// Package consts
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts package consts
const ( const (

View File

@ -1,3 +1,8 @@
// Package consts
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts package consts
// 授权分组 // 授权分组

View File

@ -1,3 +1,8 @@
// Package consts
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts package consts
// 授权类型 // 授权类型

View File

@ -130,6 +130,8 @@ func (c *cMonitor) NetOnlineList(ctx context.Context, req *monitor.NetOnlineList
conns := serv.GetClients() conns := serv.GetClients()
if len(conns) == 0 { if len(conns) == 0 {
res = new(monitor.NetOnlineListRes)
res.PageRes.Pack(req, 0)
return return
} }

View File

@ -70,7 +70,7 @@ func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissio
// DataScopeSelect 获取数据权限选项 // DataScopeSelect 获取数据权限选项
func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) { func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
res = new(role.DataScopeSelectRes) res = new(role.DataScopeSelectRes)
res.List = consts.DataScopeSelect //service.AdminRole().DataScopeSelect() res.List = consts.DataScopeSelect
return return
} }

View File

@ -5,11 +5,7 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/consts"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
"hotgo/internal/model/entity"
) )
// internalAdminDeptDao is internal type for wrapping internal DAO implements. // internalAdminDeptDao is internal type for wrapping internal DAO implements.
@ -28,23 +24,4 @@ var (
} }
) )
// IsUniqueName 判断名称是否唯一 // Fill with you ideas below.
func (dao *adminDeptDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
var data *entity.AdminDept
m := dao.Ctx(ctx).Where("name", name)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}

View File

@ -5,10 +5,7 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
"hotgo/internal/model/entity"
) )
// internalAdminMemberPostDao is internal type for wrapping internal DAO implements. // internalAdminMemberPostDao is internal type for wrapping internal DAO implements.
@ -27,27 +24,4 @@ var (
} }
) )
// UpdatePostIds 更新管理员岗位 // Fill with you ideas below.
func (dao *adminMemberPostDao) UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) {
_, err = dao.Ctx(ctx).
Where("member_id", memberId).
Delete()
if err != nil {
err = gerror.Wrap(err, "删除失败")
return err
}
for i := 0; i < len(postIds); i++ {
_, err = dao.Ctx(ctx).
Insert(entity.AdminMemberPost{
MemberId: memberId,
PostId: postIds[i],
})
if err != nil {
err = gerror.Wrap(err, "插入用户岗位失败")
return err
}
}
return nil
}

View File

@ -23,3 +23,5 @@ var (
internal.NewAdminMenuDao(), internal.NewAdminMenuDao(),
} }
) )
// Fill with you ideas below.

View File

@ -5,11 +5,7 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/consts"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
"hotgo/internal/model/entity"
) )
// internalAdminPostDao is internal type for wrapping internal DAO implements. // internalAdminPostDao is internal type for wrapping internal DAO implements.
@ -28,44 +24,4 @@ var (
} }
) )
// IsUniqueName 判断名称是否唯一 // Fill with you ideas below.
func (dao *adminPostDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
var data *entity.AdminPost
m := dao.Ctx(ctx).Where("name", name)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}
// IsUniqueCode 判断编码是否唯一
func (dao *adminPostDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) {
var data *entity.AdminPost
m := dao.Ctx(ctx).Where("code", code)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}

View File

@ -5,11 +5,7 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/consts"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
"hotgo/internal/model/entity"
) )
// internalAdminRoleDao is internal type for wrapping internal DAO implements. // internalAdminRoleDao is internal type for wrapping internal DAO implements.
@ -28,44 +24,4 @@ var (
} }
) )
// IsUniqueName 判断名称是否唯一 // Fill with you ideas below.
func (dao *adminRoleDao) IsUniqueName(ctx context.Context, id int64, name string) (bool, error) {
var data *entity.AdminRole
m := dao.Ctx(ctx).Where("name", name)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}
// IsUniqueCode 判断编码是否唯一
func (dao *adminRoleDao) IsUniqueCode(ctx context.Context, id int64, code string) (bool, error) {
var data *entity.AdminRole
m := dao.Ctx(ctx).Where("key", code)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}

View File

@ -23,3 +23,5 @@ var (
internal.NewSysAttachmentDao(), internal.NewSysAttachmentDao(),
} }
) )
// Fill with you ideas below.

View File

@ -5,9 +5,6 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/consts"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
) )
@ -27,14 +24,4 @@ var (
} }
) )
// GetName 获取分组名称 // Fill with you ideas below.
func (dao *sysCronGroupDao) GetName(ctx context.Context, id int64) (name string, err error) {
m := dao.Ctx(ctx).Fields("name").Where("id", id)
list, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return name, err
}
return list.String(), nil
}

View File

@ -5,12 +5,7 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
"hotgo/internal/model/entity"
) )
// internalSysDictTypeDao is internal type for wrapping internal DAO implements. // internalSysDictTypeDao is internal type for wrapping internal DAO implements.
@ -30,60 +25,3 @@ var (
) )
// Fill with you ideas below. // Fill with you ideas below.
// IsUniqueType 判断类型是否唯一
func (dao *sysDictTypeDao) IsUniqueType(ctx context.Context, id int64, typeName string) (bool, error) {
var data *entity.SysDictType
m := dao.Ctx(ctx).Where("type", typeName)
if id > 0 {
m = m.WhereNot("id", id)
}
if err := m.Scan(&data); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return false, err
}
if data == nil {
return true, nil
}
return false, nil
}
// GetTypes 获取指定ID的所有类型标识包含下级
func (dao *sysDictTypeDao) GetTypes(ctx context.Context, id int64) (types []string, err error) {
columns, err := dao.Ctx(ctx).Fields("type").
Where("id", id).
WhereOr("pid", id).
Where("status", consts.StatusEnabled).Array()
types = g.NewVar(columns).Strings()
return
}
// GetType 获取指定ID的类型标识
func (dao *sysDictTypeDao) GetType(ctx context.Context, id int64) (types string, err error) {
m := dao.Ctx(ctx).Fields("type").Where("id", id).
Where("status", consts.StatusEnabled)
list, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return types, err
}
return list.String(), nil
}
// GetId 获取指定类型的ID
func (dao *sysDictTypeDao) GetId(ctx context.Context, t string) (id int64, err error) {
m := dao.Ctx(ctx).Fields("id").Where("type", t).
Where("status", consts.StatusEnabled)
list, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return 0, err
}
return list.Int64(), nil
}

View File

@ -5,8 +5,6 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
) )
@ -27,17 +25,3 @@ var (
) )
// Fill with you ideas below. // Fill with you ideas below.
// NowDayCount 当天发送次数
func (dao *sysEmsLogDao) NowDayCount(ctx context.Context, event, email string) (count int, err error) {
count, err = dao.Ctx(ctx).
Where("email", email).
Where("event", event).
WhereGTE("created_at", gtime.Now().Format("Y-m-d")).
Count()
if err != nil {
return 0, err
}
return
}

View File

@ -5,8 +5,6 @@
package dao package dao
import ( import (
"context"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/dao/internal" "hotgo/internal/dao/internal"
) )
@ -27,17 +25,3 @@ var (
) )
// Fill with you ideas below. // Fill with you ideas below.
// NowDayCount 当天发送次数
func (dao *sysSmsLogDao) NowDayCount(ctx context.Context, event, mobile string) (count int, err error) {
count, err = dao.Ctx(ctx).
Where("mobile", mobile).
Where("event", event).
WhereGTE("created_at", gtime.Now().Format("Y-m-d")).
Count()
if err != nil {
return 0, err
}
return
}

View File

@ -41,14 +41,13 @@ func PublishClusterSync(ctx context.Context, channel string, message interface{}
} }
mutex := lock.Mutex(fmt.Sprintf("%s:%s", "lock", channel)) mutex := lock.Mutex(fmt.Sprintf("%s:%s", "lock", channel))
if err := mutex.Lock(ctx); err != nil { err := mutex.LockFunc(ctx, func() {
g.Log().Warningf(ctx, "PublishClusterSync %v lock err:%v", channel, err) if _, err := pubsub.Publish(ctx, channel, message); err != nil {
return g.Log().Warningf(ctx, "PublishClusterSync %v err:%v", channel, err)
} }
_ = mutex.Unlock(ctx) })
if err != nil {
if _, err := pubsub.Publish(ctx, channel, message); err != nil { g.Log().Warningf(ctx, "PublishClusterSync %v LockFunc err:%v", channel, err)
g.Log().Warningf(ctx, "PublishClusterSync %v err:%v", channel, err)
} }
return return
} }

View File

@ -1,3 +1,8 @@
// Package addons
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package addons package addons
import ( import (

View File

@ -1,3 +1,8 @@
// Package addons
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package addons package addons
const ( const (

View File

@ -1,3 +1,8 @@
// Package file
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package file package file
import ( import (

View File

@ -1,3 +1,8 @@
// Package contexts
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package contexts package contexts
import ( import (

View File

@ -116,6 +116,33 @@ func (l *Lock) Unlock(ctx context.Context) error {
return err return err
} }
func (l *Lock) LockFunc(ctx context.Context, f func()) error {
if err := l.Lock(ctx); err != nil {
return err
}
defer func() {
_ = l.Unlock(ctx)
}()
f()
return nil
}
// TryLockFunc tries locking the mutex for writing with given callback function `f`.
// it returns true immediately if success, or if there's a lock on the mutex,
// it returns error immediately.
//
// It releases the lock after `f` is executed.
func (l *Lock) TryLockFunc(ctx context.Context, f func()) error {
err := l.TryLock(ctx)
if err != nil {
defer func() {
_ = l.Unlock(ctx)
}()
f()
}
return err
}
// startWatchDog 看门狗 // startWatchDog 看门狗
func (l *Lock) startWatchDog() { func (l *Lock) startWatchDog() {
resetTTLInterval := l.ttl / 3 resetTTLInterval := l.ttl / 3

View File

@ -32,9 +32,6 @@ func SubscribeMap(channels map[string]SubHandler) (err error) {
return return
} }
subscribes.mutex.Lock()
defer subscribes.mutex.Unlock()
for channel, hr := range channels { for channel, hr := range channels {
if err = Subscribe(channel, hr); err != nil { if err = Subscribe(channel, hr); err != nil {
return return

View File

@ -1,79 +0,0 @@
package feishu
import (
"encoding/json"
"fmt"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gctx"
"strconv"
"time"
"hotgo/internal/library/notify/feishu/internal/security"
)
const feishuAPI = "https://open.feishu.cn/open-apis/bot/v2/hook/"
// Client feishu client
type Client struct {
AccessToken string
Secret string
}
// NewClient new client
func NewClient(accessToken, secret string) *Client {
return &Client{
AccessToken: accessToken,
Secret: secret,
}
}
// Response response struct
type Response struct {
Code int64 `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
Extra interface{} `json:"Extra"`
StatusCode int64 `json:"StatusCode"`
StatusMessage string `json:"StatusMessage"`
}
// Send send message
func (d *Client) Send(message Message) (string, *Response, error) {
res := &Response{}
if len(d.AccessToken) < 1 {
return "", res, fmt.Errorf("accessToken is empty")
}
timestamp := time.Now().Unix()
sign, err := security.GenSign(d.Secret, timestamp)
if err != nil {
return "", res, err
}
body := message.Body()
body["timestamp"] = strconv.FormatInt(timestamp, 10)
body["sign"] = sign
reqBytes, err := json.Marshal(body)
if err != nil {
return "", res, err
}
var (
result *Response
URL = fmt.Sprintf("%v%v", feishuAPI, d.AccessToken)
reqString = string(reqBytes)
)
g.Client().
Retry(3, time.Second).
SetHeader("Accept", "application/json").
SetHeader("Content-Type", "application/json").
PostVar(gctx.New(), URL, &result)
if result.Code != 0 {
return reqString, result, fmt.Errorf("send message to feishu error = %s", result.Msg)
}
return reqString, result, nil
}

View File

@ -1,24 +0,0 @@
package feishu
type ImageMessage struct {
MsgType MsgType `json:"msg_type"`
Content ImageContent `json:"content"`
}
type ImageContent struct {
ImageKey string `json:"image_key"`
}
func (m *ImageMessage) Body() map[string]interface{} {
m.MsgType = MsgTypeImage
return structToMap(m)
}
func NewImageMessage() *ImageMessage {
return &ImageMessage{}
}
func (m *ImageMessage) SetImageKey(key string) *ImageMessage {
m.Content.ImageKey = key
return m
}

View File

@ -1,21 +0,0 @@
package feishu
type InteractiveMessage struct {
MsgType MsgType `json:"msg_type"`
Card string `json:"card"`
}
func (m *InteractiveMessage) Body() map[string]interface{} {
m.MsgType = MsgTypeInteractive
return structToMap(m)
}
func NewInteractiveMessage() *InteractiveMessage {
return &InteractiveMessage{}
}
// SetCard set card with cardbuilder https://open.feishu.cn/tool/cardbuilder?from=custom_bot_doc
func (m *InteractiveMessage) SetCard(card string) *InteractiveMessage {
m.Card = card
return m
}

View File

@ -1,21 +0,0 @@
package security
import (
"crypto/hmac"
"crypto/sha256"
"encoding/base64"
"fmt"
)
// GenSign generate sign
func GenSign(secret string, timestamp int64) (string, error) {
stringToSign := fmt.Sprintf("%v", timestamp) + "\n" + secret
var data []byte
h := hmac.New(sha256.New, []byte(stringToSign))
_, err := h.Write(data)
if err != nil {
return "", err
}
signature := base64.StdEncoding.EncodeToString(h.Sum(nil))
return signature, nil
}

View File

@ -1,66 +0,0 @@
package feishu
import (
"reflect"
"strings"
)
type MsgType string
// MsgType
const (
MsgTypeText MsgType = "text"
MsgTypePost MsgType = "post"
MsgTypeImage MsgType = "image"
MsgTypeShareChat MsgType = "share_chat"
MsgTypeInteractive MsgType = "interactive"
)
// Message interface
type Message interface {
Body() map[string]interface{}
}
func structToMap(item interface{}) map[string]interface{} {
res := map[string]interface{}{}
if item == nil {
return res
}
v := reflect.TypeOf(item)
reflectValue := reflect.ValueOf(item)
reflectValue = reflect.Indirect(reflectValue)
if v.Kind() == reflect.Ptr {
v = v.Elem()
}
for i := 0; i < v.NumField(); i++ {
tag := v.Field(i).Tag.Get("json")
// remove omitEmpty
omitEmpty := false
if strings.HasSuffix(tag, "omitempty") {
omitEmpty = true
idx := strings.Index(tag, ",")
if idx > 0 {
tag = tag[:idx]
} else {
tag = ""
}
}
field := reflectValue.Field(i).Interface()
if tag != "" && tag != "-" {
if omitEmpty && reflectValue.Field(i).IsZero() {
continue
}
if v.Field(i).Type.Kind() == reflect.Struct {
res[tag] = structToMap(field)
} else {
res[tag] = field
}
}
}
return res
}

View File

@ -1,170 +0,0 @@
package feishu
import (
"encoding/json"
"log"
)
type PostMessage struct {
MsgType MsgType `json:"msg_type"`
Content PostContent `json:"content"`
}
func NewPostMessage() *PostMessage {
return &PostMessage{}
}
func (m *PostMessage) Body() map[string]interface{} {
m.MsgType = MsgTypePost
return structToMap(m)
}
func (m *PostMessage) SetZH(u PostUnit) *PostMessage {
m.Content.Post.ZH = u
return m
}
func (m *PostMessage) SetZHTitle(t string) *PostMessage {
m.Content.Post.ZH.Title = t
return m
}
func (m *PostMessage) AppendZHContent(i []PostItem) *PostMessage {
m.Content.Post.ZH.Content = append(m.Content.Post.ZH.Content, i)
return m
}
func (m *PostMessage) SetJA(u PostUnit) *PostMessage {
m.Content.Post.JA = u
return m
}
func (m *PostMessage) SetJATitle(t string) *PostMessage {
m.Content.Post.JA.Title = t
return m
}
func (m *PostMessage) AppendJAContent(i []PostItem) *PostMessage {
m.Content.Post.JA.Content = append(m.Content.Post.JA.Content, i)
return m
}
func (m *PostMessage) SetEN(u PostUnit) *PostMessage {
m.Content.Post.EN = u
return m
}
func (m *PostMessage) SetENTitle(t string) *PostMessage {
m.Content.Post.EN.Title = t
return m
}
func (m *PostMessage) AppendENContent(i []PostItem) *PostMessage {
m.Content.Post.EN.Content = append(m.Content.Post.EN.Content, i)
return m
}
type PostContent struct {
Post PostBody `json:"post"`
}
type PostBody struct {
ZH PostUnit `json:"zh_cn,omitempty"`
JA PostUnit `json:"ja_jp,omitempty"`
EN PostUnit `json:"en_us,omitempty"`
}
type PostUnit struct {
Title string `json:"title,omitempty"`
Content [][]PostItem `json:"content"`
}
type PostItem interface{}
type Text struct {
Tag string `json:"tag"`
Text string `json:"text"`
UnEscape bool `json:"un_escape,omitempty"`
}
func NewText(text string) Text {
t := Text{
Tag: "text",
Text: text,
}
return t
}
type A struct {
Tag string `json:"tag"`
Text string `json:"text"`
Href string `json:"href"`
UnEscape bool `json:"un_escape,omitempty"`
}
func NewA(text, href string) A {
t := A{
Tag: "a",
Text: text,
Href: href,
}
return t
}
type AT struct {
Tag string `json:"tag"`
UserID string `json:"user_id"`
}
func NewAT(userID string) AT {
t := AT{
Tag: "at",
UserID: userID,
}
return t
}
type Image struct {
Tag string `json:"tag"`
ImageKey string `json:"image_key"`
Height int `json:"height"`
Width int `json:"width"`
}
func NewImage(imageKey string, height, width int) Image {
t := Image{
Tag: "image",
ImageKey: imageKey,
Height: height,
Width: width,
}
return t
}
type PostCMDMessage struct {
MsgType MsgType `json:"msg_type"`
Content PostCMDContent `json:"content"`
}
func (m *PostCMDMessage) Body() map[string]interface{} {
m.MsgType = MsgTypePost
return structToMap(m)
}
type PostCMDContent struct {
Post map[string]interface{} `json:"post"`
}
func NewPostCMDMessage() *PostCMDMessage {
return &PostCMDMessage{}
}
func (m *PostCMDMessage) SetPost(post string) *PostCMDMessage {
var result map[string]interface{}
err := json.Unmarshal([]byte(post), &result)
if err != nil {
log.Print("SetPost err: ", err)
}
m.Content.Post = result
return m
}

View File

@ -1,24 +0,0 @@
package feishu
type ShareChatMessage struct {
MsgType MsgType `json:"msg_type"`
Content ShareChatContent `json:"content"`
}
type ShareChatContent struct {
ShareChatID string `json:"share_chat_id"`
}
func (m *ShareChatMessage) Body() map[string]interface{} {
m.MsgType = MsgTypeShareChat
return structToMap(m)
}
func NewShareChatMessage() *ShareChatMessage {
return &ShareChatMessage{}
}
func (m *ShareChatMessage) SetShareChatID(id string) *ShareChatMessage {
m.Content.ShareChatID = id
return m
}

View File

@ -1,24 +0,0 @@
package feishu
type TextMessage struct {
MsgType MsgType `json:"msg_type"`
Content Content `json:"content"`
}
type Content struct {
Text string `json:"text"`
}
func (m *TextMessage) Body() map[string]interface{} {
m.MsgType = MsgTypeText
return structToMap(m)
}
func NewTextMessage() *TextMessage {
return &TextMessage{}
}
func (m *TextMessage) SetText(text string) *TextMessage {
m.Content.Text = text
return m
}

View File

@ -1,3 +1,8 @@
// Package alipay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package alipay package alipay
import ( import (

View File

@ -1,3 +1,8 @@
// Package alipay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package alipay package alipay
import "github.com/gogf/gf/v2/os/gtime" import "github.com/gogf/gf/v2/os/gtime"

View File

@ -1,3 +1,8 @@
// Package payment
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package payment package payment
import "hotgo/internal/model" import "hotgo/internal/model"

View File

@ -1,3 +1,8 @@
// Package payment
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package payment package payment
import ( import (

View File

@ -1,3 +1,8 @@
// Package payment
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package payment package payment
import ( import (

View File

@ -1,3 +1,8 @@
// Package qqpay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package qqpay package qqpay
import ( import (

View File

@ -1,3 +1,8 @@
// Package qqpay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package qqpay package qqpay
// NotifyRequest QQ支付异步通知参数 // NotifyRequest QQ支付异步通知参数

View File

@ -1,3 +1,8 @@
// Package wxpay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package wxpay package wxpay
import ( import (

View File

@ -1 +1,6 @@
// Package wxpay
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package wxpay package wxpay

View File

@ -1,3 +1,8 @@
// Package queue
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package queue package queue
import ( import (

View File

@ -1,3 +1,8 @@
// Package queue
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package queue package queue
import ( import (

View File

@ -1,3 +1,8 @@
// Package disk
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package disk package disk
import ( import (

View File

@ -1,3 +1,8 @@
// Package disk
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package disk package disk
import ( import (

View File

@ -1,3 +1,8 @@
// Package disk
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package disk package disk
import ( import (

View File

@ -1,3 +1,8 @@
// Package queue
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package queue package queue
import ( import (

View File

@ -1,3 +1,8 @@
// Package queue
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package queue package queue
import ( import (

View File

@ -1,3 +1,8 @@
// Package sms
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package sms package sms
import ( import (

View File

@ -1,3 +1,8 @@
// Package sms
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package sms package sms
import ( import (

View File

@ -1,3 +1,8 @@
// Package sms
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package sms package sms
import ( import (

View File

@ -1,3 +1,8 @@
// Package sms
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package sms package sms
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
// FileMeta 文件元数据 // FileMeta 文件元数据

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package storager
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package storager package storager
import ( import (

View File

@ -1,3 +1,8 @@
// Package token
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package token package token
import ( import (

View File

@ -1,3 +1,8 @@
// Package wechat
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package wechat package wechat
import ( import (

View File

@ -1,3 +1,8 @@
// Package wechat
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package wechat package wechat
import "hotgo/internal/model" import "hotgo/internal/model"

View File

@ -1,3 +1,8 @@
// Package wechat
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package wechat package wechat
import ( import (

View File

@ -521,7 +521,7 @@ func (s *sAdminMember) Edit(ctx context.Context, in *adminin.MemberEditInp) (err
} }
// 更新岗位 // 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds); err != nil { if err = service.AdminMemberPost().UpdatePostIds(ctx, in.Id, in.PostIds); err != nil {
err = gerror.Wrap(err, "更新用户岗位失败,请稍后重试!") err = gerror.Wrap(err, "更新用户岗位失败,请稍后重试!")
} }
@ -557,7 +557,7 @@ func (s *sAdminMember) Edit(ctx context.Context, in *adminin.MemberEditInp) (err
} }
// 更新岗位 // 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds); err != nil { if err = service.AdminMemberPost().UpdatePostIds(ctx, id, in.PostIds); err != nil {
err = gerror.Wrap(err, "新增用户岗位失败,请稍后重试!") err = gerror.Wrap(err, "新增用户岗位失败,请稍后重试!")
} }

View File

@ -132,7 +132,7 @@ func (s *sAdminSite) Register(ctx context.Context, in *adminin.RegisterInp) (err
} }
// 更新岗位 // 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, config.PostIds); err != nil { if err = service.AdminMemberPost().UpdatePostIds(ctx, id, config.PostIds); err != nil {
err = gerror.Wrap(err, consts.ErrorORM) err = gerror.Wrap(err, consts.ErrorORM)
} }
return return

View File

@ -183,11 +183,22 @@ func (s *sSysCron) List(ctx context.Context, in *sysin.CronListInp) (list []*sys
} }
for _, v := range list { for _, v := range list {
v.GroupName, _ = dao.SysCronGroup.GetName(ctx, v.GroupId) v.GroupName, _ = s.GetName(ctx, v.GroupId)
} }
return return
} }
// GetName 获取分组名称
func (s *sSysCron) GetName(ctx context.Context, id int64) (name string, err error) {
m := dao.SysCronGroup.Ctx(ctx).Fields("name").Where("id", id)
list, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return name, err
}
return list.String(), nil
}
// OnlineExec 在线执行 // OnlineExec 在线执行
func (s *sSysCron) OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error) { func (s *sSysCron) OnlineExec(ctx context.Context, in *sysin.OnlineExecInp) (err error) {
var data *entity.SysCron var data *entity.SysCron

View File

@ -8,6 +8,7 @@ package sys
import ( import (
"context" "context"
"github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts" "hotgo/internal/consts"
"hotgo/internal/dao" "hotgo/internal/dao"
"hotgo/internal/model/input/sysin" "hotgo/internal/model/input/sysin"
@ -47,7 +48,7 @@ func (s *sSysDictData) Edit(ctx context.Context, in *sysin.DictDataEditInp) (err
} }
// 新增 // 新增
in.Type, err = dao.SysDictType.GetType(ctx, in.TypeID) in.Type, err = s.GetType(ctx, in.TypeID)
if err != nil { if err != nil {
err = gerror.Wrap(err, consts.ErrorORM) err = gerror.Wrap(err, consts.ErrorORM)
return err return err
@ -70,7 +71,7 @@ func (s *sSysDictData) List(ctx context.Context, in *sysin.DictDataListInp) (lis
mod := dao.SysDictData.Ctx(ctx) mod := dao.SysDictData.Ctx(ctx)
// 类型ID // 类型ID
if in.TypeID > 0 { if in.TypeID > 0 {
types, err := dao.SysDictType.GetTypes(ctx, in.TypeID) types, err := s.GetTypes(ctx, in.TypeID)
if err != nil { if err != nil {
return list, totalCount, err return list, totalCount, err
} }
@ -107,11 +108,42 @@ func (s *sSysDictData) List(ctx context.Context, in *sysin.DictDataListInp) (lis
} }
for _, v := range list { for _, v := range list {
v.TypeID, _ = dao.SysDictType.GetId(ctx, v.Type) v.TypeID, _ = s.GetId(ctx, v.Type)
} }
return list, totalCount, err return list, totalCount, err
} }
// GetId 获取指定类型的ID
func (s *sSysDictData) GetId(ctx context.Context, t string) (id int64, err error) {
m := dao.SysDictType.Ctx(ctx).Fields("id").Where("type", t).Where("status", consts.StatusEnabled)
val, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return 0, err
}
return val.Int64(), nil
}
// GetType 获取指定ID的类型标识
func (s *sSysDictData) GetType(ctx context.Context, id int64) (types string, err error) {
m := dao.SysDictType.Ctx(ctx).Fields("type").Where("id", id).Where("status", consts.StatusEnabled)
val, err := m.Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return types, err
}
return val.String(), nil
}
// GetTypes 获取指定ID的所有类型标识包含下级
func (s *sSysDictData) GetTypes(ctx context.Context, id int64) (types []string, err error) {
columns, err := dao.SysDictType.Ctx(ctx).Fields("type").
Where("id", id).WhereOr("pid", id).Where("status", consts.StatusEnabled).
Array()
types = g.NewVar(columns).Strings()
return
}
// Select 获取列表 // Select 获取列表
func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) { func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) {
mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type) mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type)

View File

@ -335,7 +335,7 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co
} }
if config.MaxIpLimit > 0 { if config.MaxIpLimit > 0 {
count, err := dao.SysEmsLog.NowDayCount(ctx, models.Event, models.Email) count, err := s.NowDayCount(ctx, models.Event, models.Email)
if err != nil { if err != nil {
return err return err
} }
@ -348,6 +348,15 @@ func (s *sSysEmsLog) AllowSend(ctx context.Context, models *entity.SysEmsLog, co
return return
} }
// NowDayCount 当天发送次数
func (s *sSysEmsLog) NowDayCount(ctx context.Context, event, email string) (count int, err error) {
return dao.SysEmsLog.Ctx(ctx).
Where("email", email).
Where("event", event).
WhereGTE("created_at", gtime.Now().Format("Y-m-d")).
Count()
}
// VerifyCode 效验验证码 // VerifyCode 效验验证码
func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error) { func (s *sSysEmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyEmsCodeInp) (err error) {
if in.Event == "" { if in.Event == "" {

View File

@ -245,7 +245,7 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co
} }
if config.SmsMaxIpLimit > 0 { if config.SmsMaxIpLimit > 0 {
count, err := dao.SysSmsLog.NowDayCount(ctx, models.Event, models.Mobile) count, err := s.NowDayCount(ctx, models.Event, models.Mobile)
if err != nil { if err != nil {
return err return err
} }
@ -258,6 +258,15 @@ func (s *sSysSmsLog) AllowSend(ctx context.Context, models *entity.SysSmsLog, co
return return
} }
// NowDayCount 当天发送次数
func (s *sSysSmsLog) NowDayCount(ctx context.Context, event, mobile string) (count int, err error) {
return dao.SysSmsLog.Ctx(ctx).
Where("mobile", mobile).
Where("event", event).
WhereGTE("created_at", gtime.Now().Format("Y-m-d")).
Count()
}
// VerifyCode 效验验证码 // VerifyCode 效验验证码
func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error) { func (s *sSysSmsLog) VerifyCode(ctx context.Context, in *sysin.VerifyCodeInp) (err error) {
if in.Event == "" { if in.Event == "" {

View File

@ -1,3 +1,8 @@
// Package model
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package model package model
// 后台配置. // 后台配置.

View File

@ -1,3 +1,8 @@
// Package model
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package model package model
// 本地配置. // 本地配置.

View File

@ -1,3 +1,8 @@
// Package model
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package model package model
// GenCodesColumn 生成表字段属性 // GenCodesColumn 生成表字段属性

View File

@ -1,3 +1,8 @@
// Package form
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package form package form
import ( import (

View File

@ -1,3 +1,8 @@
// Package form
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package form package form
import "github.com/gogf/gf/v2/util/gconv" import "github.com/gogf/gf/v2/util/gconv"

View File

@ -1,3 +1,8 @@
// Package payin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package payin package payin
import ( import (

View File

@ -1,3 +1,8 @@
// Package servmsgin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package servmsgin package servmsgin
import "github.com/gogf/gf/v2/os/gtime" import "github.com/gogf/gf/v2/os/gtime"

View File

@ -1,3 +1,8 @@
// Package servmsgin
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package servmsgin package servmsgin
import "github.com/gogf/gf/v2/os/gtime" import "github.com/gogf/gf/v2/os/gtime"

View File

@ -1,3 +1,8 @@
// Package convert
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package convert package convert
import ( import (

View File

@ -1,3 +1,8 @@
// Package simple
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package simple package simple
import ( import (

View File

@ -1,3 +1,8 @@
// Package url
// @Link https://github.com/bufanyun/hotgo
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package url package url
import ( import (

View File

@ -2,7 +2,7 @@
<div> <div>
<div class="n-layout-page-header"> <div class="n-layout-page-header">
<n-card :bordered="false" title="通知公告"> <n-card :bordered="false" title="通知公告">
在这里你可以发送通知公告私信到平台中的用户 在这里您可以向平台中的用户发送通知公告和私信消息
</n-card> </n-card>
</div> </div>
<n-card :bordered="false" class="proCard"> <n-card :bordered="false" class="proCard">

View File

@ -2,7 +2,7 @@
<div> <div>
<div class="n-layout-page-header"> <div class="n-layout-page-header">
<n-card :bordered="false" title="我的消息"> <n-card :bordered="false" title="我的消息">
在这里你可以查看平台中通知公告和与你相关的私信 在这里您可以方便地查看平台中的通知公告和与您相关的私信消息
</n-card> </n-card>
</div> </div>
<n-card :bordered="false" class="proCard"> <n-card :bordered="false" class="proCard">
@ -13,9 +13,9 @@
animated animated
@before-leave="handleBeforeLeave" @before-leave="handleBeforeLeave"
> >
<n-tab-pane name="1" tab="系统通知"> <List :type="defaultTab" /></n-tab-pane> <n-tab-pane name="1" tab="通知"> <List :type="defaultTab" /></n-tab-pane>
<n-tab-pane name="2" tab="系统公告"> <List :type="defaultTab" /> </n-tab-pane> <n-tab-pane name="2" tab="公告"> <List :type="defaultTab" /> </n-tab-pane>
<n-tab-pane name="3" tab="私信消息"> <List :type="defaultTab" /> </n-tab-pane> <n-tab-pane name="3" tab="私信"> <List :type="defaultTab" /> </n-tab-pane>
</n-tabs> </n-tabs>
</n-card> </n-card>
</div> </div>

View File

@ -56,7 +56,7 @@
import GroupModal from './modal/modal.vue'; import GroupModal from './modal/modal.vue';
import Edit from '@/views/monitor/netconn/modal/edit.vue'; import Edit from '@/views/monitor/netconn/modal/edit.vue';
import { newState, options, State } from '@/views/monitor/netconn/modal/model'; import { newState, options, State } from '@/views/monitor/netconn/modal/model';
import { defRangeShortcuts } from "@/utils/dateUtil"; import { defRangeShortcuts } from '@/utils/dateUtil';
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();

View File

@ -93,7 +93,7 @@
import DataItem from './components/DataItem.vue'; import DataItem from './components/DataItem.vue';
import LoadChart from './components/chart/LoadChart.vue'; import LoadChart from './components/chart/LoadChart.vue';
import FullYearSalesChart from './components/chart/FullYearSalesChart.vue'; import FullYearSalesChart from './components/chart/FullYearSalesChart.vue';
import { defineComponent, inject, onMounted, ref, onUpdated } from 'vue'; import { defineComponent, inject, onMounted, ref, onUnmounted } from 'vue';
import { SocketEnum } from '@/enums/socketEnum'; import { SocketEnum } from '@/enums/socketEnum';
import { addOnMessage, sendMsg } from '@/utils/websocket'; import { addOnMessage, sendMsg } from '@/utils/websocket';
import { formatBefore } from '@/utils/dateUtil'; import { formatBefore } from '@/utils/dateUtil';
@ -107,6 +107,7 @@
FullYearSalesChart, FullYearSalesChart,
}, },
setup() { setup() {
const timer = ref(0);
const dataRunInfo = ref({ const dataRunInfo = ref({
arch: '', arch: '',
goMem: '0MB', goMem: '0MB',
@ -180,7 +181,7 @@
const fullYearSalesChartRef = ref<InstanceType<typeof FullYearSalesChart>>(); const fullYearSalesChartRef = ref<InstanceType<typeof FullYearSalesChart>>();
const onMessageList = inject('onMessageList'); const onMessageList = inject('onMessageList');
const onAdminMonitor = (res) => { const onAdminMonitor = (res: { data: string }) => {
const data = JSON.parse(res.data); const data = JSON.parse(res.data);
if (data.event === SocketEnum.EventAdminMonitorRunInfo) { if (data.event === SocketEnum.EventAdminMonitorRunInfo) {
loading.value = false; loading.value = false;
@ -207,7 +208,14 @@
addOnMessage(onMessageList, onAdminMonitor); addOnMessage(onMessageList, onAdminMonitor);
onMounted(() => { onMounted(() => {
getInfo(); loading.value = true;
sendMsg(SocketEnum.EventAdminMonitorTrends);
sendMsg(SocketEnum.EventAdminMonitorRunInfo);
timer.value = window.setInterval(function () {
sendMsg(SocketEnum.EventAdminMonitorTrends);
sendMsg(SocketEnum.EventAdminMonitorRunInfo);
}, 2000);
setTimeout(() => { setTimeout(() => {
if (loading.value) { if (loading.value) {
@ -221,28 +229,10 @@
}, 5000); }, 5000);
}); });
onUpdated(() => { onUnmounted(() => {
// window.clearInterval(timer.value);
if (loading.value === false) {
sendMsg(SocketEnum.EventAdminMonitorTrends);
sendMsg(SocketEnum.EventAdminMonitorRunInfo);
}
}); });
function getInfo() {
loading.value = true;
sendMsg(SocketEnum.EventAdminMonitorTrends);
sendMsg(SocketEnum.EventAdminMonitorRunInfo);
setInterval(function () {
sendMsg(SocketEnum.EventAdminMonitorTrends);
}, 1000 * 2);
setInterval(function () {
sendMsg(SocketEnum.EventAdminMonitorRunInfo);
}, 1000 * 10);
}
return { return {
loading, loading,
collapse, collapse,

View File

@ -25,6 +25,7 @@
</n-space> </n-space>
<n-data-table <n-data-table
v-if="data.length > 0 || !loading"
:columns="columns" :columns="columns"
:data="data" :data="data"
:row-key="rowKey" :row-key="rowKey"
@ -317,6 +318,10 @@
return h(TableAction as any, { return h(TableAction as any, {
style: 'button', style: 'button',
actions: [ actions: [
{
label: '添加',
onClick: handleAddSub.bind(null, record),
},
{ {
label: '编辑', label: '编辑',
onClick: handleEdit.bind(null, record), onClick: handleEdit.bind(null, record),
@ -341,6 +346,12 @@
optionsDefaultValue.value = 0; optionsDefaultValue.value = 0;
} }
function handleAddSub(record: Recordable) {
showModal.value = true;
formParams.value = cloneDeep(defaultState);
optionsDefaultValue.value = record.id;
}
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
showModal.value = true; showModal.value = true;
formParams.value = cloneDeep(record); formParams.value = cloneDeep(record);

View File

@ -1,20 +1,8 @@
<template> <template>
<div> <div>
<div class="n-layout-page-header"> <n-card :bordered="false" title="角色管理">
<n-card :bordered="false" title="角色管理"> 在这里可以管理你权限下的角色权限</n-card> <n-space vertical :size="12">
</div> <n-space>
<n-card :bordered="false" class="mt-4 proCard">
<BasicTable
:columns="columns"
:request="loadDataTable"
:row-key="(row) => row.id"
ref="actionRef"
:actionColumn="actionColumn"
@update:checked-row-keys="onCheckedRow"
:pagination="false"
:resizeHeightOffset="-20000"
>
<template #tableTitle>
<n-button type="primary" @click="addTable"> <n-button type="primary" @click="addTable">
<template #icon> <template #icon>
<n-icon> <n-icon>
@ -23,8 +11,18 @@
</template> </template>
添加角色 添加角色
</n-button> </n-button>
</template> </n-space>
</BasicTable>
<n-data-table
v-if="data.length > 0 || !loading"
:columns="columns.concat(actionColumn)"
:data="data"
:row-key="(row) => row.id"
:loading="loading"
:resizeHeightOffset="-20000"
default-expand-all
/>
</n-space>
</n-card> </n-card>
<n-modal v-model:show="showModal" :show-icon="false" preset="dialog" :title="editRoleTitle"> <n-modal v-model:show="showModal" :show-icon="false" preset="dialog" :title="editRoleTitle">
@ -155,8 +153,8 @@
<script lang="ts" setup> <script lang="ts" setup>
import { h, onMounted, reactive, ref } from 'vue'; import { h, onMounted, reactive, ref } from 'vue';
import { useDialog, useMessage } from 'naive-ui'; import { NButton, useDialog, useMessage } from 'naive-ui';
import { BasicColumn, BasicTable, TableAction } from '@/components/Table'; import { BasicColumn, TableAction } from '@/components/Table';
import { import {
Delete, Delete,
Edit, Edit,
@ -195,6 +193,8 @@
const dataFormBtnLoading = ref(false); const dataFormBtnLoading = ref(false);
const showDataModal = ref(false); const showDataModal = ref(false);
const dataForm = ref<any>(); const dataForm = ref<any>();
const loading = ref(false);
const data = ref<any>([]);
const rules = { const rules = {
name: { name: {
@ -270,12 +270,18 @@
}); });
const loadDataTable = async (res: any) => { const loadDataTable = async (res: any) => {
return await getRoleList({ ...res, ...{ pageSize: 100, page: 1 } }); loading.value = true;
const tmp = await getRoleList({ ...res, ...{ pageSize: 100, page: 1 } });
data.value = tmp?.list;
if (data.value === undefined || data.value === null) {
data.value = [];
}
loading.value = false;
}; };
function onCheckedRow(rowKeys: any[]) { onMounted(async () => {
console.log(rowKeys); await loadDataTable({});
} });
function reloadTable() { function reloadTable() {
actionRef.value.reload(); actionRef.value.reload();