first commit
This commit is contained in:
commit
ee50f56b26
5
.devcontainer/.env
Normal file
5
.devcontainer/.env
Normal file
@ -0,0 +1,5 @@
|
||||
|
||||
POSTGRES_DB=ginadmin
|
||||
POSTGRES_USER=postgres
|
||||
POSTGRES_PASSWORD=123456
|
||||
DATABASE_URL=postgres://postgres:123456@db:5432/ginadmin
|
||||
13
.devcontainer/Dockerfile
Normal file
13
.devcontainer/Dockerfile
Normal file
@ -0,0 +1,13 @@
|
||||
FROM mcr.microsoft.com/devcontainers/go:1.22-bookworm
|
||||
|
||||
ARG APP=jinshan_community
|
||||
|
||||
# Set CGO_CFLAGS to enable large file support
|
||||
ENV CGO_CFLAGS "-D_LARGEFILE64_SOURCE"
|
||||
|
||||
RUN go install github.com/google/wire/cmd/wire@latest \
|
||||
&& go install github.com/swaggo/swag/cmd/swag@latest \
|
||||
&& go install github.com/gin-admin/gin-admin-cli/v10@latest \
|
||||
&& chown -R vscode /go
|
||||
|
||||
|
||||
9
.devcontainer/devcontainer.json
Normal file
9
.devcontainer/devcontainer.json
Normal file
@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "ginadmin",
|
||||
"dockerComposeFile": "docker-compose.yml",
|
||||
"service": "app",
|
||||
"workspaceFolder": "/workspaces/${localWorkspaceFolderBasename}",
|
||||
"forwardPorts": [
|
||||
8040
|
||||
]
|
||||
}
|
||||
42
.devcontainer/docker-compose.yml
Normal file
42
.devcontainer/docker-compose.yml
Normal file
@ -0,0 +1,42 @@
|
||||
version: "3"
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
command: sleep infinity
|
||||
networks:
|
||||
- db
|
||||
- redis
|
||||
volumes:
|
||||
- ../..:/workspaces:cached
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
db:
|
||||
image: postgres:15.3-alpine
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 5432:5432
|
||||
networks:
|
||||
- db
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
env_file:
|
||||
- .env
|
||||
|
||||
redis:
|
||||
image: redis:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- 6379:6379
|
||||
networks:
|
||||
- redis
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
|
||||
networks:
|
||||
db:
|
||||
redis:
|
||||
32
.gitignore
vendored
Normal file
32
.gitignore
vendored
Normal file
@ -0,0 +1,32 @@
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, build with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
*.DS_Store
|
||||
/jinshan_community
|
||||
/jinshan_community_linux_amd64
|
||||
/jinshan_community.lock
|
||||
/release
|
||||
/data
|
||||
/internal/test/data
|
||||
tmp
|
||||
/vendor
|
||||
/configs/gen_rbac_policy.csv
|
||||
/configs/gen_rbac_policy.csv.bak
|
||||
/configs/rbac_policy.csv.bak
|
||||
/test/data
|
||||
/internal/swagger/v3/.openapi-generator
|
||||
/internal/swagger/v3/.openapi-generator-ignore
|
||||
|
||||
# IDE configs
|
||||
.idea
|
||||
.vscode
|
||||
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
FROM golang:alpine as builder
|
||||
|
||||
ARG APP=jinshan_community
|
||||
ARG VERSION=v1.0.0
|
||||
ARG RELEASE_TAG=$(VERSION)
|
||||
|
||||
# Install the required packages
|
||||
RUN apk add --no-cache gcc musl-dev sqlite-dev
|
||||
|
||||
# Set CGO_CFLAGS to enable large file support
|
||||
ENV CGO_CFLAGS "-D_LARGEFILE64_SOURCE"
|
||||
|
||||
ENV GOPROXY="https://goproxy.cn"
|
||||
|
||||
WORKDIR /go/src/${APP}
|
||||
COPY . .
|
||||
|
||||
# Build the application
|
||||
RUN go build -ldflags "-w -s -X main.VERSION=${RELEASE_TAG}" -o ./${APP} .
|
||||
|
||||
FROM alpine
|
||||
ARG APP=jinshan_community
|
||||
WORKDIR /go/src/${APP}
|
||||
COPY --from=builder /go/src/${APP}/${APP} /usr/bin/
|
||||
# COPY --from=builder /go/src/${APP}/configs /usr/bin/configs
|
||||
# COPY --from=builder /go/src/${APP}/dist /usr/bin/dist
|
||||
ENTRYPOINT ["jinshan_community", "start", "-d", "/usr/bin/configs", "-c", "prod", "-s", "/usr/bin/dist"]
|
||||
EXPOSE 8040
|
||||
51
Makefile
Normal file
51
Makefile
Normal file
@ -0,0 +1,51 @@
|
||||
.PHONY: start build
|
||||
|
||||
NOW = $(shell date -u '+%Y%m%d%I%M%S')
|
||||
|
||||
RELEASE_VERSION = v1.0.0
|
||||
|
||||
APP = jinshan_community
|
||||
SERVER_BIN = ${APP}
|
||||
GIT_COUNT = $(shell git rev-list --all --count)
|
||||
GIT_HASH = $(shell git rev-parse --short HEAD)
|
||||
RELEASE_TAG = $(RELEASE_VERSION).$(GIT_COUNT).$(GIT_HASH)
|
||||
|
||||
CONFIG_DIR = ./configs
|
||||
CONFIG_FILES = dev
|
||||
STATIC_DIR = ./build/dist
|
||||
START_ARGS = -d $(CONFIG_DIR) -c $(CONFIG_FILES) -s $(STATIC_DIR)
|
||||
|
||||
all: start
|
||||
|
||||
start:
|
||||
@go run -ldflags "-X main.VERSION=$(RELEASE_TAG)" main.go start $(START_ARGS)
|
||||
|
||||
build:
|
||||
@go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN)
|
||||
|
||||
build-linux:
|
||||
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 CC="zig cc -target x86_64-linux-musl" CXX="zig c++ -target x86_64-linux-musl" CGO_CFLAGS="-D_LARGEFILE64_SOURCE" go build -ldflags "-w -s -X main.VERSION=$(RELEASE_TAG)" -o $(SERVER_BIN)_linux_amd64
|
||||
|
||||
# go install github.com/google/wire/cmd/wire@latest
|
||||
wire:
|
||||
@wire gen ./internal/wirex
|
||||
|
||||
# go install github.com/swaggo/swag/cmd/swag@latest
|
||||
swagger:
|
||||
@swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger
|
||||
|
||||
# https://github.com/OpenAPITools/openapi-generator
|
||||
openapi:
|
||||
docker run --rm -v ${PWD}:/local openapitools/openapi-generator-cli generate -i /local/internal/swagger/swagger.yaml -g openapi -o /local/internal/swagger/v3
|
||||
|
||||
clean:
|
||||
rm -rf data $(SERVER_BIN)
|
||||
|
||||
serve: build
|
||||
./$(SERVER_BIN) start $(START_ARGS)
|
||||
|
||||
serve-d: build
|
||||
./$(SERVER_BIN) start $(START_ARGS) --daemon
|
||||
|
||||
stop:
|
||||
./$(SERVER_BIN) stop
|
||||
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
||||
# jinshan_community
|
||||
|
||||
> 近山社区小程序平台
|
||||
|
||||
## Quick Start
|
||||
|
||||
```bash
|
||||
make start
|
||||
```
|
||||
|
||||
## Build
|
||||
|
||||
```bash
|
||||
make build
|
||||
```
|
||||
|
||||
## Generate wire inject files
|
||||
|
||||
```bash
|
||||
make wire
|
||||
```
|
||||
|
||||
## Generate swagger documents
|
||||
|
||||
```bash
|
||||
make swagger
|
||||
```
|
||||
|
||||
250
README_EN.md
Normal file
250
README_EN.md
Normal file
@ -0,0 +1,250 @@
|
||||
# [Gin](https://github.com/gin-gonic/gin)-Admin
|
||||
|
||||
> A lightweight, flexible, elegant and full-featured RBAC scaffolding based on Golang + Gin + GORM 2.0 + Casbin 2.0 + Wire DI.
|
||||
|
||||
English | [中文](README.md)
|
||||
|
||||
[](https://github.com/LyricTian/gin-admin/blob/main/LICENSE)
|
||||
[](https://golang.org/)
|
||||
[](https://goreportcard.com/report/github.com/LyricTian/gin-admin)
|
||||
[](https://github.com/LyricTian/gin-admin/releases)
|
||||
[](https://github.com/LyricTian/gin-admin/releases)
|
||||
[](https://godoc.org/github.com/LyricTian/gin-admin)
|
||||
|
||||
## Features
|
||||
|
||||
- :scroll: Elegant implementation of `RESTful API`, using interface-based programming paradigm to make your API design more professional and standardized
|
||||
- :house: Adopts clear and concise modular architecture, making code structure clear at a glance, maintenance and upgrades more effortless
|
||||
- :rocket: Based on high-performance `GIN` framework, integrating rich and practical middleware (authentication, CORS, logging, rate limiting, tracing, permission control, fault tolerance, compression, etc.), helping you quickly build enterprise-level applications
|
||||
- :closed_lock_with_key: Integrates industry-leading `Casbin` permission framework, flexible and precise RBAC permission control makes security protection rock solid
|
||||
- :page_facing_up: Based on powerful `GORM 2.0` ORM framework, elegantly handles database operations, greatly improving development efficiency
|
||||
- :electric_plug: Innovatively adopts `WIRE` dependency injection, revolutionarily simplifies module dependency relationships, making code more elegant and decoupled
|
||||
- :memo: Based on high-performance `Zap` logging framework, coupled with Context tracing, making system running status clear and transparent, problem troubleshooting nowhere to hide
|
||||
- :key: Integrates time-tested `JWT` authentication mechanism, making user identity verification more secure and reliable
|
||||
- :microscope: Automatically integrates `Swagger` API documentation, real-time API documentation updates, making development and debugging easier - [Online Demo](https://demo.ginadmin.top/swagger/index.html)
|
||||
- :wrench: Complete unit testing system, based on `testify` framework to ensure system quality, leaving no place for bugs to hide
|
||||
- :100: Adopts stateless design, supports horizontal scaling, paired with Redis to implement dynamic permission management, letting your system easily handle high concurrency
|
||||
- :hammer: Developer's blessing! Powerful scaffolding tool [gin-admin-cli](https://github.com/gin-admin/gin-admin-cli), making your development work twice as efficient
|
||||
|
||||

|
||||

|
||||
|
||||
## Frontend Projects
|
||||
|
||||
- [Frontend project based on Ant Design React](https://github.com/gin-admin/gin-admin-frontend)
|
||||
- [Frontend project based on Vue.js](https://github.com/gin-admin/gin-admin-vue)
|
||||
|
||||
## Install Dependencies
|
||||
|
||||
- [Go](https://golang.org/) 1.19+
|
||||
- [Wire](github.com/google/wire) `go install github.com/google/wire/cmd/wire@latest`
|
||||
- [Swag](github.com/swaggo/swag) `go install github.com/swaggo/swag/cmd/swag@latest`
|
||||
- [GIN-ADMIN-CLI](https://github.com/gin-admin/gin-admin-cli) `go install github.com/gin-admin/gin-admin-cli/v10@latest`
|
||||
|
||||
## Quick Start
|
||||
|
||||
### Create a New Project
|
||||
|
||||
> You can view detailed command instructions via `gin-admin-cli help new`
|
||||
|
||||
```bash
|
||||
gin-admin-cli new -d ~/go/src --name testapp --desc 'A test API service based on golang.' --pkg 'github.com/xxx/testapp' --git-url https://gitee.com/lyric/gin-admin.git
|
||||
```
|
||||
|
||||
### Start the Service
|
||||
|
||||
> You can switch to Chinese menu by changing `MenuFile = "menu_cn.json"` in the `configs/dev/server.toml` configuration file
|
||||
|
||||
```bash
|
||||
cd ~/go/src/testapp
|
||||
|
||||
make start
|
||||
# or
|
||||
go run main.go start
|
||||
```
|
||||
|
||||
### Compile the Service
|
||||
|
||||
```bash
|
||||
make build
|
||||
# or
|
||||
go build -ldflags "-w -s -X main.VERSION=v1.0.0" -o testapp
|
||||
```
|
||||
|
||||
### Generate Docker Image
|
||||
|
||||
```bash
|
||||
docker build -f ./Dockerfile -t testapp:v1.0.0 .
|
||||
```
|
||||
|
||||
### Generate Codes
|
||||
|
||||
> You can view detailed command instructions via `gin-admin-cli help gen`
|
||||
|
||||
#### Prepare Configuration File `dictionary.yaml`
|
||||
|
||||
```yaml
|
||||
- name: Dictionary
|
||||
comment: Dictionary management
|
||||
disable_pagination: true
|
||||
fill_gorm_commit: true
|
||||
fill_router_prefix: true
|
||||
tpl_type: "tree"
|
||||
fields:
|
||||
- name: Code
|
||||
type: string
|
||||
comment: Code of dictionary (unique for same parent)
|
||||
gorm_tag: "size:32;"
|
||||
form:
|
||||
binding_tag: "required,max=32"
|
||||
- name: Name
|
||||
type: string
|
||||
comment: Display name of dictionary
|
||||
gorm_tag: "size:128;index"
|
||||
query:
|
||||
name: LikeName
|
||||
in_query: true
|
||||
form_tag: name
|
||||
op: LIKE
|
||||
form:
|
||||
binding_tag: "required,max=128"
|
||||
- name: Description
|
||||
type: string
|
||||
comment: Details about dictionary
|
||||
gorm_tag: "size:1024"
|
||||
form: {}
|
||||
- name: Sequence
|
||||
type: int
|
||||
comment: Sequence for sorting
|
||||
gorm_tag: "index;"
|
||||
order: DESC
|
||||
form: {}
|
||||
- name: Status
|
||||
type: string
|
||||
comment: Status of dictionary (disabled, enabled)
|
||||
gorm_tag: "size:20;index"
|
||||
query: {}
|
||||
form:
|
||||
binding_tag: "required,oneof=disabled enabled"
|
||||
```
|
||||
|
||||
```bash
|
||||
gin-admin-cli gen -d . -m SYS -c dictionary.yaml
|
||||
```
|
||||
|
||||
### Delete Function Module
|
||||
|
||||
> You can view detailed command instructions via `gin-admin-cli help remove`
|
||||
|
||||
```bash
|
||||
gin-admin-cli rm -d . -m CMS --structs Article
|
||||
```
|
||||
|
||||
### Generate Swagger Documentation
|
||||
|
||||
> You can generate Swagger documentation automatically via [Swag](github.com/swaggo/swag)
|
||||
|
||||
```bash
|
||||
make swagger
|
||||
# or
|
||||
swag init --parseDependency --generalInfo ./main.go --output ./internal/swagger
|
||||
```
|
||||
|
||||
### Generate Dependency Injection Code
|
||||
|
||||
> Dependency injection itself is used to solve the initial process of layer dependency among various modules, and you can generate dependency injection code automatically via [Wire](github.com/google/wire) to simplify the dependency injection process.
|
||||
|
||||
```bash
|
||||
make wire
|
||||
# or
|
||||
wire gen ./internal/wirex
|
||||
```
|
||||
|
||||
## Project Structure Overview
|
||||
|
||||
```text
|
||||
├── cmd (Command line definition directory)
|
||||
│ ├── start.go (Start command)
|
||||
│ ├── stop.go (Stop command)
|
||||
│ └── version.go (Version command)
|
||||
├── configs
|
||||
│ ├── dev
|
||||
│ │ ├── logging.toml (Logging configuration file)
|
||||
│ │ ├── middleware.toml (Middleware configuration file)
|
||||
│ │ └── server.toml (Service configuration file)
|
||||
│ ├── menu.json (Initialization menu file)
|
||||
│ └── rbac_model.conf (Casbin RBAC model configuration file)
|
||||
├── internal
|
||||
│ ├── bootstrap (Initialization directory)
|
||||
│ │ ├── bootstrap.go (Initialization)
|
||||
│ │ ├── http.go (HTTP service)
|
||||
│ │ └── logger.go (Logging service)
|
||||
│ ├── config (Configuration file directory)
|
||||
│ │ ├── config.go (Configuration file initialization)
|
||||
│ │ ├── consts.go (Constant definition)
|
||||
│ │ ├── middleware.go (Middleware configuration)
|
||||
│ │ └── parse.go (Configuration file parsing)
|
||||
│ ├── mods
|
||||
│ │ ├── rbac (RBAC module)
|
||||
│ │ │ ├── api (API layer)
|
||||
│ │ │ ├── biz (Business logic layer)
|
||||
│ │ │ ├── dal (Data access layer)
|
||||
│ │ │ ├── schema (Data model layer)
|
||||
│ │ │ ├── casbin.go (Casbin initialization)
|
||||
│ │ │ ├── main.go (RBAC module entry)
|
||||
│ │ │ └── wire.go (RBAC dependency injection initialization)
|
||||
│ │ └── mods.go
|
||||
│ ├── utility
|
||||
│ │ └── prom
|
||||
│ │ └── prom.go (Prometheus monitoring, used for integration with prometheus)
|
||||
│ └── wirex (Dependency injection directory, contains the definition and initialization of dependency groups)
|
||||
│ ├── injector.go
|
||||
│ ├── wire.go
|
||||
│ └── wire_gen.go
|
||||
├── pkg (Public package directory)
|
||||
│ ├── cachex (Cache package)
|
||||
│ ├── crypto (Encryption package)
|
||||
│ │ ├── aes (AES encryption)
|
||||
│ │ ├── hash (Hash encryption)
|
||||
│ │ └── rand (Random number)
|
||||
│ ├── encoding (Encoding package)
|
||||
│ │ ├── json (JSON encoding)
|
||||
│ │ ├── toml (TOML encoding)
|
||||
│ │ └── yaml (YAML encoding)
|
||||
│ ├── errors (Error handling package)
|
||||
│ ├── gormx (Gorm extension package)
|
||||
│ ├── jwtx (JWT package)
|
||||
│ ├── logging (Logging package)
|
||||
│ ├── mail (Mail package)
|
||||
│ ├── middleware (Middleware package)
|
||||
│ ├── oss (Object storage package)
|
||||
│ ├── promx (Prometheus package)
|
||||
│ └── util (Utility package)
|
||||
├── test (Unit test directory)
|
||||
│ ├── menu_test.go
|
||||
│ ├── role_test.go
|
||||
│ ├── test.go
|
||||
│ └── user_test.go
|
||||
├── Dockerfile
|
||||
├── Makefile
|
||||
├── README.md
|
||||
├── go.mod
|
||||
├── go.sum
|
||||
└── main.go (Entry file)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
Copyright (c) 2023 Lyric
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
105
cmd/start.go
Normal file
105
cmd/start.go
Normal file
@ -0,0 +1,105 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/bootstrap"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// The function defines a CLI command to start a server with various flags and options, including the
|
||||
// ability to run as a daemon.
|
||||
func StartCmd() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "start",
|
||||
Usage: "Start server",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "workdir",
|
||||
Aliases: []string{"d"},
|
||||
Usage: "Working directory",
|
||||
DefaultText: "configs",
|
||||
Value: "configs",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "config",
|
||||
Aliases: []string{"c"},
|
||||
Usage: "Runtime configuration files or directory (relative to workdir, multiple separated by commas)",
|
||||
DefaultText: "dev",
|
||||
Value: "dev",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "static",
|
||||
Aliases: []string{"s"},
|
||||
Usage: "Static files directory",
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Name: "daemon",
|
||||
Usage: "Run as a daemon",
|
||||
},
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
workDir := c.String("workdir")
|
||||
staticDir := c.String("static")
|
||||
configs := c.String("config")
|
||||
|
||||
if c.Bool("daemon") {
|
||||
bin, err := filepath.Abs(os.Args[0])
|
||||
if err != nil {
|
||||
fmt.Printf("failed to get absolute path for command: %s \n", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
args := []string{"start"}
|
||||
args = append(args, "-d", workDir)
|
||||
args = append(args, "-c", configs)
|
||||
args = append(args, "-s", staticDir)
|
||||
fmt.Printf("execute command: %s %s \n", bin, strings.Join(args, " "))
|
||||
command := exec.Command(bin, args...)
|
||||
|
||||
// Redirect stdout and stderr to log file
|
||||
stdLogFile := fmt.Sprintf("%s.log", c.App.Name)
|
||||
file, err := os.OpenFile(stdLogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err != nil {
|
||||
fmt.Printf("failed to open log file: %s \n", err.Error())
|
||||
return err
|
||||
}
|
||||
defer file.Close()
|
||||
|
||||
command.Stdout = file
|
||||
command.Stderr = file
|
||||
|
||||
err = command.Start()
|
||||
if err != nil {
|
||||
fmt.Printf("failed to start daemon thread: %s \n", err.Error())
|
||||
return err
|
||||
}
|
||||
|
||||
// Don't wait for the command to finish
|
||||
// The main process will exit, allowing the daemon to run independently
|
||||
fmt.Printf("Service %s daemon thread started successfully\n", config.C.General.AppName)
|
||||
|
||||
pid := command.Process.Pid
|
||||
_ = os.WriteFile(fmt.Sprintf("%s.lock", c.App.Name), []byte(fmt.Sprintf("%d", pid)), 0666)
|
||||
fmt.Printf("service %s daemon thread started with pid %d \n", config.C.General.AppName, pid)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
err := bootstrap.Run(context.Background(), bootstrap.RunConfig{
|
||||
WorkDir: workDir,
|
||||
Configs: configs,
|
||||
StaticDir: staticDir,
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
40
cmd/stop.go
Normal file
40
cmd/stop.go
Normal file
@ -0,0 +1,40 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// The function defines a CLI command to stop a server by reading a lock file, killing the process with
|
||||
// the corresponding PID, and removing the lock file.
|
||||
func StopCmd() *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "stop",
|
||||
Usage: "stop server",
|
||||
Action: func(c *cli.Context) error {
|
||||
appName := c.App.Name
|
||||
lockFile := fmt.Sprintf("%s.lock", appName)
|
||||
pid, err := os.ReadFile(lockFile)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
command := exec.Command("kill", string(pid))
|
||||
err = command.Start()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = os.Remove(lockFile)
|
||||
if err != nil {
|
||||
return fmt.Errorf("can't remove %s.lock. %s", appName, err.Error())
|
||||
}
|
||||
|
||||
fmt.Printf("service %s stopped \n", appName)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
19
cmd/version.go
Normal file
19
cmd/version.go
Normal file
@ -0,0 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// This function creates a CLI command that prints the version number.
|
||||
func VersionCmd(v string) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "version",
|
||||
Usage: "Show version",
|
||||
Action: func(_ *cli.Context) error {
|
||||
fmt.Println(v)
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
26
configs/dev/logging.toml
Normal file
26
configs/dev/logging.toml
Normal file
@ -0,0 +1,26 @@
|
||||
[Logger]
|
||||
Debug = true
|
||||
Level = "debug" # debug/info/warn/error/dpanic/panic/fatal
|
||||
CallerSkip = 1
|
||||
|
||||
[Logger.File]
|
||||
Enable = false
|
||||
Path = "data/log/jinshan_community.log"
|
||||
MaxBackups = 20 # Files
|
||||
MaxSize = 64 # MB
|
||||
|
||||
[[Logger.Hooks]]
|
||||
Enable = true
|
||||
Level = "info"
|
||||
Type = "gorm" # gorm
|
||||
MaxBuffer = 1024
|
||||
MaxThread = 2
|
||||
|
||||
[Logger.Hooks.Options]
|
||||
Debug = "false"
|
||||
DBType = "mysql" # sqlite3/mysql/postgres
|
||||
DSN = "jinshan:jinshan@tcp(115.239.217.220:3306)/jinshan?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
MaxOpenConns = "16"
|
||||
MaxIdleConns = "4"
|
||||
MaxLifetime = "86400"
|
||||
MaxIdleTime = "7200"
|
||||
76
configs/dev/middleware.toml
Normal file
76
configs/dev/middleware.toml
Normal file
@ -0,0 +1,76 @@
|
||||
[Middleware]
|
||||
|
||||
[Middleware.Recovery]
|
||||
Skip = 3
|
||||
|
||||
[Middleware.CORS]
|
||||
Enable = false
|
||||
AllowOrigins = ["*"]
|
||||
AllowMethods = ["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD", "OPTIONS"]
|
||||
AllowHeaders = ["*"]
|
||||
MaxAge = 86400
|
||||
AllowWildcard = true
|
||||
AllowWebSockets = true
|
||||
AllowFiles = true
|
||||
|
||||
[Middleware.Trace]
|
||||
RequestHeaderKey = "X-Request-Id"
|
||||
ResponseTraceKey = "X-Trace-Id"
|
||||
|
||||
[Middleware.Logger]
|
||||
MaxOutputRequestBodyLen = 4096 # bytes
|
||||
MaxOutputResponseBodyLen = 4096 # bytes
|
||||
|
||||
[Middleware.CopyBody]
|
||||
MaxContentLen = 134217728 # 128MB
|
||||
|
||||
[Middleware.Auth]
|
||||
Disable = true
|
||||
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login"]
|
||||
SigningMethod = "HS512" # HS256/HS384/HS512
|
||||
SigningKey = "XnEsT0S@" # Secret key
|
||||
OldSigningKey = "" # Old secret key (For change secret key)
|
||||
Expired = 86400 # seconds
|
||||
|
||||
[Middleware.Auth.Store]
|
||||
Type = "redis" # memory/badger/redis
|
||||
Delimiter = ":"
|
||||
|
||||
[Middleware.Auth.Store.Memory]
|
||||
CleanupInterval = 60 # seconds
|
||||
|
||||
[Middleware.Auth.Store.Badger]
|
||||
Path = "data/auth"
|
||||
|
||||
[Middleware.Auth.Store.Redis]
|
||||
Addr = "115.239.217.220:6379" # If empty, then use the same configuration as Storage.Cache.Redis
|
||||
Username = ""
|
||||
Password = "123456"
|
||||
DB = 5
|
||||
|
||||
[Middleware.RateLimiter]
|
||||
Enable = false
|
||||
Period = 10 # seconds
|
||||
MaxRequestsPerIP = 1000
|
||||
MaxRequestsPerUser = 500
|
||||
|
||||
[Middleware.RateLimiter.Store]
|
||||
Type = "memory" # memory/redis
|
||||
|
||||
[Middleware.RateLimiter.Store.Memory]
|
||||
Expiration = 3600
|
||||
CleanupInterval = 60
|
||||
|
||||
[Middleware.RateLimiter.Store.Redis]
|
||||
Addr = "115.239.217.220:6379" # If empty, then use the same configuration as Storage.Cache.Redis
|
||||
Username = ""
|
||||
Password = "123456"
|
||||
DB = 4
|
||||
|
||||
[Middleware.Casbin]
|
||||
Disable = true
|
||||
SkippedPathPrefixes = ["/api/v1/captcha/", "/api/v1/login", "/api/v1/current/"]
|
||||
LoadThread = 2
|
||||
AutoLoadInterval = 3 # seconds
|
||||
ModelFile = "rbac_model.conf"
|
||||
GenPolicyFile = "gen_rbac_policy.csv"
|
||||
89
configs/dev/server.toml
Normal file
89
configs/dev/server.toml
Normal file
@ -0,0 +1,89 @@
|
||||
[General]
|
||||
AppName = "jinshan_community"
|
||||
Version = "v10.1.0"
|
||||
Debug = true
|
||||
PprofAddr = "" # Pprof monitor address, "localhost:6060"
|
||||
DisableSwagger = false
|
||||
DisablePrintConfig = false
|
||||
DefaultLoginPwd = "6351623c8cef86fefabfa7da046fc619" # MD5("abc-123")
|
||||
MenuFile = "menu_cn.json" # Or use "menu_cn.json"
|
||||
DenyOperateMenu = false
|
||||
|
||||
[General.HTTP]
|
||||
Addr = ":8071"
|
||||
ShutdownTimeout = 10
|
||||
ReadTimeout = 60
|
||||
WriteTimeout = 60
|
||||
IdleTimeout = 10
|
||||
CertFile = ""
|
||||
KeyFile = ""
|
||||
|
||||
[General.Root] # Super Administrator Account
|
||||
ID = "root"
|
||||
Username = "admin"
|
||||
Password = "6351623c8cef86fefabfa7da046fc619" # MD5("abc-123")
|
||||
Name = "Admin"
|
||||
|
||||
[Storage]
|
||||
|
||||
[Storage.Cache]
|
||||
Type = "redis" # memory/badger/redis
|
||||
Delimiter = ":"
|
||||
|
||||
[Storage.Cache.Memory]
|
||||
CleanupInterval = 60
|
||||
|
||||
[Storage.Cache.Badger]
|
||||
Path = "data/cache"
|
||||
|
||||
[Storage.Cache.Redis]
|
||||
Addr = "115.239.217.220:6379"
|
||||
Username = ""
|
||||
Password = "123456"
|
||||
DB = 6
|
||||
|
||||
[Storage.DB]
|
||||
Debug = true
|
||||
Type = "mysql" # sqlite3/mysql/postgres
|
||||
# SQLite3 DSN
|
||||
#DSN = "data/jinshan_community.db"
|
||||
# MySQL DSN
|
||||
DSN = "jinshan:jinshan@tcp(115.239.217.220:3306)/jinshan?charset=utf8mb4&parseTime=True&loc=Local"
|
||||
# PostgreSQL DSN
|
||||
# DSN = "host=db user=postgres password=123456 dbname=jinshan_community port=5432 sslmode=disable TimeZone=Asia/Shanghai"
|
||||
MaxLifetime = 86400
|
||||
MaxIdleTime = 3600
|
||||
MaxOpenConns = 100
|
||||
MaxIdleConns = 50
|
||||
TablePrefix = ""
|
||||
AutoMigrate = true
|
||||
|
||||
[Util]
|
||||
|
||||
[Util.Captcha]
|
||||
Length = 4
|
||||
Width = 400
|
||||
Height = 160
|
||||
CacheType = "memory" # memory/redis
|
||||
|
||||
[Util.Captcha.Redis]
|
||||
Addr = "115.239.217.220:6379" # If empty, then use the same configuration as Storage.Cache.Redis
|
||||
Username = ""
|
||||
Password = "123456"
|
||||
DB = 1
|
||||
KeyPrefix = "captcha:"
|
||||
|
||||
[Util.Prometheus]
|
||||
Enable = false
|
||||
Port = 9100
|
||||
BasicUsername = "admin"
|
||||
BasicPassword = "admin"
|
||||
LogApis = [] # Log APIs, e.g. ["/api/v1/users"]
|
||||
LogMethods = [] # Log HTTP methods, e.g. ["GET"]
|
||||
DefaultCollect = true
|
||||
|
||||
[Dictionary]
|
||||
UserCacheExp = 4 # hours
|
||||
[FileConfig]
|
||||
UploadDir = "./uploads"
|
||||
StaticPrefix = "/static"
|
||||
240
configs/menu.json
Normal file
240
configs/menu.json
Normal file
@ -0,0 +1,240 @@
|
||||
[
|
||||
{
|
||||
"code": "home",
|
||||
"name": "Home",
|
||||
"sequence": 90,
|
||||
"type": "page",
|
||||
"path": "/home",
|
||||
"status": "enabled"
|
||||
},
|
||||
{
|
||||
"code": "system",
|
||||
"name": "System",
|
||||
"sequence": 10,
|
||||
"type": "page",
|
||||
"path": "/system",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "menu",
|
||||
"name": "Menu",
|
||||
"sequence": 90,
|
||||
"type": "page",
|
||||
"path": "/system/menu",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "Add",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/menus"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "Edit",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "Delete",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "Search",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "role",
|
||||
"name": "Role",
|
||||
"sequence": 80,
|
||||
"type": "page",
|
||||
"path": "/system/role",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "Add",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/roles"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "Edit",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "Delete",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "Search",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "user",
|
||||
"name": "User",
|
||||
"sequence": 70,
|
||||
"type": "page",
|
||||
"path": "/system/user",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "Add",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/users"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "Edit",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "Delete",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "Search",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/users"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "logger",
|
||||
"name": "Logger",
|
||||
"sequence": 10,
|
||||
"type": "page",
|
||||
"path": "/system/logger",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/loggers"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
240
configs/menu_cn.json
Normal file
240
configs/menu_cn.json
Normal file
@ -0,0 +1,240 @@
|
||||
[
|
||||
{
|
||||
"code": "home",
|
||||
"name": "首页",
|
||||
"sequence": 90,
|
||||
"type": "page",
|
||||
"path": "/home",
|
||||
"status": "enabled"
|
||||
},
|
||||
{
|
||||
"code": "system",
|
||||
"name": "系统管理",
|
||||
"sequence": 10,
|
||||
"type": "page",
|
||||
"path": "/system",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "menu",
|
||||
"name": "菜单管理",
|
||||
"sequence": 90,
|
||||
"type": "page",
|
||||
"path": "/system/menu",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "增加",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/menus"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "编辑",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "删除",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "查询",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "role",
|
||||
"name": "角色管理",
|
||||
"sequence": 80,
|
||||
"type": "page",
|
||||
"path": "/system/role",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "增加",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/roles"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "编辑",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "删除",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "查询",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/menus"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "user",
|
||||
"name": "用户管理",
|
||||
"sequence": 70,
|
||||
"type": "page",
|
||||
"path": "/system/user",
|
||||
"status": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"code": "add",
|
||||
"name": "增加",
|
||||
"sequence": 9,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "POST",
|
||||
"path": "/api/v1/users"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "edit",
|
||||
"name": "编辑",
|
||||
"sequence": 8,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "PUT",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "delete",
|
||||
"name": "删除",
|
||||
"sequence": 7,
|
||||
"type": "button",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "DELETE",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "search",
|
||||
"name": "查询",
|
||||
"sequence": 6,
|
||||
"type": "button",
|
||||
"status": "enabled"
|
||||
}
|
||||
],
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/roles"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/users"
|
||||
},
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/users/{id}"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"code": "logger",
|
||||
"name": "日志查询",
|
||||
"sequence": 10,
|
||||
"type": "page",
|
||||
"path": "/system/logger",
|
||||
"status": "enabled",
|
||||
"resources": [
|
||||
{
|
||||
"method": "GET",
|
||||
"path": "/api/v1/loggers"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
14
configs/rbac_model.conf
Normal file
14
configs/rbac_model.conf
Normal file
@ -0,0 +1,14 @@
|
||||
[request_definition]
|
||||
r = sub, obj, act
|
||||
|
||||
[policy_definition]
|
||||
p = sub, obj, act
|
||||
|
||||
[policy_effect]
|
||||
e = some(where (p.eft == allow)) # Passes auth if any of the policies allows
|
||||
|
||||
[role_definition]
|
||||
g = _, _
|
||||
|
||||
[matchers]
|
||||
m = g(r.sub, p.sub) && r.sub == p.sub && (keyMatch2(r.obj, p.obj) || keyMatch3(r.obj, p.obj)) && r.act == p.act
|
||||
144
go.mod
Normal file
144
go.mod
Normal file
@ -0,0 +1,144 @@
|
||||
module gitlab.guxuan.icu/jinshan_community
|
||||
|
||||
go 1.21
|
||||
|
||||
toolchain go1.24.4
|
||||
|
||||
require (
|
||||
github.com/BurntSushi/toml v1.2.1
|
||||
github.com/LyricTian/captcha v1.2.0
|
||||
github.com/aws/aws-sdk-go v1.44.300
|
||||
github.com/casbin/casbin/v2 v2.68.0
|
||||
github.com/creasty/defaults v1.7.0
|
||||
github.com/dgraph-io/badger/v3 v3.2103.5
|
||||
github.com/gavv/httpexpect/v2 v2.15.0
|
||||
github.com/gin-contrib/cors v1.4.0
|
||||
github.com/gin-gonic/gin v1.9.0
|
||||
github.com/go-playground/validator/v10 v10.12.0
|
||||
github.com/go-redis/redis/v8 v8.11.5
|
||||
github.com/go-redis/redis_rate/v9 v9.1.2
|
||||
github.com/go-sql-driver/mysql v1.7.0
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible
|
||||
github.com/google/uuid v1.6.0
|
||||
github.com/google/wire v0.5.0
|
||||
github.com/json-iterator/go v1.1.12
|
||||
github.com/minio/minio-go/v7 v7.0.51
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible
|
||||
github.com/pelletier/go-toml v1.9.5
|
||||
github.com/pkg/errors v0.9.1
|
||||
github.com/prometheus/client_golang v1.14.0
|
||||
github.com/redis/go-redis/v9 v9.0.4
|
||||
github.com/rs/xid v1.4.0
|
||||
github.com/spf13/cast v1.5.1
|
||||
github.com/stretchr/testify v1.8.4
|
||||
github.com/swaggo/files v1.0.1
|
||||
github.com/swaggo/gin-swagger v1.6.0
|
||||
github.com/swaggo/swag v1.16.2
|
||||
github.com/urfave/cli/v2 v2.25.1
|
||||
go.uber.org/zap v1.24.0
|
||||
golang.org/x/crypto v0.25.0
|
||||
golang.org/x/time v0.3.0
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1
|
||||
gopkg.in/yaml.v3 v3.0.1
|
||||
gorm.io/driver/mysql v1.4.7
|
||||
gorm.io/driver/postgres v1.5.0
|
||||
gorm.io/driver/sqlite v1.4.4
|
||||
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11
|
||||
gorm.io/plugin/dbresolver v1.4.1
|
||||
gorm.io/plugin/soft_delete v1.2.1
|
||||
)
|
||||
|
||||
require (
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible // indirect
|
||||
github.com/KyleBanks/depth v1.2.1 // indirect
|
||||
github.com/ajg/form v1.5.1 // indirect
|
||||
github.com/andybalholm/brotli v1.0.4 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bytedance/sonic v1.8.7 // indirect
|
||||
github.com/cespare/xxhash v1.1.0 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.2.0 // indirect
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 // indirect
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dgraph-io/ristretto v0.1.1 // indirect
|
||||
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
|
||||
github.com/dustin/go-humanize v1.0.1 // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/fatih/structs v1.1.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-openapi/jsonpointer v0.19.6 // indirect
|
||||
github.com/go-openapi/jsonreference v0.20.2 // indirect
|
||||
github.com/go-openapi/spec v0.20.8 // indirect
|
||||
github.com/go-openapi/swag v0.22.3 // indirect
|
||||
github.com/go-playground/locales v0.14.1 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.1 // indirect
|
||||
github.com/gobwas/glob v0.2.3 // indirect
|
||||
github.com/goccy/go-json v0.10.2 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/glog v1.1.1 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/protobuf v1.5.3 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/flatbuffers v23.3.3+incompatible // indirect
|
||||
github.com/google/go-querystring v1.1.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/imkira/go-interpol v1.1.0 // indirect
|
||||
github.com/jackc/pgpassfile v1.0.0 // indirect
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a // indirect
|
||||
github.com/jackc/pgx/v5 v5.3.1 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/josharian/intern v1.0.0 // indirect
|
||||
github.com/klauspost/compress v1.16.4 // indirect
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 // indirect
|
||||
github.com/leodido/go-urn v1.2.3 // indirect
|
||||
github.com/mailru/easyjson v0.7.7 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
github.com/mattn/go-isatty v0.0.18 // indirect
|
||||
github.com/mattn/go-sqlite3 v1.14.16 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 // indirect
|
||||
github.com/minio/md5-simd v1.1.2 // indirect
|
||||
github.com/minio/sha256-simd v1.0.0 // indirect
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/openai/openai-go v0.1.0-alpha.62 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.7 // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
github.com/prometheus/client_model v0.3.0 // indirect
|
||||
github.com/prometheus/common v0.42.0 // indirect
|
||||
github.com/prometheus/procfs v0.9.0 // indirect
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sanity-io/litter v1.5.5 // indirect
|
||||
github.com/sergi/go-diff v1.0.0 // indirect
|
||||
github.com/sirupsen/logrus v1.9.0 // indirect
|
||||
github.com/tidwall/gjson v1.14.4 // indirect
|
||||
github.com/tidwall/match v1.1.1 // indirect
|
||||
github.com/tidwall/pretty v1.2.1 // indirect
|
||||
github.com/tidwall/sjson v1.2.5 // indirect
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 // indirect
|
||||
github.com/ugorji/go/codec v1.2.11 // indirect
|
||||
github.com/valyala/bytebufferpool v1.0.0 // indirect
|
||||
github.com/valyala/fasthttp v1.34.0 // indirect
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 // indirect
|
||||
github.com/yudai/gojsondiff v1.0.0 // indirect
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 // indirect
|
||||
go.opencensus.io v0.24.0 // indirect
|
||||
go.uber.org/atomic v1.10.0 // indirect
|
||||
go.uber.org/multierr v1.11.0 // indirect
|
||||
golang.org/x/arch v0.3.0 // indirect
|
||||
golang.org/x/net v0.27.0 // indirect
|
||||
golang.org/x/sys v0.22.0 // indirect
|
||||
golang.org/x/text v0.16.0 // indirect
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d // indirect
|
||||
google.golang.org/protobuf v1.30.0 // indirect
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
|
||||
gopkg.in/ini.v1 v1.67.0 // indirect
|
||||
moul.io/http2curl/v2 v2.3.0 // indirect
|
||||
)
|
||||
626
go.sum
Normal file
626
go.sum
Normal file
@ -0,0 +1,626 @@
|
||||
cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
|
||||
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
|
||||
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
|
||||
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible h1:1G1pk05UrOh0NlF1oeaaix1x8XzrfjIDK47TY0Zehcw=
|
||||
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
|
||||
github.com/KyleBanks/depth v1.2.1 h1:5h8fQADFrWtarTdtDudMmGsC7GPbOAu6RVB3ffsVFHc=
|
||||
github.com/KyleBanks/depth v1.2.1/go.mod h1:jzSb9d0L43HxTQfT+oSA1EEp2q+ne2uh6XgeJcm8brE=
|
||||
github.com/LyricTian/captcha v1.2.0 h1:SXmXj9B1KHBTsVv9rXVVTsKdgNlHrSeb4Memlw+wks4=
|
||||
github.com/LyricTian/captcha v1.2.0/go.mod h1:tpNDvMWf9XBnkfPB2Tyx7lxDWTgfZ9wA4o7Yl50FWs4=
|
||||
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
|
||||
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=
|
||||
github.com/ajg/form v1.5.1 h1:t9c7v8JUKu/XxOGBU0yjNpaMloxGEJhUkqFRq0ibGeU=
|
||||
github.com/ajg/form v1.5.1/go.mod h1:uL1WgH+h2mgNtvBq0339dVnzXdBETtL2LeUXaIv25UY=
|
||||
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
|
||||
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
|
||||
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
|
||||
github.com/aws/aws-sdk-go v1.44.300 h1:Zn+3lqgYahIf9yfrwZ+g+hq/c3KzUBaQ8wqY/ZXiAbY=
|
||||
github.com/aws/aws-sdk-go v1.44.300/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI=
|
||||
github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8=
|
||||
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
|
||||
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
|
||||
github.com/bsm/ginkgo/v2 v2.7.0 h1:ItPMPH90RbmZJt5GtkcNvIRuGEdwlBItdNVoyzaNQao=
|
||||
github.com/bsm/gomega v1.26.0 h1:LhQm+AFcgV2M0WyKroMASzAzCAJVpAxQXv4SaI9a69Y=
|
||||
github.com/bytedance/sonic v1.5.0/go.mod h1:ED5hyg4y6t3/9Ku1R6dU/4KyJ48DZ4jPhfY1O2AihPM=
|
||||
github.com/bytedance/sonic v1.8.7 h1:d3sry5vGgVq/OpgozRUNP6xBsSo0mtNdwliApw+SAMQ=
|
||||
github.com/bytedance/sonic v1.8.7/go.mod h1:i736AoUSYt75HyZLoJW9ERYxcy6eaN6h4BZXU064P/U=
|
||||
github.com/casbin/casbin/v2 v2.68.0 h1:7L4kwNJJw/pzdSEhl4SkeHz+1JzYn8guO+Q422sxzLM=
|
||||
github.com/casbin/casbin/v2 v2.68.0/go.mod h1:vByNa/Fchek0KZUgG5wEsl7iFsiviAYKRtgrQfcJqHg=
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
|
||||
github.com/cespare/xxhash v1.1.0 h1:a6HrQnmkObjyL+Gs60czilIUGqrzKutQD6XZog3p+ko=
|
||||
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
|
||||
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
|
||||
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20211019084208-fb5309c8db06/go.mod h1:DH46F32mSOjUmXrMHnKwZdA8wcEefY7UVqBKYGjpdQY=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311 h1:qSGYFH7+jGhDF8vLC+iwCD4WpbV1EBDSzWkJODFLams=
|
||||
github.com/chenzhuoyu/base64x v0.0.0-20221115062448-fe3a3abad311/go.mod h1:b583jCggY9gE99b6G5LEC39OIiVsWj+R97kbl5odCEk=
|
||||
github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI=
|
||||
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
|
||||
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
|
||||
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
|
||||
github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc=
|
||||
github.com/coreos/etcd v3.3.10+incompatible/go.mod h1:uF7uidLiAD3TWHmW31ZFd/JWoc32PjwdhPthX9715RE=
|
||||
github.com/coreos/go-etcd v2.0.0+incompatible/go.mod h1:Jez6KQU2B/sWsbdaef3ED8NzMklzPG4d5KIOhIy30Tk=
|
||||
github.com/coreos/go-semver v0.2.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk=
|
||||
github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwcJI5acqYI6dE=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
|
||||
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
|
||||
github.com/creasty/defaults v1.7.0 h1:eNdqZvc5B509z18lD8yc212CAqJNvfT1Jq6L8WowdBA=
|
||||
github.com/creasty/defaults v1.7.0/go.mod h1:iGzKe6pbEHnpMPtfDXZEr0NVxWnPTjb1bbDy08fPzYM=
|
||||
github.com/davecgh/go-spew v0.0.0-20161028175848-04cdfd42973b/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/dgraph-io/badger/v3 v3.2103.5 h1:ylPa6qzbjYRQMU6jokoj4wzcaweHylt//CH0AKt0akg=
|
||||
github.com/dgraph-io/badger/v3 v3.2103.5/go.mod h1:4MPiseMeDQ3FNCYwRbbcBOGJLf5jsE0PPFzRiKjtcdw=
|
||||
github.com/dgraph-io/ristretto v0.1.1 h1:6CWw5tJNgpegArSHpNHJKldNeq03FQCwYvfMVWajOK8=
|
||||
github.com/dgraph-io/ristretto v0.1.1/go.mod h1:S1GPSBCYCIhmVNfcth17y2zZtQT6wzkzgwUve0VDWWA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
|
||||
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
|
||||
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.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
|
||||
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/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.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98=
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/fatih/structs v1.1.0 h1:Q7juDM0QtcnhCpeyLGQKyg4TOIghuNXrkL32pHAUMxo=
|
||||
github.com/fatih/structs v1.1.0/go.mod h1:9NiDSp5zOcgEDl+j00MP/WkGVPOlPRLejGD8Ga6PJ7M=
|
||||
github.com/frankban/quicktest v1.14.4 h1:g2rn0vABPOOXmZUj+vbmUp0lPoXEMuhTpIluN0XL9UY=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/fsnotify/fsnotify v1.4.9 h1:hsms1Qyu0jgnwNXIxa+/V/PDsU6CfLf6CNO8H7IWoS4=
|
||||
github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ=
|
||||
github.com/gavv/httpexpect/v2 v2.15.0 h1:CCnFk9of4l4ijUhnMxyoEpJsIIBKcuWIFLMwwGTZxNs=
|
||||
github.com/gavv/httpexpect/v2 v2.15.0/go.mod h1:7myOP3A3VyS4+qnA4cm8DAad8zMN+7zxDB80W9f8yIc=
|
||||
github.com/gin-contrib/cors v1.4.0 h1:oJ6gwtUl3lqV0WEIwM/LxPF1QZ5qe2lGWdY2+bz7y0g=
|
||||
github.com/gin-contrib/cors v1.4.0/go.mod h1:bs9pNM0x/UsmHPBWT2xZz9ROh8xYjYkiURUfmBoMlcs=
|
||||
github.com/gin-contrib/gzip v0.0.6 h1:NjcunTcGAj5CO1gn4N8jHOSIeRFHIbn51z6K+xaN4d4=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
github.com/gin-gonic/gin v1.8.1/go.mod h1:ji8BvRH1azfM+SYow9zQ6SZMvR8qOMZHmsCuWR9tTTk=
|
||||
github.com/gin-gonic/gin v1.9.0 h1:OjyFBKICoexlu99ctXNR2gg+c5pKrKMuyjgARg9qeY8=
|
||||
github.com/gin-gonic/gin v1.9.0/go.mod h1:W1Me9+hsUSyj3CePGrd1/QrKJMSJ1Tu/0hFEH89961k=
|
||||
github.com/go-openapi/jsonpointer v0.19.3/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.5/go.mod h1:Pl9vOtqEWErmShwVjC8pYs9cog34VGT37dQOVbmoatg=
|
||||
github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE=
|
||||
github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs=
|
||||
github.com/go-openapi/jsonreference v0.20.0/go.mod h1:Ag74Ico3lPc+zR+qjn4XBUmXymS4zJbYVCZmcgkasdo=
|
||||
github.com/go-openapi/jsonreference v0.20.2 h1:3sVjiK66+uXK/6oQ8xgcRKcFgQ5KXa2KvnJRumpMGbE=
|
||||
github.com/go-openapi/jsonreference v0.20.2/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k=
|
||||
github.com/go-openapi/spec v0.20.8 h1:ubHmXNY3FCIOinT8RNrrPfGc9t7I1qhPtdOGoG2AxRU=
|
||||
github.com/go-openapi/spec v0.20.8/go.mod h1:2OpW+JddWPrpXSCIX8eOx7lZ5iyuWj3RYR6VaaBKcWA=
|
||||
github.com/go-openapi/swag v0.19.5/go.mod h1:POnQmlKehdgb5mhVOsnJFsivZCEZ/vjK9gh66Z9tfKk=
|
||||
github.com/go-openapi/swag v0.19.15/go.mod h1:QYRuS/SOXUCsnplDa677K7+DxSOj6IPNl/eQntq43wQ=
|
||||
github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g=
|
||||
github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14=
|
||||
github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4=
|
||||
github.com/go-playground/assert/v2 v2.2.0 h1:JvknZsQTYeFEAhQwI4qEt9cyV5ONwRHC+lYKSsYSR8s=
|
||||
github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs=
|
||||
github.com/go-playground/locales v0.14.1 h1:EWaQ/wswjilfKLTECiXz7Rh+3BjFhfDFKv/oXslEjJA=
|
||||
github.com/go-playground/locales v0.14.1/go.mod h1:hxrqLVvrK65+Rwrd5Fc6F2O76J/NuW9t0sjnWqG1slY=
|
||||
github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl+lu/H90nyDXpg0fqeB/AQUGNTVA=
|
||||
github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY=
|
||||
github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY=
|
||||
github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos=
|
||||
github.com/go-playground/validator/v10 v10.12.0 h1:E4gtWgxWxp8YSxExrQFv5BpCahla0PVF2oTTEYaWQGI=
|
||||
github.com/go-playground/validator/v10 v10.12.0/go.mod h1:hCAPuzYvKdP33pxWa+2+6AIKXEKqjIUyqsNCtbsSJrA=
|
||||
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-redis/redis_rate/v9 v9.1.2 h1:H0l5VzoAtOE6ydd38j8MCq3ABlGLnvvbA1xDSVVCHgQ=
|
||||
github.com/go-redis/redis_rate/v9 v9.1.2/go.mod h1:oam2de2apSgRG8aJzwJddXbNu91Iyz1m8IKJE2vpvlQ=
|
||||
github.com/go-sql-driver/mysql v1.6.0/go.mod h1:DCzpHaOWr8IXmIStZouvnhqoel9Qv2LBy8hT2VhHyBg=
|
||||
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-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE=
|
||||
github.com/gobwas/glob v0.2.3 h1:A4xDbljILXROh+kObIiy5kIaPYD8e96x1tgBhUI5J+Y=
|
||||
github.com/gobwas/glob v0.2.3/go.mod h1:d3Ez4x06l9bZtSvzIay5+Yzi0fmZzPgnTbPcKjJAkT8=
|
||||
github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/goccy/go-json v0.10.2 h1:CrxCmQqYDkv1z7lO7Wbh2HN93uovUHgrECaO5ZrCXAU=
|
||||
github.com/goccy/go-json v0.10.2/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I=
|
||||
github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q=
|
||||
github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible h1:IfV12K8xAKAnZqdXVzCZ+TOjboZ2keLg81eXfW3O+oY=
|
||||
github.com/golang-jwt/jwt v3.2.2+incompatible/go.mod h1:8pz2t5EyA70fFQQSrl6XZXzqecmYZeUEB8OUGHkxJ+I=
|
||||
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
|
||||
github.com/golang/glog v1.1.1 h1:jxpi2eWoU84wbX9iIEyAeeoac3FLuifZpY9tcNUD9kw=
|
||||
github.com/golang/glog v1.1.1/go.mod h1:zR+okUeTbrL6EL3xHUDxZuEtGv04p5shwip1+mL/rLQ=
|
||||
github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
|
||||
github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A=
|
||||
github.com/golang/mock v1.4.4 h1:l75CXGRSwbaYNpl/Z2X1XIIAMSCquvXgpVZDhwEIJsc=
|
||||
github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4=
|
||||
github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
|
||||
github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk=
|
||||
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.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI=
|
||||
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
|
||||
github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
|
||||
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
|
||||
github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/golang/snappy v0.0.4 h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=
|
||||
github.com/golang/snappy v0.0.4/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q=
|
||||
github.com/google/flatbuffers v1.12.1/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||
github.com/google/flatbuffers v23.3.3+incompatible h1:5PJI/WbJkaMTvpGxsHVKG/LurN/KnWXNyGpwSCDgen0=
|
||||
github.com/google/flatbuffers v23.3.3+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8=
|
||||
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.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
|
||||
github.com/google/go-cmp v0.5.4/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/go-querystring v1.1.0 h1:AnCroh3fv4ZBgVIf1Iwtovgjaw/GiKJo8M8yD/fhyJ8=
|
||||
github.com/google/go-querystring v1.1.0/go.mod h1:Kcdr2DB4koayq7X8pmAG4sNG59So17icRSOU623lUBU=
|
||||
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
|
||||
github.com/google/pprof v0.0.0-20210407192527-94a9f03dee38/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE=
|
||||
github.com/google/subcommands v1.0.1/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk=
|
||||
github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I=
|
||||
github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/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/google/wire v0.5.0 h1:I7ELFeVBr3yfPIcc8+MWvrjk+3VjbcSzoXm3JVa+jD8=
|
||||
github.com/google/wire v0.5.0/go.mod h1:ngWDr9Qvq3yZA10YrxfyGELY/AFWGVpy9c1LTRi1EoU=
|
||||
github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc=
|
||||
github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
|
||||
github.com/imkira/go-interpol v1.1.0 h1:KIiKr0VSG2CUW1hl1jpiyuzuJeKUUpC8iM1AIE7N1Vk=
|
||||
github.com/imkira/go-interpol v1.1.0/go.mod h1:z0h2/2T3XF8kyEPpRgJ3kmNv+C43p+I/CoI+jC3w2iA=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
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/pgservicefile v0.0.0-20221227161230-091c0ba34f0a h1:bbPeKD0xmW/Y25WS6cokEszi5g+S0QxI/d45PkRi7Nk=
|
||||
github.com/jackc/pgservicefile v0.0.0-20221227161230-091c0ba34f0a/go.mod h1:5TJZWKEWniPve33vlWYSoGYefn3gLQRzjfDlhSJ9ZKM=
|
||||
github.com/jackc/pgx/v5 v5.3.0/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
|
||||
github.com/jackc/pgx/v5 v5.3.1 h1:Fcr8QJ1ZeLi5zsPZqQeUZhNhxfkkKBOgJuYkJHoBOtU=
|
||||
github.com/jackc/pgx/v5 v5.3.1/go.mod h1:t3JDKnCBlYIc0ewLF0Q7B8MXmoIaBOZj/ic7iHozM/8=
|
||||
github.com/jackc/puddle/v2 v2.2.0/go.mod h1:vriiEXHvEE654aYKXXjOvZM39qJ0q+azkZFrfEOc3H4=
|
||||
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.1/go.mod h1:d3SSVoowX0Lcu0IBviAWJpolVfI5UJVZZ7cO71lE/z8=
|
||||
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/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg=
|
||||
github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8=
|
||||
github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U=
|
||||
github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY=
|
||||
github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y=
|
||||
github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM=
|
||||
github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo=
|
||||
github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8=
|
||||
github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck=
|
||||
github.com/klauspost/compress v1.12.3/go.mod h1:8dP1Hq4DHOhN9w426knH3Rhby4rFm6D8eO+e+Dq5Gzg=
|
||||
github.com/klauspost/compress v1.15.0/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
|
||||
github.com/klauspost/compress v1.16.4 h1:91KN02FnsOYhuunwU4ssRe8lc2JosWmizWa91B5v1PU=
|
||||
github.com/klauspost/compress v1.16.4/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE=
|
||||
github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.4/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.4 h1:acbojRNwl3o09bUq+yDCtZFc1aiwaAAxtcn8YkZXnvk=
|
||||
github.com/klauspost/cpuid/v2 v2.2.4/go.mod h1:RVVoqg1df56z8g3pUjL/3lE5UfnlrJX8tyFgg4nqhuY=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI=
|
||||
github.com/kr/pretty v0.3.0/go.mod h1:640gp4NfQd8pI5XOwp5fnNeVWj67G7CFk/SaSQn7NBk=
|
||||
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
|
||||
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/leodido/go-urn v1.2.1/go.mod h1:zt4jvISO2HfUBqxjfIshjdMTYS56ZS/qv49ictyFfxY=
|
||||
github.com/leodido/go-urn v1.2.3 h1:6BE2vPT0lqoz3fmOesHZiaiFh7889ssCo2GMvLCfiuA=
|
||||
github.com/leodido/go-urn v1.2.3/go.mod h1:7ZrI8mTSeBSHl/UaRyKQW1qZeMgak41ANeCNaVckg+4=
|
||||
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
|
||||
github.com/mailru/easyjson v0.0.0-20190614124828-94de47d64c63/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.0.0-20190626092158-b2ccc519800e/go.mod h1:C1wdFJiN94OJF2b5HbByQZoLdCWB1Yqtg26g4irojpc=
|
||||
github.com/mailru/easyjson v0.7.6/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0=
|
||||
github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc=
|
||||
github.com/mattn/go-colorable v0.1.9/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.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
|
||||
github.com/mattn/go-isatty v0.0.18 h1:DOKFKCQ7FNG2L1rbrmstDN4QVRdS89Nkh85u68Uwp98=
|
||||
github.com/mattn/go-isatty v0.0.18/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.3/go.mod h1:WVKg1VTActs4Qso6iwGbiFih2UIHo0ENGwNd0Lj+XmI=
|
||||
github.com/mattn/go-sqlite3 v1.14.15/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/mattn/go-sqlite3 v1.14.16 h1:yOQRA0RpS5PFz/oikGwBEqvAWhWg5ufRz4ETLjwpU1Y=
|
||||
github.com/mattn/go-sqlite3 v1.14.16/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo=
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4=
|
||||
github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34=
|
||||
github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM=
|
||||
github.com/minio/minio-go/v7 v7.0.51 h1:eSewrwc23TqUDEH8aw8Bwp4f+JDdozRrPWcKR7DZhmY=
|
||||
github.com/minio/minio-go/v7 v7.0.51/go.mod h1:IbbodHyjUAguneyucUaahv+VMNs/EOTV9du7A7/Z3HU=
|
||||
github.com/minio/sha256-simd v1.0.0 h1:v1ta+49hkWZyvaKwrQB8elexRqm6Y0aMLjCNsrYxo6g=
|
||||
github.com/minio/sha256-simd v1.0.0/go.mod h1:OuYzVNI5vcoYIAmbIvHPl3N3jUzVedXbKy5RFepssQM=
|
||||
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1 h1:TLuKupo69TCn6TQSyGxwI1EblZZEsQ0vMlAFQflz0v0=
|
||||
github.com/mitchellh/go-wordwrap v1.0.1/go.mod h1:R62XHJLzvMFRBbcrT7m7WgmE1eOyTSsCt+hzestvNj0=
|
||||
github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y=
|
||||
github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg=
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q=
|
||||
github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M=
|
||||
github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk=
|
||||
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
|
||||
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
|
||||
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
|
||||
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
|
||||
github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE=
|
||||
github.com/onsi/ginkgo v1.12.1/go.mod h1:zj2OWP4+oCPe1qIXoGWkgMRwljMUYCdkwsT2108oapk=
|
||||
github.com/onsi/ginkgo v1.16.4/go.mod h1:dX+/inL/fNMqNlz0e9LfyB9TswhZpCVdJM/Z6Vvnwo0=
|
||||
github.com/onsi/ginkgo v1.16.5 h1:8xi0RTUf59SOSfEtZMvwTvXYMzG4gV23XVHOZiXNtnE=
|
||||
github.com/onsi/ginkgo v1.16.5/go.mod h1:+E8gABHa3K6zRBolWtd+ROzc/U5bkGt0FwiG042wbpU=
|
||||
github.com/onsi/ginkgo/v2 v2.0.0/go.mod h1:vw5CSIxN1JObi/U8gcbwft7ZxR2dgaR70JSE3/PpL4c=
|
||||
github.com/onsi/gomega v1.7.1/go.mod h1:XdKZgCCFLUoM/7CFJVPcG8C1xQ1AJ0vpAezJrB7JYyY=
|
||||
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
|
||||
github.com/onsi/gomega v1.17.0/go.mod h1:HnhC7FXeEQY45zxNK3PPoIUhzk/80Xly9PcubAlGdZY=
|
||||
github.com/onsi/gomega v1.18.1 h1:M1GfJqGRrBrrGGsbxzV5dqM2U2ApXefZCQpkukxYRLE=
|
||||
github.com/onsi/gomega v1.18.1/go.mod h1:0q+aL8jAiMXy9hbwj2mr5GziHiwhAIQpFmmtT5hitRs=
|
||||
github.com/openai/openai-go v0.1.0-alpha.62 h1:wf1Z+ZZAlqaUBlxhE5rhXxc9hQylcDRgMU2fg+jME+E=
|
||||
github.com/openai/openai-go v0.1.0-alpha.62/go.mod h1:3SdE6BffOX9HPEQv8IL/fi3LYZ5TUpRYaqGQZbyk11A=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible h1:HRMgzkcYKYpi3C8ajMPV8OFXaaRUnok+kx1WdO15EQc=
|
||||
github.com/patrickmn/go-cache v2.1.0+incompatible/go.mod h1:3Qf8kWWT7OJRJbdiICTKqZju1ZixQ/KpMGzzAfe6+WQ=
|
||||
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
|
||||
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
|
||||
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
|
||||
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
|
||||
github.com/pelletier/go-toml/v2 v2.0.7 h1:muncTPStnKRos5dpVKULv2FVd4bMOhNePj9CjgDb8Us=
|
||||
github.com/pelletier/go-toml/v2 v2.0.7/go.mod h1:eumQOmlWiOPt5WriQQqoM5y18pDHwha2N+QD+EUNTek=
|
||||
github.com/pkg/diff v0.0.0-20200914180035-5b29258ca4f7/go.mod h1:zO8QMzTeZd5cpnIkz/Gn6iK0jDfGicM1nynOkkPIl28=
|
||||
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
|
||||
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 v0.0.0-20151028094244-d8ed2627bdf0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
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_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw=
|
||||
github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y=
|
||||
github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA=
|
||||
github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4=
|
||||
github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w=
|
||||
github.com/prometheus/common v0.42.0 h1:EKsfXEYo4JpWMHH5cg+KOUWeuJSov1Id8zGR8eeI1YM=
|
||||
github.com/prometheus/common v0.42.0/go.mod h1:xBwqVerjNdUDjgODMpudtOMwlOwf2SaTr1yjz4b7Zbc=
|
||||
github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI=
|
||||
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
|
||||
github.com/redis/go-redis/v9 v9.0.4 h1:FC82T+CHJ/Q/PdyLW++GeCO+Ol59Y4T7R4jbgjvktgc=
|
||||
github.com/redis/go-redis/v9 v9.0.4/go.mod h1:WqMKv5vnQbRuZstUwxQI195wHy+t4PuXDOjzMvcuQHk=
|
||||
github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
|
||||
github.com/rogpeppe/go-internal v1.8.0/go.mod h1:WmiCO8CzOY8rg0OYDC4/i/2WRWAB6poM+XZ2dLUbcbE=
|
||||
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
|
||||
github.com/rs/xid v1.4.0 h1:qd7wPTDkN6KQx2VmMBLrpHkiyQwgFXRnkOLacUiaSNY=
|
||||
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
|
||||
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/sanity-io/litter v1.5.5 h1:iE+sBxPBzoK6uaEP5Lt3fHNgpKcHXc/A2HGETy0uJQo=
|
||||
github.com/sanity-io/litter v1.5.5/go.mod h1:9gzJgR2i4ZpjZHsKvUXIRQVk7P+yM3e+jAF7bU2UI5U=
|
||||
github.com/sergi/go-diff v1.0.0 h1:Kpca3qRNrduNnOQeazBd0ysaKrUJiIuISHxogkT9RPQ=
|
||||
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
|
||||
github.com/sirupsen/logrus v1.9.0 h1:trlNQbNUG3OdDrDil03MCb1H2o9nJ1x4/5LYw7byDE0=
|
||||
github.com/sirupsen/logrus v1.9.0/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
|
||||
github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI=
|
||||
github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cast v1.5.1 h1:R+kOtfhWQE6TVQzY+4D7wJLBgkdVasCEFxSUBYBYIlA=
|
||||
github.com/spf13/cast v1.5.1/go.mod h1:b9PdjNptOpzXr7Rq1q9gJML/2cdGQAo69NKzQ10KN48=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
|
||||
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
|
||||
github.com/stretchr/testify v0.0.0-20161117074351-18a02ba4a312/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
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.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
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.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
|
||||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
|
||||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
|
||||
github.com/swaggo/files v1.0.1 h1:J1bVJ4XHZNq0I46UU90611i9/YzdrF7x92oX1ig5IdE=
|
||||
github.com/swaggo/files v1.0.1/go.mod h1:0qXmMNH6sXNf+73t65aKeB+ApmgxdnkQzVTAj2uaMUg=
|
||||
github.com/swaggo/gin-swagger v1.6.0 h1:y8sxvQ3E20/RCyrXeFfg60r6H0Z+SwpTjMYsMm+zy8M=
|
||||
github.com/swaggo/gin-swagger v1.6.0/go.mod h1:BG00cCEy294xtVpyIAHG6+e2Qzj/xKlRdOqDkvq0uzo=
|
||||
github.com/swaggo/swag v1.16.2 h1:28Pp+8DkQoV+HLzLx8RGJZXNGKbFqnuvSbAAtoxiY04=
|
||||
github.com/swaggo/swag v1.16.2/go.mod h1:6YzXnDcpr0767iOejs318CwYkCQqyGer6BizOg03f+E=
|
||||
github.com/tailscale/depaware v0.0.0-20210622194025-720c4b409502/go.mod h1:p9lPsd+cx33L3H9nNoecRRxPssFKUwwI50I3pZ0yT+8=
|
||||
github.com/tidwall/gjson v1.14.2/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/gjson v1.14.4 h1:uo0p8EbA09J7RQaflQ1aBRffTR7xedD2bcIVSYxLnkM=
|
||||
github.com/tidwall/gjson v1.14.4/go.mod h1:/wbyibRr2FHMks5tjHJ5F8dMZh3AcwJEMf5vlfC0lxk=
|
||||
github.com/tidwall/match v1.1.1 h1:+Ho715JplO36QYgwN9PGYNhgZvoUSc9X2c80KVTi+GA=
|
||||
github.com/tidwall/match v1.1.1/go.mod h1:eRSPERbgtNPcGhD8UCthc6PmLEQXEWd3PRB5JTxsfmM=
|
||||
github.com/tidwall/pretty v1.2.0/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/pretty v1.2.1 h1:qjsOFOWWQl+N3RsoF5/ssm1pHmJJwhjlSbZ51I6wMl4=
|
||||
github.com/tidwall/pretty v1.2.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
|
||||
github.com/tidwall/sjson v1.2.5 h1:kLy8mja+1c9jlljvWTlSazM7cKDRfJuR/bOJhcY5NcY=
|
||||
github.com/tidwall/sjson v1.2.5/go.mod h1:Fvgq9kS/6ociJEDnK0Fk1cpYF4FIW6ZF7LAe+6jwd28=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1 h1:SU5vSMR7hnwNxj24w34ZyCi/FmDZTkS4MhqMhdFk5YI=
|
||||
github.com/twitchyliquid64/golang-asm v0.15.1/go.mod h1:a1lVb/DtPvCB8fslRZhAngC2+aY1QWCk3Cedj/Gdt08=
|
||||
github.com/ugorji/go v1.2.7/go.mod h1:nF9osbDWLy6bDVv/Rtoh6QgnvNDpmCalQV5urGCCS6M=
|
||||
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
|
||||
github.com/ugorji/go/codec v1.2.7/go.mod h1:WGN1fab3R1fzQlVQTkfxVtIBhWDRqOviHU95kRgeqEY=
|
||||
github.com/ugorji/go/codec v1.2.11 h1:BMaWp1Bb6fHwEtbplGBGJ498wD+LKlNSl25MjdZY4dU=
|
||||
github.com/ugorji/go/codec v1.2.11/go.mod h1:UNopzCgEMSXjBc6AOMqYvWC1ktqTAfzJZUZgYf6w6lg=
|
||||
github.com/urfave/cli/v2 v2.25.1 h1:zw8dSP7ghX0Gmm8vugrs6q9Ku0wzweqPyshy+syu9Gw=
|
||||
github.com/urfave/cli/v2 v2.25.1/go.mod h1:GHupkWPMM0M/sj1a2b4wUrWBPzazNrIjouW6fmdJLxc=
|
||||
github.com/valyala/bytebufferpool v1.0.0 h1:GqA5TC/0021Y/b9FG4Oi9Mr3q7XYx6KllzawFIhcdPw=
|
||||
github.com/valyala/bytebufferpool v1.0.0/go.mod h1:6bBcMArwyJ5K/AmCkWv1jt77kVWyCJ6HpOuEn7z0Csc=
|
||||
github.com/valyala/fasthttp v1.34.0 h1:d3AAQJ2DRcxJYHm7OXNXtXt2as1vMDfxeIcFvhmGGm4=
|
||||
github.com/valyala/fasthttp v1.34.0/go.mod h1:epZA5N+7pY6ZaEKRmstzOuYJx9HI8DI1oaCGZpdH4h0=
|
||||
github.com/valyala/tcplisten v1.0.0/go.mod h1:T0xQ8SeCZGxckz9qRXTfG43PvQ/mcWh7FwZEA7Ioqkc=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20180127040702-4e3ac2762d5f/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb h1:zGWFAtiMcyryUHoUjUJX0/lt1H2+i2Ka2n+D3DImSNo=
|
||||
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb/go.mod h1:N2zxlSyiKSe5eX1tZViRH5QA0qijqEDrYZiPEAiq3wU=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 h1:EzJWgHovont7NscjpAxXsDA8S8BMYve8Y5+7cuRE7R0=
|
||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415/go.mod h1:GwrjFmJcFw6At/Gs6z4yjiIwzuJ1/+UwLxMQDVQXShQ=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0 h1:LhYJRs+L4fBtjZUfuSZIKGeVu0QRy8e5Xi7D17UxZ74=
|
||||
github.com/xeipuuv/gojsonschema v1.2.0/go.mod h1:anYRn/JVcOK2ZgGU+IjEV4nwlhoK5sQluxsYJ78Id3Y=
|
||||
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU=
|
||||
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0 h1:6fRhSjgLCkTD3JnJxvaJ4Sj+TYblw757bqYgZaOq5ZY=
|
||||
github.com/yalp/jsonpath v0.0.0-20180802001716-5cc68e5049a0/go.mod h1:/LWChgwKmvncFJFHJ7Gvn9wZArjbV5/FppcK2fKk/tI=
|
||||
github.com/yudai/gojsondiff v1.0.0 h1:27cbfqXLVEJ1o8I6v3y9lg8Ydm53EKqHXAOMxEGlCOA=
|
||||
github.com/yudai/gojsondiff v1.0.0/go.mod h1:AY32+k2cwILAkW1fbgxQ5mUmMiZFgLIV+FBNExI05xg=
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82 h1:BHyfKlQyqbsFN5p3IfnEUduWvb9is428/nNb5L3U01M=
|
||||
github.com/yudai/golcs v0.0.0-20170316035057-ecda9a501e82/go.mod h1:lgjkn3NuSvDfVJdfcVVdX+jpBxNmX4rDAzaS45IcYoM=
|
||||
github.com/yudai/pp v2.0.1+incompatible h1:Q4//iY4pNF6yPLZIigmvcl7k/bPgrcTPIFIcmawg5bI=
|
||||
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
|
||||
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
|
||||
go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk=
|
||||
go.opencensus.io v0.24.0 h1:y73uSU6J157QMP2kn2r30vwW1A2W2WFwSCGnAVxeaD0=
|
||||
go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo=
|
||||
go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ=
|
||||
go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
|
||||
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
|
||||
go.uber.org/zap v1.24.0 h1:FiJd5l1UOLj0wCgbSE0rwwXHzEdAZS6hiiSnxJN/D60=
|
||||
go.uber.org/zap v1.24.0/go.mod h1:2kMP+WWQ8aoFoedH3T2sq6iJ2yDWpHbP0f6MQbS9Gkg=
|
||||
golang.org/x/arch v0.0.0-20210923205945-b76863e36670/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/arch v0.3.0 h1:02VY4/ZcO/gBOH6PUaoiptASxtXU10jazRCP865E97k=
|
||||
golang.org/x/arch v0.3.0/go.mod h1:5om86z9Hs0C8fWVUuoMHwpExlXzs5Tkyp9hOrfG7pp8=
|
||||
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
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-20210711020723-a769d52b0f97/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc=
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
|
||||
golang.org/x/crypto v0.6.0/go.mod h1:OFC/31mSvZgRz0V1QTNCzfAI1aIRzbiufJtkMIlEp58=
|
||||
golang.org/x/crypto v0.8.0 h1:pd9TJtTueMTVQXzk8E2XESSMQDj/U7OUu0PqJqPXQjQ=
|
||||
golang.org/x/crypto v0.8.0/go.mod h1:mRqEX+O9/h5TFCrQhkgjo2yKi0yYA+9ecGkdQoHrywE=
|
||||
golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30=
|
||||
golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M=
|
||||
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
|
||||
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/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4=
|
||||
golang.org/x/mod v0.10.0 h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=
|
||||
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
|
||||
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-20180906233101-161cd47e91fd/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-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
|
||||
golang.org/x/net v0.0.0-20200520004742-59133d7f0dd7/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||
golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk=
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
|
||||
golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
|
||||
golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c=
|
||||
golang.org/x/net v0.1.0/go.mod h1:Cx3nUiGt4eDBEyega/BKRp+/AlGL8hYe7U9odMt2Cco=
|
||||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.9.0 h1:aWJ/m6xSmxWBx+V0XRHTlrYrPG56jKsLdTFmsSsCzOM=
|
||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||
golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys=
|
||||
golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE=
|
||||
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-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/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-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/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-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/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-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/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-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210112080510-489259a85091/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220704084225-05e143d24a9e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.0.0-20221010170243-090e33056c14/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.1.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.7.0 h1:3jlCCIQZPdOYu1h8BkNvLz8Kgwtae2cagcG/VamtZRU=
|
||||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI=
|
||||
golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.1.0/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/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.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0 h1:2sjJmO8cDvYveuX97RDLsxlyUxLl+GHoLxBiRdHllBE=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4=
|
||||
golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI=
|
||||
golang.org/x/time v0.3.0 h1:rg5rLMjNzMS1RkNLzCG38eapWhnYLFYXDXj2gOlr8j4=
|
||||
golang.org/x/time v0.3.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ=
|
||||
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-20190422233926-fe54fb35175b/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs=
|
||||
golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE=
|
||||
golang.org/x/tools v0.0.0-20201211185031-d93e913c1a58/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20201224043029-2b0845dc783e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
golang.org/x/tools v0.8.0 h1:vSDcovVPld282ceKgDimkRSC8kpaH1dgyc9UMzlt84Y=
|
||||
golang.org/x/tools v0.8.0/go.mod h1:JxBZ99ISMI5ViVkT1tr6tdNmXeTrcpVSD3vZ1RsRdN4=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg=
|
||||
golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
|
||||
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-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE=
|
||||
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/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c=
|
||||
google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38=
|
||||
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.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc=
|
||||
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.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
|
||||
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/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc h1:2gGKlE2+asNV9m7xrywl36YYNnBG5ZQ0r/BOOxqPpmk=
|
||||
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc/go.mod h1:m7x9LTH6d71AHyAX77c9yqWCCa3UKHcVEj9y7hAtKDk=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
|
||||
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
|
||||
gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI=
|
||||
gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df h1:n7WqCuqOuCbNr617RXOY0AWRXxgwEyPp2z+p0+hgMuE=
|
||||
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df/go.mod h1:LRQQ+SO6ZHR7tOkpBDuZnXENFzX8qRjMDMyPD6BRkCw=
|
||||
gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA=
|
||||
gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc=
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ=
|
||||
gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/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.3/go.mod h1:sSIebwZAVPiT+27jK9HIwvsqOGKx3YMPmrA3mBJR10c=
|
||||
gorm.io/driver/mysql v1.4.7 h1:rY46lkCspzGHn7+IYsNpSfEv9tA+SU4SkkB+GFX125Y=
|
||||
gorm.io/driver/mysql v1.4.7/go.mod h1:SxzItlnT1cb6e1e4ZRpgJN2VYtcqJgqnHxWr4wsP8oc=
|
||||
gorm.io/driver/postgres v1.5.0 h1:u2FXTy14l45qc3UeCJ7QaAXZmZfDDv0YrthvmRq1l0U=
|
||||
gorm.io/driver/postgres v1.5.0/go.mod h1:FUZXzO+5Uqg5zzwzv4KK49R8lvGIyscBOqYrtI1Ce9A=
|
||||
gorm.io/driver/sqlite v1.1.3/go.mod h1:AKDgRWk8lcSQSw+9kxCJnX/yySj8G3rdwYlU57cB45c=
|
||||
gorm.io/driver/sqlite v1.4.4 h1:gIufGoR0dQzjkyqDyYSCvsYR6fba1Gw5YKDqKeChxFc=
|
||||
gorm.io/driver/sqlite v1.4.4/go.mod h1:0Aq3iPO+v9ZKbcdiz8gLWRw5VOPcBOPUQJFLq5e2ecI=
|
||||
gorm.io/gorm v1.20.1/go.mod h1:0HFTzE/SqkGTzK6TlDPPQbAYCluiVvhzoA1+aVyzenw=
|
||||
gorm.io/gorm v1.23.0/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.23.8/go.mod h1:l2lP/RyAtc1ynaTjFksBde/O8v9oOGIApu2/xRitmZk=
|
||||
gorm.io/gorm v1.24.0/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||
gorm.io/gorm v1.24.3/go.mod h1:DVrVomtaYTbqs7gB/x2uVvqnXzv0nqjB396B8cG4dBA=
|
||||
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11 h1:9qNbmu21nNThCNnF5i2R3kw2aL27U8ZwbzccNjOmW0g=
|
||||
gorm.io/gorm v1.24.7-0.20230306060331-85eaf9eeda11/go.mod h1:L4uxeKpfBml98NYqVqwAdmV1a2nBtAec/cf3fpucW/k=
|
||||
gorm.io/plugin/dbresolver v1.4.1 h1:Ug4LcoPhrvqq71UhxtF346f+skTYoCa/nEsdjvHwEzk=
|
||||
gorm.io/plugin/dbresolver v1.4.1/go.mod h1:CTbCtMWhsjXSiJqiW2R8POvJ2cq18RVOl4WGyT5nhNc=
|
||||
gorm.io/plugin/soft_delete v1.2.1 h1:qx9D/c4Xu6w5KT8LviX8DgLcB9hkKl6JC9f44Tj7cGU=
|
||||
gorm.io/plugin/soft_delete v1.2.1/go.mod h1:Zv7vQctOJTGOsJ/bWgrN1n3od0GBAZgnLjEx+cApLGk=
|
||||
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=
|
||||
moul.io/http2curl/v2 v2.3.0 h1:9r3JfDzWPcbIklMOs2TnIFzDYvfAZvjeavG6EzP7jYs=
|
||||
moul.io/http2curl/v2 v2.3.0/go.mod h1:RW4hyBjTWSYDOxapodpNEtX0g5Eb16sxklBqmd2RHcE=
|
||||
rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4=
|
||||
106
internal/bootstrap/bootstrap.go
Normal file
106
internal/bootstrap/bootstrap.go
Normal file
@ -0,0 +1,106 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
_ "net/http/pprof" //nolint:gosec
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
_ "gitlab.guxuan.icu/jinshan_community/internal/swagger"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/utility/prom"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/wirex"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/logging"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// RunConfig defines the config for run command.
|
||||
type RunConfig struct {
|
||||
WorkDir string // Working directory
|
||||
Configs string // Directory or files (multiple separated by commas)
|
||||
StaticDir string // Static files directory
|
||||
}
|
||||
|
||||
// The Run function initializes and starts a service with configuration and logging, and handles
|
||||
// cleanup upon exit.
|
||||
func Run(ctx context.Context, runCfg RunConfig) error {
|
||||
defer func() {
|
||||
if err := zap.L().Sync(); err != nil {
|
||||
fmt.Printf("failed to sync zap logger: %s \n", err.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
// Load configuration.
|
||||
workDir := runCfg.WorkDir
|
||||
staticDir := runCfg.StaticDir
|
||||
config.MustLoad(workDir, strings.Split(runCfg.Configs, ",")...)
|
||||
config.C.General.WorkDir = workDir
|
||||
config.C.Middleware.Static.Dir = staticDir
|
||||
config.C.Print()
|
||||
config.C.PreLoad()
|
||||
|
||||
// Initialize logger.
|
||||
cleanLoggerFn, err := logging.InitWithConfig(ctx, &config.C.Logger, initLoggerHook)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ctx = logging.NewTag(ctx, logging.TagKeyMain)
|
||||
|
||||
logging.Context(ctx).Info("starting service ...",
|
||||
zap.String("version", config.C.General.Version),
|
||||
zap.Int("pid", os.Getpid()),
|
||||
zap.String("workdir", workDir),
|
||||
zap.String("config", runCfg.Configs),
|
||||
zap.String("static", staticDir),
|
||||
)
|
||||
|
||||
// Start pprof server.
|
||||
if addr := config.C.General.PprofAddr; addr != "" {
|
||||
logging.Context(ctx).Info("pprof server is listening on " + addr)
|
||||
go func() {
|
||||
err := http.ListenAndServe(addr, nil)
|
||||
if err != nil {
|
||||
logging.Context(ctx).Error("failed to listen pprof server", zap.Error(err))
|
||||
}
|
||||
}()
|
||||
}
|
||||
|
||||
// Build injector.
|
||||
injector, cleanInjectorFn, err := wirex.BuildInjector(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err := injector.M.Init(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Initialize global prometheus metrics.
|
||||
prom.Init()
|
||||
|
||||
return util.Run(ctx, func(ctx context.Context) (func(), error) {
|
||||
cleanHTTPServerFn, err := startHTTPServer(ctx, injector)
|
||||
if err != nil {
|
||||
return cleanInjectorFn, err
|
||||
}
|
||||
|
||||
return func() {
|
||||
if err := injector.M.Release(ctx); err != nil {
|
||||
logging.Context(ctx).Error("failed to release injector", zap.Error(err))
|
||||
}
|
||||
|
||||
if cleanHTTPServerFn != nil {
|
||||
cleanHTTPServerFn()
|
||||
}
|
||||
if cleanInjectorFn != nil {
|
||||
cleanInjectorFn()
|
||||
}
|
||||
if cleanLoggerFn != nil {
|
||||
cleanLoggerFn()
|
||||
}
|
||||
}, nil
|
||||
})
|
||||
}
|
||||
192
internal/bootstrap/http.go
Normal file
192
internal/bootstrap/http.go
Normal file
@ -0,0 +1,192 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"path/filepath"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/utility/prom"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/wirex"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/logging"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/middleware"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"github.com/casbin/casbin/v2"
|
||||
"github.com/gin-gonic/gin"
|
||||
swaggerFiles "github.com/swaggo/files"
|
||||
ginSwagger "github.com/swaggo/gin-swagger"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
func startHTTPServer(ctx context.Context, injector *wirex.Injector) (func(), error) {
|
||||
if config.C.IsDebug() {
|
||||
gin.SetMode(gin.DebugMode)
|
||||
} else {
|
||||
gin.SetMode(gin.ReleaseMode)
|
||||
}
|
||||
|
||||
e := gin.New()
|
||||
e.GET("/health", func(c *gin.Context) {
|
||||
util.ResOK(c)
|
||||
})
|
||||
e.Use(middleware.RecoveryWithConfig(middleware.RecoveryConfig{
|
||||
Skip: config.C.Middleware.Recovery.Skip,
|
||||
}))
|
||||
e.NoMethod(func(c *gin.Context) {
|
||||
util.ResError(c, errors.MethodNotAllowed("", "Method Not Allowed"))
|
||||
})
|
||||
e.NoRoute(func(c *gin.Context) {
|
||||
util.ResError(c, errors.NotFound("", "Not Found"))
|
||||
})
|
||||
|
||||
allowedPrefixes := injector.M.RouterPrefixes()
|
||||
|
||||
// Register middlewares
|
||||
if err := useHTTPMiddlewares(ctx, e, injector, allowedPrefixes); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Register routers
|
||||
if err := injector.M.RegisterRouters(ctx, e); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Register swagger
|
||||
if !config.C.General.DisableSwagger {
|
||||
e.StaticFile("/openapi.json", filepath.Join(config.C.General.WorkDir, "openapi.json"))
|
||||
e.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
|
||||
}
|
||||
|
||||
if dir := config.C.Middleware.Static.Dir; dir != "" {
|
||||
e.Use(middleware.StaticWithConfig(middleware.StaticConfig{
|
||||
Root: dir,
|
||||
SkippedPathPrefixes: allowedPrefixes,
|
||||
}))
|
||||
}
|
||||
|
||||
addr := config.C.General.HTTP.Addr
|
||||
logging.Context(ctx).Info(fmt.Sprintf("HTTP server is listening on %s", addr))
|
||||
srv := &http.Server{
|
||||
Addr: addr,
|
||||
Handler: e,
|
||||
ReadTimeout: time.Second * time.Duration(config.C.General.HTTP.ReadTimeout),
|
||||
WriteTimeout: time.Second * time.Duration(config.C.General.HTTP.WriteTimeout),
|
||||
IdleTimeout: time.Second * time.Duration(config.C.General.HTTP.IdleTimeout),
|
||||
}
|
||||
|
||||
go func() {
|
||||
var err error
|
||||
if config.C.General.HTTP.CertFile != "" && config.C.General.HTTP.KeyFile != "" {
|
||||
srv.TLSConfig = &tls.Config{MinVersion: tls.VersionTLS12}
|
||||
err = srv.ListenAndServeTLS(config.C.General.HTTP.CertFile, config.C.General.HTTP.KeyFile)
|
||||
} else {
|
||||
err = srv.ListenAndServe()
|
||||
}
|
||||
|
||||
if err != nil && err != http.ErrServerClosed {
|
||||
logging.Context(ctx).Error("Failed to listen http server", zap.Error(err))
|
||||
}
|
||||
}()
|
||||
|
||||
return func() {
|
||||
ctx, cancel := context.WithTimeout(ctx, time.Second*time.Duration(config.C.General.HTTP.ShutdownTimeout))
|
||||
defer cancel()
|
||||
|
||||
srv.SetKeepAlivesEnabled(false)
|
||||
if err := srv.Shutdown(ctx); err != nil {
|
||||
logging.Context(ctx).Error("Failed to shutdown http server", zap.Error(err))
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
func useHTTPMiddlewares(_ context.Context, e *gin.Engine, injector *wirex.Injector, allowedPrefixes []string) error {
|
||||
e.Use(middleware.CORSWithConfig(middleware.CORSConfig{
|
||||
Enable: config.C.Middleware.CORS.Enable,
|
||||
AllowAllOrigins: config.C.Middleware.CORS.AllowAllOrigins,
|
||||
AllowOrigins: config.C.Middleware.CORS.AllowOrigins,
|
||||
AllowMethods: config.C.Middleware.CORS.AllowMethods,
|
||||
AllowHeaders: config.C.Middleware.CORS.AllowHeaders,
|
||||
AllowCredentials: config.C.Middleware.CORS.AllowCredentials,
|
||||
ExposeHeaders: config.C.Middleware.CORS.ExposeHeaders,
|
||||
MaxAge: config.C.Middleware.CORS.MaxAge,
|
||||
AllowWildcard: config.C.Middleware.CORS.AllowWildcard,
|
||||
AllowBrowserExtensions: config.C.Middleware.CORS.AllowBrowserExtensions,
|
||||
AllowWebSockets: config.C.Middleware.CORS.AllowWebSockets,
|
||||
AllowFiles: config.C.Middleware.CORS.AllowFiles,
|
||||
}))
|
||||
|
||||
e.Use(middleware.TraceWithConfig(middleware.TraceConfig{
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.Trace.SkippedPathPrefixes,
|
||||
RequestHeaderKey: config.C.Middleware.Trace.RequestHeaderKey,
|
||||
ResponseTraceKey: config.C.Middleware.Trace.ResponseTraceKey,
|
||||
}))
|
||||
|
||||
e.Use(middleware.LoggerWithConfig(middleware.LoggerConfig{
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.Logger.SkippedPathPrefixes,
|
||||
MaxOutputRequestBodyLen: config.C.Middleware.Logger.MaxOutputRequestBodyLen,
|
||||
MaxOutputResponseBodyLen: config.C.Middleware.Logger.MaxOutputResponseBodyLen,
|
||||
}))
|
||||
|
||||
e.Use(middleware.CopyBodyWithConfig(middleware.CopyBodyConfig{
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.CopyBody.SkippedPathPrefixes,
|
||||
MaxContentLen: config.C.Middleware.CopyBody.MaxContentLen,
|
||||
}))
|
||||
|
||||
e.Use(middleware.AuthWithConfig(middleware.AuthConfig{
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.Auth.SkippedPathPrefixes,
|
||||
ParseUserID: injector.M.RBAC.LoginAPI.LoginBIZ.ParseUserID,
|
||||
RootID: config.C.General.Root.ID,
|
||||
}))
|
||||
|
||||
e.Use(middleware.RateLimiterWithConfig(middleware.RateLimiterConfig{
|
||||
Enable: config.C.Middleware.RateLimiter.Enable,
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.RateLimiter.SkippedPathPrefixes,
|
||||
Period: config.C.Middleware.RateLimiter.Period,
|
||||
MaxRequestsPerIP: config.C.Middleware.RateLimiter.MaxRequestsPerIP,
|
||||
MaxRequestsPerUser: config.C.Middleware.RateLimiter.MaxRequestsPerUser,
|
||||
StoreType: config.C.Middleware.RateLimiter.Store.Type,
|
||||
MemoryStoreConfig: middleware.RateLimiterMemoryConfig{
|
||||
Expiration: time.Second * time.Duration(config.C.Middleware.RateLimiter.Store.Memory.Expiration),
|
||||
CleanupInterval: time.Second * time.Duration(config.C.Middleware.RateLimiter.Store.Memory.CleanupInterval),
|
||||
},
|
||||
RedisStoreConfig: middleware.RateLimiterRedisConfig{
|
||||
Addr: config.C.Middleware.RateLimiter.Store.Redis.Addr,
|
||||
Password: config.C.Middleware.RateLimiter.Store.Redis.Password,
|
||||
DB: config.C.Middleware.RateLimiter.Store.Redis.DB,
|
||||
Username: config.C.Middleware.RateLimiter.Store.Redis.Username,
|
||||
},
|
||||
}))
|
||||
|
||||
e.Use(middleware.CasbinWithConfig(middleware.CasbinConfig{
|
||||
AllowedPathPrefixes: allowedPrefixes,
|
||||
SkippedPathPrefixes: config.C.Middleware.Casbin.SkippedPathPrefixes,
|
||||
Skipper: func(c *gin.Context) bool {
|
||||
if config.C.Middleware.Casbin.Disable ||
|
||||
util.FromIsRootUser(c.Request.Context()) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
},
|
||||
GetEnforcer: func(c *gin.Context) *casbin.Enforcer {
|
||||
return injector.M.RBAC.Casbinx.GetEnforcer()
|
||||
},
|
||||
GetSubjects: func(c *gin.Context) []string {
|
||||
return util.FromUserCache(c.Request.Context()).RoleIDs
|
||||
},
|
||||
}))
|
||||
|
||||
if config.C.Util.Prometheus.Enable {
|
||||
e.Use(prom.GinMiddleware)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
43
internal/bootstrap/logger.go
Normal file
43
internal/bootstrap/logger.go
Normal file
@ -0,0 +1,43 @@
|
||||
package bootstrap
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/gormx"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/logging"
|
||||
"github.com/spf13/cast"
|
||||
)
|
||||
|
||||
func initLoggerHook(_ context.Context, cfg *logging.HookConfig) (*logging.Hook, error) {
|
||||
extra := cfg.Extra
|
||||
if extra == nil {
|
||||
extra = make(map[string]string)
|
||||
}
|
||||
extra["appname"] = config.C.General.AppName
|
||||
|
||||
switch cfg.Type {
|
||||
case "gorm":
|
||||
db, err := gormx.New(gormx.Config{
|
||||
Debug: cast.ToBool(cfg.Options["Debug"]),
|
||||
DBType: cast.ToString(cfg.Options["DBType"]),
|
||||
DSN: cast.ToString(cfg.Options["DSN"]),
|
||||
MaxLifetime: cast.ToInt(cfg.Options["MaxLifetime"]),
|
||||
MaxIdleTime: cast.ToInt(cfg.Options["MaxIdleTime"]),
|
||||
MaxOpenConns: cast.ToInt(cfg.Options["MaxOpenConns"]),
|
||||
MaxIdleConns: cast.ToInt(cfg.Options["MaxIdleConns"]),
|
||||
TablePrefix: config.C.Storage.DB.TablePrefix,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
hook := logging.NewHook(logging.NewGormHook(db),
|
||||
logging.SetHookExtra(cfg.Extra),
|
||||
logging.SetHookMaxJobs(cfg.MaxBuffer),
|
||||
logging.SetHookMaxWorkers(cfg.MaxThread))
|
||||
return hook, nil
|
||||
default:
|
||||
return nil, nil
|
||||
}
|
||||
}
|
||||
166
internal/config/config.go
Normal file
166
internal/config/config.go
Normal file
@ -0,0 +1,166 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/encoding/json"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/logging"
|
||||
)
|
||||
|
||||
type Config struct {
|
||||
Logger logging.LoggerConfig
|
||||
General General
|
||||
Storage Storage
|
||||
Middleware Middleware
|
||||
Util Util
|
||||
Dictionary Dictionary
|
||||
FileConfig FileConfig
|
||||
}
|
||||
type FileConfig struct {
|
||||
UploadDir string
|
||||
StaticPrefix string
|
||||
}
|
||||
|
||||
type General struct {
|
||||
AppName string `default:"haibei"`
|
||||
Version string `default:"v1.0.0"`
|
||||
Debug bool
|
||||
PprofAddr string
|
||||
DisableSwagger bool
|
||||
DisablePrintConfig bool
|
||||
DefaultLoginPwd string `default:"6351623c8cef86fefabfa7da046fc619"` // MD5(abc-123)
|
||||
WorkDir string // From command arguments
|
||||
MenuFile string // From schema.Menus (JSON/YAML)
|
||||
DenyOperateMenu bool
|
||||
HTTP struct {
|
||||
Addr string `default:":8040"`
|
||||
ShutdownTimeout int `default:"10"` // seconds
|
||||
ReadTimeout int `default:"60"` // seconds
|
||||
WriteTimeout int `default:"60"` // seconds
|
||||
IdleTimeout int `default:"10"` // seconds
|
||||
CertFile string
|
||||
KeyFile string
|
||||
}
|
||||
Root struct {
|
||||
ID string `default:"root"`
|
||||
Username string `default:"admin"`
|
||||
Password string
|
||||
Name string `default:"Admin"`
|
||||
}
|
||||
}
|
||||
|
||||
type Storage struct {
|
||||
Cache struct {
|
||||
Type string `default:"memory"` // memory/badger/redis
|
||||
Delimiter string `default:":"` // delimiter for key
|
||||
Memory struct {
|
||||
CleanupInterval int `default:"60"` // seconds
|
||||
}
|
||||
Badger struct {
|
||||
Path string `default:"data/cache"`
|
||||
}
|
||||
Redis struct {
|
||||
Addr string
|
||||
Username string
|
||||
Password string
|
||||
DB int
|
||||
}
|
||||
}
|
||||
DB struct {
|
||||
Debug bool
|
||||
Type string `default:"sqlite3"` // sqlite3/mysql/postgres
|
||||
DSN string `default:"data/haibei.db"` // database source name
|
||||
MaxLifetime int `default:"86400"` // seconds
|
||||
MaxIdleTime int `default:"3600"` // seconds
|
||||
MaxOpenConns int `default:"100"` // connections
|
||||
MaxIdleConns int `default:"50"` // connections
|
||||
TablePrefix string `default:""`
|
||||
AutoMigrate bool
|
||||
PrepareStmt bool
|
||||
Resolver []struct {
|
||||
DBType string // sqlite3/mysql/postgres
|
||||
Sources []string // DSN
|
||||
Replicas []string // DSN
|
||||
Tables []string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type Util struct {
|
||||
Captcha struct {
|
||||
Length int `default:"4"`
|
||||
Width int `default:"400"`
|
||||
Height int `default:"160"`
|
||||
CacheType string `default:"memory"` // memory/redis
|
||||
Redis struct {
|
||||
Addr string
|
||||
Username string
|
||||
Password string
|
||||
DB int
|
||||
KeyPrefix string `default:"captcha:"`
|
||||
}
|
||||
}
|
||||
Prometheus struct {
|
||||
Enable bool
|
||||
Port int `default:"9100"`
|
||||
BasicUsername string `default:"admin"`
|
||||
BasicPassword string `default:"admin"`
|
||||
LogApis []string
|
||||
LogMethods []string
|
||||
DefaultCollect bool
|
||||
}
|
||||
}
|
||||
|
||||
type Dictionary struct {
|
||||
UserCacheExp int `default:"4"` // hours
|
||||
}
|
||||
|
||||
func (c *Config) IsDebug() bool {
|
||||
return c.General.Debug
|
||||
}
|
||||
|
||||
func (c *Config) String() string {
|
||||
b, err := json.MarshalIndent(c, "", " ")
|
||||
if err != nil {
|
||||
panic("Failed to marshal config: " + err.Error())
|
||||
}
|
||||
return string(b)
|
||||
}
|
||||
|
||||
func (c *Config) PreLoad() {
|
||||
if addr := c.Storage.Cache.Redis.Addr; addr != "" {
|
||||
username := c.Storage.Cache.Redis.Username
|
||||
password := c.Storage.Cache.Redis.Password
|
||||
if c.Util.Captcha.CacheType == "redis" &&
|
||||
c.Util.Captcha.Redis.Addr == "" {
|
||||
c.Util.Captcha.Redis.Addr = addr
|
||||
c.Util.Captcha.Redis.Username = username
|
||||
c.Util.Captcha.Redis.Password = password
|
||||
}
|
||||
if c.Middleware.RateLimiter.Store.Type == "redis" &&
|
||||
c.Middleware.RateLimiter.Store.Redis.Addr == "" {
|
||||
c.Middleware.RateLimiter.Store.Redis.Addr = addr
|
||||
c.Middleware.RateLimiter.Store.Redis.Username = username
|
||||
c.Middleware.RateLimiter.Store.Redis.Password = password
|
||||
}
|
||||
if c.Middleware.Auth.Store.Type == "redis" &&
|
||||
c.Middleware.Auth.Store.Redis.Addr == "" {
|
||||
c.Middleware.Auth.Store.Redis.Addr = addr
|
||||
c.Middleware.Auth.Store.Redis.Username = username
|
||||
c.Middleware.Auth.Store.Redis.Password = password
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (c *Config) Print() {
|
||||
if c.General.DisablePrintConfig {
|
||||
return
|
||||
}
|
||||
fmt.Println("// ----------------------- Load configurations start ------------------------")
|
||||
fmt.Println(c.String())
|
||||
fmt.Println("// ----------------------- Load configurations end --------------------------")
|
||||
}
|
||||
|
||||
func (c *Config) FormatTableName(name string) string {
|
||||
return c.Storage.DB.TablePrefix + name
|
||||
}
|
||||
17
internal/config/consts.go
Normal file
17
internal/config/consts.go
Normal file
@ -0,0 +1,17 @@
|
||||
package config
|
||||
|
||||
const (
|
||||
CacheNSForUser = "user"
|
||||
CacheNSForApp = "app"
|
||||
CacheNSForRole = "role"
|
||||
)
|
||||
|
||||
const (
|
||||
CacheKeyForSyncToCasbin = "sync:casbin"
|
||||
)
|
||||
|
||||
const (
|
||||
ErrInvalidTokenID = "com.invalid.token"
|
||||
ErrInvalidCaptchaID = "com.invalid.captcha"
|
||||
ErrInvalidUsernameOrPassword = "com.invalid.username-or-password"
|
||||
)
|
||||
90
internal/config/middleware.go
Normal file
90
internal/config/middleware.go
Normal file
@ -0,0 +1,90 @@
|
||||
package config
|
||||
|
||||
type Middleware struct {
|
||||
Recovery struct {
|
||||
Skip int `default:"3"` // skip the first n stack frames
|
||||
}
|
||||
CORS struct {
|
||||
Enable bool
|
||||
AllowAllOrigins bool
|
||||
AllowOrigins []string
|
||||
AllowMethods []string
|
||||
AllowHeaders []string
|
||||
AllowCredentials bool
|
||||
ExposeHeaders []string
|
||||
MaxAge int
|
||||
AllowWildcard bool
|
||||
AllowBrowserExtensions bool
|
||||
AllowWebSockets bool
|
||||
AllowFiles bool
|
||||
}
|
||||
Trace struct {
|
||||
SkippedPathPrefixes []string
|
||||
RequestHeaderKey string `default:"X-Request-Id"`
|
||||
ResponseTraceKey string `default:"X-Trace-Id"`
|
||||
}
|
||||
Logger struct {
|
||||
SkippedPathPrefixes []string
|
||||
MaxOutputRequestBodyLen int `default:"4096"`
|
||||
MaxOutputResponseBodyLen int `default:"1024"`
|
||||
}
|
||||
CopyBody struct {
|
||||
SkippedPathPrefixes []string
|
||||
MaxContentLen int64 `default:"33554432"` // max content length (default 32MB)
|
||||
}
|
||||
Auth struct {
|
||||
Disable bool
|
||||
SkippedPathPrefixes []string
|
||||
SigningMethod string `default:"HS512"` // HS256/HS384/HS512
|
||||
SigningKey string `default:"XnEsT0S@"` // secret key
|
||||
OldSigningKey string // old secret key (for migration)
|
||||
Expired int `default:"86400"` // seconds
|
||||
Store struct {
|
||||
Type string `default:"memory"` // memory/badger/redis
|
||||
Delimiter string `default:":"` // delimiter for key
|
||||
Memory struct {
|
||||
CleanupInterval int `default:"60"` // seconds
|
||||
}
|
||||
Badger struct {
|
||||
Path string `default:"data/auth"`
|
||||
}
|
||||
Redis struct {
|
||||
Addr string
|
||||
Username string
|
||||
Password string
|
||||
DB int
|
||||
}
|
||||
}
|
||||
}
|
||||
RateLimiter struct {
|
||||
Enable bool
|
||||
SkippedPathPrefixes []string
|
||||
Period int // seconds
|
||||
MaxRequestsPerIP int
|
||||
MaxRequestsPerUser int
|
||||
Store struct {
|
||||
Type string // memory/redis
|
||||
Memory struct {
|
||||
Expiration int `default:"3600"` // seconds
|
||||
CleanupInterval int `default:"60"` // seconds
|
||||
}
|
||||
Redis struct {
|
||||
Addr string
|
||||
Username string
|
||||
Password string
|
||||
DB int
|
||||
}
|
||||
}
|
||||
}
|
||||
Casbin struct {
|
||||
Disable bool
|
||||
SkippedPathPrefixes []string
|
||||
LoadThread int `default:"2"`
|
||||
AutoLoadInterval int `default:"3"` // seconds
|
||||
ModelFile string `default:"rbac_model.conf"`
|
||||
GenPolicyFile string `default:"gen_rbac_policy.csv"`
|
||||
}
|
||||
Static struct {
|
||||
Dir string // Static files directory (From command arguments)
|
||||
}
|
||||
}
|
||||
84
internal/config/parse.go
Normal file
84
internal/config/parse.go
Normal file
@ -0,0 +1,84 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/encoding/json"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/encoding/toml"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"github.com/creasty/defaults"
|
||||
)
|
||||
|
||||
var (
|
||||
once sync.Once
|
||||
C = new(Config)
|
||||
)
|
||||
|
||||
func MustLoad(dir string, names ...string) {
|
||||
once.Do(func() {
|
||||
if err := Load(dir, names...); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// Loads configuration files in various formats from a directory and parses them into
|
||||
// a struct.
|
||||
func Load(dir string, names ...string) error {
|
||||
// Set default values
|
||||
if err := defaults.Set(C); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
supportExts := []string{".json", ".toml"}
|
||||
parseFile := func(name string) error {
|
||||
ext := filepath.Ext(name)
|
||||
if ext == "" || !strings.Contains(strings.Join(supportExts, ","), ext) {
|
||||
return nil
|
||||
}
|
||||
|
||||
buf, err := os.ReadFile(name)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to read config file %s", name)
|
||||
}
|
||||
|
||||
switch ext {
|
||||
case ".json":
|
||||
err = json.Unmarshal(buf, C)
|
||||
case ".toml":
|
||||
err = toml.Unmarshal(buf, C)
|
||||
}
|
||||
return errors.Wrapf(err, "failed to unmarshal config %s", name)
|
||||
}
|
||||
|
||||
for _, name := range names {
|
||||
fullname := filepath.Join(dir, name)
|
||||
info, err := os.Stat(fullname)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to get config file %s", name)
|
||||
}
|
||||
|
||||
if info.IsDir() {
|
||||
err := filepath.WalkDir(fullname, func(path string, d os.DirEntry, err error) error {
|
||||
if err != nil {
|
||||
return err
|
||||
} else if d.IsDir() {
|
||||
return nil
|
||||
}
|
||||
return parseFile(path)
|
||||
})
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "failed to walk config dir %s", name)
|
||||
}
|
||||
continue
|
||||
}
|
||||
if err := parseFile(fullname); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
131
internal/mods/activity/api/activity.api.go
Normal file
131
internal/mods/activity/api/activity.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Activity` api.
|
||||
type Activity struct {
|
||||
ActivityBIZ *biz.Activity
|
||||
}
|
||||
|
||||
// @Tags ActivityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query activity list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Activity}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activities [get]
|
||||
func (a *Activity) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.ActivityQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ActivityBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags ActivityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get activity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Activity}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activities/{id} [get]
|
||||
func (a *Activity) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.ActivityBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags ActivityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create activity record
|
||||
// @Param body body schema.ActivityForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Activity}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activities [post]
|
||||
func (a *Activity) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ActivityForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ActivityBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags ActivityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update activity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.ActivityForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activities/{id} [put]
|
||||
func (a *Activity) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ActivityForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.ActivityBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags ActivityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete activity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activities/{id} [delete]
|
||||
func (a *Activity) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.ActivityBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/activity/api/activity_category.api.go
Normal file
131
internal/mods/activity/api/activity_category.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `ActivityCategory` api.
|
||||
type ActivityCategory struct {
|
||||
ActivityCategoryBIZ *biz.ActivityCategory
|
||||
}
|
||||
|
||||
// @Tags ActivityCategoryAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query activity category list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.ActivityCategory}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activity-categories [get]
|
||||
func (a *ActivityCategory) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.ActivityCategoryQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ActivityCategoryBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags ActivityCategoryAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get activity category record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.ActivityCategory}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activity-categories/{id} [get]
|
||||
func (a *ActivityCategory) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.ActivityCategoryBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags ActivityCategoryAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create activity category record
|
||||
// @Param body body schema.ActivityCategoryForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.ActivityCategory}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activity-categories [post]
|
||||
func (a *ActivityCategory) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ActivityCategoryForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ActivityCategoryBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags ActivityCategoryAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update activity category record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.ActivityCategoryForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activity-categories/{id} [put]
|
||||
func (a *ActivityCategory) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ActivityCategoryForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.ActivityCategoryBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags ActivityCategoryAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete activity category record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/activity-categories/{id} [delete]
|
||||
func (a *ActivityCategory) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.ActivityCategoryBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/activity/api/reciprocity.api.go
Normal file
131
internal/mods/activity/api/reciprocity.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Reciprocity` api.
|
||||
type Reciprocity struct {
|
||||
ReciprocityBIZ *biz.Reciprocity
|
||||
}
|
||||
|
||||
// @Tags ReciprocityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query reciprocity list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Reciprocity}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/reciprocities [get]
|
||||
func (a *Reciprocity) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.ReciprocityQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ReciprocityBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags ReciprocityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get reciprocity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Reciprocity}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/reciprocities/{id} [get]
|
||||
func (a *Reciprocity) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.ReciprocityBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags ReciprocityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create reciprocity record
|
||||
// @Param body body schema.ReciprocityForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Reciprocity}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/reciprocities [post]
|
||||
func (a *Reciprocity) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ReciprocityForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.ReciprocityBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags ReciprocityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update reciprocity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.ReciprocityForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/reciprocities/{id} [put]
|
||||
func (a *Reciprocity) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.ReciprocityForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.ReciprocityBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags ReciprocityAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete reciprocity record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/reciprocities/{id} [delete]
|
||||
func (a *Reciprocity) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.ReciprocityBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
104
internal/mods/activity/biz/activity.biz.go
Normal file
104
internal/mods/activity/biz/activity.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Activity` business logic.
|
||||
type Activity struct {
|
||||
Trans *util.Trans
|
||||
ActivityDAL *dal.Activity
|
||||
}
|
||||
|
||||
// Query activities from the data access object based on the provided parameters and options.
|
||||
func (a *Activity) Query(ctx context.Context, params schema.ActivityQueryParam) (*schema.ActivityQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.ActivityDAL.Query(ctx, params, schema.ActivityQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified activity from the data access object.
|
||||
func (a *Activity) Get(ctx context.Context, id string) (*schema.Activity, error) {
|
||||
activity, err := a.ActivityDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if activity == nil {
|
||||
return nil, errors.NotFound("", "Activity not found")
|
||||
}
|
||||
return activity, nil
|
||||
}
|
||||
|
||||
// Create a new activity in the data access object.
|
||||
func (a *Activity) Create(ctx context.Context, formItem *schema.ActivityForm) (*schema.Activity, error) {
|
||||
activity := &schema.Activity{}
|
||||
|
||||
if err := formItem.FillTo(activity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityDAL.Create(ctx, activity); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return activity, nil
|
||||
}
|
||||
|
||||
// Update the specified activity in the data access object.
|
||||
func (a *Activity) Update(ctx context.Context, id string, formItem *schema.ActivityForm) error {
|
||||
activity, err := a.ActivityDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if activity == nil {
|
||||
return errors.NotFound("", "Activity not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(activity); err != nil {
|
||||
return err
|
||||
}
|
||||
activity.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityDAL.Update(ctx, activity); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified activity from the data access object.
|
||||
func (a *Activity) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.ActivityDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Activity not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/activity/biz/activity_category.biz.go
Normal file
104
internal/mods/activity/biz/activity_category.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `ActivityCategory` business logic.
|
||||
type ActivityCategory struct {
|
||||
Trans *util.Trans
|
||||
ActivityCategoryDAL *dal.ActivityCategory
|
||||
}
|
||||
|
||||
// Query activity categories from the data access object based on the provided parameters and options.
|
||||
func (a *ActivityCategory) Query(ctx context.Context, params schema.ActivityCategoryQueryParam) (*schema.ActivityCategoryQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.ActivityCategoryDAL.Query(ctx, params, schema.ActivityCategoryQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified activity category from the data access object.
|
||||
func (a *ActivityCategory) Get(ctx context.Context, id string) (*schema.ActivityCategory, error) {
|
||||
activityCategory, err := a.ActivityCategoryDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if activityCategory == nil {
|
||||
return nil, errors.NotFound("", "Activity category not found")
|
||||
}
|
||||
return activityCategory, nil
|
||||
}
|
||||
|
||||
// Create a new activity category in the data access object.
|
||||
func (a *ActivityCategory) Create(ctx context.Context, formItem *schema.ActivityCategoryForm) (*schema.ActivityCategory, error) {
|
||||
activityCategory := &schema.ActivityCategory{}
|
||||
|
||||
if err := formItem.FillTo(activityCategory); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityCategoryDAL.Create(ctx, activityCategory); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return activityCategory, nil
|
||||
}
|
||||
|
||||
// Update the specified activity category in the data access object.
|
||||
func (a *ActivityCategory) Update(ctx context.Context, id string, formItem *schema.ActivityCategoryForm) error {
|
||||
activityCategory, err := a.ActivityCategoryDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if activityCategory == nil {
|
||||
return errors.NotFound("", "Activity category not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(activityCategory); err != nil {
|
||||
return err
|
||||
}
|
||||
activityCategory.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityCategoryDAL.Update(ctx, activityCategory); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified activity category from the data access object.
|
||||
func (a *ActivityCategory) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.ActivityCategoryDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Activity category not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ActivityCategoryDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/activity/biz/reciprocity.biz.go
Normal file
104
internal/mods/activity/biz/reciprocity.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Reciprocity` business logic.
|
||||
type Reciprocity struct {
|
||||
Trans *util.Trans
|
||||
ReciprocityDAL *dal.Reciprocity
|
||||
}
|
||||
|
||||
// Query reciprocities from the data access object based on the provided parameters and options.
|
||||
func (a *Reciprocity) Query(ctx context.Context, params schema.ReciprocityQueryParam) (*schema.ReciprocityQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.ReciprocityDAL.Query(ctx, params, schema.ReciprocityQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified reciprocity from the data access object.
|
||||
func (a *Reciprocity) Get(ctx context.Context, id string) (*schema.Reciprocity, error) {
|
||||
reciprocity, err := a.ReciprocityDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if reciprocity == nil {
|
||||
return nil, errors.NotFound("", "Reciprocity not found")
|
||||
}
|
||||
return reciprocity, nil
|
||||
}
|
||||
|
||||
// Create a new reciprocity in the data access object.
|
||||
func (a *Reciprocity) Create(ctx context.Context, formItem *schema.ReciprocityForm) (*schema.Reciprocity, error) {
|
||||
reciprocity := &schema.Reciprocity{}
|
||||
|
||||
if err := formItem.FillTo(reciprocity); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ReciprocityDAL.Create(ctx, reciprocity); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return reciprocity, nil
|
||||
}
|
||||
|
||||
// Update the specified reciprocity in the data access object.
|
||||
func (a *Reciprocity) Update(ctx context.Context, id string, formItem *schema.ReciprocityForm) error {
|
||||
reciprocity, err := a.ReciprocityDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if reciprocity == nil {
|
||||
return errors.NotFound("", "Reciprocity not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(reciprocity); err != nil {
|
||||
return err
|
||||
}
|
||||
reciprocity.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ReciprocityDAL.Update(ctx, reciprocity); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified reciprocity from the data access object.
|
||||
func (a *Reciprocity) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.ReciprocityDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Reciprocity not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.ReciprocityDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
83
internal/mods/activity/dal/activity.dal.go
Normal file
83
internal/mods/activity/dal/activity.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get activity storage instance
|
||||
func GetActivityDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.Activity))
|
||||
}
|
||||
|
||||
// Defining the `Activity` data access object.
|
||||
type Activity struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query activities from the database based on the provided parameters and options.
|
||||
func (a *Activity) Query(ctx context.Context, params schema.ActivityQueryParam, opts ...schema.ActivityQueryOptions) (*schema.ActivityQueryResult, error) {
|
||||
var opt schema.ActivityQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetActivityDB(ctx, a.DB)
|
||||
|
||||
var list schema.Activities
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.ActivityQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified activity from the database.
|
||||
func (a *Activity) Get(ctx context.Context, id string, opts ...schema.ActivityQueryOptions) (*schema.Activity, error) {
|
||||
var opt schema.ActivityQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.Activity)
|
||||
ok, err := util.FindOne(ctx, GetActivityDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified activity exists in the database.
|
||||
func (a *Activity) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetActivityDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new activity.
|
||||
func (a *Activity) Create(ctx context.Context, item *schema.Activity) error {
|
||||
result := GetActivityDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified activity in the database.
|
||||
func (a *Activity) Update(ctx context.Context, item *schema.Activity) error {
|
||||
result := GetActivityDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified activity from the database.
|
||||
func (a *Activity) Delete(ctx context.Context, id string) error {
|
||||
result := GetActivityDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.Activity))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/activity/dal/activity_category.dal.go
Normal file
83
internal/mods/activity/dal/activity_category.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get activity category storage instance
|
||||
func GetActivityCategoryDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.ActivityCategory))
|
||||
}
|
||||
|
||||
// Defining the `ActivityCategory` data access object.
|
||||
type ActivityCategory struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query activity categories from the database based on the provided parameters and options.
|
||||
func (a *ActivityCategory) Query(ctx context.Context, params schema.ActivityCategoryQueryParam, opts ...schema.ActivityCategoryQueryOptions) (*schema.ActivityCategoryQueryResult, error) {
|
||||
var opt schema.ActivityCategoryQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetActivityCategoryDB(ctx, a.DB)
|
||||
|
||||
var list schema.ActivityCategories
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.ActivityCategoryQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified activity category from the database.
|
||||
func (a *ActivityCategory) Get(ctx context.Context, id string, opts ...schema.ActivityCategoryQueryOptions) (*schema.ActivityCategory, error) {
|
||||
var opt schema.ActivityCategoryQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.ActivityCategory)
|
||||
ok, err := util.FindOne(ctx, GetActivityCategoryDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified activity category exists in the database.
|
||||
func (a *ActivityCategory) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetActivityCategoryDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new activity category.
|
||||
func (a *ActivityCategory) Create(ctx context.Context, item *schema.ActivityCategory) error {
|
||||
result := GetActivityCategoryDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified activity category in the database.
|
||||
func (a *ActivityCategory) Update(ctx context.Context, item *schema.ActivityCategory) error {
|
||||
result := GetActivityCategoryDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified activity category from the database.
|
||||
func (a *ActivityCategory) Delete(ctx context.Context, id string) error {
|
||||
result := GetActivityCategoryDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.ActivityCategory))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/activity/dal/reciprocity.dal.go
Normal file
83
internal/mods/activity/dal/reciprocity.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get reciprocity storage instance
|
||||
func GetReciprocityDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.Reciprocity))
|
||||
}
|
||||
|
||||
// Defining the `Reciprocity` data access object.
|
||||
type Reciprocity struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query reciprocities from the database based on the provided parameters and options.
|
||||
func (a *Reciprocity) Query(ctx context.Context, params schema.ReciprocityQueryParam, opts ...schema.ReciprocityQueryOptions) (*schema.ReciprocityQueryResult, error) {
|
||||
var opt schema.ReciprocityQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetReciprocityDB(ctx, a.DB)
|
||||
|
||||
var list schema.Reciprocities
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.ReciprocityQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified reciprocity from the database.
|
||||
func (a *Reciprocity) Get(ctx context.Context, id string, opts ...schema.ReciprocityQueryOptions) (*schema.Reciprocity, error) {
|
||||
var opt schema.ReciprocityQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.Reciprocity)
|
||||
ok, err := util.FindOne(ctx, GetReciprocityDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified reciprocity exists in the database.
|
||||
func (a *Reciprocity) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetReciprocityDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new reciprocity.
|
||||
func (a *Reciprocity) Create(ctx context.Context, item *schema.Reciprocity) error {
|
||||
result := GetReciprocityDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified reciprocity in the database.
|
||||
func (a *Reciprocity) Update(ctx context.Context, item *schema.Reciprocity) error {
|
||||
result := GetReciprocityDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified reciprocity from the database.
|
||||
func (a *Reciprocity) Delete(ctx context.Context, id string) error {
|
||||
result := GetReciprocityDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.Reciprocity))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
64
internal/mods/activity/main.go
Normal file
64
internal/mods/activity/main.go
Normal file
@ -0,0 +1,64 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/schema"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Activity struct {
|
||||
DB *gorm.DB
|
||||
ActivityAPI *api.Activity
|
||||
ActivityCategoryAPI *api.ActivityCategory
|
||||
ReciprocityAPI *api.Reciprocity
|
||||
}
|
||||
|
||||
func (a *Activity) AutoMigrate(ctx context.Context) error {
|
||||
return a.DB.AutoMigrate(new(schema.Activity), new(schema.ActivityCategory), new(schema.Reciprocity))
|
||||
}
|
||||
|
||||
func (a *Activity) Init(ctx context.Context) error {
|
||||
if config.C.Storage.DB.AutoMigrate {
|
||||
if err := a.AutoMigrate(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Activity) RegisterV1Routers(ctx context.Context, v1 *gin.RouterGroup) error {
|
||||
activity := v1.Group("activities")
|
||||
{
|
||||
activity.GET("", a.ActivityAPI.Query)
|
||||
activity.GET(":id", a.ActivityAPI.Get)
|
||||
activity.POST("", a.ActivityAPI.Create)
|
||||
activity.PUT(":id", a.ActivityAPI.Update)
|
||||
activity.DELETE(":id", a.ActivityAPI.Delete)
|
||||
}
|
||||
activityCategory := v1.Group("activity-categories")
|
||||
{
|
||||
activityCategory.GET("", a.ActivityCategoryAPI.Query)
|
||||
activityCategory.GET(":id", a.ActivityCategoryAPI.Get)
|
||||
activityCategory.POST("", a.ActivityCategoryAPI.Create)
|
||||
activityCategory.PUT(":id", a.ActivityCategoryAPI.Update)
|
||||
activityCategory.DELETE(":id", a.ActivityCategoryAPI.Delete)
|
||||
}
|
||||
reciprocity := v1.Group("reciprocities")
|
||||
{
|
||||
reciprocity.GET("", a.ReciprocityAPI.Query)
|
||||
reciprocity.GET(":id", a.ReciprocityAPI.Get)
|
||||
reciprocity.POST("", a.ReciprocityAPI.Create)
|
||||
reciprocity.PUT(":id", a.ReciprocityAPI.Update)
|
||||
reciprocity.DELETE(":id", a.ReciprocityAPI.Delete)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Activity) Release(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
92
internal/mods/activity/schema/activity.go
Normal file
92
internal/mods/activity/schema/activity.go
Normal file
@ -0,0 +1,92 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Defining the `Activity` struct.
|
||||
type Activity struct {
|
||||
util.BaseModel
|
||||
CategoryID string `json:"categoryId" gorm:"type:char(36);index;comment:分类id"`
|
||||
Title string `json:"title" gorm:"size:128;not null;index;comment:标题"`
|
||||
Cover string `json:"cover" gorm:"size:2048;not null;comment:封面"`
|
||||
Images *[]string `json:"images" gorm:"serializer:json;comment:详图数组"`
|
||||
StartAt *time.Time `json:"startAt" gorm:"not null;comment:开始时间"`
|
||||
EndAt *time.Time `json:"endAt" gorm:"not null;comment:结束时间"`
|
||||
StartSignupAt *time.Time `json:"startSignupAt" gorm:"not null;comment:报名开始时间"`
|
||||
EndSignupAt *time.Time `json:"endSignupAt" gorm:"not null;comment:报名结束时间"`
|
||||
MaxSignupNum int `json:"maxSignupNum" gorm:"not null;comment:最大报名人数"`
|
||||
SignupNum int `json:"signupNum" gorm:"not null;default:0;comment:当前报名人数"`
|
||||
Address string `json:"address" gorm:"size:1024;not null;comment:活动地址"`
|
||||
Content string `json:"content" gorm:"type:text;not null;comment:活动详情"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *Activity) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Activity` struct.
|
||||
type ActivityQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `Activity` struct.
|
||||
type ActivityQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `Activity` struct.
|
||||
type ActivityQueryResult struct {
|
||||
Data Activities
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `Activity` struct.
|
||||
type Activities []*Activity
|
||||
|
||||
// Defining the data structure for creating a `Activity` struct.
|
||||
type ActivityForm struct {
|
||||
CategoryID string `json:"categoryId"`
|
||||
Title string `json:"title" `
|
||||
Cover string `json:"cover" `
|
||||
Images *[]string `json:"images"`
|
||||
StartAt *time.Time `json:"startAt"`
|
||||
EndAt *time.Time `json:"endAt"`
|
||||
StartSignupAt *time.Time `json:"startSignupAt"`
|
||||
EndSignupAt *time.Time `json:"endSignupAt" `
|
||||
MaxSignupNum int `json:"maxSignupNum"`
|
||||
SignupNum int `json:"signupNum"`
|
||||
Address string `json:"address"`
|
||||
Content string `json:"content"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `ActivityForm` struct.
|
||||
func (a *ActivityForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `ActivityForm` to `Activity` object.
|
||||
func (a *ActivityForm) FillTo(activity *Activity) error {
|
||||
activity.CategoryID = a.CategoryID
|
||||
activity.Title = a.Title
|
||||
activity.Cover = a.Cover
|
||||
activity.Images = a.Images
|
||||
activity.StartAt = a.StartAt
|
||||
activity.EndAt = a.EndAt
|
||||
activity.StartSignupAt = a.StartSignupAt
|
||||
activity.EndSignupAt = a.EndSignupAt
|
||||
activity.MaxSignupNum = a.MaxSignupNum
|
||||
activity.SignupNum = a.SignupNum
|
||||
activity.Address = a.Address
|
||||
activity.Content = a.Content
|
||||
activity.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
55
internal/mods/activity/schema/activity_category.go
Normal file
55
internal/mods/activity/schema/activity_category.go
Normal file
@ -0,0 +1,55 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `ActivityCategory` struct.
|
||||
type ActivityCategory struct {
|
||||
util.BaseModel
|
||||
Name string `json:"name" gorm:"size:1024;comment:名字" `
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *ActivityCategory) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `ActivityCategory` struct.
|
||||
type ActivityCategoryQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `ActivityCategory` struct.
|
||||
type ActivityCategoryQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `ActivityCategory` struct.
|
||||
type ActivityCategoryQueryResult struct {
|
||||
Data ActivityCategories
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `ActivityCategory` struct.
|
||||
type ActivityCategories []*ActivityCategory
|
||||
|
||||
// Defining the data structure for creating a `ActivityCategory` struct.
|
||||
type ActivityCategoryForm struct {
|
||||
}
|
||||
|
||||
// A validation function for the `ActivityCategoryForm` struct.
|
||||
func (a *ActivityCategoryForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `ActivityCategoryForm` to `ActivityCategory` object.
|
||||
func (a *ActivityCategoryForm) FillTo(activityCategory *ActivityCategory) error {
|
||||
return nil
|
||||
}
|
||||
68
internal/mods/activity/schema/reciprocity.go
Normal file
68
internal/mods/activity/schema/reciprocity.go
Normal file
@ -0,0 +1,68 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `Reciprocity` struct.
|
||||
type Reciprocity struct {
|
||||
util.BaseModel
|
||||
CustomerID string `json:"customerId" gorm:"type:char(36);index;comment:客户id"`
|
||||
Title string `json:"title" gorm:"size:128;not null;index;comment:标题"`
|
||||
Images *[]string `json:"images" gorm:"serializer:json;comment:详图数组"`
|
||||
Content string `json:"content" gorm:"type:text;not null;comment:活动详情"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *Reciprocity) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Reciprocity` struct.
|
||||
type ReciprocityQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `Reciprocity` struct.
|
||||
type ReciprocityQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `Reciprocity` struct.
|
||||
type ReciprocityQueryResult struct {
|
||||
Data Reciprocities
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `Reciprocity` struct.
|
||||
type Reciprocities []*Reciprocity
|
||||
|
||||
// Defining the data structure for creating a `Reciprocity` struct.
|
||||
type ReciprocityForm struct {
|
||||
CustomerID string `json:"customerId"`
|
||||
Title string `json:"title"`
|
||||
Images *[]string `json:"images"`
|
||||
Content string `json:"content"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `ReciprocityForm` struct.
|
||||
func (a *ReciprocityForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `ReciprocityForm` to `Reciprocity` object.
|
||||
func (a *ReciprocityForm) FillTo(reciprocity *Reciprocity) error {
|
||||
reciprocity.CustomerID = a.CustomerID
|
||||
reciprocity.Title = a.Title
|
||||
reciprocity.Images = a.Images
|
||||
reciprocity.Content = a.Content
|
||||
reciprocity.Status = a.Status
|
||||
|
||||
return nil
|
||||
}
|
||||
21
internal/mods/activity/wire.go
Normal file
21
internal/mods/activity/wire.go
Normal file
@ -0,0 +1,21 @@
|
||||
package activity
|
||||
|
||||
import (
|
||||
"github.com/google/wire"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/activity/dal"
|
||||
)
|
||||
|
||||
var Set = wire.NewSet(
|
||||
wire.Struct(new(Activity), "*"),
|
||||
wire.Struct(new(dal.Activity), "*"),
|
||||
wire.Struct(new(biz.Activity), "*"),
|
||||
wire.Struct(new(api.Activity), "*"),
|
||||
wire.Struct(new(dal.ActivityCategory), "*"),
|
||||
wire.Struct(new(biz.ActivityCategory), "*"),
|
||||
wire.Struct(new(api.ActivityCategory), "*"),
|
||||
wire.Struct(new(dal.Reciprocity), "*"),
|
||||
wire.Struct(new(biz.Reciprocity), "*"),
|
||||
wire.Struct(new(api.Reciprocity), "*"),
|
||||
)
|
||||
171
internal/mods/ai/api/ai_request.api.go
Normal file
171
internal/mods/ai/api/ai_request.api.go
Normal file
@ -0,0 +1,171 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/ai"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Defining the `AiRequest` api.
|
||||
type AiRequest struct {
|
||||
AiRequestBIZ *biz.AiRequest
|
||||
}
|
||||
|
||||
// @Tags AiRequestAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query ai request list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.AiRequest}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/ai-requests [get]
|
||||
func (a *AiRequest) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.AiRequestQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.AiRequestBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags AiRequestAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get ai request record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.AiRequest}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/ai-requests/{id} [get]
|
||||
func (a *AiRequest) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.AiRequestBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags AiRequestAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create ai request record
|
||||
// @Param body body schema.AiRequestForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.AiRequest}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/ai-requests [post]
|
||||
func (a *AiRequest) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.AiRequestForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
apiKey := "sk-f96d78738d3143d3859c63a5715490ac"
|
||||
client := ai.NewBaichuanClient(apiKey)
|
||||
example, err := singleCallExample(ctx, client, item.Msg)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, example)
|
||||
}
|
||||
func singleCallExample(ctx context.Context, client *ai.BaichuanClient, msg string) (string, error) {
|
||||
// 准备消息
|
||||
messages := []ai.ChatMessage{
|
||||
{Role: "system", Content: "你是一个专业的科技助手"},
|
||||
{Role: "user", Content: msg},
|
||||
}
|
||||
|
||||
// 设置参数
|
||||
params := ai.ChatCompletionParams{
|
||||
Model: "qwen-plus",
|
||||
Messages: messages,
|
||||
MaxToken: 200,
|
||||
}
|
||||
|
||||
// 调用API
|
||||
ctx2, cancel := context.WithTimeout(ctx, 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
response, err := client.ChatCompletion(ctx2, params)
|
||||
if err != nil {
|
||||
fmt.Printf("调用失败: %v\n", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
// 输出结果
|
||||
fmt.Println("=== 单次调用结果 ===")
|
||||
fmt.Printf("请求ID: %s\n", response.ID)
|
||||
fmt.Printf("模型: %s\n", response.Model)
|
||||
fmt.Printf("回复: %s\n", response.Content)
|
||||
fmt.Printf("Token使用: 提示 %d, 完成 %d, 总计 %d\n\n",
|
||||
response.Usage.PromptTokens,
|
||||
response.Usage.CompletionTokens,
|
||||
response.Usage.TotalTokens)
|
||||
return response.Content, nil
|
||||
}
|
||||
|
||||
// @Tags AiRequestAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update ai request record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.AiRequestForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/ai-requests/{id} [put]
|
||||
func (a *AiRequest) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.AiRequestForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.AiRequestBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags AiRequestAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete ai request record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/ai-requests/{id} [delete]
|
||||
func (a *AiRequest) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.AiRequestBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
104
internal/mods/ai/biz/ai_request.biz.go
Normal file
104
internal/mods/ai/biz/ai_request.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `AiRequest` business logic.
|
||||
type AiRequest struct {
|
||||
Trans *util.Trans
|
||||
AiRequestDAL *dal.AiRequest
|
||||
}
|
||||
|
||||
// Query ai requests from the data access object based on the provided parameters and options.
|
||||
func (a *AiRequest) Query(ctx context.Context, params schema.AiRequestQueryParam) (*schema.AiRequestQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.AiRequestDAL.Query(ctx, params, schema.AiRequestQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified ai request from the data access object.
|
||||
func (a *AiRequest) Get(ctx context.Context, id string) (*schema.AiRequest, error) {
|
||||
aiRequest, err := a.AiRequestDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if aiRequest == nil {
|
||||
return nil, errors.NotFound("", "Ai request not found")
|
||||
}
|
||||
return aiRequest, nil
|
||||
}
|
||||
|
||||
// Create a new ai request in the data access object.
|
||||
func (a *AiRequest) Create(ctx context.Context, formItem *schema.AiRequestForm) (*schema.AiRequest, error) {
|
||||
aiRequest := &schema.AiRequest{}
|
||||
|
||||
if err := formItem.FillTo(aiRequest); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AiRequestDAL.Create(ctx, aiRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return aiRequest, nil
|
||||
}
|
||||
|
||||
// Update the specified ai request in the data access object.
|
||||
func (a *AiRequest) Update(ctx context.Context, id string, formItem *schema.AiRequestForm) error {
|
||||
aiRequest, err := a.AiRequestDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if aiRequest == nil {
|
||||
return errors.NotFound("", "Ai request not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(aiRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
aiRequest.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AiRequestDAL.Update(ctx, aiRequest); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified ai request from the data access object.
|
||||
func (a *AiRequest) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.AiRequestDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Ai request not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AiRequestDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
83
internal/mods/ai/dal/ai_request.dal.go
Normal file
83
internal/mods/ai/dal/ai_request.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get ai request storage instance
|
||||
func GetAiRequestDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.AiRequest))
|
||||
}
|
||||
|
||||
// Defining the `AiRequest` data access object.
|
||||
type AiRequest struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query ai requests from the database based on the provided parameters and options.
|
||||
func (a *AiRequest) Query(ctx context.Context, params schema.AiRequestQueryParam, opts ...schema.AiRequestQueryOptions) (*schema.AiRequestQueryResult, error) {
|
||||
var opt schema.AiRequestQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetAiRequestDB(ctx, a.DB)
|
||||
|
||||
var list schema.AiRequests
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.AiRequestQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified ai request from the database.
|
||||
func (a *AiRequest) Get(ctx context.Context, id string, opts ...schema.AiRequestQueryOptions) (*schema.AiRequest, error) {
|
||||
var opt schema.AiRequestQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.AiRequest)
|
||||
ok, err := util.FindOne(ctx, GetAiRequestDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified ai request exists in the database.
|
||||
func (a *AiRequest) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetAiRequestDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new ai request.
|
||||
func (a *AiRequest) Create(ctx context.Context, item *schema.AiRequest) error {
|
||||
result := GetAiRequestDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified ai request in the database.
|
||||
func (a *AiRequest) Update(ctx context.Context, item *schema.AiRequest) error {
|
||||
result := GetAiRequestDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified ai request from the database.
|
||||
func (a *AiRequest) Delete(ctx context.Context, id string) error {
|
||||
result := GetAiRequestDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.AiRequest))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
46
internal/mods/ai/main.go
Normal file
46
internal/mods/ai/main.go
Normal file
@ -0,0 +1,46 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/schema"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Ai struct {
|
||||
DB *gorm.DB
|
||||
AiRequestAPI *api.AiRequest
|
||||
}
|
||||
|
||||
func (a *Ai) AutoMigrate(ctx context.Context) error {
|
||||
return a.DB.AutoMigrate(new(schema.AiRequest))
|
||||
}
|
||||
|
||||
func (a *Ai) Init(ctx context.Context) error {
|
||||
if config.C.Storage.DB.AutoMigrate {
|
||||
if err := a.AutoMigrate(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Ai) RegisterV1Routers(ctx context.Context, v1 *gin.RouterGroup) error {
|
||||
aiRequest := v1.Group("ai-requests")
|
||||
{
|
||||
aiRequest.GET("", a.AiRequestAPI.Query)
|
||||
aiRequest.GET(":id", a.AiRequestAPI.Get)
|
||||
aiRequest.POST("", a.AiRequestAPI.Create)
|
||||
aiRequest.PUT(":id", a.AiRequestAPI.Update)
|
||||
aiRequest.DELETE(":id", a.AiRequestAPI.Delete)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Ai) Release(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
53
internal/mods/ai/schema/ai_request.go
Normal file
53
internal/mods/ai/schema/ai_request.go
Normal file
@ -0,0 +1,53 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `AiRequest` struct.
|
||||
type AiRequest struct {
|
||||
util.BaseModel
|
||||
}
|
||||
|
||||
func (c *AiRequest) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `AiRequest` struct.
|
||||
type AiRequestQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `AiRequest` struct.
|
||||
type AiRequestQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `AiRequest` struct.
|
||||
type AiRequestQueryResult struct {
|
||||
Data AiRequests
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `AiRequest` struct.
|
||||
type AiRequests []*AiRequest
|
||||
|
||||
// Defining the data structure for creating a `AiRequest` struct.
|
||||
type AiRequestForm struct {
|
||||
Msg string `json:"msg" `
|
||||
}
|
||||
|
||||
// A validation function for the `AiRequestForm` struct.
|
||||
func (a *AiRequestForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `AiRequestForm` to `AiRequest` object.
|
||||
func (a *AiRequestForm) FillTo(aiRequest *AiRequest) error {
|
||||
return nil
|
||||
}
|
||||
15
internal/mods/ai/wire.go
Normal file
15
internal/mods/ai/wire.go
Normal file
@ -0,0 +1,15 @@
|
||||
package ai
|
||||
|
||||
import (
|
||||
"github.com/google/wire"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/ai/dal"
|
||||
)
|
||||
|
||||
var Set = wire.NewSet(
|
||||
wire.Struct(new(Ai), "*"),
|
||||
wire.Struct(new(dal.AiRequest), "*"),
|
||||
wire.Struct(new(biz.AiRequest), "*"),
|
||||
wire.Struct(new(api.AiRequest), "*"),
|
||||
)
|
||||
131
internal/mods/app/api/app.api.go
Normal file
131
internal/mods/app/api/app.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `App` api.
|
||||
type App struct {
|
||||
AppBIZ *biz.App
|
||||
}
|
||||
|
||||
// @Tags AppAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query app list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.App}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/apps [get]
|
||||
func (a *App) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.AppQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.AppBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags AppAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get app record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.App}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/apps/{id} [get]
|
||||
func (a *App) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.AppBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags AppAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create app record
|
||||
// @Param body body schema.AppForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.App}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/apps [post]
|
||||
func (a *App) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.AppForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.AppBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags AppAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update app record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.AppForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/apps/{id} [put]
|
||||
func (a *App) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.AppForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.AppBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags AppAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete app record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/apps/{id} [delete]
|
||||
func (a *App) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.AppBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
104
internal/mods/app/biz/app.biz.go
Normal file
104
internal/mods/app/biz/app.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `App` business logic.
|
||||
type App struct {
|
||||
Trans *util.Trans
|
||||
AppDAL *dal.App
|
||||
}
|
||||
|
||||
// Query apps from the data access object based on the provided parameters and options.
|
||||
func (a *App) Query(ctx context.Context, params schema.AppQueryParam) (*schema.AppQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.AppDAL.Query(ctx, params, schema.AppQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified app from the data access object.
|
||||
func (a *App) Get(ctx context.Context, id string) (*schema.App, error) {
|
||||
app, err := a.AppDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if app == nil {
|
||||
return nil, errors.NotFound("", "App not found")
|
||||
}
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// Create a new app in the data access object.
|
||||
func (a *App) Create(ctx context.Context, formItem *schema.AppForm) (*schema.App, error) {
|
||||
app := &schema.App{}
|
||||
|
||||
if err := formItem.FillTo(app); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AppDAL.Create(ctx, app); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return app, nil
|
||||
}
|
||||
|
||||
// Update the specified app in the data access object.
|
||||
func (a *App) Update(ctx context.Context, id string, formItem *schema.AppForm) error {
|
||||
app, err := a.AppDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if app == nil {
|
||||
return errors.NotFound("", "App not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(app); err != nil {
|
||||
return err
|
||||
}
|
||||
app.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AppDAL.Update(ctx, app); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified app from the data access object.
|
||||
func (a *App) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.AppDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "App not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.AppDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
83
internal/mods/app/dal/app.dal.go
Normal file
83
internal/mods/app/dal/app.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get app storage instance
|
||||
func GetAppDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.App))
|
||||
}
|
||||
|
||||
// Defining the `App` data access object.
|
||||
type App struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query apps from the database based on the provided parameters and options.
|
||||
func (a *App) Query(ctx context.Context, params schema.AppQueryParam, opts ...schema.AppQueryOptions) (*schema.AppQueryResult, error) {
|
||||
var opt schema.AppQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetAppDB(ctx, a.DB)
|
||||
|
||||
var list schema.Apps
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.AppQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified app from the database.
|
||||
func (a *App) Get(ctx context.Context, id string, opts ...schema.AppQueryOptions) (*schema.App, error) {
|
||||
var opt schema.AppQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.App)
|
||||
ok, err := util.FindOne(ctx, GetAppDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified app exists in the database.
|
||||
func (a *App) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetAppDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new app.
|
||||
func (a *App) Create(ctx context.Context, item *schema.App) error {
|
||||
result := GetAppDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified app in the database.
|
||||
func (a *App) Update(ctx context.Context, item *schema.App) error {
|
||||
result := GetAppDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified app from the database.
|
||||
func (a *App) Delete(ctx context.Context, id string) error {
|
||||
result := GetAppDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.App))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
46
internal/mods/app/main.go
Normal file
46
internal/mods/app/main.go
Normal file
@ -0,0 +1,46 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/schema"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type App struct {
|
||||
DB *gorm.DB
|
||||
AppAPI *api.App
|
||||
}
|
||||
|
||||
func (a *App) AutoMigrate(ctx context.Context) error {
|
||||
return a.DB.AutoMigrate(new(schema.App))
|
||||
}
|
||||
|
||||
func (a *App) Init(ctx context.Context) error {
|
||||
if config.C.Storage.DB.AutoMigrate {
|
||||
if err := a.AutoMigrate(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) RegisterV1Routers(ctx context.Context, v1 *gin.RouterGroup) error {
|
||||
app := v1.Group("apps")
|
||||
{
|
||||
app.GET("", a.AppAPI.Query)
|
||||
app.GET(":id", a.AppAPI.Get)
|
||||
app.POST("", a.AppAPI.Create)
|
||||
app.PUT(":id", a.AppAPI.Update)
|
||||
app.DELETE(":id", a.AppAPI.Delete)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) Release(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
47
internal/mods/app/schema/app.go
Normal file
47
internal/mods/app/schema/app.go
Normal file
@ -0,0 +1,47 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `App` struct.
|
||||
type App struct {
|
||||
ID string `json:"id" gorm:"size:20;primaryKey;"` // Unique ID
|
||||
CreatedAt time.Time `json:"created_at" gorm:"index;"` // Create time
|
||||
UpdatedAt time.Time `json:"updated_at" gorm:"index;"` // Update time
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `App` struct.
|
||||
type AppQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `App` struct.
|
||||
type AppQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `App` struct.
|
||||
type AppQueryResult struct {
|
||||
Data Apps
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `App` struct.
|
||||
type Apps []*App
|
||||
|
||||
// Defining the data structure for creating a `App` struct.
|
||||
type AppForm struct {
|
||||
}
|
||||
|
||||
// A validation function for the `AppForm` struct.
|
||||
func (a *AppForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `AppForm` to `App` object.
|
||||
func (a *AppForm) FillTo(app *App) error {
|
||||
return nil
|
||||
}
|
||||
15
internal/mods/app/wire.go
Normal file
15
internal/mods/app/wire.go
Normal file
@ -0,0 +1,15 @@
|
||||
package app
|
||||
|
||||
import (
|
||||
"github.com/google/wire"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/app/dal"
|
||||
)
|
||||
|
||||
var Set = wire.NewSet(
|
||||
wire.Struct(new(App), "*"),
|
||||
wire.Struct(new(dal.App), "*"),
|
||||
wire.Struct(new(biz.App), "*"),
|
||||
wire.Struct(new(api.App), "*"),
|
||||
)
|
||||
131
internal/mods/common/api/banner.api.go
Normal file
131
internal/mods/common/api/banner.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Banner` api.
|
||||
type Banner struct {
|
||||
BannerBIZ *biz.Banner
|
||||
}
|
||||
|
||||
// @Tags BannerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query banner list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Banner}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/banners [get]
|
||||
func (a *Banner) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.BannerQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.BannerBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags BannerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get banner record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Banner}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/banners/{id} [get]
|
||||
func (a *Banner) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.BannerBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags BannerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create banner record
|
||||
// @Param body body schema.BannerForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Banner}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/banners [post]
|
||||
func (a *Banner) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.BannerForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.BannerBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags BannerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update banner record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.BannerForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/banners/{id} [put]
|
||||
func (a *Banner) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.BannerForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.BannerBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags BannerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete banner record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/banners/{id} [delete]
|
||||
func (a *Banner) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.BannerBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/help.api.go
Normal file
131
internal/mods/common/api/help.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Help` api.
|
||||
type Help struct {
|
||||
HelpBIZ *biz.Help
|
||||
}
|
||||
|
||||
// @Tags HelpAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query help list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Help}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/helps [get]
|
||||
func (a *Help) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.HelpQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.HelpBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags HelpAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get help record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Help}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/helps/{id} [get]
|
||||
func (a *Help) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.HelpBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags HelpAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create help record
|
||||
// @Param body body schema.HelpForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Help}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/helps [post]
|
||||
func (a *Help) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.HelpForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.HelpBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags HelpAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update help record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.HelpForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/helps/{id} [put]
|
||||
func (a *Help) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.HelpForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.HelpBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags HelpAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete help record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/helps/{id} [delete]
|
||||
func (a *Help) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.HelpBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/metting_room.api.go
Normal file
131
internal/mods/common/api/metting_room.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoom` api.
|
||||
type MettingRoom struct {
|
||||
MettingRoomBIZ *biz.MettingRoom
|
||||
}
|
||||
|
||||
// @Tags MettingRoomAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query metting room list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.MettingRoom}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-rooms [get]
|
||||
func (a *MettingRoom) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.MettingRoomQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.MettingRoomBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get metting room record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.MettingRoom}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-rooms/{id} [get]
|
||||
func (a *MettingRoom) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.MettingRoomBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create metting room record
|
||||
// @Param body body schema.MettingRoomForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.MettingRoom}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-rooms [post]
|
||||
func (a *MettingRoom) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.MettingRoomForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.MettingRoomBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update metting room record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.MettingRoomForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-rooms/{id} [put]
|
||||
func (a *MettingRoom) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.MettingRoomForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.MettingRoomBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete metting room record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-rooms/{id} [delete]
|
||||
func (a *MettingRoom) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.MettingRoomBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/metting_room_order.api.go
Normal file
131
internal/mods/common/api/metting_room_order.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoomOrder` api.
|
||||
type MettingRoomOrder struct {
|
||||
MettingRoomOrderBIZ *biz.MettingRoomOrder
|
||||
}
|
||||
|
||||
// @Tags MettingRoomOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query metting room order list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.MettingRoomOrder}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-room-orders [get]
|
||||
func (a *MettingRoomOrder) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.MettingRoomOrderQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.MettingRoomOrderBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get metting room order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.MettingRoomOrder}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-room-orders/{id} [get]
|
||||
func (a *MettingRoomOrder) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.MettingRoomOrderBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create metting room order record
|
||||
// @Param body body schema.MettingRoomOrderForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.MettingRoomOrder}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-room-orders [post]
|
||||
func (a *MettingRoomOrder) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.MettingRoomOrderForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.MettingRoomOrderBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update metting room order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.MettingRoomOrderForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-room-orders/{id} [put]
|
||||
func (a *MettingRoomOrder) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.MettingRoomOrderForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.MettingRoomOrderBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags MettingRoomOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete metting room order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/metting-room-orders/{id} [delete]
|
||||
func (a *MettingRoomOrder) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.MettingRoomOrderBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/notice.api.go
Normal file
131
internal/mods/common/api/notice.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Notice` api.
|
||||
type Notice struct {
|
||||
NoticeBIZ *biz.Notice
|
||||
}
|
||||
|
||||
// @Tags NoticeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query notice list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Notice}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/notices [get]
|
||||
func (a *Notice) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.NoticeQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.NoticeBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags NoticeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get notice record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Notice}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/notices/{id} [get]
|
||||
func (a *Notice) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.NoticeBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags NoticeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create notice record
|
||||
// @Param body body schema.NoticeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Notice}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/notices [post]
|
||||
func (a *Notice) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.NoticeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.NoticeBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags NoticeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update notice record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.NoticeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/notices/{id} [put]
|
||||
func (a *Notice) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.NoticeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.NoticeBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags NoticeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete notice record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/notices/{id} [delete]
|
||||
func (a *Notice) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.NoticeBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/surrounding_service.api.go
Normal file
131
internal/mods/common/api/surrounding_service.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingService` api.
|
||||
type SurroundingService struct {
|
||||
SurroundingServiceBIZ *biz.SurroundingService
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query surrounding service list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.SurroundingService}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-services [get]
|
||||
func (a *SurroundingService) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.SurroundingServiceQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.SurroundingServiceBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get surrounding service record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.SurroundingService}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-services/{id} [get]
|
||||
func (a *SurroundingService) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.SurroundingServiceBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create surrounding service record
|
||||
// @Param body body schema.SurroundingServiceForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.SurroundingService}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-services [post]
|
||||
func (a *SurroundingService) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.SurroundingServiceForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.SurroundingServiceBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update surrounding service record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.SurroundingServiceForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-services/{id} [put]
|
||||
func (a *SurroundingService) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.SurroundingServiceForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.SurroundingServiceBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete surrounding service record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-services/{id} [delete]
|
||||
func (a *SurroundingService) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.SurroundingServiceBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/surrounding_service_type.api.go
Normal file
131
internal/mods/common/api/surrounding_service_type.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingServiceType` api.
|
||||
type SurroundingServiceType struct {
|
||||
SurroundingServiceTypeBIZ *biz.SurroundingServiceType
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query surrounding service type list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.SurroundingServiceType}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-service-types [get]
|
||||
func (a *SurroundingServiceType) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.SurroundingServiceTypeQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.SurroundingServiceTypeBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get surrounding service type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.SurroundingServiceType}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-service-types/{id} [get]
|
||||
func (a *SurroundingServiceType) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.SurroundingServiceTypeBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create surrounding service type record
|
||||
// @Param body body schema.SurroundingServiceTypeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.SurroundingServiceType}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-service-types [post]
|
||||
func (a *SurroundingServiceType) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.SurroundingServiceTypeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.SurroundingServiceTypeBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update surrounding service type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.SurroundingServiceTypeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-service-types/{id} [put]
|
||||
func (a *SurroundingServiceType) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.SurroundingServiceTypeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.SurroundingServiceTypeBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags SurroundingServiceTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete surrounding service type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/surrounding-service-types/{id} [delete]
|
||||
func (a *SurroundingServiceType) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.SurroundingServiceTypeBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/web_site.api.go
Normal file
131
internal/mods/common/api/web_site.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WebSite` api.
|
||||
type WebSite struct {
|
||||
WebSiteBIZ *biz.WebSite
|
||||
}
|
||||
|
||||
// @Tags WebSiteAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query web site list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.WebSite}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/web-sites [get]
|
||||
func (a *WebSite) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.WebSiteQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WebSiteBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags WebSiteAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get web site record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WebSite}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/web-sites/{id} [get]
|
||||
func (a *WebSite) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.WebSiteBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags WebSiteAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create web site record
|
||||
// @Param body body schema.WebSiteForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WebSite}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/web-sites [post]
|
||||
func (a *WebSite) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WebSiteForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WebSiteBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags WebSiteAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update web site record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.WebSiteForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/web-sites/{id} [put]
|
||||
func (a *WebSite) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WebSiteForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.WebSiteBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags WebSiteAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete web site record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/web-sites/{id} [delete]
|
||||
func (a *WebSite) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.WebSiteBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/work_order.api.go
Normal file
131
internal/mods/common/api/work_order.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrder` api.
|
||||
type WorkOrder struct {
|
||||
WorkOrderBIZ *biz.WorkOrder
|
||||
}
|
||||
|
||||
// @Tags WorkOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query work order list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.WorkOrder}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-orders [get]
|
||||
func (a *WorkOrder) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.WorkOrderQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WorkOrderBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get work order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WorkOrder}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-orders/{id} [get]
|
||||
func (a *WorkOrder) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.WorkOrderBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create work order record
|
||||
// @Param body body schema.WorkOrderForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WorkOrder}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-orders [post]
|
||||
func (a *WorkOrder) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WorkOrderForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WorkOrderBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update work order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.WorkOrderForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-orders/{id} [put]
|
||||
func (a *WorkOrder) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WorkOrderForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.WorkOrderBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete work order record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-orders/{id} [delete]
|
||||
func (a *WorkOrder) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.WorkOrderBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/common/api/work_order_type.api.go
Normal file
131
internal/mods/common/api/work_order_type.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrderType` api.
|
||||
type WorkOrderType struct {
|
||||
WorkOrderTypeBIZ *biz.WorkOrderType
|
||||
}
|
||||
|
||||
// @Tags WorkOrderTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query work order type list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.WorkOrderType}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-order-types [get]
|
||||
func (a *WorkOrderType) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.WorkOrderTypeQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WorkOrderTypeBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get work order type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WorkOrderType}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-order-types/{id} [get]
|
||||
func (a *WorkOrderType) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.WorkOrderTypeBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create work order type record
|
||||
// @Param body body schema.WorkOrderTypeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.WorkOrderType}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-order-types [post]
|
||||
func (a *WorkOrderType) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WorkOrderTypeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.WorkOrderTypeBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update work order type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.WorkOrderTypeForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-order-types/{id} [put]
|
||||
func (a *WorkOrderType) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.WorkOrderTypeForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.WorkOrderTypeBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags WorkOrderTypeAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete work order type record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/work-order-types/{id} [delete]
|
||||
func (a *WorkOrderType) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.WorkOrderTypeBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
104
internal/mods/common/biz/banner.biz.go
Normal file
104
internal/mods/common/biz/banner.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Banner` business logic.
|
||||
type Banner struct {
|
||||
Trans *util.Trans
|
||||
BannerDAL *dal.Banner
|
||||
}
|
||||
|
||||
// Query banners from the data access object based on the provided parameters and options.
|
||||
func (a *Banner) Query(ctx context.Context, params schema.BannerQueryParam) (*schema.BannerQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.BannerDAL.Query(ctx, params, schema.BannerQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified banner from the data access object.
|
||||
func (a *Banner) Get(ctx context.Context, id string) (*schema.Banner, error) {
|
||||
banner, err := a.BannerDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if banner == nil {
|
||||
return nil, errors.NotFound("", "Banner not found")
|
||||
}
|
||||
return banner, nil
|
||||
}
|
||||
|
||||
// Create a new banner in the data access object.
|
||||
func (a *Banner) Create(ctx context.Context, formItem *schema.BannerForm) (*schema.Banner, error) {
|
||||
banner := &schema.Banner{}
|
||||
|
||||
if err := formItem.FillTo(banner); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BannerDAL.Create(ctx, banner); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return banner, nil
|
||||
}
|
||||
|
||||
// Update the specified banner in the data access object.
|
||||
func (a *Banner) Update(ctx context.Context, id string, formItem *schema.BannerForm) error {
|
||||
banner, err := a.BannerDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if banner == nil {
|
||||
return errors.NotFound("", "Banner not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(banner); err != nil {
|
||||
return err
|
||||
}
|
||||
banner.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BannerDAL.Update(ctx, banner); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified banner from the data access object.
|
||||
func (a *Banner) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.BannerDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Banner not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BannerDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/help.biz.go
Normal file
104
internal/mods/common/biz/help.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Help` business logic.
|
||||
type Help struct {
|
||||
Trans *util.Trans
|
||||
HelpDAL *dal.Help
|
||||
}
|
||||
|
||||
// Query helps from the data access object based on the provided parameters and options.
|
||||
func (a *Help) Query(ctx context.Context, params schema.HelpQueryParam) (*schema.HelpQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.HelpDAL.Query(ctx, params, schema.HelpQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified help from the data access object.
|
||||
func (a *Help) Get(ctx context.Context, id string) (*schema.Help, error) {
|
||||
help, err := a.HelpDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if help == nil {
|
||||
return nil, errors.NotFound("", "Help not found")
|
||||
}
|
||||
return help, nil
|
||||
}
|
||||
|
||||
// Create a new help in the data access object.
|
||||
func (a *Help) Create(ctx context.Context, formItem *schema.HelpForm) (*schema.Help, error) {
|
||||
help := &schema.Help{}
|
||||
|
||||
if err := formItem.FillTo(help); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.HelpDAL.Create(ctx, help); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return help, nil
|
||||
}
|
||||
|
||||
// Update the specified help in the data access object.
|
||||
func (a *Help) Update(ctx context.Context, id string, formItem *schema.HelpForm) error {
|
||||
help, err := a.HelpDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if help == nil {
|
||||
return errors.NotFound("", "Help not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(help); err != nil {
|
||||
return err
|
||||
}
|
||||
help.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.HelpDAL.Update(ctx, help); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified help from the data access object.
|
||||
func (a *Help) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.HelpDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Help not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.HelpDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/metting_room.biz.go
Normal file
104
internal/mods/common/biz/metting_room.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoom` business logic.
|
||||
type MettingRoom struct {
|
||||
Trans *util.Trans
|
||||
MettingRoomDAL *dal.MettingRoom
|
||||
}
|
||||
|
||||
// Query metting rooms from the data access object based on the provided parameters and options.
|
||||
func (a *MettingRoom) Query(ctx context.Context, params schema.MettingRoomQueryParam) (*schema.MettingRoomQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.MettingRoomDAL.Query(ctx, params, schema.MettingRoomQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified metting room from the data access object.
|
||||
func (a *MettingRoom) Get(ctx context.Context, id string) (*schema.MettingRoom, error) {
|
||||
mettingRoom, err := a.MettingRoomDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mettingRoom == nil {
|
||||
return nil, errors.NotFound("", "Metting room not found")
|
||||
}
|
||||
return mettingRoom, nil
|
||||
}
|
||||
|
||||
// Create a new metting room in the data access object.
|
||||
func (a *MettingRoom) Create(ctx context.Context, formItem *schema.MettingRoomForm) (*schema.MettingRoom, error) {
|
||||
mettingRoom := &schema.MettingRoom{}
|
||||
|
||||
if err := formItem.FillTo(mettingRoom); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomDAL.Create(ctx, mettingRoom); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mettingRoom, nil
|
||||
}
|
||||
|
||||
// Update the specified metting room in the data access object.
|
||||
func (a *MettingRoom) Update(ctx context.Context, id string, formItem *schema.MettingRoomForm) error {
|
||||
mettingRoom, err := a.MettingRoomDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if mettingRoom == nil {
|
||||
return errors.NotFound("", "Metting room not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(mettingRoom); err != nil {
|
||||
return err
|
||||
}
|
||||
mettingRoom.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomDAL.Update(ctx, mettingRoom); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified metting room from the data access object.
|
||||
func (a *MettingRoom) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.MettingRoomDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Metting room not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/metting_room_order.biz.go
Normal file
104
internal/mods/common/biz/metting_room_order.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoomOrder` business logic.
|
||||
type MettingRoomOrder struct {
|
||||
Trans *util.Trans
|
||||
MettingRoomOrderDAL *dal.MettingRoomOrder
|
||||
}
|
||||
|
||||
// Query metting room orders from the data access object based on the provided parameters and options.
|
||||
func (a *MettingRoomOrder) Query(ctx context.Context, params schema.MettingRoomOrderQueryParam) (*schema.MettingRoomOrderQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.MettingRoomOrderDAL.Query(ctx, params, schema.MettingRoomOrderQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified metting room order from the data access object.
|
||||
func (a *MettingRoomOrder) Get(ctx context.Context, id string) (*schema.MettingRoomOrder, error) {
|
||||
mettingRoomOrder, err := a.MettingRoomOrderDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if mettingRoomOrder == nil {
|
||||
return nil, errors.NotFound("", "Metting room order not found")
|
||||
}
|
||||
return mettingRoomOrder, nil
|
||||
}
|
||||
|
||||
// Create a new metting room order in the data access object.
|
||||
func (a *MettingRoomOrder) Create(ctx context.Context, formItem *schema.MettingRoomOrderForm) (*schema.MettingRoomOrder, error) {
|
||||
mettingRoomOrder := &schema.MettingRoomOrder{}
|
||||
|
||||
if err := formItem.FillTo(mettingRoomOrder); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomOrderDAL.Create(ctx, mettingRoomOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return mettingRoomOrder, nil
|
||||
}
|
||||
|
||||
// Update the specified metting room order in the data access object.
|
||||
func (a *MettingRoomOrder) Update(ctx context.Context, id string, formItem *schema.MettingRoomOrderForm) error {
|
||||
mettingRoomOrder, err := a.MettingRoomOrderDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if mettingRoomOrder == nil {
|
||||
return errors.NotFound("", "Metting room order not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(mettingRoomOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
mettingRoomOrder.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomOrderDAL.Update(ctx, mettingRoomOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified metting room order from the data access object.
|
||||
func (a *MettingRoomOrder) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.MettingRoomOrderDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Metting room order not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.MettingRoomOrderDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/notice.biz.go
Normal file
104
internal/mods/common/biz/notice.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Notice` business logic.
|
||||
type Notice struct {
|
||||
Trans *util.Trans
|
||||
NoticeDAL *dal.Notice
|
||||
}
|
||||
|
||||
// Query notices from the data access object based on the provided parameters and options.
|
||||
func (a *Notice) Query(ctx context.Context, params schema.NoticeQueryParam) (*schema.NoticeQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.NoticeDAL.Query(ctx, params, schema.NoticeQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified notice from the data access object.
|
||||
func (a *Notice) Get(ctx context.Context, id string) (*schema.Notice, error) {
|
||||
notice, err := a.NoticeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if notice == nil {
|
||||
return nil, errors.NotFound("", "Notice not found")
|
||||
}
|
||||
return notice, nil
|
||||
}
|
||||
|
||||
// Create a new notice in the data access object.
|
||||
func (a *Notice) Create(ctx context.Context, formItem *schema.NoticeForm) (*schema.Notice, error) {
|
||||
notice := &schema.Notice{}
|
||||
|
||||
if err := formItem.FillTo(notice); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.NoticeDAL.Create(ctx, notice); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return notice, nil
|
||||
}
|
||||
|
||||
// Update the specified notice in the data access object.
|
||||
func (a *Notice) Update(ctx context.Context, id string, formItem *schema.NoticeForm) error {
|
||||
notice, err := a.NoticeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if notice == nil {
|
||||
return errors.NotFound("", "Notice not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(notice); err != nil {
|
||||
return err
|
||||
}
|
||||
notice.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.NoticeDAL.Update(ctx, notice); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified notice from the data access object.
|
||||
func (a *Notice) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.NoticeDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Notice not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.NoticeDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/surrounding_service.biz.go
Normal file
104
internal/mods/common/biz/surrounding_service.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingService` business logic.
|
||||
type SurroundingService struct {
|
||||
Trans *util.Trans
|
||||
SurroundingServiceDAL *dal.SurroundingService
|
||||
}
|
||||
|
||||
// Query surrounding services from the data access object based on the provided parameters and options.
|
||||
func (a *SurroundingService) Query(ctx context.Context, params schema.SurroundingServiceQueryParam) (*schema.SurroundingServiceQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.SurroundingServiceDAL.Query(ctx, params, schema.SurroundingServiceQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified surrounding service from the data access object.
|
||||
func (a *SurroundingService) Get(ctx context.Context, id string) (*schema.SurroundingService, error) {
|
||||
surroundingService, err := a.SurroundingServiceDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if surroundingService == nil {
|
||||
return nil, errors.NotFound("", "Surrounding service not found")
|
||||
}
|
||||
return surroundingService, nil
|
||||
}
|
||||
|
||||
// Create a new surrounding service in the data access object.
|
||||
func (a *SurroundingService) Create(ctx context.Context, formItem *schema.SurroundingServiceForm) (*schema.SurroundingService, error) {
|
||||
surroundingService := &schema.SurroundingService{}
|
||||
|
||||
if err := formItem.FillTo(surroundingService); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceDAL.Create(ctx, surroundingService); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return surroundingService, nil
|
||||
}
|
||||
|
||||
// Update the specified surrounding service in the data access object.
|
||||
func (a *SurroundingService) Update(ctx context.Context, id string, formItem *schema.SurroundingServiceForm) error {
|
||||
surroundingService, err := a.SurroundingServiceDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if surroundingService == nil {
|
||||
return errors.NotFound("", "Surrounding service not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(surroundingService); err != nil {
|
||||
return err
|
||||
}
|
||||
surroundingService.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceDAL.Update(ctx, surroundingService); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified surrounding service from the data access object.
|
||||
func (a *SurroundingService) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.SurroundingServiceDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Surrounding service not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/surrounding_service_type.biz.go
Normal file
104
internal/mods/common/biz/surrounding_service_type.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingServiceType` business logic.
|
||||
type SurroundingServiceType struct {
|
||||
Trans *util.Trans
|
||||
SurroundingServiceTypeDAL *dal.SurroundingServiceType
|
||||
}
|
||||
|
||||
// Query surrounding service types from the data access object based on the provided parameters and options.
|
||||
func (a *SurroundingServiceType) Query(ctx context.Context, params schema.SurroundingServiceTypeQueryParam) (*schema.SurroundingServiceTypeQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.SurroundingServiceTypeDAL.Query(ctx, params, schema.SurroundingServiceTypeQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified surrounding service type from the data access object.
|
||||
func (a *SurroundingServiceType) Get(ctx context.Context, id string) (*schema.SurroundingServiceType, error) {
|
||||
surroundingServiceType, err := a.SurroundingServiceTypeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if surroundingServiceType == nil {
|
||||
return nil, errors.NotFound("", "Surrounding service type not found")
|
||||
}
|
||||
return surroundingServiceType, nil
|
||||
}
|
||||
|
||||
// Create a new surrounding service type in the data access object.
|
||||
func (a *SurroundingServiceType) Create(ctx context.Context, formItem *schema.SurroundingServiceTypeForm) (*schema.SurroundingServiceType, error) {
|
||||
surroundingServiceType := &schema.SurroundingServiceType{}
|
||||
|
||||
if err := formItem.FillTo(surroundingServiceType); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceTypeDAL.Create(ctx, surroundingServiceType); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return surroundingServiceType, nil
|
||||
}
|
||||
|
||||
// Update the specified surrounding service type in the data access object.
|
||||
func (a *SurroundingServiceType) Update(ctx context.Context, id string, formItem *schema.SurroundingServiceTypeForm) error {
|
||||
surroundingServiceType, err := a.SurroundingServiceTypeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if surroundingServiceType == nil {
|
||||
return errors.NotFound("", "Surrounding service type not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(surroundingServiceType); err != nil {
|
||||
return err
|
||||
}
|
||||
surroundingServiceType.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceTypeDAL.Update(ctx, surroundingServiceType); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified surrounding service type from the data access object.
|
||||
func (a *SurroundingServiceType) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.SurroundingServiceTypeDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Surrounding service type not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.SurroundingServiceTypeDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/web_site.biz.go
Normal file
104
internal/mods/common/biz/web_site.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WebSite` business logic.
|
||||
type WebSite struct {
|
||||
Trans *util.Trans
|
||||
WebSiteDAL *dal.WebSite
|
||||
}
|
||||
|
||||
// Query web sites from the data access object based on the provided parameters and options.
|
||||
func (a *WebSite) Query(ctx context.Context, params schema.WebSiteQueryParam) (*schema.WebSiteQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.WebSiteDAL.Query(ctx, params, schema.WebSiteQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified web site from the data access object.
|
||||
func (a *WebSite) Get(ctx context.Context, id string) (*schema.WebSite, error) {
|
||||
webSite, err := a.WebSiteDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if webSite == nil {
|
||||
return nil, errors.NotFound("", "Web site not found")
|
||||
}
|
||||
return webSite, nil
|
||||
}
|
||||
|
||||
// Create a new web site in the data access object.
|
||||
func (a *WebSite) Create(ctx context.Context, formItem *schema.WebSiteForm) (*schema.WebSite, error) {
|
||||
webSite := &schema.WebSite{}
|
||||
|
||||
if err := formItem.FillTo(webSite); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WebSiteDAL.Create(ctx, webSite); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return webSite, nil
|
||||
}
|
||||
|
||||
// Update the specified web site in the data access object.
|
||||
func (a *WebSite) Update(ctx context.Context, id string, formItem *schema.WebSiteForm) error {
|
||||
webSite, err := a.WebSiteDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if webSite == nil {
|
||||
return errors.NotFound("", "Web site not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(webSite); err != nil {
|
||||
return err
|
||||
}
|
||||
webSite.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WebSiteDAL.Update(ctx, webSite); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified web site from the data access object.
|
||||
func (a *WebSite) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.WebSiteDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Web site not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WebSiteDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/work_order.biz.go
Normal file
104
internal/mods/common/biz/work_order.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrder` business logic.
|
||||
type WorkOrder struct {
|
||||
Trans *util.Trans
|
||||
WorkOrderDAL *dal.WorkOrder
|
||||
}
|
||||
|
||||
// Query work orders from the data access object based on the provided parameters and options.
|
||||
func (a *WorkOrder) Query(ctx context.Context, params schema.WorkOrderQueryParam) (*schema.WorkOrderQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.WorkOrderDAL.Query(ctx, params, schema.WorkOrderQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified work order from the data access object.
|
||||
func (a *WorkOrder) Get(ctx context.Context, id string) (*schema.WorkOrder, error) {
|
||||
workOrder, err := a.WorkOrderDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if workOrder == nil {
|
||||
return nil, errors.NotFound("", "Work order not found")
|
||||
}
|
||||
return workOrder, nil
|
||||
}
|
||||
|
||||
// Create a new work order in the data access object.
|
||||
func (a *WorkOrder) Create(ctx context.Context, formItem *schema.WorkOrderForm) (*schema.WorkOrder, error) {
|
||||
workOrder := &schema.WorkOrder{}
|
||||
|
||||
if err := formItem.FillTo(workOrder); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderDAL.Create(ctx, workOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return workOrder, nil
|
||||
}
|
||||
|
||||
// Update the specified work order in the data access object.
|
||||
func (a *WorkOrder) Update(ctx context.Context, id string, formItem *schema.WorkOrderForm) error {
|
||||
workOrder, err := a.WorkOrderDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if workOrder == nil {
|
||||
return errors.NotFound("", "Work order not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(workOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
workOrder.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderDAL.Update(ctx, workOrder); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified work order from the data access object.
|
||||
func (a *WorkOrder) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.WorkOrderDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Work order not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/common/biz/work_order_type.biz.go
Normal file
104
internal/mods/common/biz/work_order_type.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrderType` business logic.
|
||||
type WorkOrderType struct {
|
||||
Trans *util.Trans
|
||||
WorkOrderTypeDAL *dal.WorkOrderType
|
||||
}
|
||||
|
||||
// Query work order types from the data access object based on the provided parameters and options.
|
||||
func (a *WorkOrderType) Query(ctx context.Context, params schema.WorkOrderTypeQueryParam) (*schema.WorkOrderTypeQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.WorkOrderTypeDAL.Query(ctx, params, schema.WorkOrderTypeQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified work order type from the data access object.
|
||||
func (a *WorkOrderType) Get(ctx context.Context, id string) (*schema.WorkOrderType, error) {
|
||||
workOrderType, err := a.WorkOrderTypeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if workOrderType == nil {
|
||||
return nil, errors.NotFound("", "Work order type not found")
|
||||
}
|
||||
return workOrderType, nil
|
||||
}
|
||||
|
||||
// Create a new work order type in the data access object.
|
||||
func (a *WorkOrderType) Create(ctx context.Context, formItem *schema.WorkOrderTypeForm) (*schema.WorkOrderType, error) {
|
||||
workOrderType := &schema.WorkOrderType{}
|
||||
|
||||
if err := formItem.FillTo(workOrderType); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderTypeDAL.Create(ctx, workOrderType); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return workOrderType, nil
|
||||
}
|
||||
|
||||
// Update the specified work order type in the data access object.
|
||||
func (a *WorkOrderType) Update(ctx context.Context, id string, formItem *schema.WorkOrderTypeForm) error {
|
||||
workOrderType, err := a.WorkOrderTypeDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if workOrderType == nil {
|
||||
return errors.NotFound("", "Work order type not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(workOrderType); err != nil {
|
||||
return err
|
||||
}
|
||||
workOrderType.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderTypeDAL.Update(ctx, workOrderType); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified work order type from the data access object.
|
||||
func (a *WorkOrderType) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.WorkOrderTypeDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Work order type not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.WorkOrderTypeDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
83
internal/mods/common/dal/banner.dal.go
Normal file
83
internal/mods/common/dal/banner.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get banner storage instance
|
||||
func GetBannerDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.Banner))
|
||||
}
|
||||
|
||||
// Defining the `Banner` data access object.
|
||||
type Banner struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query banners from the database based on the provided parameters and options.
|
||||
func (a *Banner) Query(ctx context.Context, params schema.BannerQueryParam, opts ...schema.BannerQueryOptions) (*schema.BannerQueryResult, error) {
|
||||
var opt schema.BannerQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetBannerDB(ctx, a.DB)
|
||||
|
||||
var list schema.Banners
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.BannerQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified banner from the database.
|
||||
func (a *Banner) Get(ctx context.Context, id string, opts ...schema.BannerQueryOptions) (*schema.Banner, error) {
|
||||
var opt schema.BannerQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.Banner)
|
||||
ok, err := util.FindOne(ctx, GetBannerDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified banner exists in the database.
|
||||
func (a *Banner) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetBannerDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new banner.
|
||||
func (a *Banner) Create(ctx context.Context, item *schema.Banner) error {
|
||||
result := GetBannerDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified banner in the database.
|
||||
func (a *Banner) Update(ctx context.Context, item *schema.Banner) error {
|
||||
result := GetBannerDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified banner from the database.
|
||||
func (a *Banner) Delete(ctx context.Context, id string) error {
|
||||
result := GetBannerDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.Banner))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/help.dal.go
Normal file
83
internal/mods/common/dal/help.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get help storage instance
|
||||
func GetHelpDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.Help))
|
||||
}
|
||||
|
||||
// Defining the `Help` data access object.
|
||||
type Help struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query helps from the database based on the provided parameters and options.
|
||||
func (a *Help) Query(ctx context.Context, params schema.HelpQueryParam, opts ...schema.HelpQueryOptions) (*schema.HelpQueryResult, error) {
|
||||
var opt schema.HelpQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetHelpDB(ctx, a.DB)
|
||||
|
||||
var list schema.Helps
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.HelpQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified help from the database.
|
||||
func (a *Help) Get(ctx context.Context, id string, opts ...schema.HelpQueryOptions) (*schema.Help, error) {
|
||||
var opt schema.HelpQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.Help)
|
||||
ok, err := util.FindOne(ctx, GetHelpDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified help exists in the database.
|
||||
func (a *Help) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetHelpDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new help.
|
||||
func (a *Help) Create(ctx context.Context, item *schema.Help) error {
|
||||
result := GetHelpDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified help in the database.
|
||||
func (a *Help) Update(ctx context.Context, item *schema.Help) error {
|
||||
result := GetHelpDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified help from the database.
|
||||
func (a *Help) Delete(ctx context.Context, id string) error {
|
||||
result := GetHelpDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.Help))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/metting_room.dal.go
Normal file
83
internal/mods/common/dal/metting_room.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get metting room storage instance
|
||||
func GetMettingRoomDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.MettingRoom))
|
||||
}
|
||||
|
||||
// Defining the `MettingRoom` data access object.
|
||||
type MettingRoom struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query metting rooms from the database based on the provided parameters and options.
|
||||
func (a *MettingRoom) Query(ctx context.Context, params schema.MettingRoomQueryParam, opts ...schema.MettingRoomQueryOptions) (*schema.MettingRoomQueryResult, error) {
|
||||
var opt schema.MettingRoomQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetMettingRoomDB(ctx, a.DB)
|
||||
|
||||
var list schema.MettingRooms
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.MettingRoomQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified metting room from the database.
|
||||
func (a *MettingRoom) Get(ctx context.Context, id string, opts ...schema.MettingRoomQueryOptions) (*schema.MettingRoom, error) {
|
||||
var opt schema.MettingRoomQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.MettingRoom)
|
||||
ok, err := util.FindOne(ctx, GetMettingRoomDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified metting room exists in the database.
|
||||
func (a *MettingRoom) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetMettingRoomDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new metting room.
|
||||
func (a *MettingRoom) Create(ctx context.Context, item *schema.MettingRoom) error {
|
||||
result := GetMettingRoomDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified metting room in the database.
|
||||
func (a *MettingRoom) Update(ctx context.Context, item *schema.MettingRoom) error {
|
||||
result := GetMettingRoomDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified metting room from the database.
|
||||
func (a *MettingRoom) Delete(ctx context.Context, id string) error {
|
||||
result := GetMettingRoomDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.MettingRoom))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/metting_room_order.dal.go
Normal file
83
internal/mods/common/dal/metting_room_order.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get metting room order storage instance
|
||||
func GetMettingRoomOrderDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.MettingRoomOrder))
|
||||
}
|
||||
|
||||
// Defining the `MettingRoomOrder` data access object.
|
||||
type MettingRoomOrder struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query metting room orders from the database based on the provided parameters and options.
|
||||
func (a *MettingRoomOrder) Query(ctx context.Context, params schema.MettingRoomOrderQueryParam, opts ...schema.MettingRoomOrderQueryOptions) (*schema.MettingRoomOrderQueryResult, error) {
|
||||
var opt schema.MettingRoomOrderQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetMettingRoomOrderDB(ctx, a.DB)
|
||||
|
||||
var list schema.MettingRoomOrders
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.MettingRoomOrderQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified metting room order from the database.
|
||||
func (a *MettingRoomOrder) Get(ctx context.Context, id string, opts ...schema.MettingRoomOrderQueryOptions) (*schema.MettingRoomOrder, error) {
|
||||
var opt schema.MettingRoomOrderQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.MettingRoomOrder)
|
||||
ok, err := util.FindOne(ctx, GetMettingRoomOrderDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified metting room order exists in the database.
|
||||
func (a *MettingRoomOrder) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetMettingRoomOrderDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new metting room order.
|
||||
func (a *MettingRoomOrder) Create(ctx context.Context, item *schema.MettingRoomOrder) error {
|
||||
result := GetMettingRoomOrderDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified metting room order in the database.
|
||||
func (a *MettingRoomOrder) Update(ctx context.Context, item *schema.MettingRoomOrder) error {
|
||||
result := GetMettingRoomOrderDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified metting room order from the database.
|
||||
func (a *MettingRoomOrder) Delete(ctx context.Context, id string) error {
|
||||
result := GetMettingRoomOrderDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.MettingRoomOrder))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/notice.dal.go
Normal file
83
internal/mods/common/dal/notice.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get notice storage instance
|
||||
func GetNoticeDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.Notice))
|
||||
}
|
||||
|
||||
// Defining the `Notice` data access object.
|
||||
type Notice struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query notices from the database based on the provided parameters and options.
|
||||
func (a *Notice) Query(ctx context.Context, params schema.NoticeQueryParam, opts ...schema.NoticeQueryOptions) (*schema.NoticeQueryResult, error) {
|
||||
var opt schema.NoticeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetNoticeDB(ctx, a.DB)
|
||||
|
||||
var list schema.Notices
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.NoticeQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified notice from the database.
|
||||
func (a *Notice) Get(ctx context.Context, id string, opts ...schema.NoticeQueryOptions) (*schema.Notice, error) {
|
||||
var opt schema.NoticeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.Notice)
|
||||
ok, err := util.FindOne(ctx, GetNoticeDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified notice exists in the database.
|
||||
func (a *Notice) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetNoticeDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new notice.
|
||||
func (a *Notice) Create(ctx context.Context, item *schema.Notice) error {
|
||||
result := GetNoticeDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified notice in the database.
|
||||
func (a *Notice) Update(ctx context.Context, item *schema.Notice) error {
|
||||
result := GetNoticeDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified notice from the database.
|
||||
func (a *Notice) Delete(ctx context.Context, id string) error {
|
||||
result := GetNoticeDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.Notice))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/surrounding_service.dal.go
Normal file
83
internal/mods/common/dal/surrounding_service.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get surrounding service storage instance
|
||||
func GetSurroundingServiceDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.SurroundingService))
|
||||
}
|
||||
|
||||
// Defining the `SurroundingService` data access object.
|
||||
type SurroundingService struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query surrounding services from the database based on the provided parameters and options.
|
||||
func (a *SurroundingService) Query(ctx context.Context, params schema.SurroundingServiceQueryParam, opts ...schema.SurroundingServiceQueryOptions) (*schema.SurroundingServiceQueryResult, error) {
|
||||
var opt schema.SurroundingServiceQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetSurroundingServiceDB(ctx, a.DB)
|
||||
|
||||
var list schema.SurroundingServices
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.SurroundingServiceQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified surrounding service from the database.
|
||||
func (a *SurroundingService) Get(ctx context.Context, id string, opts ...schema.SurroundingServiceQueryOptions) (*schema.SurroundingService, error) {
|
||||
var opt schema.SurroundingServiceQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.SurroundingService)
|
||||
ok, err := util.FindOne(ctx, GetSurroundingServiceDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified surrounding service exists in the database.
|
||||
func (a *SurroundingService) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetSurroundingServiceDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new surrounding service.
|
||||
func (a *SurroundingService) Create(ctx context.Context, item *schema.SurroundingService) error {
|
||||
result := GetSurroundingServiceDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified surrounding service in the database.
|
||||
func (a *SurroundingService) Update(ctx context.Context, item *schema.SurroundingService) error {
|
||||
result := GetSurroundingServiceDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified surrounding service from the database.
|
||||
func (a *SurroundingService) Delete(ctx context.Context, id string) error {
|
||||
result := GetSurroundingServiceDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.SurroundingService))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/surrounding_service_type.dal.go
Normal file
83
internal/mods/common/dal/surrounding_service_type.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get surrounding service type storage instance
|
||||
func GetSurroundingServiceTypeDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.SurroundingServiceType))
|
||||
}
|
||||
|
||||
// Defining the `SurroundingServiceType` data access object.
|
||||
type SurroundingServiceType struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query surrounding service types from the database based on the provided parameters and options.
|
||||
func (a *SurroundingServiceType) Query(ctx context.Context, params schema.SurroundingServiceTypeQueryParam, opts ...schema.SurroundingServiceTypeQueryOptions) (*schema.SurroundingServiceTypeQueryResult, error) {
|
||||
var opt schema.SurroundingServiceTypeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetSurroundingServiceTypeDB(ctx, a.DB)
|
||||
|
||||
var list schema.SurroundingServiceTypes
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.SurroundingServiceTypeQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified surrounding service type from the database.
|
||||
func (a *SurroundingServiceType) Get(ctx context.Context, id string, opts ...schema.SurroundingServiceTypeQueryOptions) (*schema.SurroundingServiceType, error) {
|
||||
var opt schema.SurroundingServiceTypeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.SurroundingServiceType)
|
||||
ok, err := util.FindOne(ctx, GetSurroundingServiceTypeDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified surrounding service type exists in the database.
|
||||
func (a *SurroundingServiceType) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetSurroundingServiceTypeDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new surrounding service type.
|
||||
func (a *SurroundingServiceType) Create(ctx context.Context, item *schema.SurroundingServiceType) error {
|
||||
result := GetSurroundingServiceTypeDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified surrounding service type in the database.
|
||||
func (a *SurroundingServiceType) Update(ctx context.Context, item *schema.SurroundingServiceType) error {
|
||||
result := GetSurroundingServiceTypeDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified surrounding service type from the database.
|
||||
func (a *SurroundingServiceType) Delete(ctx context.Context, id string) error {
|
||||
result := GetSurroundingServiceTypeDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.SurroundingServiceType))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/web_site.dal.go
Normal file
83
internal/mods/common/dal/web_site.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get web site storage instance
|
||||
func GetWebSiteDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.WebSite))
|
||||
}
|
||||
|
||||
// Defining the `WebSite` data access object.
|
||||
type WebSite struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query web sites from the database based on the provided parameters and options.
|
||||
func (a *WebSite) Query(ctx context.Context, params schema.WebSiteQueryParam, opts ...schema.WebSiteQueryOptions) (*schema.WebSiteQueryResult, error) {
|
||||
var opt schema.WebSiteQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetWebSiteDB(ctx, a.DB)
|
||||
|
||||
var list schema.WebSites
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.WebSiteQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified web site from the database.
|
||||
func (a *WebSite) Get(ctx context.Context, id string, opts ...schema.WebSiteQueryOptions) (*schema.WebSite, error) {
|
||||
var opt schema.WebSiteQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.WebSite)
|
||||
ok, err := util.FindOne(ctx, GetWebSiteDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified web site exists in the database.
|
||||
func (a *WebSite) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetWebSiteDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new web site.
|
||||
func (a *WebSite) Create(ctx context.Context, item *schema.WebSite) error {
|
||||
result := GetWebSiteDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified web site in the database.
|
||||
func (a *WebSite) Update(ctx context.Context, item *schema.WebSite) error {
|
||||
result := GetWebSiteDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified web site from the database.
|
||||
func (a *WebSite) Delete(ctx context.Context, id string) error {
|
||||
result := GetWebSiteDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.WebSite))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/work_order.dal.go
Normal file
83
internal/mods/common/dal/work_order.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get work order storage instance
|
||||
func GetWorkOrderDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.WorkOrder))
|
||||
}
|
||||
|
||||
// Defining the `WorkOrder` data access object.
|
||||
type WorkOrder struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query work orders from the database based on the provided parameters and options.
|
||||
func (a *WorkOrder) Query(ctx context.Context, params schema.WorkOrderQueryParam, opts ...schema.WorkOrderQueryOptions) (*schema.WorkOrderQueryResult, error) {
|
||||
var opt schema.WorkOrderQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetWorkOrderDB(ctx, a.DB)
|
||||
|
||||
var list schema.WorkOrders
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.WorkOrderQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified work order from the database.
|
||||
func (a *WorkOrder) Get(ctx context.Context, id string, opts ...schema.WorkOrderQueryOptions) (*schema.WorkOrder, error) {
|
||||
var opt schema.WorkOrderQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.WorkOrder)
|
||||
ok, err := util.FindOne(ctx, GetWorkOrderDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified work order exists in the database.
|
||||
func (a *WorkOrder) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetWorkOrderDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new work order.
|
||||
func (a *WorkOrder) Create(ctx context.Context, item *schema.WorkOrder) error {
|
||||
result := GetWorkOrderDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified work order in the database.
|
||||
func (a *WorkOrder) Update(ctx context.Context, item *schema.WorkOrder) error {
|
||||
result := GetWorkOrderDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified work order from the database.
|
||||
func (a *WorkOrder) Delete(ctx context.Context, id string) error {
|
||||
result := GetWorkOrderDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.WorkOrder))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
83
internal/mods/common/dal/work_order_type.dal.go
Normal file
83
internal/mods/common/dal/work_order_type.dal.go
Normal file
@ -0,0 +1,83 @@
|
||||
package dal
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Get work order type storage instance
|
||||
func GetWorkOrderTypeDB(ctx context.Context, defDB *gorm.DB) *gorm.DB {
|
||||
return util.GetDB(ctx, defDB).Model(new(schema.WorkOrderType))
|
||||
}
|
||||
|
||||
// Defining the `WorkOrderType` data access object.
|
||||
type WorkOrderType struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
// Query work order types from the database based on the provided parameters and options.
|
||||
func (a *WorkOrderType) Query(ctx context.Context, params schema.WorkOrderTypeQueryParam, opts ...schema.WorkOrderTypeQueryOptions) (*schema.WorkOrderTypeQueryResult, error) {
|
||||
var opt schema.WorkOrderTypeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
db := GetWorkOrderTypeDB(ctx, a.DB)
|
||||
|
||||
var list schema.WorkOrderTypes
|
||||
pageResult, err := util.WrapPageQuery(ctx, db, params.PaginationParam, opt.QueryOptions, &list)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
}
|
||||
|
||||
queryResult := &schema.WorkOrderTypeQueryResult{
|
||||
PageResult: pageResult,
|
||||
Data: list,
|
||||
}
|
||||
return queryResult, nil
|
||||
}
|
||||
|
||||
// Get the specified work order type from the database.
|
||||
func (a *WorkOrderType) Get(ctx context.Context, id string, opts ...schema.WorkOrderTypeQueryOptions) (*schema.WorkOrderType, error) {
|
||||
var opt schema.WorkOrderTypeQueryOptions
|
||||
if len(opts) > 0 {
|
||||
opt = opts[0]
|
||||
}
|
||||
|
||||
item := new(schema.WorkOrderType)
|
||||
ok, err := util.FindOne(ctx, GetWorkOrderTypeDB(ctx, a.DB).Where("id=?", id), opt.QueryOptions, item)
|
||||
if err != nil {
|
||||
return nil, errors.WithStack(err)
|
||||
} else if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
return item, nil
|
||||
}
|
||||
|
||||
// Exists checks if the specified work order type exists in the database.
|
||||
func (a *WorkOrderType) Exists(ctx context.Context, id string) (bool, error) {
|
||||
ok, err := util.Exists(ctx, GetWorkOrderTypeDB(ctx, a.DB).Where("id=?", id))
|
||||
return ok, errors.WithStack(err)
|
||||
}
|
||||
|
||||
// Create a new work order type.
|
||||
func (a *WorkOrderType) Create(ctx context.Context, item *schema.WorkOrderType) error {
|
||||
result := GetWorkOrderTypeDB(ctx, a.DB).Create(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Update the specified work order type in the database.
|
||||
func (a *WorkOrderType) Update(ctx context.Context, item *schema.WorkOrderType) error {
|
||||
result := GetWorkOrderTypeDB(ctx, a.DB).Where("id=?", item.ID).Select("*").Omit("created_at").Updates(item)
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
|
||||
// Delete the specified work order type from the database.
|
||||
func (a *WorkOrderType) Delete(ctx context.Context, id string) error {
|
||||
result := GetWorkOrderTypeDB(ctx, a.DB).Where("id=?", id).Delete(new(schema.WorkOrderType))
|
||||
return errors.WithStack(result.Error)
|
||||
}
|
||||
127
internal/mods/common/main.go
Normal file
127
internal/mods/common/main.go
Normal file
@ -0,0 +1,127 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/config"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/schema"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Common struct {
|
||||
DB *gorm.DB
|
||||
BannerAPI *api.Banner
|
||||
NoticeAPI *api.Notice
|
||||
WorkOrderAPI *api.WorkOrder
|
||||
WorkOrderTypeAPI *api.WorkOrderType
|
||||
SurroundingServiceAPI *api.SurroundingService
|
||||
SurroundingServiceTypeAPI *api.SurroundingServiceType
|
||||
WebSiteAPI *api.WebSite
|
||||
HelpAPI *api.Help
|
||||
MettingRoomAPI *api.MettingRoom
|
||||
MettingRoomOrderAPI *api.MettingRoomOrder
|
||||
}
|
||||
|
||||
func (a *Common) AutoMigrate(ctx context.Context) error {
|
||||
return a.DB.AutoMigrate(new(schema.Banner), new(schema.Notice), new(schema.WorkOrder), new(schema.WorkOrderType), new(schema.SurroundingService), new(schema.SurroundingServiceType), new(schema.WebSite), new(schema.Help), new(schema.MettingRoom), new(schema.MettingRoomOrder))
|
||||
}
|
||||
|
||||
func (a *Common) Init(ctx context.Context) error {
|
||||
if config.C.Storage.DB.AutoMigrate {
|
||||
if err := a.AutoMigrate(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Common) RegisterV1Routers(ctx context.Context, v1 *gin.RouterGroup) error {
|
||||
banner := v1.Group("banners")
|
||||
{
|
||||
banner.GET("", a.BannerAPI.Query)
|
||||
banner.GET(":id", a.BannerAPI.Get)
|
||||
banner.POST("", a.BannerAPI.Create)
|
||||
banner.PUT(":id", a.BannerAPI.Update)
|
||||
banner.DELETE(":id", a.BannerAPI.Delete)
|
||||
}
|
||||
notice := v1.Group("notices")
|
||||
{
|
||||
notice.GET("", a.NoticeAPI.Query)
|
||||
notice.GET(":id", a.NoticeAPI.Get)
|
||||
notice.POST("", a.NoticeAPI.Create)
|
||||
notice.PUT(":id", a.NoticeAPI.Update)
|
||||
notice.DELETE(":id", a.NoticeAPI.Delete)
|
||||
}
|
||||
workOrder := v1.Group("work-orders")
|
||||
{
|
||||
workOrder.GET("", a.WorkOrderAPI.Query)
|
||||
workOrder.GET(":id", a.WorkOrderAPI.Get)
|
||||
workOrder.POST("", a.WorkOrderAPI.Create)
|
||||
workOrder.PUT(":id", a.WorkOrderAPI.Update)
|
||||
workOrder.DELETE(":id", a.WorkOrderAPI.Delete)
|
||||
}
|
||||
workOrderType := v1.Group("work-order-types")
|
||||
{
|
||||
workOrderType.GET("", a.WorkOrderTypeAPI.Query)
|
||||
workOrderType.GET(":id", a.WorkOrderTypeAPI.Get)
|
||||
workOrderType.POST("", a.WorkOrderTypeAPI.Create)
|
||||
workOrderType.PUT(":id", a.WorkOrderTypeAPI.Update)
|
||||
workOrderType.DELETE(":id", a.WorkOrderTypeAPI.Delete)
|
||||
}
|
||||
surroundingService := v1.Group("surrounding-services")
|
||||
{
|
||||
surroundingService.GET("", a.SurroundingServiceAPI.Query)
|
||||
surroundingService.GET(":id", a.SurroundingServiceAPI.Get)
|
||||
surroundingService.POST("", a.SurroundingServiceAPI.Create)
|
||||
surroundingService.PUT(":id", a.SurroundingServiceAPI.Update)
|
||||
surroundingService.DELETE(":id", a.SurroundingServiceAPI.Delete)
|
||||
}
|
||||
surroundingServiceType := v1.Group("surrounding-service-types")
|
||||
{
|
||||
surroundingServiceType.GET("", a.SurroundingServiceTypeAPI.Query)
|
||||
surroundingServiceType.GET(":id", a.SurroundingServiceTypeAPI.Get)
|
||||
surroundingServiceType.POST("", a.SurroundingServiceTypeAPI.Create)
|
||||
surroundingServiceType.PUT(":id", a.SurroundingServiceTypeAPI.Update)
|
||||
surroundingServiceType.DELETE(":id", a.SurroundingServiceTypeAPI.Delete)
|
||||
}
|
||||
webSite := v1.Group("web-sites")
|
||||
{
|
||||
webSite.GET("", a.WebSiteAPI.Query)
|
||||
webSite.GET(":id", a.WebSiteAPI.Get)
|
||||
webSite.POST("", a.WebSiteAPI.Create)
|
||||
webSite.PUT(":id", a.WebSiteAPI.Update)
|
||||
webSite.DELETE(":id", a.WebSiteAPI.Delete)
|
||||
}
|
||||
help := v1.Group("helps")
|
||||
{
|
||||
help.GET("", a.HelpAPI.Query)
|
||||
help.GET(":id", a.HelpAPI.Get)
|
||||
help.POST("", a.HelpAPI.Create)
|
||||
help.PUT(":id", a.HelpAPI.Update)
|
||||
help.DELETE(":id", a.HelpAPI.Delete)
|
||||
}
|
||||
mettingRoom := v1.Group("metting-rooms")
|
||||
{
|
||||
mettingRoom.GET("", a.MettingRoomAPI.Query)
|
||||
mettingRoom.GET(":id", a.MettingRoomAPI.Get)
|
||||
mettingRoom.POST("", a.MettingRoomAPI.Create)
|
||||
mettingRoom.PUT(":id", a.MettingRoomAPI.Update)
|
||||
mettingRoom.DELETE(":id", a.MettingRoomAPI.Delete)
|
||||
}
|
||||
mettingRoomOrder := v1.Group("metting-room-orders")
|
||||
{
|
||||
mettingRoomOrder.GET("", a.MettingRoomOrderAPI.Query)
|
||||
mettingRoomOrder.GET(":id", a.MettingRoomOrderAPI.Get)
|
||||
mettingRoomOrder.POST("", a.MettingRoomOrderAPI.Create)
|
||||
mettingRoomOrder.PUT(":id", a.MettingRoomOrderAPI.Update)
|
||||
mettingRoomOrder.DELETE(":id", a.MettingRoomOrderAPI.Delete)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *Common) Release(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
74
internal/mods/common/schema/banner.go
Normal file
74
internal/mods/common/schema/banner.go
Normal file
@ -0,0 +1,74 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `Banner` struct.
|
||||
type Banner struct {
|
||||
util.BaseModel
|
||||
Title string `json:"title" gorm:"size:128;index;comment:标题"`
|
||||
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
|
||||
Img string `json:"img" gorm:"size:2048;comment:图片"`
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Typer string `json:"type" gorm:"index;comment:类型"`
|
||||
Link string `json:"link" gorm:"size:2048;comment:链接"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *Banner) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Banner` struct.
|
||||
type BannerQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `Banner` struct.
|
||||
type BannerQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `Banner` struct.
|
||||
type BannerQueryResult struct {
|
||||
Data Banners
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `Banner` struct.
|
||||
type Banners []*Banner
|
||||
|
||||
// Defining the data structure for creating a `Banner` struct.
|
||||
type BannerForm struct {
|
||||
Title string `json:"title"`
|
||||
Desc string `json:"desc"`
|
||||
Img string `json:"img"`
|
||||
Sequence int `json:"sequence"`
|
||||
Link string `json:"link"`
|
||||
Typer string `json:"type"`
|
||||
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `BannerForm` struct.
|
||||
func (a *BannerForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `BannerForm` to `Banner` object.
|
||||
func (a *BannerForm) FillTo(banner *Banner) error {
|
||||
banner.Title = a.Title
|
||||
banner.Desc = a.Desc
|
||||
banner.Img = a.Img
|
||||
banner.Sequence = a.Sequence
|
||||
banner.Link = a.Link
|
||||
banner.Typer = a.Typer
|
||||
banner.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
59
internal/mods/common/schema/help.go
Normal file
59
internal/mods/common/schema/help.go
Normal file
@ -0,0 +1,59 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `Help` struct.
|
||||
type Help struct {
|
||||
util.BaseModel
|
||||
CustomerID string `json:"customerId" gorm:"type:char(36);index;comment:客户id"`
|
||||
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
|
||||
Img string `json:"img" gorm:"size:2048;comment:图片"`
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Typer string `json:"type" gorm:"index;comment:类型"`
|
||||
Link string `json:"link" gorm:"size:2048;comment:链接"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *Help) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Help` struct.
|
||||
type HelpQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `Help` struct.
|
||||
type HelpQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `Help` struct.
|
||||
type HelpQueryResult struct {
|
||||
Data Helps
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `Help` struct.
|
||||
type Helps []*Help
|
||||
|
||||
// Defining the data structure for creating a `Help` struct.
|
||||
type HelpForm struct {
|
||||
}
|
||||
|
||||
// A validation function for the `HelpForm` struct.
|
||||
func (a *HelpForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `HelpForm` to `Help` object.
|
||||
func (a *HelpForm) FillTo(help *Help) error {
|
||||
return nil
|
||||
}
|
||||
70
internal/mods/common/schema/metting_room.go
Normal file
70
internal/mods/common/schema/metting_room.go
Normal file
@ -0,0 +1,70 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoom` struct.
|
||||
type MettingRoom struct {
|
||||
util.BaseModel
|
||||
Title string `json:"title" gorm:"size:128;index;comment:标题"`
|
||||
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
|
||||
Imgs []*string `json:"imgs" gorm:"size:2048;comment:图片"`
|
||||
MaxNum int `json:"maxNum" gorm:"comment:容纳人数"`
|
||||
Link string `json:"link" gorm:"size:2048;comment:链接"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *MettingRoom) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `MettingRoom` struct.
|
||||
type MettingRoomQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `MettingRoom` struct.
|
||||
type MettingRoomQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `MettingRoom` struct.
|
||||
type MettingRoomQueryResult struct {
|
||||
Data MettingRooms
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `MettingRoom` struct.
|
||||
type MettingRooms []*MettingRoom
|
||||
|
||||
// Defining the data structure for creating a `MettingRoom` struct.
|
||||
type MettingRoomForm struct {
|
||||
Title string `json:"title"`
|
||||
Desc string `json:"desc" `
|
||||
Imgs []*string `json:"imgs" `
|
||||
MaxNum int `json:"maxNum" `
|
||||
Link string `json:"link" `
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `MettingRoomForm` struct.
|
||||
func (a *MettingRoomForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `MettingRoomForm` to `MettingRoom` object.
|
||||
func (a *MettingRoomForm) FillTo(mettingRoom *MettingRoom) error {
|
||||
mettingRoom.Title = a.Title
|
||||
mettingRoom.Desc = a.Desc
|
||||
mettingRoom.Imgs = a.Imgs
|
||||
mettingRoom.MaxNum = a.MaxNum
|
||||
mettingRoom.Link = a.Link
|
||||
mettingRoom.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
74
internal/mods/common/schema/metting_room_order.go
Normal file
74
internal/mods/common/schema/metting_room_order.go
Normal file
@ -0,0 +1,74 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Defining the `MettingRoomOrder` struct.
|
||||
type MettingRoomOrder struct {
|
||||
util.BaseModel
|
||||
RoomID string `json:"roomId" gorm:"type:char(36);index;not null;comment:会议室id"`
|
||||
CustomerID string `json:"customerId" gorm:"type:char(36);index;not null;comment:用户id"`
|
||||
ConcatName string `json:"concatName" gorm:"type:varchar(255);comment:联系人"`
|
||||
ConcatPhone string `json:"concatPhone" gorm:"type:varchar(255);comment:联系手机号"`
|
||||
StartAt *time.Time `json:"startAt" gorm:"type:datetime;comment:开始时间"`
|
||||
EndAt *time.Time `json:"endAt" gorm:"type:datetime;comment:结束时间"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *MettingRoomOrder) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `MettingRoomOrder` struct.
|
||||
type MettingRoomOrderQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `MettingRoomOrder` struct.
|
||||
type MettingRoomOrderQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `MettingRoomOrder` struct.
|
||||
type MettingRoomOrderQueryResult struct {
|
||||
Data MettingRoomOrders
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `MettingRoomOrder` struct.
|
||||
type MettingRoomOrders []*MettingRoomOrder
|
||||
|
||||
// Defining the data structure for creating a `MettingRoomOrder` struct.
|
||||
type MettingRoomOrderForm struct {
|
||||
RoomID string `json:"roomId" `
|
||||
CustomerID string `json:"customerId" `
|
||||
ConcatName string `json:"concatName"`
|
||||
ConcatPhone string `json:"concatPhone"`
|
||||
StartAt *time.Time `json:"startAt" `
|
||||
EndAt *time.Time `json:"endAt" `
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `MettingRoomOrderForm` struct.
|
||||
func (a *MettingRoomOrderForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `MettingRoomOrderForm` to `MettingRoomOrder` object.
|
||||
func (a *MettingRoomOrderForm) FillTo(mettingRoomOrder *MettingRoomOrder) error {
|
||||
mettingRoomOrder.RoomID = a.RoomID
|
||||
mettingRoomOrder.CustomerID = a.CustomerID
|
||||
mettingRoomOrder.ConcatName = a.ConcatName
|
||||
mettingRoomOrder.ConcatPhone = a.ConcatPhone
|
||||
mettingRoomOrder.StartAt = a.StartAt
|
||||
mettingRoomOrder.EndAt = a.EndAt
|
||||
mettingRoomOrder.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
67
internal/mods/common/schema/notice.go
Normal file
67
internal/mods/common/schema/notice.go
Normal file
@ -0,0 +1,67 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `Notice` struct.
|
||||
type Notice struct {
|
||||
util.BaseModel
|
||||
Title string `json:"title" gorm:"size:128;index;comment:标题"`
|
||||
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Link string `json:"link" gorm:"size:2048;comment:链接"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *Notice) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `Notice` struct.
|
||||
type NoticeQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `Notice` struct.
|
||||
type NoticeQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `Notice` struct.
|
||||
type NoticeQueryResult struct {
|
||||
Data Notices
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `Notice` struct.
|
||||
type Notices []*Notice
|
||||
|
||||
// Defining the data structure for creating a `Notice` struct.
|
||||
type NoticeForm struct {
|
||||
Title string `json:"title"`
|
||||
Desc string `json:"desc"`
|
||||
Sequence int `json:"sequence"`
|
||||
Link string `json:"link"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `NoticeForm` struct.
|
||||
func (a *NoticeForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `NoticeForm` to `Notice` object.
|
||||
func (a *NoticeForm) FillTo(notice *Notice) error {
|
||||
notice.Title = a.Title
|
||||
notice.Desc = a.Desc
|
||||
notice.Sequence = a.Sequence
|
||||
notice.Link = a.Link
|
||||
notice.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
76
internal/mods/common/schema/surrounding_service.go
Normal file
76
internal/mods/common/schema/surrounding_service.go
Normal file
@ -0,0 +1,76 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingService` struct.
|
||||
type SurroundingService struct {
|
||||
util.BaseModel
|
||||
TypeID string `json:"typeId" gorm:"type:char(36);index;not null;comment:分类id"`
|
||||
Title string `json:"title" gorm:"size:128;index;comment:标题"`
|
||||
Desc string `json:"desc" gorm:"size:128;comment:介绍"`
|
||||
Img string `json:"img" gorm:"size:2048;comment:图片"`
|
||||
Content string `json:"content" gorm:"type:text;comment:内容"`
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Link string `json:"link" gorm:"size:2048;comment:链接"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *SurroundingService) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `SurroundingService` struct.
|
||||
type SurroundingServiceQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `SurroundingService` struct.
|
||||
type SurroundingServiceQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `SurroundingService` struct.
|
||||
type SurroundingServiceQueryResult struct {
|
||||
Data SurroundingServices
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `SurroundingService` struct.
|
||||
type SurroundingServices []*SurroundingService
|
||||
|
||||
// Defining the data structure for creating a `SurroundingService` struct.
|
||||
type SurroundingServiceForm struct {
|
||||
TypeID string `json:"typeId" `
|
||||
Title string `json:"title" `
|
||||
Desc string `json:"desc" `
|
||||
Img string `json:"img" `
|
||||
Content string `json:"content" `
|
||||
Sequence int `json:"sequence"`
|
||||
Link string `json:"link"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `SurroundingServiceForm` struct.
|
||||
func (a *SurroundingServiceForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `SurroundingServiceForm` to `SurroundingService` object.
|
||||
func (a *SurroundingServiceForm) FillTo(surroundingService *SurroundingService) error {
|
||||
surroundingService.TypeID = a.TypeID
|
||||
surroundingService.Title = a.Title
|
||||
surroundingService.Desc = a.Desc
|
||||
surroundingService.Img = a.Img
|
||||
surroundingService.Content = a.Content
|
||||
surroundingService.Sequence = a.Sequence
|
||||
surroundingService.Link = a.Link
|
||||
surroundingService.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
62
internal/mods/common/schema/surrounding_service_type.go
Normal file
62
internal/mods/common/schema/surrounding_service_type.go
Normal file
@ -0,0 +1,62 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `SurroundingServiceType` struct.
|
||||
type SurroundingServiceType struct {
|
||||
util.BaseModel
|
||||
Name string `json:"name" gorm:"size:1024;comment:名字" `
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *SurroundingServiceType) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `SurroundingServiceType` struct.
|
||||
type SurroundingServiceTypeQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `SurroundingServiceType` struct.
|
||||
type SurroundingServiceTypeQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `SurroundingServiceType` struct.
|
||||
type SurroundingServiceTypeQueryResult struct {
|
||||
Data SurroundingServiceTypes
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `SurroundingServiceType` struct.
|
||||
type SurroundingServiceTypes []*SurroundingServiceType
|
||||
|
||||
// Defining the data structure for creating a `SurroundingServiceType` struct.
|
||||
type SurroundingServiceTypeForm struct {
|
||||
Name string `json:"name" `
|
||||
Sequence int `json:"sequence"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `SurroundingServiceTypeForm` struct.
|
||||
func (a *SurroundingServiceTypeForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `SurroundingServiceTypeForm` to `SurroundingServiceType` object.
|
||||
func (a *SurroundingServiceTypeForm) FillTo(surroundingServiceType *SurroundingServiceType) error {
|
||||
surroundingServiceType.Name = a.Name
|
||||
surroundingServiceType.Sequence = a.Sequence
|
||||
surroundingServiceType.Status = a.Status
|
||||
|
||||
return nil
|
||||
}
|
||||
55
internal/mods/common/schema/web_site.go
Normal file
55
internal/mods/common/schema/web_site.go
Normal file
@ -0,0 +1,55 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `WebSite` struct.
|
||||
type WebSite struct {
|
||||
util.BaseModel
|
||||
Phone string `json:"phone" gorm:"size:128;comment:联系电话"`
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `WebSite` struct.
|
||||
type WebSiteQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
func (c *WebSite) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query options for the `WebSite` struct.
|
||||
type WebSiteQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `WebSite` struct.
|
||||
type WebSiteQueryResult struct {
|
||||
Data WebSites
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `WebSite` struct.
|
||||
type WebSites []*WebSite
|
||||
|
||||
// Defining the data structure for creating a `WebSite` struct.
|
||||
type WebSiteForm struct {
|
||||
Phone string `json:"phone"`
|
||||
}
|
||||
|
||||
// A validation function for the `WebSiteForm` struct.
|
||||
func (a *WebSiteForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `WebSiteForm` to `WebSite` object.
|
||||
func (a *WebSiteForm) FillTo(webSite *WebSite) error {
|
||||
webSite.Phone = a.Phone
|
||||
return nil
|
||||
}
|
||||
77
internal/mods/common/schema/work_order.go
Normal file
77
internal/mods/common/schema/work_order.go
Normal file
@ -0,0 +1,77 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrder` struct.
|
||||
type WorkOrder struct {
|
||||
util.BaseModel
|
||||
CustomerID string `json:"customerId" gorm:"type:char(36);index;comment:客户id"`
|
||||
Content string `json:"content" gorm:"type:text;comment:工单内容"`
|
||||
Images *[]string `json:"images" gorm:"serializer:json;comment:图片数组"`
|
||||
Videos *[]string `json:"videos" gorm:"serializer:json;comment:视频数组"`
|
||||
Records *[]Record `json:"records" gorm:"serializer:json;comment:回复记录"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
type Record struct {
|
||||
Sender string `json:"sender"`
|
||||
Content string `json:"content"`
|
||||
SendAt string `json:"sendAt"`
|
||||
}
|
||||
|
||||
func (c *WorkOrder) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `WorkOrder` struct.
|
||||
type WorkOrderQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `WorkOrder` struct.
|
||||
type WorkOrderQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `WorkOrder` struct.
|
||||
type WorkOrderQueryResult struct {
|
||||
Data WorkOrders
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `WorkOrder` struct.
|
||||
type WorkOrders []*WorkOrder
|
||||
|
||||
// Defining the data structure for creating a `WorkOrder` struct.
|
||||
type WorkOrderForm struct {
|
||||
CustomerID string `json:"customerId"`
|
||||
Content string `json:"content"`
|
||||
Images *[]string `json:"images"`
|
||||
Videos *[]string `json:"videos"`
|
||||
Records *[]Record `json:"records"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `WorkOrderForm` struct.
|
||||
func (a *WorkOrderForm) Validate() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `WorkOrderForm` to `WorkOrder` object.
|
||||
func (a *WorkOrderForm) FillTo(workOrder *WorkOrder) error {
|
||||
workOrder.CustomerID = a.CustomerID
|
||||
workOrder.Content = a.Content
|
||||
workOrder.Images = a.Images
|
||||
workOrder.Videos = a.Videos
|
||||
workOrder.Records = a.Records
|
||||
workOrder.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
61
internal/mods/common/schema/work_order_type.go
Normal file
61
internal/mods/common/schema/work_order_type.go
Normal file
@ -0,0 +1,61 @@
|
||||
package schema
|
||||
|
||||
import (
|
||||
"github.com/google/uuid"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// Defining the `WorkOrderType` struct.
|
||||
type WorkOrderType struct {
|
||||
util.BaseModel
|
||||
Name string `json:"name" gorm:"size:1024;comment:名字" `
|
||||
Sequence int `json:"sequence" gorm:"index;default:0;comment:排序"`
|
||||
Status string `json:"status" gorm:"size:20;index;comment:状态"`
|
||||
}
|
||||
|
||||
func (c *WorkOrderType) BeforeCreate(tx *gorm.DB) (err error) {
|
||||
if c.ID == "" {
|
||||
c.ID = uuid.New().String()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// Defining the query parameters for the `WorkOrderType` struct.
|
||||
type WorkOrderTypeQueryParam struct {
|
||||
util.PaginationParam
|
||||
}
|
||||
|
||||
// Defining the query options for the `WorkOrderType` struct.
|
||||
type WorkOrderTypeQueryOptions struct {
|
||||
util.QueryOptions
|
||||
}
|
||||
|
||||
// Defining the query result for the `WorkOrderType` struct.
|
||||
type WorkOrderTypeQueryResult struct {
|
||||
Data WorkOrderTypes
|
||||
PageResult *util.PaginationResult
|
||||
}
|
||||
|
||||
// Defining the slice of `WorkOrderType` struct.
|
||||
type WorkOrderTypes []*WorkOrderType
|
||||
|
||||
// Defining the data structure for creating a `WorkOrderType` struct.
|
||||
type WorkOrderTypeForm struct {
|
||||
Name string `json:"name" `
|
||||
Sequence int `json:"sequence"`
|
||||
Status string `json:"status"`
|
||||
}
|
||||
|
||||
// A validation function for the `WorkOrderTypeForm` struct.
|
||||
func (a *WorkOrderTypeForm) Validate() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Convert `WorkOrderTypeForm` to `WorkOrderType` object.
|
||||
func (a *WorkOrderTypeForm) FillTo(workOrderType *WorkOrderType) error {
|
||||
workOrderType.Name = a.Name
|
||||
workOrderType.Sequence = a.Sequence
|
||||
workOrderType.Status = a.Status
|
||||
return nil
|
||||
}
|
||||
42
internal/mods/common/wire.go
Normal file
42
internal/mods/common/wire.go
Normal file
@ -0,0 +1,42 @@
|
||||
package common
|
||||
|
||||
import (
|
||||
"github.com/google/wire"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/api"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/common/dal"
|
||||
)
|
||||
|
||||
var Set = wire.NewSet(
|
||||
wire.Struct(new(Common), "*"),
|
||||
wire.Struct(new(dal.Banner), "*"),
|
||||
wire.Struct(new(biz.Banner), "*"),
|
||||
wire.Struct(new(api.Banner), "*"),
|
||||
wire.Struct(new(dal.Notice), "*"),
|
||||
wire.Struct(new(biz.Notice), "*"),
|
||||
wire.Struct(new(api.Notice), "*"),
|
||||
wire.Struct(new(dal.WorkOrder), "*"),
|
||||
wire.Struct(new(biz.WorkOrder), "*"),
|
||||
wire.Struct(new(api.WorkOrder), "*"),
|
||||
wire.Struct(new(dal.WorkOrderType), "*"),
|
||||
wire.Struct(new(biz.WorkOrderType), "*"),
|
||||
wire.Struct(new(api.WorkOrderType), "*"),
|
||||
wire.Struct(new(dal.SurroundingService), "*"),
|
||||
wire.Struct(new(biz.SurroundingService), "*"),
|
||||
wire.Struct(new(api.SurroundingService), "*"),
|
||||
wire.Struct(new(dal.SurroundingServiceType), "*"),
|
||||
wire.Struct(new(biz.SurroundingServiceType), "*"),
|
||||
wire.Struct(new(api.SurroundingServiceType), "*"),
|
||||
wire.Struct(new(dal.WebSite), "*"),
|
||||
wire.Struct(new(biz.WebSite), "*"),
|
||||
wire.Struct(new(api.WebSite), "*"),
|
||||
wire.Struct(new(dal.Help), "*"),
|
||||
wire.Struct(new(biz.Help), "*"),
|
||||
wire.Struct(new(api.Help), "*"),
|
||||
wire.Struct(new(dal.MettingRoom), "*"),
|
||||
wire.Struct(new(biz.MettingRoom), "*"),
|
||||
wire.Struct(new(api.MettingRoom), "*"),
|
||||
wire.Struct(new(dal.MettingRoomOrder), "*"),
|
||||
wire.Struct(new(biz.MettingRoomOrder), "*"),
|
||||
wire.Struct(new(api.MettingRoomOrder), "*"),
|
||||
)
|
||||
131
internal/mods/customer/api/balance.api.go
Normal file
131
internal/mods/customer/api/balance.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Balance` api.
|
||||
type Balance struct {
|
||||
BalanceBIZ *biz.Balance
|
||||
}
|
||||
|
||||
// @Tags BalanceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query balance list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Balance}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/balances [get]
|
||||
func (a *Balance) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.BalanceQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.BalanceBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags BalanceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get balance record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Balance}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/balances/{id} [get]
|
||||
func (a *Balance) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.BalanceBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags BalanceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create balance record
|
||||
// @Param body body schema.BalanceForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Balance}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/balances [post]
|
||||
func (a *Balance) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.BalanceForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.BalanceBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags BalanceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update balance record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.BalanceForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/balances/{id} [put]
|
||||
func (a *Balance) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.BalanceForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.BalanceBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags BalanceAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete balance record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/balances/{id} [delete]
|
||||
func (a *Balance) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.BalanceBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
131
internal/mods/customer/api/customer.api.go
Normal file
131
internal/mods/customer/api/customer.api.go
Normal file
@ -0,0 +1,131 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/biz"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Customer` api.
|
||||
type Customer struct {
|
||||
CustomerBIZ *biz.Customer
|
||||
}
|
||||
|
||||
// @Tags CustomerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Query customer list
|
||||
// @Param current query int true "pagination index" default(1)
|
||||
// @Param pageSize query int true "pagination size" default(10)
|
||||
// @Success 200 {object} util.ResponseResult{data=[]schema.Customer}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/customers [get]
|
||||
func (a *Customer) Query(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
var params schema.CustomerQueryParam
|
||||
if err := util.ParseQuery(c, ¶ms); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.CustomerBIZ.Query(ctx, params)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResPage(c, result.Data, result.PageResult)
|
||||
}
|
||||
|
||||
// @Tags CustomerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Get customer record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Customer}
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/customers/{id} [get]
|
||||
func (a *Customer) Get(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item, err := a.CustomerBIZ.Get(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, item)
|
||||
}
|
||||
|
||||
// @Tags CustomerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Create customer record
|
||||
// @Param body body schema.CustomerForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult{data=schema.Customer}
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/customers [post]
|
||||
func (a *Customer) Create(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.CustomerForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
result, err := a.CustomerBIZ.Create(ctx, item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResSuccess(c, result)
|
||||
}
|
||||
|
||||
// @Tags CustomerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Update customer record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Param body body schema.CustomerForm true "Request body"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 400 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/customers/{id} [put]
|
||||
func (a *Customer) Update(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
item := new(schema.CustomerForm)
|
||||
if err := util.ParseJSON(c, item); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
} else if err := item.Validate(); err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
|
||||
err := a.CustomerBIZ.Update(ctx, c.Param("id"), item)
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
|
||||
// @Tags CustomerAPI
|
||||
// @Security ApiKeyAuth
|
||||
// @Summary Delete customer record by ID
|
||||
// @Param id path string true "unique id"
|
||||
// @Success 200 {object} util.ResponseResult
|
||||
// @Failure 401 {object} util.ResponseResult
|
||||
// @Failure 500 {object} util.ResponseResult
|
||||
// @Router /api/v1/customers/{id} [delete]
|
||||
func (a *Customer) Delete(c *gin.Context) {
|
||||
ctx := c.Request.Context()
|
||||
err := a.CustomerBIZ.Delete(ctx, c.Param("id"))
|
||||
if err != nil {
|
||||
util.ResError(c, err)
|
||||
return
|
||||
}
|
||||
util.ResOK(c)
|
||||
}
|
||||
104
internal/mods/customer/biz/balance.biz.go
Normal file
104
internal/mods/customer/biz/balance.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Balance` business logic.
|
||||
type Balance struct {
|
||||
Trans *util.Trans
|
||||
BalanceDAL *dal.Balance
|
||||
}
|
||||
|
||||
// Query balances from the data access object based on the provided parameters and options.
|
||||
func (a *Balance) Query(ctx context.Context, params schema.BalanceQueryParam) (*schema.BalanceQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.BalanceDAL.Query(ctx, params, schema.BalanceQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified balance from the data access object.
|
||||
func (a *Balance) Get(ctx context.Context, id string) (*schema.Balance, error) {
|
||||
balance, err := a.BalanceDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if balance == nil {
|
||||
return nil, errors.NotFound("", "Balance not found")
|
||||
}
|
||||
return balance, nil
|
||||
}
|
||||
|
||||
// Create a new balance in the data access object.
|
||||
func (a *Balance) Create(ctx context.Context, formItem *schema.BalanceForm) (*schema.Balance, error) {
|
||||
balance := &schema.Balance{}
|
||||
|
||||
if err := formItem.FillTo(balance); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BalanceDAL.Create(ctx, balance); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return balance, nil
|
||||
}
|
||||
|
||||
// Update the specified balance in the data access object.
|
||||
func (a *Balance) Update(ctx context.Context, id string, formItem *schema.BalanceForm) error {
|
||||
balance, err := a.BalanceDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if balance == nil {
|
||||
return errors.NotFound("", "Balance not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(balance); err != nil {
|
||||
return err
|
||||
}
|
||||
balance.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BalanceDAL.Update(ctx, balance); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified balance from the data access object.
|
||||
func (a *Balance) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.BalanceDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Balance not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.BalanceDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
104
internal/mods/customer/biz/customer.biz.go
Normal file
104
internal/mods/customer/biz/customer.biz.go
Normal file
@ -0,0 +1,104 @@
|
||||
package biz
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/dal"
|
||||
"gitlab.guxuan.icu/jinshan_community/internal/mods/customer/schema"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/errors"
|
||||
"gitlab.guxuan.icu/jinshan_community/pkg/util"
|
||||
)
|
||||
|
||||
// Defining the `Customer` business logic.
|
||||
type Customer struct {
|
||||
Trans *util.Trans
|
||||
CustomerDAL *dal.Customer
|
||||
}
|
||||
|
||||
// Query customers from the data access object based on the provided parameters and options.
|
||||
func (a *Customer) Query(ctx context.Context, params schema.CustomerQueryParam) (*schema.CustomerQueryResult, error) {
|
||||
params.Pagination = true
|
||||
|
||||
result, err := a.CustomerDAL.Query(ctx, params, schema.CustomerQueryOptions{
|
||||
QueryOptions: util.QueryOptions{
|
||||
OrderFields: []util.OrderByParam{
|
||||
{Field: "created_at", Direction: util.DESC},
|
||||
},
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// Get the specified customer from the data access object.
|
||||
func (a *Customer) Get(ctx context.Context, id string) (*schema.Customer, error) {
|
||||
customer, err := a.CustomerDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if customer == nil {
|
||||
return nil, errors.NotFound("", "Customer not found")
|
||||
}
|
||||
return customer, nil
|
||||
}
|
||||
|
||||
// Create a new customer in the data access object.
|
||||
func (a *Customer) Create(ctx context.Context, formItem *schema.CustomerForm) (*schema.Customer, error) {
|
||||
customer := &schema.Customer{}
|
||||
|
||||
if err := formItem.FillTo(customer); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err := a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.CustomerDAL.Create(ctx, customer); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return customer, nil
|
||||
}
|
||||
|
||||
// Update the specified customer in the data access object.
|
||||
func (a *Customer) Update(ctx context.Context, id string, formItem *schema.CustomerForm) error {
|
||||
customer, err := a.CustomerDAL.Get(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if customer == nil {
|
||||
return errors.NotFound("", "Customer not found")
|
||||
}
|
||||
|
||||
if err := formItem.FillTo(customer); err != nil {
|
||||
return err
|
||||
}
|
||||
customer.UpdatedAt = time.Now()
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.CustomerDAL.Update(ctx, customer); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
// Delete the specified customer from the data access object.
|
||||
func (a *Customer) Delete(ctx context.Context, id string) error {
|
||||
exists, err := a.CustomerDAL.Exists(ctx, id)
|
||||
if err != nil {
|
||||
return err
|
||||
} else if !exists {
|
||||
return errors.NotFound("", "Customer not found")
|
||||
}
|
||||
|
||||
return a.Trans.Exec(ctx, func(ctx context.Context) error {
|
||||
if err := a.CustomerDAL.Delete(ctx, id); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user