mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-27 14:40:42 +08:00
发布v2.2.10版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
39
server/resource/generate/default/addon/README.MD.template
Normal file
39
server/resource/generate/default/addon/README.MD.template
Normal file
@@ -0,0 +1,39 @@
|
||||
## @{.label}
|
||||
|
||||
### 简介
|
||||
|
||||
@{.brief}
|
||||
|
||||
|
||||
### 使用说明
|
||||
|
||||
@{.description}
|
||||
|
||||
|
||||
### 迁移或安装
|
||||
|
||||
1、安装 HotGo (2.1.4及以上)
|
||||
|
||||
项目介绍:https://github.com/bufanyun/hotgo
|
||||
|
||||
2、将当前插件项目拷贝进 HotGo 根目录的 server/addons 目录下
|
||||
|
||||
3、在 HotGo 根目录的 server/addons/modules 目录下创建go文件:@{.name}.go,内容如下:
|
||||
```go
|
||||
package modules
|
||||
|
||||
import _ "hotgo/addons/@{.name}"
|
||||
```
|
||||
|
||||
4、HotGo 后台进入 开发工具->插件管理->找到 @{.label} (@{.name}) 进行安装
|
||||
|
||||
5、重启服务即可生效
|
||||
|
||||
|
||||
### 常用命令行
|
||||
|
||||
```shell
|
||||
# 接口维护-gen service
|
||||
gf gen service -s=addons/@{.name}/logic -d=addons/@{.name}/service
|
||||
|
||||
```
|
@@ -0,0 +1,28 @@
|
||||
// Package config
|
||||
// @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 config
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
// GetReq 获取指定分组的配置
|
||||
type GetReq struct {
|
||||
g.Meta `path:"/config/get" method:"get" tags:"@{.label}" summary:"获取指定分组的配置"`
|
||||
sysin.GetConfigInp
|
||||
}
|
||||
type GetRes struct {
|
||||
*sysin.GetConfigModel
|
||||
}
|
||||
|
||||
// UpdateReq 获取指定分组的配置
|
||||
type UpdateReq struct {
|
||||
g.Meta `path:"/config/update" method:"post" tags:"@{.label}" summary:"获取指定分组的配置"`
|
||||
sysin.UpdateConfigInp
|
||||
}
|
||||
type UpdateRes struct {
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @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 index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"@{.label}" summary:"测试后台API"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @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 index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"@{.label}" summary:"测试前台API"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @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 index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" summary:"@{.label}" tags:"测试首页"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
g.Meta `mime:"text/html" type:"string" example:"<html/>"`
|
||||
}
|
@@ -0,0 +1,21 @@
|
||||
// Package index
|
||||
// @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 index
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
// TestReq 测试
|
||||
type TestReq struct {
|
||||
g.Meta `path:"/index/test" method:"get" tags:"@{.label}" summary:"测试websocket"`
|
||||
sysin.IndexTestInp
|
||||
}
|
||||
|
||||
type TestRes struct {
|
||||
*sysin.IndexTestModel
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
// Package sys
|
||||
// @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 sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/api/admin/config"
|
||||
isysin "hotgo/internal/model/input/sysin"
|
||||
)
|
||||
|
||||
var (
|
||||
Config = cConfig{}
|
||||
)
|
||||
|
||||
type cConfig struct{}
|
||||
|
||||
// GetConfig 获取指定分组的配置
|
||||
func (c *cConfig) GetConfig(ctx context.Context, req *config.GetReq) (res *config.GetRes, err error) {
|
||||
var in sysin.GetConfigInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := service.SysConfig().GetConfigByGroup(ctx, in)
|
||||
|
||||
res = new(config.GetRes)
|
||||
res.GetConfigModel = (*isysin.GetConfigModel)(data)
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateConfig 更新指定分组的配置
|
||||
func (c *cConfig) UpdateConfig(ctx context.Context, req *config.UpdateReq) (res *config.UpdateRes, err error) {
|
||||
var in sysin.UpdateConfigInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysConfig().UpdateConfigByGroup(ctx, in)
|
||||
return
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
// Package sys
|
||||
// @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 sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/api/admin/index"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
var in sysin.IndexTestInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := service.SysIndex().Test(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
// Package api
|
||||
// @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 api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/api/api/index"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
var in sysin.IndexTestInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := service.SysIndex().Test(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
// Package home
|
||||
// @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 home
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/api/home/index"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/internal/model"
|
||||
isc "hotgo/internal/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
// Index 基础
|
||||
var Index = cIndex{}
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
func (a *cIndex) Index(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
var in sysin.IndexTestInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := service.SysIndex().Test(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
isc.View().RenderTpl(ctx, global.Tpl("home/index.html"), model.View{Data: g.Map{
|
||||
"name": data.Name,
|
||||
"module": data.Module,
|
||||
"time": data.Time,
|
||||
}})
|
||||
return
|
||||
}
|
@@ -0,0 +1,42 @@
|
||||
// Package websocket
|
||||
// @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 websocket
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/api/websocket/index"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
var in sysin.IndexTestInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
data, err := service.SysIndex().Test(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
@@ -0,0 +1,12 @@
|
||||
// Package global
|
||||
// @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 global
|
||||
|
||||
import "hotgo/internal/library/addons"
|
||||
|
||||
var (
|
||||
skeleton *addons.Skeleton // 插件架子
|
||||
)
|
@@ -0,0 +1,26 @@
|
||||
// Package global
|
||||
// @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 global
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
func Init(ctx context.Context, sk *addons.Skeleton) {
|
||||
skeleton = sk
|
||||
}
|
||||
|
||||
func GetSkeleton() *addons.Skeleton {
|
||||
if skeleton == nil {
|
||||
panic("addon skeleton not initialized.")
|
||||
}
|
||||
return skeleton
|
||||
}
|
||||
|
||||
func Tpl(tpl string) string {
|
||||
return addons.Tpl(skeleton.Name, tpl)
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
// ==========================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// ==========================================================================
|
||||
|
||||
package logic
|
||||
|
||||
import (
|
||||
_ "hotgo/addons/@{.name}/logic/sys"
|
||||
)
|
@@ -0,0 +1,60 @@
|
||||
// Package sys
|
||||
// @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 sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/addons/@{.name}/model"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
isysin "hotgo/internal/model/input/sysin"
|
||||
isc "hotgo/internal/service"
|
||||
)
|
||||
|
||||
type sSysConfig struct{}
|
||||
|
||||
func NewSysConfig() *sSysConfig {
|
||||
return &sSysConfig{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysConfig(NewSysConfig())
|
||||
}
|
||||
|
||||
// GetBasic 获取基础配置
|
||||
func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err error) {
|
||||
var in = isysin.GetAddonsConfigInp{AddonName: global.GetSkeleton().Name, Group: "basic"}
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = gconv.Struct(models.List, &conf); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// GetConfigByGroup 获取指定分组配置
|
||||
func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) {
|
||||
in.GetAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, in.GetAddonsConfigInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(sysin.GetConfigModel)
|
||||
res.List = models.List
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateConfigByGroup 更新指定分组的配置
|
||||
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) error {
|
||||
in.UpdateAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
return isc.SysAddonsConfig().UpdateConfigByGroup(ctx, in.UpdateAddonsConfigInp)
|
||||
}
|
@@ -0,0 +1,35 @@
|
||||
// Package sys
|
||||
// @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 sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
"hotgo/addons/@{.name}/service"
|
||||
"hotgo/internal/library/contexts"
|
||||
)
|
||||
|
||||
type sSysIndex struct{}
|
||||
|
||||
func NewSysIndex() *sSysIndex {
|
||||
return &sSysIndex{}
|
||||
}
|
||||
|
||||
func init() {
|
||||
service.RegisterSysIndex(NewSysIndex())
|
||||
}
|
||||
|
||||
// Test 测试
|
||||
func (s *sSysIndex) Test(ctx context.Context, in sysin.IndexTestInp) (res *sysin.IndexTestModel, err error) {
|
||||
res = new(sysin.IndexTestModel)
|
||||
res.Name = in.Name
|
||||
res.Module = fmt.Sprintf("当前插件模块是:%s,当前应用模块是:%s", global.GetSkeleton().Name, contexts.Get(ctx).Module)
|
||||
res.Time = gtime.Now()
|
||||
return
|
||||
}
|
91
server/resource/generate/default/addon/main.go.template
Normal file
91
server/resource/generate/default/addon/main.go.template
Normal file
@@ -0,0 +1,91 @@
|
||||
// Package @{.name}
|
||||
// @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 @{.name}
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"github.com/gogf/gf/v2/os/gctx"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
_ "hotgo/addons/@{.name}/logic"
|
||||
"hotgo/addons/@{.name}/router"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type module struct {
|
||||
skeleton *addons.Skeleton
|
||||
ctx context.Context
|
||||
sync.Mutex
|
||||
}
|
||||
|
||||
func init() {
|
||||
newModule()
|
||||
}
|
||||
|
||||
func newModule() {
|
||||
m := &module{
|
||||
skeleton: &addons.Skeleton{
|
||||
Label: `@{.label}`,
|
||||
Name: `@{.name}`,
|
||||
Group: @{.group},
|
||||
Logo: "",
|
||||
Brief: `@{.brief}`,
|
||||
Description: `@{.description}`,
|
||||
Author: `@{.author}`,
|
||||
Version: `@{.version}`, // 当该版本号高于已安装的版本号时,会提示可以更新
|
||||
RootPath: addons.GetModulePath("@{.name}"),
|
||||
},
|
||||
ctx: gctx.New(),
|
||||
}
|
||||
|
||||
addons.RegisterModule(m)
|
||||
}
|
||||
|
||||
// Init 初始化
|
||||
func (m *module) Init(ctx context.Context) {
|
||||
global.Init(ctx, m.skeleton)
|
||||
// ...
|
||||
}
|
||||
|
||||
// InitRouter 初始化WEB路由
|
||||
func (m *module) InitRouter(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
m.Init(ctx)
|
||||
group.Middleware(service.Middleware().Addon)
|
||||
router.Admin(ctx, group)
|
||||
router.Api(ctx, group)
|
||||
router.Home(ctx, group)
|
||||
router.WebSocket(ctx, group)
|
||||
}
|
||||
|
||||
// Ctx 上下文
|
||||
func (m *module) Ctx() context.Context {
|
||||
return m.ctx
|
||||
}
|
||||
|
||||
// GetSkeleton 架子
|
||||
func (m *module) GetSkeleton() *addons.Skeleton {
|
||||
return m.skeleton
|
||||
}
|
||||
|
||||
// Install 安装模块
|
||||
func (m *module) Install(ctx context.Context) (err error) {
|
||||
// ...
|
||||
return
|
||||
}
|
||||
|
||||
// Upgrade 更新模块
|
||||
func (m *module) Upgrade(ctx context.Context) (err error) {
|
||||
// ...
|
||||
return
|
||||
}
|
||||
|
||||
// UnInstall 卸载模块
|
||||
func (m *module) UnInstall(ctx context.Context) (err error) {
|
||||
// ...
|
||||
return
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
// 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
|
||||
|
||||
// BasicConfig 基础配置
|
||||
type BasicConfig struct {
|
||||
Test string `json:"basicTest"`
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
// Package sysin
|
||||
// @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 sysin
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
)
|
||||
|
||||
// UpdateConfigInp 更新指定配置
|
||||
type UpdateConfigInp struct {
|
||||
sysin.UpdateAddonsConfigInp
|
||||
}
|
||||
|
||||
type GetConfigInp struct {
|
||||
sysin.GetAddonsConfigInp
|
||||
}
|
||||
|
||||
type GetConfigModel struct {
|
||||
List g.Map `json:"list"`
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
// Package sysin
|
||||
// @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 sysin
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// IndexTestInp 测试
|
||||
type IndexTestInp struct {
|
||||
Name string `json:"name" d:"HotGo" dc:"名称"`
|
||||
}
|
||||
|
||||
func (in *IndexTestInp) Filter(ctx context.Context) (err error) {
|
||||
return
|
||||
}
|
||||
|
||||
type IndexTestModel struct {
|
||||
Name string `json:"name" dc:"名称"`
|
||||
Module string `json:"module" dc:"当前插件模块"`
|
||||
Time *gtime.Time `json:"time" dc:"当前时间"`
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
// Package router
|
||||
// @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 router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/@{.name}/controller/admin/sys"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/addons/@{.name}/router/genrouter"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Admin 后台路由
|
||||
func Admin(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppAdmin, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
sys.Index,
|
||||
)
|
||||
group.Middleware(service.Middleware().AdminAuth)
|
||||
group.Bind(
|
||||
sys.Config,
|
||||
)
|
||||
})
|
||||
|
||||
// 注册生成路由
|
||||
genrouter.Register(ctx, group)
|
||||
}
|
@@ -0,0 +1,32 @@
|
||||
// Package router
|
||||
// @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 router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/@{.name}/controller/api"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Api 前台路由
|
||||
func Api(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppApi, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
// 无需验证的路由
|
||||
api.Index,
|
||||
)
|
||||
group.Middleware(service.Middleware().ApiAuth)
|
||||
group.Bind(
|
||||
// 需要验证的路由
|
||||
// ...
|
||||
)
|
||||
})
|
||||
}
|
@@ -0,0 +1,34 @@
|
||||
// Package genrouter
|
||||
// @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 genrouter
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
|
||||
var (
|
||||
NoLogin []interface{} // 无需登录
|
||||
LoginRequiredRouter []interface{} // 需要登录
|
||||
)
|
||||
|
||||
// Register 注册通过代码生成的后台路由
|
||||
func Register(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppAdmin, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
if len(NoLogin) > 0 {
|
||||
group.Bind(NoLogin...)
|
||||
}
|
||||
group.Middleware(service.Middleware().AdminAuth)
|
||||
if len(LoginRequiredRouter) > 0 {
|
||||
group.Bind(LoginRequiredRouter...)
|
||||
}
|
||||
})
|
||||
}
|
@@ -0,0 +1,25 @@
|
||||
// Package router
|
||||
// @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 router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/@{.name}/controller/home"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
)
|
||||
|
||||
// Home 前台页面路由
|
||||
func Home(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppHome, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
home.Index,
|
||||
)
|
||||
})
|
||||
}
|
@@ -0,0 +1,40 @@
|
||||
// Package router
|
||||
// @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 router
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/net/ghttp"
|
||||
"hotgo/addons/@{.name}/controller/websocket"
|
||||
"hotgo/addons/@{.name}/global"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/service"
|
||||
ws "hotgo/internal/websocket"
|
||||
)
|
||||
|
||||
// WebSocket ws路由配置
|
||||
func WebSocket(ctx context.Context, group *ghttp.RouterGroup) {
|
||||
prefix := addons.RouterPrefix(ctx, consts.AppWebSocket, global.GetSkeleton().Name)
|
||||
group.Group(prefix, func(group *ghttp.RouterGroup) {
|
||||
group.Bind(
|
||||
// 无需验证的路由
|
||||
websocket.Index,
|
||||
)
|
||||
// ws连接中间件
|
||||
group.Middleware(service.Middleware().WebSocketToken)
|
||||
group.Bind(
|
||||
// 需要验证的路由
|
||||
// ..
|
||||
)
|
||||
})
|
||||
|
||||
// 注册消息路由
|
||||
ws.RegisterMsg(ws.EventHandlers{
|
||||
// ...
|
||||
})
|
||||
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
// ================================================================================
|
||||
// Code generated by GoFrame CLI tool. DO NOT EDIT.
|
||||
// You can delete these comments if you wish manually maintain this interface file.
|
||||
// ================================================================================
|
||||
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/@{.name}/model"
|
||||
"hotgo/addons/@{.name}/model/input/sysin"
|
||||
)
|
||||
|
||||
type (
|
||||
ISysConfig interface {
|
||||
GetBasic(ctx context.Context) (conf *model.BasicConfig, err error)
|
||||
GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (res *sysin.GetConfigModel, err error)
|
||||
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) error
|
||||
}
|
||||
ISysIndex interface {
|
||||
Test(ctx context.Context, in sysin.IndexTestInp) (res *sysin.IndexTestModel, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSysConfig ISysConfig
|
||||
localSysIndex ISysIndex
|
||||
)
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
if localSysConfig == nil {
|
||||
panic("implement not found for interface ISysConfig, forgot register?")
|
||||
}
|
||||
return localSysConfig
|
||||
}
|
||||
|
||||
func RegisterSysConfig(i ISysConfig) {
|
||||
localSysConfig = i
|
||||
}
|
||||
|
||||
func SysIndex() ISysIndex {
|
||||
if localSysIndex == nil {
|
||||
panic("implement not found for interface ISysIndex, forgot register?")
|
||||
}
|
||||
return localSysIndex
|
||||
}
|
||||
|
||||
func RegisterSysIndex(i ISysIndex) {
|
||||
localSysIndex = i
|
||||
}
|
Reference in New Issue
Block a user