diff --git a/api/v1/common/config_data.go b/api/v1/common/config_data.go index 0c33621..905149c 100644 --- a/api/v1/common/config_data.go +++ b/api/v1/common/config_data.go @@ -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 } @@ -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 { @@ -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 { diff --git a/api/v1/common/dict_type.go b/api/v1/common/dict_type.go index e2d08b6..334b456 100644 --- a/api/v1/common/dict_type.go +++ b/api/v1/common/dict_type.go @@ -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"` } @@ -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"` } diff --git a/internal/dao/internal/sys_config.go b/internal/dao/internal/sys_config.go index f54312e..197a9b0 100644 --- a/internal/dao/internal/sys_config.go +++ b/internal/dao/internal/sys_config.go @@ -20,40 +20,40 @@ type SysConfigDao struct { // SysConfigColumns defines and stores column names for table sys_config. type SysConfigColumns struct { - ConfigId string // 参数主键 - ConfigName string // 参数名称 - ConfigKey string // 参数键名 - ConfigValue string // 参数键值 - ConfigType string // 系统内置(1是 2否) - DictClassCode string // 所属字典类型数据code - Remark string // 备注 - Status string // 状态 0 停用 1启用 - IsDeleted string // 是否删除 0未删除 1已删除 - CreateBy string // 创建者 - CreatedAt string // 创建时间 - UpdateBy string // 更新者 - UpdatedAt string // 修改时间 - DeletedBy string // 删除人 - DeletedAt string // 删除时间 + ConfigId string // 参数主键 + ConfigName string // 参数名称 + ConfigKey string // 参数键名 + ConfigValue string // 参数键值 + ConfigType string // 系统内置(1是 2否) + ModuleClassify string // 字典分类编码 + Remark string // 备注 + Status string // 状态 0 停用 1启用 + IsDeleted string // 是否删除 0未删除 1已删除 + CreateBy string // 创建者 + CreatedAt string // 创建时间 + UpdateBy string // 更新者 + UpdatedAt string // 修改时间 + DeletedBy string // 删除人 + DeletedAt string // 删除时间 } // sysConfigColumns holds the columns for table sys_config. var sysConfigColumns = SysConfigColumns{ - ConfigId: "config_id", - ConfigName: "config_name", - ConfigKey: "config_key", - ConfigValue: "config_value", - ConfigType: "config_type", - DictClassCode: "dict_class_code", - Remark: "remark", - Status: "status", - IsDeleted: "is_deleted", - CreateBy: "create_by", - CreatedAt: "created_at", - UpdateBy: "update_by", - UpdatedAt: "updated_at", - DeletedBy: "deleted_by", - DeletedAt: "deleted_at", + ConfigId: "config_id", + ConfigName: "config_name", + ConfigKey: "config_key", + ConfigValue: "config_value", + ConfigType: "config_type", + ModuleClassify: "module_classify", + Remark: "remark", + Status: "status", + IsDeleted: "is_deleted", + CreateBy: "create_by", + CreatedAt: "created_at", + UpdateBy: "update_by", + UpdatedAt: "updated_at", + DeletedBy: "deleted_by", + DeletedAt: "deleted_at", } // NewSysConfigDao creates and returns a new DAO object for table data access. diff --git a/internal/logic/common/config_data.go b/internal/logic/common/config_data.go index e9448a9..d7860bd 100644 --- a/internal/logic/common/config_data.go +++ b/internal/logic/common/config_data.go @@ -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() @@ -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, "添加系统参数失败") //清除缓存 @@ -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, "校验失败") @@ -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, "修改系统参数失败") //清除缓存 diff --git a/internal/logic/common/dict_type.go b/internal/logic/common/dict_type.go index ab83b40..5b18de0 100644 --- a/internal/logic/common/dict_type.go +++ b/internal/logic/common/dict_type.go @@ -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, "获取字典类型失败") diff --git a/internal/model/config_data.go b/internal/model/config_data.go index b00471f..3b4ab3b 100644 --- a/internal/model/config_data.go +++ b/internal/model/config_data.go @@ -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"` } diff --git a/internal/model/do/sys_config.go b/internal/model/do/sys_config.go index 57b28f2..daedb29 100644 --- a/internal/model/do/sys_config.go +++ b/internal/model/do/sys_config.go @@ -11,20 +11,20 @@ import ( // SysConfig is the golang structure of table sys_config for DAO operations like Where/Data. type SysConfig struct { - g.Meta `orm:"table:sys_config, do:true"` - ConfigId interface{} // 参数主键 - ConfigName interface{} // 参数名称 - ConfigKey interface{} // 参数键名 - ConfigValue interface{} // 参数键值 - ConfigType interface{} // 系统内置(1是 2否) - DictClassCode interface{} // 所属字典类型数据code - Remark interface{} // 备注 - Status interface{} // 状态 0 停用 1启用 - IsDeleted interface{} // 是否删除 0未删除 1已删除 - CreateBy interface{} // 创建者 - CreatedAt *gtime.Time // 创建时间 - UpdateBy interface{} // 更新者 - UpdatedAt *gtime.Time // 修改时间 - DeletedBy interface{} // 删除人 - DeletedAt *gtime.Time // 删除时间 + g.Meta `orm:"table:sys_config, do:true"` + ConfigId interface{} // 参数主键 + ConfigName interface{} // 参数名称 + ConfigKey interface{} // 参数键名 + ConfigValue interface{} // 参数键值 + ConfigType interface{} // 系统内置(1是 2否) + ModuleClassify interface{} // 字典分类编码 + Remark interface{} // 备注 + Status interface{} // 状态 0 停用 1启用 + IsDeleted interface{} // 是否删除 0未删除 1已删除 + CreateBy interface{} // 创建者 + CreatedAt *gtime.Time // 创建时间 + UpdateBy interface{} // 更新者 + UpdatedAt *gtime.Time // 修改时间 + DeletedBy interface{} // 删除人 + DeletedAt *gtime.Time // 删除时间 } diff --git a/internal/model/entity/sys_config.go b/internal/model/entity/sys_config.go index b061336..ea141f1 100644 --- a/internal/model/entity/sys_config.go +++ b/internal/model/entity/sys_config.go @@ -10,19 +10,19 @@ import ( // SysConfig is the golang structure for table sys_config. type SysConfig 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:"系统内置(1是 2否)"` - DictClassCode string `json:"dictClassCode" description:"所属字典类型数据code"` - Remark string `json:"remark" description:"备注"` - Status int `json:"status" description:"状态 0 停用 1启用"` - IsDeleted int `json:"isDeleted" description:"是否删除 0未删除 1已删除"` - CreateBy uint `json:"createBy" description:"创建者"` - CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` - UpdateBy uint `json:"updateBy" description:"更新者"` - UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` - DeletedBy int `json:"deletedBy" description:"删除人"` - DeletedAt *gtime.Time `json:"deletedAt" 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:"系统内置(1是 2否)"` + ModuleClassify string `json:"moduleClassify" description:"字典分类编码"` + Remark string `json:"remark" description:"备注"` + Status int `json:"status" description:"状态 0 停用 1启用"` + IsDeleted int `json:"isDeleted" description:"是否删除 0未删除 1已删除"` + CreateBy uint `json:"createBy" description:"创建者"` + CreatedAt *gtime.Time `json:"createdAt" description:"创建时间"` + UpdateBy uint `json:"updateBy" description:"更新者"` + UpdatedAt *gtime.Time `json:"updatedAt" description:"修改时间"` + DeletedBy int `json:"deletedBy" description:"删除人"` + DeletedAt *gtime.Time `json:"deletedAt" description:"删除时间"` }