MCPcopy
hub / github.com/ccfos/nightingale / Add

Method Add

models/user.go:275–289  ·  view source on GitHub ↗
(ctx *ctx.Context)

Source from the content-addressed store, hash-verified

273}
274
275func (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
291func (u *User) Update(ctx *ctx.Context, selectField interface{}, selectFields ...interface{}) error {
292 if u.Belong == "" {

Callers 2

userAddPostMethod · 0.95
AddUserAndGroupsMethod · 0.95

Calls 2

UserGetByUsernameFunction · 0.85
InsertFunction · 0.85

Tested by

no test coverage detected