新增用户相关接口
This commit is contained in:
@@ -18,6 +18,8 @@ type AdminUser struct {
|
||||
RoleID int64 `gorm:"column:role_id;type:bigint(19);comment:'角色id'" json:"role_id"`
|
||||
DeptID int64 `gorm:"column:dept_id;type:bigint(19);comment:'部门id'" json:"dept_id"`
|
||||
PostID int64 `gorm:"column:post_id;type:bigint(19);comment:'岗位id'" json:"post_id"`
|
||||
CreateBy int64 `gorm:"column:create_by;type:bigint(19);comment:'创建者id(用户表id)'" json:"create_by"`
|
||||
UpdateBy int64 `gorm:"column:update_by;type:bigint(19);comment:'更新者id(用户表id)'" json:"update_by"`
|
||||
Role *AdminRole `gorm:"foreignKey:RoleID"` // 角色
|
||||
Dept *AdminDept `gorm:"foreignKey:DeptID"` // 部门
|
||||
Post *AdminPost `gorm:"foreignKey:PostID"` // 岗位
|
||||
|
||||
@@ -60,28 +60,6 @@ func (t *LocalTime) String() string {
|
||||
return fmt.Sprintf("hhh:%s", time.Time(*t).String())
|
||||
}
|
||||
|
||||
// BeforeCreate 注册 BeforeCreate 回调函数
|
||||
// func (m *Model) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
// // 动态访问 YourModel 结构体本身
|
||||
// model := tx.Statement.Dest
|
||||
//
|
||||
// // 设置创建时间
|
||||
// layout := "2006-01-02 15:04:05"
|
||||
// strTime := "2019-08-09 11:35:52"
|
||||
// parsedTime, err := time.Parse(layout, strTime)
|
||||
// if err != nil {
|
||||
// return err
|
||||
// }
|
||||
//
|
||||
// // 使用反射设置创建时间字段
|
||||
// createdAtField := reflect.ValueOf(model).Elem().FieldByName("CreatedAt")
|
||||
// if createdAtField.CanSet() {
|
||||
// createdAtField.Set(reflect.ValueOf(parsedTime))
|
||||
// }
|
||||
//
|
||||
// return nil
|
||||
// }
|
||||
|
||||
func (m *Model) BeforeUpdate(tx *gorm.DB) (err error) {
|
||||
m.UpdatedAt = LocalTime(time.Now())
|
||||
tx.Statement.SetColumn("UpdatedAt", m.UpdatedAt)
|
||||
|
||||
Reference in New Issue
Block a user