fix: 用户信息更新返回类型与关注建表缺陷
updateMeLogic 更新后重新查询并返回 User 类型,修复 converter 转换 空响应的错误。proto_string 不再丢弃含空格的字符串。userfollows ent schema 补上 created_at 的 Default(time.Now)。
This commit is contained in:
@@ -51,6 +51,7 @@ func (_c *UserFollowsCreate) Mutation() *UserFollowsMutation {
|
||||
|
||||
// Save creates the UserFollows in the database.
|
||||
func (_c *UserFollowsCreate) Save(ctx context.Context) (*UserFollows, error) {
|
||||
_c.defaults()
|
||||
return withHooks(ctx, _c.sqlSave, _c.mutation, _c.hooks)
|
||||
}
|
||||
|
||||
@@ -76,6 +77,13 @@ func (_c *UserFollowsCreate) ExecX(ctx context.Context) {
|
||||
}
|
||||
}
|
||||
|
||||
func (_c *UserFollowsCreate) defaults() {
|
||||
if _, ok := _c.mutation.CreatedAt(); !ok {
|
||||
v := userfollows.DefaultCreatedAt()
|
||||
_c.mutation.SetCreatedAt(v)
|
||||
}
|
||||
}
|
||||
|
||||
// check runs all checks and user-defined validators on the builder.
|
||||
func (_c *UserFollowsCreate) check() error {
|
||||
if _, ok := _c.mutation.FollowerID(); !ok {
|
||||
@@ -152,6 +160,7 @@ func (_c *UserFollowsCreateBulk) Save(ctx context.Context) ([]*UserFollows, erro
|
||||
for i := range _c.builders {
|
||||
func(i int, root context.Context) {
|
||||
builder := _c.builders[i]
|
||||
builder.defaults()
|
||||
var mut Mutator = MutateFunc(func(ctx context.Context, m Mutation) (Value, error) {
|
||||
mutation, ok := m.(*UserFollowsMutation)
|
||||
if !ok {
|
||||
|
||||
Reference in New Issue
Block a user