Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
so-operation-api
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
smart-operation
so-operation-api
Commits
9ab57916
Commit
9ab57916
authored
Jul 06, 2023
by
黄智
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
字典调整
parent
27aaee75
Changes
8
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
786 additions
and
15 deletions
+786
-15
src/bean/vo/request/dict.go
src/bean/vo/request/dict.go
+2
-0
src/controller/dict.go
src/controller/dict.go
+24
-2
src/controller/log_management.go
src/controller/log_management.go
+159
-0
src/router/dict.go
src/router/dict.go
+9
-7
src/router/logmanagementrouter.go
src/router/logmanagementrouter.go
+37
-0
src/router/router.go
src/router/router.go
+2
-0
src/service/component_dict.go
src/service/component_dict.go
+28
-6
src/service/log_management.go
src/service/log_management.go
+525
-0
No files found.
src/bean/vo/request/dict.go
View file @
9ab57916
...
...
@@ -7,6 +7,8 @@ type DictReq struct {
Status
int
`json:"status" form:"status"`
Class
int
`json:"class" form:"class" binding:"oneof=0 1 2 3 4 5 6 7 8 9 10 11 12 13 14"`
//组件分类(1开发语言与版本 2中间件类型与中间件 3云组件类型 4模块类型 5所属区域 6操作系统 7对象类型 8SQL类型 9调研评估结果 10任务阶段 11测试文档类型 12验收问题类型 13Q&A问题类型 14文档类型)
ParentId
string
`json:"parent_id" form:"parent_id"`
//父级ID
Search
string
`json:"search" form:"search"`
Pagination
}
type
DictTreeReq
struct
{
...
...
src/controller/dict.go
View file @
9ab57916
...
...
@@ -27,13 +27,13 @@ func (d Dict) List(c *gin.Context) {
svc
:=
new
(
service
.
Dict
)
svc
.
Ctx
=
c
svc
.
User
=
header
.
GetUser
(
c
)
result
,
err
:=
svc
.
List
(
req
)
result
,
count
,
err
:=
svc
.
List
(
req
)
if
err
!=
nil
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithError
(
err
),
""
)
return
}
SendJson
Response
(
c
,
resp
.
OK
,
resul
t
)
SendJson
PageResponse
(
c
,
resp
.
OK
,
result
,
coun
t
)
}
// DictTree 字典列表-树结构
...
...
@@ -194,6 +194,28 @@ func (d Dict) DictSort(c *gin.Context) {
SendJsonResponse
(
c
,
resp
.
OK
,
""
)
}
func
(
d
Dict
)
UpdateDictionaryState
(
c
*
gin
.
Context
)
{
id
:=
c
.
Query
(
"id"
)
status
:=
c
.
Query
(
"status"
)
if
id
==
""
||
status
==
""
{
SendJsonResponse
(
c
,
resp
.
InvalidParam
.
WithData
(
"id 或 status 字段不能为空"
),
""
)
return
}
svc
:=
new
(
service
.
Dict
)
svc
.
Ctx
=
c
svc
.
User
=
header
.
GetUser
(
c
)
total
,
err
:=
svc
.
UpdateDictionaryState
(
id
,
status
)
if
err
!=
nil
{
SendJsonResponse
(
c
,
err
,
nil
)
return
}
if
total
==
0
{
SendJsonResponse
(
c
,
resp
.
FAIL
,
nil
)
return
}
SendJsonResponse
(
c
,
resp
.
OK
,
nil
)
}
// List 组件列表
//func (d Dict) ManageList(c *gin.Context) {
//
...
...
src/controller/log_management.go
0 → 100644
View file @
9ab57916
package
controller
import
(
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/pkg/beagle/resp"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/service"
)
// 系统日志树
func
GetSystemLoggerTree
(
c
*
gin
.
Context
)
{
search
:=
c
.
Query
(
"logTime"
)
svc
:=
service
.
LogManagement
{
User
:
header
.
GetUser
(
c
)}
if
dir
,
err
:=
svc
.
GetSysLogDir
(
search
);
err
!=
nil
{
SendJsonResponse
(
c
,
err
,
""
)
}
else
{
SendJsonResponse
(
c
,
resp
.
OK
,
dir
)
}
}
// 系统日志
func
GetSystemLog
(
c
*
gin
.
Context
)
{
name
:=
c
.
Param
(
"name"
)
search
:=
c
.
Query
(
"search"
)
logLevel
:=
c
.
Query
(
"logLevel"
)
svc
:=
service
.
LogManagement
{
User
:
header
.
GetUser
(
c
)}
if
logs
,
err
:=
svc
.
GetSysLog
(
logLevel
,
search
,
name
);
err
!=
nil
{
SendJsonResponse
(
c
,
err
,
""
)
}
else
{
SendJsonResponse
(
c
,
resp
.
OK
,
logs
)
}
}
// 用户账户审计列表
//func LogUserAccountAuditList(c *gin.Context) {
// params := request.LogManagementListReq{}
// // 绑定分页数据
// if err := c.ShouldBindQuery(¶ms); err != nil {
// SendJsonResponse(c, res.ParamsParserError.ErrorDetail(err), nil)
// return
// }
// // 分页数据初始化 limit page Offset
// params.PageInfo = params.PageInfo.InitPage()
// svc := service.LogManagement{User: util.GetContextUser(c)}
// list, count, err := svc.LogUserAccountAuditList(¶ms)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonPageResponse(c, err, list, count)
//}
//
//// 用户账户审计列表导出LogUserAccountAuditExport
//func LogUserAccountAuditExport(c *gin.Context) {
// params := request.LogManagementListReq{}
// // 绑定分页数据
// if err := c.ShouldBindQuery(¶ms); err != nil {
// SendJsonResponse(c, res.ParamsParserError.ErrorDetail(err), nil)
// return
// }
// // 分页数据初始化 limit page Offset
// params.PageInfo = params.PageInfo.InitPage()
// svc := service.LogManagement{User: util.GetContextUser(c)}
// file, fileName, err := svc.LogUserAccountAuditExport(¶ms)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName)) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
// c.Writer.Header().Add("Content-Type", "application/octet-stream")
// c.Writer.Header().Add("Content-Transfer-Encoding", "binary")
// _ = file.Write(c.Writer)
//
//}
//
//// 用户行为审计列表
//func LogUserBehaviorList(c *gin.Context) {
// params := request.LogUserBehaviorListReq{}
// // 绑定分页数据
// if err := c.ShouldBindQuery(¶ms); err != nil {
// SendJsonResponse(c, res.ParamsParserError.ErrorDetail(err), nil)
// return
// }
// // 分页数据初始化 limit page Offset
// params.PageInfo = params.PageInfo.InitPage()
// svc := service.LogManagement{User: util.GetContextUser(c)}
// var (
// list interface{}
// count int64
// err error
// )
// //是否ES查询用户行为审计信息
// if conf.Options.IsBehaviorToES {
// list, count, err = svc.LogUserBehaviorListEs(¶ms)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// } else {
// list, count, err = svc.LogUserBehaviorList(¶ms)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// }
// SendJsonPageResponse(c, nil, list, count)
//}
//
//// 用户行为审计列表导出
//func LogUserBehaviorListExport(c *gin.Context) {
// params := request.LogUserBehaviorListReq{}
// // 绑定分页数据
// if err := c.ShouldBindQuery(¶ms); err != nil {
// SendJsonResponse(c, res.ParamsParserError.ErrorDetail(err), nil)
// return
// }
// // 分页数据初始化 limit page Offset
// params.PageInfo = params.PageInfo.InitPage()
// svc := service.LogManagement{User: util.GetContextUser(c)}
// file, fileName, err := svc.LogUserBehaviorListExport(¶ms)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// c.Writer.Header().Add("Content-Disposition", fmt.Sprintf("attachment; filename=%s", fileName)) //fmt.Sprintf("attachment; filename=%s", filename)对下载的文件重命名
// c.Writer.Header().Add("Content-Type", "application/octet-stream")
// c.Writer.Header().Add("Content-Transfer-Encoding", "binary")
// _ = file.Write(c.Writer)
//}
//
//func LogUserBehaviorDetail(c *gin.Context) {
// id := c.Param("id")
// if id == "" {
// SendJsonResponse(c, res.ParamsMissError.ErrorDetail(errors.New("id必填")), nil)
// return
// }
// svc := service.LogManagement{User: util.GetContextUser(c)}
// data, err := svc.LogUserBehaviorDetail(id)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonResponse(c, nil, data)
//}
//
//func LogUserBehaviorDelete(c *gin.Context) {
// ids := strings.Split(c.Query("ids"), ",")
// if len(ids) == 0 {
// SendJsonResponse(c, res.ParamsMissError.ErrorDetail(errors.New("ids必填")), nil)
// return
// }
// svc := service.LogManagement{User: util.GetContextUser(c)}
// err := svc.LogUserBehaviorDelete(ids)
// if err != nil {
// SendJsonResponse(c, err, nil)
// return
// }
// SendJsonResponse(c, nil, "删除成功")
//}
src/router/dict.go
View file @
9ab57916
...
...
@@ -22,6 +22,8 @@ func initDictRoute(e *gin.Engine) {
base
.
GET
(
"/tree"
,
dict
.
DictTree
)
//字典列表-树结构
base
.
GET
(
"/classList"
,
dict
.
ClassList
)
//字典分类列表
base
.
PUT
(
"/sort"
,
dict
.
DictSort
)
//字典排序
base
.
PUT
(
"//state"
,
dict
.
UpdateDictionaryState
)
//字典排序
//base.GET("/manage_list", dict.ManageList) //字典管理列表
}
src/router/logmanagementrouter.go
0 → 100644
View file @
9ab57916
package
router
import
(
"fmt"
"github.com/gin-gonic/gin"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/common/conf"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/controller"
"gitlab.wodcloud.com/smart-operation/so-operation-api/src/router/middleware/header"
)
// 初始化日志管理路由
func
InitLogManagementRouter
(
e
*
gin
.
Engine
)
{
logger
:=
e
.
Group
(
fmt
.
Sprintf
(
"%s/log"
,
conf
.
Options
.
Prefix
),
header
.
SetContext
)
{
systemLog
:=
logger
.
Group
(
"/system"
,
header
.
SetContext
)
{
systemLog
.
GET
(
"tree"
,
controller
.
GetSystemLoggerTree
)
//系统日志树
systemLog
.
GET
(
"log"
,
controller
.
GetSystemLog
)
//系统日志
}
//userAccountAudit := logger.Group("/userAccountAudit", header.SetUserToContext)
//{
// //用户账户审计:
// userAccountAudit.GET("list", controller.LogUserAccountAuditList, log.AddLogMiddleware("用户账户审计", "/list", constant.OpTypeIntMap[constant.Find])) //用户账户审计列表
// userAccountAudit.GET("list/export", controller.LogUserAccountAuditExport, log.AddLogMiddleware("用户账户审计", "/export", constant.OpTypeIntMap[constant.Export])) //用户账户审计列表导出
//
//}
//userBehavior := logger.Group("userBehavior", header.SetUserToContext)
//{
// //用户行为审计:
// userBehavior.GET("list", controller.LogUserBehaviorList, log.AddLogMiddleware("用户行为审计", "/list", constant.OpTypeIntMap[constant.Find])) //用户行为审计列表
// userBehavior.GET("list/export", controller.LogUserBehaviorListExport, log.AddLogMiddleware("用户行为审计", "/export", constant.OpTypeIntMap[constant.Export])) //用户行为审计列表导出
// userBehavior.GET("detail/:id", controller.LogUserBehaviorDetail) //用户行为审计详情
// userBehavior.DELETE("delete", controller.LogUserBehaviorDelete) //用户行为审计删除
//}
}
}
src/router/router.go
View file @
9ab57916
...
...
@@ -49,6 +49,8 @@ func Load(r *gin.Engine, middleware ...gin.HandlerFunc) {
InitPreferenceConfigRouter
(
r
)
// 初始化访问控制管理路由
InitAccessRuleRouter
(
r
)
// 初始化日志管理
InitLogManagementRouter
(
r
)
// 初始化指标配置路由
InitMetricConfigRouter
(
r
)
// 初始化预警规则配置路由
...
...
src/service/component_dict.go
View file @
9ab57916
...
...
@@ -55,12 +55,12 @@ func (c *Dict) Check(id, parentId string, name string) (err error) {
return
}
func
(
c
*
Dict
)
List
(
req
request
.
DictReq
)
(
dictListRes
[]
*
response
.
DictListRes
,
err
error
)
{
func
(
c
*
Dict
)
List
(
req
request
.
DictReq
)
(
dictListRes
[]
*
response
.
DictListRes
,
count
int64
,
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
err
=
resp
.
DbConnectError
.
WithError
(
err
)
return
dictListRes
,
err
return
dictListRes
,
0
,
err
}
session
:=
db
.
NewSession
()
...
...
@@ -79,10 +79,15 @@ func (c *Dict) List(req request.DictReq) (dictListRes []*response.DictListRes, e
if
req
.
Status
!=
0
{
session
.
Where
(
"status = ? "
,
req
.
Status
)
}
if
req
.
Search
!=
""
{
keyword
:=
util
.
SpecialEscape
(
req
.
Search
)
session
.
Where
(
"name like ?"
,
"%"
+
keyword
+
"%"
)
}
err
=
session
.
OrderBy
(
" class,sort"
)
.
Find
(
&
dictListRes
)
count
,
err
=
session
.
OrderBy
(
" class,sort"
)
.
Limit
(
req
.
GetPageSize
(),
(
req
.
GetPage
()
-
1
)
*
req
.
GetPageSize
())
.
FindAndCount
(
&
dictListRes
)
if
err
!=
nil
{
return
dictListRes
,
resp
.
DbSelectError
.
WithError
(
err
)
return
dictListRes
,
0
,
resp
.
DbSelectError
.
WithError
(
err
)
}
return
}
...
...
@@ -90,9 +95,9 @@ func (c *Dict) List(req request.DictReq) (dictListRes []*response.DictListRes, e
func
(
c
*
Dict
)
DictTree
(
req
request
.
DictTreeReq
)
(
componentDictTreeRes
[]
*
response
.
DictListRes
,
err
error
)
{
listReq
:=
request
.
DictReq
{
Class
:
req
.
Class
,
ParentId
:
""
,
ParentId
:
req
.
ParentId
,
}
componentDictList
,
err
:=
c
.
List
(
listReq
)
componentDictList
,
_
,
err
:=
c
.
List
(
listReq
)
if
err
!=
nil
{
return
}
...
...
@@ -263,6 +268,23 @@ func (c *Dict) DictSort(req []request.DictSortInput) error {
return
err
}
func
(
d
*
Dict
)
UpdateDictionaryState
(
id
string
,
status
string
)
(
total
int64
,
err
error
)
{
db
,
err
:=
client
.
GetDbClient
()
if
err
!=
nil
{
return
0
,
resp
.
DbConnectError
.
ErrorDetail
(
err
)
}
total
,
err
=
db
.
Table
(
"dict"
)
.
Where
(
"id = ? and is_delete = 0 "
,
id
)
.
Update
(
map
[
string
]
interface
{}{
"status"
:
status
,
"updated_by"
:
d
.
User
.
Id
,
})
if
err
!=
nil
{
conf
.
Logger
.
Error
(
"Update UpdateDictionaryState "
,
zap
.
String
(
"erro"
,
err
.
Error
()))
return
0
,
resp
.
DbUpdateError
.
ErrorDetail
(
err
)
}
return
}
//func (c *Dict) ManageList(req request.DictManageListReq) (componentDictTreeRes []*response.DictListRes, err error) {
// listReq := request.DictReq{
// Class: req.Class,
...
...
src/service/log_management.go
0 → 100644
View file @
9ab57916
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment