diff --git a/server/api/admin/curddemo/curddemo.go b/server/api/admin/curddemo/curddemo.go
index 46fe45f..612eb44 100644
--- a/server/api/admin/curddemo/curddemo.go
+++ b/server/api/admin/curddemo/curddemo.go
@@ -3,8 +3,7 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-// @AutoGenerate Version 2.5.3
-// @AutoGenerate Date 2023-04-28 15:28:40
+// @AutoGenerate Version 2.7.3
package curddemo
import (
diff --git a/server/api/admin/dept/dept.go b/server/api/admin/dept/dept.go
index eff93a4..8879575 100644
--- a/server/api/admin/dept/dept.go
+++ b/server/api/admin/dept/dept.go
@@ -12,16 +12,6 @@ import (
"hotgo/internal/model/input/form"
)
-// NameUniqueReq 名称是否唯一
-type NameUniqueReq struct {
- Name string `json:"name" v:"required#部门名称不能为空" dc:"部门名称"`
- Id int64 `json:"id" dc:"部门ID"`
- g.Meta `path:"/dept/name_unique" method:"get" tags:"部门" summary:"部门名称是否唯一"`
-}
-type NameUniqueRes struct {
- IsUnique bool `json:"is_unique" dc:"是否唯一"`
-}
-
// ListReq 查询列表
type ListReq struct {
Name string `json:"name" dc:"部门名称"`
diff --git a/server/api/admin/role/role.go b/server/api/admin/role/role.go
index 596fe14..159d2d3 100644
--- a/server/api/admin/role/role.go
+++ b/server/api/admin/role/role.go
@@ -3,38 +3,14 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-//
package role
import (
"github.com/gogf/gf/v2/frame/g"
- "hotgo/internal/model/entity"
"hotgo/internal/model/input/adminin"
"hotgo/internal/model/input/form"
)
-// MemberListReq 查询列表
-type MemberListReq struct {
- g.Meta `path:"/role/member_list" method:"get" tags:"角色" summary:"获取角色下的用户列表"`
- form.PageReq
- form.RangeDateReq
- form.StatusReq
- Role int `json:"role" description:"角色ID"`
- DeptId int `json:"deptId" description:"部门ID"`
- Mobile int `json:"mobile" description:"手机号"`
- Username string `json:"username" description:"用户名"`
- Realname string `json:"realname" description:"真实姓名"`
- StartTime string `json:"start_time" description:"开始时间"`
- EndTime string `json:"end_time" description:"结束时间"`
- Name string `json:"name" description:"岗位名称"`
- Code string `json:"code" description:"岗位编码"`
-}
-
-type MemberListRes struct {
- List []*adminin.MemberListModel `json:"list" description:"数据列表"`
- form.PageRes
-}
-
// ListReq 查询列表
type ListReq struct {
g.Meta `path:"/role/list" method:"get" tags:"角色" summary:"获取角色列表"`
@@ -81,42 +57,33 @@ type DynamicRes struct {
List []adminin.MenuRoute `json:"list" description:"数据列表"`
}
-type MenuEditReq struct {
- g.Meta `path:"/role/edit" method:"post" tags:"角色" summary:"编辑角色"`
- RoleId int64 `json:"id"`
- MenuIds []int64 `json:"menuIds"`
-}
-
-type MenuEditRes struct{}
-
type UpdatePermissionsReq struct {
- g.Meta `path:"/role/updatePermissions" method:"post" tags:"角色" summary:"编辑角色菜单权限"`
- RoleId int64 `json:"id"`
- MenuIds []int64 `json:"menuIds"`
+ g.Meta `path:"/role/updatePermissions" method:"post" tags:"角色" summary:"编辑角色菜单权限"`
+ adminin.UpdatePermissionsInp
}
type UpdatePermissionsRes struct{}
type GetPermissionsReq struct {
g.Meta `path:"/role/getPermissions" method:"get" tags:"角色" summary:"获取指定角色权限"`
- RoleId int64 `json:"id"`
+ adminin.GetPermissionsInp
}
type GetPermissionsRes struct {
- MenuIds []int64 `json:"menuIds"`
+ *adminin.GetPermissionsModel
}
// EditReq 修改/新增角色
type EditReq struct {
g.Meta `path:"/role/edit" method:"post" tags:"角色" summary:"修改/新增角色"`
- entity.AdminRole
+ adminin.RoleEditInp
}
type EditRes struct{}
// DeleteReq 删除角色
type DeleteReq struct {
g.Meta `path:"/role/delete" method:"post" tags:"角色" summary:"删除角色"`
- Id int64 `json:"id" v:"required"`
+ adminin.RoleDeleteInp
}
type DeleteRes struct{}
diff --git a/server/internal/consts/config.go b/server/internal/consts/config.go
index 7c9c80d..1a85e77 100644
--- a/server/internal/consts/config.go
+++ b/server/internal/consts/config.go
@@ -5,7 +5,9 @@
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
package consts
-import "github.com/gogf/gf/v2/util/gconv"
+import (
+ "github.com/gogf/gf/v2/util/gconv"
+)
// RequestEncryptKey
// 请求加密密钥用于敏感数据加密,16位字符,前后端需保持一致
@@ -44,6 +46,29 @@ var ConfigTypes = []string{ConfigTypeString,
ConfigTypeSliceString, ConfigTypeSliceInt, ConfigTypeSliceInt64,
}
+// ConfigMaskDemoField 演示环境下需要隐藏的配置
+var ConfigMaskDemoField = map[string]struct{}{
+ // 邮箱
+ "smtpUser": {}, "smtpPass": {},
+
+ // 云存储
+ "uploadUCloudPublicKey": {}, "uploadUCloudPrivateKey": {}, "uploadCosSecretId": {}, "uploadCosSecretKey": {},
+ "uploadOssSecretId": {}, "uploadOssSecretKey": {}, "uploadQiNiuAccessKey": {}, "uploadQiNiuSecretKey": {},
+
+ // 地图
+ "geoAmapWebKey": {},
+
+ // 短信
+ "smsAliYunAccessKeyID": {}, "smsAliYunAccessKeySecret": {}, "smsTencentSecretId": {}, "smsTencentSecretKey": {},
+
+ // 支付
+ "payWxPayMchId": {}, "payWxPaySerialNo": {}, "payWxPayAPIv3Key": {}, "payWxPayPrivateKey": {}, "payQQPayMchId": {}, "payQQPayApiKey": {},
+
+ // 微信
+ "officialAccountAppSecret": {}, "officialAccountToken": {}, "officialAccountEncodingAESKey": {}, "openPlatformAppSecret": {},
+ "openPlatformToken": {}, "openPlatformEncodingAESKey": {},
+}
+
// ConvType 类型转换
func ConvType(val interface{}, t string) interface{} {
switch t {
diff --git a/server/internal/controller/admin/admin/cash.go b/server/internal/controller/admin/admin/cash.go
index 92e99e6..d9bbdfa 100644
--- a/server/internal/controller/admin/admin/cash.go
+++ b/server/internal/controller/admin/admin/cash.go
@@ -22,27 +22,27 @@ var (
type cCash struct{}
// View 获取指定信息
-func (c *cCash) View(ctx context.Context, req *cash.ViewReq) (*cash.ViewRes, error) {
+func (c *cCash) View(ctx context.Context, req *cash.ViewReq) (res *cash.ViewRes, err error) {
data, err := service.AdminCash().View(ctx, adminin.CashViewInp{Id: req.Id})
if err != nil {
- return nil, err
+ return
}
- var res cash.ViewRes
+ res = new(cash.ViewRes)
res.CashViewModel = data
- return &res, nil
+ return
}
// List 查看列表
func (c *cCash) List(ctx context.Context, req *cash.ListReq) (res *cash.ListRes, err error) {
var in adminin.CashListInp
if err = gconv.Scan(req, &in); err != nil {
- return nil, err
+ return
}
list, totalCount, err := service.AdminCash().List(ctx, in)
if err != nil {
- return nil, err
+ return
}
res = new(cash.ListRes)
diff --git a/server/internal/controller/admin/admin/credits_log.go b/server/internal/controller/admin/admin/credits_log.go
index 183910b..ad07a99 100644
--- a/server/internal/controller/admin/admin/credits_log.go
+++ b/server/internal/controller/admin/admin/credits_log.go
@@ -65,7 +65,7 @@ func (c *cCreditsLog) Export(ctx context.Context, req *creditslog.ExportReq) (re
}
// Option 获取变动状态选项
-func (c *cCreditsLog) Option(ctx context.Context, req *creditslog.OptionReq) (res *creditslog.OptionRes, err error) {
+func (c *cCreditsLog) Option(_ context.Context, _ *creditslog.OptionReq) (res *creditslog.OptionRes, err error) {
res = &creditslog.OptionRes{
CreditType: consts.CreditTypeOptions,
CreditGroup: consts.CreditGroupOptions,
diff --git a/server/internal/controller/admin/admin/dept.go b/server/internal/controller/admin/admin/dept.go
index 9311826..fbf7ab8 100644
--- a/server/internal/controller/admin/admin/dept.go
+++ b/server/internal/controller/admin/admin/dept.go
@@ -12,6 +12,7 @@ import (
"hotgo/internal/model/input/adminin"
"hotgo/internal/model/input/form"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -20,18 +21,6 @@ var (
type cDept struct{}
-// NameUnique 名称是否唯一
-func (c *cDept) NameUnique(ctx context.Context, req *dept.NameUniqueReq) (res *dept.NameUniqueRes, err error) {
- data, err := service.AdminDept().NameUnique(ctx, adminin.DeptNameUniqueInp{Id: req.Id, Name: req.Name})
- if err != nil {
- return
- }
-
- res = new(dept.NameUniqueRes)
- res.IsUnique = data.IsUnique
- return
-}
-
// Delete 删除
func (c *cDept) Delete(ctx context.Context, req *dept.DeleteReq) (res *dept.DeleteRes, err error) {
var in adminin.DeptDeleteInp
@@ -50,6 +39,10 @@ func (c *cDept) Edit(ctx context.Context, req *dept.EditReq) (res *dept.EditRes,
return nil, err
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.AdminDept().Edit(ctx, in)
return
}
@@ -102,6 +95,10 @@ func (c *cDept) Status(ctx context.Context, req *dept.StatusReq) (res *dept.Stat
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.AdminDept().Status(ctx, in)
return
}
diff --git a/server/internal/controller/admin/admin/member.go b/server/internal/controller/admin/admin/member.go
index da3ed1b..8d7a1e9 100644
--- a/server/internal/controller/admin/admin/member.go
+++ b/server/internal/controller/admin/admin/member.go
@@ -115,6 +115,10 @@ func (c *cMember) Delete(ctx context.Context, req *member.DeleteReq) (res *membe
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.AdminMember().Delete(ctx, in)
return
}
@@ -174,12 +178,16 @@ func (c *cMember) Status(ctx context.Context, req *member.StatusReq) (res *membe
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.AdminMember().Status(ctx, in)
return
}
// Select 获取可选的后台用户选项
-func (c *cMember) Select(ctx context.Context, req *member.SelectReq) (res *member.SelectRes, err error) {
+func (c *cMember) Select(ctx context.Context, _ *member.SelectReq) (res *member.SelectRes, err error) {
data, err := service.AdminMember().Select(ctx, adminin.MemberSelectInp{})
if err != nil {
return
diff --git a/server/internal/controller/admin/admin/role.go b/server/internal/controller/admin/admin/role.go
index a8b26e8..436a228 100644
--- a/server/internal/controller/admin/admin/role.go
+++ b/server/internal/controller/admin/admin/role.go
@@ -13,6 +13,7 @@ import (
"hotgo/internal/model/input/adminin"
"hotgo/internal/model/input/form"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -21,26 +22,6 @@ var (
type cRole struct{}
-// RoleMemberList 获取角色下的用户列表
-func (c *cRole) RoleMemberList(ctx context.Context, req *role.MemberListReq) (res *role.MemberListRes, err error) {
- var in adminin.RoleMemberListInp
- if err = gconv.Scan(req, &in); err != nil {
- return
- }
-
- list, totalCount, err := service.AdminMember().RoleMemberList(ctx, in)
- if err != nil {
- return
- }
-
- res = new(role.MemberListRes)
- res.List = list
- res.PageCount = form.CalPageCount(totalCount, req.PerPage)
- res.PerPage = req.Page
- res.PerPage = req.PerPage
- return
-}
-
// List 获取列表
func (c *cRole) List(ctx context.Context, req *role.ListReq) (res *role.ListRes, err error) {
var in adminin.RoleListInp
@@ -63,49 +44,79 @@ func (c *cRole) List(ctx context.Context, req *role.ListReq) (res *role.ListRes,
// Edit 修改角色
func (c *cRole) Edit(ctx context.Context, req *role.EditReq) (res *role.EditRes, err error) {
- err = service.AdminRole().Edit(ctx, req)
+ var in adminin.RoleEditInp
+ if err = gconv.Scan(req, &in); err != nil {
+ return
+ }
+
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
+ err = service.AdminRole().Edit(ctx, in)
return
}
// Delete 删除
func (c *cRole) Delete(ctx context.Context, req *role.DeleteReq) (res *role.DeleteRes, err error) {
- err = service.AdminRole().Delete(ctx, req)
+ var in adminin.RoleDeleteInp
+ if err = gconv.Scan(req, &in); err != nil {
+ return
+ }
+
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
+ err = service.AdminRole().Delete(ctx, in)
return
}
// Dynamic 动态路由
-func (c *cRole) Dynamic(ctx context.Context, req *role.DynamicReq) (res role.DynamicRes, err error) {
+func (c *cRole) Dynamic(ctx context.Context, _ *role.DynamicReq) (res *role.DynamicRes, err error) {
return service.AdminMenu().GetMenuList(ctx, contexts.GetUserId(ctx))
}
// GetPermissions 获取指定角色权限
func (c *cRole) GetPermissions(ctx context.Context, req *role.GetPermissionsReq) (res *role.GetPermissionsRes, err error) {
- MenuIds, err := service.AdminRole().GetPermissions(ctx, req)
+ var in adminin.GetPermissionsInp
+ if err = gconv.Scan(req, &in); err != nil {
+ return
+ }
+
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
+ data, err := service.AdminRole().GetPermissions(ctx, in)
if err != nil {
- return nil, err
+ return
}
- res = &role.GetPermissionsRes{
- MenuIds: []int64{},
- }
-
- if MenuIds != nil {
- res.MenuIds = MenuIds
- }
- return res, nil
+ res = new(role.GetPermissionsRes)
+ res.GetPermissionsModel = data
+ return
}
// UpdatePermissions 修改角色菜单权限
func (c *cRole) UpdatePermissions(ctx context.Context, req *role.UpdatePermissionsReq) (res *role.UpdatePermissionsRes, err error) {
- err = service.AdminRole().UpdatePermissions(ctx, req)
+ var in adminin.UpdatePermissionsInp
+ if err = gconv.Scan(req, &in); err != nil {
+ return
+ }
+
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
+ err = service.AdminRole().UpdatePermissions(ctx, in)
return
}
// DataScopeSelect 获取数据权限选项
-func (c *cRole) DataScopeSelect(ctx context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
- data := service.AdminRole().DataScopeSelect(ctx)
+func (c *cRole) DataScopeSelect(_ context.Context, _ *role.DataScopeSelectReq) (res *role.DataScopeSelectRes, err error) {
res = new(role.DataScopeSelectRes)
- res.List = data
+ res.List = service.AdminRole().DataScopeSelect()
return
}
@@ -117,6 +128,10 @@ func (c *cRole) DataScopeEdit(ctx context.Context, req *role.DataScopeEditReq) (
}
in.CustomDept = req.CustomDept
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.AdminRole().DataScopeEdit(ctx, &in)
return
}
diff --git a/server/internal/controller/admin/sys/cron_group.go b/server/internal/controller/admin/sys/cron_group.go
index 6037af2..3ddffa5 100644
--- a/server/internal/controller/admin/sys/cron_group.go
+++ b/server/internal/controller/admin/sys/cron_group.go
@@ -12,6 +12,7 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -38,6 +39,10 @@ func (c *cCronGroup) Edit(ctx context.Context, req *cron.GroupEditReq) (res *cro
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysCronGroup().Edit(ctx, in)
return res, nil
}
@@ -93,6 +98,10 @@ func (c *cCronGroup) Status(ctx context.Context, req *cron.GroupStatusReq) (res
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysCronGroup().Status(ctx, in)
return res, nil
}
diff --git a/server/internal/controller/admin/sys/curd_demo.go b/server/internal/controller/admin/sys/curd_demo.go
index 9b63e42..89a6800 100644
--- a/server/internal/controller/admin/sys/curd_demo.go
+++ b/server/internal/controller/admin/sys/curd_demo.go
@@ -3,8 +3,7 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-// @AutoGenerate Version 2.5.3
-// @AutoGenerate Date 2023-04-28 15:28:40
+// @AutoGenerate Version 2.7.3
package sys
import (
diff --git a/server/internal/controller/admin/sys/dict_data.go b/server/internal/controller/admin/sys/dict_data.go
index e0f5e28..a218d86 100644
--- a/server/internal/controller/admin/sys/dict_data.go
+++ b/server/internal/controller/admin/sys/dict_data.go
@@ -13,6 +13,7 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -39,6 +40,10 @@ func (c *cDictData) Edit(ctx context.Context, req *dict.DataEditReq) (res *dict.
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysDictData().Edit(ctx, in)
return
}
diff --git a/server/internal/controller/admin/sys/dict_type.go b/server/internal/controller/admin/sys/dict_type.go
index 0ec805b..86afb6a 100644
--- a/server/internal/controller/admin/sys/dict_type.go
+++ b/server/internal/controller/admin/sys/dict_type.go
@@ -11,6 +11,7 @@ import (
"hotgo/api/admin/dict"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -44,6 +45,10 @@ func (c *cDictType) Edit(ctx context.Context, req *dict.TypeEditReq) (res *dict.
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysDictType().Edit(ctx, in)
return
}
diff --git a/server/internal/controller/admin/sys/provinces.go b/server/internal/controller/admin/sys/provinces.go
index 9ba15cb..9418699 100644
--- a/server/internal/controller/admin/sys/provinces.go
+++ b/server/internal/controller/admin/sys/provinces.go
@@ -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 sys
import (
@@ -14,6 +13,7 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
+ "hotgo/utility/validate"
)
var (
@@ -23,7 +23,7 @@ var (
type cProvinces struct{}
// Tree 关系树选项列表
-func (c *cProvinces) Tree(ctx context.Context, req *provinces.TreeReq) (res *provinces.TreeRes, err error) {
+func (c *cProvinces) Tree(ctx context.Context, _ *provinces.TreeReq) (res *provinces.TreeRes, err error) {
res = new(provinces.TreeRes)
res.List, err = service.SysProvinces().Tree(ctx)
return
@@ -47,6 +47,10 @@ func (c *cProvinces) Edit(ctx context.Context, req *provinces.EditReq) (res *pro
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysProvinces().Edit(ctx, in)
return
}
@@ -102,6 +106,10 @@ func (c *cProvinces) Status(ctx context.Context, req *provinces.StatusReq) (res
return
}
+ if err = validate.PreFilter(ctx, &in); err != nil {
+ return
+ }
+
err = service.SysProvinces().Status(ctx, in)
return
}
diff --git a/server/internal/global/init.go b/server/internal/global/init.go
index e946f8a..d6bafbd 100644
--- a/server/internal/global/init.go
+++ b/server/internal/global/init.go
@@ -30,14 +30,13 @@ func Init(ctx context.Context) {
// 设置服务日志处理
g.Log().SetHandlers(LoggingServeLogHandler)
- _, err := g.Cfg().Get(ctx, "hotgo.debug")
- if err != nil {
+ if _, err := g.Cfg().Get(ctx, "hotgo.debug"); err != nil {
g.Log().Fatal(ctx, "配置读取异常:", err, "\r\n你确定 config/config.yaml 文件存在且格式正确吗?\r\n")
return
}
// 默认上海时区
- if err = gtime.SetTimeZone("Asia/Shanghai"); err != nil {
+ if err := gtime.SetTimeZone("Asia/Shanghai"); err != nil {
g.Log().Fatalf(ctx, "时区设置异常 err:%+v", err)
return
}
diff --git a/server/internal/library/hggen/views/column_default.go b/server/internal/library/hggen/views/column_default.go
index 1944004..c205a25 100644
--- a/server/internal/library/hggen/views/column_default.go
+++ b/server/internal/library/hggen/views/column_default.go
@@ -23,6 +23,13 @@ var defaultFormModeMap = map[string]string{
TsTypeAny: FormModeInput,
}
+var defaultEditFields = map[string]bool{
+ "id": false,
+ "created_at": false,
+ "updated_at": false,
+ "deleted_at": false,
+}
+
var defaultEditSwitch = map[string]bool{
"id": false,
"level": false,
@@ -33,6 +40,7 @@ var defaultEditSwitch = map[string]bool{
"updated_at": false,
"deleted_at": false,
}
+
var defaultListSwitch = map[string]bool{
"level": false,
"tree": false,
@@ -135,6 +143,10 @@ func setDefaultEdit(field *sysin.GenCodesColumnListModel) {
return
}
+ if df, ok := defaultEditFields[field.Name]; ok {
+ field.IsEdit = df
+ }
+
if df, ok := defaultEditSwitch[field.Name]; ok {
field.IsEdit = df
}
diff --git a/server/internal/library/hggen/views/curd_generate_input.go b/server/internal/library/hggen/views/curd_generate_input.go
index 8616b54..b00ec04 100644
--- a/server/internal/library/hggen/views/curd_generate_input.go
+++ b/server/internal/library/hggen/views/curd_generate_input.go
@@ -25,7 +25,8 @@ const (
InputTypeListModel = 2 // 列表输出
InputTypeExportModel = 3 // 列表导出
InputTypeEditInpValidator = 4 // 添加&编辑验证器
-
+ InputTypeUpdateFields = 5 // 编辑修改过滤字段
+ InputTypeInsertFields = 6 // 编辑新增过滤字段
EditInpValidatorGenerally = "if err := g.Validator().Rules(\"%s\").Data(in.%s).Messages(\"%s\").Run(ctx); err != nil {\n\t\treturn err.Current()\n\t}\n"
)
@@ -35,6 +36,8 @@ func (l *gCurd) inputTplData(ctx context.Context, in *CurdPreviewInput) (data g.
data["listModelColumns"] = l.generateInputListColumns(ctx, in, InputTypeListModel)
data["exportModelColumns"] = l.generateInputListColumns(ctx, in, InputTypeExportModel)
data["editInpValidator"] = l.generateInputListColumns(ctx, in, InputTypeEditInpValidator)
+ data["updateFieldsColumns"] = l.generateInputListColumns(ctx, in, InputTypeUpdateFields)
+ data["insertFieldsColumns"] = l.generateInputListColumns(ctx, in, InputTypeInsertFields)
return
}
@@ -132,7 +135,7 @@ func (l *gCurd) generateStructFieldDefinition(field *sysin.GenCodesColumnListMod
if !field.Required && (field.FormRole == "none" || field.FormRole == "") {
return nil
}
- rule := "// 验证" + field.GoName + "\n"
+ rule := "// 验证" + field.Dc + "\n"
if field.Required && (field.FormRole == FormRoleNone || field.FormRole == "") {
field.FormRole = "required"
}
@@ -142,6 +145,22 @@ func (l *gCurd) generateStructFieldDefinition(field *sysin.GenCodesColumnListMod
rule += s
}
result = []string{rule}
+ case InputTypeUpdateFields:
+ if !field.IsEdit && field.GoName != "UpdatedBy" {
+ return nil
+ }
+
+ result = append(result, " #"+field.GoType)
+ result = append(result, " #"+fmt.Sprintf(tagKey+`json:"%s"`, field.TsName))
+ result = append(result, " #"+fmt.Sprintf(`dc:"%s"`+tagKey, descriptionTag))
+ case InputTypeInsertFields:
+ if !field.IsEdit && field.GoName != "CreatedBy" {
+ return nil
+ }
+
+ result = append(result, " #"+field.GoType)
+ result = append(result, " #"+fmt.Sprintf(tagKey+`json:"%s"`, field.TsName))
+ result = append(result, " #"+fmt.Sprintf(`dc:"%s"`+tagKey, descriptionTag))
default:
panic("inputType is invalid")
}
diff --git a/server/internal/library/hggen/views/curd_generate_logic.go b/server/internal/library/hggen/views/curd_generate_logic.go
index ceb1bcb..57a6747 100644
--- a/server/internal/library/hggen/views/curd_generate_logic.go
+++ b/server/internal/library/hggen/views/curd_generate_logic.go
@@ -21,8 +21,8 @@ const (
LogicListSimpleSelect = "\tfields, err := hgorm.GenSelect(ctx, sysin.%sListModel{}, dao.%s)\n\tif err != nil {\n\t\treturn\n\t}"
LogicListJoinSelect = "\t//关联表select\n\tfields, err := hgorm.GenJoinSelect(ctx, %sin.%sListModel{}, dao.%s, []*hgorm.Join{\n%v\t})"
LogicListJoinOnRelation = "\t// 关联表%s\n\tmod = mod.%s(hgorm.GenJoinOnRelation(\n\t\tdao.%s.Table(), dao.%s.Columns().%s, // 主表表名,关联字段\n\t\tdao.%s.Table(), \"%s\", dao.%s.Columns().%s, // 关联表表名,别名,关联字段\n\t)...)\n\n"
- LogicEditUpdate = "\t\t_, err = s.Model(ctx%s).\n\t\t\tFields(\n%s\t\t\t).\n\t\t\tWhere(dao.%s.Columns().%s, in.%s).Data(in).Update()\n\t\treturn "
- LogicEditInsert = "\t_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(\n%s\t\t).\n\t\tData(in).Insert()"
+ LogicEditUpdate = "\t\t_, err = s.Model(ctx%s).\n\t\t\tFields(%sin.%sUpdateFields{}).\n\t\t\tWherePri(in.%s).Data(in).Update()\n\t\treturn "
+ LogicEditInsert = "\t_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).\n\t\tFields(%sin.%sInsertFields{}).\n\t\tData(in).Insert()"
LogicEditUnique = "\t// 验证'%s'唯一\n\tif err = hgorm.IsUnique(ctx, dao.%s, g.Map{dao.%s.Columns().%s: in.%s}, \"%s已存在\", in.Id); err != nil {\n\t\treturn\n\t}\n"
LogicSwitchUpdate = "g.Map{\n\t\tin.Key: in.Value,\n%s}"
LogicStatusUpdate = "g.Map{\n\t\tdao.%s.Columns().Status: in.Status,\n%s}"
@@ -69,7 +69,7 @@ func (l *gCurd) generateLogicSwitchFields(ctx context.Context, in *CurdPreviewIn
if in.options.Step.HasSwitch {
for _, field := range in.masterFields {
if field.FormMode == "Switch" {
- buffer.WriteString("\t\t\"" + field.TsName + "\",\n")
+ buffer.WriteString("\t\tdao." + in.In.DaoName + ".Columns()." + field.GoName + ",\n")
}
}
}
@@ -79,9 +79,7 @@ func (l *gCurd) generateLogicSwitchFields(ctx context.Context, in *CurdPreviewIn
func (l *gCurd) generateLogicEdit(ctx context.Context, in *CurdPreviewInput) g.Map {
var (
data = make(g.Map)
- updateFields = ""
updateBuffer = bytes.NewBuffer(nil)
- insertFields = ""
insertBuffer = bytes.NewBuffer(nil)
uniqueBuffer = bytes.NewBuffer(nil)
)
@@ -95,14 +93,6 @@ func (l *gCurd) generateLogicEdit(ctx context.Context, in *CurdPreviewInput) g.M
insertBuffer.WriteString("\tin.CreatedBy = contexts.GetUserId(ctx)\n")
}
- if field.Index != consts.GenCodesIndexPK && (field.IsEdit == true || field.GoName == "UpdatedAt" || field.GoName == "UpdatedBy") {
- updateFields = updateFields + "\t\t\t\tdao." + in.In.DaoName + ".Columns()." + field.GoName + ",\n"
- }
-
- if field.Index != consts.GenCodesIndexPK && (field.IsEdit == true || field.Required == true || field.GoName == "CreatedAt" || field.GoName == "CreatedBy") {
- insertFields = insertFields + "\t\t\t\tdao." + in.In.DaoName + ".Columns()." + field.GoName + ",\n"
- }
-
if field.Unique {
uniqueBuffer.WriteString(fmt.Sprintf(LogicEditUnique, field.GoName, in.In.DaoName, in.In.DaoName, field.GoName, field.GoName, field.Dc))
}
@@ -113,8 +103,8 @@ func (l *gCurd) generateLogicEdit(ctx context.Context, in *CurdPreviewInput) g.M
notFilterAuth = ", &handler.Option{FilterAuth: false}"
}
- updateBuffer.WriteString(fmt.Sprintf(LogicEditUpdate, notFilterAuth, updateFields, in.In.DaoName, in.pk.GoName, in.pk.GoName))
- insertBuffer.WriteString(fmt.Sprintf(LogicEditInsert, insertFields))
+ updateBuffer.WriteString(fmt.Sprintf(LogicEditUpdate, notFilterAuth, in.options.TemplateGroup, in.In.VarName, in.pk.GoName))
+ insertBuffer.WriteString(fmt.Sprintf(LogicEditInsert, in.options.TemplateGroup, in.In.VarName))
data["update"] = updateBuffer.String()
data["insert"] = insertBuffer.String()
diff --git a/server/internal/logic/admin/dept.go b/server/internal/logic/admin/dept.go
index 8778afe..0ed5935 100644
--- a/server/internal/logic/admin/dept.go
+++ b/server/internal/logic/admin/dept.go
@@ -9,7 +9,7 @@ import (
"context"
"github.com/gogf/gf/v2/database/gdb"
"github.com/gogf/gf/v2/errors/gerror"
- "github.com/gogf/gf/v2/os/gtime"
+ "github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
@@ -20,7 +20,6 @@ import (
"hotgo/internal/service"
"hotgo/utility/convert"
"hotgo/utility/tree"
- "hotgo/utility/validate"
)
type sAdminDept struct{}
@@ -33,18 +32,6 @@ func init() {
service.RegisterAdminDept(NewAdminDept())
}
-// NameUnique 菜单名称是否唯一
-func (s *sAdminDept) NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (res *adminin.DeptNameUniqueModel, err error) {
- isUnique, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
- if err != nil {
- return
- }
-
- res = new(adminin.DeptNameUniqueModel)
- res.IsUnique = isUnique
- return
-}
-
// Delete 删除
func (s *sAdminDept) Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error) {
var models *entity.AdminDept
@@ -71,18 +58,7 @@ func (s *sAdminDept) Delete(ctx context.Context, in adminin.DeptDeleteInp) (err
// Edit 修改/新增
func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err error) {
- if in.Name == "" {
- err = gerror.New("名称不能为空")
- return
- }
-
- uniqueName, err := dao.AdminDept.IsUniqueName(ctx, in.Id, in.Name)
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
- if !uniqueName {
- err = gerror.New("名称已存在")
+ if err = hgorm.IsUnique(ctx, dao.AdminDept, g.Map{dao.AdminDept.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
return
}
@@ -103,7 +79,7 @@ func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err erro
err = dao.AdminDept.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
// 更新数据
- _, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ _, err = dao.AdminDept.Ctx(ctx).Fields(adminin.DeptUpdateFields{}).WherePri(in.Id).Data(in).Update()
if err != nil {
return err
}
@@ -116,7 +92,7 @@ func (s *sAdminDept) Edit(ctx context.Context, in adminin.DeptEditInp) (err erro
}
// 新增
- _, err = dao.AdminDept.Ctx(ctx).Data(in).Insert()
+ _, err = dao.AdminDept.Ctx(ctx).Fields(adminin.DeptInsertFields{}).Data(in).Insert()
return
}
@@ -144,24 +120,9 @@ func updateChildrenTree(ctx context.Context, _id int64, _level int, _tree string
// Status 更新部门状态
func (s *sAdminDept) Status(ctx context.Context, in adminin.DeptStatusInp) (err error) {
- if in.Id <= 0 {
- err = gerror.New("ID不能为空")
- return
+ if _, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
}
-
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
- }
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- // 修改
- in.UpdatedAt = gtime.Now()
- _, err = dao.AdminDept.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
return
}
@@ -177,6 +138,7 @@ func (s *sAdminDept) MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (re
if res == nil {
res = new(adminin.DeptMaxSortModel)
}
+
res.Sort = form.DefaultMaxSort(ctx, res.Sort)
return
}
diff --git a/server/internal/logic/admin/member.go b/server/internal/logic/admin/member.go
index 2a1de21..a18c346 100644
--- a/server/internal/logic/admin/member.go
+++ b/server/internal/logic/admin/member.go
@@ -47,17 +47,17 @@ func (s *sAdminMember) AddBalance(ctx context.Context, in adminin.MemberAddBalan
memberId = contexts.GetUserId(ctx)
)
- if err = s.FilterAuthModel(ctx, memberId).Where("id", in.Id).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
if mb == nil {
err = gerror.New("用户信息不存在")
- return err
+ return
}
- err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
+ return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
// 更新我的余额
_, err = service.AdminCreditsLog().SaveBalance(ctx, adminin.CreditsLogSaveBalanceInp{
MemberId: memberId,
@@ -68,7 +68,7 @@ func (s *sAdminMember) AddBalance(ctx context.Context, in adminin.MemberAddBalan
Remark: fmt.Sprintf("为后台用户:%v 操作%v", mb.Id, in.Remark),
})
if err != nil {
- return err
+ return
}
// 更新对方余额
@@ -82,8 +82,6 @@ func (s *sAdminMember) AddBalance(ctx context.Context, in adminin.MemberAddBalan
})
return
})
-
- return
}
// AddIntegral 增加积分
@@ -93,17 +91,17 @@ func (s *sAdminMember) AddIntegral(ctx context.Context, in adminin.MemberAddInte
memberId = contexts.GetUserId(ctx)
)
- if err = s.FilterAuthModel(ctx, memberId).Where("id", in.Id).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
if mb == nil {
err = gerror.New("用户信息不存在")
- return err
+ return
}
- err = g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
+ return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
// 更新我的余额
_, err = service.AdminCreditsLog().SaveIntegral(ctx, adminin.CreditsLogSaveIntegralInp{
MemberId: memberId,
@@ -114,7 +112,7 @@ func (s *sAdminMember) AddIntegral(ctx context.Context, in adminin.MemberAddInte
Remark: fmt.Sprintf("为后台用户:%v 操作%v", mb.Id, in.Remark),
})
if err != nil {
- return err
+ return
}
// 更新对方余额
@@ -128,8 +126,6 @@ func (s *sAdminMember) AddIntegral(ctx context.Context, in adminin.MemberAddInte
})
return
})
-
- return
}
// UpdateCash 修改提现信息
@@ -140,19 +136,18 @@ func (s *sAdminMember) UpdateCash(ctx context.Context, in adminin.MemberUpdateCa
return
}
- var memberInfo entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Scan(&memberInfo); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ var mb entity.AdminMember
+ if err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
return
}
- if gmd5.MustEncryptString(in.Password+memberInfo.Salt) != memberInfo.PasswordHash {
+ if gmd5.MustEncryptString(in.Password+mb.Salt) != mb.PasswordHash {
err = gerror.New("登录密码不正确")
return
}
- _, err = dao.AdminMember.Ctx(ctx).
- Where("id", memberId).
+ _, err = dao.AdminMember.Ctx(ctx).WherePri(memberId).
Data(g.Map{
dao.AdminMember.Columns().Cash: adminin.MemberCash{
Name: in.Name,
@@ -162,6 +157,10 @@ func (s *sAdminMember) UpdateCash(ctx context.Context, in adminin.MemberUpdateCa
}).
Update()
+ if err != nil {
+ err = gerror.New("修改提现信息失败!")
+ return
+ }
return
}
@@ -170,21 +169,21 @@ func (s *sAdminMember) UpdateEmail(ctx context.Context, in adminin.MemberUpdateE
memberId := contexts.Get(ctx).User.Id
if memberId <= 0 {
err = gerror.New("获取用户信息失败!")
- return err
+ return
}
- var memberInfo *entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Scan(&memberInfo); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ var mb *entity.AdminMember
+ if err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
- if memberInfo == nil {
+ if mb == nil {
err = gerror.New("用户信息不存在")
- return err
+ return
}
- if memberInfo.Email == in.Email {
+ if mb.Email == in.Email {
err = gerror.New("新旧邮箱不能一样")
return
}
@@ -195,14 +194,14 @@ func (s *sAdminMember) UpdateEmail(ctx context.Context, in adminin.MemberUpdateE
}
// 存在原绑定号码,需要进行验证
- if memberInfo.Email != "" {
+ if mb.Email != "" {
err = service.SysEmsLog().VerifyCode(ctx, sysin.VerifyEmsCodeInp{
Event: consts.EmsTemplateBind,
- Email: memberInfo.Email,
+ Email: mb.Email,
Code: in.Code,
})
if err != nil {
- return err
+ return
}
}
@@ -210,12 +209,10 @@ func (s *sAdminMember) UpdateEmail(ctx context.Context, in adminin.MemberUpdateE
dao.AdminMember.Columns().Email: in.Email,
}
- _, err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Data(update).Update()
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if _, err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Data(update).Update(); err != nil {
+ err = gerror.Wrap(err, "换绑邮箱失败,请稍后重试!")
+ return
}
-
return
}
@@ -224,18 +221,18 @@ func (s *sAdminMember) UpdateMobile(ctx context.Context, in adminin.MemberUpdate
memberId := contexts.Get(ctx).User.Id
if memberId <= 0 {
err = gerror.New("获取用户信息失败!")
- return err
+ return
}
var mb *entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
if mb == nil {
err = gerror.New("用户信息不存在")
- return err
+ return
}
if mb.Mobile == in.Mobile {
@@ -256,7 +253,7 @@ func (s *sAdminMember) UpdateMobile(ctx context.Context, in adminin.MemberUpdate
Code: in.Code,
})
if err != nil {
- return err
+ return
}
}
@@ -264,11 +261,10 @@ func (s *sAdminMember) UpdateMobile(ctx context.Context, in adminin.MemberUpdate
dao.AdminMember.Columns().Mobile: in.Mobile,
}
- if _, err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Data(update).Update(); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if _, err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Data(update).Update(); err != nil {
+ err = gerror.Wrap(err, "换绑手机号失败,请稍后重试!")
+ return
}
-
return
}
@@ -277,63 +273,59 @@ func (s *sAdminMember) UpdateProfile(ctx context.Context, in adminin.MemberUpdat
memberId := contexts.Get(ctx).User.Id
if memberId <= 0 {
err = gerror.New("获取用户信息失败!")
- return err
+ return
}
var mb *entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
if mb == nil {
err = gerror.New("用户信息不存在")
- return err
+ return
}
+ cols := dao.AdminMember.Columns()
update := g.Map{
- dao.AdminMember.Columns().Avatar: in.Avatar,
- dao.AdminMember.Columns().RealName: in.RealName,
- dao.AdminMember.Columns().Qq: in.Qq,
- dao.AdminMember.Columns().Birthday: in.Birthday,
- dao.AdminMember.Columns().Sex: in.Sex,
- dao.AdminMember.Columns().CityId: in.CityId,
- dao.AdminMember.Columns().Address: in.Address,
+ cols.Avatar: in.Avatar,
+ cols.RealName: in.RealName,
+ cols.Qq: in.Qq,
+ cols.Birthday: in.Birthday,
+ cols.Sex: in.Sex,
+ cols.CityId: in.CityId,
+ cols.Address: in.Address,
}
- if _, err = dao.AdminMember.Ctx(ctx).Where("id", memberId).Data(update).Update(); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if _, err = dao.AdminMember.Ctx(ctx).WherePri(memberId).Data(update).Update(); err != nil {
+ err = gerror.Wrap(err, "更新资料失败,请稍后重试!")
+ return
}
-
return
}
// UpdatePwd 修改登录密码
func (s *sAdminMember) UpdatePwd(ctx context.Context, in adminin.MemberUpdatePwdInp) (err error) {
var mb entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", in.Id).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ if err = dao.AdminMember.Ctx(ctx).WherePri(in.Id).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
}
if gmd5.MustEncryptString(in.OldPassword+mb.Salt) != mb.PasswordHash {
err = gerror.New("原密码不正确")
- return err
+ return
}
- _, err = dao.AdminMember.Ctx(ctx).
- Where("id", in.Id).
- Data(g.Map{
- dao.AdminMember.Columns().PasswordHash: gmd5.MustEncryptString(in.NewPassword + mb.Salt),
- }).
- Update()
-
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ update := g.Map{
+ dao.AdminMember.Columns().PasswordHash: gmd5.MustEncryptString(in.NewPassword + mb.Salt),
}
+ if _, err = dao.AdminMember.Ctx(ctx).WherePri(in.Id).Data(update).Update(); err != nil {
+ err = gerror.Wrap(err, "更新登录密码失败,请稍后重试!")
+ return
+ }
return
}
@@ -344,8 +336,8 @@ func (s *sAdminMember) ResetPwd(ctx context.Context, in adminin.MemberResetPwdIn
memberId = contexts.GetUserId(ctx)
)
- if err = s.FilterAuthModel(ctx, memberId).Where("id", in.Id).Scan(&mb); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ if err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Scan(&mb); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
return
}
@@ -354,12 +346,14 @@ func (s *sAdminMember) ResetPwd(ctx context.Context, in adminin.MemberResetPwdIn
return
}
- _, err = s.FilterAuthModel(ctx, memberId).
- Where("id", in.Id).
- Data(g.Map{
- dao.AdminMember.Columns().PasswordHash: gmd5.MustEncryptString(in.Password + mb.Salt),
- }).
- Update()
+ update := g.Map{
+ dao.AdminMember.Columns().PasswordHash: gmd5.MustEncryptString(in.Password + mb.Salt),
+ }
+
+ if _, err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Data(update).Update(); err != nil {
+ err = gerror.Wrap(err, "用户密码重置失败,请稍后重试!")
+ return
+ }
return
}
@@ -369,11 +363,12 @@ func (s *sAdminMember) VerifyUnique(ctx context.Context, in adminin.VerifyUnique
return
}
+ cols := dao.AdminMember.Columns()
msgMap := g.MapStrStr{
- "username": "用户名已存在,请换一个",
- "email": "邮箱已存在,请换一个",
- "mobile": "手机号已存在,请换一个",
- "invite_code": "邀请码已存在,请换一个",
+ cols.Username: "用户名已存在,请换一个",
+ cols.Email: "邮箱已存在,请换一个",
+ cols.Mobile: "手机号已存在,请换一个",
+ cols.InviteCode: "邀请码已存在,请换一个",
}
for k, v := range in.Where {
@@ -389,7 +384,6 @@ func (s *sAdminMember) VerifyUnique(ctx context.Context, in adminin.VerifyUnique
return
}
}
-
return
}
@@ -406,8 +400,28 @@ func (s *sAdminMember) Delete(ctx context.Context, in adminin.MemberDeleteInp) (
return
}
- _, err = s.FilterAuthModel(ctx, memberId).Where("id", in.Id).Delete()
- return
+ var models *entity.AdminMember
+ if err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Scan(&models); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return
+ }
+
+ if models == nil {
+ err = gerror.New("需要删除的用户不存在或已删除!")
+ return
+ }
+
+ return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
+ if _, err = s.FilterAuthModel(ctx, memberId).WherePri(in.Id).Delete(); err != nil {
+ err = gerror.Wrap(err, "删除用户失败,请稍后重试!")
+ return
+ }
+
+ if _, err = dao.AdminMemberPost.Ctx(ctx).Where("member_id", memberId).Delete(); err != nil {
+ err = gerror.Wrap(err, "删除用户岗位失败,请稍后重试!")
+ }
+ return
+ })
}
// Edit 修改/新增
@@ -423,12 +437,13 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return
}
+ cols := dao.AdminMember.Columns()
err = s.VerifyUnique(ctx, adminin.VerifyUniqueInp{
Id: in.Id,
Where: g.Map{
- dao.AdminMember.Columns().Username: in.Username,
- dao.AdminMember.Columns().Mobile: in.Mobile,
- dao.AdminMember.Columns().Email: in.Email,
+ cols.Username: in.Username,
+ cols.Mobile: in.Mobile,
+ cols.Email: in.Email,
},
})
if err != nil {
@@ -450,28 +465,30 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
mod := s.FilterAuthModel(ctx, opMemberId)
if in.Password != "" {
- // 修改密码
- salt, err := s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).
- Fields(dao.AdminMember.Columns().Salt).
- Where("id", in.Id).
- Value()
+ // 修改密码,需要获取到密码盐
+ salt, err := s.FilterAuthModel(ctx, opMemberId).Fields(cols.Salt).WherePri(in.Id).Value()
if err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ return err
+ }
+ if salt.IsEmpty() {
+ err = gerror.New("该用户没有设置密码盐,请联系管理员!")
return err
}
in.PasswordHash = gmd5.MustEncryptString(in.Password + salt.String())
} else {
- mod = mod.FieldsEx(dao.AdminMember.Columns().PasswordHash)
+ mod = mod.FieldsEx(cols.PasswordHash)
}
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
- if _, err = mod.Where("id", in.Id).Data(in).Update(); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ if _, err = mod.WherePri(in.Id).Data(in).Update(); err != nil {
+ err = gerror.Wrap(err, "修改用户信息失败,请稍后重试!")
return
}
// 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, in.Id, in.PostIds); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "更新用户岗位失败,请稍后重试!")
}
return
})
@@ -499,62 +516,62 @@ func (s *sAdminMember) Edit(ctx context.Context, in adminin.MemberEditInp) (err
return g.DB().Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
id, err := dao.AdminMember.Ctx(ctx).Data(data).InsertAndGetId()
if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "新增用户失败,请稍后重试!")
return
}
// 更新岗位
if err = dao.AdminMemberPost.UpdatePostIds(ctx, id, in.PostIds); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "新增用户岗位失败,请稍后重试!")
}
return
})
}
-// View 获取信息
+// View 获取用户信息
func (s *sAdminMember) View(ctx context.Context, in adminin.MemberViewInp) (res *adminin.MemberViewModel, err error) {
- err = s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).
- Hook(hook.MemberInfo).
- Where("id", in.Id).
- Scan(&res)
+ if err = s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).Hook(hook.MemberInfo).WherePri(in.Id).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
+ }
return
}
// List 获取列表
func (s *sAdminMember) List(ctx context.Context, in adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error) {
mod := s.FilterAuthModel(ctx, contexts.GetUserId(ctx))
+ cols := dao.AdminMember.Columns()
if in.RealName != "" {
- mod = mod.WhereLike("real_name", "%"+in.RealName+"%")
+ mod = mod.WhereLike(cols.RealName, "%"+in.RealName+"%")
}
if in.Username != "" {
- mod = mod.WhereLike("username", "%"+in.Username+"%")
+ mod = mod.WhereLike(cols.Username, "%"+in.Username+"%")
}
if in.Mobile > 0 {
- mod = mod.Where("mobile", in.Mobile)
+ mod = mod.Where(cols.Mobile, in.Mobile)
}
if in.Status > 0 {
- mod = mod.Where("status", in.Status)
+ mod = mod.Where(cols.Status, in.Status)
}
if in.DeptId > 0 {
- mod = mod.Where("dept_id", in.DeptId)
+ mod = mod.Where(cols.DeptId, in.DeptId)
}
if in.RoleId > 0 {
- mod = mod.Where("role_id", in.RoleId)
+ mod = mod.Where(cols.RoleId, in.RoleId)
}
if len(in.CreatedAt) == 2 {
- mod = mod.WhereBetween("created_at", gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
+ mod = mod.WhereBetween(cols.CreatedAt, gtime.New(in.CreatedAt[0]), gtime.New(in.CreatedAt[1]))
}
totalCount, err = mod.Count()
if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "获取用户数据行失败!")
return
}
@@ -562,17 +579,19 @@ func (s *sAdminMember) List(ctx context.Context, in adminin.MemberListInp) (list
return
}
- if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
+ if err = mod.Hook(hook.MemberInfo).Page(in.Page, in.PerPage).OrderDesc(cols.Id).Scan(&list); err != nil {
+ err = gerror.Wrap(err, "获取用户列表失败!")
return
}
for i := 0; i < len(list); i++ {
posts, err := dao.AdminMemberPost.Ctx(ctx).
- Fields("post_id").
- Where("member_id", list[i].Id).
+ Fields(dao.AdminMemberPost.Columns().PostId).
+ Where(dao.AdminMemberPost.Columns().MemberId, list[i].Id).
Array()
if err != nil {
+ err = gerror.Wrap(err, "获取用户岗位数据失败!")
return nil, 0, err
}
@@ -586,36 +605,21 @@ func (s *sAdminMember) List(ctx context.Context, in adminin.MemberListInp) (list
// Status 更新状态
func (s *sAdminMember) Status(ctx context.Context, in adminin.MemberStatusInp) (err error) {
- if in.Id <= 0 {
- err = gerror.New("ID不能为空")
- return
- }
-
if s.VerifySuperId(ctx, in.Id) {
err = gerror.New("超管账号不能更改状态")
return
}
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
+ if _, err = s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).WherePri(in.Id).Data(dao.AdminMember.Columns().Status, in.Status).Update(); err != nil {
+ err = gerror.Wrap(err, "更新用户状态失败,请稍后重试!")
}
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- // 修改
- in.UpdatedAt = gtime.Now()
- _, err = s.FilterAuthModel(ctx, contexts.GetUserId(ctx)).Where("id", in.Id).Data("status", in.Status).Update()
return
}
// GenTree 生成关系树
func (s *sAdminMember) GenTree(ctx context.Context, pid int64) (level int, newTree string, err error) {
var pmb *entity.AdminMember
- if err = dao.AdminMember.Ctx(ctx).Where("id", pid).Scan(&pmb); err != nil {
+ if err = dao.AdminMember.Ctx(ctx).WherePri(pid).Scan(&pmb); err != nil {
return
}
@@ -629,26 +633,6 @@ func (s *sAdminMember) GenTree(ctx context.Context, pid int64) (level int, newTr
return
}
-// RoleMemberList 获取角色下的用户列表
-func (s *sAdminMember) RoleMemberList(ctx context.Context, in adminin.RoleMemberListInp) (list []*adminin.MemberListModel, totalCount int, err error) {
- mod := dao.AdminMember.Ctx(ctx)
- if in.Role > 0 {
- mod = mod.Where("role", in.Role)
- }
-
- totalCount, err = mod.Count()
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
-
- if err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
- return
-}
-
// LoginMemberInfo 获取登录用户信息
func (s *sAdminMember) LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error) {
var memberId = contexts.GetUserId(ctx)
@@ -657,8 +641,8 @@ func (s *sAdminMember) LoginMemberInfo(ctx context.Context) (res *adminin.LoginM
return
}
- if err = dao.AdminMember.Ctx(ctx).Hook(hook.MemberInfo).Where("id", memberId).Scan(&res); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ if err = dao.AdminMember.Ctx(ctx).Hook(hook.MemberInfo).WherePri(memberId).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
return
}
@@ -677,7 +661,7 @@ func (s *sAdminMember) LoginMemberInfo(ctx context.Context) (res *adminin.LoginM
// 登录统计
stat, err := s.MemberLoginStat(ctx, adminin.MemberLoginStatInp{MemberId: memberId})
if err != nil {
- return nil, err
+ return
}
res.MemberLoginStatModel = stat
@@ -689,11 +673,16 @@ func (s *sAdminMember) LoginMemberInfo(ctx context.Context) (res *adminin.LoginM
// MemberLoginStat 用户登录统计
func (s *sAdminMember) MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error) {
- var models *entity.SysLoginLog
+ var (
+ models *entity.SysLoginLog
+ cols = dao.SysLoginLog.Columns()
+ )
+
err = dao.SysLoginLog.Ctx(ctx).
- Fields("login_at,login_ip").
- Where("member_id", in.MemberId).
- Where("status", consts.StatusEnabled).
+ Fields(cols.LoginAt, cols.LoginIp).
+ Where(cols.MemberId, in.MemberId).
+ Where(cols.Status, consts.StatusEnabled).
+ OrderDesc(cols.Id).
Scan(&models)
if err != nil {
@@ -708,16 +697,16 @@ func (s *sAdminMember) MemberLoginStat(ctx context.Context, in adminin.MemberLog
res.LastLoginAt = models.LoginAt
res.LastLoginIp = models.LoginIp
res.LoginCount, err = dao.SysLoginLog.Ctx(ctx).
- Where("member_id", in.MemberId).
- Where("status", consts.StatusEnabled).
+ Where(cols.MemberId, in.MemberId).
+ Where(cols.Status, consts.StatusEnabled).
Count()
return
}
// GetIdByCode 通过邀请码获取用户ID
func (s *sAdminMember) GetIdByCode(ctx context.Context, in adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error) {
- if err = dao.AdminMember.Ctx(ctx).Fields(adminin.GetIdByCodeModel{}).Where("invite_code", in.Code).Scan(&res); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ if err = dao.AdminMember.Ctx(ctx).Fields(adminin.GetIdByCodeModel{}).Where(dao.AdminMember.Columns().InviteCode, in.Code).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取用户信息失败,请稍后重试!")
}
return
}
@@ -729,15 +718,14 @@ func (s *sAdminMember) Select(ctx context.Context, in adminin.MemberSelectInp) (
Handler(handler.FilterAuthWithField("id")).
Scan(&res)
if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "获取可选用户选项失败,请稍后重试!")
}
return
}
// VerifySuperId 验证是否为超管
func (s *sAdminMember) VerifySuperId(ctx context.Context, verifyId int64) bool {
- superIds := g.Cfg().MustGet(ctx, "hotgo.admin.superIds")
- for _, id := range superIds.Int64s() {
+ for _, id := range g.Cfg().MustGet(ctx, "hotgo.admin.superIds").Int64s() {
if id == verifyId {
return true
}
diff --git a/server/internal/logic/admin/menu.go b/server/internal/logic/admin/menu.go
index 330624a..9ee997a 100644
--- a/server/internal/logic/admin/menu.go
+++ b/server/internal/logic/admin/menu.go
@@ -217,7 +217,7 @@ func (s *sAdminMenu) getChildrenList(menu *adminin.MenuRouteSummary, treeMap map
}
// GetMenuList 获取菜单列表
-func (s *sAdminMenu) GetMenuList(ctx context.Context, memberId int64) (lists role.DynamicRes, err error) {
+func (s *sAdminMenu) GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error) {
var (
allMenus []adminin.MenuRouteSummary
menus []adminin.MenuRouteSummary
@@ -232,12 +232,12 @@ func (s *sAdminMenu) GetMenuList(ctx context.Context, memberId int64) (lists rol
Where("role_id", contexts.GetRoleId(ctx)).
Array()
if err != nil {
- return lists, err
+ return nil, err
}
if len(array) > 0 {
pidList, err := dao.AdminMenu.Ctx(ctx).Fields("pid").WhereIn("id", array).Group("pid").Array()
if err != nil {
- return role.DynamicRes{}, err
+ return nil, err
}
if len(pidList) > 0 {
array = append(pidList, array...)
@@ -263,7 +263,8 @@ func (s *sAdminMenu) GetMenuList(ctx context.Context, memberId int64) (lists rol
err = s.getChildrenList(&menus[i], treeMap)
}
- lists.List = append(lists.List, s.genNaiveMenus(menus)...)
+ res = new(role.DynamicRes)
+ res.List = append(res.List, s.genNaiveMenus(menus)...)
return
}
diff --git a/server/internal/logic/admin/role.go b/server/internal/logic/admin/role.go
index dab0fb4..ee54679 100644
--- a/server/internal/logic/admin/role.go
+++ b/server/internal/logic/admin/role.go
@@ -11,7 +11,6 @@ import (
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
- "hotgo/api/admin/role"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/casbin"
@@ -39,9 +38,9 @@ func init() {
// Verify 验证权限
func (s *sAdminRole) Verify(ctx context.Context, path, method string) bool {
var (
- user = contexts.Get(ctx).User
- superRoleKey = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
- err error
+ user = contexts.Get(ctx).User
+ sk = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
+ err error
)
if user == nil {
@@ -49,7 +48,7 @@ func (s *sAdminRole) Verify(ctx context.Context, path, method string) bool {
return false
}
- if service.AdminMember().VerifySuperId(ctx, user.Id) || user.RoleKey == superRoleKey.String() {
+ if service.AdminMember().VerifySuperId(ctx, user.Id) || user.RoleKey == sk.String() {
return true
}
@@ -93,81 +92,75 @@ func (s *sAdminRole) List(ctx context.Context, in adminin.RoleListInp) (res *adm
}
// GetName 获取指定角色的名称
-func (s *sAdminRole) GetName(ctx context.Context, RoleId int64) (name string, err error) {
- roleName, err := dao.AdminRole.Ctx(ctx).
+func (s *sAdminRole) GetName(ctx context.Context, id int64) (name string, err error) {
+ r, err := dao.AdminRole.Ctx(ctx).
Fields("name").
- Where("id", RoleId).
+ WherePri(id).
Order("id desc").
Value()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
- return name, err
+ return
}
- return roleName.String(), nil
+ return r.String(), nil
}
// GetMemberList 获取指定用户的岗位列表
-func (s *sAdminRole) GetMemberList(ctx context.Context, RoleId int64) (list []*adminin.RoleListModel, err error) {
- err = dao.AdminRole.Ctx(ctx).
- Where("id", RoleId).
- Order("id desc").
- Scan(&list)
- if err != nil {
+func (s *sAdminRole) GetMemberList(ctx context.Context, id int64) (list []*adminin.RoleListModel, err error) {
+ if err = dao.AdminRole.Ctx(ctx).WherePri(id).Order("id desc").Scan(&list); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
- return list, err
}
-
- return list, err
+ return
}
// GetPermissions 更改角色菜单权限
-func (s *sAdminRole) GetPermissions(ctx context.Context, reqInfo *role.GetPermissionsReq) (MenuIds []int64, err error) {
+func (s *sAdminRole) GetPermissions(ctx context.Context, in adminin.GetPermissionsInp) (res *adminin.GetPermissionsModel, err error) {
values, err := dao.AdminRoleMenu.Ctx(ctx).
Fields("menu_id").
- Where("role_id", reqInfo.RoleId).
+ Where("role_id", in.RoleId).
Array()
if err != nil {
- return nil, err
+ return
}
if len(values) == 0 {
return
}
+ res = new(adminin.GetPermissionsModel)
for i := 0; i < len(values); i++ {
- MenuIds = append(MenuIds, values[i].Int64())
+ res.MenuIds = append(res.MenuIds, values[i].Int64())
}
return
}
// UpdatePermissions 更改角色菜单权限
-func (s *sAdminRole) UpdatePermissions(ctx context.Context, reqInfo *role.UpdatePermissionsReq) (err error) {
+func (s *sAdminRole) UpdatePermissions(ctx context.Context, in adminin.UpdatePermissionsInp) (err error) {
err = dao.AdminRoleMenu.Transaction(ctx, func(ctx context.Context, tx gdb.TX) (err error) {
- _, err = dao.AdminRoleMenu.Ctx(ctx).Where("role_id", reqInfo.RoleId).Delete()
- if err != nil {
+ if _, err = dao.AdminRoleMenu.Ctx(ctx).Where("role_id", in.RoleId).Delete(); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ return
}
- if len(reqInfo.MenuIds) == 0 {
- return nil
+ if len(in.MenuIds) == 0 {
+ return
}
// 去重
- reqInfo.MenuIds = convert.UniqueSliceInt64(reqInfo.MenuIds)
+ in.MenuIds = convert.UniqueSliceInt64(in.MenuIds)
- addMap := make(g.List, 0, len(reqInfo.MenuIds))
- for _, v := range reqInfo.MenuIds {
- addMap = append(addMap, g.Map{
- "role_id": reqInfo.RoleId,
+ list := make(g.List, 0, len(in.MenuIds))
+ for _, v := range in.MenuIds {
+ list = append(list, g.Map{
+ "role_id": in.RoleId,
"menu_id": v,
})
}
- if _, err = dao.AdminRoleMenu.Ctx(ctx).Data(addMap).Insert(); err != nil {
+ if _, err = dao.AdminRoleMenu.Ctx(ctx).Data(list).Insert(); err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ return
}
return
@@ -180,34 +173,12 @@ func (s *sAdminRole) UpdatePermissions(ctx context.Context, reqInfo *role.Update
return casbin.Refresh(ctx)
}
-func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
- if in.Name == "" {
- err = gerror.New("名称不能为空")
+func (s *sAdminRole) Edit(ctx context.Context, in adminin.RoleEditInp) (err error) {
+ if err = hgorm.IsUnique(ctx, dao.AdminRole, g.Map{dao.AdminRole.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
return
}
- if in.Key == "" {
- err = gerror.New("编码不能为空")
- return
- }
-
- uniqueName, err := dao.AdminRole.IsUniqueName(ctx, in.Id, in.Name)
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
- if !uniqueName {
- err = gerror.New("名称已存在")
- return
- }
-
- uniqueCode, err := dao.AdminRole.IsUniqueCode(ctx, in.Id, in.Key)
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
- if !uniqueCode {
- err = gerror.New("编码已存在")
+ if err = hgorm.IsUnique(ctx, dao.AdminRole, g.Map{dao.AdminRole.Columns().Key: in.Key}, "编码已存在", in.Id); err != nil {
return
}
@@ -227,8 +198,9 @@ func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
err = dao.AdminRole.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error {
// 更新数据
- _, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ _, err = dao.AdminRole.Ctx(ctx).Fields(adminin.RoleUpdateFields{}).WherePri(in.Id).Data(in).Update()
if err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
return err
}
@@ -239,7 +211,10 @@ func (s *sAdminRole) Edit(ctx context.Context, in *role.EditReq) (err error) {
}
// 新增
- _, err = dao.AdminRole.Ctx(ctx).Data(in).Insert()
+ if _, err = dao.AdminRole.Ctx(ctx).Fields(adminin.RoleInsertFields{}).Data(in).Insert(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ return
+ }
return
}
@@ -265,11 +240,7 @@ func updateRoleChildrenTree(ctx context.Context, _id int64, _level int, _tree st
return
}
-func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error) {
- if in.Id <= 0 {
- return gerror.New("ID不正确!")
- }
-
+func (s *sAdminRole) Delete(ctx context.Context, in adminin.RoleDeleteInp) (err error) {
var models *entity.AdminRole
if err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
return
@@ -279,20 +250,23 @@ func (s *sAdminRole) Delete(ctx context.Context, in *role.DeleteReq) (err error)
return gerror.New("数据不存在或已删除!")
}
- pidExist, err := dao.AdminRole.Ctx(ctx).Where("pid", models.Id).One()
+ has, err := dao.AdminRole.Ctx(ctx).Where("pid", models.Id).One()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
- return err
+ return
}
- if !pidExist.IsEmpty() {
+
+ if !has.IsEmpty() {
return gerror.New("请先删除该角色下得所有子级!")
}
- _, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Delete()
+ if _, err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Delete(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
-func (s *sAdminRole) DataScopeSelect(ctx context.Context) (res form.Selects) {
+func (s *sAdminRole) DataScopeSelect() (res form.Selects) {
for k, v := range consts.RoleDataNameMap {
res = append(res, &form.Select{
Value: k,
@@ -305,13 +279,9 @@ func (s *sAdminRole) DataScopeSelect(ctx context.Context) (res form.Selects) {
}
func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error) {
- if in.Id <= 0 {
- return gerror.New("角色ID不正确!")
- }
-
var (
- models *entity.AdminRole
- superRoleKey = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
+ models *entity.AdminRole
+ sk = g.Cfg().MustGet(ctx, "hotgo.admin.superRoleKey")
)
if err = dao.AdminRole.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
@@ -322,7 +292,7 @@ func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEdi
return gerror.New("角色不存在")
}
- if models.Key == superRoleKey.String() {
+ if models.Key == sk.String() {
return gerror.New("超管角色拥有全部权限,无需修改!")
}
@@ -342,7 +312,7 @@ func (s *sAdminRole) DataScopeEdit(ctx context.Context, in *adminin.DataScopeEdi
return
}
-// treeList 树状列表
+// treeList 角色树列表
func (s *sAdminRole) treeList(pid int64, nodes []*entity.AdminRole) (list []*adminin.RoleTree) {
list = make([]*adminin.RoleTree, 0)
for _, v := range nodes {
diff --git a/server/internal/logic/sys/blacklist.go b/server/internal/logic/sys/blacklist.go
index dd9e88a..b795676 100644
--- a/server/internal/logic/sys/blacklist.go
+++ b/server/internal/logic/sys/blacklist.go
@@ -17,9 +17,12 @@ import (
"hotgo/internal/service"
"hotgo/utility/convert"
"hotgo/utility/validate"
+ "sync"
)
-type sSysBlacklist struct{}
+type sSysBlacklist struct {
+ sync.RWMutex
+}
func NewSysBlacklist() *sSysBlacklist {
return &sSysBlacklist{}
@@ -126,7 +129,6 @@ func (s *sSysBlacklist) List(ctx context.Context, in sysin.BlacklistListInp) (li
if err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
return
}
-
return
}
@@ -139,6 +141,9 @@ func (s *sSysBlacklist) VariableLoad(ctx context.Context, err error) {
// Load 加载黑名单
func (s *sSysBlacklist) Load(ctx context.Context) {
+ s.RLock()
+ defer s.RUnlock()
+
global.Blacklists = make(map[string]struct{})
array, err := dao.SysBlacklist.Ctx(ctx).
diff --git a/server/internal/logic/sys/config.go b/server/internal/logic/sys/config.go
index 7dc3771..2717ef6 100644
--- a/server/internal/logic/sys/config.go
+++ b/server/internal/logic/sys/config.go
@@ -12,7 +12,6 @@ import (
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
- "github.com/gogf/gf/v2/text/gstr"
"github.com/gogf/gf/v2/util/gconv"
"hotgo/internal/consts"
"hotgo/internal/dao"
@@ -23,6 +22,7 @@ import (
"hotgo/internal/model/entity"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
+ "hotgo/utility/simple"
)
// MaskDemoField 演示环境下需要隐藏的配置
@@ -217,12 +217,9 @@ func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp
return
}
- var (
- models []*entity.SysConfig
- isDemo = g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool()
- )
-
+ var models []*entity.SysConfig
if err = dao.SysConfig.Ctx(ctx).Fields("key", "value", "type").Where("group", in.Group).Scan(&models); err != nil {
+ err = gerror.Wrapf(err, "获取配置分组[ %v ]失败,请稍后重试!", in.Group)
return
}
@@ -235,13 +232,10 @@ func (s *sSysConfig) GetConfigByGroup(ctx context.Context, in sysin.GetConfigInp
return nil, err
}
res.List[v.Key] = val
- if isDemo && gstr.InArray(MaskDemoField, v.Key) {
- res.List[v.Key] = consts.DemoTips
- res.List[v.Key] = consts.DemoTips
- }
}
}
+ res.List = simple.FilterMaskDemo(ctx, res.List)
return
}
diff --git a/server/internal/logic/sys/cron.go b/server/internal/logic/sys/cron.go
index 89bfb68..be8d203 100644
--- a/server/internal/logic/sys/cron.go
+++ b/server/internal/logic/sys/cron.go
@@ -83,7 +83,6 @@ func (s *sSysCron) Edit(ctx context.Context, in sysin.CronEditInp) (err error) {
if _, err = dao.SysCron.Ctx(ctx).Where("id", in.Id).Data(in).Update(); err != nil {
return
}
-
simple.SafeGo(ctx, func(ctx context.Context) {
crons.RefreshStatus(&in.SysCron)
})
diff --git a/server/internal/logic/sys/cron_group.go b/server/internal/logic/sys/cron_group.go
index fc6889d..42a9724 100644
--- a/server/internal/logic/sys/cron_group.go
+++ b/server/internal/logic/sys/cron_group.go
@@ -14,7 +14,6 @@ import (
"hotgo/internal/model/input/form"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
- "hotgo/utility/validate"
)
type sSysCronGroup struct{}
@@ -35,40 +34,27 @@ func (s *sSysCronGroup) Delete(ctx context.Context, in sysin.CronGroupDeleteInp)
// Edit 修改/新增
func (s *sSysCronGroup) Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error) {
- if in.Name == "" {
- err = gerror.New("分组名称不能为空")
- return
- }
-
// 修改
if in.Id > 0 {
- _, err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ if _, err = dao.SysCronGroup.Ctx(ctx).Fields(sysin.CronGroupUpdateFields{}).Where("id", in.Id).Data(in).Update(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
// 新增
- _, err = dao.SysCronGroup.Ctx(ctx).Data(in).Insert()
+ if _, err = dao.SysCronGroup.Ctx(ctx).Fields(sysin.CronGroupInsertFields{}).Data(in).Insert(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
+
return
}
// Status 更新状态
func (s *sSysCronGroup) Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error) {
- if in.Id <= 0 {
- err = gerror.New("ID不能为空")
- return
+ if _, err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
}
-
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
- }
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- _, err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
return
}
@@ -76,6 +62,7 @@ func (s *sSysCronGroup) Status(ctx context.Context, in sysin.CronGroupStatusInp)
func (s *sSysCronGroup) MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error) {
if in.Id > 0 {
if err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Order("sort desc").Scan(&res); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
return
}
}
@@ -90,7 +77,9 @@ func (s *sSysCronGroup) MaxSort(ctx context.Context, in sysin.CronGroupMaxSortIn
// View 获取指定信息
func (s *sSysCronGroup) View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error) {
- err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Scan(&res)
+ if err = dao.SysCronGroup.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
@@ -108,6 +97,7 @@ func (s *sSysCronGroup) List(ctx context.Context, in sysin.CronGroupListInp) (li
totalCount, err = mod.Count()
if err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
return
}
@@ -115,7 +105,9 @@ func (s *sSysCronGroup) List(ctx context.Context, in sysin.CronGroupListInp) (li
return
}
- err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list)
+ if err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
diff --git a/server/internal/logic/sys/curd_demo.go b/server/internal/logic/sys/curd_demo.go
index d4c7d14..4a69736 100644
--- a/server/internal/logic/sys/curd_demo.go
+++ b/server/internal/logic/sys/curd_demo.go
@@ -3,14 +3,12 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-// @AutoGenerate Version 2.5.3
-// @AutoGenerate Date 2023-04-28 15:28:40
+// @AutoGenerate Version 2.7.3
package sys
import (
"context"
"fmt"
- "hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
"hotgo/internal/library/hgorm"
@@ -70,12 +68,17 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
// 关联表testCategory
mod = mod.LeftJoin(hgorm.GenJoinOnRelation(
- dao.SysGenCurdDemo.Table(), dao.SysGenCurdDemo.Columns().CategoryId, // 主表表名,关联条件
- dao.TestCategory.Table(), "testCategory", dao.TestCategory.Columns().Id, // 关联表表名,别名,关联条件
+ dao.SysGenCurdDemo.Table(), dao.SysGenCurdDemo.Columns().CategoryId, // 主表表名,关联字段
+ dao.TestCategory.Table(), "testCategory", dao.TestCategory.Columns().Id, // 关联表表名,别名,关联字段
)...)
totalCount, err = mod.Clone().Count()
- if totalCount == 0 || err != nil {
+ if err != nil {
+ err = gerror.Wrap(err, "获取生成演示数据行失败,请稍后重试!")
+ return
+ }
+
+ if totalCount == 0 {
return
}
@@ -83,7 +86,11 @@ func (s *sSysCurdDemo) List(ctx context.Context, in sysin.CurdDemoListInp) (list
fields, err := hgorm.GenJoinSelect(ctx, sysin.CurdDemoListModel{}, dao.SysGenCurdDemo, []*hgorm.Join{
{Dao: dao.TestCategory, Alias: "testCategory"},
})
- err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderAsc(dao.SysGenCurdDemo.Columns().Sort).OrderDesc(dao.SysGenCurdDemo.Columns().Id).Scan(&list)
+
+ if err = mod.Fields(fields).Page(in.Page, in.PerPage).OrderAsc(dao.SysGenCurdDemo.Columns().Sort).OrderDesc(dao.SysGenCurdDemo.Columns().Id).Scan(&list); err != nil {
+ err = gerror.Wrap(err, "获取生成演示列表失败,请稍后重试!")
+ return
+ }
return
}
@@ -116,41 +123,37 @@ func (s *sSysCurdDemo) Export(ctx context.Context, in sysin.CurdDemoListInp) (er
// Edit 修改/新增生成演示
func (s *sSysCurdDemo) Edit(ctx context.Context, in sysin.CurdDemoEditInp) (err error) {
+
// 修改
if in.Id > 0 {
in.UpdatedBy = contexts.GetUserId(ctx)
_, err = s.Model(ctx).
- FieldsEx(
- dao.SysGenCurdDemo.Columns().Id,
- dao.SysGenCurdDemo.Columns().CreatedBy,
- dao.SysGenCurdDemo.Columns().CreatedAt,
- dao.SysGenCurdDemo.Columns().DeletedAt,
- ).
- Where(dao.SysGenCurdDemo.Columns().Id, in.Id).Data(in).Update()
+ Fields(sysin.CurdDemoUpdateFields{}).
+ WherePri(in.Id).Data(in).Update()
return
}
// 新增
in.CreatedBy = contexts.GetUserId(ctx)
_, err = s.Model(ctx, &handler.Option{FilterAuth: false}).
- FieldsEx(
- dao.SysGenCurdDemo.Columns().Id,
- dao.SysGenCurdDemo.Columns().UpdatedBy,
- dao.SysGenCurdDemo.Columns().DeletedAt,
- ).
+ Fields(sysin.CurdDemoInsertFields{}).
Data(in).Insert()
return
}
// Delete 删除生成演示
func (s *sSysCurdDemo) Delete(ctx context.Context, in sysin.CurdDemoDeleteInp) (err error) {
- _, err = s.Model(ctx).Where(dao.SysGenCurdDemo.Columns().Id, in.Id).Delete()
+ if _, err = s.Model(ctx).WherePri(in.Id).Delete(); err != nil {
+ err = gerror.Wrap(err, "删除生成演示失败,请稍后重试!")
+ return
+ }
return
}
// MaxSort 获取生成演示最大排序
func (s *sSysCurdDemo) MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp) (res *sysin.CurdDemoMaxSortModel, err error) {
if err = dao.SysGenCurdDemo.Ctx(ctx).Fields(dao.SysGenCurdDemo.Columns().Sort).OrderDesc(dao.SysGenCurdDemo.Columns().Sort).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取生成演示最大排序,请稍后重试!")
return
}
@@ -164,31 +167,22 @@ func (s *sSysCurdDemo) MaxSort(ctx context.Context, in sysin.CurdDemoMaxSortInp)
// View 获取生成演示指定信息
func (s *sSysCurdDemo) View(ctx context.Context, in sysin.CurdDemoViewInp) (res *sysin.CurdDemoViewModel, err error) {
- err = s.Model(ctx).Where(dao.SysGenCurdDemo.Columns().Id, in.Id).Scan(&res)
+ if err = s.Model(ctx).WherePri(in.Id).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取生成演示信息,请稍后重试!")
+ return
+ }
return
}
// Status 更新生成演示状态
func (s *sSysCurdDemo) Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error) {
- if in.Id <= 0 {
- err = gerror.New("ID不能为空")
- return
- }
-
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
- }
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- _, err = s.Model(ctx).Where(dao.SysGenCurdDemo.Columns().Id, in.Id).Data(g.Map{
+ if _, err = s.Model(ctx).WherePri(in.Id).Data(g.Map{
dao.SysGenCurdDemo.Columns().Status: in.Status,
dao.SysGenCurdDemo.Columns().UpdatedBy: contexts.GetUserId(ctx),
- }).Update()
+ }).Update(); err != nil {
+ err = gerror.Wrap(err, "更新生成演示状态失败,请稍后重试!")
+ return
+ }
return
}
@@ -205,9 +199,12 @@ func (s *sSysCurdDemo) Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (
return
}
- _, err = s.Model(ctx).Where(dao.SysGenCurdDemo.Columns().Id, in.Id).Data(g.Map{
+ if _, err = s.Model(ctx).WherePri(in.Id).Data(g.Map{
in.Key: in.Value,
dao.SysGenCurdDemo.Columns().UpdatedBy: contexts.GetUserId(ctx),
- }).Update()
+ }).Update(); err != nil {
+ err = gerror.Wrap(err, "更新生成演示开关失败,请稍后重试!")
+ return
+ }
return
}
diff --git a/server/internal/logic/sys/dict_data.go b/server/internal/logic/sys/dict_data.go
index 23bc991..f8a17de 100644
--- a/server/internal/logic/sys/dict_data.go
+++ b/server/internal/logic/sys/dict_data.go
@@ -3,13 +3,11 @@
// @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/errors/gerror"
- "github.com/gogf/gf/v2/os/gtime"
"hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/model/input/sysin"
@@ -39,15 +37,9 @@ func (s *sSysDictData) Delete(ctx context.Context, in sysin.DictDataDeleteInp) e
// Edit 修改/新增
func (s *sSysDictData) Edit(ctx context.Context, in sysin.DictDataEditInp) (err error) {
- if in.Label == "" {
- err = gerror.New("字典标签不能为空")
- return err
- }
-
// 修改
- in.UpdatedAt = gtime.Now()
if in.Id > 0 {
- _, err = dao.SysDictData.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ _, err = dao.SysDictData.Ctx(ctx).Fields(sysin.DictDataUpdateFields{}).WherePri(in.Id).Data(in).Update()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
@@ -57,12 +49,6 @@ func (s *sSysDictData) Edit(ctx context.Context, in sysin.DictDataEditInp) (err
}
// 新增
- in.CreatedAt = gtime.Now()
- if in.TypeID <= 0 {
- err = gerror.New("字典类型不能为空")
- return err
- }
-
in.Type, err = dao.SysDictType.GetType(ctx, in.TypeID)
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
@@ -73,7 +59,7 @@ func (s *sSysDictData) Edit(ctx context.Context, in sysin.DictDataEditInp) (err
return gerror.Wrap(err, "类型选择无效,请检查")
}
- _, err = dao.SysDictData.Ctx(ctx).Data(in).Insert()
+ _, err = dao.SysDictData.Ctx(ctx).Fields(sysin.DictDataInsertFields{}).Data(in).Insert()
if err != nil {
err = gerror.Wrap(err, consts.ErrorORM)
return err
diff --git a/server/internal/logic/sys/dict_type.go b/server/internal/logic/sys/dict_type.go
index bd6e5c1..ac074d8 100644
--- a/server/internal/logic/sys/dict_type.go
+++ b/server/internal/logic/sys/dict_type.go
@@ -8,8 +8,10 @@ package sys
import (
"context"
"github.com/gogf/gf/v2/errors/gerror"
+ "github.com/gogf/gf/v2/frame/g"
"hotgo/internal/consts"
"hotgo/internal/dao"
+ "hotgo/internal/library/hgorm"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
@@ -80,29 +82,22 @@ func (s *sSysDictType) Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (
// Edit 修改/新增
func (s *sSysDictType) Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error) {
- if in.Name == "" {
- err = gerror.New("名称不能为空")
- return
- }
-
- uniqueName, err := dao.SysDictType.IsUniqueType(ctx, in.Id, in.Name)
- if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
- return
- }
- if !uniqueName {
- err = gerror.New("名称已存在")
+ if err = hgorm.IsUnique(ctx, dao.SysDictType, g.Map{dao.SysDictType.Columns().Name: in.Name}, "名称已存在", in.Id); err != nil {
return
}
// 修改
if in.Id > 0 {
- _, err = dao.SysDictType.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ if _, err = dao.SysDictType.Ctx(ctx).Fields(sysin.DictTypeUpdateFields{}).WherePri(in.Id).Data(in).Update(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
// 新增
- _, err = dao.SysDictType.Ctx(ctx).Data(in).Insert()
+ if _, err = dao.SysDictType.Ctx(ctx).Fields(sysin.DictTypeInsertFields{}).Data(in).Insert(); err != nil {
+ err = gerror.Wrap(err, consts.ErrorORM)
+ }
return
}
diff --git a/server/internal/logic/sys/provinces.go b/server/internal/logic/sys/provinces.go
index ab5fa5a..5c13a76 100644
--- a/server/internal/logic/sys/provinces.go
+++ b/server/internal/logic/sys/provinces.go
@@ -10,7 +10,6 @@ import (
"github.com/gogf/gf/v2/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/util/gconv"
- "hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/hgorm"
"hotgo/internal/model/entity"
@@ -18,7 +17,6 @@ import (
"hotgo/internal/model/input/sysin"
"hotgo/internal/service"
"hotgo/utility/tree"
- "hotgo/utility/validate"
)
type sSysProvinces struct{}
@@ -35,7 +33,7 @@ func init() {
func (s *sSysProvinces) Tree(ctx context.Context) (list []g.Map, err error) {
var models []*entity.SysProvinces
if err = dao.SysProvinces.Ctx(ctx).Order("pid asc,id asc,sort asc").Scan(&models); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "获取省市区关系树选项列表失败!")
return
}
@@ -44,14 +42,14 @@ func (s *sSysProvinces) Tree(ctx context.Context) (list []g.Map, err error) {
list[k]["key"] = v["id"]
list[k]["label"] = v["title"]
}
-
return tree.GenTree(list), nil
}
-// Delete 删除
+// Delete 删除省市区数据
func (s *sSysProvinces) Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error) {
var models *entity.SysProvinces
if err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Scan(&models); err != nil {
+ err = gerror.Wrap(err, "获取省市区数据失败!")
return
}
@@ -60,84 +58,64 @@ func (s *sSysProvinces) Delete(ctx context.Context, in sysin.ProvincesDeleteInp)
return
}
- pidExist, err := dao.SysProvinces.Ctx(ctx).Where("pid", models.Id).One()
+ has, err := dao.SysProvinces.Ctx(ctx).Where("pid", models.Id).One()
if err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "删除省市区数据时获取上级数据失败!")
return
}
- if !pidExist.IsEmpty() {
+ if !has.IsEmpty() {
err = gerror.New("请先删除该地区下得所有子级!")
return
}
- _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Delete()
+ if _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Delete(); err != nil {
+ err = gerror.Wrap(err, "删除省市区数据失败!")
+ return
+ }
return
}
-// Edit 修改/新增
+// Edit 修改/新增省市区数据
func (s *sSysProvinces) Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error) {
- if in.Title == "" {
- err = gerror.New("标题不能为空")
- return
- }
-
- if in.Id <= 0 {
- err = gerror.New("地区Id必须大于0")
- return
- }
-
// 关系树
in.Pid, in.Level, in.Tree, err = hgorm.GenSubTree(ctx, dao.SysProvinces, in.Pid)
if err != nil {
return
}
- isUpdate := false
models, err := s.View(ctx, sysin.ProvincesViewInp{Id: in.Id})
if err != nil {
return
}
- if models != nil {
- isUpdate = true
- }
-
// 修改
- if isUpdate {
- _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Data(in).Update()
+ if models != nil {
+ if _, err = dao.SysProvinces.Ctx(ctx).Fields(sysin.ProvincesUpdateFields{}).WherePri(in.Id).Data(in).Update(); err != nil {
+ err = gerror.Wrap(err, "修改省市区数据失败!")
+ }
return
}
// 新增
- _, err = dao.SysProvinces.Ctx(ctx).Data(in).Insert()
+ if _, err = dao.SysProvinces.Ctx(ctx).Fields(sysin.ProvincesInsertFields{}).Data(in).Insert(); err != nil {
+ err = gerror.Wrap(err, "新增省市区数据失败!")
+ }
return
}
-// Status 更新部门状态
+// Status 更新省市区状态
func (s *sSysProvinces) Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error) {
- if in.Id <= 0 {
- err = gerror.New("ID不能为空")
- return
+ if _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update(); err != nil {
+ err = gerror.Wrap(err, "更新省市区状态失败!")
}
-
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
- }
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- _, err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Data("status", in.Status).Update()
return
}
// MaxSort 最大排序
func (s *sSysProvinces) MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error) {
if err = dao.SysProvinces.Ctx(ctx).Fields(dao.SysProvinces.Columns().Sort).OrderDesc(dao.SysProvinces.Columns().Sort).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取省市区最大排序失败!")
return
}
@@ -148,9 +126,11 @@ func (s *sSysProvinces) MaxSort(ctx context.Context, in sysin.ProvincesMaxSortIn
return
}
-// View 获取指定字典类型信息
+// View 获取省市区信息
func (s *sSysProvinces) View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error) {
- err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Scan(&res)
+ if err = dao.SysProvinces.Ctx(ctx).Where("id", in.Id).Scan(&res); err != nil {
+ err = gerror.Wrap(err, "获取省市区信息失败!")
+ }
return
}
@@ -167,11 +147,18 @@ func (s *sSysProvinces) List(ctx context.Context, in sysin.ProvincesListInp) (li
}
totalCount, err = mod.Count()
- if err != nil || totalCount == 0 {
+ if err != nil {
+ err = gerror.Wrap(err, "获取省市区数据行失败!")
return
}
- err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list)
+ if totalCount == 0 {
+ return
+ }
+
+ if err = mod.Page(in.Page, in.PerPage).Order("id desc").Scan(&list); err != nil {
+ err = gerror.Wrap(err, "获取省市区列表失败!")
+ }
return
}
@@ -192,11 +179,18 @@ func (s *sSysProvinces) ChildrenList(ctx context.Context, in sysin.ProvincesChil
}
totalCount, err = mod.Count()
- if err != nil || totalCount == 0 {
+ if err != nil {
+ err = gerror.Wrap(err, "获取省市区下级数据行失败!")
return
}
- err = mod.Page(in.Page, in.PerPage).Order("sort asc,id desc").Scan(&list)
+ if totalCount == 0 {
+ return
+ }
+
+ if err = mod.Page(in.Page, in.PerPage).Order("sort asc,id desc").Scan(&list); err != nil {
+ err = gerror.Wrap(err, "获取省市区下级列表失败!")
+ }
return
}
@@ -212,7 +206,6 @@ func (s *sSysProvinces) UniqueId(ctx context.Context, in sysin.ProvincesUniqueId
res.IsUnique = false
return
}
-
return
}
@@ -224,7 +217,7 @@ func (s *sSysProvinces) Select(ctx context.Context, in sysin.ProvincesSelectInp)
Where("pid", in.Value)
if err = mod.Order("sort asc,id asc").Scan(&res.List); err != nil {
- err = gerror.Wrap(err, consts.ErrorORM)
+ err = gerror.Wrap(err, "获取省市区选项失败!")
return
}
@@ -243,6 +236,5 @@ func (s *sSysProvinces) Select(ctx context.Context, in sysin.ProvincesSelectInp)
continue
}
}
-
return
}
diff --git a/server/internal/model/input/adminin/dept.go b/server/internal/model/input/adminin/dept.go
index 210eec7..df2aa4a 100644
--- a/server/internal/model/input/adminin/dept.go
+++ b/server/internal/model/input/adminin/dept.go
@@ -6,20 +6,14 @@
package adminin
import (
+ "context"
+ "github.com/gogf/gf/v2/errors/gerror"
+ "hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
+ "hotgo/utility/validate"
)
-// DeptNameUniqueInp 名称是否唯一
-type DeptNameUniqueInp struct {
- Name string
- Id int64
-}
-
-type DeptNameUniqueModel struct {
- IsUnique bool
-}
-
// DeptMaxSortInp 最大排序
type DeptMaxSortInp struct {
Id int64
@@ -29,13 +23,59 @@ type DeptMaxSortModel struct {
Sort int
}
-// DeptEditInp 修改/新增字典数据
+// DeptEditInp 修改/新增部门数据
type DeptEditInp struct {
entity.AdminDept
}
+
+func (in *DeptEditInp) Filter(ctx context.Context) (err error) {
+ if in.Name == "" {
+ err = gerror.New("名称不能为空")
+ return
+ }
+
+ if in.Id > 0 && in.Id == in.Pid {
+ err = gerror.New("上级部门不能是自己")
+ return
+ }
+
+ return
+}
+
type DeptEditModel struct{}
-// DeptDeleteInp 删除字典类型
+// DeptUpdateFields 修改数据字段过滤
+type DeptUpdateFields struct {
+ Id int64 `json:"id" description:"部门ID"`
+ Pid int64 `json:"pid" description:"父部门ID"`
+ Name string `json:"name" description:"部门名称"`
+ Code string `json:"code" description:"部门编码"`
+ Type string `json:"type" description:"部门类型"`
+ Leader string `json:"leader" description:"负责人"`
+ Phone string `json:"phone" description:"联系电话"`
+ Email string `json:"email" description:"邮箱"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系树"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"部门状态"`
+}
+
+// DeptInsertFields 新增数据字段过滤
+type DeptInsertFields struct {
+ Pid int64 `json:"pid" description:"父部门ID"`
+ Name string `json:"name" description:"部门名称"`
+ Code string `json:"code" description:"部门编码"`
+ Type string `json:"type" description:"部门类型"`
+ Leader string `json:"leader" description:"负责人"`
+ Phone string `json:"phone" description:"联系电话"`
+ Email string `json:"email" description:"邮箱"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系树"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"部门状态"`
+}
+
+// DeptDeleteInp 删除部门类型
type DeptDeleteInp struct {
Id interface{}
}
@@ -72,6 +112,26 @@ type DeptListModel struct {
type DeptStatusInp struct {
entity.AdminDept
}
+
+func (in *DeptStatusInp) 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.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
+
+ return
+}
+
type DeptStatusModel struct{}
type DeptOptionInp struct {
diff --git a/server/internal/model/input/adminin/member.go b/server/internal/model/input/adminin/member.go
index b058a25..8361c59 100644
--- a/server/internal/model/input/adminin/member.go
+++ b/server/internal/model/input/adminin/member.go
@@ -15,6 +15,7 @@ import (
"hotgo/internal/library/contexts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
+ "hotgo/utility/validate"
)
// MemberUpdateCashInp 更新会员提现信息
@@ -110,11 +111,11 @@ type LoginMemberInfoModel struct {
// MemberEditInp 修改/新增管理员
type MemberEditInp struct {
- Id int64 `json:"id" dc:""`
- RoleId int64 `json:"roleId" v:"required#角色不能为空" dc:"角色ID"`
- PostIds []int64 `json:"postIds" v:"required#岗位不能为空" dc:"岗位ID"`
- DeptId int64 `json:"deptId" v:"required#部门不能为空" dc:"部门ID"`
- Username string `json:"username" v:"required#账号不能为空" dc:"帐号"`
+ Id int64 `json:"id" dc:"管理员ID"`
+ RoleId int64 `json:"roleId" v:"required#角色不能为空" dc:"角色ID"`
+ PostIds []int64 `json:"postIds" v:"required#岗位不能为空" dc:"岗位ID"`
+ DeptId int64 `json:"deptId" v:"required#部门不能为空" dc:"部门ID"`
+ Username string `json:"username" v:"required#账号不能为空" dc:"帐号"`
PasswordHash string `json:"passwordHash" dc:"密码hash"`
Password string `json:"password" dc:"密码"`
RealName string `json:"realName" dc:"真实姓名"`
@@ -130,8 +131,6 @@ type MemberEditInp struct {
Mobile string `json:"mobile" dc:"手机号码"`
Remark string `json:"remark" dc:"备注"`
Status int `json:"status" dc:"状态"`
- CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
- UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
}
type MemberAddInp struct {
@@ -214,6 +213,25 @@ type MemberCash struct {
type MemberStatusInp struct {
entity.AdminMember
}
+
+func (in *MemberStatusInp) 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.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
+ return
+}
+
type MemberStatusModel struct{}
// MemberSelectInp 获取可选的后台用户选项
diff --git a/server/internal/model/input/adminin/role.go b/server/internal/model/input/adminin/role.go
index 969a16b..eb9ff81 100644
--- a/server/internal/model/input/adminin/role.go
+++ b/server/internal/model/input/adminin/role.go
@@ -3,16 +3,99 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-//
package adminin
import (
+ "context"
+ "github.com/gogf/gf/v2/encoding/gjson"
+ "github.com/gogf/gf/v2/errors/gerror"
"hotgo/internal/model"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
- "sort"
)
+// GetPermissionsInp 获取指定角色的菜单权限
+type GetPermissionsInp struct {
+ RoleId int64 `json:"id"`
+}
+
+type GetPermissionsModel struct {
+ MenuIds []int64 `json:"menuIds"`
+}
+
+// UpdatePermissionsInp 更新指定角色的菜单权限
+type UpdatePermissionsInp struct {
+ RoleId int64 `json:"id"`
+ MenuIds []int64 `json:"menuIds"`
+}
+
+// RoleDeleteInp 删除角色
+type RoleDeleteInp struct {
+ Id int64 `json:"id" v:"required"`
+}
+
+func (in *RoleDeleteInp) Filter(ctx context.Context) (err error) {
+ if in.Id <= 0 {
+ err = gerror.New("ID不能为空")
+ return
+ }
+
+ return
+}
+
+// RoleEditInp 获取列表
+type RoleEditInp struct {
+ entity.AdminRole
+}
+
+func (in *RoleEditInp) Filter(ctx context.Context) (err error) {
+ if in.Name == "" {
+ err = gerror.New("名称不能为空")
+ return
+ }
+
+ if in.Key == "" {
+ err = gerror.New("编码不能为空")
+ return
+ }
+
+ if in.Id > 0 && in.Id == in.Pid {
+ err = gerror.New("上级角色不能是自己")
+ return
+ }
+
+ return
+}
+
+// RoleUpdateFields 修改数据字段过滤
+type RoleUpdateFields struct {
+ Id int64 `json:"id" description:"角色ID"`
+ Name string `json:"name" description:"角色名称"`
+ Key string `json:"key" description:"角色权限字符串"`
+ DataScope int `json:"dataScope" description:"数据范围"`
+ CustomDept *gjson.Json `json:"customDept" description:"自定义部门权限"`
+ Pid int64 `json:"pid" description:"上级角色ID"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系树"`
+ Remark string `json:"remark" description:"备注"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"角色状态"`
+}
+
+// RoleInsertFields 新增数据字段过滤
+type RoleInsertFields struct {
+ Name string `json:"name" description:"角色名称"`
+ Key string `json:"key" description:"角色权限字符串"`
+ DataScope int `json:"dataScope" description:"数据范围"`
+ CustomDept *gjson.Json `json:"customDept" description:"自定义部门权限"`
+ Pid int64 `json:"pid" description:"上级角色ID"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系树"`
+ Remark string `json:"remark" description:"备注"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"角色状态"`
+}
+
// RoleListInp 获取列表
type RoleListInp struct {
form.PageReq
@@ -29,18 +112,6 @@ type RoleListModel struct {
List []*RoleTree `json:"list"`
}
-func Sort(v []*RoleTree) {
- sort.SliceStable(v, func(i, j int) bool {
- if v[i].Sort < v[j].Sort {
- return true
- }
- if v[i].Sort > v[j].Sort {
- return false
- }
- return v[i].Id < v[j].Id
- })
-}
-
// RoleMemberListInp 查询列表
type RoleMemberListInp struct {
form.PageReq
@@ -68,8 +139,16 @@ type MenuRoleListModel struct {
CheckedKeys []int64 `json:"checkedKeys" dc:"选择的菜单ID"`
}
+// DataScopeEditInp 获取数据权限选项
type DataScopeEditInp struct {
Id int64 `json:"id" v:"required" dc:"角色ID"`
DataScope int `json:"dataScope" v:"required" dc:"数据范围"`
CustomDept []int64 `json:"customDept" dc:"自定义部门权限"`
}
+
+func (in *DataScopeEditInp) Filter(ctx context.Context) (err error) {
+ if in.Id <= 0 {
+ return gerror.New("角色ID不正确!")
+ }
+ return
+}
diff --git a/server/internal/model/input/sysin/cron_group.go b/server/internal/model/input/sysin/cron_group.go
index be7ff73..495b453 100644
--- a/server/internal/model/input/sysin/cron_group.go
+++ b/server/internal/model/input/sysin/cron_group.go
@@ -3,12 +3,15 @@
// @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/errors/gerror"
+ "hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
+ "hotgo/utility/validate"
)
// CronGroupMaxSortInp 最大排序
@@ -24,8 +27,44 @@ type CronGroupMaxSortModel struct {
type CronGroupEditInp struct {
entity.SysCronGroup
}
+
+func (in *CronGroupEditInp) Filter(ctx context.Context) (err error) {
+ if in.Name == "" {
+ err = gerror.New("名称不能为空")
+ return
+ }
+
+ if in.Id > 0 && in.Id == in.Pid {
+ err = gerror.New("上级分组不能是自己")
+ return
+ }
+
+ return
+}
+
type CronGroupEditModel struct{}
+// CronGroupUpdateFields 修改数据字段过滤
+type CronGroupUpdateFields struct {
+ Id int64 `json:"id" description:"任务分组ID"`
+ Pid int64 `json:"pid" description:"父类字典类型ID"`
+ Name string `json:"name" description:"字典类型名称"`
+ Type string `json:"type" description:"字典类型"`
+ Sort int `json:"sort" description:"排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"字典类型状态"`
+}
+
+// CronGroupInsertFields 新增数据字段过滤
+type CronGroupInsertFields struct {
+ Pid int64 `json:"pid" description:"父类任务分组ID"`
+ Name string `json:"name" description:"分组名称"`
+ IsDefault int `json:"isDefault" description:"是否默认"`
+ Sort int `json:"sort" description:"排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"分组状态"`
+}
+
// CronGroupDeleteInp 删除字典类型
type CronGroupDeleteInp struct {
Id interface{}
@@ -57,6 +96,26 @@ type CronGroupListModel struct {
type CronGroupStatusInp struct {
entity.SysCronGroup
}
+
+func (in *CronGroupStatusInp) 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.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
+
+ return
+}
+
type CronGroupStatusModel struct{}
// CronGroupSelectInp 选项
diff --git a/server/internal/model/input/sysin/curd_demo.go b/server/internal/model/input/sysin/curd_demo.go
index 39a88de..0dfe53b 100644
--- a/server/internal/model/input/sysin/curd_demo.go
+++ b/server/internal/model/input/sysin/curd_demo.go
@@ -3,24 +3,82 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-// @AutoGenerate Version 2.5.3
-// @AutoGenerate Date 2023-04-28 15:28:40
+// @AutoGenerate Version 2.7.3
package sysin
import (
"context"
+ "hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
+ "hotgo/utility/validate"
+ "github.com/gogf/gf/v2/errors/gerror"
+ "github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gtime"
)
+// CurdDemoUpdateFields 修改生成演示字段过滤
+type CurdDemoUpdateFields struct {
+ CategoryId int64 `json:"categoryId" dc:"分类ID"`
+ Title string `json:"title" dc:"标题"`
+ Description string `json:"description" dc:"描述"`
+ Content string `json:"content" dc:"内容"`
+ Image string `json:"image" dc:"单图"`
+ Attachfile string `json:"attachfile" dc:"附件"`
+ CityId int64 `json:"cityId" dc:"所在城市"`
+ Switch int `json:"switch" dc:"显示开关"`
+ Sort int `json:"sort" dc:"排序"`
+ Status int `json:"status" dc:"状态"`
+ UpdatedBy int64 `json:"updatedBy" dc:"更新者"`
+}
+
+// CurdDemoInsertFields 新增生成演示字段过滤
+type CurdDemoInsertFields struct {
+ CategoryId int64 `json:"categoryId" dc:"分类ID"`
+ Title string `json:"title" dc:"标题"`
+ Description string `json:"description" dc:"描述"`
+ Content string `json:"content" dc:"内容"`
+ Image string `json:"image" dc:"单图"`
+ Attachfile string `json:"attachfile" dc:"附件"`
+ CityId int64 `json:"cityId" dc:"所在城市"`
+ Switch int `json:"switch" dc:"显示开关"`
+ Sort int `json:"sort" dc:"排序"`
+ Status int `json:"status" dc:"状态"`
+ CreatedBy int64 `json:"createdBy" dc:"创建者"`
+}
+
// CurdDemoEditInp 修改/新增生成演示
type CurdDemoEditInp struct {
entity.SysGenCurdDemo
}
func (in *CurdDemoEditInp) Filter(ctx context.Context) (err error) {
+ // 验证分类ID
+ if err := g.Validator().Rules("required").Data(in.CategoryId).Messages("分类ID不能为空").Run(ctx); err != nil {
+ return err.Current()
+ }
+
+ // 验证标题
+ if err := g.Validator().Rules("required").Data(in.Title).Messages("标题不能为空").Run(ctx); err != nil {
+ return err.Current()
+ }
+
+ // 验证描述
+ if err := g.Validator().Rules("required").Data(in.Description).Messages("描述不能为空").Run(ctx); err != nil {
+ return err.Current()
+ }
+
+ // 验证内容
+ if err := g.Validator().Rules("required").Data(in.Content).Messages("内容不能为空").Run(ctx); err != nil {
+ return err.Current()
+ }
+
+ // 验证排序
+ if err := g.Validator().Rules("required").Data(in.Sort).Messages("排序不能为空").Run(ctx); err != nil {
+ return err.Current()
+ }
+
return
}
@@ -70,9 +128,12 @@ type CurdDemoListModel struct {
Description string `json:"description" dc:"描述"`
Image string `json:"image" dc:"单图"`
Attachfile string `json:"attachfile" dc:"附件"`
+ CityId int64 `json:"cityId" dc:"所在城市"`
Switch int `json:"switch" dc:"显示开关"`
Sort int `json:"sort" dc:"排序"`
Status int `json:"status" dc:"状态"`
+ CreatedBy int64 `json:"createdBy" dc:"创建者"`
+ UpdatedBy int64 `json:"updatedBy" dc:"更新者"`
CreatedAt *gtime.Time `json:"createdAt" dc:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" dc:"修改时间"`
TestCategoryName string `json:"testCategoryName" dc:"分类名称"`
@@ -86,6 +147,7 @@ type CurdDemoExportModel struct {
Description string `json:"description" dc:"描述"`
Image string `json:"image" dc:"单图"`
Attachfile string `json:"attachfile" dc:"附件"`
+ CityId int64 `json:"cityId" dc:"所在城市"`
Switch int `json:"switch" dc:"显示开关"`
Sort int `json:"sort" dc:"排序"`
Status int `json:"status" dc:"状态"`
@@ -114,6 +176,20 @@ type CurdDemoStatusInp struct {
}
func (in *CurdDemoStatusInp) 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.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
return
}
diff --git a/server/internal/model/input/sysin/dict_data.go b/server/internal/model/input/sysin/dict_data.go
index 6275b40..5dac434 100644
--- a/server/internal/model/input/sysin/dict_data.go
+++ b/server/internal/model/input/sysin/dict_data.go
@@ -3,10 +3,11 @@
// @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/errors/gerror"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
)
@@ -16,8 +17,50 @@ type DictDataEditInp struct {
entity.SysDictData
TypeID int64
}
+
+func (in *DictDataEditInp) Filter(ctx context.Context) (err error) {
+ if in.Label == "" {
+ err = gerror.New("字典标签不能为空")
+ return
+ }
+
+ if in.Id > 0 && in.TypeID <= 0 {
+ err = gerror.New("字典类型不能为空")
+ return
+ }
+
+ return
+}
+
type DictDataEditModel struct{}
+// DictDataUpdateFields 修改数据字段过滤
+type DictDataUpdateFields struct {
+ Id int64 `json:"id" description:"字典数据ID"`
+ Label string `json:"label" description:"字典标签"`
+ Value string `json:"value" description:"字典键值"`
+ ValueType string `json:"valueType" description:"键值数据类型:string,int,uint,bool,datetime,date"`
+ Type string `json:"type" description:"字典类型"`
+ ListClass string `json:"listClass" description:"表格回显样式"`
+ IsDefault int `json:"isDefault" description:"是否为系统默认"`
+ Sort int `json:"sort" description:"字典排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"状态"`
+}
+
+// DictDataInsertFields 新增数据字段过滤
+type DictDataInsertFields struct {
+ Label string `json:"label" description:"字典标签"`
+ Value string `json:"value" description:"字典键值"`
+ ValueType string `json:"valueType" description:"键值数据类型:string,int,uint,bool,datetime,date"`
+ Type string `json:"type" description:"字典类型"`
+ ListClass string `json:"listClass" description:"表格回显样式"`
+ IsDefault int `json:"isDefault" description:"是否为系统默认"`
+ Sort int `json:"sort" description:"字典排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"状态"`
+}
+
// DictDataDeleteInp 删除字典数据
type DictDataDeleteInp struct {
Id interface{}
diff --git a/server/internal/model/input/sysin/dict_type.go b/server/internal/model/input/sysin/dict_type.go
index 74d7e71..57780ae 100644
--- a/server/internal/model/input/sysin/dict_type.go
+++ b/server/internal/model/input/sysin/dict_type.go
@@ -3,10 +3,11 @@
// @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/errors/gerror"
"github.com/gogf/gf/v2/frame/g"
"hotgo/internal/model/entity"
)
@@ -15,8 +16,44 @@ import (
type DictTypeEditInp struct {
entity.SysDictType
}
+
+func (in *DictTypeEditInp) Filter(ctx context.Context) (err error) {
+ if in.Name == "" {
+ err = gerror.New("名称不能为空")
+ return
+ }
+
+ if in.Id > 0 && in.Id == in.Pid {
+ err = gerror.New("上级字典不能是自己")
+ return
+ }
+
+ return
+}
+
type DictTypeEditModel struct{}
+// DictTypeUpdateFields 修改数据字段过滤
+type DictTypeUpdateFields struct {
+ Id int64 `json:"id" description:"字典类型ID"`
+ Pid int64 `json:"pid" description:"父类字典类型ID"`
+ Name string `json:"name" description:"字典类型名称"`
+ Type string `json:"type" description:"字典类型"`
+ Sort int `json:"sort" description:"排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"字典类型状态"`
+}
+
+// DictTypeInsertFields 新增数据字段过滤
+type DictTypeInsertFields struct {
+ Pid int64 `json:"pid" description:"父类字典类型ID"`
+ Name string `json:"name" description:"字典类型名称"`
+ Type string `json:"type" description:"字典类型"`
+ Sort int `json:"sort" description:"排序"`
+ Remark string `json:"remark" description:"备注"`
+ Status int `json:"status" description:"字典类型状态"`
+}
+
// DictTypeDeleteInp 删除字典类型
type DictTypeDeleteInp struct {
Id interface{}
diff --git a/server/internal/model/input/sysin/provinces.go b/server/internal/model/input/sysin/provinces.go
index ed55ee3..89096a0 100644
--- a/server/internal/model/input/sysin/provinces.go
+++ b/server/internal/model/input/sysin/provinces.go
@@ -3,12 +3,15 @@
// @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/errors/gerror"
+ "hotgo/internal/consts"
"hotgo/internal/model/entity"
"hotgo/internal/model/input/form"
+ "hotgo/utility/validate"
)
// ProvincesMaxSortInp 最大排序
@@ -23,8 +26,50 @@ type ProvincesMaxSortModel struct {
type ProvincesEditInp struct {
entity.SysProvinces
}
+
+func (in *ProvincesEditInp) Filter(ctx context.Context) (err error) {
+ if in.Title == "" {
+ err = gerror.New("标题不能为空")
+ return
+ }
+
+ if in.Id <= 0 {
+ err = gerror.New("地区Id必须大于0")
+ return
+ }
+
+ return
+}
+
type ProvincesEditModel struct{}
+// ProvincesUpdateFields 修改数据字段过滤
+type ProvincesUpdateFields struct {
+ Id int64 `json:"id" description:"省市区ID"`
+ Title string `json:"title" description:"栏目名称"`
+ Pinyin string `json:"pinyin" description:"拼音"`
+ Lng string `json:"lng" description:"经度"`
+ Lat string `json:"lat" description:"纬度"`
+ Pid int64 `json:"pid" description:"父栏目"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"状态"`
+}
+
+// ProvincesInsertFields 新增数据字段过滤
+type ProvincesInsertFields struct {
+ Title string `json:"title" description:"栏目名称"`
+ Pinyin string `json:"pinyin" description:"拼音"`
+ Lng string `json:"lng" description:"经度"`
+ Lat string `json:"lat" description:"纬度"`
+ Pid int64 `json:"pid" description:"父栏目"`
+ Level int `json:"level" description:"关系树等级"`
+ Tree string `json:"tree" description:"关系"`
+ Sort int `json:"sort" description:"排序"`
+ Status int `json:"status" description:"状态"`
+}
+
// ProvincesDeleteInp 删除字典类型
type ProvincesDeleteInp struct {
Id interface{} `json:"id" v:"required#省市区ID不能为空" dc:"省市区ID"`
@@ -57,6 +102,25 @@ type ProvincesListModel struct {
type ProvincesStatusInp struct {
entity.SysProvinces
}
+
+func (in *ProvincesStatusInp) 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.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
+ return
+}
+
type ProvincesStatusModel struct{}
// ProvincesChildrenListInp 获取省市区下级列表
diff --git a/server/internal/router/genrouter/curd_demo.go b/server/internal/router/genrouter/curd_demo.go
index f16014f..b5577ad 100644
--- a/server/internal/router/genrouter/curd_demo.go
+++ b/server/internal/router/genrouter/curd_demo.go
@@ -3,8 +3,7 @@
// @Copyright Copyright (c) 2023 HotGo CLI
// @Author Ms <133814250@qq.com>
// @License https://github.com/bufanyun/hotgo/blob/master/LICENSE
-// @AutoGenerate Version 2.5.3
-// @AutoGenerate Date 2023-04-28 15:28:40
+// @AutoGenerate Version 2.7.3
package genrouter
import "hotgo/internal/controller/admin/sys"
diff --git a/server/internal/service/admin.go b/server/internal/service/admin.go
index 624ee85..0a74267 100644
--- a/server/internal/service/admin.go
+++ b/server/internal/service/admin.go
@@ -19,11 +19,49 @@ import (
)
type (
- IAdminCash interface {
- View(ctx context.Context, in adminin.CashViewInp) (res *adminin.CashViewModel, err error)
- List(ctx context.Context, in adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error)
- Apply(ctx context.Context, in adminin.CashApplyInp) (err error)
- Payment(ctx context.Context, in adminin.CashPaymentInp) (err error)
+ IAdminCreditsLog interface {
+ Model(ctx context.Context, option ...*handler.Option) *gdb.Model
+ SaveBalance(ctx context.Context, in adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error)
+ SaveIntegral(ctx context.Context, in adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error)
+ List(ctx context.Context, in adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error)
+ Export(ctx context.Context, in adminin.CreditsLogListInp) (err error)
+ }
+ IAdminDept interface {
+ Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error)
+ Edit(ctx context.Context, in adminin.DeptEditInp) (err error)
+ Status(ctx context.Context, in adminin.DeptStatusInp) (err error)
+ MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error)
+ View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error)
+ Option(ctx context.Context, in adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error)
+ List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error)
+ GetName(ctx context.Context, id int64) (name string, err error)
+ }
+ IAdminMember interface {
+ AddBalance(ctx context.Context, in adminin.MemberAddBalanceInp) (err error)
+ AddIntegral(ctx context.Context, in adminin.MemberAddIntegralInp) (err error)
+ UpdateCash(ctx context.Context, in adminin.MemberUpdateCashInp) (err error)
+ UpdateEmail(ctx context.Context, in adminin.MemberUpdateEmailInp) (err error)
+ UpdateMobile(ctx context.Context, in adminin.MemberUpdateMobileInp) (err error)
+ UpdateProfile(ctx context.Context, in adminin.MemberUpdateProfileInp) (err error)
+ UpdatePwd(ctx context.Context, in adminin.MemberUpdatePwdInp) (err error)
+ ResetPwd(ctx context.Context, in adminin.MemberResetPwdInp) (err error)
+ VerifyUnique(ctx context.Context, in adminin.VerifyUniqueInp) (err error)
+ Delete(ctx context.Context, in adminin.MemberDeleteInp) (err error)
+ Edit(ctx context.Context, in adminin.MemberEditInp) (err error)
+ View(ctx context.Context, in adminin.MemberViewInp) (res *adminin.MemberViewModel, err error)
+ List(ctx context.Context, in adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error)
+ Status(ctx context.Context, in adminin.MemberStatusInp) (err error)
+ GenTree(ctx context.Context, pid int64) (level int, newTree string, err error)
+ LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error)
+ MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error)
+ GetIdByCode(ctx context.Context, in adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error)
+ Select(ctx context.Context, in adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error)
+ VerifySuperId(ctx context.Context, verifyId int64) bool
+ FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model
+ }
+ IAdminMemberPost interface {
+ UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
+ GetMemberByIds(ctx context.Context, memberId int64) (postIds []int64, err error)
}
IAdminMenu interface {
MaxSort(ctx context.Context, req *menu.MaxSortReq) (res *menu.MaxSortRes, err error)
@@ -33,13 +71,9 @@ type (
Edit(ctx context.Context, req *menu.EditReq) (err error)
View(ctx context.Context, req *menu.ViewReq) (res *menu.ViewRes, err error)
List(ctx context.Context, req *menu.ListReq) (lists []map[string]interface{}, err error)
- GetMenuList(ctx context.Context, memberId int64) (lists role.DynamicRes, err error)
+ GetMenuList(ctx context.Context, memberId int64) (res *role.DynamicRes, err error)
LoginPermissions(ctx context.Context, memberId int64) (lists adminin.MemberLoginPermissions, err error)
}
- IAdminMonitor interface {
- StartMonitor(ctx context.Context)
- GetMeta(ctx context.Context) *model.MonitorData
- }
IAdminPost interface {
Delete(ctx context.Context, in adminin.PostDeleteInp) (err error)
Edit(ctx context.Context, in adminin.PostEditInp) (err error)
@@ -51,6 +85,24 @@ type (
GetMemberByStartName(ctx context.Context, memberId int64) (name string, err error)
Status(ctx context.Context, in adminin.PostStatusInp) (err error)
}
+ IAdminRole interface {
+ Verify(ctx context.Context, path, method string) bool
+ List(ctx context.Context, in adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error)
+ GetName(ctx context.Context, id int64) (name string, err error)
+ GetMemberList(ctx context.Context, id int64) (list []*adminin.RoleListModel, err error)
+ GetPermissions(ctx context.Context, in adminin.GetPermissionsInp) (res *adminin.GetPermissionsModel, err error)
+ UpdatePermissions(ctx context.Context, in adminin.UpdatePermissionsInp) (err error)
+ Edit(ctx context.Context, in adminin.RoleEditInp) (err error)
+ Delete(ctx context.Context, in adminin.RoleDeleteInp) (err error)
+ DataScopeSelect() (res form.Selects)
+ DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error)
+ }
+ IAdminCash interface {
+ View(ctx context.Context, in adminin.CashViewInp) (res *adminin.CashViewModel, err error)
+ List(ctx context.Context, in adminin.CashListInp) (list []*adminin.CashListModel, totalCount int, err error)
+ Apply(ctx context.Context, in adminin.CashApplyInp) (err error)
+ Payment(ctx context.Context, in adminin.CashPaymentInp) (err error)
+ }
IAdminNotice interface {
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
Delete(ctx context.Context, in adminin.NoticeDeleteInp) (err error)
@@ -78,128 +130,41 @@ type (
View(ctx context.Context, in adminin.OrderViewInp) (res *adminin.OrderViewModel, err error)
Status(ctx context.Context, in adminin.OrderStatusInp) (err error)
}
- IAdminRole interface {
- Verify(ctx context.Context, path, method string) bool
- List(ctx context.Context, in adminin.RoleListInp) (res *adminin.RoleListModel, totalCount int, err error)
- GetName(ctx context.Context, RoleId int64) (name string, err error)
- GetMemberList(ctx context.Context, RoleId int64) (list []*adminin.RoleListModel, err error)
- GetPermissions(ctx context.Context, reqInfo *role.GetPermissionsReq) (MenuIds []int64, err error)
- UpdatePermissions(ctx context.Context, reqInfo *role.UpdatePermissionsReq) (err error)
- Edit(ctx context.Context, in *role.EditReq) (err error)
- Delete(ctx context.Context, in *role.DeleteReq) (err error)
- DataScopeSelect(ctx context.Context) (res form.Selects)
- DataScopeEdit(ctx context.Context, in *adminin.DataScopeEditInp) (err error)
- }
IAdminSite interface {
Register(ctx context.Context, in adminin.RegisterInp) (err error)
AccountLogin(ctx context.Context, in adminin.AccountLoginInp) (res *adminin.LoginModel, err error)
MobileLogin(ctx context.Context, in adminin.MobileLoginInp) (res *adminin.LoginModel, err error)
}
- IAdminCreditsLog interface {
- Model(ctx context.Context, option ...*handler.Option) *gdb.Model
- SaveBalance(ctx context.Context, in adminin.CreditsLogSaveBalanceInp) (res *adminin.CreditsLogSaveBalanceModel, err error)
- SaveIntegral(ctx context.Context, in adminin.CreditsLogSaveIntegralInp) (res *adminin.CreditsLogSaveIntegralModel, err error)
- List(ctx context.Context, in adminin.CreditsLogListInp) (list []*adminin.CreditsLogListModel, totalCount int, err error)
- Export(ctx context.Context, in adminin.CreditsLogListInp) (err error)
- }
- IAdminDept interface {
- NameUnique(ctx context.Context, in adminin.DeptNameUniqueInp) (res *adminin.DeptNameUniqueModel, err error)
- Delete(ctx context.Context, in adminin.DeptDeleteInp) (err error)
- Edit(ctx context.Context, in adminin.DeptEditInp) (err error)
- Status(ctx context.Context, in adminin.DeptStatusInp) (err error)
- MaxSort(ctx context.Context, in adminin.DeptMaxSortInp) (res *adminin.DeptMaxSortModel, err error)
- View(ctx context.Context, in adminin.DeptViewInp) (res *adminin.DeptViewModel, err error)
- Option(ctx context.Context, in adminin.DeptOptionInp) (res *adminin.DeptOptionModel, totalCount int, err error)
- List(ctx context.Context, in adminin.DeptListInp) (res *adminin.DeptListModel, err error)
- GetName(ctx context.Context, id int64) (name string, err error)
- }
- IAdminMember interface {
- AddBalance(ctx context.Context, in adminin.MemberAddBalanceInp) (err error)
- AddIntegral(ctx context.Context, in adminin.MemberAddIntegralInp) (err error)
- UpdateCash(ctx context.Context, in adminin.MemberUpdateCashInp) (err error)
- UpdateEmail(ctx context.Context, in adminin.MemberUpdateEmailInp) (err error)
- UpdateMobile(ctx context.Context, in adminin.MemberUpdateMobileInp) (err error)
- UpdateProfile(ctx context.Context, in adminin.MemberUpdateProfileInp) (err error)
- UpdatePwd(ctx context.Context, in adminin.MemberUpdatePwdInp) (err error)
- ResetPwd(ctx context.Context, in adminin.MemberResetPwdInp) (err error)
- VerifyUnique(ctx context.Context, in adminin.VerifyUniqueInp) (err error)
- Delete(ctx context.Context, in adminin.MemberDeleteInp) (err error)
- Edit(ctx context.Context, in adminin.MemberEditInp) (err error)
- View(ctx context.Context, in adminin.MemberViewInp) (res *adminin.MemberViewModel, err error)
- List(ctx context.Context, in adminin.MemberListInp) (list []*adminin.MemberListModel, totalCount int, err error)
- Status(ctx context.Context, in adminin.MemberStatusInp) (err error)
- GenTree(ctx context.Context, pid int64) (level int, newTree string, err error)
- RoleMemberList(ctx context.Context, in adminin.RoleMemberListInp) (list []*adminin.MemberListModel, totalCount int, err error)
- LoginMemberInfo(ctx context.Context) (res *adminin.LoginMemberInfoModel, err error)
- MemberLoginStat(ctx context.Context, in adminin.MemberLoginStatInp) (res *adminin.MemberLoginStatModel, err error)
- GetIdByCode(ctx context.Context, in adminin.GetIdByCodeInp) (res *adminin.GetIdByCodeModel, err error)
- Select(ctx context.Context, in adminin.MemberSelectInp) (res []*adminin.MemberSelectModel, err error)
- VerifySuperId(ctx context.Context, verifyId int64) bool
- FilterAuthModel(ctx context.Context, memberId int64) *gdb.Model
- }
- IAdminMemberPost interface {
- UpdatePostIds(ctx context.Context, memberId int64, postIds []int64) (err error)
- GetMemberByIds(ctx context.Context, memberId int64) (postIds []int64, err error)
+ IAdminMonitor interface {
+ StartMonitor(ctx context.Context)
+ GetMeta(ctx context.Context) *model.MonitorData
}
)
var (
- localAdminMemberPost IAdminMemberPost
- localAdminNotice IAdminNotice
- localAdminOrder IAdminOrder
- localAdminRole IAdminRole
- localAdminSite IAdminSite
+ localAdminCash IAdminCash
localAdminCreditsLog IAdminCreditsLog
localAdminDept IAdminDept
localAdminMember IAdminMember
- localAdminPost IAdminPost
- localAdminCash IAdminCash
+ localAdminMemberPost IAdminMemberPost
localAdminMenu IAdminMenu
+ localAdminPost IAdminPost
+ localAdminRole IAdminRole
localAdminMonitor IAdminMonitor
+ localAdminNotice IAdminNotice
+ localAdminOrder IAdminOrder
+ localAdminSite IAdminSite
)
-func AdminMember() IAdminMember {
- if localAdminMember == nil {
- panic("implement not found for interface IAdminMember, forgot register?")
+func AdminPost() IAdminPost {
+ if localAdminPost == nil {
+ panic("implement not found for interface IAdminPost, forgot register?")
}
- return localAdminMember
+ return localAdminPost
}
-func RegisterAdminMember(i IAdminMember) {
- localAdminMember = i
-}
-
-func AdminMemberPost() IAdminMemberPost {
- if localAdminMemberPost == nil {
- panic("implement not found for interface IAdminMemberPost, forgot register?")
- }
- return localAdminMemberPost
-}
-
-func RegisterAdminMemberPost(i IAdminMemberPost) {
- localAdminMemberPost = i
-}
-
-func AdminNotice() IAdminNotice {
- if localAdminNotice == nil {
- panic("implement not found for interface IAdminNotice, forgot register?")
- }
- return localAdminNotice
-}
-
-func RegisterAdminNotice(i IAdminNotice) {
- localAdminNotice = i
-}
-
-func AdminOrder() IAdminOrder {
- if localAdminOrder == nil {
- panic("implement not found for interface IAdminOrder, forgot register?")
- }
- return localAdminOrder
-}
-
-func RegisterAdminOrder(i IAdminOrder) {
- localAdminOrder = i
+func RegisterAdminPost(i IAdminPost) {
+ localAdminPost = i
}
func AdminRole() IAdminRole {
@@ -213,15 +178,15 @@ func RegisterAdminRole(i IAdminRole) {
localAdminRole = i
}
-func AdminSite() IAdminSite {
- if localAdminSite == nil {
- panic("implement not found for interface IAdminSite, forgot register?")
+func AdminCash() IAdminCash {
+ if localAdminCash == nil {
+ panic("implement not found for interface IAdminCash, forgot register?")
}
- return localAdminSite
+ return localAdminCash
}
-func RegisterAdminSite(i IAdminSite) {
- localAdminSite = i
+func RegisterAdminCash(i IAdminCash) {
+ localAdminCash = i
}
func AdminCreditsLog() IAdminCreditsLog {
@@ -246,37 +211,26 @@ func RegisterAdminDept(i IAdminDept) {
localAdminDept = i
}
-func AdminMonitor() IAdminMonitor {
- if localAdminMonitor == nil {
- panic("implement not found for interface IAdminMonitor, forgot register?")
+func AdminMember() IAdminMember {
+ if localAdminMember == nil {
+ panic("implement not found for interface IAdminMember, forgot register?")
}
- return localAdminMonitor
+ return localAdminMember
}
-func RegisterAdminMonitor(i IAdminMonitor) {
- localAdminMonitor = i
+func RegisterAdminMember(i IAdminMember) {
+ localAdminMember = i
}
-func AdminPost() IAdminPost {
- if localAdminPost == nil {
- panic("implement not found for interface IAdminPost, forgot register?")
+func AdminMemberPost() IAdminMemberPost {
+ if localAdminMemberPost == nil {
+ panic("implement not found for interface IAdminMemberPost, forgot register?")
}
- return localAdminPost
+ return localAdminMemberPost
}
-func RegisterAdminPost(i IAdminPost) {
- localAdminPost = i
-}
-
-func AdminCash() IAdminCash {
- if localAdminCash == nil {
- panic("implement not found for interface IAdminCash, forgot register?")
- }
- return localAdminCash
-}
-
-func RegisterAdminCash(i IAdminCash) {
- localAdminCash = i
+func RegisterAdminMemberPost(i IAdminMemberPost) {
+ localAdminMemberPost = i
}
func AdminMenu() IAdminMenu {
@@ -289,3 +243,47 @@ func AdminMenu() IAdminMenu {
func RegisterAdminMenu(i IAdminMenu) {
localAdminMenu = i
}
+
+func AdminMonitor() IAdminMonitor {
+ if localAdminMonitor == nil {
+ panic("implement not found for interface IAdminMonitor, forgot register?")
+ }
+ return localAdminMonitor
+}
+
+func RegisterAdminMonitor(i IAdminMonitor) {
+ localAdminMonitor = i
+}
+
+func AdminNotice() IAdminNotice {
+ if localAdminNotice == nil {
+ panic("implement not found for interface IAdminNotice, forgot register?")
+ }
+ return localAdminNotice
+}
+
+func RegisterAdminNotice(i IAdminNotice) {
+ localAdminNotice = i
+}
+
+func AdminOrder() IAdminOrder {
+ if localAdminOrder == nil {
+ panic("implement not found for interface IAdminOrder, forgot register?")
+ }
+ return localAdminOrder
+}
+
+func RegisterAdminOrder(i IAdminOrder) {
+ localAdminOrder = i
+}
+
+func AdminSite() IAdminSite {
+ if localAdminSite == nil {
+ panic("implement not found for interface IAdminSite, forgot register?")
+ }
+ return localAdminSite
+}
+
+func RegisterAdminSite(i IAdminSite) {
+ localAdminSite = i
+}
diff --git a/server/internal/service/sys.go b/server/internal/service/sys.go
index d854205..611701f 100644
--- a/server/internal/service/sys.go
+++ b/server/internal/service/sys.go
@@ -17,6 +17,16 @@ import (
)
type (
+ ISysAttachment interface {
+ Model(ctx context.Context, option ...*handler.Option) *gdb.Model
+ Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error)
+ Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
+ Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
+ MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (res *sysin.AttachmentMaxSortModel, err error)
+ View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
+ List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
+ Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (models *entity.SysAttachment, err error)
+ }
ISysBlacklist interface {
Delete(ctx context.Context, in sysin.BlacklistDeleteInp) (err error)
Edit(ctx context.Context, in sysin.BlacklistEditInp) (err error)
@@ -27,53 +37,26 @@ type (
VariableLoad(ctx context.Context, err error)
Load(ctx context.Context)
}
- ISysCronGroup interface {
- Delete(ctx context.Context, in sysin.CronGroupDeleteInp) (err error)
- Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error)
- Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error)
- MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error)
- View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
- List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
- Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
+ ISysDictData interface {
+ Delete(ctx context.Context, in sysin.DictDataDeleteInp) error
+ Edit(ctx context.Context, in sysin.DictDataEditInp) (err error)
+ List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
+ Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
}
- ISysGenCodes interface {
- Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error)
- Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
- Status(ctx context.Context, in sysin.GenCodesStatusInp) (err error)
- MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
- View(ctx context.Context, in sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
- List(ctx context.Context, in sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
- Selects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
- TableSelect(ctx context.Context, in sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
- ColumnSelect(ctx context.Context, in sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
- ColumnList(ctx context.Context, in sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
- Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
- Build(ctx context.Context, in sysin.GenCodesBuildInp) (err error)
- }
- ISysLoginLog interface {
- Model(ctx context.Context) *gdb.Model
- List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
- Export(ctx context.Context, in sysin.LoginLogListInp) (err error)
- Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error)
- View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
- Push(ctx context.Context, in sysin.LoginLogPushInp)
- RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
+ ISysLog interface {
+ Export(ctx context.Context, in sysin.LogListInp) (err error)
+ RealWrite(ctx context.Context, log entity.SysLog) (err error)
+ AutoLog(ctx context.Context) error
+ AnalysisLog(ctx context.Context) entity.SysLog
+ View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error)
+ Delete(ctx context.Context, in sysin.LogDeleteInp) (err error)
+ List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
}
ISysAddonsConfig interface {
GetConfigByGroup(ctx context.Context, in sysin.GetAddonsConfigInp) (res *sysin.GetAddonsConfigModel, err error)
ConversionType(ctx context.Context, models *entity.SysAddonsConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateAddonsConfigInp) (err error)
}
- ISysAttachment interface {
- Model(ctx context.Context, option ...*handler.Option) *gdb.Model
- Delete(ctx context.Context, in sysin.AttachmentDeleteInp) (err error)
- Edit(ctx context.Context, in sysin.AttachmentEditInp) (err error)
- Status(ctx context.Context, in sysin.AttachmentStatusInp) (err error)
- MaxSort(ctx context.Context, in sysin.AttachmentMaxSortInp) (res *sysin.AttachmentMaxSortModel, err error)
- View(ctx context.Context, in sysin.AttachmentViewInp) (res *sysin.AttachmentViewModel, err error)
- List(ctx context.Context, in sysin.AttachmentListInp) (list []*sysin.AttachmentListModel, totalCount int, err error)
- Add(ctx context.Context, meta *sysin.UploadFileMeta, fullPath, drive string) (models *entity.SysAttachment, err error)
- }
ISysConfig interface {
InitConfig(ctx context.Context)
GetLogin(ctx context.Context) (conf *model.LoginConfig, err error)
@@ -95,34 +78,17 @@ type (
ConversionType(ctx context.Context, models *entity.SysConfig) (value interface{}, err error)
UpdateConfigByGroup(ctx context.Context, in sysin.UpdateConfigInp) (err error)
}
- ISysLog interface {
- Export(ctx context.Context, in sysin.LogListInp) (err error)
- RealWrite(ctx context.Context, log entity.SysLog) (err error)
- AutoLog(ctx context.Context) error
- AnalysisLog(ctx context.Context) entity.SysLog
- View(ctx context.Context, in sysin.LogViewInp) (res *sysin.LogViewModel, err error)
- Delete(ctx context.Context, in sysin.LogDeleteInp) (err error)
- List(ctx context.Context, in sysin.LogListInp) (list []*sysin.LogListModel, totalCount int, err error)
- }
- ISysServeLog interface {
- Model(ctx context.Context) *gdb.Model
- List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
- Export(ctx context.Context, in sysin.ServeLogListInp) (err error)
- Delete(ctx context.Context, in sysin.ServeLogDeleteInp) (err error)
- View(ctx context.Context, in sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
- RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
- }
- ISysDictData interface {
- Delete(ctx context.Context, in sysin.DictDataDeleteInp) error
- Edit(ctx context.Context, in sysin.DictDataEditInp) (err error)
- List(ctx context.Context, in sysin.DictDataListInp) (list []*sysin.DictDataListModel, totalCount int, err error)
- Select(ctx context.Context, in sysin.DataSelectInp) (list sysin.DataSelectModel, err error)
- }
- ISysDictType interface {
- Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
- Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (err error)
- Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error)
- TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
+ ISysProvinces interface {
+ Tree(ctx context.Context) (list []g.Map, err error)
+ Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error)
+ Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
+ Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
+ MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
+ View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
+ List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
+ ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
+ UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
+ Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
}
ISysCurdDemo interface {
Model(ctx context.Context, option ...*handler.Option) *gdb.Model
@@ -135,6 +101,12 @@ type (
Status(ctx context.Context, in sysin.CurdDemoStatusInp) (err error)
Switch(ctx context.Context, in sysin.CurdDemoSwitchInp) (err error)
}
+ ISysDictType interface {
+ Tree(ctx context.Context) (list []*sysin.DictTypeTree, err error)
+ Delete(ctx context.Context, in sysin.DictTypeDeleteInp) (err error)
+ Edit(ctx context.Context, in sysin.DictTypeEditInp) (err error)
+ TreeSelect(ctx context.Context, in sysin.DictTreeSelectInp) (list []*sysin.DictTypeTree, err error)
+ }
ISysEmsLog interface {
Delete(ctx context.Context, in sysin.EmsLogDeleteInp) (err error)
Edit(ctx context.Context, in sysin.EmsLogEditInp) (err error)
@@ -146,17 +118,14 @@ type (
AllowSend(ctx context.Context, models *entity.SysEmsLog, config *model.EmailConfig) (err error)
VerifyCode(ctx context.Context, in sysin.VerifyEmsCodeInp) (err error)
}
- ISysProvinces interface {
- Tree(ctx context.Context) (list []g.Map, err error)
- Delete(ctx context.Context, in sysin.ProvincesDeleteInp) (err error)
- Edit(ctx context.Context, in sysin.ProvincesEditInp) (err error)
- Status(ctx context.Context, in sysin.ProvincesStatusInp) (err error)
- MaxSort(ctx context.Context, in sysin.ProvincesMaxSortInp) (res *sysin.ProvincesMaxSortModel, err error)
- View(ctx context.Context, in sysin.ProvincesViewInp) (res *sysin.ProvincesViewModel, err error)
- List(ctx context.Context, in sysin.ProvincesListInp) (list []*sysin.ProvincesListModel, totalCount int, err error)
- ChildrenList(ctx context.Context, in sysin.ProvincesChildrenListInp) (list []*sysin.ProvincesChildrenListModel, totalCount int, err error)
- UniqueId(ctx context.Context, in sysin.ProvincesUniqueIdInp) (res *sysin.ProvincesUniqueIdModel, err error)
- Select(ctx context.Context, in sysin.ProvincesSelectInp) (res *sysin.ProvincesSelectModel, err error)
+ ISysLoginLog interface {
+ Model(ctx context.Context) *gdb.Model
+ List(ctx context.Context, in sysin.LoginLogListInp) (list []*sysin.LoginLogListModel, totalCount int, err error)
+ Export(ctx context.Context, in sysin.LoginLogListInp) (err error)
+ Delete(ctx context.Context, in sysin.LoginLogDeleteInp) (err error)
+ View(ctx context.Context, in sysin.LoginLogViewInp) (res *sysin.LoginLogViewModel, err error)
+ Push(ctx context.Context, in sysin.LoginLogPushInp)
+ RealWrite(ctx context.Context, models entity.SysLoginLog) (err error)
}
ISysSmsLog interface {
Delete(ctx context.Context, in sysin.SmsLogDeleteInp) (err error)
@@ -188,94 +157,59 @@ type (
List(ctx context.Context, in sysin.CronListInp) (list []*sysin.CronListModel, totalCount int, err error)
OnlineExec(ctx context.Context, in sysin.OnlineExecInp) (err error)
}
+ ISysCronGroup interface {
+ Delete(ctx context.Context, in sysin.CronGroupDeleteInp) (err error)
+ Edit(ctx context.Context, in sysin.CronGroupEditInp) (err error)
+ Status(ctx context.Context, in sysin.CronGroupStatusInp) (err error)
+ MaxSort(ctx context.Context, in sysin.CronGroupMaxSortInp) (res *sysin.CronGroupMaxSortModel, err error)
+ View(ctx context.Context, in sysin.CronGroupViewInp) (res *sysin.CronGroupViewModel, err error)
+ List(ctx context.Context, in sysin.CronGroupListInp) (list []*sysin.CronGroupListModel, totalCount int, err error)
+ Select(ctx context.Context, in sysin.CronGroupSelectInp) (res *sysin.CronGroupSelectModel, err error)
+ }
+ ISysGenCodes interface {
+ Delete(ctx context.Context, in sysin.GenCodesDeleteInp) (err error)
+ Edit(ctx context.Context, in sysin.GenCodesEditInp) (res *sysin.GenCodesEditModel, err error)
+ Status(ctx context.Context, in sysin.GenCodesStatusInp) (err error)
+ MaxSort(ctx context.Context, in sysin.GenCodesMaxSortInp) (res *sysin.GenCodesMaxSortModel, err error)
+ View(ctx context.Context, in sysin.GenCodesViewInp) (res *sysin.GenCodesViewModel, err error)
+ List(ctx context.Context, in sysin.GenCodesListInp) (list []*sysin.GenCodesListModel, totalCount int, err error)
+ Selects(ctx context.Context, in sysin.GenCodesSelectsInp) (res *sysin.GenCodesSelectsModel, err error)
+ TableSelect(ctx context.Context, in sysin.GenCodesTableSelectInp) (res []*sysin.GenCodesTableSelectModel, err error)
+ ColumnSelect(ctx context.Context, in sysin.GenCodesColumnSelectInp) (res []*sysin.GenCodesColumnSelectModel, err error)
+ ColumnList(ctx context.Context, in sysin.GenCodesColumnListInp) (res []*sysin.GenCodesColumnListModel, err error)
+ Preview(ctx context.Context, in sysin.GenCodesPreviewInp) (res *sysin.GenCodesPreviewModel, err error)
+ Build(ctx context.Context, in sysin.GenCodesBuildInp) (err error)
+ }
+ ISysServeLog interface {
+ Model(ctx context.Context) *gdb.Model
+ List(ctx context.Context, in sysin.ServeLogListInp) (list []*sysin.ServeLogListModel, totalCount int, err error)
+ Export(ctx context.Context, in sysin.ServeLogListInp) (err error)
+ Delete(ctx context.Context, in sysin.ServeLogDeleteInp) (err error)
+ View(ctx context.Context, in sysin.ServeLogViewInp) (res *sysin.ServeLogViewModel, err error)
+ RealWrite(ctx context.Context, models entity.SysServeLog) (err error)
+ }
)
var (
- localSysDictData ISysDictData
- localSysDictType ISysDictType
- localSysLog ISysLog
- localSysServeLog ISysServeLog
- localSysProvinces ISysProvinces
- localSysSmsLog ISysSmsLog
localSysAddons ISysAddons
localSysCron ISysCron
- localSysCurdDemo ISysCurdDemo
- localSysEmsLog ISysEmsLog
+ localSysCronGroup ISysCronGroup
localSysGenCodes ISysGenCodes
- localSysLoginLog ISysLoginLog
- localSysAddonsConfig ISysAddonsConfig
+ localSysServeLog ISysServeLog
localSysAttachment ISysAttachment
localSysBlacklist ISysBlacklist
- localSysCronGroup ISysCronGroup
+ localSysDictData ISysDictData
+ localSysLog ISysLog
+ localSysAddonsConfig ISysAddonsConfig
localSysConfig ISysConfig
+ localSysProvinces ISysProvinces
+ localSysCurdDemo ISysCurdDemo
+ localSysDictType ISysDictType
+ localSysEmsLog ISysEmsLog
+ localSysLoginLog ISysLoginLog
+ localSysSmsLog ISysSmsLog
)
-func SysDictData() ISysDictData {
- if localSysDictData == nil {
- panic("implement not found for interface ISysDictData, forgot register?")
- }
- return localSysDictData
-}
-
-func RegisterSysDictData(i ISysDictData) {
- localSysDictData = i
-}
-
-func SysDictType() ISysDictType {
- if localSysDictType == nil {
- panic("implement not found for interface ISysDictType, forgot register?")
- }
- return localSysDictType
-}
-
-func RegisterSysDictType(i ISysDictType) {
- localSysDictType = i
-}
-
-func SysLog() ISysLog {
- if localSysLog == nil {
- panic("implement not found for interface ISysLog, forgot register?")
- }
- return localSysLog
-}
-
-func RegisterSysLog(i ISysLog) {
- localSysLog = i
-}
-
-func SysServeLog() ISysServeLog {
- if localSysServeLog == nil {
- panic("implement not found for interface ISysServeLog, forgot register?")
- }
- return localSysServeLog
-}
-
-func RegisterSysServeLog(i ISysServeLog) {
- localSysServeLog = i
-}
-
-func SysProvinces() ISysProvinces {
- if localSysProvinces == nil {
- panic("implement not found for interface ISysProvinces, forgot register?")
- }
- return localSysProvinces
-}
-
-func RegisterSysProvinces(i ISysProvinces) {
- localSysProvinces = i
-}
-
-func SysSmsLog() ISysSmsLog {
- if localSysSmsLog == nil {
- panic("implement not found for interface ISysSmsLog, forgot register?")
- }
- return localSysSmsLog
-}
-
-func RegisterSysSmsLog(i ISysSmsLog) {
- localSysSmsLog = i
-}
-
func SysAddons() ISysAddons {
if localSysAddons == nil {
panic("implement not found for interface ISysAddons, forgot register?")
@@ -298,26 +232,15 @@ func RegisterSysCron(i ISysCron) {
localSysCron = i
}
-func SysCurdDemo() ISysCurdDemo {
- if localSysCurdDemo == nil {
- panic("implement not found for interface ISysCurdDemo, forgot register?")
+func SysCronGroup() ISysCronGroup {
+ if localSysCronGroup == nil {
+ panic("implement not found for interface ISysCronGroup, forgot register?")
}
- return localSysCurdDemo
+ return localSysCronGroup
}
-func RegisterSysCurdDemo(i ISysCurdDemo) {
- localSysCurdDemo = i
-}
-
-func SysEmsLog() ISysEmsLog {
- if localSysEmsLog == nil {
- panic("implement not found for interface ISysEmsLog, forgot register?")
- }
- return localSysEmsLog
-}
-
-func RegisterSysEmsLog(i ISysEmsLog) {
- localSysEmsLog = i
+func RegisterSysCronGroup(i ISysCronGroup) {
+ localSysCronGroup = i
}
func SysGenCodes() ISysGenCodes {
@@ -331,26 +254,15 @@ func RegisterSysGenCodes(i ISysGenCodes) {
localSysGenCodes = i
}
-func SysLoginLog() ISysLoginLog {
- if localSysLoginLog == nil {
- panic("implement not found for interface ISysLoginLog, forgot register?")
+func SysServeLog() ISysServeLog {
+ if localSysServeLog == nil {
+ panic("implement not found for interface ISysServeLog, forgot register?")
}
- return localSysLoginLog
+ return localSysServeLog
}
-func RegisterSysLoginLog(i ISysLoginLog) {
- localSysLoginLog = i
-}
-
-func SysAddonsConfig() ISysAddonsConfig {
- if localSysAddonsConfig == nil {
- panic("implement not found for interface ISysAddonsConfig, forgot register?")
- }
- return localSysAddonsConfig
-}
-
-func RegisterSysAddonsConfig(i ISysAddonsConfig) {
- localSysAddonsConfig = i
+func RegisterSysServeLog(i ISysServeLog) {
+ localSysServeLog = i
}
func SysAttachment() ISysAttachment {
@@ -375,15 +287,37 @@ func RegisterSysBlacklist(i ISysBlacklist) {
localSysBlacklist = i
}
-func SysCronGroup() ISysCronGroup {
- if localSysCronGroup == nil {
- panic("implement not found for interface ISysCronGroup, forgot register?")
+func SysDictData() ISysDictData {
+ if localSysDictData == nil {
+ panic("implement not found for interface ISysDictData, forgot register?")
}
- return localSysCronGroup
+ return localSysDictData
}
-func RegisterSysCronGroup(i ISysCronGroup) {
- localSysCronGroup = i
+func RegisterSysDictData(i ISysDictData) {
+ localSysDictData = i
+}
+
+func SysLog() ISysLog {
+ if localSysLog == nil {
+ panic("implement not found for interface ISysLog, forgot register?")
+ }
+ return localSysLog
+}
+
+func RegisterSysLog(i ISysLog) {
+ localSysLog = i
+}
+
+func SysAddonsConfig() ISysAddonsConfig {
+ if localSysAddonsConfig == nil {
+ panic("implement not found for interface ISysAddonsConfig, forgot register?")
+ }
+ return localSysAddonsConfig
+}
+
+func RegisterSysAddonsConfig(i ISysAddonsConfig) {
+ localSysAddonsConfig = i
}
func SysConfig() ISysConfig {
@@ -396,3 +330,69 @@ func SysConfig() ISysConfig {
func RegisterSysConfig(i ISysConfig) {
localSysConfig = i
}
+
+func SysProvinces() ISysProvinces {
+ if localSysProvinces == nil {
+ panic("implement not found for interface ISysProvinces, forgot register?")
+ }
+ return localSysProvinces
+}
+
+func RegisterSysProvinces(i ISysProvinces) {
+ localSysProvinces = i
+}
+
+func SysCurdDemo() ISysCurdDemo {
+ if localSysCurdDemo == nil {
+ panic("implement not found for interface ISysCurdDemo, forgot register?")
+ }
+ return localSysCurdDemo
+}
+
+func RegisterSysCurdDemo(i ISysCurdDemo) {
+ localSysCurdDemo = i
+}
+
+func SysDictType() ISysDictType {
+ if localSysDictType == nil {
+ panic("implement not found for interface ISysDictType, forgot register?")
+ }
+ return localSysDictType
+}
+
+func RegisterSysDictType(i ISysDictType) {
+ localSysDictType = i
+}
+
+func SysEmsLog() ISysEmsLog {
+ if localSysEmsLog == nil {
+ panic("implement not found for interface ISysEmsLog, forgot register?")
+ }
+ return localSysEmsLog
+}
+
+func RegisterSysEmsLog(i ISysEmsLog) {
+ localSysEmsLog = i
+}
+
+func SysLoginLog() ISysLoginLog {
+ if localSysLoginLog == nil {
+ panic("implement not found for interface ISysLoginLog, forgot register?")
+ }
+ return localSysLoginLog
+}
+
+func RegisterSysLoginLog(i ISysLoginLog) {
+ localSysLoginLog = i
+}
+
+func SysSmsLog() ISysSmsLog {
+ if localSysSmsLog == nil {
+ panic("implement not found for interface ISysSmsLog, forgot register?")
+ }
+ return localSysSmsLog
+}
+
+func RegisterSysSmsLog(i ISysSmsLog) {
+ localSysSmsLog = i
+}
diff --git a/server/main.go b/server/main.go
index be2d396..ba62143 100644
--- a/server/main.go
+++ b/server/main.go
@@ -19,7 +19,7 @@ import (
)
func main() {
- var ctx = gctx.New()
+ var ctx = gctx.GetInitCtx()
global.Init(ctx)
cmd.Main.Run(ctx)
}
diff --git a/server/resource/generate/default/curd/input.go.template b/server/resource/generate/default/curd/input.go.template
index 191a1e3..e5f483f 100644
--- a/server/resource/generate/default/curd/input.go.template
+++ b/server/resource/generate/default/curd/input.go.template
@@ -20,6 +20,16 @@ import (
"hotgo/utility/validate"
)
@{ if eq .options.Step.HasEdit true }
+// @{.varName}UpdateFields 修改@{.tableComment}字段过滤
+type @{.varName}UpdateFields struct {
+@{.updateFieldsColumns}
+}
+
+// @{.varName}InsertFields 新增@{.tableComment}字段过滤
+type @{.varName}InsertFields struct {
+@{.insertFieldsColumns}
+}
+
// @{.varName}EditInp 修改/新增@{.tableComment}
type @{.varName}EditInp struct {
entity.@{.daoName}
@@ -97,6 +107,20 @@ type @{.varName}StatusInp struct {
}
func (in *@{.varName}StatusInp) Filter(ctx context.Context) (err error) {
+ if in.@{.pk.GoName} <= 0 {
+ err = gerror.New("@{.pk.Dc}不能为空")
+ return
+ }
+
+ if in.Status <= 0 {
+ err = gerror.New("状态不能为空")
+ return
+ }
+
+ if !validate.InSliceInt(consts.StatusSlice, in.Status) {
+ err = gerror.New("状态不正确")
+ return
+ }
return
}
diff --git a/server/resource/generate/default/curd/logic.go.template b/server/resource/generate/default/curd/logic.go.template
index 5e4c439..5d7da46 100644
--- a/server/resource/generate/default/curd/logic.go.template
+++ b/server/resource/generate/default/curd/logic.go.template
@@ -16,7 +16,6 @@ import (
"github.com/gogf/gf/v2/os/gctx"
"github.com/gogf/gf/v2/os/gtime"
"github.com/gogf/gf/v2/util/gconv"
- "hotgo/internal/consts"
"hotgo/internal/dao"
"hotgo/internal/library/contexts"
"hotgo/internal/library/hgorm"
@@ -50,12 +49,21 @@ func (s *s@{.servFunName}) List(ctx context.Context, in @{.templateGroup}in.@{.v
@{.listWhere}
@{.listJoin.link}
totalCount, err = mod.Clone().Count()
- if totalCount == 0 || err != nil {
+ if err != nil {
+ err = gerror.Wrap(err, "获取@{.tableComment}数据行失败,请稍后重试!")
+ return
+ }
+
+ if totalCount == 0 {
return
}
@{.listJoin.select}
- err = mod.Fields(@{.listJoin.fields}).Page(in.Page, in.PerPage).@{.listOrder}.Scan(&list)
+
+ if err = mod.Fields(@{.listJoin.fields}).Page(in.Page, in.PerPage).@{.listOrder}.Scan(&list);err != nil {
+ err = gerror.Wrap(err, "获取@{.tableComment}列表失败,请稍后重试!")
+ return
+ }
return
}
@{ if eq .options.Step.HasExport true }
@@ -102,13 +110,17 @@ func (s *s@{.servFunName}) Edit(ctx context.Context, in @{.templateGroup}in.@{.v
@{ if eq .options.Step.HasDel true }
// Delete 删除@{.tableComment}
func (s *s@{.servFunName}) Delete(ctx context.Context, in @{.templateGroup}in.@{.varName}DeleteInp) (err error) {
- _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Delete()
+ 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
+ }
return
}@{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) {
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
}
@@ -123,28 +135,19 @@ func (s *s@{.servFunName}) MaxSort(ctx context.Context, in @{.templateGroup}in.@
@{ 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) {
- err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Scan(&res)
+ 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
+ }
return
}@{end}
@{ if eq .options.Step.HasStatus true }
// Status 更新@{.tableComment}状态
func (s *s@{.servFunName}) Status(ctx context.Context, in @{.templateGroup}in.@{.varName}StatusInp) (err error) {
- if in.@{.pk.GoName} <= 0 {
- err = gerror.New("@{.pk.Dc}不能为空")
+ 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
}
-
- if in.Status <= 0 {
- err = gerror.New("状态不能为空")
- return
- }
-
- if !validate.InSliceInt(consts.StatusSlice, in.Status) {
- err = gerror.New("状态不正确")
- return
- }
-
- _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(@{.statusUpdate}).Update()
return
}
@{end}
@@ -161,7 +164,10 @@ func (s *s@{.servFunName}) Switch(ctx context.Context, in @{.templateGroup}in.@{
return
}
- _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).Where(dao.@{.daoName}.Columns().@{.pk.GoName}, in.@{.pk.GoName}).Data(@{.switchUpdate}).Update()
+ if _, err = s.Model(ctx@{ if eq .options.Step.HasNotFilterAuth true } ,&handler.Option{FilterAuth: false}@{end}).WherePri(in.@{.pk.GoName}).Data(@{.switchUpdate}).Update();err != nil {
+ err = gerror.Wrap(err, "更新@{.tableComment}开关失败,请稍后重试!")
+ return
+ }
return
}
@{end}
\ No newline at end of file
diff --git a/server/utility/simple/simple.go b/server/utility/simple/simple.go
index 7551ad5..8458a93 100644
--- a/server/utility/simple/simple.go
+++ b/server/utility/simple/simple.go
@@ -18,6 +18,24 @@ import (
"hotgo/utility/encrypt"
)
+// FilterMaskDemo 过滤演示环境下的配置隐藏字段
+func FilterMaskDemo(ctx context.Context, src g.Map) g.Map {
+ if src == nil || len(src) == 0 {
+ return nil
+ }
+
+ if !g.Cfg().MustGet(ctx, "hotgo.isDemo", false).Bool() {
+ return src
+ }
+
+ for k, _ := range src {
+ if _, ok := consts.ConfigMaskDemoField[k]; ok {
+ src[k] = consts.DemoTips
+ }
+ }
+ return src
+}
+
// DecryptText 解密文本
func DecryptText(text string) (string, error) {
str, err := gbase64.Decode([]byte(text))
diff --git a/web/src/views/curdDemo/edit.vue b/web/src/views/curdDemo/edit.vue
index 8217dcd..9dbaabd 100644
--- a/web/src/views/curdDemo/edit.vue
+++ b/web/src/views/curdDemo/edit.vue
@@ -174,4 +174,4 @@
);
-
+
\ No newline at end of file
diff --git a/web/src/views/curdDemo/index.vue b/web/src/views/curdDemo/index.vue
index 607bd04..c48891b 100644
--- a/web/src/views/curdDemo/index.vue
+++ b/web/src/views/curdDemo/index.vue
@@ -6,6 +6,7 @@
+
({
});
export const rules = {
+ categoryId: {
+ required: true,
+ trigger: ['blur', 'input'],
+ type: 'number',
+ message: '请输入分类ID',
+ },
+ title: {
+ required: true,
+ trigger: ['blur', 'input'],
+ type: 'string',
+ message: '请输入标题',
+ },
+ description: {
+ required: true,
+ trigger: ['blur', 'input'],
+ type: 'string',
+ message: '请输入描述',
+ },
+ content: {
+ required: true,
+ trigger: ['blur', 'input'],
+ type: 'string',
+ message: '请输入内容',
+ },
+ sort: {
+ required: true,
+ trigger: ['blur', 'input'],
+ type: 'number',
+ message: '请输入排序',
+ },
};
export const schemas = ref([
@@ -171,6 +201,10 @@ export const columns = [
);
},
},
+ {
+ title: '所在城市',
+ key: 'cityId',
+ },
{
title: '显示开关',
key: 'switch',
@@ -217,6 +251,14 @@ export const columns = [
);
},
},
+ {
+ title: '创建者',
+ key: 'createdBy',
+ },
+ {
+ title: '更新者',
+ key: 'updatedBy',
+ },
{
title: '创建时间',
key: 'createdAt',
diff --git a/web/src/views/develop/code/components/BaseInfo.vue b/web/src/views/develop/code/components/BaseInfo.vue
index e6ca57d..bc924ed 100644
--- a/web/src/views/develop/code/components/BaseInfo.vue
+++ b/web/src/views/develop/code/components/BaseInfo.vue
@@ -154,7 +154,7 @@
- 只会强制覆盖需要生成的文件,但不包含SQL文件
+ 强制覆盖所有需要生成的代码文件,但不包含菜单SQL文件