im 管理后台
This commit is contained in:
@@ -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/xuri/excelize/v2"
|
||||
"hotgo/addons/hgexample/api/admin/comp"
|
||||
)
|
||||
|
||||
var (
|
||||
Comp = cComp{}
|
||||
)
|
||||
|
||||
type cComp struct{}
|
||||
|
||||
// ImportExcel 导入Excel
|
||||
func (c *cComp) ImportExcel(ctx context.Context, req *comp.ImportExcelReq) (res *comp.ImportExcelRes, err error) {
|
||||
file, err := req.File.Open()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
excel, err := excelize.OpenReader(file)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
defer excel.Close()
|
||||
|
||||
res = new(comp.ImportExcelRes)
|
||||
sheetList := excel.GetSheetList()
|
||||
for _, sheet := range sheetList {
|
||||
item := new(comp.ImportExcelSheet)
|
||||
item.Sheet = sheet
|
||||
item.Rows, err = excel.GetRows(sheet)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
res.Sheets = append(res.Sheets, item)
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/admin/config"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Config = cConfig{}
|
||||
)
|
||||
|
||||
type cConfig struct{}
|
||||
|
||||
// GetConfig 获取指定分组的配置
|
||||
func (c *cConfig) GetConfig(ctx context.Context, req *config.GetReq) (res *config.GetRes, err error) {
|
||||
data, err := service.SysConfig().GetConfigByGroup(ctx, &req.GetConfigInp)
|
||||
|
||||
res = new(config.GetRes)
|
||||
res.GetConfigModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// UpdateConfig 更新指定分组的配置
|
||||
func (c *cConfig) UpdateConfig(ctx context.Context, req *config.UpdateReq) (res *config.UpdateRes, err error) {
|
||||
err = service.SysConfig().UpdateConfigByGroup(ctx, &req.UpdateConfigInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/admin/index"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/admin/table"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Table = cTable{}
|
||||
)
|
||||
|
||||
type cTable struct{}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cTable) List(ctx context.Context, req *table.ListReq) (res *table.ListRes, err error) {
|
||||
list, totalCount, err := service.SysTable().List(ctx, &req.TableListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(table.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出列表
|
||||
func (c *cTable) Export(ctx context.Context, req *table.ExportReq) (res *table.ExportRes, err error) {
|
||||
err = service.SysTable().Export(ctx, &req.TableListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cTable) Edit(ctx context.Context, req *table.EditReq) (res *table.EditRes, err error) {
|
||||
err = service.SysTable().Edit(ctx, &req.TableEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cTable) MaxSort(ctx context.Context, req *table.MaxSortReq) (res *table.MaxSortRes, err error) {
|
||||
data, err := service.SysTable().MaxSort(ctx, &req.TableMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(table.MaxSortRes)
|
||||
res.TableMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cTable) View(ctx context.Context, req *table.ViewReq) (res *table.ViewRes, err error) {
|
||||
data, err := service.SysTable().View(ctx, &req.TableViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(table.ViewRes)
|
||||
res.TableViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cTable) Delete(ctx context.Context, req *table.DeleteReq) (res *table.DeleteRes, err error) {
|
||||
err = service.SysTable().Delete(ctx, &req.TableDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cTable) Status(ctx context.Context, req *table.StatusReq) (res *table.StatusRes, err error) {
|
||||
err = service.SysTable().Status(ctx, &req.TableStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Switch 更新开关状态
|
||||
func (c *cTable) Switch(ctx context.Context, req *table.SwitchReq) (res *table.SwitchRes, err error) {
|
||||
err = service.SysTable().Switch(ctx, &req.TableSwitchInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.13.1
|
||||
package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"hotgo/addons/hgexample/api/admin/tenantorder"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
TenantOrder = cTenantOrder{}
|
||||
)
|
||||
|
||||
type cTenantOrder struct{}
|
||||
|
||||
// List 查看多租户功能演示列表
|
||||
func (c *cTenantOrder) List(ctx context.Context, req *tenantorder.ListReq) (res *tenantorder.ListRes, err error) {
|
||||
list, totalCount, err := service.SysTenantOrder().List(ctx, &req.TenantOrderListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if list == nil {
|
||||
list = []*sysin.TenantOrderListModel{}
|
||||
}
|
||||
|
||||
res = new(tenantorder.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出多租户功能演示列表
|
||||
func (c *cTenantOrder) Export(ctx context.Context, req *tenantorder.ExportReq) (res *tenantorder.ExportRes, err error) {
|
||||
err = service.SysTenantOrder().Export(ctx, &req.TenantOrderListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新多租户功能演示
|
||||
func (c *cTenantOrder) Edit(ctx context.Context, req *tenantorder.EditReq) (res *tenantorder.EditRes, err error) {
|
||||
err = service.SysTenantOrder().Edit(ctx, &req.TenantOrderEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定多租户功能演示信息
|
||||
func (c *cTenantOrder) View(ctx context.Context, req *tenantorder.ViewReq) (res *tenantorder.ViewRes, err error) {
|
||||
data, err := service.SysTenantOrder().View(ctx, &req.TenantOrderViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(tenantorder.ViewRes)
|
||||
res.TenantOrderViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除多租户功能演示
|
||||
func (c *cTenantOrder) Delete(ctx context.Context, req *tenantorder.DeleteReq) (res *tenantorder.DeleteRes, err error) {
|
||||
err = service.SysTenantOrder().Delete(ctx, &req.TenantOrderDeleteInp)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/admin/treetable"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
TreeTable = cTreeTable{}
|
||||
)
|
||||
|
||||
type cTreeTable struct{}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cTreeTable) List(ctx context.Context, req *treetable.ListReq) (res *treetable.ListRes, err error) {
|
||||
list, totalCount, err := service.SysTreeTable().List(ctx, &req.TreeTableListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(treetable.ListRes)
|
||||
res.List = list
|
||||
res.PageRes.Pack(req, totalCount)
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出列表
|
||||
func (c *cTreeTable) Export(ctx context.Context, req *treetable.ExportReq) (res *treetable.ExportRes, err error) {
|
||||
err = service.SysTable().Export(ctx, &req.TableListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cTreeTable) Edit(ctx context.Context, req *treetable.EditReq) (res *treetable.EditRes, err error) {
|
||||
err = service.SysTreeTable().Edit(ctx, &req.TableEditInp)
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (c *cTreeTable) MaxSort(ctx context.Context, req *treetable.MaxSortReq) (res *treetable.MaxSortRes, err error) {
|
||||
data, err := service.SysTable().MaxSort(ctx, &req.TableMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(treetable.MaxSortRes)
|
||||
res.TableMaxSortModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cTreeTable) View(ctx context.Context, req *treetable.ViewReq) (res *treetable.ViewRes, err error) {
|
||||
data, err := service.SysTable().View(ctx, &req.TableViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(treetable.ViewRes)
|
||||
res.TableViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (c *cTreeTable) Delete(ctx context.Context, req *treetable.DeleteReq) (res *treetable.DeleteRes, err error) {
|
||||
err = service.SysTreeTable().Delete(ctx, &req.TableDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cTreeTable) Status(ctx context.Context, req *treetable.StatusReq) (res *treetable.StatusRes, err error) {
|
||||
err = service.SysTable().Status(ctx, &req.TableStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Switch 更新开关状态
|
||||
func (c *cTreeTable) Switch(ctx context.Context, req *treetable.SwitchReq) (res *treetable.SwitchRes, err error) {
|
||||
err = service.SysTable().Switch(ctx, &req.TableSwitchInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Select 树形选项
|
||||
func (c *cTreeTable) Select(ctx context.Context, _ *treetable.SelectReq) (res *treetable.SelectRes, err error) {
|
||||
res = new(treetable.SelectRes)
|
||||
res.List, err = service.SysTreeTable().Select(ctx)
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/api/index"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/home/index"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/internal/model"
|
||||
isc "hotgo/internal/service"
|
||||
)
|
||||
|
||||
// Index 基础
|
||||
var Index = cIndex{}
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
func (a *cIndex) Index(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
isc.View().RenderTpl(ctx, "home/index.html", model.View{Data: g.Map{
|
||||
"name": data.Name,
|
||||
"module": data.Module,
|
||||
"time": data.Time,
|
||||
}})
|
||||
return
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
// Package handler
|
||||
// @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 handler
|
||||
|
||||
import (
|
||||
"github.com/gogf/gf/v2/encoding/gjson"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/websocket"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// TestMessage 测试消息
|
||||
func (c *cIndex) TestMessage(client *websocket.Client, req *websocket.WRequest) {
|
||||
g.Log().Infof(client.Context(), "收到客户端测试消息:%v", gjson.New(req).String())
|
||||
// 将收到的消息原样发送给客户端
|
||||
websocket.SendSuccess(client, req.Event, req.Data)
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 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"
|
||||
"hotgo/addons/hgexample/api/websocket/index"
|
||||
"hotgo/addons/hgexample/service"
|
||||
)
|
||||
|
||||
var (
|
||||
Index = cIndex{}
|
||||
)
|
||||
|
||||
type cIndex struct{}
|
||||
|
||||
// Test 测试
|
||||
func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestRes, err error) {
|
||||
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(index.TestRes)
|
||||
res.IndexTestModel = data
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user