feat: 新增预警定时扫描器,移除附件归档字段并为角色表补充更新时间
This commit is contained in:
@@ -8,6 +8,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"entgo.io/ent/dialect/sql"
|
||||
"entgo.io/ent/dialect/sql/sqlgraph"
|
||||
@@ -89,6 +90,18 @@ func (_u *RoleUpdate) ClearPermissionCodes() *RoleUpdate {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updatedAt" field.
|
||||
func (_u *RoleUpdate) SetUpdatedAt(v time.Time) *RoleUpdate {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
||||
func (_u *RoleUpdate) ClearUpdatedAt() *RoleUpdate {
|
||||
_u.mutation.ClearUpdatedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the RoleMutation object of the builder.
|
||||
func (_u *RoleUpdate) Mutation() *RoleMutation {
|
||||
return _u.mutation
|
||||
@@ -96,6 +109,7 @@ func (_u *RoleUpdate) Mutation() *RoleMutation {
|
||||
|
||||
// Save executes the query and returns the number of nodes affected by the update operation.
|
||||
func (_u *RoleUpdate) Save(ctx context.Context) (int, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
@@ -121,6 +135,14 @@ func (_u *RoleUpdate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *RoleUpdate) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
||||
v := role.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *RoleUpdate) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
@@ -179,6 +201,12 @@ func (_u *RoleUpdate) sqlSave(ctx context.Context) (_node int, err error) {
|
||||
if _u.mutation.PermissionCodesCleared() {
|
||||
_spec.ClearField(role.FieldPermissionCodes, field.TypeJSON)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(role.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(role.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
if _node, err = sqlgraph.UpdateNodes(ctx, _u.driver, _spec); err != nil {
|
||||
if _, ok := err.(*sqlgraph.NotFoundError); ok {
|
||||
@@ -261,6 +289,18 @@ func (_u *RoleUpdateOne) ClearPermissionCodes() *RoleUpdateOne {
|
||||
return _u
|
||||
}
|
||||
|
||||
// SetUpdatedAt sets the "updatedAt" field.
|
||||
func (_u *RoleUpdateOne) SetUpdatedAt(v time.Time) *RoleUpdateOne {
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
return _u
|
||||
}
|
||||
|
||||
// ClearUpdatedAt clears the value of the "updatedAt" field.
|
||||
func (_u *RoleUpdateOne) ClearUpdatedAt() *RoleUpdateOne {
|
||||
_u.mutation.ClearUpdatedAt()
|
||||
return _u
|
||||
}
|
||||
|
||||
// Mutation returns the RoleMutation object of the builder.
|
||||
func (_u *RoleUpdateOne) Mutation() *RoleMutation {
|
||||
return _u.mutation
|
||||
@@ -281,6 +321,7 @@ func (_u *RoleUpdateOne) Select(field string, fields ...string) *RoleUpdateOne {
|
||||
|
||||
// Save executes the query and returns the updated Role entity.
|
||||
func (_u *RoleUpdateOne) Save(ctx context.Context) (*Role, error) {
|
||||
_u.defaults()
|
||||
return withHooks(ctx, _u.sqlSave, _u.mutation, _u.hooks)
|
||||
}
|
||||
|
||||
@@ -306,6 +347,14 @@ func (_u *RoleUpdateOne) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
// defaults sets the default values of the builder before save.
|
||||
func (_u *RoleUpdateOne) defaults() {
|
||||
if _, ok := _u.mutation.UpdatedAt(); !ok && !_u.mutation.UpdatedAtCleared() {
|
||||
v := role.UpdateDefaultUpdatedAt()
|
||||
_u.mutation.SetUpdatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_u *RoleUpdateOne) check() error {
|
||||
if v, ok := _u.mutation.Name(); ok {
|
||||
@@ -381,6 +430,12 @@ func (_u *RoleUpdateOne) sqlSave(ctx context.Context) (_node *Role, err error) {
|
||||
if _u.mutation.PermissionCodesCleared() {
|
||||
_spec.ClearField(role.FieldPermissionCodes, field.TypeJSON)
|
||||
}
|
||||
if value, ok := _u.mutation.UpdatedAt(); ok {
|
||||
_spec.SetField(role.FieldUpdatedAt, field.TypeTime, value)
|
||||
}
|
||||
if _u.mutation.UpdatedAtCleared() {
|
||||
_spec.ClearField(role.FieldUpdatedAt, field.TypeTime)
|
||||
}
|
||||
_spec.AddModifiers(_u.modifiers...)
|
||||
_node = &Role{config: _u.config}
|
||||
_spec.Assign = _node.assignValues
|
||||
|
||||
Reference in New Issue
Block a user