Skip to content

Commit

Permalink
配置信息表添加字段
Browse files Browse the repository at this point in the history
  • Loading branch information
singledemon committed Sep 11, 2023
1 parent 1d20bf9 commit df843fc
Show file tree
Hide file tree
Showing 13 changed files with 223 additions and 214 deletions.
37 changes: 20 additions & 17 deletions api/v1/common/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ import (
)

type ConfigSearchReq struct {
g.Meta `path:"/config/list" tags:"系统参数管理" method:"get" summary:"系统参数列表"`
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
g.Meta `path:"/config/list" tags:"系统参数管理" method:"get" summary:"系统参数列表"`
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
DictClassCode string `p:"dictClassCode"` //字典类型编码
*PaginationReq
}

Expand All @@ -20,12 +21,13 @@ type ConfigSearchRes struct {
}

type ConfigAddReq struct {
g.Meta `path:"/config/add" tags:"系统参数管理" method:"post" summary:"添加系统参数"`
ConfigName string `p:"configName" v:"required#参数名称不能为空"`
ConfigKey string `p:"configKey" v:"required#参数键名不能为空"`
ConfigValue string `p:"configValue" v:"required#参数键值不能为空"`
ConfigType int `p:"configType" v:"required|in:0,1#系统内置不能为空|系统内置类型只能为0或1"`
Remark string `p:"remark"`
g.Meta `path:"/config/add" tags:"系统参数管理" method:"post" summary:"添加系统参数"`
ConfigName string `p:"configName" v:"required#参数名称不能为空"`
ConfigKey string `p:"configKey" v:"required#参数键名不能为空"`
ConfigValue string `p:"configValue" v:"required#参数键值不能为空"`
ConfigType int `p:"configType" v:"required|in:0,1#系统内置不能为空|系统内置类型只能为0或1"`
DictClassCode string `p:"dictClassCode" v:"required#参数键值不能为空"` //字典类型编码
Remark string `p:"remark"`
}

type ConfigAddRes struct {
Expand All @@ -42,13 +44,14 @@ type ConfigGetRes struct {
}

type ConfigEditReq struct {
g.Meta `path:"/config/edit" tags:"系统参数管理" method:"put" summary:"修改系统参数"`
ConfigId int `p:"configId" v:"required|min:1#主键ID不能为空|主键ID参数错误"`
ConfigName string `p:"configName" v:"required#参数名称不能为空"`
ConfigKey string `p:"configKey" v:"required#参数键名不能为空"`
ConfigValue string `p:"configValue" v:"required#参数键值不能为空"`
ConfigType int `p:"configType" v:"required|in:0,1#系统内置不能为空|系统内置类型只能为0或1"`
Remark string `p:"remark"`
g.Meta `path:"/config/edit" tags:"系统参数管理" method:"put" summary:"修改系统参数"`
ConfigId int `p:"configId" v:"required|min:1#主键ID不能为空|主键ID参数错误"`
ConfigName string `p:"configName" v:"required#参数名称不能为空"`
ConfigKey string `p:"configKey" v:"required#参数键名不能为空"`
ConfigValue string `p:"configValue" v:"required#参数键值不能为空"`
ConfigType int `p:"configType" v:"required|in:0,1#系统内置不能为空|系统内置类型只能为0或1"`
DictClassCode string `p:"dictClassCode" v:"required#参数键值不能为空"` //字典类型编码
Remark string `p:"remark"`
}

type ConfigEditRes struct {
Expand Down
36 changes: 18 additions & 18 deletions api/v1/common/dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
)

type DictTypeSearchReq struct {
g.Meta `path:"/dict/type/list" tags:"字典管理" method:"get" summary:"字典类型列表"`
DictName string `p:"dictName"` //字典名称
DictType string `p:"dictType"` //字典类型
Status string `p:"status"` //字典状态
DictClass string `p:"dictClass"` //字典分类
g.Meta `path:"/dict/type/list" tags:"字典管理" method:"get" summary:"字典类型列表"`
DictName string `p:"dictName"` //字典名称
DictType string `p:"dictType"` //字典类型
Status string `p:"status"` //字典状态
ModuleClassify string `p:"moduleClassify"` //字典模块分类
*PaginationReq
}

Expand All @@ -21,12 +21,12 @@ type DictTypeSearchRes struct {
}

type DictTypeAddReq struct {
g.Meta `path:"/dict/type/add" tags:"字典管理" method:"post" summary:"添加字典类型"`
DictName string `p:"dictName" v:"required#字典名称不能为空"`
DictType string `p:"dictType" v:"required#字典类型不能为空"`
Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"`
DictClass string `p:"dictClass"` //字典分类
Remark string `p:"remark"`
g.Meta `path:"/dict/type/add" tags:"字典管理" method:"post" summary:"添加字典类型"`
DictName string `p:"dictName" v:"required#字典名称不能为空"`
DictType string `p:"dictType" v:"required#字典类型不能为空"`
Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"`
ModuleClassify string `p:"moduleClassify"` //字典分类
Remark string `p:"remark"`
}

type DictTypeAddRes struct {
Expand All @@ -43,13 +43,13 @@ type DictTypeGetRes struct {
}

type DictTypeEditReq struct {
g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"put" summary:"修改字典类型"`
DictId int `p:"dictId" v:"required|min:1#主键ID不能为空|主键ID必须为大于0的值"`
DictName string `p:"dictName" v:"required#字典名称不能为空"`
DictType string `p:"dictType" v:"required#字典类型不能为空"`
Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"`
DictClass string `p:"dictClass"` //字典分类
Remark string `p:"remark"`
g.Meta `path:"/dict/type/edit" tags:"字典管理" method:"put" summary:"修改字典类型"`
DictId int `p:"dictId" v:"required|min:1#主键ID不能为空|主键ID必须为大于0的值"`
DictName string `p:"dictName" v:"required#字典名称不能为空"`
DictType string `p:"dictType" v:"required#字典类型不能为空"`
Status uint `p:"status" v:"required|in:0,1#状态不能为空|状态只能为0或1"`
ModuleClassify string `p:"moduleClassify"` //字典分类
Remark string `p:"remark"`
}

type DictTypeEditRes struct {
Expand Down
60 changes: 31 additions & 29 deletions internal/dao/internal/sys_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions internal/dao/internal/sys_dict_type.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 17 additions & 12 deletions internal/logic/common/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ func (s *sConfigData) List(ctx context.Context, input *model.ConfigDoInput) (tot
if input.ConfigKey != "" {
m = m.Where("config_key like ?", "%"+input.ConfigKey+"%")
}
if input.DictClassCode != "" {
m = m.Where("dict_class_code = ", input.DictClassCode)
}
if len(input.DateRange) > 0 {
m = m.Where("created_at >= ? AND created_at<=?", input.DateRange[0], input.DateRange[1])
}
Expand All @@ -62,12 +65,13 @@ func (s *sConfigData) Add(ctx context.Context, input *model.AddConfigInput, user
err = s.CheckConfigKeyUnique(ctx, input.ConfigKey)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).Insert(do.SysConfig{
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
CreateBy: userId,
Remark: input.Remark,
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
DictClassCode: input.DictClassCode,
CreateBy: userId,
Remark: input.Remark,
})
liberr.ErrIsNil(ctx, err, "添加系统参数失败")
//清除缓存
Expand Down Expand Up @@ -108,12 +112,13 @@ func (s *sConfigData) Edit(ctx context.Context, input *model.EditConfigInput, us
err = s.CheckConfigKeyUnique(ctx, input.ConfigKey, input.ConfigId)
liberr.ErrIsNil(ctx, err)
_, err = dao.SysConfig.Ctx(ctx).WherePri(input.ConfigId).Update(do.SysConfig{
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
UpdateBy: userId,
Remark: input.Remark,
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
DictClassCode: input.DictClassCode,
UpdateBy: userId,
Remark: input.Remark,
})
liberr.ErrIsNil(ctx, err, "修改系统参数失败")
//清除缓存
Expand Down
30 changes: 15 additions & 15 deletions internal/logic/common/dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ func (s *sDictType) List(ctx context.Context, input *model.DictTypeDoInput) (tot
if input.Status != "" {
m = m.Where(dao.SysDictType.Columns().Status+" = ", gconv.Int(input.Status))
}
if input.DictClass != "" {
m = m.Where(dao.SysDictType.Columns().DictClass+" = ", input.DictClass)
if input.ModuleClassify != "" {
m = m.Where(dao.SysDictType.Columns().ModuleClassify+" = ", input.ModuleClassify)
}
total, err = m.Count()
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
Expand All @@ -66,13 +66,13 @@ func (s *sDictType) Add(ctx context.Context, input *model.AddDictTypeInput, user
liberr.ErrIsNil(ctx, err)
parentId := 0
_, err = dao.SysDictType.Ctx(ctx).Insert(do.SysDictType{
DictName: input.DictName,
DictType: input.DictType,
Status: input.Status,
CreateBy: userId,
Remark: input.Remark,
DictClass: input.DictClass,
ParentId: parentId,
DictName: input.DictName,
DictType: input.DictType,
Status: input.Status,
CreateBy: userId,
Remark: input.Remark,
ModuleClassify: input.ModuleClassify,
ParentId: parentId,
})
liberr.ErrIsNil(ctx, err, "添加字典类型失败")
//清除缓存
Expand All @@ -93,12 +93,12 @@ func (s *sDictType) Edit(ctx context.Context, input *model.EditDictTypeInput, us
liberr.ValueIsNil(dictType, "字典类型不存在")
//修改字典类型
_, e = dao.SysDictType.Ctx(ctx).TX(tx).WherePri(input.DictId).Update(do.SysDictType{
DictName: input.DictName,
DictType: input.DictType,
Status: input.Status,
UpdateBy: userId,
Remark: input.Remark,
DictClass: input.DictClass,
DictName: input.DictName,
DictType: input.DictType,
Status: input.Status,
UpdateBy: userId,
Remark: input.Remark,
ModuleClassify: input.ModuleClassify,
})
liberr.ErrIsNil(ctx, e, "修改字典类型失败")
//修改字典数据
Expand Down
73 changes: 39 additions & 34 deletions internal/model/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,56 @@ package model
import "github.com/gogf/gf/v2/os/gtime"

type ConfigDoInput struct {
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
DictClassCode string `p:"dictClassCode"` //字典类型编码
*PaginationInput
}

type SysConfigRes struct {
ConfigId uint `json:"configId" description:"参数主键"`
ConfigName string `json:"configName" description:"参数名称"`
ConfigKey string `json:"configKey" description:"参数键名"`
ConfigValue string `json:"configValue" description:"参数键值"`
ConfigType int `json:"configType" description:"系统内置(Y是 N否)"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
ConfigId uint `json:"configId" description:"参数主键"`
ConfigName string `json:"configName" description:"参数名称"`
ConfigKey string `json:"configKey" description:"参数键名"`
ConfigValue string `json:"configValue" description:"参数键值"`
ConfigType int `json:"configType" description:"系统内置(Y是 N否)"`
DictClassCode string `json:"dictClassCode" description:"字典类型编码"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
}

type SysConfigOut struct {
ConfigId uint `json:"configId" description:"参数主键"`
ConfigName string `json:"configName" description:"参数名称"`
ConfigKey string `json:"configKey" description:"参数键名"`
ConfigValue string `json:"configValue" description:"参数键值"`
ConfigType int `json:"configType" description:"系统内置(Y是 N否)"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
ConfigId uint `json:"configId" description:"参数主键"`
ConfigName string `json:"configName" description:"参数名称"`
ConfigKey string `json:"configKey" description:"参数键名"`
ConfigValue string `json:"configValue" description:"参数键值"`
ConfigType int `json:"configType" description:"系统内置(Y是 N否)"`
DictClassCode string `json:"dictClassCode" description:"字典类型编码"`
CreateBy uint `json:"createBy" description:"创建者"`
UpdateBy uint `json:"updateBy" description:"更新者"`
Remark string `json:"remark" description:"备注"`
CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"`
UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"`
}

type AddConfigInput struct {
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
DictClassCode string `p:"dictClassCode"`
}

type EditConfigInput struct {
ConfigId int `p:"configId"`
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
ConfigId int `p:"configId"`
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
DictClassCode string `p:"dictClassCode"`
}
Loading

0 comments on commit df843fc

Please sign in to comment.