1234567891011121314151617181920212223242526272829303132333435 |
- // Copyright 2019 github.com. All rights reserved.
- // Use of this source code is governed by github.com.
- package log
- import (
- "context"
- "git.getensh.com/common/gopkgs/database"
- "property-log/model"
- "property-log/pb/v1"
- "time"
- "property-log/errors"
- )
- func ManagementLogAdd(ctx context.Context, req *v1.ManagementLogAddRequest) (reply *v1.ManagementLogAddReply, err error) {
- p := &model.TManagementLog{}
- p.Uid = req.Uid
- p.Module = req.Module
- p.Action = req.Action
- p.Origin = req.Origin
- p.Target = req.Target
- p.Username = req.Username
- p.CreatedAt = time.Unix(req.Timestamp, 0)
- err = p.Insert(database.DB())
- if err != nil {
- return nil, errors.DataBaseError
- }
- reply = &v1.ManagementLogAddReply{}
- return reply, nil
- }
|