切换导航条
此项目
正在载入...
登录
allied-creation
/
allied-creation-gateway
·
提交
转到一个项目
GitLab
转到群组
项目
活动
文件
提交
管道
0
构建
0
图表
里程碑
问题
0
合并请求
0
成员
标记
维基
派生
网络
创建新的问题
下载为
邮件补丁
差异文件
浏览文件
作者
tangxuhui
3 years ago
提交
353add25260098b8fc81f835a59606789f9eaa28
1 个父辈
8391ee6c
添加日志文件
隐藏空白字符变更
内嵌
并排对比
正在显示
8 个修改的文件
包含
157 行增加
和
16 行删除
deploy/k8s/dev/allied-creation-gateway.yaml
pkg/application/web/cooperationApplication/service/cooperation_application.go
pkg/constant/common.go
pkg/infrastructure/service_gateway/allied_creation_cooperation/param_cooperation_application.go
pkg/log/beego_log.go
pkg/log/logger.go
pkg/port/beego/controllers/common_controller.go
pkg/port/beego/routers/common_router.go
deploy/k8s/dev/allied-creation-gateway.yaml
查看文件 @
353add2
...
...
@@ -91,6 +91,8 @@ spec:
value
:
"
"
-
name
:
LOG_LEVEL
value
:
"
debug"
-
name
:
LOG_TYPE
value
:
file
-
name
:
ERROR_BASE_CODE
value
:
"
1"
-
name
:
ERROR_BASE_CODE_MULTIPLE
...
...
pkg/application/web/cooperationApplication/service/cooperation_application.go
查看文件 @
353add2
...
...
@@ -70,6 +70,7 @@ func (cooperationApplicationService *CooperationApplicationService) ListCooperat
PageNumber
:
listCooperationApplicationQuery
.
PageNumber
,
PageSize
:
listCooperationApplicationQuery
.
PageSize
,
CompanyId
:
int
(
listCooperationApplicationQuery
.
Operator
.
CompanyId
),
OrgIds
:
listCooperationApplicationQuery
.
Operator
.
OrgIds
,
IsCanceled
:
3
,
})
if
err
!=
nil
{
...
...
pkg/constant/common.go
查看文件 @
353add2
...
...
@@ -8,7 +8,8 @@ import (
const
SERVICE_NAME
=
"allied-creation-gateway"
var
LOG_LEVEL
=
"debug"
var
LOG_TYPE
=
"console"
var
LOG_FILE
=
"app.log"
var
HTTP_PORT
int
=
8083
//天联共创基础模块
...
...
@@ -30,6 +31,9 @@ func init() {
if
os
.
Getenv
(
"LOG_LEVEL"
)
!=
""
{
LOG_LEVEL
=
os
.
Getenv
(
"LOG_LEVEL"
)
}
if
os
.
Getenv
(
"LOG_TYPE"
)
!=
""
{
LOG_TYPE
=
os
.
Getenv
(
"LOG_TYPE"
)
}
if
os
.
Getenv
(
"ALLIED_CREATION_BASIC_HOST"
)
!=
""
{
ALLIED_CREATION_BASIC_HOST
=
os
.
Getenv
(
"ALLIED_CREATION_BASIC_HOST"
)
}
...
...
pkg/infrastructure/service_gateway/allied_creation_cooperation/param_cooperation_application.go
查看文件 @
353add2
...
...
@@ -161,17 +161,18 @@ type (
//查询共创申请
type
(
ReqCooperationApplicationSearch
struct
{
ApplicantName
string
`json:"applicantName"`
//申请人姓名
CooperationApplicationStatus
int
`json:"cooperationApplicationStatus"`
//共创申请审核状态,1待审核,2已同意,3已拒绝
CooperationProjectName
string
`json:"cooperationProjectName"`
//共创项目名称
CooperationProjectNumber
string
`json:"cooperationProjectNumber"`
//共创项目编号
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
CompanyId
int
`json:"companyId"`
OrgId
int64
`json:"orgId"`
// 组织机构ID
UserId
int64
`json:"userId"`
UserBaseId
int64
`json:"userBaseId"`
IsCanceled
int
`json:"isCanceled"`
//1正常,2取消,3所有
ApplicantName
string
`json:"applicantName"`
//申请人姓名
CooperationApplicationStatus
int
`json:"cooperationApplicationStatus"`
//共创申请审核状态,1待审核,2已同意,3已拒绝
CooperationProjectName
string
`json:"cooperationProjectName"`
//共创项目名称
CooperationProjectNumber
string
`json:"cooperationProjectNumber"`
//共创项目编号
PageNumber
int
`json:"pageNumber"`
PageSize
int
`json:"pageSize"`
CompanyId
int
`json:"companyId"`
OrgId
int64
`json:"orgId"`
// 组织机构ID
OrgIds
[]
int64
`json:"orgIds"`
// 组织机构ID
UserId
int64
`json:"userId"`
UserBaseId
int64
`json:"userBaseId"`
IsCanceled
int
`json:"isCanceled"`
//1正常,2取消,3所有
}
DataCooperationApplicationSearch
struct
{
...
...
pkg/log/beego_log.go
0 → 100644
查看文件 @
353add2
package
log
import
(
"bytes"
"encoding/json"
"fmt"
"io"
"strconv"
"github.com/beego/beego/v2/core/logs"
"github.com/linmadan/egglib-go/log"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
)
type
LoggerConfig
struct
{
Level
int
`json:"level,omitempty"`
Filename
string
`json:"filename,omitempty"`
MaxSize
int
`json:"maxsize,omitempty"`
MaxBackups
int
`json:"max_backups,omitempty"`
MaxAge
int
`json:"max_age,omitempty"`
Compress
bool
`json:"compress,omitempty"`
}
type
BeegoLog
struct
{
serviceName
string
beeLogger
*
logs
.
BeeLogger
}
var
_
log
.
Logger
=
&
BeegoLog
{}
func
NewBeegoLog
(
conf
LoggerConfig
)
*
BeegoLog
{
logger
:=
logs
.
GetBeeLogger
()
logger
.
SetLevel
(
conf
.
Level
)
if
constant
.
LOG_TYPE
==
"file"
{
// 日志存储到文件
confByte
,
_
:=
json
.
Marshal
(
conf
)
err
:=
logger
.
SetLogger
(
logs
.
AdapterFile
,
string
(
confByte
))
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
return
nil
}
}
else
{
// 日志输出到控制台
err
:=
logger
.
SetLogger
(
logs
.
AdapterConsole
,
`{"level":7,"color":true}`
)
if
err
!=
nil
{
fmt
.
Println
(
err
.
Error
())
return
nil
}
}
logger
.
SetPrefix
(
constant
.
SERVICE_NAME
)
logger
.
EnableFuncCallDepth
(
true
)
logger
.
SetLogFuncCallDepth
(
5
)
return
&
BeegoLog
{
beeLogger
:
logger
,
}
}
func
(
logger
*
BeegoLog
)
AddHook
(
write
io
.
Writer
)
{
}
func
(
logger
*
BeegoLog
)
SetServiceName
(
serviceName
string
)
{
logger
.
serviceName
=
serviceName
}
func
(
logger
*
BeegoLog
)
SetLevel
(
level
string
)
{
ilv
,
err
:=
strconv
.
Atoi
(
level
)
if
err
!=
nil
{
ilv
=
logs
.
LevelDebug
}
logger
.
beeLogger
.
SetLevel
(
ilv
)
}
func
(
logger
*
BeegoLog
)
Trace
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
logs
.
Trace
(
msg
,
appends
)
}
func
(
logger
*
BeegoLog
)
Debug
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
appendsJson
,
_
:=
json
.
Marshal
(
appends
)
if
appendsJson
==
nil
{
logs
.
Debug
(
msg
,
make
(
map
[
string
]
interface
{},
0
))
}
else
{
var
out
bytes
.
Buffer
err
:=
json
.
Indent
(
&
out
,
appendsJson
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
msg
)
return
}
logs
.
Debug
(
msg
,
out
.
String
())
}
}
func
(
logger
*
BeegoLog
)
Info
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
appendsJson
,
_
:=
json
.
Marshal
(
appends
)
if
appendsJson
==
nil
{
logs
.
Info
(
msg
,
make
(
map
[
string
]
interface
{},
0
))
}
else
{
var
out
bytes
.
Buffer
err
:=
json
.
Indent
(
&
out
,
appendsJson
,
""
,
" "
)
if
err
!=
nil
{
fmt
.
Println
(
msg
)
return
}
logs
.
Info
(
msg
,
out
.
String
())
}
}
func
(
logger
*
BeegoLog
)
Warn
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
logs
.
Warn
(
msg
,
appends
)
}
func
(
logger
*
BeegoLog
)
Error
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
logs
.
Error
(
msg
,
appends
)
}
func
(
logger
*
BeegoLog
)
Fatal
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
logs
.
Error
(
msg
,
appends
)
}
func
(
logger
*
BeegoLog
)
Panic
(
msg
string
,
appends
...
map
[
string
]
interface
{})
{
logs
.
Error
(
msg
,
appends
)
}
...
...
pkg/log/logger.go
查看文件 @
353add2
...
...
@@ -4,13 +4,18 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/constant"
"github.com/linmadan/egglib-go/log"
"github.com/linmadan/egglib-go/log/logrus"
)
var
Logger
log
.
Logger
func
init
()
{
Logger
=
logrus
.
NewLogrusLogger
()
Logger
.
SetServiceName
(
constant
.
SERVICE_NAME
)
Logger
.
SetLevel
(
constant
.
LOG_LEVEL
)
// Logger = logrus.NewLogrusLogger()
// Logger.SetServiceName(constant.SERVICE_NAME)
// Logger.SetLevel(constant.LOG_LEVEL)
// //
Logger
=
NewBeegoLog
(
LoggerConfig
{
Filename
:
constant
.
LOG_FILE
,
Level
:
7
,
MaxSize
:
1024
*
1024
*
2
,
})
}
...
...
pkg/port/beego/controllers/common_controller.go
查看文件 @
353add2
package
controllers
import
(
"io/ioutil"
"github.com/linmadan/egglib-go/web/beego"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/application/common/service"
...
...
@@ -33,3 +35,8 @@ func (controller *CommonController) AppSharing() {
data
,
err
:=
commonService
.
AppSharing
()
controller
.
Response
(
data
,
err
)
}
func
(
controller
*
CommonController
)
LogData
()
{
bytes
,
_
:=
ioutil
.
ReadFile
(
"./app.log"
)
controller
.
Ctx
.
WriteString
(
string
(
bytes
))
}
...
...
pkg/port/beego/routers/common_router.go
查看文件 @
353add2
...
...
@@ -9,4 +9,5 @@ func init() {
web
.
Router
(
"/v1/common/dictionary/search"
,
&
controllers
.
CommonController
{},
"Post:GetDictionaryByCode"
)
web
.
Router
(
"/v1/common/version/getLatestVersionInfo"
,
&
controllers
.
CommonController
{},
"Post:LatestVersionInfo"
)
web
.
Router
(
"/v1/common/app-sharing"
,
&
controllers
.
CommonController
{},
"Post:AppSharing"
)
web
.
Router
(
"/log"
,
&
controllers
.
CommonController
{},
"Get:LogData"
)
}
...
...
请
注册
或
登录
后发表评论