(ctx *ctx.Context)
| 273 | } |
| 274 | |
| 275 | func (u *User) Add(ctx *ctx.Context) error { |
| 276 | user, err := UserGetByUsername(ctx, u.Username) |
| 277 | if err != nil { |
| 278 | return errors.WithMessage(err, "failed to query user") |
| 279 | } |
| 280 | |
| 281 | if user != nil { |
| 282 | return errors.New("Username already exists") |
| 283 | } |
| 284 | |
| 285 | now := time.Now().Unix() |
| 286 | u.CreateAt = now |
| 287 | u.UpdateAt = now |
| 288 | return Insert(ctx, u) |
| 289 | } |
| 290 | |
| 291 | func (u *User) Update(ctx *ctx.Context, selectField interface{}, selectFields ...interface{}) error { |
| 292 | if u.Belong == "" { |
no test coverage detected