Skip to content

Commit

Permalink
Merge pull request #20 from singledemon/main
Browse files Browse the repository at this point in the history
参数配置代码添加
  • Loading branch information
xinjiayu authored Sep 24, 2023
2 parents 43e95a4 + ebaa007 commit 251c825
Show file tree
Hide file tree
Showing 8 changed files with 150 additions and 152 deletions.
40 changes: 20 additions & 20 deletions api/v1/common/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +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"` //状态
DictClassCode string `p:"dictClassCode"` //字典类型编码
g.Meta `path:"/config/list" tags:"系统参数管理" method:"get" summary:"系统参数列表"`
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
ModuleClassify string `p:"moduleClassify"` //字典分类编码
*PaginationReq
}

Expand All @@ -21,13 +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"`
DictClassCode string `p:"dictClassCode" v:"required#参数键值不能为空"` //字典类型编码
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"`
ModuleClassify string `p:"moduleClassify" v:"required#字典分类不能为空"`
Remark string `p:"remark"`
}

type ConfigAddRes struct {
Expand All @@ -44,14 +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"`
DictClassCode string `p:"dictClassCode" v:"required#参数键值不能为空"` //字典类型编码
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"`
ModuleClassify string `p:"moduleClassify" v:"required#字典分类不能为空"`
Remark string `p:"remark"`
}

type ConfigEditRes struct {
Expand Down
4 changes: 2 additions & 2 deletions api/v1/common/dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type DictTypeAddReq struct {
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"` //字典分类
ModuleClassify string `p:"moduleClassify"`
Remark string `p:"remark"`
}

Expand All @@ -48,7 +48,7 @@ type DictTypeEditReq struct {
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"` //字典分类
ModuleClassify string `p:"moduleClassify"`
Remark string `p:"remark"`
}

Expand Down
60 changes: 30 additions & 30 deletions internal/dao/internal/sys_config.go

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

44 changes: 22 additions & 22 deletions internal/logic/common/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ func (s *sConfigData) List(ctx context.Context, input *model.ConfigDoInput) (tot
m := dao.SysConfig.Ctx(ctx)
if input != nil {
if input.ConfigName != "" {
m = m.Where("config_name like ?", "%"+input.ConfigName+"%")
m = m.WhereLike(dao.SysConfig.Columns().ConfigName, "%"+input.ConfigName+"%")
}
if input.ConfigType != "" {
m = m.Where("config_type = ", gconv.Int(input.ConfigType))
m = m.Where(dao.SysConfig.Columns().ConfigType, gconv.Int(input.ConfigType))
}
if input.ConfigKey != "" {
m = m.Where("config_key like ?", "%"+input.ConfigKey+"%")
m = m.WhereLike(dao.SysConfig.Columns().ConfigKey, "%"+input.ConfigKey+"%")
}
if input.DictClassCode != "" {
m = m.Where("dict_class_code = ", input.DictClassCode)
if input.ModuleClassify != "" {
m = m.Where(dao.SysConfig.Columns().ModuleClassify, input.ModuleClassify)
}
if len(input.DateRange) > 0 {
m = m.Where("created_at >= ? AND created_at<=?", input.DateRange[0], input.DateRange[1])
m = m.WhereBetween(dao.SysConfig.Columns().CreatedAt, input.DateRange[0], input.DateRange[1])
}
}
total, err = m.Count()
Expand All @@ -65,13 +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,
DictClassCode: input.DictClassCode,
CreateBy: userId,
Remark: input.Remark,
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
ModuleClassify: input.ModuleClassify,
CreateBy: userId,
Remark: input.Remark,
})
liberr.ErrIsNil(ctx, err, "添加系统参数失败")
//清除缓存
Expand All @@ -84,9 +84,9 @@ func (s *sConfigData) Add(ctx context.Context, input *model.AddConfigInput, user
func (s *sConfigData) CheckConfigKeyUnique(ctx context.Context, configKey string, configId ...int) (err error) {
err = g.Try(ctx, func(ctx context.Context) {
data := (*entity.SysConfig)(nil)
m := dao.SysConfig.Ctx(ctx).Fields(dao.SysConfig.Columns().ConfigId).Where(dao.SysConfig.Columns().ConfigKey, configKey)
m := dao.SysConfig.Ctx(ctx).Fields(dao.SysConfig.Columns().ConfigId).Where(dao.SysConfig.Columns().ConfigKey, configKey).Unscoped()
if len(configId) > 0 {
m = m.Where(dao.SysConfig.Columns().ConfigId+" != ?", configId[0])
m = m.WhereNot(dao.SysConfig.Columns().ConfigId, configId[0])
}
err = m.Scan(&data)
liberr.ErrIsNil(ctx, err, "校验失败")
Expand All @@ -112,13 +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,
DictClassCode: input.DictClassCode,
UpdateBy: userId,
Remark: input.Remark,
ConfigName: input.ConfigName,
ConfigKey: input.ConfigKey,
ConfigValue: input.ConfigValue,
ConfigType: input.ConfigType,
ModuleClassify: input.ModuleClassify,
UpdateBy: userId,
Remark: input.Remark,
})
liberr.ErrIsNil(ctx, err, "修改系统参数失败")
//清除缓存
Expand Down
14 changes: 6 additions & 8 deletions internal/logic/common/dict_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@ func init() {
func (s *sDictType) List(ctx context.Context, input *model.DictTypeDoInput) (total int, out []*model.SysDictTypeInfoOut, err error) {
err = g.Try(ctx, func(ctx context.Context) {
m := dao.SysDictType.Ctx(ctx)
if input.DictName != "" {
m = m.Where(dao.SysDictType.Columns().DictName+" like ?", "%"+input.DictName+"%")
}
if input.DictType != "" {
m = m.Where(dao.SysDictType.Columns().DictType+" like ?", "%"+input.DictType+"%")
if input.ModuleClassify != "" {
m = m.Where(dao.SysDictType.Columns().ModuleClassify, input.ModuleClassify)
}
if input.Status != "" {
m = m.Where(dao.SysDictType.Columns().Status+" = ", gconv.Int(input.Status))
m = m.Where(dao.SysDictType.Columns().Status, gconv.Int(input.Status))
}
if input.ModuleClassify != "" {
m = m.Where(dao.SysDictType.Columns().ModuleClassify+" = ", input.ModuleClassify)
if input.DictName != "" {
m = m.WhereLike(dao.SysDictType.Columns().DictName, "%"+input.DictName+"%")
m = m.WhereOrLike(dao.SysDictType.Columns().DictType, "%"+input.DictName+"%")
}
total, err = m.Count()
liberr.ErrIsNil(ctx, err, "获取字典类型失败")
Expand Down
78 changes: 39 additions & 39 deletions internal/model/config_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +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"` //状态
DictClassCode string `p:"dictClassCode"` //字典类型编码
ConfigName string `p:"configName"` //参数名称
ConfigKey string `p:"configKey"` //参数键名
ConfigType string `p:"configType"` //状态
ModuleClassify string `p:"moduleClassify"` //字典分类编码
*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否)"`
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:"修改时间"`
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否)"`
ModuleClassify string `json:"moduleClassify" 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否)"`
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:"修改时间"`
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否)"`
ModuleClassify string `json:"moduleClassify" 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"`
DictClassCode string `p:"dictClassCode"`
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
ModuleClassify string `p:"moduleClassify"`
}

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"`
DictClassCode string `p:"dictClassCode"`
ConfigId int `p:"configId"`
ConfigName string `p:"configName"`
ConfigKey string `p:"configKey"`
ConfigValue string `p:"configValue"`
ConfigType int `p:"configType"`
Remark string `p:"remark"`
ModuleClassify string `p:"moduleClassify"`
}
32 changes: 16 additions & 16 deletions internal/model/do/sys_config.go

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

Loading

0 comments on commit 251c825

Please sign in to comment.