wip: alpha version
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.idea
|
||||
.vscode
|
||||
.DS_Store
|
||||
.data
|
||||
*.sqlite
|
54
deployment/database.dev.yml
Normal file
@ -0,0 +1,54 @@
|
||||
version: "3.9"
|
||||
|
||||
services:
|
||||
redis:
|
||||
image: "repository.umisen.com:5000/external/redis:latest"
|
||||
container_name: redis
|
||||
volumes:
|
||||
- .data/redis:/data
|
||||
ports:
|
||||
- "6379:6379"
|
||||
|
||||
pgsql:
|
||||
image: "repository.umisen.com:5000/external/postgres:latest"
|
||||
container_name: pgsql
|
||||
restart: always
|
||||
environment:
|
||||
POSTGRES_USER: ult
|
||||
POSTGRES_PASSWORD: ult@sonar
|
||||
POSTGRES_DB: ult
|
||||
PGDATA: /var/lib/postgresql/data
|
||||
volumes:
|
||||
- .data/pgsql:/var/lib/postgresql
|
||||
ports:
|
||||
- "5432:5432"
|
||||
|
||||
es:
|
||||
image: "repository.umisen.com:5000/external/es:latest"
|
||||
container_name: elk_es
|
||||
restart: always
|
||||
environment:
|
||||
- bootstrap.memory_lock=true
|
||||
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
||||
- discovery.type=single-node
|
||||
ulimits:
|
||||
nproc: 65535
|
||||
memlock:
|
||||
soft: -1
|
||||
hard: -1
|
||||
volumes:
|
||||
- ./data/es/data:/data
|
||||
- ./data/es/logs:/logs
|
||||
- ./data/es/plugins:/plugins
|
||||
ports:
|
||||
- 9200:9200
|
||||
|
||||
kibana:
|
||||
image: "repository.umisen.com:5000/external/kibana:latest"
|
||||
container_name: elk_kibana
|
||||
restart: always
|
||||
environment:
|
||||
ELASTICSEARCH_HOSTS: http://elk_es:9200
|
||||
I18N_LOCALE: zh-CN
|
||||
ports:
|
||||
- 5601:5601
|
28
etc/config.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"name": "ult",
|
||||
"address": "0.0.0.0:80",
|
||||
"_database": {
|
||||
"type": "postgresql",
|
||||
"_type": "mysql",
|
||||
"host": "127.0.0.1",
|
||||
"port": 5432,
|
||||
"db": "ult",
|
||||
"username": "ult",
|
||||
"password": "ult@sonar"
|
||||
},
|
||||
"database": {
|
||||
"type": "sqlite",
|
||||
"path": "db.sqlite",
|
||||
"_path": ":memory:"
|
||||
},
|
||||
"_cache": {
|
||||
"type": "redis",
|
||||
"host": "127.0.0.1",
|
||||
"port": 6379,
|
||||
"username": "",
|
||||
"password": ""
|
||||
},
|
||||
"cache": {
|
||||
"type": "memory"
|
||||
}
|
||||
}
|
16
front/.editorconfig
Normal file
@ -0,0 +1,16 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.ts]
|
||||
quote_type = single
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
42
front/.gitignore
vendored
Normal file
@ -0,0 +1,42 @@
|
||||
# See http://help.github.com/ignore-files/ for more about ignoring files.
|
||||
|
||||
# Compiled output
|
||||
/dist
|
||||
/tmp
|
||||
/out-tsc
|
||||
/bazel-out
|
||||
|
||||
# Node
|
||||
/node_modules
|
||||
npm-debug.log
|
||||
yarn-error.log
|
||||
|
||||
# IDEs and editors
|
||||
.idea/
|
||||
.project
|
||||
.classpath
|
||||
.c9/
|
||||
*.launch
|
||||
.settings/
|
||||
*.sublime-workspace
|
||||
|
||||
# Visual Studio Code
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
.history/*
|
||||
|
||||
# Miscellaneous
|
||||
/.angular/cache
|
||||
.sass-cache/
|
||||
/connect.lock
|
||||
/coverage
|
||||
/libpeerconnection.log
|
||||
testem.log
|
||||
/typings
|
||||
|
||||
# System files
|
||||
.DS_Store
|
||||
Thumbs.db
|
27
front/README.md
Normal file
@ -0,0 +1,27 @@
|
||||
# Front
|
||||
|
||||
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 17.0.3.
|
||||
|
||||
## Development server
|
||||
|
||||
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The application will automatically reload if you change any of the source files.
|
||||
|
||||
## Code scaffolding
|
||||
|
||||
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
|
||||
|
||||
## Build
|
||||
|
||||
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
|
||||
|
||||
## Running unit tests
|
||||
|
||||
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
|
||||
|
||||
## Running end-to-end tests
|
||||
|
||||
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
|
||||
|
||||
## Further help
|
||||
|
||||
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
|
113
front/angular.json
Normal file
@ -0,0 +1,113 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
|
||||
"version": 1,
|
||||
"cli": {
|
||||
"packageManager": "pnpm",
|
||||
"analytics": false
|
||||
},
|
||||
"newProjectRoot": "projects",
|
||||
"projects": {
|
||||
"front": {
|
||||
"projectType": "application",
|
||||
"schematics": {
|
||||
"@schematics/angular:component": {
|
||||
"style": "scss"
|
||||
}
|
||||
},
|
||||
"root": "",
|
||||
"sourceRoot": "src",
|
||||
"prefix": "app",
|
||||
"architect": {
|
||||
"build": {
|
||||
"builder": "@angular-devkit/build-angular:application",
|
||||
"options": {
|
||||
"outputPath": "dist/front",
|
||||
"index": "src/index.html",
|
||||
"browser": "src/main.ts",
|
||||
"polyfills": [
|
||||
"zone.js"
|
||||
],
|
||||
"tsConfig": "tsconfig.app.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/manifest.webmanifest"
|
||||
],
|
||||
"styles": [
|
||||
"@angular/material/prebuilt-themes/indigo-pink.css",
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"budgets": [
|
||||
{
|
||||
"type": "initial",
|
||||
"maximumWarning": "500kb",
|
||||
"maximumError": "1mb"
|
||||
},
|
||||
{
|
||||
"type": "anyComponentStyle",
|
||||
"maximumWarning": "2kb",
|
||||
"maximumError": "4kb"
|
||||
}
|
||||
],
|
||||
"outputHashing": "all",
|
||||
"serviceWorker": "ngsw-config.json"
|
||||
},
|
||||
"development": {
|
||||
"optimization": false,
|
||||
"extractLicenses": false,
|
||||
"sourceMap": true
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "production"
|
||||
},
|
||||
"serve": {
|
||||
"builder": "@angular-devkit/build-angular:dev-server",
|
||||
"options": {
|
||||
"proxyConfig": "src/proxy.conf.json"
|
||||
},
|
||||
"configurations": {
|
||||
"production": {
|
||||
"buildTarget": "front:build:production"
|
||||
},
|
||||
"development": {
|
||||
"buildTarget": "front:build:development"
|
||||
}
|
||||
},
|
||||
"defaultConfiguration": "development"
|
||||
},
|
||||
"extract-i18n": {
|
||||
"builder": "@angular-devkit/build-angular:extract-i18n",
|
||||
"options": {
|
||||
"buildTarget": "front:build"
|
||||
}
|
||||
},
|
||||
"test": {
|
||||
"builder": "@angular-devkit/build-angular:karma",
|
||||
"options": {
|
||||
"polyfills": [
|
||||
"zone.js",
|
||||
"zone.js/testing"
|
||||
],
|
||||
"tsConfig": "tsconfig.spec.json",
|
||||
"inlineStyleLanguage": "scss",
|
||||
"assets": [
|
||||
"src/favicon.ico",
|
||||
"src/assets",
|
||||
"src/manifest.webmanifest"
|
||||
],
|
||||
"styles": [
|
||||
"@angular/material/prebuilt-themes/indigo-pink.css",
|
||||
"src/styles.scss"
|
||||
],
|
||||
"scripts": []
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
30
front/ngsw-config.json
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||
"index": "/index.html",
|
||||
"assetGroups": [
|
||||
{
|
||||
"name": "app",
|
||||
"installMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/favicon.ico",
|
||||
"/index.html",
|
||||
"/manifest.webmanifest",
|
||||
"/*.css",
|
||||
"/*.js"
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"name": "assets",
|
||||
"installMode": "lazy",
|
||||
"updateMode": "prefetch",
|
||||
"resources": {
|
||||
"files": [
|
||||
"/assets/**",
|
||||
"/media/*.(svg|cur|jpg|jpeg|png|apng|webp|avif|gif|otf|ttf|woff|woff2)"
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
44
front/package.json
Normal file
@ -0,0 +1,44 @@
|
||||
{
|
||||
"name": "front",
|
||||
"version": "0.0.0",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
"build": "ng build",
|
||||
"watch": "ng build --watch --configuration development",
|
||||
"test": "ng test"
|
||||
},
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular/animations": "^17.0.0",
|
||||
"@angular/cdk": "17.1.1",
|
||||
"@angular/common": "^17.0.0",
|
||||
"@angular/compiler": "^17.0.0",
|
||||
"@angular/core": "^17.0.0",
|
||||
"@angular/forms": "^17.0.0",
|
||||
"@angular/material": "17.1.1",
|
||||
"@angular/platform-browser": "^17.0.0",
|
||||
"@angular/platform-browser-dynamic": "^17.0.0",
|
||||
"@angular/router": "^17.0.0",
|
||||
"@angular/service-worker": "^17.0.0",
|
||||
"base-64": "^1.0.0",
|
||||
"js-base64": "^3.7.6",
|
||||
"rxjs": "~7.8.0",
|
||||
"tslib": "^2.3.0",
|
||||
"zone.js": "~0.14.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@angular-devkit/build-angular": "^17.0.3",
|
||||
"@angular/cli": "^17.0.3",
|
||||
"@angular/compiler-cli": "^17.0.0",
|
||||
"@types/jasmine": "~5.1.0",
|
||||
"html5-qrcode": "^2.3.8",
|
||||
"jasmine-core": "~5.1.0",
|
||||
"karma": "~6.4.0",
|
||||
"karma-chrome-launcher": "~3.2.0",
|
||||
"karma-coverage": "~2.2.0",
|
||||
"karma-jasmine": "~5.1.0",
|
||||
"karma-jasmine-html-reporter": "~2.1.0",
|
||||
"typescript": "~5.2.2"
|
||||
}
|
||||
}
|
8268
front/pnpm-lock.yaml
generated
Normal file
29
front/src/app/app.component.html
Normal file
@ -0,0 +1,29 @@
|
||||
<div class="title">
|
||||
<mat-toolbar color="primary">
|
||||
<span class="home-button" (click)="router.navigate([''])">NF Flow</span>
|
||||
<span class="example-spacer"></span>
|
||||
@if (user_srv.user().username != "") {
|
||||
<button mat-button class="title-menu" aria-label="title menu button" [matMenuTriggerFor]="menu">
|
||||
{{ 'welcome, '+user_srv.user().username?user_srv.user().username:'Plz Login'}}
|
||||
</button>
|
||||
<mat-menu #menu="matMenu">
|
||||
<button mat-menu-item (click)="router.navigate(['task'])">任务管理</button>
|
||||
<button mat-menu-item (click)="router.navigate(['user'])">用户管理</button>
|
||||
<button mat-menu-item (click)="router.navigate(['log'])">操作日志</button>
|
||||
<button mat-menu-item (click)="user_srv.auth_logout()">退出</button>
|
||||
</mat-menu>
|
||||
}
|
||||
</mat-toolbar>
|
||||
</div>
|
||||
<div class="content">
|
||||
@if (url != 'login') {
|
||||
<div class="side-container">
|
||||
<ul>
|
||||
<li [class]="url === 'task' ? 'active':''" (click)="router.navigate(['task'])">任务管理</li>
|
||||
<li [class]="url === 'user' ? 'active':''" (click)="router.navigate(['user'])">用户管理</li>
|
||||
<li [class]="url === 'log' ? 'active':''" (click)="router.navigate(['log'])">操作日志</li>
|
||||
</ul>
|
||||
</div>
|
||||
}
|
||||
<router-outlet></router-outlet>
|
||||
</div>
|
78
front/src/app/app.component.scss
Normal file
@ -0,0 +1,78 @@
|
||||
|
||||
:host {
|
||||
display: flex;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
width: 100%;
|
||||
flex-direction: column;
|
||||
|
||||
div.title {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
height: 64px;
|
||||
|
||||
span.home-button {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
button.title-menu {
|
||||
margin-left: auto;
|
||||
}
|
||||
}
|
||||
|
||||
div.content {
|
||||
width: 100%;
|
||||
height: calc(100% - 64px);
|
||||
max-height: calc(100% - 64px);
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
|
||||
.side-container {
|
||||
display: flex;
|
||||
width: 235px;
|
||||
max-width: 235px;
|
||||
min-width: 235px;
|
||||
flex-direction: column;
|
||||
border-right: 1px solid #ddd;
|
||||
max-height: 100%;
|
||||
overflow-y: auto;
|
||||
|
||||
|
||||
ul {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
|
||||
li {
|
||||
list-style: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
text-indent: 1rem;
|
||||
width: 100%;
|
||||
height: 48px;
|
||||
font-size: 16px;
|
||||
|
||||
&:hover {
|
||||
background: rgba(239,239,239);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
&.active {
|
||||
background: rgb(221,221,237);
|
||||
color: rgb(60,63,169);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 40rem) {
|
||||
:host {
|
||||
div.content {
|
||||
.side-container {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
front/src/app/app.component.spec.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { AppComponent } from './app.component';
|
||||
|
||||
describe('AppComponent', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [AppComponent],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('should create the app', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app).toBeTruthy();
|
||||
});
|
||||
|
||||
it(`should have the 'front' title`, () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
const app = fixture.componentInstance;
|
||||
expect(app.title).toEqual('front');
|
||||
});
|
||||
|
||||
it('should render title', () => {
|
||||
const fixture = TestBed.createComponent(AppComponent);
|
||||
fixture.detectChanges();
|
||||
const compiled = fixture.nativeElement as HTMLElement;
|
||||
expect(compiled.querySelector('h1')?.textContent).toContain('Hello, front');
|
||||
});
|
||||
});
|
38
front/src/app/app.component.ts
Normal file
@ -0,0 +1,38 @@
|
||||
import { Component } from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {ActivatedRoute, NavigationEnd, Router, RouterOutlet} from '@angular/router';
|
||||
import {MatSidenav, MatSidenavContainer, MatSidenavContent} from "@angular/material/sidenav";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {MatToolbar} from "@angular/material/toolbar";
|
||||
import {MatButton, MatIconButton} from "@angular/material/button";
|
||||
import {UserService} from "./service/user.service";
|
||||
import {MatMenu, MatMenuItem, MatMenuTrigger} from "@angular/material/menu";
|
||||
|
||||
@Component({
|
||||
selector: 'app-root',
|
||||
standalone: true,
|
||||
imports: [CommonModule, RouterOutlet, MatSidenavContent, MatSidenav, MatSidenavContainer, MatIcon, MatToolbar, MatIconButton, MatButton, MatMenuTrigger, MatMenu, MatMenuItem],
|
||||
templateUrl: './app.component.html',
|
||||
styleUrl: './app.component.scss',
|
||||
})
|
||||
export class AppComponent {
|
||||
title = 'front';
|
||||
url = '';
|
||||
|
||||
constructor(
|
||||
public router: Router,
|
||||
public user_srv: UserService,
|
||||
) {
|
||||
this.router.events.subscribe(val => {
|
||||
if (val instanceof NavigationEnd) {
|
||||
let _url = val.url
|
||||
if (_url.startsWith("/")) {
|
||||
_url = _url.slice(1)
|
||||
}
|
||||
_url = _url.split("/")[0]
|
||||
console.log('[D] router val=', _url)
|
||||
this.url = _url
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
22
front/src/app/app.config.ts
Normal file
@ -0,0 +1,22 @@
|
||||
import {ApplicationConfig, isDevMode} from '@angular/core';
|
||||
import {provideRouter} from '@angular/router';
|
||||
|
||||
import {routes} from './app.routes';
|
||||
import {HTTP_INTERCEPTORS, provideHttpClient, withInterceptorsFromDi} from "@angular/common/http";
|
||||
import {alerterInterceptor} from "./interceptor/alerter.interceptor";
|
||||
import {provideAnimations} from '@angular/platform-browser/animations';
|
||||
import { provideServiceWorker } from '@angular/service-worker';
|
||||
|
||||
export const appConfig: ApplicationConfig = {
|
||||
providers: [
|
||||
provideRouter(routes),
|
||||
provideHttpClient(withInterceptorsFromDi()), {
|
||||
provide: HTTP_INTERCEPTORS, useClass: alerterInterceptor, multi: true
|
||||
},
|
||||
provideAnimations(),
|
||||
provideServiceWorker('ngsw-worker.js', {
|
||||
enabled: !isDevMode(),
|
||||
registrationStrategy: 'registerWhenStable:30000'
|
||||
})
|
||||
]
|
||||
};
|
14
front/src/app/app.routes.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {Routes} from '@angular/router';
|
||||
import {HomeComponent} from "./page/home/home.component";
|
||||
import {LoginComponent} from "./page/login/login.component";
|
||||
import {LogComponent} from "./page/log/log.component";
|
||||
import {UserComponent} from "./page/user/user.component";
|
||||
import {TaskComponent} from "./page/task/task.component";
|
||||
|
||||
export const routes: Routes = [
|
||||
{path: "", component: HomeComponent},
|
||||
{path: "login", component: LoginComponent},
|
||||
{path: "task", component: TaskComponent},
|
||||
{path: "log", component: LogComponent},
|
||||
{path: "user", component: UserComponent},
|
||||
];
|
5
front/src/app/component/confirm/confirm.component.html
Normal file
@ -0,0 +1,5 @@
|
||||
<h2 mat-dialog-title>{{data.title}}</h2>
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-button mat-dialog-close>Cancel</button>
|
||||
<button mat-button color="primary" [mat-dialog-close]="true" cdkFocusInitial (click)="confirm()">确认</button>
|
||||
</mat-dialog-actions>
|
23
front/src/app/component/confirm/confirm.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { ConfirmComponent } from './confirm.component';
|
||||
|
||||
describe('ConfirmComponent', () => {
|
||||
let component: ConfirmComponent;
|
||||
let fixture: ComponentFixture<ConfirmComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ConfirmComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(ConfirmComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
20
front/src/app/component/confirm/confirm.component.ts
Normal file
@ -0,0 +1,20 @@
|
||||
import {Component, Inject, signal} from '@angular/core';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import {ConfirmData} from "../../interface/confirm_data";
|
||||
import {MAT_DIALOG_DATA, MatDialogActions, MatDialogClose, MatDialogTitle} from "@angular/material/dialog";
|
||||
import {MatButton} from "@angular/material/button";
|
||||
|
||||
@Component({
|
||||
selector: 'app-confirm',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatDialogTitle, MatDialogActions, MatButton, MatDialogClose],
|
||||
templateUrl: './confirm.component.html',
|
||||
styleUrl: './confirm.component.scss'
|
||||
})
|
||||
export class ConfirmComponent {
|
||||
constructor(@Inject(MAT_DIALOG_DATA) public data: ConfirmData) {}
|
||||
|
||||
confirm() {
|
||||
this.data.confirmed = true
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
<h2 mat-dialog-title>新建用户</h2>
|
||||
<mat-dialog-content class="create-user-content">
|
||||
<mat-form-field>
|
||||
<mat-label>username</mat-label>
|
||||
<input matInput placeholder="username" name="username" [(ngModel)]="new_user.username">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>password</mat-label>
|
||||
<input matInput placeholder="password" type="password" name="password" [(ngModel)]="new_user.password">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>confirm password</mat-label>
|
||||
<input matInput placeholder="confirm password" type="password" name="confirm_password"
|
||||
[(ngModel)]="new_user.confirm_password">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>privilege</mat-label>
|
||||
<mat-select multiple [(ngModel)]="new_user.privileges">
|
||||
@for (privilege of user_srv.user().privileges; track privilege) {
|
||||
<mat-option [value]="privilege.value">{{privilege.label}}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>status</mat-label>
|
||||
<mat-select [(ngModel)]="new_user.status">
|
||||
<mat-option [value]="0">正常</mat-option>
|
||||
<mat-option [value]="1">冻结</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>取消</button>
|
||||
<button mat-raised-button color="primary" (click)="create()">新建</button>
|
||||
</mat-dialog-actions>
|
@ -0,0 +1,14 @@
|
||||
:host {
|
||||
mat-dialog-content.create-user-content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 450px;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 40rem) {
|
||||
:host {
|
||||
mat-dialog-content.create-user-content{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CreateUserDialogComponent } from './create-user-dialog.component';
|
||||
|
||||
describe('CreateUserDialogComponent', () => {
|
||||
let component: CreateUserDialogComponent;
|
||||
let fixture: ComponentFixture<CreateUserDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [CreateUserDialogComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(CreateUserDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,102 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {MatFormField, MatHint, MatLabel} from "@angular/material/form-field";
|
||||
import {MatOption, MatSelect} from "@angular/material/select";
|
||||
import {MatInput} from "@angular/material/input";
|
||||
import {MatButton} from "@angular/material/button";
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {NewUser} from "../../interface/user";
|
||||
import {MsgService} from "../../service/msg.service";
|
||||
import {
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
MatDialogContent,
|
||||
MatDialogRef,
|
||||
MatDialogTitle
|
||||
} from "@angular/material/dialog";
|
||||
import {UserService} from "../../service/user.service";
|
||||
|
||||
interface user_form {
|
||||
username: string,
|
||||
nickname: string,
|
||||
password: string,
|
||||
confirm_password: string,
|
||||
status: 0 | 1,
|
||||
privileges: number[],
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-create-user-dialog',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatFormField,
|
||||
MatSelect,
|
||||
MatOption,
|
||||
MatInput,
|
||||
MatLabel,
|
||||
MatHint,
|
||||
MatButton,
|
||||
FormsModule,
|
||||
MatDialogTitle,
|
||||
MatDialogContent,
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
],
|
||||
templateUrl: './create-user-dialog.component.html',
|
||||
styleUrl: './create-user-dialog.component.scss'
|
||||
})
|
||||
export class CreateUserDialogComponent {
|
||||
new_user = {
|
||||
username: "",
|
||||
nickname: "",
|
||||
password: "",
|
||||
confirm_password: "",
|
||||
status: 0,
|
||||
privileges: [],
|
||||
} as user_form
|
||||
|
||||
constructor(
|
||||
public msg_srv: MsgService,
|
||||
public user_srv: UserService,
|
||||
public dialogRef: MatDialogRef<CreateUserDialogComponent>,
|
||||
) {
|
||||
}
|
||||
|
||||
create() {
|
||||
if (this.new_user.username.length < 3) {
|
||||
this.msg_srv.warning("用户名长度不能小于3")
|
||||
return
|
||||
}
|
||||
if (this.new_user.password.length < 8) {
|
||||
this.msg_srv.warning("密码至少8位")
|
||||
return
|
||||
}
|
||||
if (!this.new_user.password.match(/[a-z]+/)) {
|
||||
this.msg_srv.warning("密码必须包含小写字母")
|
||||
return
|
||||
}
|
||||
if (!this.new_user.password.match(/[A-Z]+/)) {
|
||||
this.msg_srv.warning("密码必须包含大写字母")
|
||||
return
|
||||
}
|
||||
if (this.new_user.password != this.new_user.confirm_password) {
|
||||
this.msg_srv.warning("输入的两次密码不同")
|
||||
return
|
||||
}
|
||||
console.log('[D] before create new user, new_user=', this.new_user)
|
||||
|
||||
this.user_srv.manage_user_create({
|
||||
username: this.new_user.username,
|
||||
password: this.new_user.password,
|
||||
status: this.new_user.status,
|
||||
privileges: this.new_user.privileges,
|
||||
role: 100,
|
||||
} as NewUser).subscribe(val => {
|
||||
if (val.status === 200) {
|
||||
this.msg_srv.success("创建用户成功")
|
||||
this.dialogRef.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
<h2 mat-dialog-title>修改用户</h2>
|
||||
<mat-dialog-content class="update-user-content">
|
||||
<mat-form-field>
|
||||
<mat-label>password</mat-label>
|
||||
<input matInput placeholder="password" type="password" name="password" [formControl]="password">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>confirm password</mat-label>
|
||||
<input matInput placeholder="confirm password" type="password" name="confirm_password"
|
||||
[formControl]="confirm_password">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>privilege</mat-label>
|
||||
<mat-select multiple [formControl]="privileges">
|
||||
@for (privilege of user_srv.user().privileges; track privilege) {
|
||||
<mat-option [value]="privilege.value">{{privilege.label}}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<mat-label>status</mat-label>
|
||||
<mat-select [formControl]="status">
|
||||
<mat-option [value]="0">正常</mat-option>
|
||||
<mat-option [value]="1">冻结</mat-option>
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</mat-dialog-content>
|
||||
|
||||
<mat-dialog-actions align="end">
|
||||
<button mat-raised-button mat-dialog-close>取消</button>
|
||||
<button mat-raised-button color="primary" (click)="update()">修改</button>
|
||||
</mat-dialog-actions>
|
@ -0,0 +1,14 @@
|
||||
:host {
|
||||
mat-dialog-content.update-user-content{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 450px;
|
||||
}
|
||||
}
|
||||
@media screen and (max-width: 40rem) {
|
||||
:host {
|
||||
mat-dialog-content.update-user-content{
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UpdateUserDialogComponent } from './update-user-dialog.component';
|
||||
|
||||
describe('UpdateUserDialogComponent', () => {
|
||||
let component: UpdateUserDialogComponent;
|
||||
let fixture: ComponentFixture<UpdateUserDialogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [UpdateUserDialogComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UpdateUserDialogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
@ -0,0 +1,94 @@
|
||||
import {Component, Inject} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {MatButton} from "@angular/material/button";
|
||||
import {
|
||||
MAT_DIALOG_DATA,
|
||||
MatDialogActions,
|
||||
MatDialogClose,
|
||||
MatDialogContent, MatDialogRef,
|
||||
MatDialogTitle
|
||||
} from "@angular/material/dialog";
|
||||
import {MatFormField, MatLabel} from "@angular/material/form-field";
|
||||
import {MatInput} from "@angular/material/input";
|
||||
import {MatOption} from "@angular/material/autocomplete";
|
||||
import {MatSelect} from "@angular/material/select";
|
||||
import {FormControl, FormsModule, ReactiveFormsModule} from "@angular/forms";
|
||||
import {User} from "../../interface/user";
|
||||
import {Enum} from "../../interface/enum";
|
||||
import {MsgService} from "../../service/msg.service";
|
||||
import {ArrayEquals} from "../../../tool";
|
||||
import {stripBom} from "@angular-devkit/build-angular/src/utils/strip-bom";
|
||||
import {UserService} from "../../service/user.service";
|
||||
|
||||
interface updateUser extends User {
|
||||
password: string
|
||||
confirm_password: string
|
||||
}
|
||||
|
||||
type Updates = { [key: string]: any }
|
||||
|
||||
@Component({
|
||||
selector: 'app-update-user-dialog',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatButton, MatDialogActions, MatDialogClose, MatDialogContent, MatDialogTitle, MatFormField, MatInput, MatLabel, MatOption, MatSelect, ReactiveFormsModule, FormsModule],
|
||||
templateUrl: './update-user-dialog.component.html',
|
||||
styleUrl: './update-user-dialog.component.scss'
|
||||
})
|
||||
export class UpdateUserDialogComponent {
|
||||
|
||||
user: updateUser = {} as updateUser
|
||||
|
||||
privileges = new FormControl([] as number[])
|
||||
status = new FormControl()
|
||||
password = new FormControl('')
|
||||
confirm_password = new FormControl('')
|
||||
|
||||
constructor(
|
||||
@Inject(MAT_DIALOG_DATA) public data: User,
|
||||
private msg_srv: MsgService,
|
||||
public user_srv: UserService,
|
||||
public dialogRef: MatDialogRef<UpdateUserDialogComponent>,
|
||||
) {
|
||||
this.user = {...data, password: '', confirm_password: ''}
|
||||
this.privileges.setValue(this.user.privileges.map(v => v.value))
|
||||
this.status.setValue(this.user.status.value)
|
||||
}
|
||||
|
||||
update() {
|
||||
let updated = false
|
||||
let updates: Updates = {"id": this.user.id}
|
||||
if (this.password.value || this.confirm_password.value) {
|
||||
updated = true
|
||||
updates["password"] = this.password.value
|
||||
if (this.password.value != this.confirm_password.value) {
|
||||
this.msg_srv.warning('两次密码不相同')
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (this.status.value != this.user.status.value) {
|
||||
updated = true
|
||||
updates["status"] = this.status.value
|
||||
}
|
||||
|
||||
if (!ArrayEquals(this.privileges.value!, this.user.privileges.map(p => p.value))) {
|
||||
updates["privileges"] = this.privileges.value
|
||||
updated = true
|
||||
}
|
||||
|
||||
if (!updated) {
|
||||
this.msg_srv.warning('没有变更')
|
||||
return
|
||||
}
|
||||
|
||||
this.user_srv.manage_user_update(updates).subscribe(rs => {
|
||||
if (rs.status === 200 || rs.status === 401) {
|
||||
this.dialogRef.close()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
initedPrivileges(privileges: Enum<number>[]) {
|
||||
return privileges.map(p => p.value)
|
||||
}
|
||||
}
|
54
front/src/app/interceptor/alerter.interceptor.ts
Normal file
@ -0,0 +1,54 @@
|
||||
import {
|
||||
HttpEvent,
|
||||
HttpHandler,
|
||||
HttpInterceptor,
|
||||
HttpRequest,
|
||||
HttpResponse
|
||||
} from '@angular/common/http';
|
||||
import {map, Observable} from "rxjs";
|
||||
import {Response} from "../interface/response";
|
||||
import {MsgService} from "../service/msg.service";
|
||||
import {Router} from "@angular/router";
|
||||
import {Injectable} from "@angular/core";
|
||||
import {UserService} from "../service/user.service";
|
||||
|
||||
// import {MsgService} from "../service/msg.service";
|
||||
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class alerterInterceptor implements HttpInterceptor {
|
||||
constructor(
|
||||
private msg_srv: MsgService,
|
||||
private router: Router,
|
||||
) {
|
||||
}
|
||||
|
||||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
||||
// const nr = req.clone().headers.set("Authorization", localStorage.getItem("ult-token"))
|
||||
req = req.clone({headers: req.headers.append("Authorization", localStorage.getItem("ult-token") ?? "")})
|
||||
return next.handle(req).pipe(
|
||||
map((event) => {
|
||||
if (event instanceof HttpResponse) {
|
||||
try {
|
||||
const rs = (event.body) as Response<any>
|
||||
console.log(`[D] ${req.method} - ${req.url} =>`, rs)
|
||||
if (rs.status > 200) {
|
||||
this.msg_srv.error(rs.msg)
|
||||
// alert(rs.msg)
|
||||
}
|
||||
|
||||
if (rs.status === 401) {
|
||||
this.router.navigate(['login'])
|
||||
}
|
||||
} catch (e) {
|
||||
console.warn('[E] http err=',e)
|
||||
this.msg_srv.error('无法连接服务器')
|
||||
}
|
||||
}
|
||||
return event
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
4
front/src/app/interface/confirm_data.ts
Normal file
@ -0,0 +1,4 @@
|
||||
export interface ConfirmData {
|
||||
title: string;
|
||||
confirmed: boolean;
|
||||
}
|
5
front/src/app/interface/enum.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface Enum<T> {
|
||||
value: T,
|
||||
code: string,
|
||||
label: string,
|
||||
}
|
13
front/src/app/interface/log.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import {Enum} from "./enum";
|
||||
|
||||
export interface Log {
|
||||
id: number,
|
||||
created_at: number,
|
||||
updated_at: number,
|
||||
deleted_at: number,
|
||||
user_id: number,
|
||||
username: string,
|
||||
type: Enum<number>,
|
||||
content: { [key: string]: any },
|
||||
html: string,
|
||||
}
|
5
front/src/app/interface/response.ts
Normal file
@ -0,0 +1,5 @@
|
||||
export interface Response<T> {
|
||||
status: number;
|
||||
msg: string;
|
||||
data: T;
|
||||
}
|
12
front/src/app/interface/task.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import {Enum} from "./enum";
|
||||
|
||||
export interface Task {
|
||||
id: number,
|
||||
created_at: number,
|
||||
updated_at: number,
|
||||
deleted_at: number,
|
||||
|
||||
task_name: string,
|
||||
task_run_type: '',
|
||||
task_status: Enum<number>,
|
||||
}
|
30
front/src/app/interface/user.ts
Normal file
@ -0,0 +1,30 @@
|
||||
import {Enum} from "./enum";
|
||||
|
||||
export interface User {
|
||||
id: number,
|
||||
created_at: number,
|
||||
updated_at: number,
|
||||
deleted_at: number,
|
||||
username: string,
|
||||
status: Enum<0 | 1>,
|
||||
nickname: string,
|
||||
comment: string,
|
||||
role: Enum<100 | 254 | 256>,
|
||||
privileges: Enum<number>[],
|
||||
created_by_id: number,
|
||||
created_by_name: string,
|
||||
active_at: number,
|
||||
deadline: number,
|
||||
login_at: number,
|
||||
}
|
||||
|
||||
export interface NewUser {
|
||||
username: string,
|
||||
nickname: string,
|
||||
status: 0 | 1,
|
||||
password: string,
|
||||
privileges: number[],
|
||||
deadline: number,
|
||||
role: 100,
|
||||
comment: string,
|
||||
}
|
1
front/src/app/page/home/home.component.html
Normal file
@ -0,0 +1 @@
|
||||
<h1>Welcome</h1>
|
76
front/src/app/page/home/home.component.scss
Normal file
@ -0,0 +1,76 @@
|
||||
|
||||
:host {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
max-height: 100%;
|
||||
min-height: 100%;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
background-color: white;
|
||||
margin: 0;
|
||||
|
||||
@keyframes fillup {
|
||||
from {
|
||||
background-position-x: 200%;
|
||||
}
|
||||
to {
|
||||
background-position-x: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes fadein {
|
||||
from {
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
h1 {
|
||||
width: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: var(--my-primary-color);
|
||||
font-size: 12rem;
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
font-weight: 800;
|
||||
letter-spacing: -0.5rem;
|
||||
position: relative;
|
||||
background-image: linear-gradient(to right, var(--my-primary-color), var(--my-primary-color), transparent);
|
||||
background-size: 200% 100%;
|
||||
background-repeat: no-repeat;
|
||||
-webkit-background-clip: text;
|
||||
background-position-x: 200%;
|
||||
animation: 3s fillup ease-in-out 2s forwards;
|
||||
|
||||
&::after {
|
||||
content: "Welcome";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
-webkit-text-stroke-color: white;
|
||||
-webkit-text-fill-color: transparent;
|
||||
opacity: 0;
|
||||
animation: 2s fadein ease-in-out forwards;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 40rem) {
|
||||
:host {
|
||||
h1 {
|
||||
font-size: 8rem;
|
||||
}
|
||||
}
|
||||
}
|
23
front/src/app/page/home/home.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { HomeComponent } from './home.component';
|
||||
|
||||
describe('HomeComponent', () => {
|
||||
let component: HomeComponent;
|
||||
let fixture: ComponentFixture<HomeComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HomeComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(HomeComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
17
front/src/app/page/home/home.component.ts
Normal file
@ -0,0 +1,17 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {UserService} from "../../service/user.service";
|
||||
|
||||
@Component({
|
||||
selector: 'app-home',
|
||||
standalone: true,
|
||||
imports: [CommonModule],
|
||||
templateUrl: './home.component.html',
|
||||
styleUrl: './home.component.scss'
|
||||
})
|
||||
export class HomeComponent {
|
||||
constructor(
|
||||
public user_srv: UserService
|
||||
) {
|
||||
}
|
||||
}
|
28
front/src/app/page/log/log.component.html
Normal file
@ -0,0 +1,28 @@
|
||||
<div class="logs">
|
||||
<div class="table">
|
||||
<table mat-table [dataSource]="log_srv.logs().list" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef>用户</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.username }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="created_at">
|
||||
<th mat-header-cell *matHeaderCellDef>时间</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.created_at | date: "yyyy-MM-dd HH:mm:SS" }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="type">
|
||||
<th mat-header-cell *matHeaderCellDef>日志类型</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.type.label }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="html">
|
||||
<th mat-header-cell *matHeaderCellDef>操作</th>
|
||||
<td mat-cell *matCellDef="let element" [innerHTML]="decodeLog(element.html)"></td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
11
front/src/app/page/log/log.component.scss
Normal file
@ -0,0 +1,11 @@
|
||||
:host {
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
|
||||
::ng-deep td>div.nf-op-log>span.nf-op-log-keyword {
|
||||
color: var(--my-primary-color);
|
||||
text-decoration: underline;
|
||||
font-weight: bold;
|
||||
margin: 0 1rem;
|
||||
}
|
||||
}
|
23
front/src/app/page/log/log.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LogComponent } from './log.component';
|
||||
|
||||
describe('LogComponent', () => {
|
||||
let component: LogComponent;
|
||||
let fixture: ComponentFixture<LogComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [LogComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LogComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
40
front/src/app/page/log/log.component.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {LogService} from "../../service/log.service";
|
||||
import {decode} from "js-base64"
|
||||
import {
|
||||
MatCell,
|
||||
MatCellDef,
|
||||
MatColumnDef,
|
||||
MatHeaderCell,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef,
|
||||
MatTable
|
||||
} from "@angular/material/table";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {MatIconButton} from "@angular/material/button";
|
||||
|
||||
@Component({
|
||||
selector: 'app-log',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatTable, MatColumnDef, MatHeaderCell, MatCell, MatCellDef, MatHeaderCellDef, MatIcon, MatIconButton, MatHeaderRow, MatHeaderRowDef, MatRowDef, MatRow],
|
||||
templateUrl: './log.component.html',
|
||||
styleUrl: './log.component.scss'
|
||||
})
|
||||
export class LogComponent implements OnInit {
|
||||
displayedColumns = ["username", "created_at", "type", "html"]
|
||||
|
||||
constructor(
|
||||
public log_srv: LogService,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.log_srv.get_logs()
|
||||
}
|
||||
|
||||
decodeLog(org: string): string {
|
||||
return decode(org)
|
||||
//.from(org, "base64").toString()
|
||||
}
|
||||
}
|
15
front/src/app/page/login/login.component.html
Normal file
@ -0,0 +1,15 @@
|
||||
<p>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>username</mat-label>
|
||||
<input matInput placeholder="username" [(ngModel)]="username" name="username">
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<p>
|
||||
<mat-form-field appearance="outline">
|
||||
<mat-label>password</mat-label>
|
||||
<input matInput placeholder="password" type="password" [(ngModel)]="password" name="password">
|
||||
</mat-form-field>
|
||||
</p>
|
||||
<p>
|
||||
<button mat-raised-button color="primary" (click)="login()">登录</button>
|
||||
</p>
|
24
front/src/app/page/login/login.component.scss
Normal file
@ -0,0 +1,24 @@
|
||||
:host {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
|
||||
p {
|
||||
min-width: 20rem;
|
||||
max-width: 30rem;
|
||||
width: 100%;
|
||||
|
||||
mat-form-field {
|
||||
width: 100%;
|
||||
input {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
button {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
}
|
23
front/src/app/page/login/login.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LoginComponent } from './login.component';
|
||||
|
||||
describe('LoginComponent', () => {
|
||||
let component: LoginComponent;
|
||||
let fixture: ComponentFixture<LoginComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [LoginComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(LoginComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
40
front/src/app/page/login/login.component.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {Component, signal} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {FormsModule} from "@angular/forms";
|
||||
import {UserService} from "../../service/user.service";
|
||||
import {MatButton} from "@angular/material/button";
|
||||
import {MatFormField, MatInput, MatInputModule} from "@angular/material/input";
|
||||
import {MatIcon, MatIconModule} from "@angular/material/icon";
|
||||
import {MatFormFieldModule} from "@angular/material/form-field";
|
||||
|
||||
@Component({
|
||||
selector: 'app-login',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
MatButton,
|
||||
MatInput,
|
||||
MatFormField,
|
||||
MatFormFieldModule,
|
||||
MatInputModule,
|
||||
MatIconModule,
|
||||
MatIcon,
|
||||
],
|
||||
templateUrl: './login.component.html',
|
||||
styleUrl: './login.component.scss'
|
||||
})
|
||||
export class LoginComponent {
|
||||
|
||||
username: string = ''
|
||||
password: string = ''
|
||||
|
||||
constructor(
|
||||
public user_srv: UserService
|
||||
) {
|
||||
}
|
||||
|
||||
login() {
|
||||
this.user_srv.auth_login(this.username, this.password)
|
||||
}
|
||||
}
|
60
front/src/app/page/task/task.component.html
Normal file
@ -0,0 +1,60 @@
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
任务管理
|
||||
</div>
|
||||
<button mat-raised-button color="primary">新建任务</button>
|
||||
</div>
|
||||
<div class="table">
|
||||
<table mat-table [dataSource]="task_srv.task_list().list" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="id">
|
||||
<th mat-header-cell *matHeaderCellDef>id</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.id }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="task_name">
|
||||
<th mat-header-cell *matHeaderCellDef>task_name</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.task_name }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="task_status">
|
||||
<th mat-header-cell *matHeaderCellDef>task_status</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.task_status.label }}</td>
|
||||
</ng-container>
|
||||
|
||||
|
||||
<ng-container matColumnDef="operation">
|
||||
<th mat-header-cell *matHeaderCellDef>operation</th>
|
||||
<td mat-cell *matCellDef="let element" style="padding-left: 4px !important;">
|
||||
@switch (element.task_status.value) {
|
||||
@case (0) {
|
||||
<button mat-icon-button disabled matTooltip="请先完善任务信息">
|
||||
<mat-icon color="">play_arrow</mat-icon>
|
||||
</button>
|
||||
}
|
||||
@case (1) {
|
||||
<button mat-icon-button (click)="update_task(element)" matTooltip="点击开始任务">
|
||||
<mat-icon color="primary">play_arrow</mat-icon>
|
||||
</button>
|
||||
}
|
||||
}
|
||||
<button mat-icon-button (click)="update_task(element)">
|
||||
<mat-icon color="primary">tune</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="delete_task(element)" color="warn">
|
||||
<mat-icon color="secondary">delete</mat-icon>
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pager">
|
||||
<mat-paginator [length]="task_srv.task_list().total"
|
||||
[pageSize]="task_srv.task_list().size"
|
||||
[pageSizeOptions]="[5, 10, 25, 100]"
|
||||
(page)="handlePager($event)"
|
||||
aria-label="Select page">
|
||||
</mat-paginator>
|
||||
</div>
|
37
front/src/app/page/task/task.component.scss
Normal file
@ -0,0 +1,37 @@
|
||||
:host {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
> div {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.toolbar {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
margin-top: 1rem;
|
||||
|
||||
> div {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-left: auto;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
div.table {
|
||||
flex: 1 0 0;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
div.pager {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
23
front/src/app/page/task/task.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskComponent } from './task.component';
|
||||
|
||||
describe('TaskComponent', () => {
|
||||
let component: TaskComponent;
|
||||
let fixture: ComponentFixture<TaskComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TaskComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TaskComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
47
front/src/app/page/task/task.component.ts
Normal file
@ -0,0 +1,47 @@
|
||||
import {Component} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {MatButton, MatIconButton} from "@angular/material/button";
|
||||
import {
|
||||
MatCell,
|
||||
MatCellDef,
|
||||
MatColumnDef,
|
||||
MatHeaderCell, MatHeaderCellDef,
|
||||
MatHeaderRow,
|
||||
MatHeaderRowDef,
|
||||
MatRow, MatRowDef, MatTable
|
||||
} from "@angular/material/table";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {MatPaginator, PageEvent} from "@angular/material/paginator";
|
||||
import {TaskService} from "../../service/task.service";
|
||||
import {Task} from '../../interface/task'
|
||||
import {MatTooltip} from "@angular/material/tooltip";
|
||||
|
||||
@Component({
|
||||
selector: 'app-task',
|
||||
standalone: true,
|
||||
imports: [CommonModule, MatButton, MatCell, MatCellDef, MatColumnDef, MatHeaderCell, MatHeaderRow, MatHeaderRowDef, MatIcon, MatIconButton, MatPaginator, MatRow, MatRowDef, MatTable, MatHeaderCellDef, MatTooltip],
|
||||
templateUrl: './task.component.html',
|
||||
styleUrl: './task.component.scss'
|
||||
})
|
||||
export class TaskComponent {
|
||||
displayedColumns = ["id", "task_name", "task_status", "operation"];
|
||||
|
||||
constructor(
|
||||
public task_srv: TaskService,
|
||||
) {
|
||||
}
|
||||
|
||||
update_task(element:Task) {
|
||||
|
||||
}
|
||||
|
||||
delete_task(element:Task) {
|
||||
|
||||
}
|
||||
|
||||
handlePager(event: PageEvent) {
|
||||
console.log('[D] handle pager change event=', event)
|
||||
// this.user_srv.user_list.set({...this.user_srv.user_list(), size: event.pageSize, page: event.pageIndex})
|
||||
// this.user_srv.manage_user_list()
|
||||
}
|
||||
}
|
52
front/src/app/page/user/user.component.html
Normal file
@ -0,0 +1,52 @@
|
||||
<div class="toolbar">
|
||||
<div>
|
||||
用户管理
|
||||
</div>
|
||||
<button mat-raised-button color="primary" (click)="open_dialog()">新建用户</button>
|
||||
</div>
|
||||
<div class="table">
|
||||
<table mat-table [dataSource]="user_srv.user_list().list" class="mat-elevation-z8">
|
||||
<ng-container matColumnDef="username">
|
||||
<th mat-header-cell *matHeaderCellDef>username</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.username }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="status">
|
||||
<th mat-header-cell *matHeaderCellDef>status</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.status.label }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="role">
|
||||
<th mat-header-cell *matHeaderCellDef>role</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ element.role.label }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="privileges">
|
||||
<th mat-header-cell *matHeaderCellDef>privileges</th>
|
||||
<td mat-cell *matCellDef="let element"> {{ _parsePrivileges(element.privileges) }}</td>
|
||||
</ng-container>
|
||||
|
||||
<ng-container matColumnDef="operation">
|
||||
<th mat-header-cell *matHeaderCellDef>operation</th>
|
||||
<td mat-cell *matCellDef="let element" style="padding-left: 4px !important;">
|
||||
<button mat-icon-button (click)="update_user(element)">
|
||||
<mat-icon color="primary">tune</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button (click)="delete_user(element)" color="warn">
|
||||
<mat-icon color="secondary">delete</mat-icon>
|
||||
</button>
|
||||
</td>
|
||||
</ng-container>
|
||||
|
||||
<tr mat-header-row *matHeaderRowDef="displayedColumns"></tr>
|
||||
<tr mat-row *matRowDef="let row; columns: displayedColumns;"></tr>
|
||||
</table>
|
||||
</div>
|
||||
<div class="pager">
|
||||
<mat-paginator [length]="user_srv.user_list().total"
|
||||
[pageSize]="user_srv.user_list().size"
|
||||
[pageSizeOptions]="[5, 10, 25, 100]"
|
||||
(page)="handlePager($event)"
|
||||
aria-label="Select page">
|
||||
</mat-paginator>
|
||||
</div>
|
37
front/src/app/page/user/user.component.scss
Normal file
@ -0,0 +1,37 @@
|
||||
:host {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
> div {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
div.toolbar {
|
||||
display: flex;
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
align-items: center;
|
||||
flex-direction: row;
|
||||
margin-top: 1rem;
|
||||
|
||||
> div {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
|
||||
button {
|
||||
margin-left: auto;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
div.table {
|
||||
flex: 1 0 0;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
|
||||
div.pager {
|
||||
margin-top: auto;
|
||||
}
|
||||
}
|
23
front/src/app/page/user/user.component.spec.ts
Normal file
@ -0,0 +1,23 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserComponent } from './user.component';
|
||||
|
||||
describe('UserComponent', () => {
|
||||
let component: UserComponent;
|
||||
let fixture: ComponentFixture<UserComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [UserComponent]
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(UserComponent);
|
||||
component = fixture.componentInstance;
|
||||
fixture.detectChanges();
|
||||
});
|
||||
|
||||
it('should create', () => {
|
||||
expect(component).toBeTruthy();
|
||||
});
|
||||
});
|
92
front/src/app/page/user/user.component.ts
Normal file
@ -0,0 +1,92 @@
|
||||
import {Component, OnInit} from '@angular/core';
|
||||
import {CommonModule} from '@angular/common';
|
||||
import {UserService} from "../../service/user.service";
|
||||
import {MatButton, MatIconButton} from "@angular/material/button";
|
||||
import {MatDialog} from "@angular/material/dialog";
|
||||
import {CreateUserDialogComponent} from "../../component/create-user-dialog/create-user-dialog.component";
|
||||
import {
|
||||
MatCell,
|
||||
MatCellDef,
|
||||
MatColumnDef,
|
||||
MatHeaderCell,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderRow, MatHeaderRowDef, MatRow, MatRowDef,
|
||||
MatTable
|
||||
} from "@angular/material/table";
|
||||
import {MatIcon} from "@angular/material/icon";
|
||||
import {Enum} from "../../interface/enum";
|
||||
import {User} from "../../interface/user";
|
||||
import {ConfirmComponent} from "../../component/confirm/confirm.component";
|
||||
import {UpdateUserDialogComponent} from "../../component/update-user-dialog/update-user-dialog.component";
|
||||
import {MatPaginator, PageEvent} from "@angular/material/paginator";
|
||||
|
||||
@Component({
|
||||
selector: 'app-user',
|
||||
standalone: true,
|
||||
imports: [
|
||||
CommonModule,
|
||||
MatButton,
|
||||
MatTable,
|
||||
MatColumnDef,
|
||||
MatHeaderCell,
|
||||
MatCell,
|
||||
MatCellDef,
|
||||
MatHeaderCellDef,
|
||||
MatHeaderRow,
|
||||
MatRow,
|
||||
MatRowDef,
|
||||
MatHeaderRowDef,
|
||||
MatIconButton,
|
||||
MatIcon,
|
||||
MatPaginator,
|
||||
],
|
||||
templateUrl: './user.component.html',
|
||||
styleUrl: './user.component.scss'
|
||||
})
|
||||
export class UserComponent implements OnInit {
|
||||
readonly displayedColumns: string[] = ["username", "status", "role", "privileges", "operation",];
|
||||
|
||||
constructor(
|
||||
public user_srv: UserService,
|
||||
public dialog: MatDialog,
|
||||
) {
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
this.user_srv.manage_user_list()
|
||||
}
|
||||
|
||||
open_dialog() {
|
||||
this.dialog.open(CreateUserDialogComponent, {data: {}})
|
||||
}
|
||||
|
||||
_parsePrivileges(privileges: any): string {
|
||||
try {
|
||||
let ps = privileges as Enum<number>[]
|
||||
return ps.map(v => v.label).join("; ")
|
||||
} catch (e) {
|
||||
console.log("[D] parse privileges err=", e)
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
delete_user(target: User) {
|
||||
let data = {title: `确认删除用户 ${target.username} 吗?`, confirmed: false }
|
||||
this.dialog.open(ConfirmComponent, {data: data}).afterClosed().subscribe(() => {
|
||||
if (data.confirmed) {
|
||||
this.user_srv.manage_user_delete(target)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
update_user(target: User) {
|
||||
this.dialog.open(UpdateUserDialogComponent, {data: target})
|
||||
}
|
||||
|
||||
handlePager(event: PageEvent) {
|
||||
console.log('[D] handle pager change event=', event)
|
||||
this.user_srv.user_list.set({...this.user_srv.user_list(), size: event.pageSize, page: event.pageIndex})
|
||||
this.user_srv.manage_user_list()
|
||||
}
|
||||
}
|
||||
|
16
front/src/app/service/log.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { LogService } from './log.service';
|
||||
|
||||
describe('LogService', () => {
|
||||
let service: LogService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(LogService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
35
front/src/app/service/log.service.ts
Normal file
@ -0,0 +1,35 @@
|
||||
import {Injectable, signal} from '@angular/core';
|
||||
import {Log} from "../interface/log";
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {tap} from "rxjs";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class LogService {
|
||||
|
||||
readonly log_list_url = "/api/log/content/list"
|
||||
|
||||
readonly logs = signal({
|
||||
list: [] as Log[],
|
||||
total: 0,
|
||||
page: 0,
|
||||
size: 0,
|
||||
})
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) {
|
||||
}
|
||||
|
||||
get_logs() {
|
||||
return this.http.get<{status:number, msg:string, data: {list:Log[], total: number}}>(this.log_list_url).pipe(
|
||||
|
||||
).subscribe(rs => {
|
||||
if (rs.status === 200) {
|
||||
this.logs.set({...this.logs(), total: rs.data.total, list: rs.data.list})
|
||||
} else {
|
||||
this.logs.set({...this.logs(), list: []})
|
||||
}
|
||||
})}
|
||||
}
|
214
front/src/app/service/msg.service.ts
Normal file
@ -0,0 +1,214 @@
|
||||
import { Injectable, Inject } from '@angular/core';
|
||||
import { Component } from '@angular/core';
|
||||
import { MAT_SNACK_BAR_DATA } from '@angular/material/snack-bar';
|
||||
import {
|
||||
MatSnackBar,
|
||||
MatSnackBarHorizontalPosition,
|
||||
MatSnackBarVerticalPosition,
|
||||
} from '@angular/material/snack-bar';
|
||||
import {MatIconModule} from "@angular/material/icon";
|
||||
|
||||
interface SnackMessage {
|
||||
type: "success" | "error" | "warning" | "info"
|
||||
duration: number
|
||||
data: string
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class MsgService {
|
||||
horizontalPosition: MatSnackBarHorizontalPosition = 'center';
|
||||
verticalPosition: MatSnackBarVerticalPosition = 'top';
|
||||
|
||||
constructor(
|
||||
private _snackBar: MatSnackBar
|
||||
) { }
|
||||
|
||||
|
||||
success(data: string) {
|
||||
this.open({ type: "success", duration: 1500, data: data })
|
||||
}
|
||||
|
||||
info(data: string) {
|
||||
this.open({ type: "info", duration: 2000, data: data })
|
||||
}
|
||||
|
||||
warning(data: string) {
|
||||
this.open({ type: "warning", duration: 3000, data: data })
|
||||
}
|
||||
|
||||
error(data: string) {
|
||||
this.open({ type: "error", duration: 3500, data: data })
|
||||
}
|
||||
|
||||
open(msg: SnackMessage) {
|
||||
switch (msg.type) {
|
||||
case "success":
|
||||
this._snackBar.openFromComponent(SnackMessageSuccess, {
|
||||
data: msg.data,
|
||||
duration: msg.duration,
|
||||
horizontalPosition: this.horizontalPosition,
|
||||
verticalPosition: this.verticalPosition,
|
||||
panelClass: ['success-snackbar'],
|
||||
})
|
||||
break;
|
||||
case "info":
|
||||
this._snackBar.openFromComponent(SnackMessageInfo, {
|
||||
data: msg.data,
|
||||
duration: msg.duration,
|
||||
horizontalPosition: this.horizontalPosition,
|
||||
verticalPosition: this.verticalPosition,
|
||||
panelClass: ['info-snackbar'],
|
||||
})
|
||||
break
|
||||
case "warning":
|
||||
this._snackBar.openFromComponent(SnackMessageWarning, {
|
||||
data: msg.data,
|
||||
duration: msg.duration,
|
||||
horizontalPosition: this.horizontalPosition,
|
||||
verticalPosition: this.verticalPosition,
|
||||
panelClass: ['warning-snackbar'],
|
||||
})
|
||||
break
|
||||
case "error":
|
||||
this._snackBar.openFromComponent(SnackMessageError, {
|
||||
data: msg.data,
|
||||
duration: msg.duration,
|
||||
horizontalPosition: this.horizontalPosition,
|
||||
verticalPosition: this.verticalPosition,
|
||||
panelClass: ['error-snackbar'],
|
||||
})
|
||||
break
|
||||
default:
|
||||
this._snackBar.openFromComponent(SnackMessageInfo, {
|
||||
data: msg.data,
|
||||
duration: msg.duration,
|
||||
horizontalPosition: this.horizontalPosition,
|
||||
verticalPosition: this.verticalPosition,
|
||||
panelClass: ['info-snackbar'],
|
||||
})
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'snack-message-success',
|
||||
template: `
|
||||
<div class="snack-message-success snack-message">
|
||||
<div>
|
||||
<mat-icon>cancel</mat-icon>
|
||||
</div>
|
||||
<div class="snack-message-content">
|
||||
{{ data }}
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatIconModule
|
||||
],
|
||||
styles: [`
|
||||
.snack-message-success {
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class SnackMessageSuccess {
|
||||
constructor(
|
||||
@Inject(MAT_SNACK_BAR_DATA) public data: string,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public duration: number,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition,
|
||||
) { }
|
||||
}
|
||||
|
||||
|
||||
@Component({
|
||||
selector: 'snack-message-info',
|
||||
template: `
|
||||
<div class="snack-message-info snack-message">
|
||||
<div>
|
||||
<mat-icon>cancel</mat-icon>
|
||||
</div>
|
||||
<div class="snack-message-content">
|
||||
{{ data }}
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatIconModule
|
||||
],
|
||||
styles: [`
|
||||
.snack-message-info {
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class SnackMessageInfo {
|
||||
constructor(
|
||||
@Inject(MAT_SNACK_BAR_DATA) public data: string,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public duration: number,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition,
|
||||
) { }
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'snack-message-warning',
|
||||
template: `
|
||||
<div class="snack-message-warning snack-message">
|
||||
<div>
|
||||
<mat-icon>cancel</mat-icon>
|
||||
</div>
|
||||
<div class="snack-message-content">
|
||||
{{ data }}
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatIconModule
|
||||
],
|
||||
styles: [`
|
||||
.snack-message-warning {
|
||||
}
|
||||
`]
|
||||
})
|
||||
export class SnackMessageWarning {
|
||||
constructor(
|
||||
@Inject(MAT_SNACK_BAR_DATA) public data: string,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public duration: number,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition,
|
||||
) { }
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'snack-message-error',
|
||||
template: `
|
||||
<div class="snack-message-error snack-message">
|
||||
<div>
|
||||
<mat-icon>cancel</mat-icon>
|
||||
</div>
|
||||
<div class="snack-message-content">
|
||||
{{ data }}
|
||||
</div>
|
||||
</div>
|
||||
`,
|
||||
standalone: true,
|
||||
imports: [
|
||||
MatIconModule
|
||||
],
|
||||
styles: [`
|
||||
`]
|
||||
})
|
||||
export class SnackMessageError {
|
||||
constructor(
|
||||
@Inject(MAT_SNACK_BAR_DATA) public data: string,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public duration: number,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public horizontalPosition: MatSnackBarHorizontalPosition,
|
||||
@Inject(MAT_SNACK_BAR_DATA) public verticalPosition: MatSnackBarVerticalPosition,
|
||||
) { }
|
||||
}
|
16
front/src/app/service/task.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { TaskService } from './task.service';
|
||||
|
||||
describe('TaskService', () => {
|
||||
let service: TaskService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(TaskService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
40
front/src/app/service/task.service.ts
Normal file
@ -0,0 +1,40 @@
|
||||
import {Injectable, signal, WritableSignal} from '@angular/core';
|
||||
import {HttpClient, HttpParams} from "@angular/common/http";
|
||||
import {tap} from "rxjs";
|
||||
import {Task} from "../interface/task"
|
||||
import {Response} from "../interface/response"
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class TaskService {
|
||||
|
||||
readonly url_task_list = '/api/task/list'
|
||||
task_list: WritableSignal<{ total: number, list: Task[], page: number, size: number }> = signal({
|
||||
page: 0,
|
||||
size: 20,
|
||||
total: 0,
|
||||
list: [] as Task[],
|
||||
})
|
||||
|
||||
constructor(
|
||||
private http: HttpClient,
|
||||
) {
|
||||
this.get_task_list().subscribe()
|
||||
}
|
||||
|
||||
get_task_list(page: number = 0, size: number = 20) {
|
||||
const params = new HttpParams()
|
||||
params.set("page", page)
|
||||
params.set("size", size)
|
||||
return this.http.get<Response<{ total: number, list: Task[] }>>(this.url_task_list, {params: params}).pipe(
|
||||
tap({
|
||||
next: (res => {
|
||||
if (res.status === 200) {
|
||||
this.task_list.set({...this.task_list(), list: res.data.list, total: res.data.total})
|
||||
}
|
||||
})
|
||||
}),
|
||||
)
|
||||
}
|
||||
}
|
16
front/src/app/service/user.service.spec.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { UserService } from './user.service';
|
||||
|
||||
describe('UserService', () => {
|
||||
let service: UserService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(UserService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
119
front/src/app/service/user.service.ts
Normal file
@ -0,0 +1,119 @@
|
||||
import {Injectable, signal, WritableSignal} from '@angular/core';
|
||||
import {HttpClient} from "@angular/common/http";
|
||||
import {Router} from "@angular/router";
|
||||
import {User, NewUser} from "../interface/user";
|
||||
import {Response} from "../interface/response";
|
||||
import {tap} from "rxjs";
|
||||
import {MsgService} from "./msg.service";
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class UserService {
|
||||
|
||||
readonly auth_login_url = '/api/user/auth/login'
|
||||
readonly auth_logout_url = '/api/user/auth/logout'
|
||||
readonly manage_user_create_url = '/api/user/manage/user/create'
|
||||
readonly manage_user_update_url= '/api/user/manage/user/update'
|
||||
readonly manage_user_delete_url = '/api/user/manage/user/delete'
|
||||
readonly manage_user_list_url = '/api/user/manage/user/list'
|
||||
readonly init_user: User = {id: 0, username: ""} as User
|
||||
|
||||
readonly user = signal(this.init_user)
|
||||
readonly user_list: WritableSignal<{ total: number, page: number, size: number, list: User[] }> = signal({
|
||||
total: 0,
|
||||
page: 0,
|
||||
size: 20,
|
||||
list: [] as User[],
|
||||
})
|
||||
|
||||
constructor(
|
||||
private msg_srv: MsgService,
|
||||
private http: HttpClient,
|
||||
private router: Router,
|
||||
) {
|
||||
this.auth_verify()
|
||||
}
|
||||
|
||||
auth_login(username: string, password: string) {
|
||||
this.http.post<Response<{ token: string, user: User }>>(this.auth_login_url, {
|
||||
username: username,
|
||||
password: password
|
||||
}).subscribe(val => {
|
||||
if (val.status === 200) {
|
||||
localStorage.setItem("ult-token", val.data.token)
|
||||
this.user.set(val.data.user)
|
||||
this.router.navigate([''])
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
auth_verify() {
|
||||
this.http.get<Response<{ token: string, user: User }>>(this.auth_login_url).subscribe(rs => {
|
||||
if (rs.status === 200) {
|
||||
this.user.set(rs.data.user)
|
||||
console.log("[D] auth verify user=", this.user())
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
auth_logout() {
|
||||
this.http.post<Response<null>>(this.auth_logout_url, {}).subscribe(rs => {
|
||||
this.router.navigate(['login']).finally(() => {
|
||||
localStorage.removeItem("ult-token")
|
||||
this.user.set(this.init_user)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
manage_user_create(new_user: NewUser) {
|
||||
return this.http.post<Response<User>>(this.manage_user_create_url, {...new_user}).pipe(
|
||||
tap({
|
||||
next: (rs) => {
|
||||
if (rs.status === 200) {
|
||||
this.manage_user_list()
|
||||
}
|
||||
}
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
manage_user_delete(target: User) {
|
||||
return this.http.post<Response<User>>(this.manage_user_delete_url, {id: target.id}).pipe(
|
||||
tap({
|
||||
next: (rs) => {
|
||||
if (rs.status === 200) {
|
||||
this.msg_srv.success('删除用户成功')
|
||||
this.manage_user_list()
|
||||
} else {
|
||||
this.msg_srv.error(rs.msg)
|
||||
}
|
||||
}
|
||||
})
|
||||
).subscribe()
|
||||
}
|
||||
|
||||
manage_user_update(body: Object) {
|
||||
return this.http.post<Response<any>>(this.manage_user_update_url, body).pipe(
|
||||
tap({next: (rs) => {
|
||||
if (rs.status === 200) {
|
||||
this.msg_srv.success("更新用户成功")
|
||||
this.manage_user_list()
|
||||
} else {
|
||||
this.msg_srv.error(rs.msg)
|
||||
}
|
||||
}})
|
||||
)
|
||||
}
|
||||
|
||||
manage_user_list() {
|
||||
this.http.get<Response<{ total: number, list: User[] }>>(this.manage_user_list_url, {params: {}}).subscribe(rs => {
|
||||
if (rs.status === 200) {
|
||||
this.user_list.set({...this.user_list(), total: rs.data.total, list: rs.data.list})
|
||||
// this.user_list = {...this.user_list, total: rs.data.total, list: rs.data.list}
|
||||
} else {
|
||||
this.user_list.set({...this.user_list(), list: []})
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
0
front/src/assets/.gitkeep
Normal file
BIN
front/src/assets/icons/icon-128x128.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
front/src/assets/icons/icon-144x144.png
Normal file
After Width: | Height: | Size: 3.0 KiB |
BIN
front/src/assets/icons/icon-152x152.png
Normal file
After Width: | Height: | Size: 3.2 KiB |
BIN
front/src/assets/icons/icon-192x192.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
front/src/assets/icons/icon-384x384.png
Normal file
After Width: | Height: | Size: 11 KiB |
BIN
front/src/assets/icons/icon-512x512.png
Normal file
After Width: | Height: | Size: 16 KiB |
BIN
front/src/assets/icons/icon-72x72.png
Normal file
After Width: | Height: | Size: 1.9 KiB |
BIN
front/src/assets/icons/icon-96x96.png
Normal file
After Width: | Height: | Size: 2.3 KiB |
BIN
front/src/favicon.ico
Normal file
After Width: | Height: | Size: 15 KiB |
18
front/src/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Front</title>
|
||||
<base href="/">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<link rel="icon" type="image/x-icon" href="favicon.ico">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&display=swap" rel="stylesheet">
|
||||
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
|
||||
<link rel="manifest" href="manifest.webmanifest">
|
||||
<meta name="theme-color" content="#1976d2">
|
||||
</head>
|
||||
<body class="mat-typography">
|
||||
<app-root></app-root>
|
||||
<noscript>Please enable JavaScript to continue using this application.</noscript>
|
||||
</body>
|
||||
</html>
|
6
front/src/main.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { bootstrapApplication } from '@angular/platform-browser';
|
||||
import { appConfig } from './app/app.config';
|
||||
import { AppComponent } from './app/app.component';
|
||||
|
||||
bootstrapApplication(AppComponent, appConfig)
|
||||
.catch((err) => console.error(err));
|
59
front/src/manifest.webmanifest
Normal file
@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "front",
|
||||
"short_name": "front",
|
||||
"theme_color": "#1976d2",
|
||||
"background_color": "#fafafa",
|
||||
"display": "standalone",
|
||||
"scope": "./",
|
||||
"start_url": "./",
|
||||
"icons": [
|
||||
{
|
||||
"src": "assets/icons/icon-72x72.png",
|
||||
"sizes": "72x72",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-96x96.png",
|
||||
"sizes": "96x96",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-128x128.png",
|
||||
"sizes": "128x128",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-144x144.png",
|
||||
"sizes": "144x144",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-152x152.png",
|
||||
"sizes": "152x152",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-192x192.png",
|
||||
"sizes": "192x192",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-384x384.png",
|
||||
"sizes": "384x384",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
},
|
||||
{
|
||||
"src": "assets/icons/icon-512x512.png",
|
||||
"sizes": "512x512",
|
||||
"type": "image/png",
|
||||
"purpose": "maskable any"
|
||||
}
|
||||
]
|
||||
}
|
6
front/src/proxy.conf.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"/api": {
|
||||
"target": "http://127.0.0.1",
|
||||
"secure": false
|
||||
}
|
||||
}
|
70
front/src/styles.scss
Normal file
@ -0,0 +1,70 @@
|
||||
/* You can add global styles to this file, and also import other style files */
|
||||
:root {
|
||||
--primary-color: rgb(63, 81, 181);
|
||||
--my-primary-color: rgb(67, 80, 175);
|
||||
--my-success-text-color: rgb(94, 140, 117);
|
||||
--my-success-backgroud-color: rgb(203, 228, 216);
|
||||
--my-warning-text-color: rgb(132, 113, 56);
|
||||
--my-warning-backgroud-color: rgb(254, 243, 200);
|
||||
--my-error-text-color: rgb(136, 52, 61);
|
||||
--my-error-backgroud-color: rgb(246, 209, 213);
|
||||
--my-info-text-color: rgb(60, 64, 69);
|
||||
--my-info-backgroud-color: rgb(222, 223, 225);
|
||||
|
||||
font-size: 8px;
|
||||
}
|
||||
|
||||
html, body {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
height: 100vh;
|
||||
max-height: 100vh;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
font-family: Roboto, "Helvetica Neue", sans-serif;
|
||||
}
|
||||
|
||||
.mat-mdc-snack-bar-container {
|
||||
|
||||
&.info-snackbar {
|
||||
--mdc-snackbar-container-color: var(--my-info-backgroud-color);
|
||||
--mdc-snackbar-supporting-text-color: var(--my-info-text-color);
|
||||
}
|
||||
|
||||
&.success-snackbar {
|
||||
--mdc-snackbar-container-color: var(--my-success-backgroud-color);
|
||||
--mdc-snackbar-supporting-text-color: var(--my-success-text-color);
|
||||
}
|
||||
|
||||
&.warning-snackbar {
|
||||
--mdc-snackbar-container-color: var(--my-warning-backgroud-color);
|
||||
--mdc-snackbar-supporting-text-color: var(--my-warning-text-color);
|
||||
}
|
||||
|
||||
&.error-snackbar {
|
||||
--mdc-snackbar-container-color: var(--my-error-backgroud-color);
|
||||
--mdc-snackbar-supporting-text-color: var(--my-error-text-color);
|
||||
}
|
||||
}
|
||||
|
||||
.snack-message {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
height: 100%;
|
||||
|
||||
div {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&.snack-message-content {
|
||||
margin-left: 1rem;
|
||||
}
|
||||
}
|
||||
}
|
6
front/src/tool.ts
Normal file
@ -0,0 +1,6 @@
|
||||
export function ArrayEquals(a: any[], b: any[]): boolean {
|
||||
return Array.isArray(a) &&
|
||||
Array.isArray(b) &&
|
||||
a.length === b.length &&
|
||||
a.every((val, index) => val === b[index]);
|
||||
}
|
14
front/tsconfig.app.json
Normal file
@ -0,0 +1,14 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/app",
|
||||
"types": []
|
||||
},
|
||||
"files": [
|
||||
"src/main.ts"
|
||||
],
|
||||
"include": [
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
32
front/tsconfig.json
Normal file
@ -0,0 +1,32 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"outDir": "./dist/out-tsc",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"strict": true,
|
||||
"noImplicitOverride": true,
|
||||
"noPropertyAccessFromIndexSignature": true,
|
||||
"noImplicitReturns": true,
|
||||
"noFallthroughCasesInSwitch": true,
|
||||
"esModuleInterop": true,
|
||||
"sourceMap": true,
|
||||
"declaration": false,
|
||||
"experimentalDecorators": true,
|
||||
"moduleResolution": "node",
|
||||
"importHelpers": true,
|
||||
"target": "ES2022",
|
||||
"module": "ES2022",
|
||||
"useDefineForClassFields": false,
|
||||
"lib": [
|
||||
"ES2022",
|
||||
"dom"
|
||||
]
|
||||
},
|
||||
"angularCompilerOptions": {
|
||||
"enableI18nLegacyMessageIdFormat": false,
|
||||
"strictInjectionParameters": true,
|
||||
"strictInputAccessModifiers": true,
|
||||
"strictTemplates": true
|
||||
}
|
||||
}
|
14
front/tsconfig.spec.json
Normal file
@ -0,0 +1,14 @@
|
||||
/* To learn more about this file see: https://angular.io/config/tsconfig. */
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"outDir": "./out-tsc/spec",
|
||||
"types": [
|
||||
"jasmine"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.spec.ts",
|
||||
"src/**/*.d.ts"
|
||||
]
|
||||
}
|
50
go.mod
Normal file
@ -0,0 +1,50 @@
|
||||
module github.com/loveuer/nfflow
|
||||
|
||||
go 1.20
|
||||
|
||||
require (
|
||||
gitea.com/taozitaozi/gredis v0.0.0-20240131032054-b02845ce1e9d
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10
|
||||
github.com/glebarez/sqlite v1.10.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/golang-jwt/jwt/v5 v5.2.0
|
||||
github.com/jackc/pgtype v1.12.0
|
||||
github.com/loveuer/nf v0.1.3
|
||||
github.com/samber/lo v1.39.0
|
||||
github.com/sirupsen/logrus v1.9.3
|
||||
github.com/spf13/cast v1.6.0
|
||||
github.com/tdewolff/minify/v2 v2.20.16
|
||||
golang.org/x/crypto v0.9.0
|
||||
gorm.io/driver/mysql v1.4.5
|
||||
gorm.io/driver/postgres v1.4.4
|
||||
gorm.io/gorm v1.25.5
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
||||
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 // indirect
|
||||
github.com/jackc/pgconn v1.13.0 // indirect
|
||||
github.com/jackc/pgio v1.0.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b // indirect
|
||||
github.com/jackc/pgx/v4 v4.17.2 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/mattn/go-isatty v0.0.19 // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||
github.com/tdewolff/parse/v2 v2.7.11 // indirect
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
|
||||
golang.org/x/sys v0.16.0 // indirect
|
||||
golang.org/x/text v0.9.0 // indirect
|
||||
modernc.org/libc v1.22.5 // indirect
|
||||
modernc.org/mathutil v1.5.0 // indirect
|
||||
modernc.org/memory v1.5.0 // indirect
|
||||
modernc.org/sqlite v1.23.1 // indirect
|
||||
)
|
268
go.sum
Normal file
@ -0,0 +1,268 @@
|
||||
gitea.com/taozitaozi/gredis v0.0.0-20240131032054-b02845ce1e9d h1:TpEOdRGqwzxx+DaN18nFE+g4EQYjneZOO1jcHtSon/g=
|
||||
gitea.com/taozitaozi/gredis v0.0.0-20240131032054-b02845ce1e9d/go.mod h1:QtcL846XUtSnhmW6TZAujUQ9V5jalY7frxzZOs00kFI=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
|
||||
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo=
|
||||
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
|
||||
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
|
||||
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
|
||||
github.com/glebarez/sqlite v1.10.0 h1:u4gt8y7OND/cCei/NMHmfbLxF6xP2wgKcT/BJf2pYkc=
|
||||
github.com/glebarez/sqlite v1.10.0/go.mod h1:IJ+lfSOmiekhQsFTJRx/lHtGYmCdtAiTaf5wI9u5uHA=
|
||||
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
|
||||
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
||||
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/jackc/chunkreader v1.0.0/go.mod h1:RT6O25fNZIuasFJRyZ4R/Y2BbhasbmZXF9QQ7T3kePo=
|
||||
github.com/jackc/chunkreader/v2 v2.0.0/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1 h1:i+RDz65UE+mmpjTfyz0MoVTnzeYxroil2G82ki7MGG8=
|
||||
github.com/jackc/chunkreader/v2 v2.0.1/go.mod h1:odVSm741yZoC3dpHEUXIqA9tQRhFrgOHwnPIn9lDKlk=
|
||||
github.com/jackc/pgconn v0.0.0-20190420214824-7e0022ef6ba3/go.mod h1:jkELnwuX+w9qN5YIfX0fl88Ehu4XC3keFuOJJk9pcnA=
|
||||
github.com/jackc/pgconn v0.0.0-20190824142844-760dd75542eb/go.mod h1:lLjNuW/+OfW9/pnVKPazfWOgNfH2aPem8YQ7ilXGvJE=
|
||||
github.com/jackc/pgconn v0.0.0-20190831204454-2fabfa3c18b7/go.mod h1:ZJKsE/KZfsUgOEh9hBm+xYTstcNHg7UPMVJqRfQxq4s=
|
||||
github.com/jackc/pgconn v1.8.0/go.mod h1:1C2Pb36bGIP9QHGBYCjnyhqu7Rv3sGshaQUvmfGIB/o=
|
||||
github.com/jackc/pgconn v1.9.0/go.mod h1:YctiPyvzfU11JFxoXokUOOKQXQmDMoJL9vJzHH8/2JY=
|
||||
github.com/jackc/pgconn v1.9.1-0.20210724152538-d89c8390a530/go.mod h1:4z2w8XhRbP1hYxkpTuBjTS3ne3J48K83+u0zoyvg2pI=
|
||||
github.com/jackc/pgconn v1.13.0 h1:3L1XMNV2Zvca/8BYhzcRFS70Lr0WlDg16Di6SFGAbys=
|
||||
github.com/jackc/pgconn v1.13.0/go.mod h1:AnowpAqO4CMIIJNZl2VJp+KrkAZciAkhEl0W0JIobpI=
|
||||
github.com/jackc/pgio v1.0.0 h1:g12B9UwVnzGhueNavwioyEEpAmqMe1E/BN9ES+8ovkE=
|
||||
github.com/jackc/pgio v1.0.0/go.mod h1:oP+2QK2wFfUWgr+gxjoBH9KGBb31Eio69xUb0w5bYf8=
|
||||
github.com/jackc/pgmock v0.0.0-20190831213851-13a1b77aafa2/go.mod h1:fGZlG77KXmcq05nJLRkk0+p82V8B8Dw8KN2/V9c/OAE=
|
||||
github.com/jackc/pgmock v0.0.0-20201204152224-4fe30f7445fd/go.mod h1:hrBW0Enj2AZTNpt/7Y5rr2xe/9Mn757Wtb2xeBzPv2c=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65 h1:DadwsjnMwFjfWc9y5Wi/+Zz7xoE5ALHsRQlOctkOiHc=
|
||||
github.com/jackc/pgmock v0.0.0-20210724152146-4ad1a8207f65/go.mod h1:5R2h2EEX+qri8jOWMbJCtaPWkrrNc7OHwsp2TCqp7ak=
|
||||
github.com/jackc/pgpassfile v1.0.0 h1:/6Hmqy13Ss2zCq62VdNG8tM1wchn8zjSGOBJ6icpsIM=
|
||||
github.com/jackc/pgpassfile v1.0.0/go.mod h1:CEx0iS5ambNFdcRtxPj5JhEz+xB6uRky5eyVu/W2HEg=
|
||||
github.com/jackc/pgproto3 v1.1.0/go.mod h1:eR5FA3leWg7p9aeAqi37XOTgTIbkABlvcPB3E5rlc78=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190420180111-c116219b62db/go.mod h1:bhq50y+xrl9n5mRYyCBFKkpRVTLYJVWeCc+mEAI3yXA=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-alpha1.0.20190609003834-432c2951c711/go.mod h1:uH0AWtUmuShn0bcesswc4aBTWGvw0cAxIJp+6OB//Wg=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.0-rc3.0.20190831210041-4c03ce451f29/go.mod h1:ryONWYqW6dqSg1Lw6vXNMXoBJhpzvWKnT95C46ckYeM=
|
||||
github.com/jackc/pgproto3/v2 v2.0.6/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.1.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgproto3/v2 v2.3.1 h1:nwj7qwf0S+Q7ISFfBndqeLwSwxs+4DPsbRFjECT1Y4Y=
|
||||
github.com/jackc/pgproto3/v2 v2.3.1/go.mod h1:WfJCnwN3HIg9Ish/j3sgWXnAfK8A9Y0bwXYU5xKaEdA=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b h1:C8S2+VttkHFdOOCXJe+YGfa4vHYwlt4Zx+IVXQ97jYg=
|
||||
github.com/jackc/pgservicefile v0.0.0-20200714003250-2b9c44734f2b/go.mod h1:vsD4gTJCa9TptPL8sPkXrLZ+hDuNrZCnj29CQpr4X1E=
|
||||
github.com/jackc/pgtype v0.0.0-20190421001408-4ed0de4755e0/go.mod h1:hdSHsc1V01CGwFsrv11mJRHWJ6aifDLfdV3aVjFF0zg=
|
||||
github.com/jackc/pgtype v0.0.0-20190824184912-ab885b375b90/go.mod h1:KcahbBH1nCMSo2DXpzsoWOAfFkdEtEJpPbVLq8eE+mc=
|
||||
github.com/jackc/pgtype v0.0.0-20190828014616-a8802b16cc59/go.mod h1:MWlu30kVJrUS8lot6TQqcg7mtthZ9T0EoIBFiJcmcyw=
|
||||
github.com/jackc/pgtype v1.8.1-0.20210724151600-32e20a603178/go.mod h1:C516IlIV9NKqfsMCXTdChteoXmwgUceqaLfjg2e3NlM=
|
||||
github.com/jackc/pgtype v1.12.0 h1:Dlq8Qvcch7kiehm8wPGIW0W3KsCCHJnRacKW0UM8n5w=
|
||||
github.com/jackc/pgtype v1.12.0/go.mod h1:LUMuVrfsFfdKGLw+AFFVv6KtHOFMwRgDDzBt76IqCA4=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190420224344-cc3461e65d96/go.mod h1:mdxmSJJuR08CZQyj1PVQBHy9XOp5p8/SHH6a0psbY9Y=
|
||||
github.com/jackc/pgx/v4 v4.0.0-20190421002000-1b8f0016e912/go.mod h1:no/Y67Jkk/9WuGR0JG/JseM9irFbnEPbuWV2EELPNuM=
|
||||
github.com/jackc/pgx/v4 v4.0.0-pre1.0.20190824185557-6972a5742186/go.mod h1:X+GQnOEnf1dqHGpw7JmHqHc1NxDoalibchSk9/RWuDc=
|
||||
github.com/jackc/pgx/v4 v4.12.1-0.20210724153913-640aa07df17c/go.mod h1:1QD0+tgSXP7iUjYm9C1NxKhny7lq6ee99u/z+IHFcgs=
|
||||
github.com/jackc/pgx/v4 v4.17.2 h1:0Ut0rpeKwvIVbMQ1KbMBU4h6wxehBI535LK6Flheh8E=
|
||||
github.com/jackc/pgx/v4 v4.17.2/go.mod h1:lcxIZN44yMIrWI78a5CpucdD14hX0SBDbNRvjDBItsw=
|
||||
github.com/jackc/puddle v0.0.0-20190413234325-e4ced69a3a2b/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jackc/puddle v1.3.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
|
||||
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
|
||||
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||
github.com/loveuer/nf v0.1.3 h1:tZP+FtwhiU+VTfPwfaEQUmiw1z6U9XwfDzJV46h5vZw=
|
||||
github.com/loveuer/nf v0.1.3/go.mod h1:uKsKYym27ravyTXSBSnxU86V7osxx9cM6DJ+dVBfJ1Q=
|
||||
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
|
||||
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.7/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
|
||||
github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE=
|
||||
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo=
|
||||
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ=
|
||||
github.com/rs/zerolog v1.13.0/go.mod h1:YbFCdg8HfsridGWAh22vktObvhZbQsZXe4/zB0OKkWU=
|
||||
github.com/rs/zerolog v1.15.0/go.mod h1:xYTKnLHcpfU2225ny5qZjxnj9NvkumZYjJHlAThCjNc=
|
||||
github.com/samber/lo v1.39.0 h1:4gTz1wUhNYLhFSKl6O+8peW0v2F4BCY034GRpU9WnuA=
|
||||
github.com/samber/lo v1.39.0/go.mod h1:+m/ZKRl6ClXCE2Lgf3MsQlWfh4bn1bz6CXEOxnEXnEA=
|
||||
github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdhQKdks0=
|
||||
github.com/shopspring/decimal v0.0.0-20180709203117-cd690d0c9e24/go.mod h1:M+9NzErvs504Cn4c5DxATwIqPbtswREoFCre64PpcG4=
|
||||
github.com/shopspring/decimal v1.2.0 h1:abSATXmQEYyShuxI4/vyW3tV1MrKAJzCZ/0zLUXYbsQ=
|
||||
github.com/shopspring/decimal v1.2.0/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o=
|
||||
github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q=
|
||||
github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE=
|
||||
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
|
||||
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||
github.com/tdewolff/minify/v2 v2.20.16 h1:/C8dtRkxLTIyUlKlBz46gDiktCrE8a6+c1gTrnPFz+U=
|
||||
github.com/tdewolff/minify/v2 v2.20.16/go.mod h1:/FvxV9KaTrFu35J9I2FhRvWSBxcHj8sDSdwBFh5voxM=
|
||||
github.com/tdewolff/parse/v2 v2.7.11 h1:v+W45LnzmjndVlfqPCT5gGjAAZKd1GJGOPJveTIkBY8=
|
||||
github.com/tdewolff/parse/v2 v2.7.11/go.mod h1:3FbJWZp3XT9OWVN3Hmfp0p/a08v4h8J9W1aghka0soA=
|
||||
github.com/tdewolff/test v1.0.11-0.20231101010635-f1265d231d52/go.mod h1:6DAvZliBAAnD7rhVgwaM7DE5/d9NMOAJ09SqYqeK4QE=
|
||||
github.com/tdewolff/test v1.0.11-0.20240106005702-7de5f7df4739 h1:IkjBCtQOOjIn03u/dMQK9g+Iw9ewps4mCl1nB8Sscbo=
|
||||
github.com/zenazn/goji v0.9.0/go.mod h1:7S9M489iMyHBNxwZnk9/EHS098H4/F6TATF2mIxtB1Q=
|
||||
go.uber.org/atomic v1.3.2/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.5.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/atomic v1.6.0/go.mod h1:sABNBOSYdrvTF6hTgEIbc7YasKWGhgEQZyfxyTvoXHQ=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.9.0 h1:LF6fAI+IutBocDJ2OT0Q1g8plpYljMZ4+lty+dsqw3g=
|
||||
golang.org/x/crypto v0.9.0/go.mod h1:yrmDGqONDYtNj3tH8X9dzUun2m2lzPa9ngI6/RUPGR0=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 h1:3MTrJm4PyNL9NBqvYDSj3DHl46qQakyfqfWo4jgfaEM=
|
||||
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17/go.mod h1:lgLbSvA5ygNOMpwM/9anMpWVlVJ7Z+cHWq/eFuinpGE=
|
||||
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||
golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc=
|
||||
golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg=
|
||||
golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.10.0 h1:X2//UzNDwYmtCLn7To6G58Wr6f5ahEAQgKNzv9Y951M=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190403152447-81d4e9dc473e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190813064441-fde4db37ae7a/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.16.0 h1:xWw16ngr6ZMtmxDyKyIgsE93KNKz5HKmMa3b8ALHidU=
|
||||
golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425163242-31fd60d6bfdc/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc=
|
||||
golang.org/x/tools v0.0.0-20190823170909-c4a336ef6a2f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||
golang.org/x/xerrors v0.0.0-20190410155217-1f06c39b4373/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190513163551-3ee3066db522/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gorm.io/driver/mysql v1.4.5 h1:u1lytId4+o9dDaNcPCFzNv7h6wvmc92UjNk3z8enSBU=
|
||||
gorm.io/driver/mysql v1.4.5/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
|
||||
gorm.io/driver/postgres v1.4.4 h1:zt1fxJ+C+ajparn0SteEnkoPg0BQ6wOWXEQ99bteAmw=
|
||||
gorm.io/driver/postgres v1.4.4/go.mod h1:whNfh5WhhHs96honoLjBAMwJGYEuA3m1hvgUbNXhPCw=
|
||||
gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
|
||||
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||
honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg=
|
||||
modernc.org/libc v1.22.5 h1:91BNch/e5B0uPbJFgqbxXuOnxBQjlS//icfQEGmvyjE=
|
||||
modernc.org/libc v1.22.5/go.mod h1:jj+Z7dTNX8fBScMVNRAYZ/jF91K8fdT2hYMThc3YjBY=
|
||||
modernc.org/mathutil v1.5.0 h1:rV0Ko/6SfM+8G+yKiyI830l3Wuz1zRutdslNoQ0kfiQ=
|
||||
modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E=
|
||||
modernc.org/memory v1.5.0 h1:N+/8c5rE6EqugZwHii4IFsaJ7MUhoWX07J5tC/iI5Ds=
|
||||
modernc.org/memory v1.5.0/go.mod h1:PkUhL0Mugw21sHPeskwZW4D6VscE/GQJOnIpCnW6pSU=
|
||||
modernc.org/sqlite v1.23.1 h1:nrSBg4aRQQwq59JpvGEQ15tNxoO5pX/kUjcRNwSAGQM=
|
||||
modernc.org/sqlite v1.23.1/go.mod h1:OrDj17Mggn6MhE+iPbBNf7RGKODDE9NFT0f3EwDzJqk=
|
60
internal/api/api.go
Normal file
@ -0,0 +1,60 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/loveuer/nf"
|
||||
"github.com/loveuer/nfflow/internal/handler"
|
||||
"github.com/loveuer/nfflow/internal/middleware/auth"
|
||||
"github.com/loveuer/nfflow/internal/middleware/front"
|
||||
"github.com/loveuer/nfflow/internal/middleware/oplog"
|
||||
"github.com/loveuer/nfflow/internal/middleware/privilege"
|
||||
"github.com/loveuer/nfflow/internal/model"
|
||||
"time"
|
||||
)
|
||||
|
||||
func initApp(ctx context.Context) *nf.App {
|
||||
engine := nf.New(nf.Config{})
|
||||
|
||||
app := engine.Group("/api")
|
||||
app.Get("/available", func(c *nf.Ctx) error {
|
||||
return c.JSON(nf.Map{"status": 200, "ok": true, "time": time.Now()})
|
||||
})
|
||||
|
||||
{
|
||||
api := app.Group("/user")
|
||||
api.Post("/auth/login", oplog.NewOpLog(ctx), handler.AuthLogin)
|
||||
api.Get("/auth/login", auth.NewAuth(), handler.AuthVerify)
|
||||
api.Post("/auth/logout", auth.NewAuth(), oplog.NewOpLog(ctx), handler.AuthLogout)
|
||||
|
||||
mng := api.Group("/manage")
|
||||
mng.Use(auth.NewAuth(), privilege.Verify(
|
||||
privilege.RelationAnd,
|
||||
model.PrivilegeUserManage,
|
||||
))
|
||||
|
||||
mng.Get("/user/list", handler.ManageUserList)
|
||||
mng.Post("/user/create", oplog.NewOpLog(ctx), handler.ManageUserCreate)
|
||||
mng.Post("/user/update", oplog.NewOpLog(ctx), handler.ManageUserUpdate)
|
||||
mng.Post("/user/delete", oplog.NewOpLog(ctx), handler.ManageUserDelete)
|
||||
}
|
||||
|
||||
{
|
||||
api := app.Group("/log")
|
||||
api.Use(auth.NewAuth(), privilege.Verify(privilege.RelationAnd, model.PrivilegeOpLog))
|
||||
api.Get("/category/list", handler.LogCategories())
|
||||
api.Get("/content/list", handler.LogList)
|
||||
}
|
||||
|
||||
{
|
||||
api := app.Group("/task")
|
||||
|
||||
api.Get("/list", handler.TaskList)
|
||||
api.Post("/create", handler.TaskCreate)
|
||||
api.Post("/input/create", handler.TaskInputCreate)
|
||||
api.Post("/input/update", handler.TaskInputUpdate)
|
||||
}
|
||||
|
||||
engine.Use(front.NewFront(&front.DefaultFront, "dist/front/browser"))
|
||||
|
||||
return engine
|
||||
}
|
40
internal/api/start.go
Normal file
@ -0,0 +1,40 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"github.com/loveuer/nfflow/internal/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net"
|
||||
)
|
||||
|
||||
func MustStart(ctx context.Context) {
|
||||
|
||||
app := initApp(ctx)
|
||||
ready := make(chan bool)
|
||||
|
||||
ln, err := net.Listen("tcp", opt.Cfg.Address)
|
||||
if err != nil {
|
||||
logrus.Panicf("api.MustStart: net listen tcp address=%v err=%v", opt.Cfg.Address, err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
ready <- true
|
||||
|
||||
if err = app.RunListener(ln); err != nil {
|
||||
logrus.Panicf("api.MustStart: app run err=%v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
<-ready
|
||||
|
||||
go func() {
|
||||
ready <- true
|
||||
<-ctx.Done()
|
||||
if err = app.Shutdown(util.Timeout(1)); err != nil {
|
||||
logrus.Errorf("api.MustStart: app shutdown err=%v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
<-ready
|
||||
}
|
24
internal/cmd/execute.go
Normal file
@ -0,0 +1,24 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/loveuer/nfflow/internal/api"
|
||||
"github.com/loveuer/nfflow/internal/controller"
|
||||
"github.com/loveuer/nfflow/internal/database"
|
||||
"github.com/loveuer/nfflow/internal/model"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
)
|
||||
|
||||
func Execute(ctx context.Context) error {
|
||||
opt.MustInitConfig()
|
||||
|
||||
database.MustInitClient()
|
||||
model.MustInit(database.DB)
|
||||
controller.Init(database.DB, database.Cache)
|
||||
|
||||
api.MustStart(ctx)
|
||||
|
||||
<-ctx.Done()
|
||||
|
||||
return nil
|
||||
}
|
11
internal/cmd/init.go
Normal file
@ -0,0 +1,11 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.StringVar(&opt.ConfigFile, "c", "etc/config.json", "config json file path")
|
||||
flag.IntVar(&opt.Debug, "debug", 0, "")
|
||||
}
|
19
internal/controller/impl.go
Normal file
@ -0,0 +1,19 @@
|
||||
package controller
|
||||
|
||||
import "github.com/loveuer/nfflow/internal/database"
|
||||
|
||||
type uc struct {
|
||||
db database.Store
|
||||
c database.Caches
|
||||
}
|
||||
|
||||
var (
|
||||
_ userController = uc{}
|
||||
|
||||
// UserController todo: 可以实现自己的 controller
|
||||
UserController userController
|
||||
)
|
||||
|
||||
func Init(db database.Store, cache database.Caches) {
|
||||
UserController = uc{db: db, c: cache}
|
||||
}
|
108
internal/controller/input/es7/client.go
Normal file
@ -0,0 +1,108 @@
|
||||
package es7
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
elastic "github.com/elastic/go-elasticsearch/v7"
|
||||
"github.com/elastic/go-elasticsearch/v7/esapi"
|
||||
"github.com/sirupsen/logrus"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
type Client struct {
|
||||
Endpoints []string `json:"endpoints"`
|
||||
Username string `json:"username"`
|
||||
Password string `json:"password"`
|
||||
CA string `json:"ca"`
|
||||
|
||||
cli *elastic.Client
|
||||
}
|
||||
|
||||
func (c *Client) InitClient(ctx context.Context) error {
|
||||
var (
|
||||
errCh = make(chan error)
|
||||
cliCh = make(chan *elastic.Client)
|
||||
hiddenCa = func(cs string) string {
|
||||
if len(cs) > 0 {
|
||||
return "******"
|
||||
}
|
||||
|
||||
return "nil"
|
||||
}
|
||||
)
|
||||
|
||||
logrus.Debugf("es7.NewClient: endpoints=%v (username=%s password=%s ca=%s)", c.Endpoints, c.Username, c.Password, hiddenCa(c.CA))
|
||||
|
||||
ncFunc := func(endpoints []string, username, password, ca string) {
|
||||
var (
|
||||
err error
|
||||
cli *elastic.Client
|
||||
infoResp *esapi.Response
|
||||
)
|
||||
|
||||
if cli, err = elastic.NewClient(
|
||||
elastic.Config{
|
||||
Addresses: endpoints,
|
||||
Username: username,
|
||||
Password: password,
|
||||
CACert: []byte(c.CA),
|
||||
RetryOnStatus: []int{429},
|
||||
MaxRetries: 3,
|
||||
RetryBackoff: nil,
|
||||
Transport: &http.Transport{
|
||||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
},
|
||||
},
|
||||
); err != nil {
|
||||
logrus.Debugf("es7.NewClient: elastic new client with endponts=%v err=%v", endpoints, err)
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
if infoResp, err = cli.Info(); err != nil {
|
||||
logrus.Debugf("es7.NewClient: ping err=%v", err)
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
if infoResp.StatusCode != 200 {
|
||||
err = fmt.Errorf("info es status=%d", infoResp.StatusCode)
|
||||
logrus.Debugf("es7.NewClient: status err=%v", err)
|
||||
errCh <- err
|
||||
return
|
||||
}
|
||||
|
||||
cliCh <- cli
|
||||
}
|
||||
|
||||
go ncFunc(c.Endpoints, c.Username, c.Password, c.CA)
|
||||
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
return fmt.Errorf("dial es=%s err=%v", c.Endpoints, context.DeadlineExceeded)
|
||||
case c.cli = <-cliCh:
|
||||
return nil
|
||||
case e := <-errCh:
|
||||
return e
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Client) Ping(ctx context.Context) error {
|
||||
rr, err := c.cli.Info(
|
||||
c.cli.Info.WithContext(ctx),
|
||||
)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if rr.StatusCode != 200 {
|
||||
return fmt.Errorf("ping status=%d msg=%s", rr.StatusCode, rr.String())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Save(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
12
internal/controller/interface.go
Normal file
@ -0,0 +1,12 @@
|
||||
package controller
|
||||
|
||||
import "github.com/loveuer/nfflow/internal/model"
|
||||
|
||||
type userController interface {
|
||||
GetUser(id uint64) (*model.User, error)
|
||||
GetUserByToken(token string) (*model.User, error)
|
||||
CacheUser(user *model.User) error
|
||||
CacheToken(token string, user *model.User) error
|
||||
RmUserCache(id uint64) error
|
||||
DeleteUser(id uint64) error
|
||||
}
|
139
internal/controller/user.go
Normal file
@ -0,0 +1,139 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/loveuer/nf/nft/resp"
|
||||
"github.com/loveuer/nfflow/internal/database"
|
||||
"github.com/loveuer/nfflow/internal/model"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"github.com/loveuer/nfflow/internal/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/spf13/cast"
|
||||
"gorm.io/gorm"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func (u uc) GetUser(id uint64) (*model.User, error) {
|
||||
var (
|
||||
err error
|
||||
target = new(model.User)
|
||||
key = fmt.Sprintf("%s:user:id:%d", opt.CachePrefix, id)
|
||||
bs []byte
|
||||
)
|
||||
|
||||
if opt.EnableUserCache {
|
||||
if bs, err = u.c.Get(util.Timeout(3), key); err != nil {
|
||||
logrus.Warnf("controller.GetUser: get user by cache key=%s err=%v", key, err)
|
||||
goto ByDB
|
||||
}
|
||||
|
||||
if err = json.Unmarshal(bs, target); err != nil {
|
||||
logrus.Warnf("controller.GetUser: json unmarshal key=%s by=%s err=%v", key, string(bs), err)
|
||||
goto ByDB
|
||||
}
|
||||
|
||||
return target, nil
|
||||
}
|
||||
|
||||
ByDB:
|
||||
if err = u.db.Session(util.Timeout(3)).
|
||||
Model(&model.User{}).
|
||||
Where("id = ?", id).
|
||||
Take(target).
|
||||
Error; err != nil {
|
||||
if errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
// tips: 公开项目需要考虑击穿处理
|
||||
return target, resp.NewError(400, "目标不存在", err, nil)
|
||||
}
|
||||
|
||||
return target, resp.NewError(500, "", err, nil)
|
||||
}
|
||||
|
||||
if opt.EnableUserCache {
|
||||
if err = u.CacheUser(target); err != nil {
|
||||
logrus.Warnf("controller.GetUser: cache user key=%s err=%v", key, err)
|
||||
}
|
||||
}
|
||||
|
||||
return target, nil
|
||||
}
|
||||
|
||||
func (u uc) GetUserByToken(token string) (*model.User, error) {
|
||||
strs := strings.Split(token, ".")
|
||||
if len(strs) != 3 {
|
||||
return nil, fmt.Errorf("controller.GetUserByToken: jwt token invalid, token=%s", token)
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("%s:user:token:%s", opt.CachePrefix, strs[2])
|
||||
bs, err := u.c.Get(util.Timeout(3), key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
logrus.Tracef("controller.GetUserByToken: key=%s cache bytes=%s", key, string(bs))
|
||||
|
||||
userId := cast.ToUint64(string(bs))
|
||||
if userId == 0 {
|
||||
return nil, fmt.Errorf("controller.GetUserByToken: bs=%s cast to uint64 err", string(bs))
|
||||
}
|
||||
|
||||
var op *model.User
|
||||
|
||||
if op, err = u.GetUser(userId); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return op, nil
|
||||
}
|
||||
|
||||
func (u uc) CacheUser(target *model.User) error {
|
||||
key := fmt.Sprintf("%s:user:id:%d", opt.CachePrefix, target.Id)
|
||||
return u.c.Set(util.Timeout(3), key, target)
|
||||
}
|
||||
|
||||
func (u uc) CacheToken(token string, user *model.User) error {
|
||||
strs := strings.Split(token, ".")
|
||||
if len(strs) != 3 {
|
||||
return fmt.Errorf("controller.CacheToken: jwt token invalid")
|
||||
}
|
||||
|
||||
key := fmt.Sprintf("%s:user:token:%s", opt.CachePrefix, strs[2])
|
||||
return u.c.SetEx(util.Timeout(3), key, user.Id, opt.TokenTimeout)
|
||||
}
|
||||
func (u uc) RmUserCache(id uint64) error {
|
||||
key := fmt.Sprintf("%s:user:id:%d", opt.CachePrefix, id)
|
||||
return u.c.Del(util.Timeout(3), key)
|
||||
}
|
||||
|
||||
func (u uc) DeleteUser(id uint64) error {
|
||||
var (
|
||||
err error
|
||||
now = time.Now()
|
||||
username = "CONCAT(username, '@del')"
|
||||
)
|
||||
|
||||
if opt.Cfg.Database.Type == "sqlite" {
|
||||
username = "username || '@del'"
|
||||
}
|
||||
|
||||
if err = database.DB.Session(util.Timeout(5)).
|
||||
Model(&model.User{}).
|
||||
Where("id = ?", id).
|
||||
Updates(map[string]any{
|
||||
"deleted_at": now.UnixMilli(),
|
||||
"username": gorm.Expr(username),
|
||||
}).Error; err != nil {
|
||||
return resp.NewError(500, "", err, nil)
|
||||
}
|
||||
|
||||
if opt.EnableUserCache {
|
||||
if err = u.RmUserCache(id); err != nil {
|
||||
logrus.Warnf("controller.DeleteUser: rm user=%d cache err=%v", id, err)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
26
internal/database/cache.go
Normal file
@ -0,0 +1,26 @@
|
||||
package database
|
||||
|
||||
import "encoding/json"
|
||||
|
||||
type encoded_value interface {
|
||||
MarshalBinary() ([]byte, error)
|
||||
}
|
||||
|
||||
type decoded_value interface {
|
||||
UnmarshalBinary(bs []byte) error
|
||||
}
|
||||
|
||||
func handleValue(value any) ([]byte, error) {
|
||||
var (
|
||||
bs []byte
|
||||
err error
|
||||
)
|
||||
|
||||
if imp, ok := value.(encoded_value); ok {
|
||||
bs, err = imp.MarshalBinary()
|
||||
} else {
|
||||
bs, err = json.Marshal(value)
|
||||
}
|
||||
|
||||
return bs, err
|
||||
}
|
63
internal/database/cache_memory.go
Normal file
@ -0,0 +1,63 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"gitea.com/taozitaozi/gredis"
|
||||
"time"
|
||||
)
|
||||
|
||||
var _ Caches = (*_mem)(nil)
|
||||
|
||||
type _mem struct {
|
||||
client *gredis.Gredis
|
||||
}
|
||||
|
||||
func (m *_mem) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
v, err := m.client.Get(key)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs, ok := v.([]byte)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid value type=%T", v)
|
||||
}
|
||||
|
||||
return bs, nil
|
||||
}
|
||||
|
||||
func (m *_mem) GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error) {
|
||||
v, err := m.client.GetEx(key, duration)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
bs, ok := v.([]byte)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("invalid value type=%T", v)
|
||||
}
|
||||
|
||||
return bs, nil
|
||||
}
|
||||
|
||||
func (m *_mem) Set(ctx context.Context, key string, value any) error {
|
||||
bs, err := handleValue(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return m.client.Set(key, bs)
|
||||
}
|
||||
|
||||
func (m *_mem) SetEx(ctx context.Context, key string, value any, duration time.Duration) error {
|
||||
bs, err := handleValue(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return m.client.SetEx(key, bs, duration)
|
||||
}
|
||||
|
||||
func (m *_mem) Del(ctx context.Context, keys ...string) error {
|
||||
m.client.Delete(keys...)
|
||||
return nil
|
||||
}
|
54
internal/database/cache_redis.go
Normal file
@ -0,0 +1,54 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"time"
|
||||
)
|
||||
|
||||
type _redis struct {
|
||||
client *redis.Client
|
||||
}
|
||||
|
||||
func (r *_redis) Get(ctx context.Context, key string) ([]byte, error) {
|
||||
result, err := r.client.Get(ctx, key).Result()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []byte(result), nil
|
||||
}
|
||||
|
||||
func (r *_redis) GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error) {
|
||||
result, err := r.client.GetEx(ctx, key, duration).Result()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return []byte(result), nil
|
||||
}
|
||||
|
||||
func (r *_redis) Set(ctx context.Context, key string, value any) error {
|
||||
bs, err := handleValue(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.client.Set(ctx, key, bs, redis.KeepTTL).Result()
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *_redis) SetEx(ctx context.Context, key string, value any, duration time.Duration) error {
|
||||
bs, err := handleValue(value)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = r.client.SetEX(ctx, key, bs, duration).Result()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (r *_redis) Del(ctx context.Context, keys ...string) error {
|
||||
return r.client.Del(ctx, keys...).Err()
|
||||
}
|
6
internal/database/client.go
Normal file
@ -0,0 +1,6 @@
|
||||
package database
|
||||
|
||||
var (
|
||||
DB Store
|
||||
Cache Caches
|
||||
)
|
89
internal/database/init.go
Normal file
@ -0,0 +1,89 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gitea.com/taozitaozi/gredis"
|
||||
"github.com/glebarez/sqlite"
|
||||
"github.com/go-redis/redis/v8"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"github.com/loveuer/nfflow/internal/util"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/driver/postgres"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
func MustInitClient() {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
|
||||
// todo: 可以实现自己的 "Store" sql_db, like sqlite, postgresql
|
||||
if DB, err = initSql(); err != nil {
|
||||
panic(fmt.Errorf("database.MustInitClient: init sql err=%v", err))
|
||||
}
|
||||
|
||||
// todo: 可以实现自己的 "Caches" 缓存, like redis
|
||||
if Cache, err = initCacher(); err != nil {
|
||||
panic(fmt.Errorf("database.MustInitCache: init cache err=%v", err))
|
||||
}
|
||||
}
|
||||
|
||||
func initSql() (Store, error) {
|
||||
var (
|
||||
err error
|
||||
client *gorm.DB
|
||||
)
|
||||
|
||||
switch opt.Cfg.Database.Type {
|
||||
case "postgresql":
|
||||
dsn := fmt.Sprintf("host=%s user=%s password=%s dbname=%s port=%d sslmode=disable TimeZone=Asia/Shanghai",
|
||||
opt.Cfg.Database.Host, opt.Cfg.Database.Username, opt.Cfg.Database.Password, opt.Cfg.Database.DB, opt.Cfg.Database.Port)
|
||||
if client, err = gorm.Open(postgres.Open(dsn)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "mysql":
|
||||
dsn := fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?charset=utf8mb4&parseTime=True&loc=Local",
|
||||
opt.Cfg.Database.Username, opt.Cfg.Database.Password, opt.Cfg.Database.Host, opt.Cfg.Database.Port, opt.Cfg.Database.DB)
|
||||
if client, err = gorm.Open(mysql.Open(dsn)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
case "sqlite":
|
||||
if client, err = gorm.Open(sqlite.Open(opt.Cfg.Database.Path)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupportted databsae type=%s", opt.Cfg.Database.Type)
|
||||
}
|
||||
|
||||
return &_db{client: client}, nil
|
||||
}
|
||||
|
||||
func initCacher() (Caches, error) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
|
||||
switch opt.Cfg.Cache.Type {
|
||||
case "redis":
|
||||
var rc *redis.Client
|
||||
rc = redis.NewClient(&redis.Options{
|
||||
Addr: fmt.Sprintf("%s:%d", opt.Cfg.Cache.Host, opt.Cfg.Cache.Port),
|
||||
Username: opt.Cfg.Cache.Username,
|
||||
Password: opt.Cfg.Cache.Password,
|
||||
})
|
||||
|
||||
if err = rc.Ping(util.Timeout(5)).Err(); err != nil {
|
||||
return nil, fmt.Errorf("redis ping err=%v", err)
|
||||
}
|
||||
|
||||
return &_redis{client: rc}, nil
|
||||
case "memory":
|
||||
var mc *gredis.Gredis
|
||||
mc = gredis.NewGredis(-1)
|
||||
|
||||
return &_mem{client: mc}, nil
|
||||
default:
|
||||
return nil, fmt.Errorf("unsupportted cache type=%s", opt.Cfg.Cache.Type)
|
||||
}
|
||||
|
||||
}
|
21
internal/database/interface.go
Normal file
@ -0,0 +1,21 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Caches interface {
|
||||
Get(ctx context.Context, key string) ([]byte, error)
|
||||
GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error)
|
||||
// Set value 会被序列化, 优先使用 MarshalBinary 方法, 没有则执行 json.Marshal
|
||||
Set(ctx context.Context, key string, value any) error
|
||||
// SetEx value 会被序列化, 优先使用 MarshalBinary 方法, 没有则执行 json.Marshal
|
||||
SetEx(ctx context.Context, key string, value any, duration time.Duration) error
|
||||
Del(ctx context.Context, keys ...string) error
|
||||
}
|
||||
|
||||
type Store interface {
|
||||
Session(ctx context.Context) *gorm.DB
|
||||
}
|
20
internal/database/sql.go
Normal file
@ -0,0 +1,20 @@
|
||||
package database
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type _db struct {
|
||||
client *gorm.DB
|
||||
}
|
||||
|
||||
func (d *_db) Session(ctx context.Context) *gorm.DB {
|
||||
s := d.client.Session(&gorm.Session{})
|
||||
if opt.Debug > 0 || opt.DBDebug {
|
||||
s = s.Debug()
|
||||
}
|
||||
|
||||
return s
|
||||
}
|
102
internal/handler/log.go
Normal file
@ -0,0 +1,102 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"github.com/loveuer/nf"
|
||||
"github.com/loveuer/nf/nft/resp"
|
||||
"github.com/loveuer/nfflow/internal/database"
|
||||
"github.com/loveuer/nfflow/internal/model"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"github.com/loveuer/nfflow/internal/sqlType"
|
||||
"github.com/loveuer/nfflow/internal/util"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func LogCategories() nf.HandlerFunc {
|
||||
return func(c *nf.Ctx) error {
|
||||
return resp.Resp200(c, model.OpLogType(0).All())
|
||||
}
|
||||
}
|
||||
|
||||
func LogList(c *nf.Ctx) error {
|
||||
type Req struct {
|
||||
Page int `query:"page"`
|
||||
Size int `query:"size"`
|
||||
UserIds []uint64 `query:"user_ids"`
|
||||
Types sqlType.NumSlice[model.OpLogType] `query:"types"`
|
||||
}
|
||||
|
||||
var (
|
||||
ok bool
|
||||
op *model.User
|
||||
err error
|
||||
req = new(Req)
|
||||
list = make([]*model.OpLog, 0)
|
||||
total int
|
||||
)
|
||||
|
||||
if op, ok = c.Locals("user").(*model.User); !ok {
|
||||
return resp.Resp401(c, nil)
|
||||
}
|
||||
|
||||
if err = c.QueryParser(req); err != nil {
|
||||
return resp.Resp400(c, err.Error())
|
||||
}
|
||||
|
||||
if req.Size <= 0 {
|
||||
req.Size = opt.DefaultSize
|
||||
}
|
||||
|
||||
if req.Size > opt.MaxSize {
|
||||
return resp.Resp400(c, req, "参数过大")
|
||||
}
|
||||
|
||||
txCount := op.Role.Where(database.DB.Session(util.Timeout(3)).
|
||||
Model(&model.OpLog{}).
|
||||
Select("COUNT(`op_logs`.`id`)").
|
||||
Joins("LEFT JOIN users ON `users`.`id` = `op_logs`.`user_id`"))
|
||||
txGet := op.Role.Where(database.DB.Session(util.Timeout(10)).
|
||||
Model(&model.OpLog{}).
|
||||
Joins("LEFT JOIN users ON `users`.`id` = `op_logs`.`user_id`"))
|
||||
|
||||
if len(req.UserIds) != 0 {
|
||||
txCount = txCount.Where("op_logs.user_id IN ?", req.UserIds)
|
||||
txGet = txGet.Where("op_logs.user_id IN ?", req.UserIds)
|
||||
}
|
||||
|
||||
if len(req.Types) != 0 {
|
||||
txCount = txCount.Where("op_logs.type IN ?", req.Types)
|
||||
txGet = txGet.Where("op_logs.type IN ?", req.Types)
|
||||
}
|
||||
|
||||
if err = txCount.
|
||||
Find(&total).
|
||||
Error; err != nil {
|
||||
return resp.Resp500(c, err.Error())
|
||||
}
|
||||
|
||||
if err = txGet.
|
||||
Offset(req.Page * req.Size).
|
||||
Limit(req.Size).
|
||||
Order("`op_logs`.`created_at` DESC").
|
||||
Find(&list).
|
||||
Error; err != nil {
|
||||
return resp.Resp500(c, err.Error())
|
||||
}
|
||||
|
||||
for _, log := range list {
|
||||
m := make(map[string]any)
|
||||
if err = log.Content.Bind(&m); err != nil {
|
||||
logrus.Warnf("handler.LogList: log=%d content=%v bind map[string]any err=%v", log.Id, log.Content, err)
|
||||
continue
|
||||
}
|
||||
|
||||
if log.HTML, err = log.Type.Render(m); err != nil {
|
||||
logrus.Warnf("handler.LogList: log=%d template=%s render map=%+v err=%v", log.Id, log.Type.Template(), m, err)
|
||||
continue
|
||||
}
|
||||
|
||||
logrus.Tracef("handler.LogList: log=%d render map=%+v string=%s", log.Id, m, log.HTML)
|
||||
}
|
||||
|
||||
return resp.Resp200(c, nf.Map{"list": list, "total": total})
|
||||
}
|
125
internal/handler/task.go
Normal file
@ -0,0 +1,125 @@
|
||||
package handler
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/loveuer/nf"
|
||||
"github.com/loveuer/nf/nft/resp"
|
||||
"github.com/loveuer/nfflow/internal/database"
|
||||
"github.com/loveuer/nfflow/internal/model"
|
||||
"github.com/loveuer/nfflow/internal/opt"
|
||||
"github.com/loveuer/nfflow/internal/sqlType"
|
||||
"github.com/loveuer/nfflow/internal/util"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TaskList(c *nf.Ctx) error {
|
||||
type Req struct {
|
||||
Keyword string `query:"keyword,omitempty"`
|
||||
Page int `query:"page,omitempty"`
|
||||
Size int `query:"size,omitempty"`
|
||||
Targets sqlType.NumSlice[uint64] `query:"targets,omitempty"`
|
||||
}
|
||||
|
||||
var (
|
||||
err error
|
||||
req = new(Req)
|
||||
total int
|
||||
list = make([]*model.Task, 0)
|
||||
)
|
||||
|
||||
if err = c.QueryParser(req); err != nil {
|
||||
return resp.Resp400(c, err.Error())
|
||||
}
|
||||
|
||||
if req.Size <= 0 {
|
||||
req.Size = 20
|
||||
}
|
||||
|
||||
txGet := database.DB.Session(util.Timeout(10)).
|
||||
Model(&model.Task{})
|
||||
txCount := database.DB.Session(util.Timeout(5)).
|
||||
Model(&model.Task{}).
|
||||
Select("COUNT(id)")
|
||||
|
||||
if req.Keyword != "" {
|
||||
key := fmt.Sprintf("%%%s%%", req.Keyword)
|
||||
txGet = txGet.Where("task_name", key)
|
||||
txCount = txCount.Where("task_name", key)
|
||||
}
|
||||
|
||||
if err = txCount.Find(&total).Error; err != nil {
|
||||
return resp.Resp500(c, err.Error())
|
||||
}
|
||||
|
||||
if err = txGet.
|
||||
Order("updated_at DESC").
|
||||
Offset(req.Page * req.Size).
|
||||
Limit(req.Size).
|
||||
Find(&list).
|
||||
Error; err != nil {
|
||||
return resp.Resp500(c, err.Error())
|
||||
}
|
||||
|
||||
return resp.Resp200(c, nf.Map{"list": list, "total": total})
|
||||
}
|
||||
|
||||
func TaskCreate(c *nf.Ctx) error {
|
||||
type Req struct {
|
||||
TaskName string `json:"task_name"`
|
||||
TaskType string `json:"task_type"`
|
||||
Timeout int `json:"timeout"`
|
||||
Cron string `json:"cron"`
|
||||
RunAt int64 `json:"run_at"`
|
||||
}
|
||||
|
||||
var (
|
||||
err error
|
||||
req = new(Req)
|
||||
now = time.Now()
|
||||
)
|
||||
|
||||
if err = c.BodyParser(req); err != nil {
|
||||
return resp.Resp400(c, err.Error())
|
||||
}
|
||||
|
||||
if req.TaskName != "" {
|
||||
return resp.Resp400(c, req)
|
||||
}
|
||||
|
||||
task := &model.Task{TaskName: req.TaskName}
|
||||
|
||||
if req.Timeout < opt.TaskMinTimeout || req.Timeout > opt.TaskMaxTimeout {
|
||||
return resp.Resp400(c, req, fmt.Sprintf("timeout 时长过短(%d - %d)", opt.TaskMinTimeout, opt.TaskMaxTimeout))
|
||||
}
|
||||
|
||||
task.TimeoutSecond = req.Timeout
|
||||
|
||||
switch req.TaskType {
|
||||
case "once":
|
||||
case "timing":
|
||||
rt := time.UnixMilli(req.RunAt)
|
||||
if rt.Sub(now).Seconds() > opt.TaskFetchInterval {
|
||||
return resp.Resp400(c, req, "任务执行时间距离当前时间太短")
|
||||
}
|
||||
task.TaskRunType = fmt.Sprintf("T-%d", req.RunAt)
|
||||
case "cron":
|
||||
task.TaskRunType = fmt.Sprintf("C-%s", req.TaskType)
|
||||
default:
|
||||
return resp.Resp400(c, req, "任务执行类型: once/timing/cron")
|
||||
}
|
||||
|
||||
if err = database.DB.Session(util.Timeout(5)).
|
||||
Create(task).
|
||||
Error; err != nil {
|
||||
return resp.Resp500(c, err.Error())
|
||||
}
|
||||
|
||||
return resp.Resp200(c, task)
|
||||
}
|
||||
|
||||
func TaskInputCreate(c *nf.Ctx) error {
|
||||
panic("impl")
|
||||
}
|
||||
func TaskInputUpdate(c *nf.Ctx) error {
|
||||
panic("impl")
|
||||
}
|