refactor🎨 部分功能重写
This commit is contained in:
1 parent
765775c54d
commit
408dcc5057
28 files changed
+649
-982
No files matched your search
@@ -1,12 +1,6 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
common "go-admin/common/models"
|
||||
@@ -15,10 +9,10 @@ import (
|
||||
// SysConfigSearch 列表或者搜索使用结构体
|
||||
type SysConfigSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config" comment:""`
|
||||
ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config" comment:""`
|
||||
ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config" comment:""`
|
||||
IsFrontend int `json:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config" comment:""`
|
||||
ConfigName string `form:"configName" search:"type:contains;column:config_name;table:sys_config"`
|
||||
ConfigKey string `form:"configKey" search:"type:contains;column:config_key;table:sys_config"`
|
||||
ConfigType string `form:"configType" search:"type:exact;column:config_type;table:sys_config"`
|
||||
IsFrontend int `form:"isFrontend" search:"type:exact;column:is_frontend;table:sys_config"`
|
||||
}
|
||||
|
||||
func (m *SysConfigSearch) GetNeedSearch() interface{} {
|
||||
@@ -27,58 +21,40 @@ func (m *SysConfigSearch) GetNeedSearch() interface{} {
|
||||
|
||||
// SysConfigControl 增、改使用的结构体
|
||||
type SysConfigControl struct {
|
||||
ID int `uri:"Id" comment:"编码"` // 编码
|
||||
Id int `uri:"Id" comment:"编码"` // 编码
|
||||
ConfigName string `json:"configName" comment:""`
|
||||
ConfigKey string `uri:"configKey" json:"configKey" comment:""`
|
||||
ConfigValue string `json:"configValue" comment:""`
|
||||
ConfigType string `json:"configType" comment:""`
|
||||
IsFrontend int `json:"isFrontend"`
|
||||
Remark string `json:"remark" comment:""`
|
||||
}
|
||||
|
||||
// Bind 映射上下文中的结构体数据
|
||||
func (s *SysConfigControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBindBodyWith(s, binding.JSON)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
var jsonStr []byte
|
||||
jsonStr, err = json.Marshal(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
ctx.Set("body", string(jsonStr))
|
||||
return err
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
|
||||
func (s *SysConfigControl) Generate() (*models.SysConfig, error) {
|
||||
return &models.SysConfig{
|
||||
Model: common.Model{Id: s.ID},
|
||||
ConfigName: s.ConfigName,
|
||||
ConfigKey: s.ConfigKey,
|
||||
ConfigValue: s.ConfigValue,
|
||||
ConfigType: s.ConfigType,
|
||||
IsFrontend: s.IsFrontend,
|
||||
Remark: s.Remark,
|
||||
}, nil
|
||||
func (s *SysConfigControl) Generate(model *models.SysConfig) {
|
||||
if s.Id == 0 {
|
||||
model.Model = common.Model{Id: s.Id}
|
||||
}
|
||||
model.ConfigName = s.ConfigName
|
||||
model.ConfigKey = s.ConfigKey
|
||||
model.ConfigValue = s.ConfigValue
|
||||
model.ConfigType = s.ConfigType
|
||||
model.IsFrontend = s.IsFrontend
|
||||
model.Remark = s.Remark
|
||||
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
func (s *SysConfigControl) GetId() interface{} {
|
||||
return s.ID
|
||||
return s.Id
|
||||
}
|
||||
|
||||
// SysConfigById 获取单个或者删除的结构体
|
||||
type SysConfigById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysConfigById) Generate() *SysConfigById {
|
||||
@@ -87,23 +63,9 @@ func (s *SysConfigById) Generate() *SysConfigById {
|
||||
}
|
||||
|
||||
func (s *SysConfigById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysConfigById) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SysConfigById) GenerateM() (*models.SysConfig, error) {
|
||||
return &models.SysConfig{}, nil
|
||||
}
|
||||
@@ -1,11 +1,10 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"go-admin/app/admin/models"
|
||||
common "go-admin/common/models"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
|
||||
"go-admin/common/dto"
|
||||
@@ -39,7 +38,7 @@ func (m *SysDeptSearch) Bind(ctx *gin.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
// SysConfigControl 增、改使用的结构体
|
||||
// SysDeptControl 增、改使用的结构体
|
||||
type SysDeptControl struct {
|
||||
DeptId int `uri:"id" comment:"编码"` // 编码
|
||||
ParentId int `form:"parentId" comment:"上级部门"` //上级部门
|
||||
@@ -50,42 +49,30 @@ type SysDeptControl struct {
|
||||
Phone string `form:"phone" comment:"手机"` //手机
|
||||
Email string `form:"email" comment:"邮箱"` //邮箱
|
||||
Status string `form:"status" comment:"状态"` //状态
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
// Bind 映射上下文中的结构体数据
|
||||
func (s *SysDeptControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBindBodyWith(s, binding.JSON)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
var jsonStr []byte
|
||||
jsonStr, err = json.Marshal(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
ctx.Set("body", string(jsonStr))
|
||||
return err
|
||||
func (s *SysDeptControl) SetCreateBy(id int) {
|
||||
s.CreateBy = id
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysConfigControl 至 system.SysConfig 对应的模型
|
||||
func (s *SysDeptControl) Generate() (*models.SysDept, error) {
|
||||
return &models.SysDept{
|
||||
DeptId: s.DeptId,
|
||||
DeptName: s.DeptName,
|
||||
ParentId: s.ParentId,
|
||||
DeptPath: s.DeptPath,
|
||||
Sort: s.Sort,
|
||||
Leader: s.Leader,
|
||||
Phone: s.Phone,
|
||||
Email: s.Email,
|
||||
Status: s.Status,
|
||||
}, nil
|
||||
func (s *SysDeptControl) SetUpdateBy(id int) {
|
||||
s.UpdateBy = id
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 SysDeptControl 至 SysDept 对应的模型
|
||||
func (s *SysDeptControl) Generate(model *models.SysDept) {
|
||||
if s.DeptId != 0 {
|
||||
model.DeptId = s.DeptId
|
||||
}
|
||||
model.DeptName = s.DeptName
|
||||
model.ParentId = s.ParentId
|
||||
model.DeptPath = s.DeptPath
|
||||
model.Sort = s.Sort
|
||||
model.Leader = s.Leader
|
||||
model.Phone = s.Phone
|
||||
model.Email = s.Email
|
||||
model.Status = s.Status
|
||||
}
|
||||
|
||||
// GetId 获取数据对应的ID
|
||||
@@ -105,22 +92,13 @@ func (s *SysDeptById) Generate() *SysDeptById {
|
||||
}
|
||||
|
||||
func (s *SysDeptById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysDeptById) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SysDeptById) GenerateM() (*models.SysDept, error) {
|
||||
return &models.SysDept{}, nil
|
||||
|
||||
@@ -50,41 +50,22 @@ type SysDictDataControl struct {
|
||||
Status string `json:"status" comment:""`
|
||||
Default string `json:"default" comment:""`
|
||||
Remark string `json:"remark" comment:""`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictDataControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
func (s *SysDictDataControl) Generate(model *models.SysDictData) {
|
||||
|
||||
func (s *SysDictDataControl) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysDictDataControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysDictData{
|
||||
DictCode: s.Id,
|
||||
DictSort: s.DictSort,
|
||||
DictLabel: s.DictLabel,
|
||||
DictValue: s.DictValue,
|
||||
DictType: s.DictType,
|
||||
CssClass: s.CssClass,
|
||||
ListClass: s.ListClass,
|
||||
IsDefault: s.IsDefault,
|
||||
Status: s.Status,
|
||||
Default: s.Default,
|
||||
Remark: s.Remark,
|
||||
}, nil
|
||||
model.DictCode = s.Id
|
||||
model.DictSort = s.DictSort
|
||||
model.DictLabel = s.DictLabel
|
||||
model.DictValue = s.DictValue
|
||||
model.DictType = s.DictType
|
||||
model.CssClass = s.CssClass
|
||||
model.ListClass = s.ListClass
|
||||
model.IsDefault = s.IsDefault
|
||||
model.Status = s.Status
|
||||
model.Default = s.Default
|
||||
model.Remark = s.Remark
|
||||
}
|
||||
|
||||
func (s *SysDictDataControl) GetId() interface{} {
|
||||
@@ -94,6 +75,7 @@ func (s *SysDictDataControl) GetId() interface{} {
|
||||
type SysDictDataById struct {
|
||||
Id int `uri:"dictCode"`
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictDataById) Bind(ctx *gin.Context) error {
|
||||
@@ -111,6 +93,7 @@ func (s *SysDictDataById) Bind(ctx *gin.Context) error {
|
||||
|
||||
func (s *SysDictDataById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
|
||||
@@ -36,45 +36,23 @@ func (m *SysDictTypeSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysDictTypeControl struct {
|
||||
Id int `uri:"id" comment:""` //
|
||||
|
||||
DictName string `json:"dictName" comment:""`
|
||||
|
||||
DictType string `json:"dictType" comment:""`
|
||||
|
||||
Status string `json:"status" comment:""`
|
||||
|
||||
Remark string `json:"remark" comment:""`
|
||||
Id int `uri:"id"`
|
||||
DictName string `json:"dictName"`
|
||||
DictType string `json:"dictType"`
|
||||
Status string `json:"status"`
|
||||
Remark string `json:"remark"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictTypeControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
func (s *SysDictTypeControl) Generate(model *models.SysDictType) {
|
||||
if s.Id != 0 {
|
||||
model.ID = s.Id
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
model.DictName = s.DictName
|
||||
model.DictType = s.DictType
|
||||
model.Status = s.Status
|
||||
model.Remark = s.Remark
|
||||
|
||||
func (s *SysDictTypeControl) Generate() dto.Control {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysDictTypeControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysDictType{
|
||||
|
||||
ID: s.Id,
|
||||
DictName: s.DictName,
|
||||
DictType: s.DictType,
|
||||
Status: s.Status,
|
||||
Remark: s.Remark,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (s *SysDictTypeControl) GetId() interface{} {
|
||||
@@ -83,6 +61,7 @@ func (s *SysDictTypeControl) GetId() interface{} {
|
||||
|
||||
type SysDictTypeById struct {
|
||||
dto.ObjectById
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) Generate() dto.Control {
|
||||
@@ -90,6 +69,14 @@ func (s *SysDictTypeById) Generate() dto.Control {
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysDictTypeById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysDictType{}, nil
|
||||
}
|
||||
@@ -19,6 +19,10 @@ type SysLoginLogSearch struct {
|
||||
LoginLocation string `form:"loginLocation" search:"type:exact;column:login_location;table:sys_login_log" comment:"归属地"`
|
||||
}
|
||||
|
||||
type SysLoginLogOrder struct {
|
||||
HandleOrder string `search:"type:order;column:created_at;table:sys_login_log" form:"created_at_order"`
|
||||
}
|
||||
|
||||
func (m *SysLoginLogSearch) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package dto
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/gin-gonic/gin/binding"
|
||||
"github.com/go-admin-team/go-admin-core/sdk/api"
|
||||
"go-admin/app/admin/models"
|
||||
common "go-admin/common/models"
|
||||
|
||||
@@ -28,15 +24,6 @@ func (m *SysMenuSearch) GetNeedSearch() interface{} {
|
||||
return *m
|
||||
}
|
||||
|
||||
// Bind 映射上下文中的结构体数据
|
||||
func (m *SysMenuSearch) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
// SysMenuControl 增、改使用的结构体
|
||||
type SysMenuControl struct {
|
||||
@@ -69,27 +56,6 @@ func (s *SysMenuControl) SetUpdateBy(id int) {
|
||||
s.UpdateBy = id
|
||||
}
|
||||
|
||||
// Bind 映射上下文中的结构体数据
|
||||
func (s *SysMenuControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBindBodyWith(s, binding.JSON)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
var jsonStr []byte
|
||||
jsonStr, err = json.Marshal(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
ctx.Set("body", string(jsonStr))
|
||||
return err
|
||||
}
|
||||
|
||||
// Generate 结构体数据转化 从 Control 至 model 对应的模型
|
||||
func (s *SysMenuControl) Generate(model *models.SysMenu) {
|
||||
if s.MenuId != 0 {
|
||||
@@ -124,35 +90,27 @@ func (s *SysMenuControl) GetId() interface{} {
|
||||
return s.MenuId
|
||||
}
|
||||
|
||||
// SysConfigById 获取单个或者删除的结构体
|
||||
// SysMenuById 获取单个或者删除的结构体
|
||||
type SysMenuById struct {
|
||||
Id int `uri:"id"`
|
||||
Ids []int `json:"ids"`
|
||||
common.ControlBy
|
||||
}
|
||||
|
||||
|
||||
func (s *SysMenuById) Generate() *SysMenuById {
|
||||
cp := *s
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysMenuById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysMenuById) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SysMenuById) GenerateM() (*models.SysMenu, error) {
|
||||
return &models.SysMenu{}, nil
|
||||
}
|
||||
|
||||
@@ -96,6 +96,10 @@ func (s *SysPostById) Generate() *SysPostById {
|
||||
}
|
||||
|
||||
func (s *SysPostById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
|
||||
@@ -119,6 +119,10 @@ func (s *SysRoleById) Generate() *SysRoleById {
|
||||
}
|
||||
|
||||
func (s *SysRoleById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,10 @@ func (s *SysSettingById) Generate() *SysSettingById {
|
||||
}
|
||||
|
||||
func (s *SysSettingById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
@@ -85,4 +89,4 @@ func (s *SysSettingById) Bind(ctx *gin.Context) error {
|
||||
|
||||
func (s *SysSettingById) GenerateM() (*models.SysSetting, error) {
|
||||
return &models.SysSetting{}, nil
|
||||
}
|
||||
}
|
||||
@@ -59,11 +59,7 @@ type SysUserControl struct {
|
||||
|
||||
func (s *SysUserControl) Bind(ctx *gin.Context) error {
|
||||
log := api.GetRequestLogger(ctx)
|
||||
//err := ctx.ShouldBindUri(s)
|
||||
//if err != nil {
|
||||
// log.Debugf("ShouldBindUri error: %s", err.Error())
|
||||
// return err
|
||||
//}
|
||||
|
||||
err := ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("ShouldBind error: %s", err.Error())
|
||||
@@ -107,6 +103,14 @@ func (s *SysUserById) Generate() dto.Control {
|
||||
return &cp
|
||||
}
|
||||
|
||||
func (s *SysUserById) GetId() interface{} {
|
||||
if len(s.Ids) > 0 {
|
||||
s.Ids = append(s.Ids, s.Id)
|
||||
return s.Ids
|
||||
}
|
||||
return s.Id
|
||||
}
|
||||
|
||||
func (s *SysUserById) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysUser{}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user