作者 yangfu

Merge branch 'test'

... ... @@ -13,4 +13,7 @@ ENV GOPROXY https://goproxy.cn
RUN ["go","mod","tidy"]
RUN ["ls"]
RUN ["go","build"]
#EXPOSE 8080
ENTRYPOINT ["./character-library-metadata-bastion"]
\ No newline at end of file
... ...
... ... @@ -16,6 +16,8 @@ METADATA_BASTION_HOST = http://106.75.231.90:9999
KAFKA_HOST =47.97.5.102:9092
#192.168.100.35:9092
REDIS_HOST=127.0.0.1
STARROCKS_DB_NAME = character_library
STARROCKS_USER = root
STARROCKS_PASSWORD = eagle1010
... ...
... ... @@ -33,6 +33,7 @@ require (
github.com/ajg/form v1.5.1 // indirect
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/go-sql-driver/mysql v1.7.0
github.com/google/go-querystring v1.1.0 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/moul/http2curl v1.0.0 // indirect
... ... @@ -52,7 +53,7 @@ require (
replace (
github.com/extrame/xls v0.0.1 => github.com/tiptok/xls v1.0.1
github.com/go-sql-driver/mysql v1.7.0 => github.com/StarRocks/go-mysql-driver v1.7.0
//github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220421085958-9682d0ac42c1
github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v1.0.2
)
... ...
package main
import (
"database/sql"
"fmt"
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/crontab"
... ... @@ -39,6 +40,7 @@ func main() {
log.Logger.Info("Service:" + constant.SERVICE_NAME)
log.Logger.Info("Version:" + Version)
log.Logger.Info("server start!")
log.Logger.Info("db driver", map[string]interface{}{"drivers": sql.Drivers()})
web.Run()
log.Logger.Info("server stop!")
}
... ...
... ... @@ -470,15 +470,22 @@ func (tableService *TableService) ValidExprSql(ctx *domain.Context, cmd *command
if len(cmd.ExprSql) == 0 {
selectValue = "''"
}
selectValue = domain.RemoveInvalidChar(selectValue)
sql := "select " + selectValue + " as expr"
if len(set.KeysStr()) > 0 {
sql += " from " + strings.Join(set.KeysStr(), ",")
sql += " limit 1"
}
tx := starrocks.DB.Exec(sql)
if tx.Error != nil {
//tx := starrocks.DB.Exec(sql)
//if tx.Error != nil {
// return map[string]string{
// "result": tx.Error.Error(),
// }, nil
//}
err := starrocks.ExecOfficial(sql)
if err != nil {
return map[string]string{
"result": tx.Error.Error(),
"result": err.Error(),
}, nil
}
case domain.ExprModeExcelFunction:
... ...
package constant
var POSTGRESQL_DB_NAME = "terms"
var POSTGRESQL_DB_NAME = "allied_creation_test"
var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "123456"
var POSTGRESQL_HOST = "127.0.0.1"
var POSTGRESQL_PORT = "5432"
var POSTGRESQL_PASSWORD = "eagle1010"
var POSTGRESQL_HOST = "114.55.200.59"
var POSTGRESQL_PORT = "31543"
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
var DISABLE_SQL_GENERATE_COMMENT = true
... ...
package constant
var (
REDIS_HOST = "127.0.0.1"
REDIS_HOST = "host.docker.internal"
REDIS_PORT = "6379"
REDIS_AUTH = ""
REDIS_ADDRESS = ""
... ...
... ... @@ -2,10 +2,10 @@ package constant
import "fmt"
var STARROCKS_DB_NAME = "character_library_standard"
var STARROCKS_DB_NAME = "character_library"
var STARROCKS_USER = "root"
var STARROCKS_PASSWORD = "eagle1010"
var STARROCKS_HOST = "118.178.239.45"
var STARROCKS_HOST = "220.250.41.79"
var STARROCKS_PORT = "9030"
var STARROCKS_MYSQL_DATA_SOURCE = ""
... ...
... ... @@ -110,6 +110,16 @@ func (expr *FieldExpr) Complete() string {
}
exprSql = strings.ReplaceAll(exprSql, sql, sub)
}
exprSql = RemoveInvalidChar(exprSql)
return exprSql
}
// RemoveInvalidChar 移除非法字符
// 前台的字符串的一个空格(ASCII:32)被UTF-8编码之后变成了一个诡异的字符(ASCII:194 和 160的组合)
// https://www.cnblogs.com/mingmingruyuedlut/archive/2012/07/04/2575180.html
func RemoveInvalidChar(exprSql string) string {
tmpValue := string([]byte{0xC2, 0xA0})
exprSql = strings.ReplaceAll(exprSql, tmpValue, " ")
return exprSql
}
... ...
package starrocks
import (
_ "github.com/go-sql-driver/mysql"
"github.com/linmadan/egglib-go/utils/json"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
... ... @@ -29,6 +30,9 @@ func Init() error {
)
DB, err = gorm.Open(mysql.Open(constant.STARROCKS_MYSQL_DATA_SOURCE), &gorm.Config{Logger: newLogger, PrepareStmt: false})
if err = InitDBOfficial(); err != nil {
return err
}
//Test1()
return err
}
... ...
package starrocks
import (
"database/sql"
"github.com/go-sql-driver/mysql"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
"time"
)
var DBOfficial *sql.DB
func InitDBOfficial() error {
var err error
sql.Register("mysql-star", &mysql.MySQLDriver{})
DBOfficial, err = sql.Open("mysql-star", constant.STARROCKS_MYSQL_DATA_SOURCE)
if err != nil {
return err
}
// See "Important settings" section.
DBOfficial.SetConnMaxLifetime(time.Minute * 3)
DBOfficial.SetMaxOpenConns(2)
DBOfficial.SetMaxIdleConns(2)
return nil
}
func ExecOfficial(sql string) error {
log.Logger.Debug(sql)
result, err := DBOfficial.Exec(sql)
if err != nil {
log.Logger.Error("exec error", map[string]interface{}{"err": err.Error()})
return err
}
_, err = result.RowsAffected()
if err != nil {
log.Logger.Error("result error", map[string]interface{}{"result": err.Error()})
return err
}
return nil
}
... ...