优化
This commit is contained in:
parent
b2b393054f
commit
68341adf80
@ -162,7 +162,7 @@ func InitRbac() (fn func(), err error) {
|
||||
func InitOpenWinBrowser() (fn func(), err error) {
|
||||
config := model.GlobConfig
|
||||
if !config.Manager.DeBug {
|
||||
port := ":" + strconv.Itoa(config.Manager.Port)
|
||||
port := ":" + strconv.Itoa(int(config.Manager.Port))
|
||||
uri := fmt.Sprintf("%s%s", "http://127.0.0.1", port)
|
||||
util.OpenWinBrowser(uri)
|
||||
log.Println(fmt.Sprintf("将打开浏览器!地址为:%v",
|
||||
|
@ -38,7 +38,6 @@ func init() {
|
||||
|
||||
// By 肖文龙
|
||||
func main() {
|
||||
log.Println("configFileDir", configFileDir)
|
||||
app := application.NewApp(
|
||||
"report_server",
|
||||
application.WithConfigFileDir(configFileDir),
|
||||
|
@ -36,7 +36,7 @@
|
||||
"mysql": {
|
||||
"username":"root",
|
||||
"pwd":"123456",
|
||||
"ip":"127.0.0.1",
|
||||
"ip":"192.168.1.236",
|
||||
"port":"3306",
|
||||
"dbName":"lyn_bi",
|
||||
"maxOpenConns":10,
|
||||
@ -45,7 +45,7 @@
|
||||
"clickhouse": {
|
||||
"username":"default",
|
||||
"pwd":"EtHnvllx",
|
||||
"ip":"127.0.0.1",
|
||||
"ip":"192.168.1.236",
|
||||
"port":"9000",
|
||||
"dbName":"default",
|
||||
"clusterName":"perftest_3shards_1replicas",
|
||||
@ -55,7 +55,7 @@
|
||||
"maxIdleConns":1000
|
||||
},
|
||||
"kafka": {
|
||||
"addresses":["127.0.0.1:9092"],
|
||||
"addresses":["192.168.1.236:9092"],
|
||||
"username":"",
|
||||
"password":"",
|
||||
"numPartitions":300,
|
||||
@ -66,12 +66,12 @@
|
||||
"realTimeDataGroup": "realTimeDataGroup2"
|
||||
},
|
||||
"elasticSearch": {
|
||||
"Addresses":["http://127.0.0.1:9200"],
|
||||
"Addresses":["http://192.168.1.236:9200"],
|
||||
"Username":"",
|
||||
"Password":""
|
||||
},
|
||||
"redis": {
|
||||
"addr":"127.0.0.1:6379",
|
||||
"addr":"192.168.1.236:6379",
|
||||
"passwd":"",
|
||||
"db": 7,
|
||||
"maxIdle": 300,
|
||||
|
@ -17,7 +17,7 @@ type BehaviorAnalysisController struct {
|
||||
func (this BehaviorAnalysisController) GetConfigs(ctx *fiber.Ctx) error {
|
||||
|
||||
type ReqData struct {
|
||||
Appid int `json:"appid"`
|
||||
Appid int32 `json:"appid"`
|
||||
}
|
||||
var reqData ReqData
|
||||
err := ctx.BodyParser(&reqData)
|
||||
@ -27,7 +27,7 @@ func (this BehaviorAnalysisController) GetConfigs(ctx *fiber.Ctx) error {
|
||||
|
||||
behaviorAnalysisService := analysis.BehaviorAnalysisService{}
|
||||
|
||||
eventNameList, attributeMap, err := behaviorAnalysisService.GetConfigs(reqData.Appid)
|
||||
eventNameList, attributeMap, err := behaviorAnalysisService.GetConfigs(int(reqData.Appid))
|
||||
|
||||
if err != nil {
|
||||
return this.Error(ctx, err)
|
||||
@ -72,7 +72,7 @@ func (this BehaviorAnalysisController) LoadPropQuotas(ctx *fiber.Ctx) error {
|
||||
func (this BehaviorAnalysisController) GetValues(ctx *fiber.Ctx) error {
|
||||
|
||||
type ReqData struct {
|
||||
Appid int `json:"appid"`
|
||||
Appid int32 `json:"appid"`
|
||||
Table string `json:"table"`
|
||||
Col string `json:"col"`
|
||||
}
|
||||
@ -82,7 +82,7 @@ func (this BehaviorAnalysisController) GetValues(ctx *fiber.Ctx) error {
|
||||
return this.Error(ctx, err)
|
||||
}
|
||||
|
||||
appid := strconv.Itoa(reqData.Appid)
|
||||
appid := strconv.Itoa(int(reqData.Appid))
|
||||
table := reqData.Table
|
||||
col := reqData.Col
|
||||
|
||||
|
@ -13,7 +13,7 @@ func NewEsClient(address []string, username, password string) (esClient *elastic
|
||||
optList = append(optList, elastic.SetBasicAuth(username, password))
|
||||
}
|
||||
|
||||
esClient, err = elastic.NewClient(optList...)
|
||||
esClient, err = elastic.NewSimpleClient(optList...)
|
||||
|
||||
return
|
||||
}
|
||||
|
12
model/app.go
12
model/app.go
@ -1,18 +1,18 @@
|
||||
package model
|
||||
|
||||
type App struct {
|
||||
Page uint64 `json:"page" db:"-"`
|
||||
Limit uint64 `json:"limit" db:"-"`
|
||||
IsClose *int `db:"is_close" json:"is_close"`
|
||||
Id int `db:"id" json:"id"`
|
||||
CreateBy int `db:"create_by" json:"create_by"`
|
||||
UpdateBy int `db:"update_by" json:"update_by"`
|
||||
SaveMonth int `db:"save_mouth" json:"save_mouth"`
|
||||
AppName string `db:"app_name" json:"app_name"`
|
||||
Descibe string `db:"descibe" json:"descibe"`
|
||||
AppId string `db:"app_id" json:"app_id"`
|
||||
AppKey string `db:"app_key" json:"app_key"`
|
||||
CreateBy int `db:"create_by" json:"create_by"`
|
||||
UpdateBy int `db:"update_by" json:"update_by"`
|
||||
CreateTime string `db:"create_time" json:"create_time"`
|
||||
UpdateTime string `db:"update_time" json:"update_time"`
|
||||
AppManager string `db:"app_manager" json:"app_manager"`
|
||||
SaveMonth int `db:"save_mouth" json:"save_mouth"`
|
||||
IsClose *int `db:"is_close" json:"is_close"`
|
||||
Page uint64 `json:"page" db:"-"`
|
||||
Limit uint64 `json:"limit" db:"-"`
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ type Config struct {
|
||||
}
|
||||
|
||||
type ManagerConfig struct{
|
||||
Port int `json:"port"` //铸龙分析系统http启动端口
|
||||
Port uint16 `json:"port"` //铸龙分析系统http启动端口
|
||||
CkQueryLimit int `json:"ckQueryLimit"` //clickhouse 查询限流器阈值
|
||||
CkQueryExpiration int `json:"ckQueryExpiration"` //clickhouse 查询限流器阈值
|
||||
JwtSecret string `json:"jwtSecret"`
|
||||
@ -39,7 +39,7 @@ type SinkerConfig struct {
|
||||
ReportAcceptStatus BatchConfig `json:"reportAcceptStatus"`
|
||||
ReportData2CK BatchConfig `json:"reportData2CK"`
|
||||
RealTimeWarehousing BatchConfig `json:"realTimeWarehousing"`
|
||||
PprofHttpPort int `json:"pprofHttpPort"`
|
||||
PprofHttpPort uint16 `json:"pprofHttpPort"`
|
||||
}
|
||||
|
||||
type RedisConfig struct {
|
||||
@ -80,7 +80,7 @@ type MysqlConfig struct {
|
||||
}
|
||||
|
||||
type ReportConfig struct {
|
||||
ReportPort int `json:"reportPort"`//上报程序启动端口
|
||||
ReportPort uint16 `json:"reportPort"`//上报程序启动端口
|
||||
ReadTimeout int `json:"readTimeout"`
|
||||
WriteTimeout int `json:"writeTimeout"`
|
||||
MaxConnsPerIP int `json:"maxConnsPerIP"`
|
||||
@ -116,11 +116,11 @@ func (this *Config) GetKafkaCfgProducerType() string {
|
||||
}
|
||||
|
||||
type KafkaCfg struct {
|
||||
NumPartitions int32 `json:"numPartitions"`
|
||||
Addresses []string `json:"addresses"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
ReportTopicName string `json:"reportTopicName"`
|
||||
NumPartitions int32 `json:"numPartitions"`
|
||||
ConsumerGroupName string `json:"consumerGroupName"`
|
||||
RealTimeDataGroup string `json:"realTimeDataGroup"`
|
||||
ReportData2CKGroup string `json:"reportData2CKGroup"`
|
||||
|
@ -10,9 +10,9 @@ import (
|
||||
// GmUserModel BI用户
|
||||
type GmUserModel struct {
|
||||
ID int32 `json:"id" db:"id"`
|
||||
RoleId int32 `json:"role_id" db:"role_id"`
|
||||
Username string `json:"username" db:"username"`
|
||||
Password string `json:"password" db:"password"`
|
||||
RoleId int32 `json:"role_id" db:"role_id"`
|
||||
Realname string `json:"realname" db:"realname"`
|
||||
CreateTime string `db:"create_time" json:"create_time"`
|
||||
UpdateTime string `db:"update_time" json:"update_time"`
|
||||
|
@ -44,11 +44,8 @@ func (this *ReportData2CK) Flush() (err error) {
|
||||
|
||||
rowsMap := map[string][][]interface{}{}
|
||||
for _, data := range this.buffer {
|
||||
|
||||
for tableName, metric := range data {
|
||||
|
||||
rows := [][]interface{}{}
|
||||
|
||||
if _, haveKey := rowsMap[tableName]; haveKey {
|
||||
rows = rowsMap[tableName]
|
||||
} else {
|
||||
@ -98,7 +95,6 @@ func (this *ReportData2CK) Flush() (err error) {
|
||||
logs.Logger.Error("CK入库失败", zap.Error(err))
|
||||
return false
|
||||
}
|
||||
log.Println("insertSql",insertSql)
|
||||
stmt, err := tx.Prepare(insertSql)
|
||||
if err != nil {
|
||||
logs.Logger.Error("CK入库失败", zap.Error(err))
|
||||
|
@ -42,7 +42,7 @@ func Init() *App {
|
||||
Rbac,
|
||||
)
|
||||
|
||||
runRouterGroupFn(
|
||||
return runRouterGroupFn(
|
||||
app,
|
||||
runOperaterLog,
|
||||
runGmUser,
|
||||
@ -53,13 +53,13 @@ func Init() *App {
|
||||
runApp,
|
||||
runUserGroup,
|
||||
)
|
||||
return app
|
||||
}
|
||||
|
||||
type routerGroupFn func(app *App)
|
||||
|
||||
func runRouterGroupFn(app *App, fns ...routerGroupFn) {
|
||||
func runRouterGroupFn(app *App, fns ...routerGroupFn) *App {
|
||||
for _, fn := range fns {
|
||||
fn(app)
|
||||
}
|
||||
return app
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user