func SelectLogByWhere(whereCond string, arg ...interface{}) ([]*Log, error) {
	var objs = new([]*Log)
	err := logDB.Select(objs, "SELECT `id`,`text`,`updated_at`,`created_at` FROM `log` WHERE "+insertZeroDeletedTsField(whereCond), arg...)
	return *objs, err
}
SelectLogByWhere query some Log data from database by WHERE condition.
NOTE:
Without cache layer.
package model
import (
	"database/sql"
	"unsafe"
	"github.com/henrylee2cn/erpc/v6"
	"github.com/henrylee2cn/goutil/coarsetime"
	"github.com/xiaoenai/tp-micro/v6/model/mysql"
	"github.com/xiaoenai/tp-micro/v6/model/sqlx"
	"github.com/xiaoenai/tp-micro/examples/project/args"
)
type Log args.Log
func ToLog(_l *args.Log) *Log {
	return (*Log)(unsafe.Pointer(_l))
}
func ToArgsLog(_l *Log) *args.Log {
	return (*args.Log)(unsafe.Pointer(_l))
}
func ToLogSlice(a []*args.Log) []*Log {
	return *(*[]*Log)(unsafe.Pointer(&a))
}
func ToArgsLogSlice(a []*Log) []*args.Log {
	return *(*[]*args.Log)(unsafe.Pointer(&a))
}
func (*Log) TableName() string {
	return "log"
}
func (_l *Log) isZeroPrimaryKey() bool {
	var _id int64
	if _l.Id != _id {
		return false
	}
	return true
}
var logDB, _ = mysqlHandler.RegCacheableDB(new(Log), cacheExpire, args.LogSql)
func GetLogDB() *mysql.CacheableDB {
	return logDB
}
func InsertLog(_l *Log, tx ...*sqlx.Tx) (int64, error) {
	_l.UpdatedAt = coarsetime.FloorTimeNow().Unix()
	if _l.CreatedAt == 0 {
		_l.CreatedAt = _l.UpdatedAt
	}
	return _l.Id, logDB.Callback(func(tx sqlx.DbOrTx) error {
		var (
			query            string
			isZeroPrimaryKey = _l.isZeroPrimaryKey()
		)
		if isZeroPrimaryKey {
			query = "INSERT INTO `log` (`text`,`updated_at`,`created_at`)VALUES(:text,:updated_at,:created_at);"
		} else {
			query = "INSERT INTO `log` (`id`,`text`,`updated_at`,`created_at`)VALUES(:id,:text,:updated_at,:created_at);"
		}
		r, err := tx.NamedExec(query, _l)
		if isZeroPrimaryKey && err == nil {
			_l.Id, err = r.LastInsertId()
		}
		return err
	}, tx...)
}
func UpsertLog(_l *Log, _updateFields []string, tx ...*sqlx.Tx) (int64, error) {
	if _l.UpdatedAt == 0 {
		_l.UpdatedAt = coarsetime.FloorTimeNow().Unix()
	}
	if _l.CreatedAt == 0 {
		_l.CreatedAt = _l.UpdatedAt
	}
	err := logDB.Callback(func(tx sqlx.DbOrTx) error {
		var (
			query            string
			isZeroPrimaryKey = _l.isZeroPrimaryKey()
		)
		if isZeroPrimaryKey {
			query = "INSERT INTO `log` (`text`,`updated_at`,`created_at`)VALUES(:text,:updated_at,:created_at)"
		} else {
			query = "INSERT INTO `log` (`id`,`text`,`updated_at`,`created_at`)VALUES(:id,:text,:updated_at,:created_at)"
		}
		query += " ON DUPLICATE KEY UPDATE "
		if len(_updateFields) == 0 {
			query += "`text`=VALUES(`text`),`updated_at`=VALUES(`updated_at`);"
		} else {
			for _, s := range _updateFields {
				if s == "updated_at" || s == "created_at" || s == "deleted_ts" || s == "id" {
					continue
				}
				query += "`" + s + "`=VALUES(`" + s + "`),"
			}
			if query[len(query)-1] != ',' {
				return nil
			}
			query += "`updated_at`=VALUES(`updated_at`),`deleted_ts`=0;"
		}
		r, err := tx.NamedExec(query, _l)
		if isZeroPrimaryKey && err == nil {
			var rowsAffected int64
			rowsAffected, err = r.RowsAffected()
			if rowsAffected == 1 {
				_l.Id, err = r.LastInsertId()
			}
		}
		return err
	}, tx...)
	if err != nil {
		return _l.Id, err
	}
	err = logDB.DeleteCache(_l)
	if err != nil {
		erpc.Errorf("%s", err.Error())
	}
	return _l.Id, nil
}
func UpdateLogByPrimary(_l *Log, _updateFields []string, tx ...*sqlx.Tx) error {
	_l.UpdatedAt = coarsetime.FloorTimeNow().Unix()
	err := logDB.Callback(func(tx sqlx.DbOrTx) error {
		query := "UPDATE `log` SET "
		if len(_updateFields) == 0 {
			query += "`text`=:text,`updated_at`=:updated_at WHERE `id`=:id AND `deleted_ts`=0 LIMIT 1;"
		} else {
			for _, s := range _updateFields {
				if s == "updated_at" || s == "created_at" || s == "deleted_ts" || s == "id" {
					continue
				}
				query += "`" + s + "`=:" + s + ","
			}
			if query[len(query)-1] != ',' {
				return nil
			}
			query += "`updated_at`=:updated_at WHERE `id`=:id AND `deleted_ts`=0 LIMIT 1;"
		}
		_, err := tx.NamedExec(query, _l)
		return err
	}, tx...)
	if err != nil {
		return err
	}
	err = logDB.DeleteCache(_l)
	if err != nil {
		erpc.Errorf("%s", err.Error())
	}
	return nil
}
func DeleteLogByPrimary(_id int64, deleteHard bool, tx ...*sqlx.Tx) error {
	var err error
	if deleteHard {
		err = logDB.Callback(func(tx sqlx.DbOrTx) error {
			_, err := tx.Exec("DELETE FROM `log` WHERE `id`=? AND `deleted_ts`=0;", _id)
			return err
		}, tx...)
	} else {
		ts := coarsetime.FloorTimeNow().Unix()
		err = logDB.Callback(func(tx sqlx.DbOrTx) error {
			_, err := tx.Exec("UPDATE `log` SET `updated_at`=?, `deleted_ts`=? WHERE `id`=? AND `deleted_ts`=0;", ts, ts, _id)
			return err
		}, tx...)
	}
	if err != nil {
		return err
	}
	err = logDB.DeleteCache(&Log{
		Id: _id,
	})
	if err != nil {
		erpc.Errorf("%s", err.Error())
	}
	return nil
}
func GetLogByPrimary(_id int64) (*Log, bool, error) {
	var _l = &Log{
		Id: _id,
	}
	err := logDB.CacheGet(_l)
	switch err {
	case nil:
		if _l.CreatedAt == 0 || _l.DeletedTs != 0 {
			return nil, false, nil
		}
		return _l, true, nil
	case sql.ErrNoRows:
		return nil, false, nil
	default:
		return nil, false, err
	}
}
func GetLogByWhere(whereCond string, arg ...interface{}) (*Log, bool, error) {
	var _l = new(Log)
	err := logDB.Get(_l, "SELECT `id`,`text`,`updated_at`,`created_at` FROM `log` WHERE "+insertZeroDeletedTsField(whereCond)+" LIMIT 1;", arg...)
	switch err {
	case nil:
		return _l, true, nil
	case sql.ErrNoRows:
		return nil, false, nil
	default:
		return nil, false, err
	}
}