This commit is contained in:
孟帅
2023-07-20 18:01:10 +08:00
parent 9113fc5297
commit 373d9627fb
492 changed files with 12170 additions and 6982 deletions

View File

@@ -7,11 +7,8 @@ package sys
import (
"context"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/addons/@{.name}/model/input/sysin"
"hotgo/addons/@{.name}/api/admin/config"
"hotgo/addons/@{.name}/service"
"hotgo/api/admin/config"
isysin "hotgo/internal/model/input/sysin"
)
var (
@@ -22,25 +19,15 @@ 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)
data, err := service.SysConfig().GetConfigByGroup(ctx, &req.GetConfigInp)
res = new(config.GetRes)
res.GetConfigModel = (*isysin.GetConfigModel)(data)
res.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)
err = service.SysConfig().UpdateConfigByGroup(ctx, &req.UpdateConfigInp)
return
}

View File

@@ -7,11 +7,8 @@ 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 (
@@ -22,16 +19,7 @@ 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)
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
if err != nil {
return
}

View File

@@ -7,11 +7,8 @@ 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 (
@@ -22,16 +19,7 @@ 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)
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
if err != nil {
return
}
@@ -40,3 +28,4 @@ func (c *cIndex) Test(ctx context.Context, req *index.TestReq) (res *index.TestR
res.IndexTestModel = data
return
}

View File

@@ -8,13 +8,10 @@ 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}/model/input/sysin"
"hotgo/addons/@{.name}/service"
"hotgo/internal/model"
isc "hotgo/internal/service"
"hotgo/utility/validate"
)
// Index 基础
@@ -23,16 +20,7 @@ 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)
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
if err != nil {
return
}

View File

@@ -7,11 +7,8 @@ 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 (
@@ -22,16 +19,7 @@ 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)
data, err := service.SysIndex().Test(ctx, &req.IndexTestInp)
if err != nil {
return
}

View File

@@ -1,3 +1,8 @@
// Package crons
// @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 crons
// 定时任务.

View File

@@ -12,7 +12,6 @@ import (
"hotgo/addons/@{.name}/model"
"hotgo/addons/@{.name}/model/input/sysin"
"hotgo/addons/@{.name}/service"
isysin "hotgo/internal/model/input/sysin"
isc "hotgo/internal/service"
)
@@ -28,22 +27,22 @@ func init() {
// 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)
var in sysin.GetConfigInp
in.GetAddonsConfigInp.AddonName = global.GetSkeleton().Name
in.GetAddonsConfigInp.Group = "basic"
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, &in.GetAddonsConfigInp)
if err != nil {
return
}
if err = gconv.Struct(models.List, &conf); err != nil {
return
}
err = gconv.Struct(models.List, &conf)
return
}
// GetConfigByGroup 获取指定分组配置
func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp) (res *sysin.GetConfigModel, err error) {
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)
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, &in.GetAddonsConfigInp)
if err != nil {
return
}
@@ -54,7 +53,7 @@ func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp
}
// UpdateConfigByGroup 更新指定分组的配置
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) error {
func (s *sSysConfig) UpdateConfigByGroup(ctx context.Context, in *sysin.UpdateConfigInp) error {
in.UpdateAddonsConfigInp.AddonName = global.GetSkeleton().Name
return isc.SysAddonsConfig().UpdateConfigByGroup(ctx, in.UpdateAddonsConfigInp)
return isc.SysAddonsConfig().UpdateConfigByGroup(ctx, &in.UpdateAddonsConfigInp)
}

View File

@@ -26,7 +26,7 @@ func init() {
}
// Test 测试
func (s *sSysIndex) Test(ctx context.Context, in sysin.IndexTestInp) (res *sysin.IndexTestModel, err error) {
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)

View File

@@ -1,3 +1,8 @@
// 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
// 消息队列.

View File

@@ -14,11 +14,11 @@ import (
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
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)
Test(ctx context.Context, in *sysin.IndexTestInp) (res *sysin.IndexTestModel, err error)
}
)

View File

@@ -65,6 +65,7 @@ type DeleteRes struct{}
// MaxSortReq 获取@{.tableComment}最大排序
type MaxSortReq struct {
g.Meta `path:"/@{.varName | LcFirst}/maxSort" method:"get" tags:"@{.tableComment}" summary:"获取@{.tableComment}最大排序"`
@{.templateGroup}in.@{.varName}MaxSortInp
}
type MaxSortRes struct {

View File

@@ -9,9 +9,7 @@ package @{.templateGroup}
import (
"context"
"github.com/gogf/gf/v2/util/gconv"
"@{.importApi}"
"@{.importInput}"
"hotgo/internal/model/input/form"
"@{.importService}"
"hotgo/utility/validate"
@@ -25,63 +23,34 @@ type c@{.varName} struct{}
// List 查看@{.tableComment}列表
func (c *c@{.varName}) List(ctx context.Context, req *@{.varName | ToLower}.ListReq) (res *@{.varName | ToLower}.ListRes, err error) {
var in @{.templateGroup}in.@{.varName}ListInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
list, totalCount, err := service.@{.templateGroup | UcFirst}@{.varName}().List(ctx, in)
list, totalCount, err := service.@{.templateGroup | UcFirst}@{.varName}().List(ctx, &req.@{.varName}ListInp)
if err != nil {
return
}
res = new(@{.varName | ToLower}.ListRes)
res.List = list
res.PageCount = form.CalPageCount(totalCount, req.PerPage)
res.Page = req.Page
res.PerPage = req.PerPage
res.PageRes.Pack(req, totalCount)
return
}
@{ if eq .options.Step.HasExport true }
// Export 导出@{.tableComment}列表
func (c *c@{.varName}) Export(ctx context.Context, req *@{.varName | ToLower}.ExportReq) (res *@{.varName | ToLower}.ExportRes, err error) {
var in @{.templateGroup}in.@{.varName}ListInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, in)
err = service.@{.templateGroup | UcFirst}@{.varName}().Export(ctx, &req.@{.varName}ListInp)
return
}
@{end}
@{ if eq .options.Step.HasEdit true }
// Edit 更新@{.tableComment}
func (c *c@{.varName}) Edit(ctx context.Context, req *@{.varName | ToLower}.EditReq) (res *@{.varName | ToLower}.EditRes, err error) {
var in @{.templateGroup}in.@{.varName}EditInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, in)
err = service.@{.templateGroup | UcFirst}@{.varName}().Edit(ctx, &req.@{.varName}EditInp)
return
}
@{end}
@{ if and (eq .options.Step.HasEdit true) (eq .options.Step.HasMaxSort true) }
// MaxSort 获取@{.tableComment}最大排序
func (c *c@{.varName}) MaxSort(ctx context.Context, req *@{.varName | ToLower}.MaxSortReq) (res *@{.varName | ToLower}.MaxSortRes, err error) {
data, err := service.@{.templateGroup | UcFirst}@{.varName}().MaxSort(ctx, sysin.@{.varName}MaxSortInp{})
data, err := service.@{.templateGroup | UcFirst}@{.varName}().MaxSort(ctx, &req.@{.varName}MaxSortInp)
if err != nil {
return
}
@@ -94,16 +63,7 @@ func (c *c@{.varName}) MaxSort(ctx context.Context, req *@{.varName | ToLower}.M
@{ if or (eq .options.Step.HasView true) (eq .options.Step.HasEdit true) }
// View 获取指定@{.tableComment}信息
func (c *c@{.varName}) View(ctx context.Context, req *@{.varName | ToLower}.ViewReq) (res *@{.varName | ToLower}.ViewRes, err error) {
var in @{.templateGroup}in.@{.varName}ViewInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
data, err := service.@{.templateGroup | UcFirst}@{.varName}().View(ctx, in)
data, err := service.@{.templateGroup | UcFirst}@{.varName}().View(ctx, &req.@{.varName}ViewInp)
if err != nil {
return
}
@@ -116,48 +76,21 @@ func (c *c@{.varName}) View(ctx context.Context, req *@{.varName | ToLower}.View
@{ if eq .options.Step.HasDel true }
// Delete 删除@{.tableComment}
func (c *c@{.varName}) Delete(ctx context.Context, req *@{.varName | ToLower}.DeleteReq) (res *@{.varName | ToLower}.DeleteRes, err error) {
var in @{.templateGroup}in.@{.varName}DeleteInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, in)
err = service.@{.templateGroup | UcFirst}@{.varName}().Delete(ctx, &req.@{.varName}DeleteInp)
return
}
@{end}
@{ if eq .options.Step.HasStatus true }
// Status 更新@{.tableComment}状态
func (c *c@{.varName}) Status(ctx context.Context, req *@{.varName | ToLower}.StatusReq) (res *@{.varName | ToLower}.StatusRes, err error) {
var in @{.templateGroup}in.@{.varName}StatusInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, in)
err = service.@{.templateGroup | UcFirst}@{.varName}().Status(ctx, &req.@{.varName}StatusInp)
return
}
@{end}
@{ if eq .options.Step.HasSwitch true }
// Switch 更新@{.tableComment}开关状态
func (c *c@{.varName}) Switch(ctx context.Context, req *@{.varName | ToLower}.SwitchReq) (res *@{.varName | ToLower}.SwitchRes, err error) {
var in @{.templateGroup}in.@{.varName}SwitchInp
if err = gconv.Scan(req, &in); err != nil {
return
}
if err = validate.PreFilter(ctx, &in); err != nil {
return
}
err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, in)
err = service.@{.templateGroup | UcFirst}@{.varName}().Switch(ctx, &req.@{.varName}SwitchInp)
return
}
@{end}

View File

@@ -44,7 +44,7 @@ func (s *s@{.servFunName}) Model(ctx context.Context, option ...*handler.Option)
}
// List 获取@{.tableComment}列表
func (s *s@{.servFunName}) List(ctx context.Context, in @{.templateGroup}in.@{.varName}ListInp) (list []*@{.templateGroup}in.@{.varName}ListModel, totalCount int, err error) {
func (s *s@{.servFunName}) List(ctx context.Context, in *@{.templateGroup}in.@{.varName}ListInp) (list []*@{.templateGroup}in.@{.varName}ListModel, totalCount int, err error) {
mod := s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end})
@{.listWhere}
@{.listJoin.link}
@@ -68,7 +68,7 @@ func (s *s@{.servFunName}) List(ctx context.Context, in @{.templateGroup}in.@{.v
}
@{ if eq .options.Step.HasExport true }
// Export 导出@{.tableComment}
func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{.varName}ListInp) (err error) {
func (s *s@{.servFunName}) Export(ctx context.Context, in *@{.templateGroup}in.@{.varName}ListInp) (err error) {
list, totalCount, err := s.List(ctx, in)
if err != nil {
return
@@ -95,9 +95,8 @@ func (s *s@{.servFunName}) Export(ctx context.Context, in @{.templateGroup}in.@{
}@{end}
@{ if eq .options.Step.HasEdit true }
// Edit 修改/新增@{.tableComment}
func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.varName}EditInp) (err error) {
@{.edit.unique}
// 修改
func (s *s@{.servFunName}) Edit(ctx context.Context, in *@{.templateGroup}in.@{.varName}EditInp) (err error) {
@{.edit.unique} // 修改
if in.@{.pk.GoName} > 0 {
@{.edit.update}
}
@@ -109,7 +108,7 @@ func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.v
@{end}
@{ if eq .options.Step.HasDel true }
// Delete 删除@{.tableComment}
func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{.varName}DeleteInp) (err error) {
func (s *s@{.servFunName}) Delete(ctx context.Context, in *@{.templateGroup}in.@{.varName}DeleteInp) (err error) {
if _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Delete();err != nil {
err = gerror.Wrap(err, "删除@{.tableComment}失败,请稍后重试!")
return
@@ -118,7 +117,7 @@ func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{
}@{end}
@{ if and (eq .options.Step.HasEdit true) (eq .options.Step.HasMaxSort true) }
// MaxSort 获取@{.tableComment}最大排序
func (s *s@{.servFunName}) MaxSort(ctx context.Context, in @{.templateGroup}in.@{.varName}MaxSortInp) (res *@{.templateGroup}in.@{.varName}MaxSortModel, err error) {
func (s *s@{.servFunName}) MaxSort(ctx context.Context, in *@{.templateGroup}in.@{.varName}MaxSortInp) (res *@{.templateGroup}in.@{.varName}MaxSortModel, err error) {
if err = dao.@{.daoName}.Ctx(ctx).Fields(dao.@{.daoName}.Columns().Sort).OrderDesc(dao.@{.daoName}.Columns().Sort).Scan(&res); err != nil {
err = gerror.Wrap(err, "获取@{.tableComment}最大排序,请稍后重试!")
return
@@ -128,13 +127,13 @@ func (s *s@{.servFunName}) MaxSort(ctx context.Context, in @{.templateGroup}in.@
res = new(@{.templateGroup}in.@{.varName}MaxSortModel)
}
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
res.Sort = form.DefaultMaxSort(res.Sort)
return
}
@{end}
@{ if or (eq .options.Step.HasView true) (eq .options.Step.HasEdit true) }
// View 获取@{.tableComment}指定信息
func (s *s@{.servFunName}) View(ctx context.Context, in @{.templateGroup}in.@{.varName}ViewInp) (res *@{.templateGroup}in.@{.varName}ViewModel, err error) {
func (s *s@{.servFunName}) View(ctx context.Context, in *@{.templateGroup}in.@{.varName}ViewInp) (res *@{.templateGroup}in.@{.varName}ViewModel, err error) {
if err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Scan(&res);err != nil {
err = gerror.Wrap(err, "获取@{.tableComment}信息,请稍后重试!")
return
@@ -143,7 +142,7 @@ func (s *s@{.servFunName}) View(ctx context.Context, in @{.templateGroup}in.@{.v
}@{end}
@{ if eq .options.Step.HasStatus true }
// Status 更新@{.tableComment}状态
func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{.varName}StatusInp) (err error) {
func (s *s@{.servFunName}) Status(ctx context.Context, in *@{.templateGroup}in.@{.varName}StatusInp) (err error) {
if _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Data(@{.statusUpdate}).Update();err != nil {
err = gerror.Wrap(err, "更新@{.tableComment}状态失败,请稍后重试!")
return
@@ -153,7 +152,7 @@ func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{
@{end}
@{ if eq .options.Step.HasSwitch true }
// Switch 更新@{.tableComment}开关
func (s *s@{.servFunName}) Switch(ctx context.Context, in @{.templateGroup}in.@{.varName}SwitchInp) (err error) {
func (s *s@{.servFunName}) Switch(ctx context.Context, in *@{.templateGroup}in.@{.varName}SwitchInp) (err error) {
var fields = []string{
@{.switchFields}
// ...