Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 58 additions & 5 deletions api/dms/service/v1/operation_record.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ type GetOperationRecordListReq struct {
// in:query
FuzzySearchOperateUserName string `json:"fuzzy_search_operate_user_name" query:"fuzzy_search_operate_user_name"`
// in:query
FilterOperateTypeName string `json:"filter_operate_type_name" query:"filter_operate_type_name"`
FuzzySearchOperateContent string `json:"fuzzy_search_operate_content" query:"fuzzy_search_operate_content"`
// in:query
FilterOperateAction string `json:"filter_operate_action" query:"filter_operate_action"`
FilterFuzzyOperateUserName string `json:"filter_fuzzy_operate_user_name" query:"filter_fuzzy_operate_user_name"`
// in:query
FilterOperateTypeNames []string `json:"filter_operate_type_names" query:"filter_operate_type_names"`
// in:query
FilterOperateActions []string `json:"filter_operate_actions" query:"filter_operate_actions"`
// in:query
FilterOperateStatus string `json:"filter_operate_status" query:"filter_operate_status"`
// in:query
// Required: true
PageIndex uint32 `json:"page_index" query:"page_index" validate:"required"`
Expand All @@ -67,7 +73,7 @@ type OperationRecordListItem struct {
OperationAction string `json:"operation_action"`
OperationContent string `json:"operation_content"`
ProjectName string `json:"project_name"`
// enum: ["succeeded","failed"]
// enum: succeeded,failed
Status string `json:"status"`
}

Expand All @@ -76,6 +82,47 @@ type OperationUser struct {
IP string `json:"ip"`
}

// swagger:model GetOperationTypeNameListReply
type GetOperationTypeNameListReply struct {
Data []OperationTypeNameListItem `json:"data"`
base.GenericResp
}

type OperationTypeNameListItem struct {
OperationTypeName string `json:"operation_type_name"`
Desc string `json:"desc"`
}

// swagger:model GetOperationActionListReply
type GetOperationActionListReply struct {
Data []OperationActionListItem `json:"data"`
base.GenericResp
}

type OperationActionListItem struct {
OperationType string `json:"operation_type"`
OperationAction string `json:"operation_action"`
Desc string `json:"desc"`
}

// swagger:model GetOperationUserNameListReply
type GetOperationUserNameListReply struct {
Data []OperationUserNameListItem `json:"data"`
base.GenericResp
}

type OperationUserNameListItem struct {
OperationUserName string `json:"operation_user_name"`
OperationReqIP string `json:"operation_req_ip"`
Desc string `json:"desc"`
}

// swagger:parameters GetOperationUserNameList
type GetOperationUserNameListReq struct {
// in:query
FilterOperateProjectName *string `json:"filter_operate_project_name" query:"filter_operate_project_name"`
}

// swagger:parameters ExportOperationRecordList
type ExportOperationRecordListReq struct {
// in:query
Expand All @@ -87,9 +134,15 @@ type ExportOperationRecordListReq struct {
// in:query
FuzzySearchOperateUserName string `json:"fuzzy_search_operate_user_name" query:"fuzzy_search_operate_user_name"`
// in:query
FilterOperateTypeName string `json:"filter_operate_type_name" query:"filter_operate_type_name"`
FuzzySearchOperateContent string `json:"fuzzy_search_operate_content" query:"fuzzy_search_operate_content"`
// in:query
FilterFuzzyOperateUserName string `json:"filter_fuzzy_operate_user_name" query:"filter_fuzzy_operate_user_name"`
// in:query
FilterOperateTypeNames []string `json:"filter_operate_type_names" query:"filter_operate_type_names"`
// in:query
FilterOperateActions []string `json:"filter_operate_actions" query:"filter_operate_actions"`
// in:query
FilterOperateAction string `json:"filter_operate_action" query:"filter_operate_action"`
FilterOperateStatus string `json:"filter_operate_status" query:"filter_operate_status"`
}

// swagger:response ExportOperationRecordListReply
Expand Down
171 changes: 104 additions & 67 deletions internal/apiserver/service/dms_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,17 +333,11 @@ func (ctl *DMSController) ListGlobalDBServices(c echo.Context) error {
// 200: body:ListGlobalDBServicesTipsReply
// default: body:GenericResp
func (ctl *DMSController) ListGlobalDBServicesTips(c echo.Context) error {
req := new(aV1.ListGlobalDBServicesTipsReq)
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}

currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
reply, err := ctl.DMS.ListGlobalDBServicesTips(c.Request().Context(), req, currentUserUid)
reply, err := ctl.DMS.ListGlobalDBServicesTips(c.Request().Context(), currentUserUid)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
Expand Down Expand Up @@ -1562,11 +1556,8 @@ func (ctl *DMSController) ListMembers(c echo.Context) error {
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}
currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
reply, err := ctl.DMS.ListMembers(c.Request().Context(), req, currentUserUid)

reply, err := ctl.DMS.ListMembers(c.Request().Context(), req)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
Expand Down Expand Up @@ -1685,32 +1676,8 @@ func (ctl *DMSController) ListMemberGroups(c echo.Context) error {
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}
currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
reply, err := ctl.DMS.ListMemberGroups(c.Request().Context(), req, currentUserUid)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
return NewOkRespWithReply(c, reply)
}

// swagger:route GET /v1/dms/projects/{project_uid}/member_groups/tips MemberGroup ListMemberGroupTips
//
// List member group tips.
//
// responses:
// 200: body:ListMemberGroupTipsReply
// default: body:GenericResp
func (ctl *DMSController) ListMemberGroupTips(c echo.Context) error {
req := new(aV1.ListMemberGroupTipsReq)
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}

reply, err := ctl.DMS.ListMemberGroupTips(c.Request().Context(), req.ProjectUid)
reply, err := ctl.DMS.ListMemberGroups(c.Request().Context(), req)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
Expand Down Expand Up @@ -2742,10 +2709,8 @@ func (ctl *DMSController) oauth2Callback(c echo.Context) error {
return NewErrResp(c, err, apiError.APIServerErr)
}

// 1. callbackData.Error 有错误时,前端会回到登录页并展示错误信息
// 2. callbackData.UserExist 为false时,前端会进入手动绑定页面,绑定时调用绑定接口签发tokens
// 3. 没错误且用户存在时,签发tokens登录成功
if callbackData.Error == "" && callbackData.UserExist {
// 只有在用户存在才签发tokens,不存在时后续会重定向到用户绑定页,绑定成功后再签发tokens
if callbackData.UserExist {
dmsToken, dmsCookieExp, err := claims.DmsToken()
if err != nil {
return NewErrResp(c, err, apiError.APIServerErr)
Expand Down Expand Up @@ -3976,32 +3941,6 @@ func (ctl *DMSController) ExportDataExportWorkflow(c echo.Context) error {
return NewOkResp(c)
}

// swagger:route GET /v1/dms/projects/{project_uid}/data_export_workflows/{data_export_workflow_uid}/original-export/download DataExportWorkflows DownloadOriginalDataExportWorkflow
//
// Download unmasked SQL query results as a zip file. Each request runs export in memory; files are not persisted.
//
// responses:
// 200: DownloadOriginalDataExportWorkflowReply
// default: body:GenericResp
func (ctl *DMSController) DownloadOriginalDataExportWorkflow(c echo.Context) error {
req := new(aV1.DownloadOriginalDataExportWorkflowReq)
if err := bindAndValidateReq(c, req); err != nil {
return NewErrResp(c, err, apiError.BadRequestErr)
}
currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
fileName, content, err := ctl.DMS.DownloadOriginalDataExportWorkflow(c.Request().Context(), req, currentUserUid)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
c.Response().Header().Set(echo.HeaderContentDisposition,
mime.FormatMediaType("attachment", map[string]string{"filename": fileName}))

return c.Blob(http.StatusOK, "application/zip", content)
}

// swagger:operation POST /v1/dms/projects/{project_uid}/data_export_tasks DataExportTask AddDataExportTask
//
// Add data_export task.
Expand Down Expand Up @@ -4189,6 +4128,26 @@ func (ctl *DMSController) proxyDownloadDataExportTask(c echo.Context, reportHost
return
}

// swagger:route GET /v1/dms/masking/rules Masking ListMaskingRules
//
// List masking rules.
//
// responses:
// 200: body:ListMaskingRulesReply
// default: body:GenericResp
func (ctl *DMSController) ListMaskingRules(c echo.Context) error {
req := &aV1.ListMaskingRulesReq{}
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}

reply, err := ctl.DMS.ListMaskingRules(c.Request().Context())
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
return NewOkRespWithReply(c, reply)
}

// swagger:route GET /v1/dms/projects/{project_uid}/cb_operation_logs CBOperationLogs ListCBOperationLogs
//
Expand Down Expand Up @@ -5044,6 +5003,84 @@ func (ctl *DMSController) GetOperationRecordList(c echo.Context) error {
return NewOkRespWithReply(c, reply)
}

// swagger:operation GET /v1/dms/operation_records/operation_type_names OperationRecord GetOperationTypeNameList
//
// Get operation type name list.
//
// ---
// responses:
//
// '200':
// description: GetOperationTypeNameListReply
// schema:
// "$ref": "#/definitions/GetOperationTypeNameListReply"
// default:
// description: GenericResp
// schema:
// "$ref": "#/definitions/GenericResp"
func (ctl *DMSController) GetOperationTypeNameList(c echo.Context) error {
reply := getOperationTypeNameListReply(c.Request().Context())
return NewOkRespWithReply(c, reply)
}

// swagger:operation GET /v1/dms/operation_records/operation_actions OperationRecord GetOperationActionList
//
// Get operation action list.
//
// ---
// responses:
//
// '200':
// description: GetOperationActionListReply
// schema:
// "$ref": "#/definitions/GetOperationActionListReply"
// default:
// description: GenericResp
// schema:
// "$ref": "#/definitions/GenericResp"
func (ctl *DMSController) GetOperationActionList(c echo.Context) error {
reply := getOperationActionListReply(c.Request().Context())
return NewOkRespWithReply(c, reply)
}

// swagger:operation GET /v1/dms/operation_records/operation_user_names OperationRecord GetOperationUserNameList
//
// Get operation user name list.
//
// ---
// parameters:
// - name: filter_operate_project_name
// in: query
// type: string
// responses:
//
// '200':
// description: GetOperationUserNameListReply
// schema:
// "$ref": "#/definitions/GetOperationUserNameListReply"
// default:
// description: GenericResp
// schema:
// "$ref": "#/definitions/GenericResp"
func (ctl *DMSController) GetOperationUserNameList(c echo.Context) error {
req := new(aV1.GetOperationUserNameListReq)
err := bindAndValidateReq(c, req)
if nil != err {
return NewErrResp(c, err, apiError.BadRequestErr)
}

currentUserUid, err := jwt.GetUserUidStrFromContext(c)
if err != nil {
return NewErrResp(c, err, apiError.DMSServiceErr)
}

reply, err := ctl.DMS.GetOperationUserNameList(c.Request().Context(), currentUserUid, req.FilterOperateProjectName)
if nil != err {
return NewErrResp(c, err, apiError.DMSServiceErr)
}
return NewOkRespWithReply(c, reply)
}

// swagger:operation GET /v1/dms/operation_records/exports OperationRecord ExportOperationRecordList
//
// Export operation record list.
Expand Down
17 changes: 17 additions & 0 deletions internal/apiserver/service/operation_record_metadata_ce.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//go:build !enterprise

package service

import (
"context"

aV1 "github.com/actiontech/dms/api/dms/service/v1"
)

func getOperationTypeNameListReply(context.Context) *aV1.GetOperationTypeNameListReply {
return &aV1.GetOperationTypeNameListReply{Data: []aV1.OperationTypeNameListItem{}}
}

func getOperationActionListReply(context.Context) *aV1.GetOperationActionListReply {
return &aV1.GetOperationActionListReply{Data: []aV1.OperationActionListItem{}}
}
Loading