Compare commits
No commits in common. "master" and "dev" have entirely different histories.
2
.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
.idea
|
.idea
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.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)
|
||||||
|
}
|
||||||
|
}
|
70
front/src/app/page/task/task.component.html
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
<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="updated_at">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>updated_at</th>
|
||||||
|
<td mat-cell *matCellDef="let element"> {{ element.updated_at | date: "yyyy-MM-dd HH:mm:SS" }}</td>
|
||||||
|
</ng-container>
|
||||||
|
|
||||||
|
<ng-container matColumnDef="task_run_type">
|
||||||
|
<th mat-header-cell *matHeaderCellDef>task_run_type</th>
|
||||||
|
<td mat-cell *matCellDef="let element" [matTooltip]="element.task_cron"> {{ element.task_run_type.label }}</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","updated_at", "task_run_type", "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"
|
||||||
|
]
|
||||||
|
}
|
57
go.mod
@ -1,16 +1,63 @@
|
|||||||
module github.com/loveuer/nfflow
|
module github.com/loveuer/nfflow
|
||||||
|
|
||||||
go 1.22.1
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
10.220.10.35/tools/toolkits v0.1.5
|
||||||
|
gitea.com/taozitaozi/gredis v0.0.0-20240131032054-b02845ce1e9d
|
||||||
|
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204
|
||||||
github.com/elastic/go-elasticsearch/v7 v7.17.10
|
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/loveuer/nf v0.1.3
|
||||||
|
github.com/robertkrimen/otto v0.3.0
|
||||||
|
github.com/robfig/cron/v3 v3.0.1
|
||||||
|
github.com/samber/lo v1.39.0
|
||||||
github.com/sirupsen/logrus v1.9.3
|
github.com/sirupsen/logrus v1.9.3
|
||||||
github.com/spf13/cobra v1.8.0
|
github.com/spf13/cast v1.6.0
|
||||||
|
github.com/tdewolff/minify/v2 v2.20.16
|
||||||
|
golang.org/x/crypto v0.18.0
|
||||||
|
google.golang.org/grpc v1.62.1
|
||||||
|
google.golang.org/protobuf v1.33.0
|
||||||
|
gorm.io/driver/mysql v1.4.5
|
||||||
|
gorm.io/driver/postgres v1.4.4
|
||||||
|
gorm.io/gorm v1.25.5
|
||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 // indirect
|
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||||
github.com/spf13/pflag v1.0.5 // indirect
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 // indirect
|
github.com/dlclark/regexp2 v1.7.0 // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
||||||
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.3 // indirect
|
||||||
|
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
|
||||||
|
github.com/google/uuid v1.6.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/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
|
github.com/stretchr/testify v1.8.4 // indirect
|
||||||
|
github.com/tdewolff/parse/v2 v2.7.11 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
|
||||||
|
golang.org/x/net v0.20.0 // indirect
|
||||||
|
golang.org/x/sys v0.16.0 // indirect
|
||||||
|
golang.org/x/text v0.14.0 // indirect
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 // indirect
|
||||||
|
gopkg.in/sourcemap.v1 v1.0.5 // 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
|
||||||
)
|
)
|
||||||
|
316
go.sum
@ -1,28 +1,324 @@
|
|||||||
github.com/cpuguy83/go-md2man/v2 v2.0.3/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
10.220.10.35/tools/toolkits v0.1.5 h1:GQLaopybqBSFo3GAMWaluHVppy/7yHCk03Z7CvewdJY=
|
||||||
|
10.220.10.35/tools/toolkits v0.1.5/go.mod h1:rv31y3I4yZPihBT49V3JhAdu2aOMqxABdIMeb6qXd1A=
|
||||||
|
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.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||||
|
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/chzyer/logex v1.2.0/go.mod h1:9+9sk7u7pGNWYMkh0hdiL++6OeibzJccyQU4p4MedaY=
|
||||||
|
github.com/chzyer/readline v1.5.0/go.mod h1:x22KAscuvRqlLoK9CsoYsmxoXZMMFVyOl86cAH8qUic=
|
||||||
|
github.com/chzyer/test v0.0.0-20210722231415-061457976a23/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||||
|
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/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
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/dlclark/regexp2 v1.4.1-0.20201116162257-a2a8dda75c91/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
|
||||||
|
github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo=
|
||||||
|
github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
|
github.com/dop251/goja v0.0.0-20211022113120-dc8c55024d06/go.mod h1:R9ET47fwRVRPZnOGvHxxhuZcbrMCuiqOz3Rlrh4KSnk=
|
||||||
|
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 h1:O7I1iuzEA7SG+dK8ocOBSlYAA9jBUmCYl/Qa7ey7JAM=
|
||||||
|
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204/go.mod h1:QMWlm50DNe14hD7t24KEqZuUdC9sOTy8W6XbCU1mlw4=
|
||||||
|
github.com/dop251/goja_nodejs v0.0.0-20210225215109-d91c329300e7/go.mod h1:hn7BA7c8pLvoGndExHudxTDKZ84Pyvv+90pbBjbTz0Y=
|
||||||
|
github.com/dop251/goja_nodejs v0.0.0-20211022123610-8dd9abb0616d/go.mod h1:DngW8aVqWbuLRMHItjPUyqdj+HWPvnQe8V8y1nDpIbM=
|
||||||
|
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 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo=
|
||||||
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
|
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
|
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-sourcemap/sourcemap v2.1.3+incompatible h1:W1iEw64niKVGogNgBN3ePyLFfuisuzeidWPMPWmECqU=
|
||||||
|
github.com/go-sourcemap/sourcemap v2.1.3+incompatible/go.mod h1:F8jJfvm2KbVjc5NqelyYJmf/v5J0dwNLS2mL4sNA1Jg=
|
||||||
|
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/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||||
|
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
|
||||||
|
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 h1:4/hN5RUoecvl+RmJRE2YxKWtnnQls6rQjjW5oV7qg2U=
|
||||||
|
github.com/google/pprof v0.0.0-20230207041349-798e818bf904/go.mod h1:uglQLonpP8qtYCYyzA+8c/9qtqgA3qsXGYqCPKARAFg=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
|
||||||
|
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
github.com/ianlancetaylor/demangle v0.0.0-20220319035150-800ac71e25c2/go.mod h1:aYm2/VgdVmcIU8iMfdMvDMsRAQjcfZSKFby6HOFvi/w=
|
||||||
|
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.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||||
|
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||||
|
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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||||
|
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 h1:tZP+FtwhiU+VTfPwfaEQUmiw1z6U9XwfDzJV46h5vZw=
|
||||||
github.com/loveuer/nf v0.1.3/go.mod h1:uKsKYym27ravyTXSBSnxU86V7osxx9cM6DJ+dVBfJ1Q=
|
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/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
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/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
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/robertkrimen/otto v0.3.0 h1:5RI+8860NSxvXywDY9ddF5HcPw0puRsd8EgbXV0oqRE=
|
||||||
|
github.com/robertkrimen/otto v0.3.0/go.mod h1:uW9yN1CYflmUQYvAMS0m+ZiNo3dMzRUDQJX0jWbzgxw=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
|
||||||
|
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||||
|
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 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
|
||||||
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
github.com/spf13/cobra v1.8.0 h1:7aJaZx1B85qltLMc546zn58BxxfZdR/W22ej9CFoEf0=
|
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||||
github.com/spf13/cobra v1.8.0/go.mod h1:WXLWApfZ71AjXPya3WOlMsY9yMs7YeiHhFVlvLyhcho=
|
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
|
||||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
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.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8 h1:0A+M6Uqn+Eje4kHMK80dtF3JCXC4ykBgQG4Fe06QRhQ=
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||||
|
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||||
|
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/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||||
|
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-20210921155107-089bfa567519/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.18.0 h1:PGVlW0xEltQnzFZ55hkuX5+KLyrMYhHld1YHO4AKcdc=
|
||||||
|
golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg=
|
||||||
|
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/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||||
|
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.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||||
|
golang.org/x/net v0.20.0 h1:aCL9BSgETF1k+blQaYUBx9hJ9LOGP3gAVemcZlf1Kpo=
|
||||||
|
golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/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-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/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/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||||
|
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.3.8/go.mod h1:E6s5w1FMmriuDzIBO73fBruAKo1PCIq6d2Q6DHfQ8WQ=
|
||||||
|
golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=
|
||||||
|
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||||
|
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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||||
|
golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||||
|
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-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80 h1:AjyfHzEPEFp/NpvfN5g+KDla3EMojjhRVZc1i7cj+oM=
|
||||||
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240123012728-ef4313101c80/go.mod h1:PAREbraiVEVGVdTZsVWjSbbTtSyGbAgIIvni8a8CD5s=
|
||||||
|
google.golang.org/grpc v1.62.1 h1:B4n+nfKzOICUXMgyrNd19h/I9oH0L1pizfk1d4zSgTk=
|
||||||
|
google.golang.org/grpc v1.62.1/go.mod h1:IWTG0VlJLCh1SkC58F7np9ka9mx/WNkjl4PGJaiq+QE=
|
||||||
|
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
|
||||||
|
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
|
||||||
|
google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI=
|
||||||
|
google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
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/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||||
|
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/sourcemap.v1 v1.0.5 h1:inv58fC9f9J3TK2Y2R1NPntXEn3/wjWHkonhIUODNTI=
|
||||||
|
gopkg.in/sourcemap.v1 v1.0.5/go.mod h1:2RlvNNSMglmRrcvhfuzp4hQHwOtjxlbjX7UPY/GXb78=
|
||||||
|
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.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
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=
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
package interfaces
|
|
||||||
|
|
||||||
import "context"
|
|
||||||
|
|
||||||
type Input interface {
|
|
||||||
InitClient(ctx context.Context) error
|
|
||||||
Fetch(ctx context.Context, limit int)
|
|
||||||
Close(ctx context.Context) error
|
|
||||||
}
|
|
@ -1 +0,0 @@
|
|||||||
package interfaces
|
|
@ -1 +0,0 @@
|
|||||||
package interfaces
|
|
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, "")
|
||||||
|
}
|
@ -1,34 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/loveuer/nfflow/internal/opt"
|
|
||||||
"github.com/loveuer/nfflow/internal/srv"
|
|
||||||
"github.com/spf13/cobra"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
version bool
|
|
||||||
root = &cobra.Command{
|
|
||||||
Use: "nfflow",
|
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
|
||||||
if version {
|
|
||||||
fmt.Printf("nfflow \nVersion: %s\n", opt.Version)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
run = &cobra.Command{
|
|
||||||
Use: "run",
|
|
||||||
Example: "nfflow run --address ':80'",
|
|
||||||
RunE: func(cmd *cobra.Command, args []string) error {
|
|
||||||
return srv.Run(cmd.Context())
|
|
||||||
},
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
root.Flags().BoolVarP(&version, "version", "v", false, "print version")
|
|
||||||
run.Flags().StringVar(&opt.Cfg.Address, "address", ":80", "service listen address")
|
|
||||||
root.AddCommand(run)
|
|
||||||
}
|
|
@ -1,13 +0,0 @@
|
|||||||
package cmd
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"github.com/sirupsen/logrus"
|
|
||||||
)
|
|
||||||
|
|
||||||
func Run(ctx context.Context) {
|
|
||||||
if err := root.ExecuteContext(ctx); err != nil {
|
|
||||||
logrus.Debugf("cmd.Run: execute with err=%v", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
|
22
internal/controller/impl.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/loveuer/nfflow/internal/database"
|
||||||
|
"github.com/loveuer/nfflow/internal/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
type uc struct {
|
||||||
|
db database.Store
|
||||||
|
c database.Caches
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
_ interfaces.UserController = (*uc)(nil)
|
||||||
|
|
||||||
|
// UserController todo: 可以实现自己的 controller
|
||||||
|
UserController interfaces.UserController
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init(db database.Store, cache database.Caches) {
|
||||||
|
UserController = uc{db: db, c: cache}
|
||||||
|
}
|
219
internal/controller/input/es7/es7.go
Normal file
@ -0,0 +1,219 @@
|
|||||||
|
package es7
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"context"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
elastic "github.com/elastic/go-elasticsearch/v7"
|
||||||
|
"github.com/elastic/go-elasticsearch/v7/esapi"
|
||||||
|
"github.com/loveuer/nfflow/internal/interfaces"
|
||||||
|
"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"
|
||||||
|
)
|
||||||
|
|
||||||
|
type ES7 struct {
|
||||||
|
cli *elastic.Client
|
||||||
|
scroll string
|
||||||
|
query map[string]any
|
||||||
|
size int
|
||||||
|
max int
|
||||||
|
source []string
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewInput(cfg sqlType.JSONB) (interfaces.Input, error) {
|
||||||
|
type config struct {
|
||||||
|
Endpoints []string `json:"endpoints"`
|
||||||
|
Username string `json:"username"`
|
||||||
|
Password string `json:"password"`
|
||||||
|
Size int `json:"size"`
|
||||||
|
Max int `json:"max"`
|
||||||
|
Query map[string]any `json:"query"`
|
||||||
|
Source []string `json:"source"`
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
c = new(config)
|
||||||
|
ins = &ES7{}
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = cfg.Bind(c); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = ins.Init(c.Endpoints, c.Username, c.Password); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
ins.query = c.Query
|
||||||
|
ins.size = c.Size
|
||||||
|
ins.max = c.Max
|
||||||
|
ins.source = c.Source
|
||||||
|
|
||||||
|
return ins, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ES7) Init(endpoints []string, username, password string) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
cfg = elastic.Config{
|
||||||
|
Addresses: endpoints,
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
RetryOnStatus: []int{429},
|
||||||
|
}
|
||||||
|
info *esapi.Response
|
||||||
|
)
|
||||||
|
|
||||||
|
if e.cli, err = elastic.NewClient(cfg); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if info, err = e.cli.Info(e.cli.Info.WithContext(util.Timeout(5))); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if info.StatusCode != 200 {
|
||||||
|
return fmt.Errorf("status=%d msg=%s", info.StatusCode, info.String())
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ES7) Start(ctx context.Context, rowCh chan<- interfaces.Row, errCh chan<- error) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
result *esapi.Response
|
||||||
|
ready = make(chan bool)
|
||||||
|
decoder *json.Decoder
|
||||||
|
|
||||||
|
hits = new(model.ESResponse)
|
||||||
|
)
|
||||||
|
|
||||||
|
qs := []func(*esapi.SearchRequest){
|
||||||
|
e.cli.Search.WithContext(util.TimeoutCtx(ctx, opt.ES7OperationTimeout)),
|
||||||
|
e.cli.Search.WithScroll(opt.ScrollTimeout),
|
||||||
|
e.cli.Search.WithSize(e.size),
|
||||||
|
}
|
||||||
|
|
||||||
|
if e.query != nil && len(e.query) > 0 {
|
||||||
|
var bs []byte
|
||||||
|
if bs, err = json.Marshal(map[string]any{"query": e.query}); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: marshal query err=%v", err)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
qs = append(qs, e.cli.Search.WithBody(bytes.NewReader(bs)))
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
defer func() {
|
||||||
|
if e.scroll != "" {
|
||||||
|
var csr *esapi.Response
|
||||||
|
if csr, err = e.cli.ClearScroll(
|
||||||
|
e.cli.ClearScroll.WithContext(util.TimeoutCtx(ctx, 5)),
|
||||||
|
e.cli.ClearScroll.WithScrollID(e.scroll),
|
||||||
|
); err != nil {
|
||||||
|
logrus.Warnf("ES7.Start: clear scroll=%s err=%v", e.scroll, err)
|
||||||
|
} else {
|
||||||
|
if csr.StatusCode != 200 {
|
||||||
|
logrus.Warnf("ES7.Start: clear scroll=%s status=%d msg=%s", e.scroll, csr.StatusCode, csr.String())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
close(rowCh)
|
||||||
|
close(errCh)
|
||||||
|
}()
|
||||||
|
|
||||||
|
ready <- true
|
||||||
|
|
||||||
|
if result, err = e.cli.Search(qs...); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: search err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = util.CheckES7Response(result); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: search resp err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder = json.NewDecoder(result.Body)
|
||||||
|
|
||||||
|
if err = decoder.Decode(hits); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: decode err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if hits.TimedOut {
|
||||||
|
err = fmt.Errorf("timeout")
|
||||||
|
logrus.Debugf("ES7.Start: search timeout")
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
e.scroll = hits.ScrollId
|
||||||
|
|
||||||
|
for idx := range hits.Hits.Hits {
|
||||||
|
rowCh <- hits.Hits.Hits[idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(hits.Hits.Hits) < e.size {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for {
|
||||||
|
if result, err = e.cli.Scroll(
|
||||||
|
e.cli.Scroll.WithContext(util.TimeoutCtx(ctx, opt.ES7OperationTimeout)),
|
||||||
|
e.cli.Scroll.WithScrollID(e.scroll),
|
||||||
|
); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: search err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = util.CheckES7Response(result); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: search resp err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
decoder = json.NewDecoder(result.Body)
|
||||||
|
hits = new(model.ESResponse)
|
||||||
|
|
||||||
|
if err = decoder.Decode(hits); err != nil {
|
||||||
|
logrus.Debugf("ES7.Start: decode err=%v", err)
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if hits.TimedOut {
|
||||||
|
err = fmt.Errorf("timeout")
|
||||||
|
logrus.Debugf("ES7.Start: search timeout")
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for idx := range hits.Hits.Hits {
|
||||||
|
rowCh <- hits.Hits.Hits[idx]
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(hits.Hits.Hits) < e.size {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ready
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e *ES7) Close() {}
|
79
internal/controller/output/xfile/local.go
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
package xfile
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"github.com/loveuer/nfflow/internal/interfaces"
|
||||||
|
"github.com/loveuer/nfflow/internal/sqlType"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
|
type LocalFile struct {
|
||||||
|
writer *os.File
|
||||||
|
Path string `json:"path"`
|
||||||
|
MaxLine int `json:"max_line"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewFileOutput(cfg sqlType.JSONB) (interfaces.Output, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
ins = &LocalFile{}
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = cfg.Bind(ins); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = os.Stat(ins.Path); !errors.Is(err, os.ErrNotExist) {
|
||||||
|
return nil, errors.New("file already exist")
|
||||||
|
}
|
||||||
|
|
||||||
|
if ins.writer, err = os.OpenFile(ins.Path, os.O_CREATE|os.O_RDWR, 0644); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return ins, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lf *LocalFile) Start(ctx context.Context, rowCh <-chan interfaces.Row, errCh chan<- error) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
bs []byte
|
||||||
|
ready = make(chan bool)
|
||||||
|
)
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
ready <- true
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
logrus.Warn("received quit signal...")
|
||||||
|
return
|
||||||
|
case row, ok := <-rowCh:
|
||||||
|
if !ok {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if bs, err = row.Bytes(); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = lf.writer.Write(append(bs, '\n')); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ready
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (lf *LocalFile) Close() {
|
||||||
|
_ = lf.writer.Close()
|
||||||
|
}
|
68
internal/controller/pipe/loadash/loadash.go
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package loadash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/dop251/goja"
|
||||||
|
"github.com/loveuer/nfflow/internal/interfaces"
|
||||||
|
"github.com/loveuer/nfflow/internal/sqlType"
|
||||||
|
"github.com/sirupsen/logrus"
|
||||||
|
)
|
||||||
|
|
||||||
|
type PipeMap struct {
|
||||||
|
vm *goja.Runtime
|
||||||
|
FN string `json:"fn"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewPipeMap(cfg sqlType.JSONB) (interfaces.Pipe, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
pm = &PipeMap{}
|
||||||
|
prefix = "let result; let doc; let myFn;"
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = cfg.Bind(pm); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if pm.FN == "" {
|
||||||
|
return nil, errors.New("nil cfg")
|
||||||
|
}
|
||||||
|
|
||||||
|
pm.vm = goja.New()
|
||||||
|
if _, err = pm.vm.RunString(prefix); err != nil {
|
||||||
|
logrus.Debugf("NewPipeMap: run prepare=%s err=%v", prefix, err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
fn := "myFn = " + pm.FN + ";"
|
||||||
|
if _, err = pm.vm.RunString(fn); err != nil {
|
||||||
|
err = fmt.Errorf("PipeMap: vm run string=%s err=%v", fn, err)
|
||||||
|
logrus.Error(err)
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return pm, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PipeMap) Start(data any) (any, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = m.vm.Set("doc", map[string]any{"data": data}); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = m.vm.RunString(`result = myFn(doc.data)`); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
value := m.vm.Get("result").Export()
|
||||||
|
|
||||||
|
return value, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *PipeMap) Close() {
|
||||||
|
m.vm = nil
|
||||||
|
}
|
440
internal/controller/pipe/loadash/loadash_test.go
Normal file
@ -0,0 +1,440 @@
|
|||||||
|
package loadash
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"github.com/dop251/goja"
|
||||||
|
_ "github.com/dop251/goja"
|
||||||
|
"github.com/loveuer/nfflow/internal/model"
|
||||||
|
"github.com/robertkrimen/otto"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestMapByOtto(t *testing.T) {
|
||||||
|
docs := []*model.ESDoc{
|
||||||
|
{DocId: "01", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "UTAustin",
|
||||||
|
"id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"input_date": 1683803316,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "02", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "3x926amfj3fxpki",
|
||||||
|
"id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"title": "五四青年节|重温入团誓词,焕发青春斗志!",
|
||||||
|
"input_date": 1683803324,
|
||||||
|
"platform": "kuaishou",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "03", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "tyler",
|
||||||
|
"id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"input_date": 1683821249,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "04", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "ErikVoorhees",
|
||||||
|
"id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"input_date": 1683821282,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "05", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "AbleEngineering",
|
||||||
|
"id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"input_date": 1683820912,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
myFunc := `var myFunc = function(item) { return {username: item._source._source.user_id} }`
|
||||||
|
|
||||||
|
vm := otto.New()
|
||||||
|
//if _, err = vm.Compile("babel", string(bfbs)); err != nil {
|
||||||
|
// t.Error("compile babel err:", err)
|
||||||
|
// return
|
||||||
|
//}
|
||||||
|
|
||||||
|
if _, err := vm.Run(myFunc); err != nil {
|
||||||
|
t.Error("1 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, doc := range docs {
|
||||||
|
bs, _ := json.Marshal(doc)
|
||||||
|
val, err := otto.ToValue(string(bs))
|
||||||
|
if err != nil {
|
||||||
|
t.Error("to value err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.Set("doc", val)
|
||||||
|
|
||||||
|
_, err = vm.Run(`var result = myFunc(JSON.parse(doc))`)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("2 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := vm.Get("result")
|
||||||
|
if err != nil {
|
||||||
|
t.Error("3 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := value.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
t.Error("4 err:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Log("result: ", string(result))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkByOtto(b *testing.B) {
|
||||||
|
docs := []*model.ESDoc{
|
||||||
|
{DocId: "01", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "UTAustin",
|
||||||
|
"id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"input_date": 1683803316,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "02", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "3x926amfj3fxpki",
|
||||||
|
"id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"title": "五四青年节|重温入团誓词,焕发青春斗志!",
|
||||||
|
"input_date": 1683803324,
|
||||||
|
"platform": "kuaishou",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "03", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "tyler",
|
||||||
|
"id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"input_date": 1683821249,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "04", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "ErikVoorhees",
|
||||||
|
"id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"input_date": 1683821282,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{DocId: "05", Index: "sonar_post", Content: map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "AbleEngineering",
|
||||||
|
"id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"input_date": 1683820912,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
myFunc := `var myFunc = function(item) { return {username: item["_source"]["_source"]["user_id"]} }`
|
||||||
|
|
||||||
|
vm := otto.New()
|
||||||
|
|
||||||
|
if _, err := vm.Run(myFunc); err != nil {
|
||||||
|
b.Error("1 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
bs, _ := json.Marshal(docs[n%5])
|
||||||
|
val, err := otto.ToValue(string(bs))
|
||||||
|
if err != nil {
|
||||||
|
b.Error("to value err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.Set("doc", val)
|
||||||
|
|
||||||
|
_, err = vm.Run(`var result = myFunc(JSON.parse(doc))`)
|
||||||
|
if err != nil {
|
||||||
|
b.Error("2 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
value, err := vm.Get("result")
|
||||||
|
if err != nil {
|
||||||
|
b.Error("3 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := value.MarshalJSON()
|
||||||
|
if err != nil {
|
||||||
|
b.Error("4 err:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
_ = result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestByGoJa(t *testing.T) {
|
||||||
|
docs := []map[string]any{
|
||||||
|
{"doc_id": "01", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "UTAustin",
|
||||||
|
"id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"input_date": 1683803316,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "02", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "3x926amfj3fxpki",
|
||||||
|
"id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"title": "五四青年节|重温入团誓词,焕发青春斗志!",
|
||||||
|
"input_date": 1683803324,
|
||||||
|
"platform": "kuaishou",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "03", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "tyler",
|
||||||
|
"id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"input_date": 1683821249,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "04", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "ErikVoorhees",
|
||||||
|
"id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"input_date": 1683821282,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "05", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "AbleEngineering",
|
||||||
|
"id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"input_date": 1683820912,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
myFunc := `let result; let doc; let myFn;`
|
||||||
|
|
||||||
|
vm := goja.New()
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if _, err = vm.RunString(myFunc); err != nil {
|
||||||
|
t.Error("1 err:", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
vm.RunString(`myFn = ` + `item => item.content._source.platform`)
|
||||||
|
|
||||||
|
for _, doc := range docs {
|
||||||
|
vm.Set("doc", doc)
|
||||||
|
|
||||||
|
t.Log("log doc: ", vm.Get("doc").Export())
|
||||||
|
|
||||||
|
_, err = vm.RunString(`result = myFn(doc)`)
|
||||||
|
if err != nil {
|
||||||
|
t.Error("2 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
value := vm.Get("result").Export()
|
||||||
|
|
||||||
|
//fm, _ := value.(map[string]any)
|
||||||
|
|
||||||
|
t.Logf("result: %+v", value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkByGoJa(b *testing.B) {
|
||||||
|
docs := []map[string]any{
|
||||||
|
{"doc_id": "01", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "UTAustin",
|
||||||
|
"id": "0e2071290cf0c1d08bc211b2452cc1b4",
|
||||||
|
"input_date": 1683803316,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "02", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "3x926amfj3fxpki",
|
||||||
|
"id": "0d47e9eecfa42704efe6c054cca7050f",
|
||||||
|
"title": "五四青年节|重温入团誓词,焕发青春斗志!",
|
||||||
|
"input_date": 1683803324,
|
||||||
|
"platform": "kuaishou",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "03", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "tyler",
|
||||||
|
"id": "dbe1091f2b7f2888e2004b2d71f7c51a",
|
||||||
|
"input_date": 1683821249,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "04", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "ErikVoorhees",
|
||||||
|
"id": "77c68a46f85f7d72ff900abe7b86eee7",
|
||||||
|
"input_date": 1683821282,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
{"doc_id": "05", "index": "sonar_post", "content": map[string]any{
|
||||||
|
"_index": "sonar_post1",
|
||||||
|
"_type": "_doc",
|
||||||
|
"_id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"_score": 1,
|
||||||
|
"_source": map[string]any{
|
||||||
|
"user_id": "AbleEngineering",
|
||||||
|
"id": "38d4aa64e21bd9e20c597c8c10ad9371",
|
||||||
|
"input_date": 1683820912,
|
||||||
|
"platform": "twitter",
|
||||||
|
},
|
||||||
|
}},
|
||||||
|
}
|
||||||
|
|
||||||
|
myFunc := `let result; let doc; let myFn = item => item.content `
|
||||||
|
|
||||||
|
vm := goja.New()
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if _, err = vm.RunString(myFunc); err != nil {
|
||||||
|
b.Error("1 err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for n := 0; n < b.N; n++ {
|
||||||
|
doc := docs[n%5]
|
||||||
|
if err = vm.Set("doc", doc); err != nil {
|
||||||
|
b.Error("set doc err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = vm.RunString(`result = myFn(doc)`); err != nil {
|
||||||
|
b.Error("dial myFn err:", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
value := vm.Get("result")
|
||||||
|
|
||||||
|
result := value.Export()
|
||||||
|
|
||||||
|
_ = result
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestNewPipeMap(t *testing.T) {
|
||||||
|
pipe, err := NewPipeMap(`
|
||||||
|
item => {
|
||||||
|
return {id: item.doc_id, name: "static name", title: item.title + item.content}
|
||||||
|
}
|
||||||
|
`)
|
||||||
|
if err != nil {
|
||||||
|
t.Error(1, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
data, err := pipe.Pipe(map[string]any{"doc_id": "220113", "title": "zyp", "content": "hello world"})
|
||||||
|
if err != nil {
|
||||||
|
t.Error(2, err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Logf("data: %+v", data)
|
||||||
|
}
|
191
internal/controller/task.go
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"github.com/loveuer/nfflow/internal/controller/input/es7"
|
||||||
|
"github.com/loveuer/nfflow/internal/controller/output/xfile"
|
||||||
|
"github.com/loveuer/nfflow/internal/controller/pipe/loadash"
|
||||||
|
"github.com/loveuer/nfflow/internal/database"
|
||||||
|
"github.com/loveuer/nfflow/internal/interfaces"
|
||||||
|
"github.com/loveuer/nfflow/internal/model"
|
||||||
|
"github.com/loveuer/nfflow/internal/util"
|
||||||
|
"github.com/samber/lo"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"sort"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TaskInitInput(tx *gorm.DB, t *model.Task) (interfaces.Input, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
ti = new(model.TaskInput)
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = tx.Model(&model.TaskInput{}).
|
||||||
|
Where("task_id", t.Id).
|
||||||
|
Take(ti).
|
||||||
|
Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ti.Type {
|
||||||
|
case model.InputTypeES:
|
||||||
|
if ti.Instance, err = es7.NewInput(ti.Config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case model.InputTypePG:
|
||||||
|
panic("not impl input:pg")
|
||||||
|
case model.InputTypeMQ:
|
||||||
|
panic("not impl input:mq")
|
||||||
|
default:
|
||||||
|
panic("invalid input type")
|
||||||
|
}
|
||||||
|
|
||||||
|
return ti.Instance, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TaskInitPipes(tx *gorm.DB, t *model.Task) ([]interfaces.Pipe, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
list = make([]*model.TaskPipe, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = tx.Model(&model.TaskPipe{}).
|
||||||
|
Where("task_id", t.Id).
|
||||||
|
Find(&list).
|
||||||
|
Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for idx := range list {
|
||||||
|
switch list[idx].Type {
|
||||||
|
case model.PipeTypeLoadashMap:
|
||||||
|
if list[idx].Instance, err = loadash.NewPipeMap(list[idx].Config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
panic("invalid pipe type")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(list, func(i, j int) bool {
|
||||||
|
return list[i].Sort < list[j].Sort
|
||||||
|
})
|
||||||
|
|
||||||
|
return lo.Map(list, func(item *model.TaskPipe, index int) interfaces.Pipe {
|
||||||
|
return item.Instance
|
||||||
|
}), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TaskInitOutputs(tx *gorm.DB, t *model.Task) ([]interfaces.Output, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
outputs = make([]*model.TaskOutput, 0)
|
||||||
|
)
|
||||||
|
|
||||||
|
if err = tx.Model(&model.TaskOutput{}).
|
||||||
|
Where("task_id", t.Id).
|
||||||
|
Find(&outputs).
|
||||||
|
Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, o := range outputs {
|
||||||
|
switch o.Type {
|
||||||
|
case model.OutputTypeES:
|
||||||
|
panic("impl output es")
|
||||||
|
case model.OutputTypeFile:
|
||||||
|
if o.Instance, err = xfile.NewFileOutput(o.Config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
case model.OutputTypeMQ:
|
||||||
|
panic("impl output mq")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return lo.Map(outputs, func(item *model.TaskOutput, index int) interfaces.Output {
|
||||||
|
return item.Instance
|
||||||
|
}), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func TaskStart(ctx context.Context, t *model.Task) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
input interfaces.Input
|
||||||
|
pipes []interfaces.Pipe
|
||||||
|
outputs []interfaces.Output
|
||||||
|
irc = make(chan interfaces.Row)
|
||||||
|
prc = make(chan interfaces.Row)
|
||||||
|
errCh = make(chan error)
|
||||||
|
done = make(chan bool)
|
||||||
|
)
|
||||||
|
|
||||||
|
if input, err = TaskInitInput(database.DB.Session(util.Timeout(5)), t); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if input == nil {
|
||||||
|
return errors.New("nil input")
|
||||||
|
}
|
||||||
|
|
||||||
|
if pipes, err = TaskInitPipes(database.DB.Session(util.Timeout(10)), t); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if outputs, err = TaskInitOutputs(database.DB.Session(util.Timeout(10)), t); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(outputs) == 0 {
|
||||||
|
return errors.New("nil output")
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
for data := range irc {
|
||||||
|
var hd interfaces.Row
|
||||||
|
for idx := range pipes {
|
||||||
|
if hd, err = pipes[idx].Start(data); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
prc <- hd
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
if err = input.Start(ctx, irc, errCh); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
|
||||||
|
chs := make([]chan interfaces.Row, len(outputs))
|
||||||
|
|
||||||
|
for idx := range outputs {
|
||||||
|
ch := make(chan interfaces.Row)
|
||||||
|
|
||||||
|
if err = outputs[idx].Start(ctx, ch, errCh); err != nil {
|
||||||
|
errCh <- err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for od := range prc {
|
||||||
|
for idx := range chs {
|
||||||
|
chs[idx] <- od
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
done <- true
|
||||||
|
}()
|
||||||
|
|
||||||
|
select {
|
||||||
|
case err = <-errCh:
|
||||||
|
return err
|
||||||
|
case <-done:
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
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
|
||||||
|
}
|