Browse Source

Added unit_scope.go

Dmitry Yu Okunev 4 years ago
parent
commit
e310f4cbac
2 changed files with 157 additions and 0 deletions
  1. 3 0
      unit.go
  2. 154 0
      voipHelpers/unit_scope.go

+ 3 - 0
unit.go

@@ -58,6 +58,9 @@ func (sql Unit) ActiveOnly() *UnitScope {
 func (sql *UnitScope) ActiveOnly() *UnitScope {
 	return sql.LatestOnly(time.Duration(0))
 }
+func (unit Unit) IsStruct() bool {
+	return true
+}
 
 func (sql Unit) LatestOnly(howLong time.Duration) *UnitScope {
 	return sql.Scope().LatestOnly(howLong)

+ 154 - 0
voipHelpers/unit_scope.go

@@ -0,0 +1,154 @@
+package voipHelpers
+
+import (
+	"fmt"
+	m "devel.mephi.ru/dyokunev/go-asu-models"
+	I "devel.mephi.ru/dyokunev/wwwvoip/app/iface"
+	vModels "devel.mephi.ru/dyokunev/wwwvoip/app/models"
+	"github.com/xaionaro/reform"
+)
+
+var (
+	ErrCannotModify error = fmt.Errorf("Modifying of this object is forbidden")
+	ErrNotImplemented error = fmt.Errorf("Not implemented (yet?)")
+)
+
+type UnitScope struct {
+	m.UnitScope
+	vModels.ItemCommon
+}
+func NewUnitScope(scope m.UnitScope) *UnitScope {
+	return &UnitScope{UnitScope: scope}
+}
+func (scope UnitScope) IsStruct() bool {
+	return false
+}
+func (scope UnitScope) BeforeSave() error {
+	return nil
+}
+func (scope UnitScope) AfterRestore() {
+	return
+}
+func (scope UnitScope) GetKeyColumnName() string {
+	panic(ErrNotImplemented)
+	return ""
+}
+func (scope UnitScope) GetReformDB() *reform.DB {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IWhere(requiredArg interface{}, in_args ...interface{}) I.Scope {
+	return NewUnitScope(*scope.Where(requiredArg, in_args...))
+}
+func (scope UnitScope) CanCache() bool {
+	return false
+}
+func (scope UnitScope) CanSave() error {
+	return ErrCannotModify
+}
+func (scope UnitScope) Create(controller I.Controller) error {
+	return ErrCannotModify
+}
+func (scope UnitScope) Destroy(controller I.Controller) error {
+	return ErrCannotModify
+}
+func (scope UnitScope) DefaultReformQuerier() I.ReformBackendQuerier {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) FieldPtrByName(fieldName string) interface{} {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) FieldValueByName(fieldName string) interface{} {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) FlushCache() error {
+	return nil
+}
+func (scope UnitScope) GetDisplayName() string {
+	panic(ErrNotImplemented)
+	return ""
+}
+func (scope UnitScope) IAsuFindByKey(key interface{}) (I.Item, error) {
+	panic(ErrNotImplemented)
+	return nil, nil
+}
+func (scope UnitScope) IDB(db *reform.DB) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IDiffFieldsTo(compareItem I.Item) [][]string {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IElem() (I.Item) {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IFirst(args ...interface{}) (I.Item, error) {
+	panic(ErrNotImplemented)
+	return nil, nil
+}
+func (scope UnitScope) IFixPairByFieldName(fieldName string) I.ItemPtr {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IGetTemplatesForSimilars() (result []I.Item) {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IGroup(argsI ...interface{}) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IIsIdenticalTo(compareItem I.Item) bool {
+	panic(ErrNotImplemented)
+	return false
+}
+func (scope UnitScope) ILimit(limit int) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) INewKeyMap() I.ItemKeyMap {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IOrder(argsI ...interface{}) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) IPrepareForRender() I.ItemPtr {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) ISelect(args ...interface{}) (I.Slice, error) {
+	panic(ErrNotImplemented)
+	return nil, nil
+}
+func (scope UnitScope) ISetDB(dbI interface{}) I.ItemPtr {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) ISetGroup(group []string) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) ISetOrder(order []string) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) ISetReformScope(anotherScope reform.GormImitateScope) reform.GormImitateScope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) ISetWhere(where [][]interface{}) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+func (scope UnitScope) Model(newModel I.Model) I.Scope {
+	panic(ErrNotImplemented)
+	return nil
+}
+