🎉: init project
7
.gitignore
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
.idea
|
||||||
|
.vscode
|
||||||
|
.DS_Store
|
||||||
|
.data
|
||||||
|
*.sqlite
|
||||||
|
*.sqlite3
|
||||||
|
xtest
|
27
.nfctl
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
# nfctl init script
|
||||||
|
# https://github.com/loveuer/nf/nft/nfctl
|
||||||
|
|
||||||
|
# 替换 import
|
||||||
|
!replace content
|
||||||
|
suffix *.go
|
||||||
|
ultone => {{.PROJECT_NAME}}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 替换 go module name
|
||||||
|
!replace content
|
||||||
|
exact go.mod
|
||||||
|
module ultone => module {{.PROJECT_NAME}}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
# 生成 readme
|
||||||
|
!generate
|
||||||
|
readme.md
|
||||||
|
# {{.PROJECT_NAME}}
|
||||||
|
|
||||||
|
### Run
|
||||||
|
- `go run . --help`
|
||||||
|
- `go run .`
|
||||||
|
|
||||||
|
### Build
|
||||||
|
- `docker build -t {repo:tag} -f Dockerfile .`
|
||||||
|
EOF
|
30
Dockerfile
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
#FROM golang:1.20-alpine AS builder
|
||||||
|
FROM repository.umisen.com/external/golang:latest AS builder
|
||||||
|
|
||||||
|
ENV GO111MODULE on
|
||||||
|
ENV CGO_ENABLED 0
|
||||||
|
ENV GOOS linux
|
||||||
|
ENV GOPROXY https://goproxy.io
|
||||||
|
|
||||||
|
WORKDIR /build
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN go mod download
|
||||||
|
RUN go build -ldflags '-s -w' -o server .
|
||||||
|
|
||||||
|
#FROM alpine:latest
|
||||||
|
FROM repository.umisen.com/external/alpine:latest
|
||||||
|
|
||||||
|
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.tuna.tsinghua.edu.cn/g' /etc/apk/repositories && apk add curl
|
||||||
|
|
||||||
|
ENV TZ Asia/Shanghai
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
RUN mkdir -p /data
|
||||||
|
|
||||||
|
COPY --from=builder /build/server /app/server
|
||||||
|
COPY etc /app/etc
|
||||||
|
|
||||||
|
CMD ["/app/server", "-c", "/app/etc/config.json"]
|
56
deployment/database.dev.yml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
version: "3.9"
|
||||||
|
|
||||||
|
services:
|
||||||
|
redis:
|
||||||
|
image: "repository.umisen.com/external/redis:latest"
|
||||||
|
container_name: redis
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- .data/redis:/data
|
||||||
|
ports:
|
||||||
|
- "6379:6379"
|
||||||
|
|
||||||
|
pgsql:
|
||||||
|
image: "repository.umisen.com/external/postgres:latest"
|
||||||
|
container_name: pgsql
|
||||||
|
restart: unless-stopped
|
||||||
|
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/external/es:latest"
|
||||||
|
container_name: es
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
- bootstrap.memory_lock=true
|
||||||
|
- "ES_JAVA_OPTS=-Xms1g -Xmx1g"
|
||||||
|
- discovery.type=single-node
|
||||||
|
ulimits:
|
||||||
|
nproc: 65535
|
||||||
|
memlock:
|
||||||
|
soft: -1
|
||||||
|
hard: -1
|
||||||
|
deploy:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpus: '1'
|
||||||
|
memory: 1G
|
||||||
|
ports:
|
||||||
|
- 9200:9200
|
||||||
|
|
||||||
|
kibana:
|
||||||
|
image: "repository.umisen.com/external/kibana:latest"
|
||||||
|
container_name: kibana
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
ELASTICSEARCH_HOSTS: http://elk_es:9200
|
||||||
|
I18N_LOCALE: zh-CN
|
||||||
|
ports:
|
||||||
|
- 5601:5601
|
8
deployment/run.sh
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
#/bin/bash
|
||||||
|
|
||||||
|
VERSION="v$(date +'%y.%m.%d')-r1"
|
||||||
|
echo "version: $VERSION"
|
||||||
|
|
||||||
|
docker build -t repository.umisen.com/{project_folder}/{project_name}:$VERSION -f Dockerfile .
|
||||||
|
docker push repository.umisen.com/{project_folder}/{project_name}:$VERSION
|
||||||
|
docker start -d --name {your_project_name} --restart unless-stopped -p xx_port:xx_port -v xx_path:xx_path repository.umisen.com/{project_folder}/{project_name}:$VERSION
|
27
etc/config.json
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{
|
||||||
|
"name": "ult",
|
||||||
|
"listen": {
|
||||||
|
"http": "0.0.0.0:8080"
|
||||||
|
},
|
||||||
|
"db": {
|
||||||
|
"_uri": "postgres::host=pg.dev user=xx_user password=xx_password dbname=xx_database port=5432 sslmode=disable TimeZone=Asia/Shanghai",
|
||||||
|
"uri": "sqlite::db.sqlite3"
|
||||||
|
},
|
||||||
|
"cache": {
|
||||||
|
"uri": "lru::",
|
||||||
|
"_uri": "memory::",
|
||||||
|
"__uri": "redis::u:p@redis.dev:6379"
|
||||||
|
},
|
||||||
|
"es": {
|
||||||
|
"uri": "http://es.dev:9200",
|
||||||
|
"index": {
|
||||||
|
"staff": "some_staff"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"nebula": {
|
||||||
|
"uri": "nebula.1.dev:9669,nebula.2.dev:9669",
|
||||||
|
"space": "test_space",
|
||||||
|
"username": "admin",
|
||||||
|
"password": "password"
|
||||||
|
}
|
||||||
|
}
|
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": "^18.0.2",
|
||||||
|
"@angular/cdk": "18.0.2",
|
||||||
|
"@angular/common": "^18.0.2",
|
||||||
|
"@angular/compiler": "^18.0.2",
|
||||||
|
"@angular/core": "^18.0.2",
|
||||||
|
"@angular/forms": "^18.0.2",
|
||||||
|
"@angular/material": "18.0.2",
|
||||||
|
"@angular/platform-browser": "^18.0.2",
|
||||||
|
"@angular/platform-browser-dynamic": "^18.0.2",
|
||||||
|
"@angular/router": "^18.0.2",
|
||||||
|
"@angular/service-worker": "^18.0.2",
|
||||||
|
"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": "^18.0.3",
|
||||||
|
"@angular/cli": "^18.0.3",
|
||||||
|
"@angular/compiler-cli": "^18.0.2",
|
||||||
|
"@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.4.5"
|
||||||
|
}
|
||||||
|
}
|
9818
front/pnpm-lock.yaml
generated
Normal file
27
front/src/app/app.component.html
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
<div class="title">
|
||||||
|
<mat-toolbar color="primary">
|
||||||
|
<span class="home-button" (click)="router.navigate([''])">Ult App</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(['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 === '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'
|
||||||
|
})
|
||||||
|
]
|
||||||
|
};
|
12
front/src/app/app.routes.ts
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
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";
|
||||||
|
|
||||||
|
export const routes: Routes = [
|
||||||
|
{path: "", component: HomeComponent},
|
||||||
|
{path: "login", component: LoginComponent},
|
||||||
|
{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,93 @@
|
|||||||
|
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 {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)
|
||||||
|
}
|
||||||
|
}
|
48
front/src/app/interceptor/alerter.interceptor.ts
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
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;
|
||||||
|
}
|
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" (keyup)="enter($event)">
|
||||||
|
</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();
|
||||||
|
});
|
||||||
|
});
|
46
front/src/app/page/login/login.component.ts
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
enter(event: KeyboardEvent) {
|
||||||
|
if (event.key === 'Enter' && this.password && this.username) {
|
||||||
|
this.login()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
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/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:8080",
|
||||||
|
"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"
|
||||||
|
]
|
||||||
|
}
|
67
go.mod
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
module ultone
|
||||||
|
|
||||||
|
go 1.20
|
||||||
|
|
||||||
|
require (
|
||||||
|
gitea.com/taozitaozi/gredis v0.0.0-20240131032054-b02845ce1e9d
|
||||||
|
github.com/elastic/go-elasticsearch/v7 v7.17.10
|
||||||
|
github.com/glebarez/sqlite v1.10.0
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0
|
||||||
|
github.com/google/uuid v1.6.0
|
||||||
|
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||||
|
github.com/jackc/pgtype v1.12.0
|
||||||
|
github.com/jedib0t/go-pretty/v6 v6.5.9
|
||||||
|
github.com/loveuer/esgo2dump v0.3.3
|
||||||
|
github.com/loveuer/nf v0.2.4
|
||||||
|
github.com/loveuer/ngorm/v2 v2.1.1
|
||||||
|
github.com/matoous/go-nanoid/v2 v2.1.0
|
||||||
|
github.com/rabbitmq/amqp091-go v1.10.0
|
||||||
|
github.com/samber/lo v1.39.0
|
||||||
|
github.com/sirupsen/logrus v1.9.2
|
||||||
|
github.com/spf13/cast v1.6.0
|
||||||
|
github.com/tdewolff/minify/v2 v2.20.16
|
||||||
|
golang.org/x/crypto v0.14.0
|
||||||
|
google.golang.org/grpc v1.50.0
|
||||||
|
gorm.io/driver/mysql v1.4.5
|
||||||
|
gorm.io/driver/postgres v1.4.4
|
||||||
|
gorm.io/gorm v1.25.5
|
||||||
|
)
|
||||||
|
|
||||||
|
require (
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||||
|
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||||
|
github.com/facebook/fbthrift v0.31.1-0.20211129061412-801ed7f9f295 // indirect
|
||||||
|
github.com/fatih/color v1.17.0 // indirect
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2 // indirect
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0 // indirect
|
||||||
|
github.com/golang/protobuf v1.5.2 // 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-colorable v0.1.13 // indirect
|
||||||
|
github.com/mattn/go-isatty v0.0.20 // indirect
|
||||||
|
github.com/mattn/go-runewidth v0.0.15 // indirect
|
||||||
|
github.com/pkg/errors v0.9.1 // indirect
|
||||||
|
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
|
||||||
|
github.com/rivo/uniseg v0.2.0 // indirect
|
||||||
|
github.com/tdewolff/parse/v2 v2.7.11 // indirect
|
||||||
|
github.com/vesoft-inc/nebula-go/v3 v3.5.0 // indirect
|
||||||
|
golang.org/x/exp v0.0.0-20220303212507-bbda1eaf7a17 // indirect
|
||||||
|
golang.org/x/net v0.17.0 // indirect
|
||||||
|
golang.org/x/sys v0.18.0 // indirect
|
||||||
|
golang.org/x/text v0.13.0 // indirect
|
||||||
|
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c // indirect
|
||||||
|
google.golang.org/protobuf v1.30.0 // indirect
|
||||||
|
modernc.org/libc v1.22.5 // indirect
|
||||||
|
modernc.org/mathutil v1.5.0 // indirect
|
||||||
|
modernc.org/memory v1.5.0 // indirect
|
||||||
|
modernc.org/sqlite v1.23.1 // indirect
|
||||||
|
)
|
381
go.sum
Normal file
@ -0,0 +1,381 @@
|
|||||||
|
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||||
|
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/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2 h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=
|
||||||
|
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||||
|
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||||
|
github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk=
|
||||||
|
github.com/cockroachdb/apd v1.1.0 h1:3LFP3629v+1aKXU5Q37mxmRxX/pIu1nijXydLShEq5I=
|
||||||
|
github.com/cockroachdb/apd v1.1.0/go.mod h1:8Sl8LxpKi29FqWXR16WEFZRNSz3SoPzUzeMeY4+DwBQ=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190321100706-95778dfbb74e/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7vjVVG0kc13fIWeqUViNPyEJxv/OmvnBo0Yme4=
|
||||||
|
github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY=
|
||||||
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78=
|
||||||
|
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc=
|
||||||
|
github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY=
|
||||||
|
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
|
||||||
|
github.com/elastic/go-elasticsearch/v7 v7.17.10 h1:TCQ8i4PmIJuBunvBS6bwT2ybzVFxxUhhltAs3Gyu1yo=
|
||||||
|
github.com/elastic/go-elasticsearch/v7 v7.17.10/go.mod h1:OJ4wdbtDNk5g503kvlHLyErCgQwwzmDtaFC4XyOxXA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||||
|
github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk=
|
||||||
|
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||||
|
github.com/facebook/fbthrift v0.31.1-0.20211129061412-801ed7f9f295 h1:ZA+qQ3d2In0RNzVpk+D/nq1sjDSv+s1Wy2zrAPQAmsg=
|
||||||
|
github.com/facebook/fbthrift v0.31.1-0.20211129061412-801ed7f9f295/go.mod h1:2tncLx5rmw69e5kMBv/yJneERbzrr1yr5fdlnTbu8lU=
|
||||||
|
github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4=
|
||||||
|
github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI=
|
||||||
|
github.com/frankban/quicktest v1.14.6 h1:7Xjx+VpznH+oBnejlPUj8oUpdxnVs4f8XU8WnHkI4W8=
|
||||||
|
github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA=
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo=
|
||||||
|
github.com/glebarez/go-sqlite v1.21.2/go.mod h1:sfxdZyhQjTM2Wry3gVYWaW072Ri1WMdWJi0k6+3382k=
|
||||||
|
github.com/glebarez/sqlite v1.10.0 h1:u4gt8y7OND/cCei/NMHmfbLxF6xP2wgKcT/BJf2pYkc=
|
||||||
|
github.com/glebarez/sqlite v1.10.0/go.mod h1:IJ+lfSOmiekhQsFTJRx/lHtGYmCdtAiTaf5wI9u5uHA=
|
||||||
|
github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY=
|
||||||
|
github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5 h1:AcZZR7igkdvfVmQTPnu9WE37LRrO/YrBH5zWyjDC0oI=
|
||||||
|
github.com/go-redis/redis/v8 v8.11.5/go.mod h1:gREzHqY1hg6oD9ngVRbLStwAWKhA0FEgq8Jd4h5lpwo=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0 h1:ueSltNNllEqE3qcWBTD0iQd3IpL/6U+mJxLkazJ7YPc=
|
||||||
|
github.com/go-sql-driver/mysql v1.7.0/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI=
|
||||||
|
github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY=
|
||||||
|
github.com/gofrs/uuid v4.0.0+incompatible h1:1SD/1F5pU8p29ybwgQSwpQk+mwdRrXCYuPhW6m+TnJw=
|
||||||
|
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw=
|
||||||
|
github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk=
|
||||||
|
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||||
|
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||||
|
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs=
|
||||||
|
github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w=
|
||||||
|
github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0=
|
||||||
|
github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8=
|
||||||
|
github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||||
|
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||||
|
github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw=
|
||||||
|
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||||
|
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
|
||||||
|
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
|
||||||
|
github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||||
|
github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38=
|
||||||
|
github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ=
|
||||||
|
github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI=
|
||||||
|
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||||
|
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/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
|
||||||
|
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
|
||||||
|
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/jedib0t/go-pretty/v6 v6.5.9 h1:ACteMBRrrmm1gMsXe9PSTOClQ63IXDUt03H5U+UV8OU=
|
||||||
|
github.com/jedib0t/go-pretty/v6 v6.5.9/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0 h1:K317FqzuhWc8YvSVlFMCCUb36O/S9MCKRDI7QkRKD/E=
|
||||||
|
github.com/jinzhu/inflection v1.0.0/go.mod h1:h+uFLlag+Qp1Va5pdKtLDYj+kHp5pxUVkryuEj+Srlc=
|
||||||
|
github.com/jinzhu/now v1.1.4/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/jinzhu/now v1.1.5 h1:/o9tlHleP7gOFmsnYNz3RGnqzefHA47wQpKrrdTIwXQ=
|
||||||
|
github.com/jinzhu/now v1.1.5/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||||
|
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||||
|
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||||
|
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||||
|
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||||
|
github.com/kr/pty v1.1.8/go.mod h1:O1sed60cT9XZ5uDucP5qwvh+TE3NnUj51EiZO/lmSfw=
|
||||||
|
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||||
|
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||||
|
github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.1.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.2.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo=
|
||||||
|
github.com/lib/pq v1.10.2 h1:AqzbZs4ZoCBp+GtejcpCpcxM3zlSMx29dXbUSeVtJb8=
|
||||||
|
github.com/lib/pq v1.10.2/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
|
||||||
|
github.com/loveuer/esgo2dump v0.3.3 h1:/AidoaFV7bDRyT1ycyBKs4XGmyVs2ShaUKrpEBiUWkM=
|
||||||
|
github.com/loveuer/esgo2dump v0.3.3/go.mod h1:thZvfsO0kd7Ck3TA0jc9rRc4CuIa4Iuiq6tF3tCqXEY=
|
||||||
|
github.com/loveuer/nf v0.2.4 h1:2xoGLXCf9Yfp7MndHtxwjy97c21rDIdLiOEWxrL2FJ4=
|
||||||
|
github.com/loveuer/nf v0.2.4/go.mod h1:mR3Hc3j6kivKS+QwaYULYuiZOLQCfcaRPTtK260pBaw=
|
||||||
|
github.com/loveuer/ngorm/v2 v2.1.1 h1:v+ut5BjeSBFU87o800pI8Q3fXEOUAkvk5+btMw2oOEc=
|
||||||
|
github.com/loveuer/ngorm/v2 v2.1.1/go.mod h1:BVhFGQsRMdcf08MtmwwRihwCR/x7wDd0Fzy8Xj+edM0=
|
||||||
|
github.com/matoous/go-nanoid/v2 v2.1.0 h1:P64+dmq21hhWdtvZfEAofnvJULaRR1Yib0+PnU669bE=
|
||||||
|
github.com/matoous/go-nanoid/v2 v2.1.0/go.mod h1:KlbGNQ+FhrUNIHUxZdL63t7tl4LaPkZNpUULS8H4uVM=
|
||||||
|
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-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA=
|
||||||
|
github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg=
|
||||||
|
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.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||||
|
github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY=
|
||||||
|
github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||||
|
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
|
||||||
|
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
|
||||||
|
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||||
|
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||||
|
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||||
|
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
|
||||||
|
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
|
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||||
|
github.com/rabbitmq/amqp091-go v1.10.0 h1:STpn5XsHlHGcecLmMFCtg7mqq0RnD+zFr4uzukfVhBw=
|
||||||
|
github.com/rabbitmq/amqp091-go v1.10.0/go.mod h1:Hy4jKW5kQART1u+JkDTF9YYOQUHXqMuhrgxOEeS7G4o=
|
||||||
|
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/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
|
||||||
|
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
|
||||||
|
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
|
||||||
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
|
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.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y=
|
||||||
|
github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||||
|
github.com/spf13/cast v1.6.0 h1:GEiTHELF+vaR5dhz3VqZfFSzZjYbgeKDpBxQVS4GYJ0=
|
||||||
|
github.com/spf13/cast v1.6.0/go.mod h1:ancEpBxwJDODSW/UG4rDrAqiKolqNNh2DX3mk86cAdo=
|
||||||
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
github.com/stretchr/objx v0.2.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||||
|
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||||
|
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||||
|
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||||
|
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||||
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
|
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
|
||||||
|
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
|
||||||
|
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/vesoft-inc/nebula-go/v3 v3.5.0 h1:2ZSkoBxtIfs15AXJXqrAPDPd0Z9HrzKR7YKXPqlJcR0=
|
||||||
|
github.com/vesoft-inc/nebula-go/v3 v3.5.0/go.mod h1:+sXv05jYQBARdTbTcIEsWVXCnF/6ttOlDK35xQ6m54s=
|
||||||
|
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
|
||||||
|
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/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=
|
||||||
|
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||||
|
go.uber.org/multierr v1.3.0/go.mod h1:VgVr7evmIr6uPjLBxg28wmKNXyqE9akIJ5XnfpiKl+4=
|
||||||
|
go.uber.org/multierr v1.5.0/go.mod h1:FeouvMocqHpRaaGuG9EjoKcStLC43Zu/fmqdUMPcKYU=
|
||||||
|
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee/go.mod h1:vJERXedbb3MVM5f9Ejo0C68/HhF8uaILCdgjnY+goOA=
|
||||||
|
go.uber.org/zap v1.9.1/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
|
||||||
|
go.uber.org/zap v1.13.0/go.mod h1:zwrFLgMcdUuIBviXEYEH1YKNaOBnKXsx2IPda5bBwHM=
|
||||||
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
|
golang.org/x/crypto v0.0.0-20190411191339-88737f569e3a/go.mod h1:WFFai1msRO1wXaEeE5yQxYXgSfI8pQAWXbQop6sCtWE=
|
||||||
|
golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||||
|
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
|
||||||
|
golang.org/x/crypto v0.0.0-20201203163018-be400aefbc4c/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
|
||||||
|
golang.org/x/crypto v0.0.0-20210616213533-5ff15b29337e/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||||
|
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||||
|
golang.org/x/crypto v0.14.0 h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=
|
||||||
|
golang.org/x/crypto v0.14.0/go.mod h1:MVFd36DqK4CsrnJYDkBA3VC4m2GkXAM0PvzMCn4JQf4=
|
||||||
|
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||||
|
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-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE=
|
||||||
|
golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU=
|
||||||
|
golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc=
|
||||||
|
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY=
|
||||||
|
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.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||||
|
golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=
|
||||||
|
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-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
|
||||||
|
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||||
|
golang.org/x/net v0.17.0 h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=
|
||||||
|
golang.org/x/net v0.17.0/go.mod h1:NxSsAGuq816PNPmqtQdLE42eU2Fs7NoRIZrHJAlaCOE=
|
||||||
|
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
|
||||||
|
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||||
|
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
|
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-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
|
golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||||
|
golang.org/x/sys v0.18.0 h1:DBdB3niSjOA/O0blCZBqDefyWNYveAYMNF1Wum0DYQ4=
|
||||||
|
golang.org/x/sys v0.18.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||||
|
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
|
||||||
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
|
||||||
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
|
golang.org/x/text v0.3.5/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.13.0 h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=
|
||||||
|
golang.org/x/text v0.13.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE=
|
||||||
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
|
golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY=
|
||||||
|
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-20190524140312-2c0ae7006135/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.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28=
|
||||||
|
golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk=
|
||||||
|
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/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM=
|
||||||
|
google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4=
|
||||||
|
google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc=
|
||||||
|
google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc=
|
||||||
|
google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo=
|
||||||
|
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c h1:wtujag7C+4D6KMoulW9YauvK2lgdvCMS260jsqqBXr0=
|
||||||
|
google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0=
|
||||||
|
google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||||
|
google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg=
|
||||||
|
google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY=
|
||||||
|
google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk=
|
||||||
|
google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM=
|
||||||
|
google.golang.org/grpc v1.50.0 h1:fPVVDxY9w++VjTZsYvXWqEf9Rqar/e+9zYfxKK+W+YU=
|
||||||
|
google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
|
||||||
|
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
|
||||||
|
google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE=
|
||||||
|
google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo=
|
||||||
|
google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU=
|
||||||
|
google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c=
|
||||||
|
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.30.0 h1:kPPoIgf3TsEvrm0PFe15JQ+570QVxYzEvvHqChK+cng=
|
||||||
|
google.golang.org/protobuf v1.30.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||||
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
|
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||||
|
gopkg.in/inconshreveable/log15.v2 v2.0.0-20180818164646-67afb5ed74ec/go.mod h1:aPpfJ7XW+gOuirDoZ8gHhLh3kZ1B08FtV2bbmy7Jv3s=
|
||||||
|
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||||
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gorm.io/driver/mysql v1.4.5 h1:u1lytId4+o9dDaNcPCFzNv7h6wvmc92UjNk3z8enSBU=
|
||||||
|
gorm.io/driver/mysql v1.4.5/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
|
||||||
|
gorm.io/driver/postgres v1.4.4 h1:zt1fxJ+C+ajparn0SteEnkoPg0BQ6wOWXEQ99bteAmw=
|
||||||
|
gorm.io/driver/postgres v1.4.4/go.mod h1:whNfh5WhhHs96honoLjBAMwJGYEuA3m1hvgUbNXhPCw=
|
||||||
|
gorm.io/gorm v1.23.7/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||||
|
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||||
|
gorm.io/gorm v1.25.5 h1:zR9lOiiYf09VNh5Q1gphfyia1JpiClIWG9hQaxB/mls=
|
||||||
|
gorm.io/gorm v1.25.5/go.mod h1:hbnx/Oo0ChWMn1BIhpy1oYozzpM15i4YPuHDmfYtwg8=
|
||||||
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
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=
|
66
internal/api/api.go
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/loveuer/nf"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/handler"
|
||||||
|
"ultone/internal/middleware/auth"
|
||||||
|
"ultone/internal/middleware/front"
|
||||||
|
"ultone/internal/middleware/logger"
|
||||||
|
"ultone/internal/middleware/oplog"
|
||||||
|
"ultone/internal/middleware/privilege"
|
||||||
|
"ultone/internal/model"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func initApp(ctx context.Context) *nf.App {
|
||||||
|
engine := nf.New(nf.Config{DisableLogger: true})
|
||||||
|
engine.Use(logger.New())
|
||||||
|
|
||||||
|
// todo: add project prefix, if you need
|
||||||
|
// for example: app := engine.Group("/api/{project}")
|
||||||
|
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)
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
// todo: 替换 xxx
|
||||||
|
// todo: 这里写你的模块和接口
|
||||||
|
api := app.Group("/xxx")
|
||||||
|
api.Use(auth.NewAuth())
|
||||||
|
_ = api // todo: 添加自己的接口后删除该行
|
||||||
|
}
|
||||||
|
|
||||||
|
if opt.EnableFront {
|
||||||
|
engine.Use(front.NewFront(&front.DefaultFront, "dist/front/browser"))
|
||||||
|
}
|
||||||
|
|
||||||
|
return engine
|
||||||
|
}
|
43
internal/api/start.go
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
package api
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/loveuer/nf/nft/log"
|
||||||
|
"net"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Start(ctx context.Context) error {
|
||||||
|
|
||||||
|
app := initApp(ctx)
|
||||||
|
ready := make(chan bool)
|
||||||
|
|
||||||
|
ln, err := net.Listen("tcp", opt.Cfg.Listen.Http)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("api.MustStart: net listen tcp address=%v err=%v", opt.Cfg.Listen.Http, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
ready <- true
|
||||||
|
|
||||||
|
if err = app.RunListener(ln); err != nil {
|
||||||
|
log.Panic("api.MustStart: app run err=%v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ready
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
ready <- true
|
||||||
|
<-ctx.Done()
|
||||||
|
if err = app.Shutdown(tool.Timeout(1)); err != nil {
|
||||||
|
log.Error("api.MustStart: app shutdown err=%v", err)
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
<-ready
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
37
internal/cmd/execute.go
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"ultone/internal/api"
|
||||||
|
"ultone/internal/controller"
|
||||||
|
"ultone/internal/database/cache"
|
||||||
|
"ultone/internal/database/db"
|
||||||
|
"ultone/internal/model"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
filename string
|
||||||
|
)
|
||||||
|
|
||||||
|
func Execute(ctx context.Context) error {
|
||||||
|
|
||||||
|
tool.Must(opt.Init(filename))
|
||||||
|
tool.Must(db.Init())
|
||||||
|
tool.Must(cache.Init())
|
||||||
|
|
||||||
|
// todo: if elastic search required
|
||||||
|
// tool.Must(es.Init())
|
||||||
|
|
||||||
|
// todo: if nebula required
|
||||||
|
// tool.Must(nebula.Init(ctx, opt.Cfg.Nebula))
|
||||||
|
|
||||||
|
tool.Must(model.Init(db.New()))
|
||||||
|
tool.Must(controller.Init())
|
||||||
|
tool.Must(api.Start(ctx))
|
||||||
|
|
||||||
|
<-ctx.Done()
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
16
internal/cmd/init.go
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"flag"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
time.Local = time.FixedZone("CST", 8*3600)
|
||||||
|
|
||||||
|
flag.StringVar(&filename, "c", "etc/config.json", "config json file path")
|
||||||
|
flag.BoolVar(&opt.Debug, "debug", false, "")
|
||||||
|
|
||||||
|
flag.Parse()
|
||||||
|
}
|
12
internal/controller/impl.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
var (
|
||||||
|
// UserController todo: 可以实现自己的 controller
|
||||||
|
UserController userController
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() error {
|
||||||
|
UserController = uc{}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
154
internal/controller/user.go
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package controller
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"errors"
|
||||||
|
"fmt"
|
||||||
|
"github.com/loveuer/nf"
|
||||||
|
"github.com/loveuer/nf/nft/resp"
|
||||||
|
"github.com/spf13/cast"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"strings"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/database/cache"
|
||||||
|
"ultone/internal/database/db"
|
||||||
|
"ultone/internal/log"
|
||||||
|
"ultone/internal/model"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
type userController interface {
|
||||||
|
GetUser(c *nf.Ctx, id uint64) (*model.User, error)
|
||||||
|
GetUserByToken(c *nf.Ctx, token string) (*model.User, error)
|
||||||
|
CacheUser(c *nf.Ctx, user *model.User) error
|
||||||
|
CacheToken(c *nf.Ctx, token string, user *model.User) error
|
||||||
|
RmUserCache(c *nf.Ctx, id uint64) error
|
||||||
|
DeleteUser(c *nf.Ctx, id uint64) error
|
||||||
|
}
|
||||||
|
|
||||||
|
type uc struct{}
|
||||||
|
|
||||||
|
var _ userController = (*uc)(nil)
|
||||||
|
|
||||||
|
func (u uc) GetUser(c *nf.Ctx, 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 = cache.Client.Get(tool.Timeout(3), key); err != nil {
|
||||||
|
log.Warn(c, "controller.GetUser: get user by cache key=%s err=%v", key, err)
|
||||||
|
goto ByDB
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = json.Unmarshal(bs, target); err != nil {
|
||||||
|
log.Warn(c, "controller.GetUser: json unmarshal key=%s by=%s err=%v", key, string(bs), err)
|
||||||
|
goto ByDB
|
||||||
|
}
|
||||||
|
|
||||||
|
return target, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
ByDB:
|
||||||
|
if err = db.New(tool.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(c, target); err != nil {
|
||||||
|
log.Warn(c, "controller.GetUser: cache user key=%s err=%v", key, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return target, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u uc) GetUserByToken(c *nf.Ctx, 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 := cache.Client.Get(tool.Timeout(3), key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug(c, "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(c, userId); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return op, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u uc) CacheUser(c *nf.Ctx, target *model.User) error {
|
||||||
|
key := fmt.Sprintf("%s:user:id:%d", opt.CachePrefix, target.Id)
|
||||||
|
return cache.Client.Set(tool.Timeout(3), key, target)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u uc) CacheToken(c *nf.Ctx, 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 cache.Client.SetEx(tool.Timeout(3), key, user.Id, opt.TokenTimeout)
|
||||||
|
}
|
||||||
|
func (u uc) RmUserCache(c *nf.Ctx, id uint64) error {
|
||||||
|
key := fmt.Sprintf("%s:user:id:%d", opt.CachePrefix, id)
|
||||||
|
return cache.Client.Del(tool.Timeout(3), key)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (u uc) DeleteUser(c *nf.Ctx, id uint64) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
now = time.Now()
|
||||||
|
username = "CONCAT(username, '@del')"
|
||||||
|
)
|
||||||
|
|
||||||
|
if opt.Cfg.DB.Type == "sqlite" {
|
||||||
|
username = "username || '@del'"
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = db.New(tool.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(c, id); err != nil {
|
||||||
|
log.Warn(c, "controller.DeleteUser: rm user=%d cache err=%v", id, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
109
internal/database/cache/cache_lru.go
vendored
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/hashicorp/golang-lru/v2/expirable"
|
||||||
|
_ "github.com/hashicorp/golang-lru/v2/expirable"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ interfaces.Cacher = (*_lru)(nil)
|
||||||
|
|
||||||
|
type _lru struct {
|
||||||
|
client *expirable.LRU[string, *_lru_value]
|
||||||
|
}
|
||||||
|
|
||||||
|
type _lru_value struct {
|
||||||
|
duration time.Duration
|
||||||
|
last time.Time
|
||||||
|
bs []byte
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *_lru) Get(ctx context.Context, key string) ([]byte, error) {
|
||||||
|
v, ok := l.client.Get(key)
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrorKeyNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.duration == 0 {
|
||||||
|
return v.bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if time.Now().Sub(v.last) > v.duration {
|
||||||
|
l.client.Remove(key)
|
||||||
|
return nil, ErrorKeyNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
return v.bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *_lru) GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error) {
|
||||||
|
v, ok := l.client.Get(key)
|
||||||
|
if !ok {
|
||||||
|
return nil, ErrorKeyNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
if v.duration == 0 {
|
||||||
|
return v.bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
now := time.Now()
|
||||||
|
|
||||||
|
if now.Sub(v.last) > v.duration {
|
||||||
|
l.client.Remove(key)
|
||||||
|
return nil, ErrorKeyNotFound
|
||||||
|
}
|
||||||
|
|
||||||
|
l.client.Add(key, &_lru_value{
|
||||||
|
duration: duration,
|
||||||
|
last: now,
|
||||||
|
bs: v.bs,
|
||||||
|
})
|
||||||
|
|
||||||
|
return v.bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *_lru) Set(ctx context.Context, key string, value any) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
l.client.Add(key, &_lru_value{
|
||||||
|
duration: 0,
|
||||||
|
last: time.Now(),
|
||||||
|
bs: bs,
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *_lru) SetEx(ctx context.Context, key string, value any, duration time.Duration) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
l.client.Add(key, &_lru_value{
|
||||||
|
duration: duration,
|
||||||
|
last: time.Now(),
|
||||||
|
bs: bs,
|
||||||
|
})
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (l *_lru) Del(ctx context.Context, keys ...string) error {
|
||||||
|
for _, key := range keys {
|
||||||
|
l.client.Remove(key)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func newLRUCache() (interfaces.Cacher, error) {
|
||||||
|
client := expirable.NewLRU[string, *_lru_value](0, nil, 0)
|
||||||
|
|
||||||
|
return &_lru{client: client}, nil
|
||||||
|
}
|
65
internal/database/cache/cache_memory.go
vendored
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/interfaces"
|
||||||
|
|
||||||
|
"gitea.com/taozitaozi/gredis"
|
||||||
|
)
|
||||||
|
|
||||||
|
var _ interfaces.Cacher = (*_mem)(nil)
|
||||||
|
|
||||||
|
type _mem struct {
|
||||||
|
client *gredis.Gredis
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *_mem) Get(ctx context.Context, key string) ([]byte, error) {
|
||||||
|
v, err := m.client.Get(key)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
bs, ok := v.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid value type=%T", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *_mem) GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error) {
|
||||||
|
v, err := m.client.GetEx(key, duration)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
bs, ok := v.([]byte)
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("invalid value type=%T", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *_mem) Set(ctx context.Context, key string, value any) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.client.Set(key, bs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *_mem) SetEx(ctx context.Context, key string, value any, duration time.Duration) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
return m.client.SetEx(key, bs, duration)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *_mem) Del(ctx context.Context, keys ...string) error {
|
||||||
|
m.client.Delete(keys...)
|
||||||
|
return nil
|
||||||
|
}
|
54
internal/database/cache/cache_redis.go
vendored
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
type _redis struct {
|
||||||
|
client *redis.Client
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *_redis) Get(ctx context.Context, key string) ([]byte, error) {
|
||||||
|
result, err := r.client.Get(ctx, key).Result()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return []byte(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *_redis) GetEx(ctx context.Context, key string, duration time.Duration) ([]byte, error) {
|
||||||
|
result, err := r.client.GetEx(ctx, key, duration).Result()
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return []byte(result), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *_redis) Set(ctx context.Context, key string, value any) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = r.client.Set(ctx, key, bs, redis.KeepTTL).Result()
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *_redis) SetEx(ctx context.Context, key string, value any, duration time.Duration) error {
|
||||||
|
bs, err := handleValue(value)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = r.client.SetEX(ctx, key, bs, duration).Result()
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *_redis) Del(ctx context.Context, keys ...string) error {
|
||||||
|
return r.client.Del(ctx, keys...).Err()
|
||||||
|
}
|
33
internal/database/cache/client.go
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"ultone/internal/interfaces"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Client interfaces.Cacher
|
||||||
|
)
|
||||||
|
|
||||||
|
type encoded_value interface {
|
||||||
|
MarshalBinary() ([]byte, error)
|
||||||
|
}
|
||||||
|
|
||||||
|
type decoded_value interface {
|
||||||
|
UnmarshalBinary(bs []byte) error
|
||||||
|
}
|
||||||
|
|
||||||
|
func handleValue(value any) ([]byte, error) {
|
||||||
|
var (
|
||||||
|
bs []byte
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if imp, ok := value.(encoded_value); ok {
|
||||||
|
bs, err = imp.MarshalBinary()
|
||||||
|
} else {
|
||||||
|
bs, err = json.Marshal(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
return bs, err
|
||||||
|
}
|
7
internal/database/cache/error.go
vendored
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import "errors"
|
||||||
|
|
||||||
|
var (
|
||||||
|
ErrorKeyNotFound = errors.New("key not found")
|
||||||
|
)
|
70
internal/database/cache/init.go
vendored
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
package cache
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"gitea.com/taozitaozi/gredis"
|
||||||
|
"github.com/go-redis/redis/v8"
|
||||||
|
"net/url"
|
||||||
|
"strings"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() error {
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
strs := strings.Split(opt.Cfg.Cache.Uri, "::")
|
||||||
|
|
||||||
|
switch strs[0] {
|
||||||
|
case "memory":
|
||||||
|
gc := gredis.NewGredis(1024 * 1024)
|
||||||
|
Client = &_mem{client: gc}
|
||||||
|
case "lru":
|
||||||
|
if Client, err = newLRUCache(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
case "redis":
|
||||||
|
var (
|
||||||
|
ins *url.URL
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(strs) != 2 {
|
||||||
|
return fmt.Errorf("cache.Init: invalid cache uri: %s", opt.Cfg.Cache.Uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
uri := strs[1]
|
||||||
|
|
||||||
|
if !strings.Contains(uri, "://") {
|
||||||
|
uri = fmt.Sprintf("redis://%s", uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ins, err = url.Parse(uri); err != nil {
|
||||||
|
return fmt.Errorf("cache.Init: url parse cache uri: %s, err: %s", opt.Cfg.Cache.Uri, err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
addr := ins.Host
|
||||||
|
username := ins.User.Username()
|
||||||
|
password, _ := ins.User.Password()
|
||||||
|
|
||||||
|
var rc *redis.Client
|
||||||
|
rc = redis.NewClient(&redis.Options{
|
||||||
|
Addr: addr,
|
||||||
|
Username: username,
|
||||||
|
Password: password,
|
||||||
|
})
|
||||||
|
|
||||||
|
if err = rc.Ping(tool.Timeout(5)).Err(); err != nil {
|
||||||
|
return fmt.Errorf("cache.Init: redis ping err: %s", err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
Client = &_redis{client: rc}
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("cache type %s not support", strs[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
38
internal/database/db/client.go
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
cli = &client{}
|
||||||
|
)
|
||||||
|
|
||||||
|
type client struct {
|
||||||
|
cli *gorm.DB
|
||||||
|
ttype string
|
||||||
|
}
|
||||||
|
|
||||||
|
func Type() string {
|
||||||
|
return cli.ttype
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(ctxs ...context.Context) *gorm.DB {
|
||||||
|
var ctx context.Context
|
||||||
|
if len(ctxs) > 0 && ctxs[0] != nil {
|
||||||
|
ctx = ctxs[0]
|
||||||
|
} else {
|
||||||
|
ctx = tool.Timeout(30)
|
||||||
|
}
|
||||||
|
|
||||||
|
session := cli.cli.Session(&gorm.Session{Context: ctx})
|
||||||
|
|
||||||
|
if opt.Debug {
|
||||||
|
session = session.Debug()
|
||||||
|
}
|
||||||
|
|
||||||
|
return session
|
||||||
|
}
|
46
internal/database/db/init.go
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package db
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/glebarez/sqlite"
|
||||||
|
"gorm.io/driver/mysql"
|
||||||
|
"gorm.io/driver/postgres"
|
||||||
|
"gorm.io/gorm"
|
||||||
|
"strings"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() error {
|
||||||
|
strs := strings.Split(opt.Cfg.DB.Uri, "::")
|
||||||
|
|
||||||
|
if len(strs) != 2 {
|
||||||
|
return fmt.Errorf("db.Init: opt db uri invalid: %s", opt.Cfg.DB.Uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
cli.ttype = strs[0]
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
dsn = strs[1]
|
||||||
|
)
|
||||||
|
|
||||||
|
switch strs[0] {
|
||||||
|
case "sqlite":
|
||||||
|
opt.Cfg.DB.Type = "sqlite"
|
||||||
|
cli.cli, err = gorm.Open(sqlite.Open(dsn))
|
||||||
|
case "mysql":
|
||||||
|
opt.Cfg.DB.Type = "mysql"
|
||||||
|
cli.cli, err = gorm.Open(mysql.Open(dsn))
|
||||||
|
case "postgres":
|
||||||
|
opt.Cfg.DB.Type = "postgres"
|
||||||
|
cli.cli, err = gorm.Open(postgres.Open(dsn))
|
||||||
|
default:
|
||||||
|
return fmt.Errorf("db type only support: [sqlite, mysql, postgres], unsupported db type: %s", strs[0])
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("db.Init: open %s with dsn:%s, err: %w", strs[0], dsn, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
29
internal/database/es/client.go
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
package es
|
||||||
|
|
||||||
|
import (
|
||||||
|
elastic "github.com/elastic/go-elasticsearch/v7"
|
||||||
|
"github.com/loveuer/esgo2dump/xes/es7"
|
||||||
|
"github.com/loveuer/nf/nft/log"
|
||||||
|
"net/url"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
Client *elastic.Client
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init() error {
|
||||||
|
ins, err := url.Parse(opt.Cfg.ES.Uri)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Debug("es.InitClient url parse uri: %s, result: %+v", opt.Cfg.ES.Uri, ins)
|
||||||
|
|
||||||
|
if Client, err = es7.NewClient(tool.Timeout(10), ins); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
89
internal/database/mq/client.go
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
"fmt"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
"net/url"
|
||||||
|
"sync"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Init - init mq client:
|
||||||
|
// - @param.uri: "{scheme[amqp/amqps]}://{username}:{password}@{endpoint}/{virtual_host}"
|
||||||
|
// - @param.certs: with amqps, certs[0]=client crt bytes, certs[0]=client key bytes
|
||||||
|
|
||||||
|
type _client struct {
|
||||||
|
sync.Mutex
|
||||||
|
uri string
|
||||||
|
tlsCfg *tls.Config
|
||||||
|
conn *amqp.Connection
|
||||||
|
ch *amqp.Channel
|
||||||
|
consume <-chan amqp.Delivery
|
||||||
|
queue *queueOption
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *_client) open() error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
c.Lock()
|
||||||
|
defer c.Unlock()
|
||||||
|
|
||||||
|
if c.tlsCfg != nil {
|
||||||
|
c.conn, err = amqp.DialTLS(c.uri, c.tlsCfg)
|
||||||
|
} else {
|
||||||
|
c.conn, err = amqp.Dial(c.uri)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.ch, err = c.conn.Channel(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if client.queue != nil && client.queue.name != "" {
|
||||||
|
if _, err = client.ch.QueueDeclare(
|
||||||
|
client.queue.name,
|
||||||
|
client.queue.durable,
|
||||||
|
client.queue.autoDelete,
|
||||||
|
client.queue.exclusive,
|
||||||
|
client.queue.noWait,
|
||||||
|
client.queue.args,
|
||||||
|
); err != nil {
|
||||||
|
return fmt.Errorf("declare queue: %s, err: %w", client.queue.name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
client = &_client{
|
||||||
|
uri: "amqp://guest:guest@127.0.0.1:5672/",
|
||||||
|
tlsCfg: nil,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
// Init - init mq client
|
||||||
|
func Init(opts ...OptionFn) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
for _, fn := range opts {
|
||||||
|
fn(client)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, err = url.Parse(client.uri); err != nil {
|
||||||
|
return fmt.Errorf("url parse uri err: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err = client.open(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
111
internal/database/mq/client_test.go
Normal file
@ -0,0 +1,111 @@
|
|||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"crypto/tls"
|
||||||
|
"crypto/x509"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
"os"
|
||||||
|
"os/signal"
|
||||||
|
"strconv"
|
||||||
|
"syscall"
|
||||||
|
"testing"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestConsume(t *testing.T) {
|
||||||
|
clientCert, err := tls.LoadX509KeyPair(
|
||||||
|
"/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/client.crt",
|
||||||
|
"/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/client.key",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
ca, err := os.ReadFile("/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/ca.crt")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
caCertPool := x509.NewCertPool()
|
||||||
|
if !caCertPool.AppendCertsFromPEM(ca) {
|
||||||
|
t.Fatal("ca pool append ca crt err")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := Init(
|
||||||
|
WithURI("amqps://admin:password@mq.dev:5671/export"),
|
||||||
|
WithTLS(&tls.Config{
|
||||||
|
Certificates: []tls.Certificate{clientCert},
|
||||||
|
RootCAs: caCertPool,
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}),
|
||||||
|
WithQueueDeclare("export", false, false, false, false, amqp.Table{"x-max-priority": 100}),
|
||||||
|
); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
ch, err := Consume(ctx, "export", &ConsumeOpt{MaxReconnection: -1})
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
t.Log("[TEST] start consume msg")
|
||||||
|
for msg := range ch {
|
||||||
|
t.Logf("[TEST] [%s] [msg: %s]", time.Now().Format("060102T150405"), string(msg.Body))
|
||||||
|
_ = msg.Ack(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestPublish(t *testing.T) {
|
||||||
|
clientCert, err := tls.LoadX509KeyPair(
|
||||||
|
"/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/client.crt",
|
||||||
|
"/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/client.key",
|
||||||
|
)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
ca, err := os.ReadFile("/Users/loveuer/codes/project/bifrost-pro/search_v3/internal/database/mq/tls/ca.crt")
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
caCertPool := x509.NewCertPool()
|
||||||
|
if !caCertPool.AppendCertsFromPEM(ca) {
|
||||||
|
t.Fatal("ca pool append ca crt err")
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := Init(
|
||||||
|
WithURI("amqps://admin:password@mq.dev:5671/export"),
|
||||||
|
WithTLS(&tls.Config{
|
||||||
|
Certificates: []tls.Certificate{clientCert},
|
||||||
|
RootCAs: caCertPool,
|
||||||
|
InsecureSkipVerify: true,
|
||||||
|
}),
|
||||||
|
WithQueueDeclare("export", false, false, false, false, amqp.Table{"x-max-priority": 100}),
|
||||||
|
); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx, cancel := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
count := 1
|
||||||
|
|
||||||
|
t.Log("[TEST] start publish msg...")
|
||||||
|
|
||||||
|
for {
|
||||||
|
if err = Publish(ctx, "export", amqp.Publishing{
|
||||||
|
ContentType: "text/plain",
|
||||||
|
Body: []byte(time.Now().Format(time.RFC3339) + " => hello_world@" + strconv.Itoa(count)),
|
||||||
|
}); err != nil {
|
||||||
|
t.Log(err.Error())
|
||||||
|
}
|
||||||
|
|
||||||
|
time.Sleep(11 * time.Second)
|
||||||
|
count++
|
||||||
|
}
|
||||||
|
}
|
97
internal/database/mq/consume.go
Normal file
@ -0,0 +1,97 @@
|
|||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"fmt"
|
||||||
|
"github.com/loveuer/esgo2dump/log"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
"os"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ConsumeOpt
|
||||||
|
// - Name: consumer's name, default unamed_<timestamp>
|
||||||
|
// - MaxReconnection: when mq connection closed, max reconnection times, default 3, -1 for unlimited
|
||||||
|
type ConsumeOpt struct {
|
||||||
|
Name string // consumer's name, default unamed_<timestamp>
|
||||||
|
AutoAck bool
|
||||||
|
Exclusive bool
|
||||||
|
NoLocal bool
|
||||||
|
NoWait bool
|
||||||
|
MaxReconnection int // when mq connection closed, max reconnection times, default 3, -1 for unlimited
|
||||||
|
Args amqp.Table
|
||||||
|
}
|
||||||
|
|
||||||
|
func Consume(ctx context.Context, queue string, opts ...*ConsumeOpt) (<-chan amqp.Delivery, error) {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
res = make(chan amqp.Delivery, 1)
|
||||||
|
opt = &ConsumeOpt{
|
||||||
|
Name: os.Getenv("HOSTNAME"),
|
||||||
|
AutoAck: false,
|
||||||
|
Exclusive: false,
|
||||||
|
NoLocal: false,
|
||||||
|
NoWait: false,
|
||||||
|
Args: nil,
|
||||||
|
MaxReconnection: 3,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(opts) > 0 && opts[0] != nil {
|
||||||
|
opt = opts[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
if opt.Name == "" {
|
||||||
|
opt.Name = fmt.Sprintf("unamed_%d", time.Now().UnixMilli())
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Lock()
|
||||||
|
if client.consume, err = client.ch.Consume(queue, opt.Name, opt.AutoAck, opt.Exclusive, opt.NoLocal, opt.NoWait, opt.Args); err != nil {
|
||||||
|
client.Unlock()
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
client.Unlock()
|
||||||
|
|
||||||
|
go func() {
|
||||||
|
Run:
|
||||||
|
retry := 0
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case <-ctx.Done():
|
||||||
|
close(res)
|
||||||
|
return
|
||||||
|
case m, ok := <-client.consume:
|
||||||
|
if !ok {
|
||||||
|
log.Warn("[mq] consume channel closed!!!")
|
||||||
|
goto Reconnect
|
||||||
|
}
|
||||||
|
|
||||||
|
res <- m
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Reconnect:
|
||||||
|
if opt.MaxReconnection == -1 || opt.MaxReconnection > retry {
|
||||||
|
retry++
|
||||||
|
|
||||||
|
log.Warn("[mq] try reconnect[%d/%d] to mq server after %d seconds...err: %v", retry, opt.MaxReconnection, tool.Min(60, retry*5), err)
|
||||||
|
time.Sleep(time.Duration(tool.Min(60, retry*5)) * time.Second)
|
||||||
|
if err = client.open(); err != nil {
|
||||||
|
goto Reconnect
|
||||||
|
}
|
||||||
|
|
||||||
|
client.Lock()
|
||||||
|
if client.consume, err = client.ch.Consume(queue, opt.Name, opt.AutoAck, opt.Exclusive, opt.NoLocal, opt.NoWait, opt.Args); err != nil {
|
||||||
|
client.Unlock()
|
||||||
|
goto Reconnect
|
||||||
|
}
|
||||||
|
client.Unlock()
|
||||||
|
|
||||||
|
log.Info("[mq] reconnect success!!!")
|
||||||
|
goto Run
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
return res, nil
|
||||||
|
}
|
48
internal/database/mq/opt.go
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"crypto/tls"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
)
|
||||||
|
|
||||||
|
type OptionFn func(*_client)
|
||||||
|
|
||||||
|
// WithURI
|
||||||
|
// - amqp uri, e.g. amqp://guest:guest@127.0.0.1:5672/vhost
|
||||||
|
// - tips: with tls, scheme should be amqps, amqps://xx:xx@127.0.0.1:5672/vhost
|
||||||
|
func WithURI(uri string) OptionFn {
|
||||||
|
return func(c *_client) {
|
||||||
|
c.uri = uri
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// WithTLS
|
||||||
|
// - amqps tls config
|
||||||
|
// - include client cert, client key, ca cert
|
||||||
|
func WithTLS(tlsCfg *tls.Config) OptionFn {
|
||||||
|
return func(c *_client) {
|
||||||
|
c.tlsCfg = tlsCfg
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type queueOption struct {
|
||||||
|
name string
|
||||||
|
durable bool
|
||||||
|
autoDelete bool
|
||||||
|
exclusive bool
|
||||||
|
noWait bool
|
||||||
|
args amqp.Table
|
||||||
|
}
|
||||||
|
|
||||||
|
func WithQueueDeclare(name string, durable, autoDelete, exclusive, noWait bool, args amqp.Table) OptionFn {
|
||||||
|
return func(c *_client) {
|
||||||
|
c.queue = &queueOption{
|
||||||
|
name: name,
|
||||||
|
durable: durable,
|
||||||
|
autoDelete: autoDelete,
|
||||||
|
exclusive: exclusive,
|
||||||
|
noWait: noWait,
|
||||||
|
args: args,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
62
internal/database/mq/publish.go
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
package mq
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"errors"
|
||||||
|
"github.com/loveuer/esgo2dump/log"
|
||||||
|
amqp "github.com/rabbitmq/amqp091-go"
|
||||||
|
"time"
|
||||||
|
"ultone/internal/tool"
|
||||||
|
)
|
||||||
|
|
||||||
|
// PublishOpt
|
||||||
|
// - MaxReconnect: publish msg auto retry with reconnect, should not be big, case memory leak
|
||||||
|
type PublishOpt struct {
|
||||||
|
Exchange string
|
||||||
|
Mandatory bool
|
||||||
|
Immediate bool
|
||||||
|
MaxReconnect uint8 // publish msg auto retry with reconnect, should not be big(default 1), case memory leak
|
||||||
|
}
|
||||||
|
|
||||||
|
func Publish(ctx context.Context, queue string, msg amqp.Publishing, opts ...*PublishOpt) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
opt = &PublishOpt{
|
||||||
|
Exchange: amqp.DefaultExchange,
|
||||||
|
Mandatory: false,
|
||||||
|
Immediate: false,
|
||||||
|
MaxReconnect: 1,
|
||||||
|
}
|
||||||
|
retry = 0
|
||||||
|
)
|
||||||
|
|
||||||
|
if len(opts) > 0 && opts[0] != nil {
|
||||||
|
opt = opts[0]
|
||||||
|
}
|
||||||
|
|
||||||
|
for ; retry <= int(opt.MaxReconnect); retry++ {
|
||||||
|
if err = client.ch.PublishWithContext(ctx, opt.Exchange, queue, opt.Mandatory, opt.Immediate, msg); err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
if errors.Is(err, amqp.ErrClosed) {
|
||||||
|
sleep := tool.Min(120, (retry+1)*30)
|
||||||
|
|
||||||
|
log.Warn("[mq] connection closed, reconnect[%d/%d] after %d seconds", retry+1, opt.MaxReconnect, sleep)
|
||||||
|
|
||||||
|
time.Sleep(time.Duration(sleep) * time.Second)
|
||||||
|
|
||||||
|
if oerr := client.open(); oerr != nil {
|
||||||
|
log.Error("[mq] reconnect[%d/%d] mq err: %v", oerr, retry+1, opt.MaxReconnect)
|
||||||
|
} else {
|
||||||
|
log.Info("[mq] reconnect mq success!!!")
|
||||||
|
}
|
||||||
|
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return err
|
||||||
|
}
|
34
internal/database/nebula/client.go
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package nebula
|
||||||
|
|
||||||
|
import (
|
||||||
|
"context"
|
||||||
|
"github.com/loveuer/ngorm/v2"
|
||||||
|
"strings"
|
||||||
|
"ultone/internal/opt"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
client *ngorm.Client
|
||||||
|
)
|
||||||
|
|
||||||
|
func Init(ctx context.Context, cfg opt.Nebula) error {
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
|
||||||
|
if client, err = ngorm.NewClient(ctx, &ngorm.Config{
|
||||||
|
Endpoints: strings.Split(cfg.Uri, ","),
|
||||||
|
Username: cfg.Username,
|
||||||
|
Password: cfg.Password,
|
||||||
|
DefaultSpace: cfg.Space,
|
||||||
|
Logger: nil,
|
||||||
|
}); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func New(ctx context.Context, cfgs ...*ngorm.SessCfg) *ngorm.Session {
|
||||||
|
return client.Session(cfgs...)
|
||||||
|
}
|