Skip to content

Commit

Permalink
[feature]: Support publish company notice
Browse files Browse the repository at this point in the history
  • Loading branch information
LZS911 committed Nov 3, 2023
1 parent 0d3caf7 commit f02af27
Show file tree
Hide file tree
Showing 18 changed files with 470 additions and 20 deletions.
18 changes: 17 additions & 1 deletion src/api/SqlManage/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import {
import {
IGetSqlManageListResp,
IBatchUpdateSqlManageReq,
IBaseRes
IBaseRes,
IGetSqlManageRuleTipsResp
} from '../common.d';

export interface IGetSqlManageListParams {
Expand All @@ -32,6 +33,10 @@ export interface IGetSqlManageListParams {

filter_status?: GetSqlManageListFilterStatusEnum;

filter_rule_name?: string;

filter_db_type?: string;

page_index: number;

page_size: number;
Expand Down Expand Up @@ -63,4 +68,15 @@ export interface IExportSqlManageV1Params {
filter_last_audit_start_time_to?: string;

filter_status?: exportSqlManageV1FilterStatusEnum;

filter_db_type?: string;

filter_rule_name?: string;
}

export interface IGetSqlManageRuleTipsParams {
project_name: string;
}

export interface IGetSqlManageRuleTipsReturn
extends IGetSqlManageRuleTipsResp {}
19 changes: 18 additions & 1 deletion src/api/SqlManage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ import {
IGetSqlManageListReturn,
IBatchUpdateSqlManageParams,
IBatchUpdateSqlManageReturn,
IExportSqlManageV1Params
IExportSqlManageV1Params,
IGetSqlManageRuleTipsParams,
IGetSqlManageRuleTipsReturn
} from './index.d';

class SqlManageService extends ServiceBase {
Expand Down Expand Up @@ -59,6 +61,21 @@ class SqlManageService extends ServiceBase {
options
);
}

public GetSqlManageRuleTips(
params: IGetSqlManageRuleTipsParams,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
const project_name = paramsData.project_name;
delete paramsData.project_name;

return this.get<IGetSqlManageRuleTipsReturn>(
`/v1/projects/${project_name}/sql_manages/rule_tips`,
paramsData,
options
);
}
}

export default new SqlManageService();
51 changes: 51 additions & 0 deletions src/api/common.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import {
WorkflowStepResV1TypeEnum,
WorkflowTemplateDetailResV1AllowSubmitWhenLessAuditLevelEnum,
AuditResDataV2AuditLevelEnum,
DirectAuditFileReqV2SqlTypeEnum,
DirectAuditReqV2SqlTypeEnum,
GetWorkflowTasksItemV2StatusEnum,
WorkflowRecordResV2StatusEnum,
Expand Down Expand Up @@ -358,6 +359,10 @@ export interface ICloneRuleTemplateReqV1 {
new_rule_template_name?: string;
}

export interface ICompanyNotice {
notice_str?: string;
}

export interface ICreateAuditPlanReqV1 {
audit_plan_cron?: string;

Expand Down Expand Up @@ -788,6 +793,14 @@ export interface IGetAuditWhitelistResV1 {
total_nums?: number;
}

export interface IGetCompanyNoticeResp {
code?: number;

data?: ICompanyNotice;

message?: string;
}

export interface IGetCustomRuleResV1 {
code?: number;

Expand Down Expand Up @@ -1362,6 +1375,14 @@ export interface IGetSqlManageListResp {
sql_manage_total_num?: number;
}

export interface IGetSqlManageRuleTipsResp {
code?: number;

data?: IRuleTips[];

message?: string;
}

export interface IGetSyncInstanceTaskListResV1 {
code?: number;

Expand Down Expand Up @@ -2142,6 +2163,12 @@ export interface IRuleResV1 {
type?: string;
}

export interface IRuleRespV1 {
desc?: string;

rule_name?: string;
}

export interface IRuleTemplateDetailResV1 {
db_type?: string;

Expand Down Expand Up @@ -2170,6 +2197,12 @@ export interface IRuleTemplateTipResV1 {
rule_template_name?: string;
}

export interface IRuleTips {
db_type?: string;

rule?: IRuleRespV1[];
}

export interface IRuleTypeV1 {
is_custom_rule_type?: boolean;

Expand Down Expand Up @@ -2552,6 +2585,10 @@ export interface IUpdateAuditWhitelistReqV1 {
value?: string;
}

export interface IUpdateCompanyNoticeReq {
notice_str?: string;
}

export interface IUpdateCurrentUserPasswordReqV1 {
new_password?: string;

Expand Down Expand Up @@ -3176,6 +3213,20 @@ export interface ICreateWorkflowResV2Data {
workflow_id?: string;
}

export interface IDirectAuditFileReqV2 {
file_contents?: string[];

instance_name?: string;

instance_type?: string;

project_name?: string;

schema_name?: string;

sql_type?: DirectAuditFileReqV2SqlTypeEnum;
}

export interface IDirectAuditReqV2 {
instance_type?: string;

Expand Down
8 changes: 8 additions & 0 deletions src/api/common.enum.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,14 @@ export enum AuditResDataV2AuditLevelEnum {
'UNKNOWN' = ''
}

export enum DirectAuditFileReqV2SqlTypeEnum {
'sql' = 'sql',

'mybatis' = 'mybatis',

'UNKNOWN' = ''
}

export enum DirectAuditReqV2SqlTypeEnum {
'sql' = 'sql',

Expand Down
11 changes: 11 additions & 0 deletions src/api/companyNotice/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import {
IGetCompanyNoticeResp,
IUpdateCompanyNoticeReq,
IBaseRes
} from '../common.d';

export interface IGetCompanyNoticeReturn extends IGetCompanyNoticeResp {}

export interface IUpdateCompanyNoticeParams extends IUpdateCompanyNoticeReq {}

export interface IUpdateCompanyNoticeReturn extends IBaseRes {}
37 changes: 37 additions & 0 deletions src/api/companyNotice/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* tslint:disable no-identical-functions */
/* tslint:disable no-useless-cast */
/* tslint:disable no-unnecessary-type-assertion */
/* tslint:disable no-big-function */
/* tslint:disable no-duplicate-string */
import ServiceBase from '../Service.base';
import { AxiosRequestConfig } from 'axios';

import {
IGetCompanyNoticeReturn,
IUpdateCompanyNoticeParams,
IUpdateCompanyNoticeReturn
} from './index.d';

class CompanyNoticeService extends ServiceBase {
public getCompanyNotice(options?: AxiosRequestConfig) {
return this.get<IGetCompanyNoticeReturn>(
'/v1/company_notice',
undefined,
options
);
}

public updateCompanyNotice(
params: IUpdateCompanyNoticeParams,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
return this.patch<IUpdateCompanyNoticeReturn>(
'/v1/company_notice',
paramsData,
options
);
}
}

export default new CompanyNoticeService();
9 changes: 7 additions & 2 deletions src/api/sql_audit/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import {
IDirectAuditFileReqV1,
IDirectAuditResV1,
IDirectAuditReqV1,
IDirectAuditReqV2,
IDirectAuditResV2
IDirectAuditFileReqV2,
IDirectAuditResV2,
IDirectAuditReqV2
} from '../common.d';

export interface IDirectAuditFilesV1Params extends IDirectAuditFileReqV1 {}
Expand All @@ -14,6 +15,10 @@ export interface IDirectAuditV1Params extends IDirectAuditReqV1 {}

export interface IDirectAuditV1Return extends IDirectAuditResV1 {}

export interface IDirectAuditFilesV2Params extends IDirectAuditFileReqV2 {}

export interface IDirectAuditFilesV2Return extends IDirectAuditResV2 {}

export interface IDirectAuditV2Params extends IDirectAuditReqV2 {}

export interface IDirectAuditV2Return extends IDirectAuditResV2 {}
14 changes: 14 additions & 0 deletions src/api/sql_audit/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
IDirectAuditFilesV1Return,
IDirectAuditV1Params,
IDirectAuditV1Return,
IDirectAuditFilesV2Params,
IDirectAuditFilesV2Return,
IDirectAuditV2Params,
IDirectAuditV2Return
} from './index.d';
Expand Down Expand Up @@ -40,6 +42,18 @@ class SqlAuditService extends ServiceBase {
);
}

public directAuditFilesV2(
params: IDirectAuditFilesV2Params,
options?: AxiosRequestConfig
) {
const paramsData = this.cloneDeep(params);
return this.post<IDirectAuditFilesV2Return>(
'/v2/audit_files',
paramsData,
options
);
}

public directAuditV2(
params: IDirectAuditV2Params,
options?: AxiosRequestConfig
Expand Down
53 changes: 53 additions & 0 deletions src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { useDispatch } from 'react-redux';
import { NotificationOutlined } from '@ant-design/icons';
import { updateNavModalStatus } from '../../../../store/nav';
import { ModalName } from '../../../../data/ModalName';
import { useRequest } from 'ahooks';
import companyNotice from '../../../../api/companyNotice';
import StorageKey from '../../../../data/StorageKey';
import {
ResponseCode,
CompanyNoticeDisplayStatusEnum,
} from '../../../../data/common';
import LocalStorageWrapper from '../../../../utils/LocalStorageWrapper';

const CompanyNoticeTrigger: React.FC = () => {
const dispatch = useDispatch();

useRequest(
() =>
companyNotice.getCompanyNotice().then((res) => {
if (res.data.code === ResponseCode.SUCCESS) {
if (res.data.data?.notice_str) {
dispatch(
updateNavModalStatus({
modalName: ModalName.Company_Notice,
status: true,
})
);

Check warning on line 27 in src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 28 in src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}

Check warning on line 29 in src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
}),

Check warning on line 30 in src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx

View workflow job for this annotation

GitHub Actions / Coverage annotations (🧪 jest-coverage-report-action)

🧾 Statement is not covered

Warning! Not covered statement
{
ready:
LocalStorageWrapper.get(StorageKey.SHOW_COMPANY_NOTICE) ===
CompanyNoticeDisplayStatusEnum.NotDisplayed,
}
);

return (
<NotificationOutlined
className="header-notification-icon"
onClick={() => {
dispatch(
updateNavModalStatus({
modalName: ModalName.Company_Notice,
status: true,
})
);
}}
/>
);
};

export default CompanyNoticeTrigger;
Loading

0 comments on commit f02af27

Please sign in to comment.