mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-08-28 00:51:13 +08:00
发布v2.8.4版本,更新内容请查看:https://github.com/bufanyun/hotgo/tree/v2.0/docs/guide-zh-CN/addon-version-upgrade.md
This commit is contained in:
@@ -15,6 +15,7 @@ type GetReq struct {
|
||||
g.Meta `path:"/config/get" method:"get" tags:"配置" summary:"获取指定分组的配置"`
|
||||
sysin.GetConfigInp
|
||||
}
|
||||
|
||||
type GetRes struct {
|
||||
*sysin.GetConfigModel
|
||||
}
|
||||
@@ -24,5 +25,6 @@ type UpdateReq struct {
|
||||
g.Meta `path:"/config/update" method:"post" tags:"配置" summary:"获取指定分组的配置"`
|
||||
sysin.UpdateConfigInp
|
||||
}
|
||||
|
||||
type UpdateRes struct {
|
||||
}
|
||||
|
@@ -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 index
|
||||
|
||||
import (
|
||||
|
@@ -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 table
|
||||
|
||||
import (
|
||||
@@ -36,6 +35,7 @@ type ViewReq struct {
|
||||
g.Meta `path:"/table/view" method:"get" tags:"表格" summary:"获取指定信息"`
|
||||
sysin.TableViewInp
|
||||
}
|
||||
|
||||
type ViewRes struct {
|
||||
*sysin.TableViewModel
|
||||
}
|
||||
@@ -45,6 +45,7 @@ type EditReq struct {
|
||||
g.Meta `path:"/table/edit" method:"post" tags:"表格" summary:"修改/新增表格"`
|
||||
sysin.TableEditInp
|
||||
}
|
||||
|
||||
type EditRes struct{}
|
||||
|
||||
// DeleteReq 删除
|
||||
@@ -52,12 +53,15 @@ type DeleteReq struct {
|
||||
g.Meta `path:"/table/delete" method:"post" tags:"表格" summary:"删除表格"`
|
||||
sysin.TableDeleteInp
|
||||
}
|
||||
|
||||
type DeleteRes struct{}
|
||||
|
||||
// MaxSortReq 最大排序
|
||||
type MaxSortReq struct {
|
||||
g.Meta `path:"/table/maxSort" method:"get" tags:"表格" summary:"表格最大排序"`
|
||||
sysin.TableMaxSortInp
|
||||
}
|
||||
|
||||
type MaxSortRes struct {
|
||||
*sysin.TableMaxSortModel
|
||||
}
|
||||
@@ -67,6 +71,7 @@ type StatusReq struct {
|
||||
g.Meta `path:"/table/status" method:"post" tags:"表格" summary:"更新表格状态"`
|
||||
sysin.TableStatusInp
|
||||
}
|
||||
|
||||
type StatusRes struct{}
|
||||
|
||||
// SwitchReq 更新开关状态
|
||||
@@ -74,4 +79,5 @@ type SwitchReq struct {
|
||||
g.Meta `path:"/table/switch" method:"post" tags:"表格" summary:"更新表格状态"`
|
||||
sysin.TableSwitchInp
|
||||
}
|
||||
|
||||
type SwitchRes struct{}
|
||||
|
@@ -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 index
|
||||
|
||||
import (
|
||||
|
@@ -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 index
|
||||
|
||||
import (
|
||||
|
@@ -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 index
|
||||
|
||||
import (
|
||||
|
@@ -7,11 +7,8 @@ package sys
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/api/admin/config"
|
||||
"hotgo/addons/hgexample/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
|
||||
}
|
||||
|
@@ -3,16 +3,12 @@
|
||||
// @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/hgexample/api/admin/index"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,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
|
||||
}
|
||||
|
@@ -3,17 +3,12 @@
|
||||
// @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/hgexample/api/admin/table"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/internal/model/input/form"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -24,57 +19,32 @@ type cTable struct{}
|
||||
|
||||
// List 查看列表
|
||||
func (c *cTable) List(ctx context.Context, req *table.ListReq) (res *table.ListRes, err error) {
|
||||
var in sysin.TableListInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
list, totalCount, err := service.SysTable().List(ctx, in)
|
||||
list, totalCount, err := service.SysTable().List(ctx, &req.TableListInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
res = new(table.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
|
||||
}
|
||||
|
||||
// Export 导出列表
|
||||
func (c *cTable) Export(ctx context.Context, req *table.ExportReq) (res *table.ExportRes, err error) {
|
||||
var in sysin.TableListInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysTable().Export(ctx, in)
|
||||
err = service.SysTable().Export(ctx, &req.TableListInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Edit 更新
|
||||
func (c *cTable) Edit(ctx context.Context, req *table.EditReq) (res *table.EditRes, err error) {
|
||||
var in sysin.TableEditInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
if err = validate.PreFilter(ctx, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysTable().Edit(ctx, in)
|
||||
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, sysin.TableMaxSortInp{})
|
||||
data, err := service.SysTable().MaxSort(ctx, &req.TableMaxSortInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -86,12 +56,7 @@ func (c *cTable) MaxSort(ctx context.Context, req *table.MaxSortReq) (res *table
|
||||
|
||||
// View 获取指定信息
|
||||
func (c *cTable) View(ctx context.Context, req *table.ViewReq) (res *table.ViewRes, err error) {
|
||||
var in sysin.TableViewInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
data, err := service.SysTable().View(ctx, in)
|
||||
data, err := service.SysTable().View(ctx, &req.TableViewInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -103,33 +68,18 @@ func (c *cTable) View(ctx context.Context, req *table.ViewReq) (res *table.ViewR
|
||||
|
||||
// Delete 删除
|
||||
func (c *cTable) Delete(ctx context.Context, req *table.DeleteReq) (res *table.DeleteRes, err error) {
|
||||
var in sysin.TableDeleteInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysTable().Delete(ctx, in)
|
||||
err = service.SysTable().Delete(ctx, &req.TableDeleteInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (c *cTable) Status(ctx context.Context, req *table.StatusReq) (res *table.StatusRes, err error) {
|
||||
var in sysin.TableStatusInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysTable().Status(ctx, in)
|
||||
err = service.SysTable().Status(ctx, &req.TableStatusInp)
|
||||
return
|
||||
}
|
||||
|
||||
// Switch 更新开关状态
|
||||
func (c *cTable) Switch(ctx context.Context, req *table.SwitchReq) (res *table.SwitchRes, err error) {
|
||||
var in sysin.TableSwitchInp
|
||||
if err = gconv.Scan(req, &in); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = service.SysTable().Switch(ctx, in)
|
||||
err = service.SysTable().Switch(ctx, &req.TableSwitchInp)
|
||||
return
|
||||
}
|
||||
|
@@ -3,16 +3,12 @@
|
||||
// @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/hgexample/api/api/index"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,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
|
||||
}
|
||||
|
@@ -8,13 +8,10 @@ package home
|
||||
import (
|
||||
"context"
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/hgexample/api/home/index"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/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
|
||||
}
|
||||
|
@@ -3,16 +3,12 @@
|
||||
// @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/hgexample/api/websocket/index"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/utility/validate"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -23,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
|
||||
}
|
||||
|
@@ -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
|
||||
|
||||
// 定时任务.
|
||||
|
@@ -1,3 +1,8 @@
|
||||
// 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 (
|
||||
@@ -25,7 +30,7 @@ func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err
|
||||
var in sysin.GetConfigInp
|
||||
in.GetAddonsConfigInp.AddonName = global.GetSkeleton().Name
|
||||
in.GetAddonsConfigInp.Group = "basic"
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, in.GetAddonsConfigInp)
|
||||
models, err := isc.SysAddonsConfig().GetConfigByGroup(ctx, &in.GetAddonsConfigInp)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -35,9 +40,9 @@ func (s *sSysConfig) GetBasic(ctx context.Context) (conf *model.BasicConfig, err
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
@@ -48,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)
|
||||
}
|
||||
|
@@ -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)
|
||||
|
@@ -15,7 +15,6 @@ import (
|
||||
"github.com/gogf/gf/v2/util/gconv"
|
||||
"hotgo/addons/hgexample/model/input/sysin"
|
||||
"hotgo/addons/hgexample/service"
|
||||
"hotgo/internal/consts"
|
||||
"hotgo/internal/dao"
|
||||
"hotgo/internal/library/contexts"
|
||||
"hotgo/internal/library/hgorm"
|
||||
@@ -42,54 +41,55 @@ func (s *sSysTable) Model(ctx context.Context, option ...*handler.Option) *gdb.M
|
||||
}
|
||||
|
||||
// List 获取列表
|
||||
func (s *sSysTable) List(ctx context.Context, in sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error) {
|
||||
func (s *sSysTable) List(ctx context.Context, in *sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error) {
|
||||
mod := s.Model(ctx)
|
||||
cols := dao.AddonHgexampleTable.Columns()
|
||||
|
||||
if in.Title != "" {
|
||||
mod = mod.WhereLike(dao.AddonHgexampleTable.Columns().Title, "%"+in.Title+"%")
|
||||
mod = mod.WhereLike(cols.Title, "%"+in.Title+"%")
|
||||
}
|
||||
|
||||
if in.Content != "" {
|
||||
mod = mod.WhereLike(dao.AddonHgexampleTable.Columns().Content, "%"+in.Content+"%")
|
||||
mod = mod.WhereLike(cols.Content, "%"+in.Content+"%")
|
||||
}
|
||||
|
||||
if in.Status > 0 {
|
||||
mod = mod.Where(dao.AddonHgexampleTable.Columns().Status, in.Status)
|
||||
mod = mod.Where(cols.Status, in.Status)
|
||||
}
|
||||
|
||||
if in.Switch > 0 {
|
||||
mod = mod.Where(dao.AddonHgexampleTable.Columns().Switch, in.Switch)
|
||||
mod = mod.Where(cols.Switch, in.Switch)
|
||||
}
|
||||
|
||||
if len(in.Price) > 0 {
|
||||
if in.Price[0] > float64(0) && in.Price[1] > float64(0) {
|
||||
mod = mod.WhereBetween(dao.AddonHgexampleTable.Columns().Price, in.Price[0], in.Price[1])
|
||||
} else if in.Price[0] > float64(0) && in.Price[1] == float64(0) {
|
||||
mod = mod.WhereGTE(dao.AddonHgexampleTable.Columns().Price, in.Price[0])
|
||||
} else if in.Price[0] == float64(0) && in.Price[1] > float64(0) {
|
||||
mod = mod.WhereLTE(dao.AddonHgexampleTable.Columns().Price, in.Price[1])
|
||||
if in.Price[0] > 0 && in.Price[1] > 0 {
|
||||
mod = mod.WhereBetween(cols.Price, in.Price[0], in.Price[1])
|
||||
} else if in.Price[0] > 0 && in.Price[1] == 0 {
|
||||
mod = mod.WhereGTE(cols.Price, in.Price[0])
|
||||
} else if in.Price[0] == 0 && in.Price[1] > 0 {
|
||||
mod = mod.WhereLTE(cols.Price, in.Price[1])
|
||||
}
|
||||
}
|
||||
|
||||
if in.ActivityAt != nil {
|
||||
mod = mod.Where(dao.AddonHgexampleTable.Columns().ActivityAt, in.ActivityAt)
|
||||
mod = mod.Where(cols.ActivityAt, in.ActivityAt)
|
||||
}
|
||||
|
||||
if len(in.CreatedAt) == 2 {
|
||||
mod = mod.WhereBetween(dao.AddonHgexampleTable.Columns().CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
||||
mod = mod.WhereBetween(cols.CreatedAt, in.CreatedAt[0], in.CreatedAt[1])
|
||||
}
|
||||
|
||||
if !in.Flag.IsNil() {
|
||||
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, dao.AddonHgexampleTable.Columns().Flag, in.Flag))
|
||||
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Flag, in.Flag))
|
||||
}
|
||||
|
||||
if !in.Hobby.IsNil() {
|
||||
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, dao.AddonHgexampleTable.Columns().Hobby, in.Hobby))
|
||||
mod = mod.Where(fmt.Sprintf(`JSON_CONTAINS(%s,'%v')`, cols.Hobby, in.Hobby))
|
||||
}
|
||||
|
||||
//// 关联表testCategory
|
||||
//mod = mod.LeftJoin(hgorm.GenJoinOnRelation(
|
||||
// dao.AddonHgexampleTable.Table(), dao.AddonHgexampleTable.Columns().CategoryId, // 主表表名,关联条件
|
||||
// dao.AddonHgexampleTable.Table(), cols.CategoryId, // 主表表名,关联条件
|
||||
// dao.AddonHgexampleTableCategory.Table(), "testCategory", dao.AddonHgexampleTableCategory.Columns().Id, // 关联表表名,别名,关联条件
|
||||
//)...)
|
||||
//
|
||||
@@ -97,7 +97,7 @@ func (s *sSysTable) List(ctx context.Context, in sysin.TableListInp) (list []*sy
|
||||
|
||||
totalCount, err = mod.Clone().Count(1)
|
||||
if err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
err = gerror.Wrap(err, "获取表格数据行失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -105,15 +105,15 @@ func (s *sSysTable) List(ctx context.Context, in sysin.TableListInp) (list []*sy
|
||||
return
|
||||
}
|
||||
|
||||
if err = mod.Fields(sysin.TableListModel{}).Page(in.Page, in.PerPage).OrderAsc(dao.AddonHgexampleTable.Columns().Sort).OrderDesc(dao.AddonHgexampleTable.Columns().Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
if err = mod.Fields(sysin.TableListModel{}).Page(in.Page, in.PerPage).OrderAsc(cols.Sort).OrderDesc(cols.Id).Scan(&list); err != nil {
|
||||
err = gerror.Wrap(err, "获取表格列表失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Export 导出
|
||||
func (s *sSysTable) Export(ctx context.Context, in sysin.TableListInp) (err error) {
|
||||
func (s *sSysTable) Export(ctx context.Context, in *sysin.TableListInp) (err error) {
|
||||
list, totalCount, err := s.List(ctx, in)
|
||||
if err != nil {
|
||||
return
|
||||
@@ -142,57 +142,56 @@ func (s *sSysTable) Export(ctx context.Context, in sysin.TableListInp) (err erro
|
||||
}
|
||||
|
||||
// Edit 修改/新增
|
||||
func (s *sSysTable) Edit(ctx context.Context, in sysin.TableEditInp) (err error) {
|
||||
if err = hgorm.IsUnique(ctx, &dao.AddonHgexampleTable, g.Map{dao.AddonHgexampleTable.Columns().Qq: in.Qq}, "QQ号码已存在,请换一个", in.Id); err != nil {
|
||||
func (s *sSysTable) Edit(ctx context.Context, in *sysin.TableEditInp) (err error) {
|
||||
cols := dao.AddonHgexampleTable.Columns()
|
||||
if err = hgorm.IsUnique(ctx, &dao.AddonHgexampleTable, g.Map{cols.Qq: in.Qq}, "QQ号码已存在,请换一个", in.Id); err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
// 修改
|
||||
if in.Id > 0 {
|
||||
in.UpdatedBy = contexts.GetUserId(ctx)
|
||||
_, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Data(in).Update()
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Data(in).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "修改表格失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 新增
|
||||
in.CreatedBy = contexts.GetUserId(ctx)
|
||||
_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).Insert()
|
||||
if _, err = s.Model(ctx, &handler.Option{FilterAuth: false}).Data(in).Insert(); err != nil {
|
||||
err = gerror.Wrap(err, "新增表格失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Delete 删除
|
||||
func (s *sSysTable) Delete(ctx context.Context, in sysin.TableDeleteInp) (err error) {
|
||||
_, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Delete()
|
||||
func (s *sSysTable) Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error) {
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
|
||||
err = gerror.Wrap(err, "删除表格失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Status 更新状态
|
||||
func (s *sSysTable) Status(ctx context.Context, in sysin.TableStatusInp) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Status <= 0 {
|
||||
err = gerror.New("状态不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSlice(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
|
||||
// 修改
|
||||
_, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Data(g.Map{
|
||||
func (s *sSysTable) Status(ctx context.Context, in *sysin.TableStatusInp) (err error) {
|
||||
update := g.Map{
|
||||
dao.AddonHgexampleTable.Columns().Status: in.Status,
|
||||
dao.AddonHgexampleTable.Columns().UpdatedBy: contexts.GetUserId(ctx),
|
||||
}).Update()
|
||||
}
|
||||
|
||||
if _, err = s.Model(ctx).WherePri(in.Id).Data(update).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "更新表格状态失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Switch 更新开关状态
|
||||
func (s *sSysTable) Switch(ctx context.Context, in sysin.TableSwitchInp) (err error) {
|
||||
func (s *sSysTable) Switch(ctx context.Context, in *sysin.TableSwitchInp) (err error) {
|
||||
var fields = []string{
|
||||
dao.AddonHgexampleTable.Columns().Switch,
|
||||
// ...
|
||||
@@ -203,18 +202,23 @@ func (s *sSysTable) Switch(ctx context.Context, in sysin.TableSwitchInp) (err er
|
||||
return
|
||||
}
|
||||
|
||||
// 修改
|
||||
_, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Data(g.Map{
|
||||
update := g.Map{
|
||||
in.Key: in.Value,
|
||||
dao.AddonHgexampleTable.Columns().UpdatedBy: contexts.GetUserId(ctx),
|
||||
}).Update()
|
||||
}
|
||||
|
||||
if _, err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Data(update).Update(); err != nil {
|
||||
err = gerror.Wrap(err, "更新表格开关失败,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// MaxSort 最大排序
|
||||
func (s *sSysTable) MaxSort(ctx context.Context, in sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error) {
|
||||
if err = dao.AddonHgexampleTable.Ctx(ctx).Fields(dao.AddonHgexampleTable.Columns().Sort).OrderDesc(dao.AddonHgexampleTable.Columns().Sort).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, consts.ErrorORM)
|
||||
func (s *sSysTable) MaxSort(ctx context.Context, in *sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error) {
|
||||
dx := dao.AddonHgexampleTable
|
||||
if err = dx.Ctx(ctx).Fields(dx.Columns().Sort).OrderDesc(dx.Columns().Sort).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取表格最大排序,请稍后重试!")
|
||||
return
|
||||
}
|
||||
|
||||
@@ -222,12 +226,15 @@ func (s *sSysTable) MaxSort(ctx context.Context, in sysin.TableMaxSortInp) (res
|
||||
res = new(sysin.TableMaxSortModel)
|
||||
}
|
||||
|
||||
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
|
||||
res.Sort = form.DefaultMaxSort(res.Sort)
|
||||
return
|
||||
}
|
||||
|
||||
// View 获取指定信息
|
||||
func (s *sSysTable) View(ctx context.Context, in sysin.TableViewInp) (res *sysin.TableViewModel, err error) {
|
||||
err = s.Model(ctx).Where(dao.AddonHgexampleTable.Columns().Id, in.Id).Scan(&res)
|
||||
func (s *sSysTable) View(ctx context.Context, in *sysin.TableViewInp) (res *sysin.TableViewModel, err error) {
|
||||
if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
|
||||
err = gerror.Wrap(err, "获取生成演示信息,请稍后重试!")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@@ -9,6 +9,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"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/os/gtime"
|
||||
"hotgo/internal/consts"
|
||||
@@ -149,6 +150,24 @@ type TableStatusInp struct {
|
||||
Status int `json:"status" dc:"状态"`
|
||||
}
|
||||
|
||||
func (in *TableStatusInp) Filter(ctx context.Context) (err error) {
|
||||
if in.Id <= 0 {
|
||||
err = gerror.New("ID不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if in.Status <= 0 {
|
||||
err = gerror.New("状态不能为空")
|
||||
return
|
||||
}
|
||||
|
||||
if !validate.InSlice(consts.StatusSlice, in.Status) {
|
||||
err = gerror.New("状态不正确")
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
type TableStatusModel struct{}
|
||||
|
||||
// TableSwitchInp 更新开关状态
|
||||
|
@@ -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
|
||||
|
||||
// 消息队列.
|
||||
|
@@ -17,29 +17,29 @@ 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)
|
||||
}
|
||||
ISysTable interface {
|
||||
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
|
||||
List(ctx context.Context, in sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error)
|
||||
Export(ctx context.Context, in sysin.TableListInp) (err error)
|
||||
Edit(ctx context.Context, in sysin.TableEditInp) (err error)
|
||||
Delete(ctx context.Context, in sysin.TableDeleteInp) (err error)
|
||||
Status(ctx context.Context, in sysin.TableStatusInp) (err error)
|
||||
Switch(ctx context.Context, in sysin.TableSwitchInp) (err error)
|
||||
MaxSort(ctx context.Context, in sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error)
|
||||
View(ctx context.Context, in sysin.TableViewInp) (res *sysin.TableViewModel, err error)
|
||||
List(ctx context.Context, in *sysin.TableListInp) (list []*sysin.TableListModel, totalCount int, err error)
|
||||
Export(ctx context.Context, in *sysin.TableListInp) (err error)
|
||||
Edit(ctx context.Context, in *sysin.TableEditInp) (err error)
|
||||
Delete(ctx context.Context, in *sysin.TableDeleteInp) (err error)
|
||||
Status(ctx context.Context, in *sysin.TableStatusInp) (err error)
|
||||
Switch(ctx context.Context, in *sysin.TableSwitchInp) (err error)
|
||||
MaxSort(ctx context.Context, in *sysin.TableMaxSortInp) (res *sysin.TableMaxSortModel, err error)
|
||||
View(ctx context.Context, in *sysin.TableViewInp) (res *sysin.TableViewModel, err error)
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
localSysTable ISysTable
|
||||
localSysConfig ISysConfig
|
||||
localSysIndex ISysIndex
|
||||
localSysTable ISysTable
|
||||
)
|
||||
|
||||
func SysConfig() ISysConfig {
|
||||
|
Reference in New Issue
Block a user