发布v2.3.5版本,本次为优化版本。更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md

This commit is contained in:
孟帅
2023-02-26 14:18:22 +08:00
parent 34c373c11e
commit ab912d0ba6
111 changed files with 3068 additions and 9329 deletions

View File

@@ -41,7 +41,7 @@ var (
---------------------------------------------------------------------------------
更多
github地址https://github.com/bufanyun/hotgo
文档地址https://github.com/bufanyun/hotgo/tree/v2.0/docs
文档地址https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN
HotGo框架交流1群190966648
`,
}

View File

@@ -3,14 +3,13 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
//
package cmd
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gcmd"
"hotgo/internal/queues"
"hotgo/internal/library/queue"
)
var (
@@ -20,7 +19,8 @@ var (
Description: ``,
Func: func(ctx context.Context, parser *gcmd.Parser) (err error) {
g.Log().Debug(ctx, "start queue consumer..")
queues.Run(ctx)
queue.StartConsumersListener(ctx)
g.Log().Debug(ctx, "start queue consumer success..")
return
},
}

View File

@@ -7,5 +7,5 @@ package consts
// VersionApp HotGo版本
const (
VersionApp = "2.2.10"
VersionApp = "2.3.5"
)

View File

@@ -90,23 +90,8 @@ func (c *cDept) List(ctx context.Context, req *dept.ListReq) (res *dept.ListRes,
return
}
res = (*dept.ListRes)(&data)
return
}
// ListTree 查看列表树
func (c *cDept) ListTree(ctx context.Context, req *dept.ListTreeReq) (res *dept.ListTreeRes, err error) {
var in adminin.DeptListTreeInp
if err = gconv.Scan(req, &in); err != nil {
return
}
data, err := service.AdminDept().ListTree(ctx, in)
if err != nil {
return
}
res = (*dept.ListTreeRes)(&data)
res = new(dept.ListRes)
res.List = data.List
return
}

View File

@@ -15,6 +15,7 @@ import (
"hotgo/internal/model/input/adminin"
"hotgo/internal/model/input/form"
"hotgo/internal/service"
"hotgo/utility/validate"
)
var (
@@ -165,6 +166,10 @@ func (c *cMember) Edit(ctx context.Context, req *member.EditReq) (res *member.Ed
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
in.PostIds = req.PostIds
err = service.AdminMember().Edit(ctx, in)
return

View File

@@ -55,7 +55,7 @@ func (c *cRole) List(ctx context.Context, req *role.ListReq) (res *role.ListRes,
}
res = new(role.ListRes)
res.List = list
res.RoleListModel = list
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
res.Page = req.Page
res.PerPage = req.PerPage

View File

@@ -100,11 +100,12 @@ func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res
// Select 选项
func (c *cCronGroup) Select(ctx context.Context, req *cron.GroupSelectReq) (res *cron.GroupSelectRes, err error) {
list, err := service.SysCronGroup().Select(ctx, sysin.CronGroupSelectInp{})
data, err := service.SysCronGroup().Select(ctx, sysin.CronGroupSelectInp{})
if err != nil {
return
}
res = (*cron.GroupSelectRes)(&list)
res = new(cron.GroupSelectRes)
res.CronGroupSelectModel = data
return
}

View File

@@ -48,14 +48,3 @@ func (c *cDictType) Edit(ctx context.Context, req *dict.TypeEditReq) (res *dict.
err = service.SysDictType().Edit(ctx, in)
return
}
// Select 选项
func (c *cDictType) Select(ctx context.Context, req *dict.TypeSelectReq) (res *dict.TypeSelectRes, err error) {
list, err := service.SysDictType().Select(ctx, sysin.DictTypeSelectInp{})
if err != nil {
return
}
res = (*dict.TypeSelectRes)(&list)
return
}

View File

@@ -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 admin
import (
@@ -71,7 +70,7 @@ func (c *cMonitor) RunInfo(client *websocket.Client, req *websocket.WRequest) {
"goName": "Golang",
"version": runtime.Version(),
"startTime": meta.STartTime,
"runTime": gtime.Now().Timestamp() - meta.STartTime.Timestamp(),
"runTime": gtime.Now().Timestamp() - meta.STartTime,
"rootPath": runtime.GOROOT(),
"pwd": pwd,
"goroutine": runtime.NumGoroutine(),
@@ -108,7 +107,7 @@ func (c *cMonitor) Trends(client *websocket.Client, req *websocket.WRequest) {
mMemUsed float64
mDisk, _ = disk.Usage("/")
mProcess, _ = process.Pids()
mLoadAvg *model.LoadAvgStats
mLoadAvg = new(model.LoadAvgStats)
data = g.Map{}
monitorHeads []MonitorHead
nets []NetC

View File

@@ -13,20 +13,24 @@ import (
// Build 构建新插件
func Build(ctx context.Context, sk Skeleton, conf *model.BuildAddonConfig) (err error) {
buildPath := "./" + consts.AddonsDir + "/" + sk.Name
modulesPath := "./" + consts.AddonsDir + "/modules/" + sk.Name + ".go"
templatePath := gstr.Replace(conf.TemplatePath, "{$name}", sk.Name)
replaces := map[string]string{
"@{.label}": sk.Label,
"@{.name}": sk.Name,
"@{.group}": strconv.Itoa(sk.Group),
"@{.brief}": sk.Brief,
"@{.description}": sk.Description,
"@{.author}": sk.Author,
"@{.version}": sk.Version,
}
var (
buildPath = "./" + consts.AddonsDir + "/" + sk.Name
modulesPath = "./" + consts.AddonsDir + "/modules/" + sk.Name + ".go"
templatePath = gstr.Replace(conf.TemplatePath, "{$name}", sk.Name)
webApiPath = gstr.Replace(conf.WebApiPath, "{$name}", sk.Name)
webViewsPath = gstr.Replace(conf.WebViewsPath, "{$name}", sk.Name)
replaces = map[string]string{
"@{.label}": sk.Label,
"@{.name}": sk.Name,
"@{.group}": strconv.Itoa(sk.Group),
"@{.brief}": sk.Brief,
"@{.description}": sk.Description,
"@{.author}": sk.Author,
"@{.version}": sk.Version,
}
)
if err = checkBuildDir(buildPath, modulesPath, templatePath); err != nil {
if err = checkBuildDir(buildPath, modulesPath, templatePath, webApiPath, webViewsPath); err != nil {
return
}
@@ -49,7 +53,6 @@ func Build(ctx context.Context, sk Skeleton, conf *model.BuildAddonConfig) (err
gfile.RealPath(conf.SrcPath): "",
".template": "",
})
flowFile = buildPath + "/" + flowFile
content := gstr.ReplaceByMap(gfile.GetContents(path), replaces)
@@ -59,11 +62,31 @@ func Build(ctx context.Context, sk Skeleton, conf *model.BuildAddonConfig) (err
}
}
if err = gfile.PutContents(templatePath+"/home/index.html", homeLayout); err != nil {
// 隐式注入插件
if err = gfile.PutContents(modulesPath, gstr.ReplaceByMap(importModules, replaces)); err != nil {
return
}
err = gfile.PutContents(modulesPath, gstr.ReplaceByMap(importModules, replaces))
// home默认页面
if err = gfile.PutContents(templatePath+"/home/index.html", gstr.ReplaceByMap(homeLayout, replaces)); err != nil {
return
}
// webApi
if err = gfile.PutContents(webApiPath+"/config/index.ts", gstr.ReplaceByMap(webApiLayout, replaces)); err != nil {
return
}
// web插件配置主页面
if err = gfile.PutContents(webViewsPath+"/config/BasicSetting.vue", gstr.ReplaceByMap(webConfigBasicSetting, replaces)); err != nil {
return
}
// web插件基础配置页面
if err = gfile.PutContents(webViewsPath+"/config/system.vue", gstr.ReplaceByMap(webConfigSystem, replaces)); err != nil {
return
}
return
}
@@ -79,48 +102,3 @@ func checkBuildDir(paths ...string) error {
}
return nil
}
const (
importModules = `// Package modules
// @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 modules
import _ "hotgo/addons/@{.name}"
`
homeLayout = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
<meta name="keywords" content="@{.Keywords}"/>
<meta name="description" content="@{.Description}"/>
<title>@{.Title}</title>
<script type="text/javascript" src="/resource/home/js/jquery-3.6.0.min.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #f6f6f6;
}
</style>
</head>
<body>
<div style="padding-top: 100px;text-align:center;">
<h1><p>Hello@{.Data.name}!!</p></h1>
<h2><p>@{.Data.module}</p></h2>
<h2><p>服务器时间:@{.Data.time}</p></h2>
</div>
</body>
<script>
</script>
</html>`
)

View File

@@ -0,0 +1,225 @@
package addons
const (
importModules = `// Package modules
// @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 modules
import _ "hotgo/addons/@{.name}"
`
homeLayout = `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=no">
<meta name="keywords" content="@{.Keywords}"/>
<meta name="description" content="@{.Description}"/>
<title>@{.Title}</title>
<script type="text/javascript" src="/resource/home/js/jquery-3.6.0.min.js"></script>
<style>
html, body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
background-color: #f6f6f6;
}
</style>
</head>
<body>
<div style="padding-top: 100px;text-align:center;">
<h1><p>Hello@{.Data.name}!!</p></h1>
<h2><p>@{.Data.module}</p></h2>
<h2><p>服务器时间:@{.Data.time}</p></h2>
</div>
</body>
<script>
</script>
</html>`
webApiLayout = `import { http } from '@/utils/http/axios';
export function getConfig(params) {
return http.request({
url: '/@{.name}/config/get',
method: 'get',
params,
});
}
export function updateConfig(params) {
return http.request({
url: '/@{.name}/config/update',
method: 'post',
params,
});
}
`
webConfigBasicSetting = `<template>
<div>
<n-spin :show="show" description="请稍候...">
<n-form :label-width="80" :model="formValue" :rules="rules" ref="formRef">
<n-form-item label="测试参数" path="basicTest">
<n-input v-model:value="formValue.basicTest" placeholder="请输入测试参数" />
<template #feedback>
这是一个测试参数,每个插件都可以有独立的配置项,可以按需添加</template
>
</n-form-item>
<div>
<n-space>
<n-button type="primary" @click="formSubmit">保存更新</n-button>
</n-space>
</div>
</n-form>
</n-spin>
</div>
</template>
<script lang="ts" setup>
import { ref, onMounted } from 'vue';
import { useMessage } from 'naive-ui';
import { getConfig, updateConfig } from '@/api/addons/@{.name}/config';
const group = ref('basic');
const show = ref(false);
const rules = {
basicTest: {
required: true,
message: '请输入测试参数',
trigger: 'blur',
},
};
const formRef: any = ref(null);
const message = useMessage();
const formValue = ref({
basicTest: 'HotGo',
});
function formSubmit() {
formRef.value.validate((errors) => {
if (!errors) {
updateConfig({ group: group.value, list: formValue.value }).then((_res) => {
message.success('更新成功');
load();
});
} else {
message.error('验证失败,请填写完整信息');
}
});
}
onMounted(() => {
load();
});
function load() {
show.value = true;
new Promise((_resolve, _reject) => {
getConfig({ group: group.value })
.then((res) => {
formValue.value = res.list;
})
.finally(() => {
show.value = false;
});
});
}
</script>
`
webConfigSystem = `<template>
<div>
<n-grid cols="24 300:1 600:24" :x-gap="24">
<n-grid-item span="6">
<n-card :bordered="false" size="small" class="proCard">
<n-thing
class="thing-cell"
v-for="item in typeTabList"
:key="item.key"
:class="{ 'thing-cell-on': type === item.key }"
@click="switchType(item)"
>
<template #header>{{ item.name }}</template>
<template #description>{{ item.desc }}</template>
</n-thing>
</n-card>
</n-grid-item>
<n-grid-item span="18">
<n-card :bordered="false" size="small" :title="typeTitle" class="proCard">
<BasicSetting v-if="type === 1" />
</n-card>
</n-grid-item>
</n-grid>
</div>
</template>
<script lang="ts">
import { defineComponent, reactive, toRefs } from 'vue';
import BasicSetting from './BasicSetting.vue';
const typeTabList = [
{
name: '基本设置',
desc: '系统常规设置',
key: 1,
},
];
export default defineComponent({
components: {
BasicSetting,
},
setup() {
const state = reactive({
type: 1,
typeTitle: '基本设置',
});
function switchType(e) {
state.type = e.key;
state.typeTitle = e.name;
}
return {
...toRefs(state),
switchType,
typeTabList,
};
},
});
</script>
<style lang="less" scoped>
.thing-cell {
margin: 0 -16px 10px;
padding: 5px 16px;
&:hover {
background: #f3f3f3;
cursor: pointer;
}
}
.thing-cell-on {
background: #f0faff;
color: #2d8cf0;
::v-deep(.n-thing-main .n-thing-header .n-thing-header__title) {
color: #2d8cf0;
}
&:hover {
background: #f0faff;
}
}
</style>
`
)

View File

@@ -66,11 +66,12 @@ func RegisterModulesRouter(ctx context.Context, group *ghttp.RouterGroup) {
func RegisterModule(m Module) Module {
mLock.Lock()
defer mLock.Unlock()
_, ok := modules[m.GetSkeleton().Name]
name := m.GetSkeleton().Name
_, ok := modules[name]
if ok {
panic("module repeat registration, name:" + m.GetSkeleton().Name)
panic("module repeat registration, name:" + name)
}
modules[m.GetSkeleton().Name] = m
modules[name] = m
return m
}

View File

@@ -107,6 +107,15 @@ func GetRoleKey(ctx context.Context) string {
return user.RoleKey
}
// GetModule 获取应用模块
func GetModule(ctx context.Context) string {
c := Get(ctx)
if c == nil {
return ""
}
return c.Module
}
// SetAddonName 设置插件信息
func SetAddonName(ctx context.Context, name string) {
c := Get(ctx)

View File

@@ -256,11 +256,6 @@ func setDefaultQuery(field *sysin.GenCodesColumnListModel) {
return
}
if field.Index == consts.GenCodesIndexPK {
field.IsQuery = true
return
}
if gstr.HasSuffix(field.GoName, "Status") && IsNumberType(field.GoType) {
field.IsQuery = true
return

View File

@@ -126,7 +126,7 @@ func (l *gCurd) generateWebEditScript(ctx context.Context, in *CurdPreviewInput)
}
setupBuffer.WriteString(" function loadForm(value) {\n loading.value = true;\n\n // 新增\n if (value.id < 1) {\n params.value = newState(value);\n MaxSort()\n .then((res) => {\n params.value.sort = res.sort;\n })\n .finally(() => {\n loading.value = false;\n });\n return;\n }\n\n // 编辑\n View({ id: value.id })\n .then((res) => {\n params.value = res;\n })\n .finally(() => {\n loading.value = false;\n });\n }\n\n watch(\n () => props.formParams,\n (value) => {\n loadForm(value);\n }\n );")
} else {
importBuffer.WriteString(" import { onMounted, ref, computed } from 'vue';\n")
importBuffer.WriteString(" import { onMounted, ref, computed, watch } from 'vue';\n")
if in.Config.Application.Crud.Templates[in.In.GenTemplate].IsAddon {
importBuffer.WriteString(" import { Edit, View } from '@/api/addons/" + in.In.AddonName + "/" + gstr.LcFirst(in.In.VarName) + "';\n")
} else {

View File

@@ -52,11 +52,11 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
err := g.Model("admin_role").Where("id", co.User.RoleId).Scan(&role)
if err != nil {
g.Log().Fatalf(ctx, "failed to role information err:%+v", err)
g.Log().Panicf(ctx, "failed to role information err:%+v", err)
}
if role == nil {
g.Log().Fatalf(ctx, "failed to role information roleModel == nil")
g.Log().Panicf(ctx, "failed to role information roleModel == nil")
}
sq := g.Model("admin_member").Fields("id")
@@ -77,7 +77,7 @@ func FilterAuthWithField(filterField string) func(m *gdb.Model) *gdb.Model {
case consts.RoleDataSelfAndAllSub: // 自己和全部下级
m = m.WhereIn(filterField, GetSelfAndAllSub(co.User.Id))
default:
g.Log().Fatalf(ctx, "dataScope is not registered")
g.Log().Panicf(ctx, "dataScope is not registered")
}
return m

View File

@@ -0,0 +1,73 @@
package queue
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"sync"
)
// consumerStrategy 消费者策略,实现该接口即可加入到消费队列中
type consumerStrategy interface {
GetTopic() string // 获取消费主题
Handle(ctx context.Context, mqMsg MqMsg) (err error) // 处理消息
}
// consumerManager 消费者管理
type consumerManager struct {
sync.Mutex
list map[string]consumerStrategy // 维护的消费者列表
}
var consumers = &consumerManager{
list: make(map[string]consumerStrategy),
}
// RegisterConsumer 注册任务到消费者队列
func RegisterConsumer(cs consumerStrategy) {
consumers.Lock()
defer consumers.Unlock()
topic := cs.GetTopic()
if _, ok := consumers.list[topic]; ok {
g.Log().Debugf(ctx, "queue.RegisterConsumer topic:%v duplicate registration.", topic)
return
}
consumers.list[topic] = cs
}
// StartConsumersListener 启动所有已注册的消费者监听
func StartConsumersListener(ctx context.Context) {
for _, consumer := range consumers.list {
go func(consumer consumerStrategy) {
consumerListen(ctx, consumer)
}(consumer)
}
}
// consumerListen 消费者监听
func consumerListen(ctx context.Context, job consumerStrategy) {
var (
topic = job.GetTopic()
consumer, err = InstanceConsumer()
)
if err != nil {
g.Log().Fatalf(ctx, "InstanceConsumer %s err:%+v", topic, err)
return
}
if listenErr := consumer.ListenReceiveMsgDo(topic, func(mqMsg MqMsg) {
err = job.Handle(ctx, mqMsg)
if err != nil {
// 遇到错误,重新加入到队列
//queue.Push(topic, mqMsg.Body)
}
// 记录消费队列日志
ConsumerLog(ctx, topic, mqMsg, err)
}); listenErr != nil {
g.Log().Fatalf(ctx, "消费队列:%s 监听失败, err:%+v", topic, listenErr)
}
}

View File

@@ -11,6 +11,8 @@ import (
"time"
)
// Disk 磁盘队列
type DiskProducerMq struct {
config *disk.Config
producers map[string]*disk.Queue

View File

@@ -66,7 +66,7 @@ func CreateClient(accessKeyId *string, accessKeySecret *string) (_result *dysmsa
return _result, _err
}
func Send(accessKeyId string, accessKeySecret string) (_err error) {
func TestSend(accessKeyId string, accessKeySecret string) (_err error) {
// 工程代码泄露可能会导致AccessKey泄露并威胁账号下所有资源的安全性。以下代码示例仅供参考建议使用更安全的 STS 方式更多鉴权访问方式请参见https://help.aliyun.com/document_detail/378661.html
client, _err := CreateClient(tea.String(accessKeyId), tea.String(accessKeySecret))
if _err != nil {

View File

@@ -10,7 +10,6 @@ import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/hgorm"
@@ -18,7 +17,6 @@ import (
"hotgo/internal/model/input/adminin"
"hotgo/internal/service"
"hotgo/utility/convert"
"hotgo/utility/tree"
"hotgo/utility/validate"
)
@@ -33,27 +31,21 @@ func init() {
}
// NameUnique 菜单名称是否唯一
func (s *sAdminDept) NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (*adminin.DeptNameUniqueModel, error) {
var res adminin.DeptNameUniqueModel
func (s *sAdminDept) NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (res *adminin.DeptNameUniqueModel, err error) {
isUnique, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return nil, err
return
}
res = new(adminin.DeptNameUniqueModel)
res.IsUnique = isUnique
return &res, nil
return
}
// Delete 删除
func (s *sAdminDept) Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error) {
var (
models *entity.AdminDept
)
err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Scan(&models)
if err != nil {
var models *entity.AdminDept
if err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
return err
}
@@ -71,115 +63,86 @@ func (s *sAdminDept) Delete(ctx context.Context, in adminin.DeptDeleteInp) (err
}
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Delete()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// Edit 修改/新增
func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err error) {
if in.Name == "" {
err = gerror.New("名称不能为空")
return err
return
}
uniqueName, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
return
}
if !uniqueName {
err = gerror.New("名称已存在")
return err
return
}
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminDept, in.Pid)
if err != nil {
return err
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminDept, in.Pid); err != nil {
return
}
// 修改
if in.Id > 0 {
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data(in).Update()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// 新增
_, err = dao.AdminDept.Ctx(ctx).Data(in).Insert()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// Status 更新部门状态
func (s *sAdminDept) Status(ctx context.Context, in adminin.DeptStatusInp) (err error) {
if in.Id <= 0 {
err = gerror.New("ID不能为空")
return err
return
}
if in.Status <= 0 {
err = gerror.New("状态不能为空")
return err
return
}
if !validate.InSliceInt(consts.StatusMap, in.Status) {
err = gerror.New("状态不正确")
return err
return
}
// 修改
in.UpdatedAt = gtime.Now()
_, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// MaxSort 最大排序
func (s *sAdminDept) MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (*adminin.DeptMaxSortModel, error) {
var res adminin.DeptMaxSortModel
func (s *sAdminDept) MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error) {
res = new(adminin.DeptMaxSortModel)
if in.Id > 0 {
if err := dao.AdminDept.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
if err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return nil, err
return
}
}
res.Sort = res.Sort + 10
return &res, nil
return
}
// View 获取指定字典类型信息
func (s *sAdminDept) View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error) {
if err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return nil, err
}
return res, nil
err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Scan(&res)
return
}
// List 获取列表
func (s *sAdminDept) List(ctx context.Context, in adminin.DeptListInp) (list adminin.DeptListModel, err error) {
func (s *sAdminDept) List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error) {
var (
mod = dao.AdminDept.Ctx(ctx)
models []*entity.AdminDept
@@ -228,114 +191,12 @@ func (s *sAdminDept) List(ctx context.Context, in adminin.DeptListInp) (list adm
if err = mod.Order("pid asc,sort asc").Scan(&models); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, err
return
}
list = gconv.SliceMap(models)
for k, v := range list {
list[k]["index"] = v["id"]
list[k]["key"] = v["id"]
list[k]["label"] = v["name"]
}
return tree.GenTree(list), nil
}
type DeptTree struct {
entity.AdminDept
Children []*DeptTree `json:"children"`
}
// getDeptChildIds 将列表转为父子关系列表
func (s *sAdminDept) getDeptChildIds(ctx context.Context, lists []*DeptTree, pid int64) []*DeptTree {
var (
count = len(lists)
newLists []*DeptTree
)
if count == 0 {
return nil
}
for i := 0; i < len(lists); i++ {
if lists[i].Id > 0 && lists[i].Pid == pid {
var row *DeptTree
if err := gconv.Structs(lists[i], &row); err != nil {
panic(err)
}
row.Children = s.getDeptChildIds(ctx, lists, row.Id)
newLists = append(newLists, row)
}
}
return newLists
}
type DeptListTree struct {
Id int64 `json:"id" `
Key int64 `json:"key" `
Pid int64 `json:"pid" `
Label string `json:"label"`
Title string `json:"title"`
Name string `json:"name"`
Type string `json:"type"`
Children []*DeptListTree `json:"children"`
}
// ListTree 获取列表树
func (s *sAdminDept) ListTree(ctx context.Context, in adminin.DeptListTreeInp) (list []*adminin.DeptListTreeModel, err error) {
var (
mod = dao.AdminDept.Ctx(ctx)
dataList []*entity.AdminDept
models []*DeptListTree
)
err = mod.Order("id desc").Scan(&dataList)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, err
}
_ = gconv.Structs(dataList, &models)
// 重写树入参
for i := 0; i < len(models); i++ {
models[i].Key = models[i].Id
models[i].Title = models[i].Name
models[i].Label = models[i].Name
}
childIds := s.getDeptTreeChildIds(ctx, models, 0)
_ = gconv.Structs(childIds, &list)
return list, nil
}
// getDeptTreeChildIds 将列表转为父子关系列表
func (s *sAdminDept) getDeptTreeChildIds(ctx context.Context, lists []*DeptListTree, pid int64) []*DeptListTree {
var (
count = len(lists)
newLists []*DeptListTree
)
if count == 0 {
return nil
}
for i := 0; i < len(lists); i++ {
if lists[i].Id > 0 && lists[i].Pid == pid {
var row *DeptListTree
if err := gconv.Structs(lists[i], &row); err != nil {
panic(err)
}
row.Children = s.getDeptTreeChildIds(ctx, lists, row.Id)
newLists = append(newLists, row)
}
}
return newLists
res = new(adminin.DeptListModel)
res.List = s.treeList(0, models)
return
}
// GetName 获取部门名称
@@ -352,3 +213,23 @@ func (s *sAdminDept) GetName(ctx context.Context, id int64) (name string, err er
return data.Name, nil
}
// treeList 树状列表
func (s *sAdminDept) treeList(pid int64, nodes []*entity.AdminDept) (list []*adminin.DeptTree) {
list = make([]*adminin.DeptTree, 0)
for _, v := range nodes {
if v.Pid == pid {
item := new(adminin.DeptTree)
item.AdminDept = *v
item.Label = v.Name
item.Value = v.Id
child := s.treeList(v.Id, nodes)
if len(child) > 0 {
item.Children = child
}
list = append(list, item)
}
}
return
}

View File

@@ -256,6 +256,7 @@ func (s *sAdminMember) ResetPwd(ctx context.Context, in adminin.MemberResetPwdIn
memberInfo *entity.AdminMember
memberId = contexts.GetUserId(ctx)
)
if err = s.FilterAuthModel(ctx, memberId).Where("id", in.Id).Scan(&memberInfo); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
@@ -400,10 +401,18 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return gerror.New("超管账号禁止编辑!")
}
// 权限验证
var mm = s.FilterAuthModel(ctx, opMemberId).Where("id", in.Id)
_, err = mm.Data(in).Update()
if err != nil {
mod := s.FilterAuthModel(ctx, opMemberId)
if in.Password != "" {
salt, err := s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).Fields(dao.AdminMember.Columns().Salt).Where("id", in.Id).Value()
if err != nil {
return err
}
in.PasswordHash = gmd5.MustEncryptString(in.Password + salt.String())
} else {
mod = mod.FieldsEx(dao.AdminMember.Columns().PasswordHash)
}
if _, err = mod.Where("id", in.Id).Data(in).Update(); err != nil {
return gerror.Wrap(err, consts.ErrorORM)
}

View File

@@ -25,18 +25,18 @@ func init() {
service.RegisterAdminMemberPost(NewAdminMemberPost())
}
func (s *sAdminMemberPost) UpdatePostIds(ctx context.Context, member_id int64, post_ids []int64) (err error) {
_, err = dao.AdminMemberPost.Ctx(ctx).Where("member_id", member_id).Delete()
func (s *sAdminMemberPost) UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error) {
_, err = dao.AdminMemberPost.Ctx(ctx).Where("member_id", memberId).Delete()
if err != nil {
err = gerror.Wrap(err, "删除失败")
return err
}
for i := 0; i < len(post_ids); i++ {
for i := 0; i < len(postIds); i++ {
_, err = dao.AdminMemberPost.Ctx(ctx).
Insert(entity.AdminMemberPost{
MemberId: member_id,
PostId: post_ids[i],
MemberId: memberId,
PostId: postIds[i],
})
if err != nil {
err = gerror.Wrap(err, "插入用户岗位失败")
@@ -48,20 +48,20 @@ func (s *sAdminMemberPost) UpdatePostIds(ctx context.Context, member_id int64, p
}
// GetMemberByIds 获取指定用户的岗位ids
func (s *sAdminMemberPost) GetMemberByIds(ctx context.Context, member_id int64) (post_ids []int64, err error) {
func (s *sAdminMemberPost) GetMemberByIds(ctx context.Context, memberId int64) (postIds []int64, err error) {
var list []*entity.AdminMemberPost
err = dao.AdminMemberPost.Ctx(ctx).
Fields("post_id").
Where("member_id", member_id).
Where("member_id", memberId).
Scan(&list)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return post_ids, err
return postIds, err
}
for i := 0; i < len(list); i++ {
post_ids = append(post_ids, list[i].PostId)
postIds = append(postIds, list[i].PostId)
}
return post_ids, nil
return postIds, nil
}

View File

@@ -34,7 +34,7 @@ func init() {
// StartMonitor 启动服务监控
func (s *sAdminMonitor) StartMonitor(ctx context.Context) {
simple.SafeGo(ctx, func(ctx context.Context) {
s.data.STartTime = gtime.Now()
s.data.STartTime = gtime.Now().Timestamp()
intranetIP, err := location.GetLocalIP()
if err != nil {
g.Log().Infof(ctx, "parse intranetIP err:%+v", err)

View File

@@ -12,7 +12,6 @@ import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/api/admin/role"
"hotgo/internal/consts"
"hotgo/internal/dao"
@@ -25,9 +24,7 @@ import (
"hotgo/internal/service"
"hotgo/utility/auth"
"hotgo/utility/convert"
"hotgo/utility/tree"
"sort"
"strconv"
)
type sAdminRole struct{}
@@ -69,31 +66,26 @@ func (s *sAdminRole) Verify(ctx context.Context, path, method string) bool {
}
// List 获取列表
func (s *sAdminRole) List(ctx context.Context, in adminin.RoleListInp) (list []g.Map, totalCount int, err error) {
func (s *sAdminRole) List(ctx context.Context, in adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error) {
var (
mod = dao.AdminRole.Ctx(ctx)
models []*adminin.RoleListModel
models []*entity.AdminRole
)
totalCount, err = mod.Count()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, totalCount, err
return
}
err = mod.Page(in.Page, in.PerPage).Order("id asc").Scan(&models)
if err != nil {
if err = mod.Page(in.Page, in.PerPage).Order("sort asc,id asc").Scan(&models); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, totalCount, err
return
}
for _, v := range models {
v.Label = v.Name
v.Value = v.Id
v.Key = strconv.FormatInt(v.Id, 10)
}
return tree.GenTree(gconv.SliceMap(models)), totalCount, err
res = new(adminin.RoleListModel)
res.List = s.treeList(0, models)
return
}
// GetName 获取指定角色的名称
@@ -134,6 +126,7 @@ func (s *sAdminRole) GetPermissions(ctx context.Context, reqInfo *role.GetPermis
if err != nil {
return nil, err
}
if len(values) == 0 {
return
}
@@ -156,6 +149,10 @@ func (s *sAdminRole) UpdatePermissions(ctx context.Context, reqInfo *role.Update
if len(reqInfo.MenuIds) == 0 {
return nil
}
// 去重
reqInfo.MenuIds = convert.UniqueSliceInt64(reqInfo.MenuIds)
addMap := make(g.List, 0, len(reqInfo.MenuIds))
for _, v := range reqInfo.MenuIds {
addMap = append(addMap, g.Map{
@@ -163,8 +160,8 @@ func (s *sAdminRole) UpdatePermissions(ctx context.Context, reqInfo *role.Update
"menu_id": v,
})
}
_, err = dao.AdminRoleMenu.Ctx(ctx).Data(addMap).Insert()
if err != nil {
if _, err = dao.AdminRoleMenu.Ctx(ctx).Data(addMap).Insert(); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
@@ -176,56 +173,47 @@ func (s *sAdminRole) UpdatePermissions(ctx context.Context, reqInfo *role.Update
func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
if in.Name == "" {
err = gerror.New("名称不能为空")
return err
return
}
if in.Key == "" {
err = gerror.New("编码不能为空")
return err
return
}
uniqueName, err := dao.AdminRole.IsUniqueName(ctx, in.Id, in.Name)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
return
}
if !uniqueName {
err = gerror.New("名称已存在")
return err
return
}
uniqueCode, err := dao.AdminRole.IsUniqueCode(ctx, in.Id, in.Key)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
return
}
if !uniqueCode {
err = gerror.New("编码已存在")
return err
return
}
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminRole, in.Pid)
if err != nil {
return err
if in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.AdminRole, in.Pid); err != nil {
return
}
// 修改
if in.Id > 0 {
_, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Data(in).Update()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// 新增
_, err = dao.AdminRole.Ctx(ctx).Data(in).Insert()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error) {
@@ -233,12 +221,9 @@ func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error)
return gerror.New("ID不正确")
}
var (
models *entity.AdminRole
)
err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models)
if err != nil {
return err
var models *entity.AdminRole
if err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
return
}
if models == nil {
@@ -255,12 +240,7 @@ func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error)
}
_, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Delete()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
func (s *sAdminRole) DataScopeSelect(ctx context.Context) (res form.Selects) {
@@ -285,8 +265,7 @@ func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEdi
superRoleKey = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
)
err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models)
if err != nil {
if err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
return
}
@@ -310,10 +289,26 @@ func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEdi
Where("id", in.Id).
Data(models).
Update()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
}
return nil
return
}
// treeList 树状列表
func (s *sAdminRole) treeList(pid int64, nodes []*entity.AdminRole) (list []*adminin.RoleTree) {
list = make([]*adminin.RoleTree, 0)
for _, v := range nodes {
if v.Pid == pid {
item := new(adminin.RoleTree)
item.AdminRole = *v
item.Label = v.Name
item.Value = v.Id
child := s.treeList(v.Id, nodes)
if len(child) > 0 {
item.Children = child
}
list = append(list, item)
}
}
return
}

View File

@@ -20,11 +20,7 @@ import (
// AdminAuth 后台鉴权中间件
func (s *sMiddleware) AdminAuth(r *ghttp.Request) {
var (
ctx = r.Context()
)
var ctx = r.Context()
// 替换掉模块前缀
routerPrefix := g.Cfg().MustGet(ctx, "router.admin.prefix", "/admin")
path := gstr.Replace(r.URL.Path, routerPrefix.String(), "", 1)

View File

@@ -9,14 +9,12 @@ package sys
import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/tree"
"hotgo/utility/validate"
)
@@ -157,31 +155,39 @@ func (s *sSysCronGroup) List(ctx context.Context, in sysin.CronGroupListInp) (li
}
// Select 选项
func (s *sSysCronGroup) Select(ctx context.Context, in sysin.CronGroupSelectInp) (list sysin.CronGroupSelectModel, err error) {
func (s *sSysCronGroup) Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error) {
var (
mod = dao.SysCronGroup.Ctx(ctx)
models []*entity.SysCronGroup
typeList []g.Map
mod = dao.SysCronGroup.Ctx(ctx)
models []*entity.SysCronGroup
)
if err = mod.Order("pid asc,sort asc").Scan(&models); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, err
return
}
for i := 0; i < len(models); i++ {
typeList = append(typeList, g.Map{
"index": models[i].Id,
"key": models[i].Id,
"label": models[i].Name,
"id": models[i].Id,
"pid": models[i].Pid,
"name": models[i].Name,
"sort": models[i].Sort,
"created_at": models[i].CreatedAt,
"status": models[i].Status,
})
}
return tree.GenTree(typeList), nil
res = new(sysin.CronGroupSelectModel)
res.List = s.treeList(0, models)
return
}
// treeList 树状列表
func (s *sSysCronGroup) treeList(pid int64, nodes []*entity.SysCronGroup) (list []*sysin.CronGroupTree) {
list = make([]*sysin.CronGroupTree, 0)
for _, v := range nodes {
if v.Pid == pid {
item := new(sysin.CronGroupTree)
item.SysCronGroup = *v
item.Label = v.Name
item.Value = v.Id
item.Key = v.Id
child := s.treeList(v.Id, nodes)
if len(child) > 0 {
item.Children = child
}
list = append(list, item)
}
}
return
}

View File

@@ -9,14 +9,12 @@ package sys
import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/tree"
)
type sSysDictType struct{}
@@ -30,35 +28,19 @@ func init() {
}
// Tree 树
func (s *sSysDictType) Tree(ctx context.Context) (list []g.Map, err error) {
func (s *sSysDictType) Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error) {
var (
mod = dao.SysDictType.Ctx(ctx)
models []*entity.SysDictType
)
if err = mod.Order("pid asc,sort asc").Scan(&models); err != nil {
if err = mod.Order("sort asc,id asc").Scan(&models); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, err
}
for i := 0; i < len(models); i++ {
list = append(list, g.Map{
"index": models[i].Id,
"key": models[i].Id,
"label": models[i].Name,
"id": models[i].Id,
"pid": models[i].Pid,
"name": models[i].Name,
"type": models[i].Type,
"sort": models[i].Sort,
"remark": models[i].Remark,
"status": models[i].Status,
"updated_at": models[i].UpdatedAt,
"created_at": models[i].CreatedAt,
})
}
return tree.GenTree(list), nil
list = s.treeList(0, models)
return
}
// Delete 删除
@@ -141,42 +123,11 @@ func (s *sSysDictType) Edit(ctx context.Context, in sysin.DictTypeEditInp) (err
return nil
}
// Select 选项
func (s *sSysDictType) Select(ctx context.Context, in sysin.DictTypeSelectInp) (list sysin.DictTypeSelectModel, err error) {
var (
mod = dao.SysDictType.Ctx(ctx)
models []*entity.SysDictType
typeList []g.Map
)
if err = mod.Order("pid asc,sort asc").Scan(&models); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return list, err
}
for i := 0; i < len(models); i++ {
typeList = append(typeList, g.Map{
"index": models[i].Id,
"key": models[i].Id,
"label": models[i].Name,
"id": models[i].Id,
"pid": models[i].Pid,
"name": models[i].Name,
"sort": models[i].Sort,
"created_at": models[i].CreatedAt,
"status": models[i].Status,
})
}
return tree.GenTree(typeList), nil
}
// TreeSelect 获取类型关系树选项
func (s *sSysDictType) TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list sysin.DictTreeSelectModel, err error) {
func (s *sSysDictType) TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error) {
var (
mod = dao.SysDictType.Ctx(ctx)
models []*entity.SysDictType
typeList []g.Map
mod = dao.SysDictType.Ctx(ctx)
models []*entity.SysDictType
)
if err = mod.Order("pid asc,sort asc").Scan(&models); err != nil {
@@ -184,26 +135,39 @@ func (s *sSysDictType) TreeSelect(ctx context.Context, in sysin.DictTreeSelectIn
return list, err
}
for i := 0; i < len(models); i++ {
typeList = append(typeList, g.Map{
"index": models[i].Id,
"key": models[i].Id,
"label": models[i].Name,
"id": models[i].Id,
"pid": models[i].Pid,
"name": models[i].Name,
"sort": models[i].Sort,
"created_at": models[i].CreatedAt,
"status": models[i].Status,
})
}
list = s.treeList(0, models)
maps := tree.GenTree(typeList)
for _, v := range maps {
for _, v := range list {
// 父类一律禁止选中
if _, ok := v["children"]; ok {
v["disabled"] = true
if len(v.Children) > 0 {
v.Disabled = true
for _, v2 := range v.Children {
if len(v2.Children) > 0 {
v2.Disabled = true
}
}
}
}
return tree.GenTree(typeList), nil
return
}
// treeList 树状列表
func (s *sSysDictType) treeList(pid int64, nodes []*entity.SysDictType) (list []*sysin.DictTypeTree) {
list = make([]*sysin.DictTypeTree, 0)
for _, v := range nodes {
if v.Pid == pid {
item := new(sysin.DictTypeTree)
item.SysDictType = *v
item.Label = v.Name
item.Value = v.Id
item.Key = v.Id
child := s.treeList(v.Id, nodes)
if len(child) > 0 {
item.Children = child
}
list = append(list, item)
}
}
return
}

View File

@@ -166,6 +166,8 @@ type GenerateConfig struct {
type BuildAddonConfig struct {
SrcPath string `json:"srcPath"`
TemplatePath string `json:"templatePath"`
WebApiPath string `json:"webApiPath"`
WebViewsPath string `json:"webViewsPath"`
}
// CacheConfig 缓存配置

View File

@@ -7,7 +7,6 @@
package adminin
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/model/entity"
)
@@ -57,34 +56,18 @@ type DeptListInp struct {
Code string
}
// DeptTreeDept
type DeptTreeDept struct {
// DeptTree 树
type DeptTree struct {
entity.AdminDept
Children []*DeptTreeDept `json:"children"`
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Children []*DeptTree `json:"children"`
}
type DeptListModel []g.Map
// DeptListTreeInp 获取列表树
type DeptListTreeInp struct {
Name string
Code string
type DeptListModel struct {
List []*DeptTree `json:"list"`
}
// DeptListTreeDept 树
type DeptListTreeDept struct {
Id int64 `json:"id" `
Key int64 `json:"key" `
Pid int64 `json:"pid" `
Label string `json:"label"`
Title string `json:"title"`
Name string `json:"name"`
Type string `json:"type"`
Children []*DeptListTreeDept `json:"children"`
}
type DeptListTreeModel DeptListTreeDept
// DeptStatusInp 更新部门状态
type DeptStatusInp struct {
entity.AdminDept

View File

@@ -7,6 +7,8 @@
package adminin
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
@@ -44,13 +46,13 @@ type MemberProfileInp struct {
Id int64
}
type MemberProfileModel struct {
PostGroup string `json:"postGroup" description:"岗位名称"`
RoleGroup string `json:"roleGroup" description:"角色名称"`
User *MemberViewModel `json:"member" description:"用户基本信息"`
SysDept *DeptViewModel `json:"sysDept" description:"部门信息"`
SysRoles []*RoleListModel `json:"sysRoles" description:"角色列表"`
PostIds int64 `json:"postIds" description:"当前岗位"`
RoleIds int64 `json:"roleIds" description:"当前角色"`
PostGroup string `json:"postGroup" dc:"岗位名称"`
RoleGroup string `json:"roleGroup" dc:"角色名称"`
User *MemberViewModel `json:"member" dc:"用户基本信息"`
SysDept *DeptViewModel `json:"sysDept" dc:"部门信息"`
SysRoles []*RoleListModel `json:"sysRoles" dc:"角色列表"`
PostIds int64 `json:"postIds" dc:"当前岗位"`
RoleIds int64 `json:"roleIds" dc:"当前角色"`
}
// MemberUpdateProfileInp 更新用户资料
@@ -118,36 +120,48 @@ type MemberMaxSortModel struct {
// MemberEditInp 修改/新增管理员
type MemberEditInp struct {
Id int64 `json:"id" description:""`
RoleId int `json:"roleId" v:"required#角色不能为空" description:"角色ID"`
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" description:"岗位ID"`
DeptId int64 `json:"deptId" v:"required#部门不能为空" description:"部门ID"`
Username string `json:"username" v:"required#账号不能为空" description:"帐号"`
Password string `json:"password" description:"密码"`
RealName string `json:"realName" description:"真实姓名"`
Avatar string `json:"avatar" description:"头像"`
Sex string `json:"sex" description:"性别"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Birthday *gtime.Time `json:"birthday" description:"生日"`
ProvinceId int `json:"provinceId" description:"省"`
CityId int `json:"cityId" description:"城市"`
AreaId int `json:"areaId" description:"地区"`
Address string `json:"address" description:"默认地址"`
Mobile string `json:"mobile" description:"手机号码"`
Remark string `json:"remark" description:"备注"`
Status string `json:"status" description:"状态"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
Id int64 `json:"id" dc:""`
RoleId int `json:"roleId" v:"required#角色不能为空" dc:"角色ID"`
PostIds []int64 `json:"postIds" v:"required#岗位不能为空" dc:"岗位ID"`
DeptId int64 `json:"deptId" v:"required#部门不能为空" dc:"部门ID"`
Username string `json:"username" v:"required#账号不能为空" dc:"帐号"`
PasswordHash string `json:"passwordHash" dc:"密码hash"`
Password string `json:"password" dc:"密码"`
RealName string `json:"realName" dc:"真实姓名"`
Avatar string `json:"avatar" dc:"头像"`
Sex string `json:"sex" dc:"性别"`
Qq string `json:"qq" dc:"qq"`
Email string `json:"email" dc:"邮箱"`
Birthday *gtime.Time `json:"birthday" dc:"生日"`
ProvinceId int `json:"provinceId" dc:"省"`
CityId int `json:"cityId" dc:"城市"`
AreaId int `json:"areaId" dc:"地区"`
Address string `json:"address" dc:"默认地址"`
Mobile string `json:"mobile" dc:"手机号码"`
Remark string `json:"remark" dc:"备注"`
Status string `json:"status" dc:"状态"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
}
type MemberAddInp struct {
MemberEditInp
PasswordHash string `json:"passwordHash" description:"密码hash"`
Salt string `json:"salt" description:"密码盐"`
Pid int64 `json:"pid" description:"上级ID"`
Level int `json:"level" description:"等级"`
Tree string `json:"tree" description:"关系树"`
Salt string `json:"salt" dc:"密码盐"`
Pid int64 `json:"pid" dc:"上级ID"`
Level int `json:"level" dc:"等级"`
Tree string `json:"tree" dc:"关系树"`
}
func (in *MemberEditInp) Filter(ctx context.Context) (err error) {
if in.Password != "" {
if err := g.Validator().
Rules("length:6,16").
Messages("#新密码不能为空#新密码需在6~16之间").
Data(in.Password).Run(ctx); err != nil {
return err.Current()
}
}
return
}
type MemberEditModel struct{}
@@ -165,8 +179,8 @@ type MemberViewInp struct {
type MemberViewModel struct {
entity.AdminMember
DeptName string `json:"deptName" description:"所属部门"`
RoleName string `json:"roleName" description:"所属角色"`
DeptName string `json:"deptName" dc:"所属部门"`
RoleName string `json:"roleName" dc:"所属角色"`
}
// MemberListInp 获取列表
@@ -174,21 +188,21 @@ type MemberListInp struct {
form.PageReq
form.RangeDateReq
form.StatusReq
DeptId int `json:"deptId" dc:"部门ID"`
Mobile int `json:"mobile" dc:"手机号"`
DeptId int `json:"deptId" dc:"部门ID"`
Mobile int `json:"mobile" dc:"手机号"`
Username string `json:"username" dc:"用户名"`
RealName string `json:"realName" dc:"真实姓名"`
Name string `json:"name" dc:"岗位名称"`
Code string `json:"code" dc:"岗位编码"`
CreatedAt []int64 `json:"createdAt" dc:"创建时间"`
Name string `json:"name" dc:"岗位名称"`
Code string `json:"code" dc:"岗位编码"`
CreatedAt []int64 `json:"createdAt" dc:"创建时间"`
}
type MemberListModel struct {
entity.AdminMember
DeptName string `json:"deptName" description:"所属部门"`
RoleName string `json:"roleName" description:"所属角色"`
PostIds []int64 `json:"postIds" description:"岗位"`
DeptId int64 `json:"deptId" description:"部门ID"`
DeptName string `json:"deptName" dc:"所属部门"`
RoleName string `json:"roleName" dc:"所属角色"`
PostIds []int64 `json:"postIds" dc:"岗位"`
DeptId int64 `json:"deptId" dc:"部门ID"`
}
// MemberLoginInp 登录
@@ -197,31 +211,31 @@ type MemberLoginInp struct {
Password string
}
type MemberLoginModel struct {
Id int64 `json:"id" description:"用户ID"`
Token string `json:"token" description:"登录token"`
Expires int64 `json:"expires" description:"登录有效期"`
Id int64 `json:"id" dc:"用户ID"`
Token string `json:"token" dc:"登录token"`
Expires int64 `json:"expires" dc:"登录有效期"`
}
type LoginMemberInfoModel struct {
Id int64 `json:"id" description:"用户ID"`
DeptName string `json:"deptName" description:"所属部门"`
RoleName string `json:"roleName" description:"所属角色"`
Permissions []string `json:"permissions" description:"角色信息"`
DeptId int64 `json:"-" description:"部门ID"`
RoleId int64 `json:"-" description:"角色ID"`
Username string `json:"username" description:"用户名"`
RealName string `json:"realName" description:"姓名"`
Avatar string `json:"avatar" description:"头像"`
Balance float64 `json:"balance" description:"余额"`
Sex int `json:"sex" description:"性别"`
Qq string `json:"qq" description:"qq"`
Email string `json:"email" description:"邮箱"`
Mobile string `json:"mobile" description:"手机号码"`
Birthday *gtime.Time `json:"birthday" description:"生日"`
CityId int64 `json:"cityId" description:"城市编码"`
Address string `json:"address" description:"联系地址"`
Cash *MemberCash `json:"cash" description:"收款信息"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
Id int64 `json:"id" dc:"用户ID"`
DeptName string `json:"deptName" dc:"所属部门"`
RoleName string `json:"roleName" dc:"所属角色"`
Permissions []string `json:"permissions" dc:"角色信息"`
DeptId int64 `json:"-" dc:"部门ID"`
RoleId int64 `json:"-" dc:"角色ID"`
Username string `json:"username" dc:"用户名"`
RealName string `json:"realName" dc:"姓名"`
Avatar string `json:"avatar" dc:"头像"`
Balance float64 `json:"balance" dc:"余额"`
Sex int `json:"sex" dc:"性别"`
Qq string `json:"qq" dc:"qq"`
Email string `json:"email" dc:"邮箱"`
Mobile string `json:"mobile" dc:"手机号码"`
Birthday *gtime.Time `json:"birthday" dc:"生日"`
CityId int64 `json:"cityId" dc:"城市编码"`
Address string `json:"address" dc:"联系地址"`
Cash *MemberCash `json:"cash" dc:"收款信息"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
*MemberLoginStatModel
}
@@ -246,10 +260,10 @@ type MemberSelectInp struct {
}
type MemberSelectModel struct {
Value int64 `json:"value" dc:"用户ID"`
Label string `json:"label" dc:"真实姓名"`
Value int64 `json:"value" dc:"用户ID"`
Label string `json:"label" dc:"真实姓名"`
Username string `json:"username" dc:"用户名"`
Avatar string `json:"avatar" dc:"头像"`
Avatar string `json:"avatar" dc:"头像"`
}
// MemberLoginStatInp 用户登录统计

View File

@@ -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 adminin
import (
@@ -123,9 +122,7 @@ type MenuRouteMeta struct {
FrameSrc string `json:"frameSrc,omitempty" ` // 内联外部地址
Permissions string `json:"permissions,omitempty"` // 菜单包含权限集合,满足其中一个就会显示
Affix bool `json:"affix,omitempty"` // 是否固定 设置为 true 之后 多页签不可删除
// 自定义
Type int `json:"type"` // 菜单类型
Type int `json:"type"` // 菜单类型
}
type MenuRoute struct {

View File

@@ -10,6 +10,7 @@ import (
"hotgo/internal/model"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
"sort"
)
// RoleListInp 获取列表
@@ -17,10 +18,27 @@ type RoleListInp struct {
form.PageReq
}
type RoleListModel struct {
type RoleTree struct {
entity.AdminRole
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Children []*RoleTree `json:"children" dc:"子级"`
}
type RoleListModel struct {
List []*RoleTree `json:"list"`
}
func Sort(v []*RoleTree) {
sort.SliceStable(v, func(i, j int) bool {
if v[i].Sort < v[j].Sort {
return true
}
if v[i].Sort > v[j].Sort {
return false
}
return v[i].Id < v[j].Id
})
}
// RoleMemberListInp 查询列表
@@ -28,15 +46,15 @@ type RoleMemberListInp struct {
form.PageReq
form.RangeDateReq
form.StatusReq
Role int `json:"role" description:"角色ID"`
DeptId int `json:"deptId" description:"部门ID"`
Mobile int `json:"mobile" description:"手机号"`
Username string `json:"username" description:"用户名"`
Realname string `json:"realname" description:"真实姓名"`
StartTime string `json:"start_time" description:"开始时间"`
EndTime string `json:"end_time" description:"结束时间"`
Name string `json:"name" description:"岗位名称"`
Code string `json:"code" description:"岗位编码"`
Role int `json:"role" dc:"角色ID"`
DeptId int `json:"deptId" dc:"部门ID"`
Mobile int `json:"mobile" dc:"手机号"`
Username string `json:"username" dc:"用户名"`
RealName string `json:"realName" dc:"真实姓名"`
StartTime string `json:"start_time" dc:"开始时间"`
EndTime string `json:"end_time" dc:"结束时间"`
Name string `json:"name" dc:"岗位名称"`
Code string `json:"code" dc:"岗位编码"`
}
type RoleMemberListModel []*MemberListModel
@@ -46,12 +64,12 @@ type MenuRoleListInp struct {
RoleId int64
}
type MenuRoleListModel struct {
Menus []*model.LabelTreeMenu `json:"menus" description:"菜单列表"`
CheckedKeys []int64 `json:"checkedKeys" description:"选择的菜单ID"`
Menus []*model.LabelTreeMenu `json:"menus" dc:"菜单列表"`
CheckedKeys []int64 `json:"checkedKeys" dc:"选择的菜单ID"`
}
type DataScopeEditInp struct {
Id int64 `json:"id" v:"required" dc:"角色ID"`
Id int64 `json:"id" v:"required" dc:"角色ID"`
DataScope int `json:"dataScope" v:"required" dc:"数据范围"`
CustomDept []int64 `json:"customDept" dc:"自定义部门权限"`
CustomDept []int64 `json:"customDept" dc:"自定义部门权限"`
}

View File

@@ -7,7 +7,6 @@
package sysin
import (
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
)
@@ -64,4 +63,15 @@ type CronGroupStatusModel struct{}
type CronGroupSelectInp struct {
}
type CronGroupSelectModel []g.Map
type CronGroupSelectModel struct {
List []*CronGroupTree `json:"list"`
}
type CronGroupTree struct {
entity.SysCronGroup
Disabled bool `json:"disabled" dc:"是否禁用"`
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Key int64 `json:"key" dc:"键名"`
Children []*CronGroupTree `json:"children" dc:"子级"`
}

View File

@@ -23,14 +23,17 @@ type DictTypeDeleteInp struct {
}
type DictTypeDeleteModel struct{}
// DictTypeSelectInp 获取类型选项
type DictTypeSelectInp struct {
}
type DictTypeSelectModel []g.Map
// DictTreeSelectInp 获取类型关系树选项
type DictTreeSelectInp struct {
}
type DictTreeSelectModel []g.Map
type DictTypeTree struct {
entity.SysDictType
Disabled bool `json:"disabled" dc:"是否禁用"`
Label string `json:"label" dc:"标签"`
Value int64 `json:"value" dc:"键值"`
Key int64 `json:"key" dc:"键名"`
Children []*DictTypeTree `json:"children" dc:"子级"`
}

View File

@@ -83,11 +83,11 @@ type GenCodesSelectsModel struct {
LinkMode form.Selects `json:"linkMode" dc:"关联表方式"`
BuildMeth form.Selects `json:"buildMeth" dc:"生成方式"`
// 字段表格选项
FormMode form.Selects `json:"formMode" dc:"表单组件"`
FormRole form.Selects `json:"formRole" dc:"表单验证"`
DictMode DictTreeSelectModel `json:"dictMode" dc:"字典类型"`
WhereMode form.Selects `json:"whereMode" dc:"查询条件"`
Addons form.Selects `json:"addons" dc:"插件选项"`
FormMode form.Selects `json:"formMode" dc:"表单组件"`
FormRole form.Selects `json:"formRole" dc:"表单验证"`
DictMode []*DictTypeTree `json:"dictMode" dc:"字典类型"`
WhereMode form.Selects `json:"whereMode" dc:"查询条件"`
Addons form.Selects `json:"addons" dc:"插件选项"`
}
type GenTypeSelects []*GenTypeSelect

View File

@@ -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 model
import (
@@ -12,7 +11,7 @@ import (
type MonitorData struct {
// STartTime 启动时间
STartTime *gtime.Time
STartTime int64
// 内网IP
IntranetIP string
// 公网IP

View File

@@ -1,70 +0,0 @@
// Package queues
// @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 queues
import (
"context"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/library/queue"
)
type jobStrategy interface {
getTopic() string
handle(ctx context.Context, mqMsg queue.MqMsg) (err error)
}
var jobList []jobStrategy
func Run(ctx context.Context) {
for _, job := range uniqueJob(jobList) {
go func(job jobStrategy) {
listen(ctx, job)
}(job)
}
}
func listen(ctx context.Context, job jobStrategy) {
var (
topic = job.getTopic()
consumer, err = queue.InstanceConsumer()
)
if err != nil {
g.Log().Fatalf(ctx, "InstanceConsumer %s err:%+v", topic, err)
return
}
// 访问日志
if listenErr := consumer.ListenReceiveMsgDo(topic, func(mqMsg queue.MqMsg) {
err = job.handle(ctx, mqMsg)
if err != nil {
// 遇到错误,重新加入到队列
//queue.Push(topic, mqMsg.Body)
}
// 记录队列日志
queue.ConsumerLog(ctx, topic, mqMsg, err)
}); listenErr != nil {
g.Log().Fatalf(ctx, "队列:%s 监听失败, err:%+v", topic, listenErr)
}
}
// uniqueJob 去重
func uniqueJob(languages []jobStrategy) []jobStrategy {
result := make([]jobStrategy, 0, len(languages))
temp := map[jobStrategy]struct{}{}
for _, item := range languages {
if _, ok := temp[item]; !ok {
temp[item] = struct{}{}
result = append(result, item)
}
}
return result
}

View File

@@ -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 queues
import (
@@ -16,7 +15,7 @@ import (
)
func init() {
jobList = append(jobList, LoginLog)
queue.RegisterConsumer(LoginLog)
}
// LoginLog 登录日志
@@ -24,13 +23,13 @@ var LoginLog = &qLoginLog{}
type qLoginLog struct{}
// getTopic 主题
func (q *qLoginLog) getTopic() string {
// GetTopic 主题
func (q *qLoginLog) GetTopic() string {
return consts.QueueLoginLogTopic
}
// handle 处理消息
func (q *qLoginLog) handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
// Handle 处理消息
func (q *qLoginLog) Handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
var data entity.SysLoginLog
if err = json.Unmarshal(mqMsg.Body, &data); err != nil {
return err

View File

@@ -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 queues
import (
@@ -16,7 +15,7 @@ import (
)
func init() {
jobList = append(jobList, ServeLog)
queue.RegisterConsumer(ServeLog)
}
// ServeLog 登录日志
@@ -24,13 +23,13 @@ var ServeLog = &qServeLog{}
type qServeLog struct{}
// getTopic 主题
func (q *qServeLog) getTopic() string {
// GetTopic 主题
func (q *qServeLog) GetTopic() string {
return consts.QueueServeLogTopic
}
// handle 处理消息
func (q *qServeLog) handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
// Handle 处理消息
func (q *qServeLog) Handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
var data entity.SysServeLog
if err = json.Unmarshal(mqMsg.Body, &data); err != nil {
return err

View File

@@ -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 queues
import (
@@ -16,7 +15,7 @@ import (
)
func init() {
jobList = append(jobList, SysLog)
queue.RegisterConsumer(SysLog)
}
// SysLog 系统日志
@@ -24,13 +23,13 @@ var SysLog = &qSysLog{}
type qSysLog struct{}
// getTopic 主题
func (q *qSysLog) getTopic() string {
// GetTopic 主题
func (q *qSysLog) GetTopic() string {
return consts.QueueLogTopic
}
// handle 处理消息
func (q *qSysLog) handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
// Handle 处理消息
func (q *qSysLog) Handle(ctx context.Context, mqMsg queue.MqMsg) (err error) {
var data entity.SysLog
if err = json.Unmarshal(mqMsg.Body, &data); err != nil {
return err

View File

@@ -38,11 +38,11 @@ func WebSocket(ctx context.Context, group *ghttp.RouterGroup) {
// 注册消息路由
websocket.RegisterMsg(websocket.EventHandlers{
"ping": common.Site.Ping, // 心跳
"join": common.Site.Join, // 加入组
"quit": common.Site.Quit, // 退出组
"adminMonitorTrends": admin.Monitor.Trends, // 后台监控,动态数据
"adminMonitorRunInfo": admin.Monitor.RunInfo, // 后台监控,运行信息
"ping": common.Site.Ping, // 心跳
"join": common.Site.Join, // 加入组
"quit": common.Site.Quit, // 退出组
"admin/monitor/trends": admin.Monitor.Trends, // 后台监控,动态数据
"admin/monitor/runInfo": admin.Monitor.RunInfo, // 后台监控,运行信息
})
}

View File

@@ -15,14 +15,9 @@ import (
"hotgo/internal/model/input/form"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/frame/g"
)
type (
IAdminMonitor interface {
StartMonitor(ctx context.Context)
GetMeta(ctx context.Context) *model.MonitorData
}
IAdminNotice interface {
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
Delete(ctx context.Context, in adminin.NoticeDeleteInp) error
@@ -50,7 +45,7 @@ type (
}
IAdminRole interface {
Verify(ctx context.Context, path, method string) bool
List(ctx context.Context, in adminin.RoleListInp) (list []g.Map, totalCount int, err error)
List(ctx context.Context, in adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error)
GetName(ctx context.Context, RoleId int64) (name string, err error)
GetMemberList(ctx context.Context, RoleId int64) (list []*adminin.RoleListModel, err error)
GetPermissions(ctx context.Context, reqInfo *role.GetPermissionsReq) (MenuIds []int64, err error)
@@ -61,14 +56,13 @@ type (
DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error)
}
IAdminDept interface {
NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (*adminin.DeptNameUniqueModel, error)
NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (res *adminin.DeptNameUniqueModel, err error)
Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error)
Edit(ctx context.Context, in adminin.DeptEditInp) (err error)
Status(ctx context.Context, in adminin.DeptStatusInp) (err error)
MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (*adminin.DeptMaxSortModel, error)
MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error)
View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error)
List(ctx context.Context, in adminin.DeptListInp) (list adminin.DeptListModel, err error)
ListTree(ctx context.Context, in adminin.DeptListTreeInp) (list []*adminin.DeptListTreeModel, err error)
List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error)
GetName(ctx context.Context, id int64) (name string, err error)
}
IAdminMember interface {
@@ -97,8 +91,8 @@ type (
MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error)
}
IAdminMemberPost interface {
UpdatePostIds(ctx context.Context, member_id int64, post_ids []int64) (err error)
GetMemberByIds(ctx context.Context, member_id int64) (post_ids []int64, err error)
UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
GetMemberByIds(ctx context.Context, memberId int64) (postIds []int64, err error)
}
IAdminMenu interface {
RoleList(ctx context.Context, in adminin.MenuRoleListInp) (*adminin.MenuRoleListModel, error)
@@ -113,9 +107,14 @@ type (
GetMenuList(ctx context.Context, memberId int64) (lists role.DynamicRes, err error)
LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error)
}
IAdminMonitor interface {
StartMonitor(ctx context.Context)
GetMeta(ctx context.Context) *model.MonitorData
}
)
var (
localAdminPost IAdminPost
localAdminRole IAdminRole
localAdminDept IAdminDept
localAdminMember IAdminMember
@@ -123,7 +122,6 @@ var (
localAdminMenu IAdminMenu
localAdminMonitor IAdminMonitor
localAdminNotice IAdminNotice
localAdminPost IAdminPost
)
func AdminDept() IAdminDept {

View File

@@ -17,6 +17,20 @@ import (
)
type (
ISysAddonsConfig interface {
GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) error
}
ISysAttachment interface {
Delete(ctx context.Context, in sysin.AttachmentDeleteInp) error
Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (*sysin.AttachmentMaxSortModel, error)
View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (data *entity.SysAttachment, err error)
}
ISysBlacklist interface {
Delete(ctx context.Context, in sysin.BlacklistDeleteInp) (err error)
Edit(ctx context.Context, in sysin.BlacklistEditInp) (err error)
@@ -27,12 +41,6 @@ type (
VariableLoad(ctx context.Context, err error)
Load(ctx context.Context)
}
ISysDictData interface {
Delete(ctx context.Context, in sysin.DictDataDeleteInp) error
Edit(ctx context.Context, in sysin.DictDataEditInp) (err error)
List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
}
ISysEmsLog interface {
Delete(ctx context.Context, in sysin.EmsLogDeleteInp) error
Edit(ctx context.Context, in sysin.EmsLogEditInp) (err error)
@@ -44,60 +52,6 @@ type (
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp) (err error)
}
ISysLog interface {
Export(ctx context.Context, in sysin.LogListInp) (err error)
RealWrite(ctx context.Context, commonLog entity.SysLog) (err error)
AutoLog(ctx context.Context) error
AnalysisLog(ctx context.Context) entity.SysLog
View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error)
Delete(ctx context.Context, in sysin.LogDeleteInp) (err error)
List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
}
ISysConfig interface {
GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error)
GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error)
GetSms(ctx context.Context) (conf *model.SmsConfig, err error)
GetGeo(ctx context.Context) (conf *model.GeoConfig, err error)
GetUpload(ctx context.Context) (conf *model.UploadConfig, err error)
GetSmtp(ctx context.Context) (conf *model.EmailConfig, err error)
GetBasic(ctx context.Context) (conf *model.BasicConfig, err error)
GetLoadSSL(ctx context.Context) (conf *model.SSLConfig, err error)
GetLoadLog(ctx context.Context) (conf *model.LogConfig, err error)
GetLoadServeLog(ctx context.Context) (conf *model.ServeLogConfig, err error)
GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (*sysin.GetConfigModel, error)
ConversionType(ctx context.Context, models *entity.SysConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) error
}
ISysCron interface {
StartCron(ctx context.Context)
Delete(ctx context.Context, in sysin.CronDeleteInp) (err error)
Edit(ctx context.Context, in sysin.CronEditInp) (err error)
Status(ctx context.Context, in sysin.CronStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
View(ctx context.Context, in sysin.CronViewInp) (res *sysin.CronViewModel, err error)
List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error)
}
ISysCronGroup interface {
Delete(ctx context.Context, in sysin.CronGroupDeleteInp) error
Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error)
Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (*sysin.CronGroupMaxSortModel, error)
View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
Select(ctx context.Context, in sysin.CronGroupSelectInp) (list sysin.CronGroupSelectModel, err error)
}
ISysCurdDemo interface {
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
List(ctx context.Context, in sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
Export(ctx context.Context, in sysin.CurdDemoListInp) (err error)
Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error)
Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error)
MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error)
Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error)
}
ISysGenCodes interface {
Delete(ctx context.Context, in sysin.GenCodesDeleteInp) error
Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
@@ -112,56 +66,6 @@ type (
Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
Build(ctx context.Context, in sysin.GenCodesBuildInp) (err error)
}
ISysAddons interface {
List(ctx context.Context, in sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error)
Selects(ctx context.Context, in sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error)
Build(ctx context.Context, in sysin.AddonsBuildInp) (err error)
Install(ctx context.Context, in sysin.AddonsInstallInp) (err error)
Upgrade(ctx context.Context, in sysin.AddonsUpgradeInp) (err error)
UnInstall(ctx context.Context, in sysin.AddonsUnInstallInp) (err error)
}
ISysAddonsConfig interface {
GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) error
}
ISysDictType interface {
Tree(ctx context.Context) (list []g.Map, err error)
Delete(ctx context.Context, in sysin.DictTypeDeleteInp) error
Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error)
Select(ctx context.Context, in sysin.DictTypeSelectInp) (list sysin.DictTypeSelectModel, err error)
TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list sysin.DictTreeSelectModel, err error)
}
ISysLoginLog interface {
Model(ctx context.Context) *gdb.Model
List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
Export(ctx context.Context, in sysin.LoginLogListInp) (err error)
Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error)
View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
Push(ctx context.Context, in sysin.LoginLogPushInp)
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
}
ISysAttachment interface {
Delete(ctx context.Context, in sysin.AttachmentDeleteInp) error
Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (*sysin.AttachmentMaxSortModel, error)
View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (data *entity.SysAttachment, err error)
}
ISysProvinces interface {
Tree(ctx context.Context) (list []g.Map, err error)
Delete(ctx context.Context, in sysin.ProvincesDeleteInp) error
Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
}
ISysServeLog interface {
Model(ctx context.Context) *gdb.Model
List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
@@ -182,28 +86,178 @@ type (
AllowSend(ctx context.Context, models *entity.SysSmsLog, config *model.SmsConfig) (err error)
VerifyCode(ctx context.Context, in sysin.VerifyCodeInp) (err error)
}
ISysAddons interface {
List(ctx context.Context, in sysin.AddonsListInp) (list []*sysin.AddonsListModel, totalCount int, err error)
Selects(ctx context.Context, in sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error)
Build(ctx context.Context, in sysin.AddonsBuildInp) (err error)
Install(ctx context.Context, in sysin.AddonsInstallInp) (err error)
Upgrade(ctx context.Context, in sysin.AddonsUpgradeInp) (err error)
UnInstall(ctx context.Context, in sysin.AddonsUnInstallInp) (err error)
}
ISysConfig interface {
GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error)
GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error)
GetSms(ctx context.Context) (conf *model.SmsConfig, err error)
GetGeo(ctx context.Context) (conf *model.GeoConfig, err error)
GetUpload(ctx context.Context) (conf *model.UploadConfig, err error)
GetSmtp(ctx context.Context) (conf *model.EmailConfig, err error)
GetBasic(ctx context.Context) (conf *model.BasicConfig, err error)
GetLoadSSL(ctx context.Context) (conf *model.SSLConfig, err error)
GetLoadLog(ctx context.Context) (conf *model.LogConfig, err error)
GetLoadServeLog(ctx context.Context) (conf *model.ServeLogConfig, err error)
GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (*sysin.GetConfigModel, error)
ConversionType(ctx context.Context, models *entity.SysConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) error
}
ISysLog interface {
Export(ctx context.Context, in sysin.LogListInp) (err error)
RealWrite(ctx context.Context, commonLog entity.SysLog) (err error)
AutoLog(ctx context.Context) error
AnalysisLog(ctx context.Context) entity.SysLog
View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error)
Delete(ctx context.Context, in sysin.LogDeleteInp) (err error)
List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
}
ISysLoginLog interface {
Model(ctx context.Context) *gdb.Model
List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
Export(ctx context.Context, in sysin.LoginLogListInp) (err error)
Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error)
View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
Push(ctx context.Context, in sysin.LoginLogPushInp)
RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
}
ISysCronGroup interface {
Delete(ctx context.Context, in sysin.CronGroupDeleteInp) error
Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error)
Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (*sysin.CronGroupMaxSortModel, error)
View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
}
ISysCurdDemo interface {
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
List(ctx context.Context, in sysin.CurdDemoListInp) (list []*sysin.CurdDemoListModel, totalCount int, err error)
Export(ctx context.Context, in sysin.CurdDemoListInp) (err error)
Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error)
Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error)
MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error)
View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error)
Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error)
Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error)
}
ISysDictData interface {
Delete(ctx context.Context, in sysin.DictDataDeleteInp) error
Edit(ctx context.Context, in sysin.DictDataEditInp) (err error)
List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
}
ISysDictType interface {
Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
Delete(ctx context.Context, in sysin.DictTypeDeleteInp) error
Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error)
TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
}
ISysProvinces interface {
Tree(ctx context.Context) (list []g.Map, err error)
Delete(ctx context.Context, in sysin.ProvincesDeleteInp) error
Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
}
ISysCron interface {
StartCron(ctx context.Context)
Delete(ctx context.Context, in sysin.CronDeleteInp) (err error)
Edit(ctx context.Context, in sysin.CronEditInp) (err error)
Status(ctx context.Context, in sysin.CronStatusInp) (err error)
MaxSort(ctx context.Context, in sysin.CronMaxSortInp) (res *sysin.CronMaxSortModel, err error)
View(ctx context.Context, in sysin.CronViewInp) (res *sysin.CronViewModel, err error)
List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error)
}
)
var (
localSysCron ISysCron
localSysCronGroup ISysCronGroup
localSysCurdDemo ISysCurdDemo
localSysAttachment ISysAttachment
localSysBlacklist ISysBlacklist
localSysEmsLog ISysEmsLog
localSysGenCodes ISysGenCodes
localSysLog ISysLog
localSysConfig ISysConfig
localSysAddonsConfig ISysAddonsConfig
localSysDictType ISysDictType
localSysLoginLog ISysLoginLog
localSysAddons ISysAddons
localSysProvinces ISysProvinces
localSysServeLog ISysServeLog
localSysSmsLog ISysSmsLog
localSysAttachment ISysAttachment
localSysAddonsConfig ISysAddonsConfig
localSysConfig ISysConfig
localSysLog ISysLog
localSysLoginLog ISysLoginLog
localSysAddons ISysAddons
localSysCurdDemo ISysCurdDemo
localSysDictData ISysDictData
localSysEmsLog ISysEmsLog
localSysBlacklist ISysBlacklist
localSysDictType ISysDictType
localSysProvinces ISysProvinces
localSysCronGroup ISysCronGroup
)
func SysGenCodes() ISysGenCodes {
if localSysGenCodes == nil {
panic("implement not found for interface ISysGenCodes, forgot register?")
}
return localSysGenCodes
}
func RegisterSysGenCodes(i ISysGenCodes) {
localSysGenCodes = i
}
func SysServeLog() ISysServeLog {
if localSysServeLog == nil {
panic("implement not found for interface ISysServeLog, forgot register?")
}
return localSysServeLog
}
func RegisterSysServeLog(i ISysServeLog) {
localSysServeLog = 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 SysAddonsConfig() ISysAddonsConfig {
if localSysAddonsConfig == nil {
panic("implement not found for interface ISysAddonsConfig, forgot register?")
}
return localSysAddonsConfig
}
func RegisterSysAddonsConfig(i ISysAddonsConfig) {
localSysAddonsConfig = i
}
func SysAttachment() ISysAttachment {
if localSysAttachment == nil {
panic("implement not found for interface ISysAttachment, forgot register?")
}
return localSysAttachment
}
func RegisterSysAttachment(i ISysAttachment) {
localSysAttachment = i
}
func SysBlacklist() ISysBlacklist {
if localSysBlacklist == nil {
panic("implement not found for interface ISysBlacklist, forgot register?")
@@ -215,17 +269,6 @@ func RegisterSysBlacklist(i ISysBlacklist) {
localSysBlacklist = i
}
func SysDictData() ISysDictData {
if localSysDictData == nil {
panic("implement not found for interface ISysDictData, forgot register?")
}
return localSysDictData
}
func RegisterSysDictData(i ISysDictData) {
localSysDictData = i
}
func SysEmsLog() ISysEmsLog {
if localSysEmsLog == nil {
panic("implement not found for interface ISysEmsLog, forgot register?")
@@ -237,6 +280,17 @@ func RegisterSysEmsLog(i ISysEmsLog) {
localSysEmsLog = i
}
func SysAddons() ISysAddons {
if localSysAddons == nil {
panic("implement not found for interface ISysAddons, forgot register?")
}
return localSysAddons
}
func RegisterSysAddons(i ISysAddons) {
localSysAddons = i
}
func SysConfig() ISysConfig {
if localSysConfig == nil {
panic("implement not found for interface ISysConfig, forgot register?")
@@ -248,15 +302,37 @@ func RegisterSysConfig(i ISysConfig) {
localSysConfig = i
}
func SysCron() ISysCron {
if localSysCron == nil {
panic("implement not found for interface ISysCron, forgot register?")
func SysLog() ISysLog {
if localSysLog == nil {
panic("implement not found for interface ISysLog, forgot register?")
}
return localSysCron
return localSysLog
}
func RegisterSysCron(i ISysCron) {
localSysCron = i
func RegisterSysLog(i ISysLog) {
localSysLog = 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 SysProvinces() ISysProvinces {
if localSysProvinces == nil {
panic("implement not found for interface ISysProvinces, forgot register?")
}
return localSysProvinces
}
func RegisterSysProvinces(i ISysProvinces) {
localSysProvinces = i
}
func SysCronGroup() ISysCronGroup {
@@ -281,48 +357,15 @@ func RegisterSysCurdDemo(i ISysCurdDemo) {
localSysCurdDemo = i
}
func SysGenCodes() ISysGenCodes {
if localSysGenCodes == nil {
panic("implement not found for interface ISysGenCodes, forgot register?")
func SysDictData() ISysDictData {
if localSysDictData == nil {
panic("implement not found for interface ISysDictData, forgot register?")
}
return localSysGenCodes
return localSysDictData
}
func RegisterSysGenCodes(i ISysGenCodes) {
localSysGenCodes = 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 SysAddons() ISysAddons {
if localSysAddons == nil {
panic("implement not found for interface ISysAddons, forgot register?")
}
return localSysAddons
}
func RegisterSysAddons(i ISysAddons) {
localSysAddons = i
}
func SysAddonsConfig() ISysAddonsConfig {
if localSysAddonsConfig == nil {
panic("implement not found for interface ISysAddonsConfig, forgot register?")
}
return localSysAddonsConfig
}
func RegisterSysAddonsConfig(i ISysAddonsConfig) {
localSysAddonsConfig = i
func RegisterSysDictData(i ISysDictData) {
localSysDictData = i
}
func SysDictType() ISysDictType {
@@ -336,57 +379,13 @@ func RegisterSysDictType(i ISysDictType) {
localSysDictType = i
}
func SysLoginLog() ISysLoginLog {
if localSysLoginLog == nil {
panic("implement not found for interface ISysLoginLog, forgot register?")
func SysCron() ISysCron {
if localSysCron == nil {
panic("implement not found for interface ISysCron, forgot register?")
}
return localSysLoginLog
return localSysCron
}
func RegisterSysLoginLog(i ISysLoginLog) {
localSysLoginLog = i
}
func SysAttachment() ISysAttachment {
if localSysAttachment == nil {
panic("implement not found for interface ISysAttachment, forgot register?")
}
return localSysAttachment
}
func RegisterSysAttachment(i ISysAttachment) {
localSysAttachment = 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 SysServeLog() ISysServeLog {
if localSysServeLog == nil {
panic("implement not found for interface ISysServeLog, forgot register?")
}
return localSysServeLog
}
func RegisterSysServeLog(i ISysServeLog) {
localSysServeLog = 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 RegisterSysCron(i ISysCron) {
localSysCron = i
}

View File

@@ -31,9 +31,9 @@ var (
// Start 启动
func Start(c context.Context) {
ctxManager = c
g.Log().Debug(ctxManager, "start websocket..")
go clientManager.start()
go clientManager.ping()
g.Log().Debug(ctxManager, "start websocket..")
}
// Stop 关闭

View File

@@ -19,9 +19,9 @@ func handlerMsg(client *Client, message []byte) {
g.Log().Warningf(ctxManager, "handlerMsg recover, err:%+v, stack:%+v", r, string(debug.Stack()))
}
}()
request := &WRequest{}
err := gconv.Struct(message, request)
if err != nil {
var request *WRequest
if err := gconv.Struct(message, &request); err != nil {
g.Log().Warningf(ctxManager, "handlerMsg 数据解析失败,err:%+v, message:%+v", err, string(message))
return
}
@@ -31,8 +31,6 @@ func handlerMsg(client *Client, message []byte) {
return
}
//g.Log().Infof(ctxManager, "websocket handlerMsg:%+v", request)
fun, ok := routers[request.Event]
if !ok {
g.Log().Warningf(ctxManager, "handlerMsg function id %v: not registered", request.Event)