mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 05:12:32 +08:00
发布v2.13.1版本,更新内容请查看:https://github.com/bufanyun/hotgo/blob/v2.0/docs/guide-zh-CN/start-update-log.md
This commit is contained in:
@@ -11,10 +11,10 @@ import (
|
||||
"github.com/gogf/gf/v2/text/gstr"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/library/addons"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
"sort"
|
||||
)
|
||||
|
||||
type sSysAddons struct{}
|
||||
@@ -83,8 +83,7 @@ func (s *sSysAddons) List(ctx context.Context, in *sysin.AddonsListInp) (list []
|
||||
row.Skeleton.Logo = consts.AddonsGroupIconMap[row.Skeleton.Group]
|
||||
}
|
||||
|
||||
row.GroupName = consts.AddonsGroupNameMap[row.Skeleton.Group]
|
||||
|
||||
row.GroupName = dict.GetOptionLabel(consts.AddonsGroupOptions, row.Skeleton.Group)
|
||||
list = append(list, row)
|
||||
i++
|
||||
}
|
||||
@@ -93,42 +92,23 @@ func (s *sSysAddons) List(ctx context.Context, in *sysin.AddonsListInp) (list []
|
||||
return
|
||||
}
|
||||
|
||||
// Selects 选项
|
||||
func (s *sSysAddons) Selects(ctx context.Context, in *sysin.AddonsSelectsInp) (res *sysin.AddonsSelectsModel, err error) {
|
||||
res = new(sysin.AddonsSelectsModel)
|
||||
for k, v := range consts.AddonsGroupNameMap {
|
||||
res.GroupType = append(res.GroupType, &form.Select{
|
||||
Value: k,
|
||||
Name: v,
|
||||
Label: v,
|
||||
})
|
||||
}
|
||||
sort.Sort(res.GroupType)
|
||||
|
||||
for k, v := range consts.AddonsInstallStatusNameMap {
|
||||
res.Status = append(res.Status, &form.Select{
|
||||
Value: k,
|
||||
Name: v,
|
||||
Label: v,
|
||||
})
|
||||
}
|
||||
|
||||
sort.Sort(res.Status)
|
||||
return
|
||||
}
|
||||
|
||||
// Build 提交生成
|
||||
func (s *sSysAddons) Build(ctx context.Context, in *sysin.AddonsBuildInp) (err error) {
|
||||
genConfig, err := service.SysConfig().GetLoadGenerate(ctx)
|
||||
config, err := service.SysConfig().GetLoadGenerate(ctx)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if genConfig == nil || genConfig.Addon == nil {
|
||||
if config == nil || config.Addon == nil {
|
||||
err = gerror.New("没有找到有效的生成或插件配置,请检查配置文件是否正常")
|
||||
return
|
||||
}
|
||||
return addons.Build(ctx, in.Skeleton, genConfig.Addon)
|
||||
|
||||
option := new(addons.BuildOption)
|
||||
option.Config = config.Addon
|
||||
option.Skeleton = in.Skeleton
|
||||
option.Extend = in.Extend
|
||||
return addons.Build(ctx, option)
|
||||
}
|
||||
|
||||
// Install 安装模块
|
||||
|
@@ -64,7 +64,7 @@ func (s *sSysBlacklist) Edit(ctx context.Context, in *sysin.BlacklistEditInp) (e
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新部门状态
|
||||
// Status 更新状态
|
||||
func (s *sSysBlacklist) Status(ctx context.Context, in *sysin.BlacklistStatusInp) (err error) {
|
||||
defer s.VariableLoad(ctx, err)
|
||||
// 修改
|
||||
@@ -72,7 +72,7 @@ func (s *sSysBlacklist) Status(ctx context.Context, in *sysin.BlacklistStatusInp
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定字典类型信息
|
||||
// View 获取指定信息
|
||||
func (s *sSysBlacklist) View(ctx context.Context, in *sysin.BlacklistViewInp) (res *sysin.BlacklistViewModel, err error) {
|
||||
err = dao.SysBlacklist.Ctx(ctx).Where("id", in.Id).Scan(&res)
|
||||
return
|
||||
|
@@ -174,12 +174,6 @@ func (s *sSysConfig) GetLoadTCP(ctx context.Context) (conf *model.TCPConfig, err
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadCache 获取本地缓存配置
|
||||
func (s *sSysConfig) GetLoadCache(ctx context.Context) (conf *model.CacheConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "cache").Scan(&conf)
|
||||
return
|
||||
}
|
||||
|
||||
// GetLoadGenerate 获取本地生成配置
|
||||
func (s *sSysConfig) GetLoadGenerate(ctx context.Context) (conf *model.GenerateConfig, err error) {
|
||||
err = g.Cfg().MustGet(ctx, "hggen").Scan(&conf)
|
||||
|
@@ -1,9 +1,9 @@
|
||||
// Package sys
|
||||
// @Link https://github.com/bufanyun/hotgo
|
||||
// @Copyright Copyright (c) 2023 HotGo CLI
|
||||
// @Copyright Copyright (c) 2024 HotGo CLI
|
||||
// @Author Ms <133814250@qq.com>
|
||||
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
|
||||
// @AutoGenerate Version 2.11.5
|
||||
// @AutoGenerate Version 2.12.10
|
||||
package sys
|
||||
|
||||
import (
|
||||
|
@@ -7,10 +7,12 @@ package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"github.com/gogf/gf/v2/errors/gerror"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
"hotgo/internal/service"
|
||||
)
|
||||
@@ -146,6 +148,15 @@ func (s *sSysDictData) GetTypes(ctx context.Context, id int64) (types []string,
|
||||
|
||||
// Select 获取列表
|
||||
func (s *sSysDictData) Select(ctx context.Context, in *sysin.DataSelectInp) (list sysin.DataSelectModel, err error) {
|
||||
// 优先从内置字典中获取
|
||||
options, err := dict.GetOptions(ctx, in.Type)
|
||||
if err == nil {
|
||||
return options, nil
|
||||
}
|
||||
if !errors.Is(err, dict.NotExistKeyError) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
mod := dao.SysDictData.Ctx(ctx).Where("type", in.Type)
|
||||
if err = mod.Order("sort asc,id desc").Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
|
@@ -11,6 +11,7 @@ import (
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/dict"
|
||||
"hotgo/internal/library/hgorm"
|
||||
"hotgo/internal/model/entity"
|
||||
"hotgo/internal/model/input/sysin"
|
||||
@@ -114,18 +115,70 @@ func (s *sSysDictType) TreeSelect(ctx context.Context, in *sysin.DictTreeSelectI
|
||||
}
|
||||
|
||||
list = s.treeList(0, models)
|
||||
list = append(list, s.BuiltinSelect()...)
|
||||
return
|
||||
}
|
||||
|
||||
for _, v := range list {
|
||||
// 父类一律禁止选中
|
||||
if len(v.Children) > 0 {
|
||||
v.Disabled = true
|
||||
for _, v2 := range v.Children {
|
||||
if len(v2.Children) > 0 {
|
||||
v2.Disabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
// BuiltinSelect 内置字典选项
|
||||
func (s *sSysDictType) BuiltinSelect() (list []*sysin.DictTypeTree) {
|
||||
top := &sysin.DictTypeTree{
|
||||
SysDictType: entity.SysDictType{
|
||||
Id: dict.BuiltinId,
|
||||
Pid: 0,
|
||||
},
|
||||
Label: "内置字典",
|
||||
Value: dict.BuiltinId,
|
||||
Key: dict.BuiltinId,
|
||||
}
|
||||
|
||||
enums := &sysin.DictTypeTree{
|
||||
SysDictType: entity.SysDictType{
|
||||
Id: dict.EnumsId,
|
||||
Pid: dict.BuiltinId,
|
||||
},
|
||||
Label: "枚举字典",
|
||||
Value: dict.EnumsId,
|
||||
Key: dict.EnumsId,
|
||||
}
|
||||
|
||||
for _, v := range dict.GetAllEnums() {
|
||||
children := &sysin.DictTypeTree{
|
||||
SysDictType: entity.SysDictType{
|
||||
Id: v.Id,
|
||||
Pid: dict.EnumsId,
|
||||
},
|
||||
Label: v.Label,
|
||||
Value: v.Id,
|
||||
Key: v.Id,
|
||||
}
|
||||
enums.Children = append(enums.Children, children)
|
||||
}
|
||||
|
||||
fun := &sysin.DictTypeTree{
|
||||
SysDictType: entity.SysDictType{
|
||||
Id: dict.FuncId,
|
||||
Pid: dict.BuiltinId,
|
||||
},
|
||||
Label: "方法字典",
|
||||
Value: dict.FuncId,
|
||||
Key: dict.FuncId,
|
||||
}
|
||||
|
||||
for _, v := range dict.GetAllFunc() {
|
||||
children := &sysin.DictTypeTree{
|
||||
SysDictType: entity.SysDictType{
|
||||
Id: v.Id,
|
||||
Pid: dict.FuncId,
|
||||
},
|
||||
Label: v.Label,
|
||||
Value: v.Id,
|
||||
Key: v.Id,
|
||||
}
|
||||
fun.Children = append(fun.Children, children)
|
||||
}
|
||||
|
||||
top.Children = append(top.Children, enums, fun)
|
||||
list = append(list, top)
|
||||
return
|
||||
}
|
||||
|
||||
|
@@ -242,6 +242,10 @@ func (s *sSysLog) View(ctx context.Context, in *sysin.LogViewInp) (res *sysin.Lo
|
||||
return
|
||||
}
|
||||
|
||||
if res == nil {
|
||||
return
|
||||
}
|
||||
|
||||
if g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool() {
|
||||
res.HeaderData = gjson.New(`{
|
||||
"none": [
|
||||
|
Reference in New Issue
Block a user