func (s *SoExtReplyCreatedWrap) getModifiedFields(oriTable *SoExtReplyCreated, curTable *SoExtReplyCreated) (map[string]bool, bool, error) {
	if oriTable == nil {
		return nil, false, errors.New("table info is nil, can't get modified fields")
	}
	hasWatcher := false
	fields := make(map[string]bool)
	if !reflect.DeepEqual(oriTable.CreatedOrder, curTable.CreatedOrder) {
		fields["CreatedOrder"] = true
		hasWatcher = hasWatcher || s.watcherFlag.HasCreatedOrderWatcher
	}
	hasWatcher = hasWatcher || s.watcherFlag.WholeWatcher
	return fields, hasWatcher, nil
}
Get all the modified fields in the table
package table
import (
	"bytes"
	"encoding/json"
	"errors"
	"fmt"
	"reflect"
	"sync"
	"github.com/coschain/contentos-go/common/encoding/kope"
	"github.com/coschain/contentos-go/iservices"
	prototype "github.com/coschain/contentos-go/prototype"
	proto "github.com/golang/protobuf/proto"
)
var (
	ExtReplyCreatedCreatedOrderTable uint32 = 874612931
	ExtReplyCreatedPostIdUniTable    uint32 = 457271836
	ExtReplyCreatedPostIdRow uint32 = 3284075428
)
type SoExtReplyCreatedWrap struct {
	dba         iservices.IDatabaseRW
	mainKey     *uint64
	watcherFlag *ExtReplyCreatedWatcherFlag
	mKeyFlag    int     
	mKeyBuf     []byte  
	mBuf        []byte  
	mdFuncMap   map[string]interface{}
}
func NewSoExtReplyCreatedWrap(dba iservices.IDatabaseRW, key *uint64) *SoExtReplyCreatedWrap {
	if dba == nil || key == nil {
		return nil
	}
	result := &SoExtReplyCreatedWrap{dba, key, nil, -1, nil, nil, nil}
	result.initWatcherFlag()
	return result
}
func (s *SoExtReplyCreatedWrap) CheckExist() bool {
	if s.dba == nil {
		return false
	}
	if s.mKeyFlag != -1 {
		if s.mKeyFlag == 0 {
			return false
		}
		return true
	}
	keyBuf, err := s.encodeMainKey()
	if err != nil {
		return false
	}
	res, err := s.dba.Has(keyBuf)
	if err != nil {
		return false
	}
	if res == false {
		s.mKeyFlag = 0
	} else {
		s.mKeyFlag = 1
	}
	return res
}
func (s *SoExtReplyCreatedWrap) MustExist(errMsgs ...interface{}) *SoExtReplyCreatedWrap {
	if !s.CheckExist() {
		panic(bindErrorInfo(fmt.Sprintf("SoExtReplyCreatedWrap.MustExist: %v not found", s.mainKey), errMsgs...))
	}
	return s
}
func (s *SoExtReplyCreatedWrap) MustNotExist(errMsgs ...interface{}) *SoExtReplyCreatedWrap {
	if s.CheckExist() {
		panic(bindErrorInfo(fmt.Sprintf("SoExtReplyCreatedWrap.MustNotExist: %v already exists", s.mainKey), errMsgs...))
	}
	return s
}
func (s *SoExtReplyCreatedWrap) initWatcherFlag() {
	if s.watcherFlag == nil {
		s.watcherFlag = new(ExtReplyCreatedWatcherFlag)
		*(s.watcherFlag) = ExtReplyCreatedWatcherFlagOfDb(s.dba.ServiceId())
	}
}
func (s *SoExtReplyCreatedWrap) create(f func(tInfo *SoExtReplyCreated)) error {
	if s.dba == nil {
		return errors.New("the db is nil")
	}
	if s.mainKey == nil {
		return errors.New("the main key is nil")
	}
	val := &SoExtReplyCreated{}
	f(val)
	if s.CheckExist() {
		return errors.New("the main key is already exist")
	}
	keyBuf, err := s.encodeMainKey()
	if err != nil {
		return err
	}
	buf, err := proto.Marshal(val)
	if err != nil {
		return err
	}
	err = s.dba.Put(keyBuf, buf)
	if err != nil {
		return err
	}
	if err = s.insertAllSortKeys(val); err != nil {
		s.delAllSortKeys(false, val)
		s.dba.Delete(keyBuf)
		return err
	}
	if sucNames, err := s.insertAllUniKeys(val); err != nil {
		s.delAllSortKeys(false, val)
		s.delUniKeysWithNames(sucNames, val)
		s.dba.Delete(keyBuf)
		return err
	}
	s.mKeyFlag = 1
	s.initWatcherFlag()
	if s.watcherFlag.AnyWatcher {
		ReportTableRecordInsert(s.dba.ServiceId(), s.dba.BranchId(), s.mainKey, val)
	}
	return nil
}
func (s *SoExtReplyCreatedWrap) Create(f func(tInfo *SoExtReplyCreated), errArgs ...interface{}) *SoExtReplyCreatedWrap {
	err := s.create(f)
	if err != nil {
		panic(bindErrorInfo(fmt.Errorf("SoExtReplyCreatedWrap.Create failed: %s", err.Error()), errArgs...))
	}
	return s
}
func (s *SoExtReplyCreatedWrap) getMainKeyBuf() ([]byte, error) {
	if s.mainKey == nil {
		return nil, errors.New("the main key is nil")
	}
	if s.mBuf == nil {
		var err error = nil
		s.mBuf, err = kope.Encode(s.mainKey)
		if err != nil {
			return nil, err
		}
	}
	return s.mBuf, nil
}
func (s *SoExtReplyCreatedWrap) modify(f func(tInfo *SoExtReplyCreated)) error {
	if !s.CheckExist() {
		return errors.New("the SoExtReplyCreated table does not exist. Please create a table first")
	}
	oriTable := s.getExtReplyCreated()
	if oriTable == nil {
		return errors.New("fail to get origin table SoExtReplyCreated")
	}
	curTable := s.getExtReplyCreated()
	if curTable == nil {
		return errors.New("fail to create current table SoExtReplyCreated")
	}
	f(curTable)
	if !reflect.DeepEqual(curTable.PostId, oriTable.PostId) {
		return errors.New("primary key does not support modification")
	}
	s.initWatcherFlag()
	modifiedFields, hasWatcher, err := s.getModifiedFields(oriTable, curTable)
	if err != nil {
		return err
	}
	if modifiedFields == nil || len(modifiedFields) < 1 {
		return nil
	}
	err = s.checkSortAndUniFieldValidity(curTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeCheck, curTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeDel, oriTable, modifiedFields)
	if err != nil {
		return err
	}
	err = s.updateExtReplyCreated(curTable)
	if err != nil {
		return err
	}
	err = s.handleFieldMd(FieldMdHandleTypeInsert, curTable, modifiedFields)
	if err != nil {
		return err
	}
	if hasWatcher {
		ReportTableRecordUpdate(s.dba.ServiceId(), s.dba.BranchId(), s.mainKey, oriTable, curTable, modifiedFields)
	}
	return nil
}
func (s *SoExtReplyCreatedWrap) Modify(f func(tInfo *SoExtReplyCreated), errArgs ...interface{}) *SoExtReplyCreatedWrap {
	err := s.modify(f)
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoExtReplyCreatedWrap.Modify failed: %s", err.Error()), errArgs...))
	}
	return s
}
func (s *SoExtReplyCreatedWrap) SetCreatedOrder(p *prototype.ReplyCreatedOrder, errArgs ...interface{}) *SoExtReplyCreatedWrap {
	err := s.modify(func(r *SoExtReplyCreated) {
		r.CreatedOrder = p
	})
	if err != nil {
		panic(bindErrorInfo(fmt.Sprintf("SoExtReplyCreatedWrap.SetCreatedOrder( %v ) failed: %s", p, err.Error()), errArgs...))
	}
	return s
}
func (s *SoExtReplyCreatedWrap) checkSortAndUniFieldValidity(curTable *SoExtReplyCreated, fields map[string]bool) error {
	if curTable != nil && fields != nil && len(fields) > 0 {
		if fields["CreatedOrder"] && curTable.CreatedOrder == nil {
			return errors.New("sort field CreatedOrder can't be modified to nil")
		}
	}
	return nil
}