...
|
...
|
@@ -4,6 +4,7 @@ import ( |
|
|
"github.com/astaxie/beego/orm"
|
|
|
"openapi/pkg/domain"
|
|
|
"openapi/pkg/infrastructure/bgorm/model"
|
|
|
"openapi/pkg/infrastructure/utils"
|
|
|
"strings"
|
|
|
"time"
|
|
|
)
|
...
|
...
|
@@ -62,6 +63,35 @@ func (repository *PushDeviceRepository) UpdateDevice(uid int64, clientId, device |
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (repository *PushDeviceRepository) SaveLog(request *domain.PushInfoRequest, err error) error {
|
|
|
var (
|
|
|
result int
|
|
|
errmsg string
|
|
|
)
|
|
|
if err != nil {
|
|
|
result = 1
|
|
|
errmsg = err.Error()
|
|
|
if v, ok := err.(*domain.ErrWithMessage); ok {
|
|
|
result = v.Errno
|
|
|
}
|
|
|
}
|
|
|
|
|
|
sql := `INSERT INTO push_log(msg_type,project,receivers,message,result,err_msg,create_at)VALUES(?,?,?,?,?,?,now())`
|
|
|
o := orm.NewOrm()
|
|
|
_, err = o.Raw(sql,
|
|
|
request.Type,
|
|
|
request.ProjectKey,
|
|
|
utils.JsonAssertString(request.Receivers),
|
|
|
utils.JsonAssertString(request),
|
|
|
result,
|
|
|
errmsg,
|
|
|
).Exec()
|
|
|
if err != nil {
|
|
|
return err
|
|
|
}
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
func (repository *PushDeviceRepository) transformBgormModelToDomainModel(model *models.PushDeviceInfo) (*domain.Device, error) {
|
|
|
return &domain.Device{
|
|
|
Uid: model.Uid,
|
...
|
...
|
|