refactor🎨 : 修改文件操作函数
This commit is contained in:
1 parent
37a2c585e1
commit
746123c888
12 files changed
+128
-169
No files matched your search
@@ -35,7 +35,7 @@ func CreateAction(control dto.Control) gin.HandlerFunc {
|
||||
app.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetCreateBy(tools.GetUserIdUint(c))
|
||||
object.SetCreateBy(tools.GetUserId(c))
|
||||
err = db.WithContext(c).Create(object).Error
|
||||
if err != nil {
|
||||
log.Errorf("MsgID[%s] Create error: %s", msgID, err)
|
||||
|
||||
@@ -37,7 +37,7 @@ func DeleteAction(control dto.Control) gin.HandlerFunc {
|
||||
return
|
||||
}
|
||||
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
object.SetUpdateBy(tools.GetUserId(c))
|
||||
|
||||
//数据权限检查
|
||||
p := GetPermissionFromContext(c)
|
||||
|
||||
@@ -35,7 +35,7 @@ func UpdateAction(control dto.Control) gin.HandlerFunc {
|
||||
app.Error(c, http.StatusInternalServerError, err, "模型生成失败")
|
||||
return
|
||||
}
|
||||
object.SetUpdateBy(tools.GetUserIdUint(c))
|
||||
object.SetUpdateBy(tools.GetUserId(c))
|
||||
|
||||
//数据权限检查
|
||||
p := GetPermissionFromContext(c)
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
)
|
||||
|
||||
type GeneralDelDto struct {
|
||||
Id uint `uri:"id" json:"id" validate:"required"`
|
||||
Ids []uint `json:"ids"`
|
||||
Id int `uri:"id" json:"id" validate:"required"`
|
||||
Ids []int `json:"ids"`
|
||||
}
|
||||
|
||||
func (g GeneralDelDto) GetIds() []uint {
|
||||
ids := make([]uint, 0)
|
||||
func (g GeneralDelDto) GetIds() []int {
|
||||
ids := make([]int, 0)
|
||||
if g.Id != 0 {
|
||||
ids = append(ids, g.Id)
|
||||
}
|
||||
@@ -36,7 +36,7 @@ func (g GeneralDelDto) GetIds() []uint {
|
||||
}
|
||||
|
||||
type GeneralGetDto struct {
|
||||
Id uint `uri:"id" json:"id" validate:"required"`
|
||||
Id int `uri:"id" json:"id" validate:"required"`
|
||||
}
|
||||
|
||||
func MakeCondition(q interface{}) func(db *gorm.DB) *gorm.DB {
|
||||
|
||||
+17
-4
@@ -1,14 +1,27 @@
|
||||
package models
|
||||
|
||||
import "time"
|
||||
|
||||
type ControlBy struct {
|
||||
CreateBy uint `gorm:"index;comment:'创建者'"`
|
||||
UpdateBy uint `gorm:"index;comment:'更新者'"`
|
||||
CreateBy int `gorm:"index;comment:'创建者'"`
|
||||
UpdateBy int `gorm:"index;comment:'更新者'"`
|
||||
}
|
||||
|
||||
func (e *ControlBy) SetCreateBy(createBy uint) {
|
||||
func (e *ControlBy) SetCreateBy(createBy int) {
|
||||
e.CreateBy = createBy
|
||||
}
|
||||
|
||||
func (e *ControlBy) SetUpdateBy(updateBy uint) {
|
||||
func (e *ControlBy) SetUpdateBy(updateBy int) {
|
||||
e.UpdateBy = updateBy
|
||||
}
|
||||
|
||||
|
||||
type Model struct {
|
||||
ID int `gorm:"primaryKey;autoIncrement;comment:'主键编码'"`
|
||||
}
|
||||
|
||||
type ModelTime struct {
|
||||
CreatedAt time.Time `gorm:"comment:'创建时间'"`
|
||||
UpdatedAt time.Time `gorm:"comment:'最后更新时间'"`
|
||||
DeletedAt *time.Time `gorm:"index;comment:'删除时间'"`
|
||||
}
|
||||
@@ -4,8 +4,8 @@ import "gorm.io/gorm/schema"
|
||||
|
||||
type ActiveRecord interface {
|
||||
schema.Tabler
|
||||
SetCreateBy(createBy uint)
|
||||
SetUpdateBy(updateBy uint)
|
||||
SetCreateBy(createBy int)
|
||||
SetUpdateBy(updateBy int)
|
||||
Generate() ActiveRecord
|
||||
GetId() interface{}
|
||||
}
|
||||
Reference in new issue
Block a user