mirror of
https://github.com/go-admin-team/go-admin.git
synced 2026-09-21 02:04:09 +00:00
refactor🎨 : uint 调整为 int
This commit is contained in:
@@ -2,8 +2,6 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
@@ -12,12 +10,10 @@ import (
|
||||
)
|
||||
|
||||
type SysCategorySearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
|
||||
dto.Pagination `search:"-"`
|
||||
Name string `form:"name" search:"type:exact;column:name;table:sys_category" comment:"名称"`
|
||||
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
|
||||
|
||||
|
||||
Status string `form:"status" search:"type:exact;column:status;table:sys_category" comment:"状态"`
|
||||
}
|
||||
|
||||
func (m *SysCategorySearch) GetNeedSearch() interface{} {
|
||||
@@ -25,12 +21,12 @@ func (m *SysCategorySearch) GetNeedSearch() interface{} {
|
||||
}
|
||||
|
||||
func (m *SysCategorySearch) Bind(ctx *gin.Context) error {
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBind(m)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %s", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *SysCategorySearch) Generate() dto.Index {
|
||||
@@ -39,37 +35,31 @@ func (m *SysCategorySearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysCategoryControl struct {
|
||||
|
||||
ID uint `uri:"ID" comment:"标识"` // 标识
|
||||
ID int `uri:"ID" comment:"标识"` // 标识
|
||||
|
||||
Name string `json:"name" comment:"名称"`
|
||||
|
||||
Name string `json:"name" comment:"名称"`
|
||||
|
||||
Img string `json:"img" comment:"图标"`
|
||||
|
||||
Img string `json:"img" comment:"图标"`
|
||||
|
||||
Sort string `json:"sort" comment:"排序"`
|
||||
|
||||
Sort string `json:"sort" comment:"排序"`
|
||||
|
||||
Status string `json:"status" comment:"状态"`
|
||||
|
||||
Status string `json:"status" comment:"状态"`
|
||||
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
|
||||
Remark string `json:"remark" comment:"备注"`
|
||||
}
|
||||
|
||||
func (s *SysCategoryControl) Bind(ctx *gin.Context) error {
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
msgID := tools.GenerateMsgIDFromContext(ctx)
|
||||
err := ctx.ShouldBindUri(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBindUri error: %s", msgID, err.Error())
|
||||
return err
|
||||
}
|
||||
err = ctx.ShouldBind(s)
|
||||
if err != nil {
|
||||
log.Debugf("MsgID[%s] ShouldBind error: %#v", msgID, err.Error())
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func (s *SysCategoryControl) Generate() dto.Control {
|
||||
@@ -79,13 +69,12 @@ func (s *SysCategoryControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysCategoryControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysCategory{
|
||||
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Name: s.Name,
|
||||
Img: s.Img,
|
||||
Sort: s.Sort,
|
||||
Status: s.Status,
|
||||
Remark: s.Remark,
|
||||
Model: common.Model{ID: s.ID},
|
||||
Name: s.Name,
|
||||
Img: s.Img,
|
||||
Sort: s.Sort,
|
||||
Status: s.Status,
|
||||
Remark: s.Remark,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,6 @@ package dto
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"go-admin/app/admin/models/system"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
common "go-admin/common/models"
|
||||
@@ -37,7 +35,7 @@ func (m *SysConfigSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysConfigControl struct {
|
||||
ID uint `uri:"ID" comment:"编码"` // 编码
|
||||
ID int `uri:"ID" comment:"编码"` // 编码
|
||||
ConfigName string `json:"configName" comment:""`
|
||||
ConfigKey string `json:"configKey" comment:""`
|
||||
ConfigValue string `json:"configValue" comment:""`
|
||||
@@ -66,7 +64,7 @@ func (s *SysConfigControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysConfigControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &system.SysConfig{
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Model: common.Model{ID: s.ID},
|
||||
ConfigName: s.ConfigName,
|
||||
ConfigKey: s.ConfigKey,
|
||||
ConfigValue: s.ConfigValue,
|
||||
|
||||
@@ -2,8 +2,6 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
@@ -14,7 +12,7 @@ import (
|
||||
type SysFileDirSearch struct {
|
||||
dto.Pagination `search:"-"`
|
||||
|
||||
ID uint `form:"ID" search:"type:exact;column:id;table:sys_file_dir" comment:"标识"`
|
||||
ID int `form:"ID" search:"type:exact;column:id;table:sys_file_dir" comment:"标识"`
|
||||
Label string `form:"label" search:"type:exact;column:label;table:sys_file_dir" comment:"目录名称"`
|
||||
PId string `form:"pId" search:"type:exact;column:p_id;table:sys_file_dir" comment:"上级目录"`
|
||||
Sort string `form:"sort" search:"type:exact;column:sort;table:sys_file_dir" comment:"排序"`
|
||||
@@ -40,11 +38,13 @@ func (m *SysFileDirSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysFileDirControl struct {
|
||||
ID uint `uri:"ID" comment:"标识"` // 标识
|
||||
ID int `uri:"ID" comment:"标识"` // 标识
|
||||
Label string `json:"label" comment:"目录名称"`
|
||||
PId uint `json:"pId" comment:"上级目录"`
|
||||
PId int `json:"pId" comment:"上级目录"`
|
||||
Sort string `json:"sort" comment:"排序"`
|
||||
Path string `json:"path" comment:"路径"`
|
||||
CreateBy int `json:"-"`
|
||||
UpdateBy int `json:"-"`
|
||||
}
|
||||
|
||||
func (s *SysFileDirControl) Bind(ctx *gin.Context) error {
|
||||
@@ -68,7 +68,7 @@ func (s *SysFileDirControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysFileDirControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &models.SysFileDir{
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Model: common.Model{ID: s.ID},
|
||||
Label: s.Label,
|
||||
PId: s.PId,
|
||||
Sort: s.Sort,
|
||||
@@ -82,6 +82,7 @@ func (s *SysFileDirControl) GetId() interface{} {
|
||||
|
||||
type SysFileDirById struct {
|
||||
dto.ObjectById
|
||||
UpdateBy int `json:"-"`
|
||||
}
|
||||
|
||||
func (s *SysFileDirById) Generate() dto.Control {
|
||||
|
||||
@@ -2,8 +2,6 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models/system"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
@@ -41,7 +39,7 @@ func (m *SysLoginLogSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysLoginLogControl struct {
|
||||
ID uint `uri:"ID" comment:"主键"` // 主键
|
||||
ID int `uri:"ID" comment:"主键"` // 主键
|
||||
Username string `json:"username" comment:"用户名"`
|
||||
Status string `json:"status" comment:"状态"`
|
||||
Ipaddr string `json:"ipaddr" comment:"ip地址"`
|
||||
@@ -75,8 +73,7 @@ func (s *SysLoginLogControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysLoginLogControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &system.SysLoginLog{
|
||||
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Model: common.Model{ID: s.ID},
|
||||
Username: s.Username,
|
||||
Status: s.Status,
|
||||
Ipaddr: s.Ipaddr,
|
||||
|
||||
@@ -2,8 +2,6 @@ package dto
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"go-admin/app/admin/models/system"
|
||||
"go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
@@ -42,7 +40,7 @@ func (m *SysOperaLogSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysOperaLogControl struct {
|
||||
ID uint `uri:"ID" comment:"编码"` // 编码
|
||||
ID int `uri:"ID" comment:"编码"` // 编码
|
||||
Title string `json:"title" comment:"操作模块"`
|
||||
BusinessType string `json:"businessType" comment:"操作类型"`
|
||||
BusinessTypes string `json:"businessTypes" comment:""`
|
||||
@@ -84,7 +82,7 @@ func (s *SysOperaLogControl) Generate() dto.Control {
|
||||
|
||||
func (s *SysOperaLogControl) GenerateM() (common.ActiveRecord, error) {
|
||||
return &system.SysOperaLog{
|
||||
Model: gorm.Model{ID: s.ID},
|
||||
Model: common.Model{ID: s.ID},
|
||||
Title: s.Title,
|
||||
BusinessType: s.BusinessType,
|
||||
BusinessTypes: s.BusinessTypes,
|
||||
|
||||
@@ -37,7 +37,7 @@ func (m *SysJobSearch) Generate() dto.Index {
|
||||
}
|
||||
|
||||
type SysJobControl struct {
|
||||
JobId uint `json:"jobId"`
|
||||
JobId int `json:"jobId"`
|
||||
JobName string `json:"jobName" validate:"required"` // 名称
|
||||
JobGroup string `json:"jobGroup"` // 任务分组
|
||||
JobType int `json:"jobType"` // 任务类型
|
||||
@@ -93,7 +93,7 @@ func (s *SysJobById) GenerateM() (common.ActiveRecord, error) {
|
||||
}
|
||||
|
||||
type SysJobItem struct {
|
||||
JobId uint `json:"jobId"`
|
||||
JobId int `json:"jobId"`
|
||||
JobName string `json:"jobName" validate:"required"` // 名称
|
||||
JobGroup string `json:"jobGroup"` // 任务分组
|
||||
JobType int `json:"jobType"` // 任务类型
|
||||
|
||||
@@ -3,10 +3,10 @@ package service
|
||||
import (
|
||||
"errors"
|
||||
"go-admin/app/admin/models"
|
||||
"go-admin/app/admin/service/dto"
|
||||
"go-admin/common/actions"
|
||||
cDto "go-admin/common/dto"
|
||||
"go-admin/common/log"
|
||||
common "go-admin/common/models"
|
||||
"go-admin/common/service"
|
||||
"go-admin/tools"
|
||||
"gorm.io/gorm"
|
||||
@@ -17,7 +17,7 @@ type SysFileDir struct {
|
||||
}
|
||||
|
||||
// GetSysFileDirPage 获取SysFileDir列表
|
||||
func (e *SysFileDir) GetSysFileDirPage(c cDto.Index, list *[]models.SysFileDirL) error {
|
||||
func (e *SysFileDir) GetSysFileDirPage(c *dto.SysFileDirSearch, list *[]models.SysFileDirL) error {
|
||||
var err error
|
||||
var data models.SysFileDir
|
||||
msgID := e.MsgID
|
||||
@@ -25,7 +25,6 @@ func (e *SysFileDir) GetSysFileDirPage(c cDto.Index, list *[]models.SysFileDirL)
|
||||
err = e.Orm.Model(&data).
|
||||
Scopes(
|
||||
cDto.MakeCondition(c.GetNeedSearch()),
|
||||
//cDto.Paginate(c.GetPageSize(), c.GetPageIndex()),
|
||||
).
|
||||
Find(list). //Limit(-1).Offset(-1).
|
||||
Error
|
||||
@@ -58,7 +57,7 @@ func (e *SysFileDir) GetSysFileDir(d cDto.Control, model *models.SysFileDir) err
|
||||
}
|
||||
|
||||
// InsertSysFileDir 创建SysFileDir对象
|
||||
func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
|
||||
func (e *SysFileDir) InsertSysFileDir(model *dto.SysFileDirControl) error {
|
||||
var err error
|
||||
var data models.SysFileDir
|
||||
msgID := e.MsgID
|
||||
@@ -70,7 +69,7 @@ func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
|
||||
return err
|
||||
}
|
||||
id := model.GetId()
|
||||
path := "/" + tools.UIntToString(id.(uint))
|
||||
path := "/" + tools.IntToString(id.(int))
|
||||
db = e.Orm.Model(&data).
|
||||
First(&data, model.GetId())
|
||||
err = db.Error
|
||||
@@ -92,7 +91,7 @@ func (e *SysFileDir) InsertSysFileDir(model common.ActiveRecord) error {
|
||||
}
|
||||
|
||||
// UpdateSysFileDir 修改SysFileDir对象
|
||||
func (e *SysFileDir) UpdateSysFileDir(c common.ActiveRecord, p *actions.DataPermission) error {
|
||||
func (e *SysFileDir) UpdateSysFileDir(c *dto.SysFileDirControl, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data models.SysFileDir
|
||||
msgID := e.MsgID
|
||||
@@ -100,20 +99,19 @@ func (e *SysFileDir) UpdateSysFileDir(c common.ActiveRecord, p *actions.DataPerm
|
||||
db := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Where(c.GetId()).Updates(c)
|
||||
).Where(c.ID).Updates(c)
|
||||
if db.Error != nil {
|
||||
log.Errorf("msgID[%s] db error:%s", msgID, err)
|
||||
return err
|
||||
}
|
||||
if db.RowsAffected == 0 {
|
||||
return errors.New("无权更新该数据")
|
||||
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// RemoveSysFileDir 删除SysFileDir
|
||||
func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *actions.DataPermission) error {
|
||||
func (e *SysFileDir) RemoveSysFileDir(d *dto.SysFileDirById, p *actions.DataPermission) error {
|
||||
var err error
|
||||
var data models.SysFileDir
|
||||
msgID := e.MsgID
|
||||
@@ -121,7 +119,7 @@ func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *
|
||||
db := e.Orm.Model(&data).
|
||||
Scopes(
|
||||
actions.Permission(data.TableName(), p),
|
||||
).Where(d.GetId()).Delete(c)
|
||||
).Where(d.Id).Delete(&data)
|
||||
if db.Error != nil {
|
||||
err = db.Error
|
||||
log.Errorf("MsgID[%s] Delete error: %s", msgID, err)
|
||||
@@ -134,7 +132,7 @@ func (e *SysFileDir) RemoveSysFileDir(d cDto.Control, c common.ActiveRecord, p *
|
||||
return nil
|
||||
}
|
||||
|
||||
func (e *SysFileDir) SetSysFileDir(c cDto.Index) (*[]models.SysFileDirL, error) {
|
||||
func (e *SysFileDir) SetSysFileDir(c *dto.SysFileDirSearch) (*[]models.SysFileDirL, error) {
|
||||
var list []models.SysFileDirL
|
||||
err := e.GetSysFileDirPage(c, &list)
|
||||
m := make([]models.SysFileDirL, 0)
|
||||
|
||||
Reference in New Issue
Block a user