作者 yangfu

init project

正在显示 100 个修改的文件 包含 2470 行增加0 行删除

要显示太多修改。

为保证性能只显示 100 of 100+ 个文件。

# Compiled Object codefiles, Static and Dynamic libs (Shared Objects)
*.o
*.a
*.so
# Folders
_obj
_test
# Architecture specific extensions/prefixes
*.[568vq]
[568vq].out
*.cgo1.go
*.cgo2.c
_cgo_defun.c
_cgo_gotypes.go
_cgo_export.*
_testmain.go
*.exe
*.test
.log
.idea
app.log
go.sum
lastupdate.tmp
\ No newline at end of file
... ...
FROM golang:latest
ENV APP_DIR $GOPATH/src/character-library-metadata-bastion
RUN mkdir -p $APP_DIR
WORKDIR $APP_DIR/
COPY ./pkg pkg
COPY ./conf conf
COPY ./go.mod go.mod
COPY ./go.sum go.sum
COPY ./main.go main.go
RUN ["ln","-sf","/usr/share/zoneinfo/Asia/Shanghai","/etc/localtime"]
ENV GO111MODULE on
ENV GOPROXY https://goproxy.io
RUN ["go","mod","tidy"]
RUN ["ls"]
RUN ["go","build"]
ENTRYPOINT ["./character-library-metadata-bastion"]
\ No newline at end of file
... ...
# character-library-metadata-bastion
## 源文件管理
- 文件列表 - list
- 上传 - 上传oss / 创建file
- 加载 - loadDataTable
- 编辑 - editDataTable
- 持久化 - flushDataTable
- 导出 - url
- 删除 - delete
... ...
POSTGRESQL_DB_NAME = allied_creation_dev
POSTGRESQL_HOST = 114.55.200.59
POSTGRESQL_PORT = 31543
POSTGRESQL_USER = postgres
POSTGRESQL_PASSWORD = eagle1010
DISABLE_SQL_GENERATE_COMMENT = false
SERVICE_ENV = test
HTTP_PORT = 8081
ENABLE_KAFKA_LOG11 = true
HTTPS_PORT = 8143
ALLIED_CREATION_USER_HOST = http://allied-creation-user-dev.fjmaimaimai.com
... ...
POSTGRESQL_DB_NAME = allied_creation_test
POSTGRESQL_HOST = 114.55.200.59
POSTGRESQL_PORT = 31543
POSTGRESQL_USER = postgres
POSTGRESQL_PASSWORD = eagle1010
DISABLE_SQL_GENERATE_COMMENT = false
SERVICE_ENV = test
HTTP_PORT = 8081
ENABLE_KAFKA_LOG11 = true
HTTPS_PORT = 8143
ALLIED_CREATION_USER_HOST = http://allied-creation-user-test.fjmaimaimai.com
MANUFACTURE_DEFAULT_COMPANYID = 23
MANUFACTURE_DEFAULT_ORGID = 487
MANUFACTURE_DEFAULT_WORKSHOPID = 28
... ...
-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA45R02HLq/QHraf7VBf6QO4ca1StnmvztF5BLVU7txhKe9FD4
CLUhwharlUlPPjYFdqm9pFxynUqt15djEPhGVUEFeBpf931pVuPugNmZ/AVj0p8y
06eTNLphkrzCdBzISUN5E3PKglz3efIzq6ZK8vbns/XSQA9NRzAPTboe0KC0Flj4
YPP1X69aJiBOGClsAjG1EXQ6gxepBiL1Fq3GtpKHrQPFHffUXEkPZJz09x6RxpuU
CrtxUKdO6eKg89COo3xLXVpOZu94+csBAgvXqmADp/XCQELZRMTTEA4OIyz7yXoK
nmqceoHaeSv4nzDDMwzITFvWmZHDPHLuZwNSZwIDAQABAoIBAQDGPKf3b0rQLt7g
irEGsrLyl4JBE7kA4bao4vEsEz+9XLUHfoxAEX+hcFvwA1a6ixYBQmRGCp1v9AAw
HteVjZ6+XpAkCV102NJsdMlphaLDS/KjIjeE9KCeuoeJ6VC9EeFJKDQMRL2vBsov
eFGYAJeiwn4cXVHSqUGYc/2wqCJ1eRHJkvprDqIeZU8ND3uQ5Gz/5azezf8hBu2P
MUDseX1PzdvvElidxpHR1KsZTvGVFMMFWRcSDfQYSIB8EevMKQS2YwU9kmiCI3s3
qDEAc/Usj64oRLh3Wwh9V0H26zpn/XyQ5pzYmWtCGUpifGuAAQeFKc1jPN6fJy6a
WwLprqV5AoGBAP0k7btOXE5+hmMGcuiu3vWg0X3EOQf7MtMlsrMbqrzS4HbaaMqP
BW4hrQOLl8zB9vOYt0TuK0/+ONLlCgYiodqA8FkC7TUHcTyHUEIE3+QTrI23CY6z
AbJgnHew4jKhRvbLFHkrrIMWgRIDlIwk7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QojPpbxB+zirynvgqV/0DCktDAdBgNVHQ4EFgQUU3m/WqorSs9UgOHYm8Cd8rID
ZsswDgYDVR0PAQH/BAQDAgGGMA8GA1UdEwEB/wQFMAMBAf8wEQYDVR0gBAowCDAG
BgRVHSAAMEMGA1UdHwQ8MDowOKA2oDSGMmh0dHA6Ly9jcmwuY29tb2RvY2EuY29t
L0FBQUNlcnRpZmljYXRlU2VydmljZXMuY3JsMDQGCCsGAQUFBwEBBCgwJjAkBggr
BgEFBQcwAYYYaHR0cDovL29jc3AuY29tb2RvY2EuY29tMA0GCSqGSIb3DQEBDAUA
A4IBAQAYh1HcdCE9nIrgJ7cz0C7M7PDmy14R3iJvm3WOnnL+5Nb+qh+cli3vA0p+
rvSNb3I8QzvAP+u431yqqcau8vzY7qN7Q/aGNnwU4M309z/+3ri0ivCRlv79Q2R+
/czSAaF9ffgZGclCKxO/WIu6pKJmBHaIkU4MiRTOok3JMrO66BQavHHxW/BBC5gA
CiIDEOUMsfnNkjcZ7Tvx5Dq2+UUTJnWvu6rvP3t3O9LEApE9GQDTF1w52z97GA1F
zZOFli9d31kWTz9RvdVFGD/tSo7oBmF0Ixa1DVBzJ0RHfxBdiSprhTEUxOipakyA
vGp4z7h/jnZymQyd/teRCBaho1+V
-----END CERTIFICATE-----
... ...
apiVersion: v1
kind: Service
metadata:
name: character-library-metadata-bastion
namespace: <replace-your-k8s-namespace>
labels:
k8s-app: character-library-metadata-bastion
spec:
ports:
- name: "http"
port: 80
targetPort: 8082
selector:
k8s-app: character-library-metadata-bastion
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: character-library-metadata-bastion
namespace: <replace-your-k8s-namespace>
labels:
k8s-app: character-library-metadata-bastion
spec:
replicas: 1
template:
metadata:
labels:
k8s-app: character-library-metadata-bastion
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- preference: {}
weight: 100
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: In
values:
- cn-hangzhou.i-bp1djh1xn7taumbue1ze
- cn-hangzhou.i-bp1djh1xn7taumbue1zd
- cn-hangzhou.i-bp1euf5u1ph9kbhtndhb
- cn-hangzhou.i-bp1hyp5oips9cdwxxgxy
containers:
- name: character-library-metadata-bastion
image: 192.168.0.243:5000/mmm/character-library-metadata-bastion:dev
imagePullPolicy: Always
ports:
- containerPort: 8082
volumeMounts:
- mountPath: /opt/logs
name: accesslogs
env:
- name: LOG_LEVEL
value: "debug"
- name: ERROR_BASE_CODE
value: "1"
- name: ERROR_BASE_CODE_MULTIPLE
value: "1000"
volumes:
- name: accesslogs
emptyDir: {}
\ No newline at end of file
... ...
#!/bin/bash
export PATH=/root/local/bin:$PATH
kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion
if [ "$?" == "1" ];then
kubectl create -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml --record
kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion
if [ "$?" == "0" ];then
echo "character-library-metadata-bastion service install success!"
else
echo "character-library-metadata-bastion service install fail!"
fi
kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion
if [ "$?" == "0" ];then
echo "character-library-metadata-bastion deployment install success!"
else
echo "character-library-metadata-bastion deployment install fail!"
fi
else
kubectl delete -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml
kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion
while [ "$?" == "0" ]
do
kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion
done
kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion
while [ "$?" == "0" ]
do
kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion
done
kubectl create -f /tmp/dev/character-library-metadata-bastion/character-library-metadata-bastion.yaml --record
kubectl -n <replace-your-k8s-namespace> get svc | grep -q character-library-metadata-bastion
if [ "$?" == "0" ];then
echo "character-library-metadata-bastion service update success!"
else
echo "character-library-metadata-bastion service update fail!"
fi
kubectl -n <replace-your-k8s-namespace> get pods | grep -q character-library-metadata-bastion
if [ "$?" == "0" ];then
echo "character-library-metadata-bastion deployment update success!"
else
echo "character-library-metadata-bastion deployment update fail!"
fi
fi
\ No newline at end of file
... ...
version: v1
kind: HttpApi
metadata:
service: file
path: /files
endpoints:
- method: createFile
route:
post: /
- method: updateFile
route:
put: /{fileId}
- method: getFile
route:
get: /{fileId}
- method: removeFile
route:
delete: /{fileId}
- method: listFile
route:
get: /
params:
- name: offset
- name: limit
- method: loadDataTable
route:
post: /files/load-data-table
- method: editDataTable
route:
post: /files/edit-data-table
- method: flushDataTable
route:
post: /files/flush-data-table
- method: generateMainTable
route:
post: /files/generate-main-table
\ No newline at end of file
... ...
version: v1
kind: Attribute
metadata:
name: count
description: 匹配数目
type:
primitive: int64
... ...
version: v1
kind: Attribute
metadata:
name: createdAt
description: 创建时间
type:
primitive: datetime
... ...
version: v1
kind: Attribute
metadata:
name: deletedAt
description: 删除时间
type:
primitive: datetime
... ...
version: v1
kind: Attribute
metadata:
name: limit
description: 查询限制
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: offset
description: 查询偏离量
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: parentId
description: 父级ID
type:
primitive: int64
... ...
version: v1
kind: Attribute
metadata:
name: sort
description: 排序
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: updatedAt
description: 更新时间
type:
primitive: datetime
... ...
version: v1
kind: Attribute
metadata:
name: version
description: 版本
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: SQLName
description: 对应数据库名称
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: SQLType
description: 对应数据库类型
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: description
description: 描述
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: fieldId
description: 字段Id
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: flag
description: 标识 1:主表字段 2:手动添加
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: index
description: 索引序号
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: name
description: 名称
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: fileId
description: 文件ID
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: fileInfo
description: 文件信息
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: fileSize
description: 文件大小
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: fileType
description: 文件类型
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: operator
description: 操作人
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: sourceFileId
description: 源文件Id(FileType为TemporaryFile或VerifiedFile时有值)
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: table
description:
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: url
description: 文件地址
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: content
description: 日志内容
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: entry
description: 日志内容
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: logId
description: 日志ID
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: logType
description: 日志类型 1.校验步骤 2.常规日志
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: objectName
description: 对象名称 数据表名 / 文件名
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: objectType
description: 对象类型 1.主表 2.分表 3.副表 4.源文件 5.校验文件
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: operationType
description: 操作类型 1.主表生成 2.主表拆分 3.数据导入 4.分表生成 5.表复制 6.编辑记录 7.文件上传 8.文件校验
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: operatorName
description: 操作人名称
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: sourceId
description: 源数据ID
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: PK
description: 主键字段
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: dataFieldIndex
description: 数据字段序号
type:
primitive: int
... ...
version: v1
kind: Attribute
metadata:
name: dataFields
description: 数据列
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: manualFields
description: 手动添加的列
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: tableId
description: 表Id
type:
primitive: string
... ...
version: v1
kind: Attribute
metadata:
name: tableType
description: 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表
type:
primitive: string
... ...
version: v1
kind: Project
metadata:
name: character-library-metadata-bastion
description: 字库元数据堡垒
version: 0.0.1
repository: gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion
contact:
name: ttt
email:
\ No newline at end of file
... ...
version: v1
kind: Schema
metadata:
name: field
description: 字段
attributes:
- ref: fieldId
required: true
- ref: index
required: true
- ref: name
required: true
- ref: SQLName
required: true
- ref: SQLType
required: true
- ref: description
required: true
- ref: flag
required: true
... ...
version: v1
kind: Schema
metadata:
name: file
description: 文件
attributes:
- ref: fileId
required: true
- ref: fileType
required: true
- ref: fileInfo
required: true
- ref: sourceFileId
required: true
- ref: operator
required: true
- ref: createdAt
required: true
- ref: updatedAt
required: true
- ref: deletedAt
required: true
- ref: version
required: true
... ...
version: v1
kind: Schema
metadata:
name: fileInfo
description: 文件信息
attributes:
- ref: name
required: true
- ref: url
required: true
- ref: fileSize
required: true
... ...
version: v1
kind: Schema
metadata:
name: log
description: 日志
attributes:
- ref: logId
required: true
- ref: logType
required: true
- ref: sourceId
required: true
- ref: entry
required: true
- ref: createdAt
required: true
... ...
version: v1
kind: Schema
metadata:
name: logEntry
description: 日志内容
attributes:
- ref: objectName
required: true
- ref: objectType
required: true
- ref: operationType
required: true
- ref: content
required: true
- ref: operatorName
required: true
... ...
version: v1
kind: Schema
metadata:
name: table
description:
attributes:
- ref: tableId
required: true
- ref: tableType
required: true
- ref: name
required: true
- ref: SQLName
required: true
- ref: parentId
required: true
- ref: dataFieldIndex
required: true
- ref: PK
required: true
- ref: dataFields
required: true
- ref: manualFields
required: true
- ref: createdAt
required: true
- ref: updatedAt
required: true
- ref: deletedAt
required: true
- ref: version
required: true
... ...
version: v1
kind: Method
metadata:
name: createFile
type: command
description: 创建文件服务
payload:
- ref: name
required: true
- ref: url
required: true
- ref: fileSize
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: editDataTable
type: command
description: 编辑表格数据
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: flushDataTable
type: command
description: 持久化表格数据
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: generateMainTable
type: command
description: 生成主表
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: getFile
type: query
description: 返回文件服务
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: listFile
type: query
description: 返回文件服务列表
payload:
- ref: offset
required: true
- ref: limit
required: true
result:
- ref: count
required: true
- name: files
type:
array: file
required: true
... ...
version: v1
kind: Method
metadata:
name: loadDataTable
type: command
description: 加载表格数据
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: removeFile
type: command
description: 移除文件服务
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Method
metadata:
name: updateFile
type: command
description: 更新文件服务
payload:
- ref: fileId
required: true
result:
- name: file
type:
schema: file
required: true
... ...
version: v1
kind: Service
metadata:
name: file
description: 文件服务
... ...
swagger: "2.0"
info:
title: ""
description: 字库元数据堡垒
contact:
name: ttt
email: ""
home: ""
version: 0.0.1
consumes:
- application/json
- application/xml
produces:
- application/json
- application/xml
paths:
/files:
get:
tags:
- file
summary: 返回文件服务列表
description: 返回文件服务列表
operationId: file#listFile
parameters:
- name: offset
in: query
description: 查询偏离量
required: false
type: integer
- name: limit
in: query
description: 查询限制
required: false
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileListFileResponseBody'
schemes:
- http
post:
tags:
- file
summary: 创建文件服务
description: 创建文件服务
operationId: file#createFile
parameters:
- name: CreateFileRequestBody
in: body
required: true
schema:
$ref: '#/definitions/FileCreateFileRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileCreateFileResponseBody'
schemes:
- http
/files/{fileId}:
get:
tags:
- file
summary: 返回文件服务
description: 返回文件服务
operationId: file#getFile
parameters:
- name: fileId
in: path
description: 文件ID
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileGetFileResponseBody'
schemes:
- http
put:
tags:
- file
summary: 更新文件服务
description: 更新文件服务
operationId: file#updateFile
parameters:
- name: fileId
in: path
description: 文件ID
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileUpdateFileResponseBody'
schemes:
- http
delete:
tags:
- file
summary: 移除文件服务
description: 移除文件服务
operationId: file#removeFile
parameters:
- name: fileId
in: path
description: 文件ID
required: true
type: integer
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileRemoveFileResponseBody'
schemes:
- http
/files/files/edit-data-table:
post:
tags:
- file
summary: 编辑表格数据
description: 编辑表格数据
operationId: file#editDataTable
parameters:
- name: EditDataTableRequestBody
in: body
required: true
schema:
$ref: '#/definitions/FileEditDataTableRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileEditDataTableResponseBody'
schemes:
- http
/files/files/flush-data-table:
post:
tags:
- file
summary: 持久化表格数据
description: 持久化表格数据
operationId: file#flushDataTable
parameters:
- name: FlushDataTableRequestBody
in: body
required: true
schema:
$ref: '#/definitions/FileFlushDataTableRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileFlushDataTableResponseBody'
schemes:
- http
/files/files/generate-main-table:
post:
tags:
- file
summary: 生成主表
description: 生成主表
operationId: file#generateMainTable
parameters:
- name: GenerateMainTableRequestBody
in: body
required: true
schema:
$ref: '#/definitions/FileGenerateMainTableRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileGenerateMainTableResponseBody'
schemes:
- http
/files/files/load-data-table:
post:
tags:
- file
summary: 加载表格数据
description: 加载表格数据
operationId: file#loadDataTable
parameters:
- name: LoadDataTableRequestBody
in: body
required: true
schema:
$ref: '#/definitions/FileLoadDataTableRequestBody'
responses:
"200":
description: OK response.
schema:
$ref: '#/definitions/FileLoadDataTableResponseBody'
schemes:
- http
definitions:
FileCreateFileRequestBody:
title: FileCreateFileRequestBody
type: object
properties:
fileSize:
type: integer
description: 文件大小
required:
- fileSize
name:
type: string
description: 名称
required:
- name
url:
type: string
description: 文件地址
required:
- url
FileCreateFileResponseBody:
title: 'Mediatype identifier: FileCreateFileResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileEditDataTableRequestBody:
title: FileEditDataTableRequestBody
type: object
properties:
fileId:
type: integer
description: 文件ID
required:
- fileId
FileEditDataTableResponseBody:
title: 'Mediatype identifier: FileEditDataTableResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileFlushDataTableRequestBody:
title: FileFlushDataTableRequestBody
type: object
properties:
fileId:
type: integer
description: 文件ID
required:
- fileId
FileFlushDataTableResponseBody:
title: 'Mediatype identifier: FileFlushDataTableResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileGenerateMainTableRequestBody:
title: FileGenerateMainTableRequestBody
type: object
properties:
fileId:
type: integer
description: 文件ID
required:
- fileId
FileGenerateMainTableResponseBody:
title: 'Mediatype identifier: FileGenerateMainTableResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileGetFileResponseBody:
title: 'Mediatype identifier: FileGetFileResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileListFileResponseBody:
title: 'Mediatype identifier: FileListFileResponseBody'
type: object
properties:
count:
type: integer
description: 匹配数目
required:
- count
files:
type: array
items:
$ref: '#/definitions/fileResponseBody'
required:
- files
FileLoadDataTableRequestBody:
title: FileLoadDataTableRequestBody
type: object
properties:
fileId:
type: integer
description: 文件ID
required:
- fileId
FileLoadDataTableResponseBody:
title: 'Mediatype identifier: FileLoadDataTableResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileRemoveFileResponseBody:
title: 'Mediatype identifier: FileRemoveFileResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
FileUpdateFileResponseBody:
title: 'Mediatype identifier: FileUpdateFileResponseBody'
type: object
properties:
file:
$ref: '#/definitions/fileResponseBody'
fileResponseBody:
title: fileResponseBody
type: object
properties:
createdAt:
type: string
description: 创建时间
required:
- createdAt
deletedAt:
type: string
description: 删除时间
required:
- deletedAt
fileId:
type: integer
description: 文件ID
required:
- fileId
fileInfo:
type: string
description: 文件信息
required:
- fileInfo
fileType:
type: string
description: 文件类型
required:
- fileType
operator:
type: string
description: 操作人
required:
- operator
sourceFileId:
type: string
description: 源文件Id(FileType为TemporaryFile或VerifiedFile时有值)
required:
- sourceFileId
updatedAt:
type: string
description: 更新时间
required:
- updatedAt
version:
type: integer
description: 版本
required:
- version
description: 文件
... ...
module gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion
go 1.16
require (
github.com/Shopify/sarama v1.25.0
github.com/ajg/form v1.5.1 // indirect
github.com/beego/beego/v2 v2.0.1
github.com/fasthttp-contrib/websocket v0.0.0-20160511215533-1f3b11f56072 // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/gavv/httpexpect v2.0.0+incompatible
github.com/go-pg/pg/v10 v10.9.0
github.com/go-redis/redis v6.15.9+incompatible // indirect
github.com/go-redis/redis/v7 v7.4.1 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.6 // indirect
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/imkira/go-interpol v1.1.0 // indirect
github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7
github.com/moul/http2curl v1.0.0 // indirect
github.com/onsi/ginkgo v1.15.2
github.com/onsi/gomega v1.11.0
github.com/sergi/go-diff v1.2.0 // indirect
github.com/smartystreets/goconvey v1.7.2 // indirect
github.com/valyala/fasthttp v1.38.0 // indirect
github.com/xeipuuv/gojsonschema v1.2.0 // 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
github.com/yudai/pp v2.0.1+incompatible // indirect
)
replace github.com/linmadan/egglib-go v0.0.0-20210313060205-8b5e456b11f7 => github.com/tiptok/egglib-go v0.0.0-20220421085958-9682d0ac42c1
... ...
package main
import (
"fmt"
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
"time"
_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg"
_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/redis"
_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/log"
_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/port/beego"
)
func main() {
defer func() {
if r := recover(); r != nil {
log.Logger.Error(fmt.Sprintf("%v", r))
}
}()
log.InitLogHook(constant.ENABLE_KAFKA_LOG, true)
redis.InitRedis()
time.Sleep(time.Second)
log.Logger.Info("server start!")
web.Run()
log.Logger.Info("server stop!")
}
... ...
package factory
import (
"github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/repository"
)
func CreateTableRepository(options map[string]interface{}) (domain.TableRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewTableRepository(transactionContext)
}
func CreateLogRepository(options map[string]interface{}) (domain.LogRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewLogRepository(transactionContext)
}
func CreateFileRepository(options map[string]interface{}) (domain.FileRepository, error) {
var transactionContext *pg.TransactionContext
if value, ok := options["transactionContext"]; ok {
transactionContext = value.(*pg.TransactionContext)
}
return repository.NewFileRepository(transactionContext)
}
... ...
package factory
import (
"github.com/linmadan/egglib-go/core/application"
pG "github.com/linmadan/egglib-go/transaction/pg"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg"
)
func CreateTransactionContext(options map[string]interface{}) (application.TransactionContext, error) {
return pG.NewPGTransactionContext(pg.DB), nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type CreateFileCommand struct {
// 名称
Name string `cname:"名称" json:"name" valid:"Required"`
// 文件地址
Url string `cname:"文件地址" json:"url" valid:"Required"`
// 文件大小
FileSize int `cname:"文件大小" json:"fileSize" valid:"Required"`
}
func (createFileCommand *CreateFileCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (createFileCommand *CreateFileCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(createFileCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(createFileCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type EditDataTableCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (editDataTableCommand *EditDataTableCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (editDataTableCommand *EditDataTableCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(editDataTableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(editDataTableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type FlushDataTableCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (flushDataTableCommand *FlushDataTableCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (flushDataTableCommand *FlushDataTableCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(flushDataTableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(flushDataTableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type GenerateMainTableCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (generateMainTableCommand *GenerateMainTableCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (generateMainTableCommand *GenerateMainTableCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(generateMainTableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(generateMainTableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type LoadDataTableCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (loadDataTableCommand *LoadDataTableCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (loadDataTableCommand *LoadDataTableCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(loadDataTableCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(loadDataTableCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type RemoveFileCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (removeFileCommand *RemoveFileCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (removeFileCommand *RemoveFileCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(removeFileCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(removeFileCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package command
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type UpdateFileCommand struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (updateFileCommand *UpdateFileCommand) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (updateFileCommand *UpdateFileCommand) ValidateCommand() error {
valid := validation.Validation{}
b, err := valid.Valid(updateFileCommand)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(updateFileCommand).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type GetFileQuery struct {
// 文件ID
FileId int `cname:"文件ID" json:"fileId" valid:"Required"`
}
func (getFileQuery *GetFileQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (getFileQuery *GetFileQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(getFileQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(getFileQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package query
import (
"fmt"
"reflect"
"strings"
"github.com/beego/beego/v2/core/validation"
)
type ListFileQuery struct {
// 查询偏离量
Offset int `cname:"查询偏离量" json:"offset" valid:"Required"`
// 查询限制
Limit int `cname:"查询限制" json:"limit" valid:"Required"`
}
func (listFileQuery *ListFileQuery) Valid(validation *validation.Validation) {
validation.SetError("CustomValid", "未实现的自定义认证")
}
func (listFileQuery *ListFileQuery) ValidateQuery() error {
valid := validation.Validation{}
b, err := valid.Valid(listFileQuery)
if err != nil {
return err
}
if !b {
elem := reflect.TypeOf(listFileQuery).Elem()
for _, validErr := range valid.Errors {
field, isExist := elem.FieldByName(validErr.Field)
if isExist {
return fmt.Errorf(strings.Replace(validErr.Message, validErr.Field, field.Tag.Get("cname"), -1))
} else {
return fmt.Errorf(validErr.Message)
}
}
}
return nil
}
... ...
package service
import (
"fmt"
"github.com/linmadan/egglib-go/core/application"
"github.com/linmadan/egglib-go/utils/tool_funs"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/factory"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/command"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/application/file/query"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
)
// 文件服务
type FileService struct {
}
// 创建文件服务
func (fileService *FileService) CreateFile(createFileCommand *command.CreateFileCommand) (interface{}, error) {
if err := createFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
newFile := &domain.File{
//Name: createFileCommand.Name,
//Url: createFileCommand.Url,
//FileSize: createFileCommand.FileSize,
}
var fileRepository domain.FileRepository
if value, err := factory.CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
fileRepository = value
}
if file, err := fileRepository.Save(newFile); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return file, nil
}
}
// 编辑表格数据
func (fileService *FileService) EditDataTable(editDataTableCommand *command.EditDataTableCommand) (interface{}, error) {
if err := editDataTableCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 持久化表格数据
func (fileService *FileService) FlushDataTable(flushDataTableCommand *command.FlushDataTableCommand) (interface{}, error) {
if err := flushDataTableCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 生成主表
func (fileService *FileService) GenerateMainTable(generateMainTableCommand *command.GenerateMainTableCommand) (interface{}, error) {
if err := generateMainTableCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 返回文件服务
func (fileService *FileService) GetFile(getFileQuery *query.GetFileQuery) (interface{}, error) {
if err := getFileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var fileRepository domain.FileRepository
if value, err := factory.CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
fileRepository = value
}
file, err := fileRepository.FindOne(map[string]interface{}{"fileId": getFileQuery.FileId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if file == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(getFileQuery.FileId)))
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return file, nil
}
}
// 返回文件服务列表
func (fileService *FileService) ListFile(listFileQuery *query.ListFileQuery) (interface{}, error) {
if err := listFileQuery.ValidateQuery(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var fileRepository domain.FileRepository
if value, err := factory.CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
fileRepository = value
}
if count, files, err := fileRepository.Find(tool_funs.SimpleStructToMap(listFileQuery)); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return map[string]interface{}{
"count": count,
"files": files,
}, nil
}
}
// 加载表格数据
func (fileService *FileService) LoadDataTable(loadDataTableCommand *command.LoadDataTableCommand) (interface{}, error) {
if err := loadDataTableCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return nil, nil
}
// 移除文件服务
func (fileService *FileService) RemoveFile(removeFileCommand *command.RemoveFileCommand) (interface{}, error) {
if err := removeFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var fileRepository domain.FileRepository
if value, err := factory.CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
fileRepository = value
}
file, err := fileRepository.FindOne(map[string]interface{}{"fileId": removeFileCommand.FileId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if file == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(removeFileCommand.FileId)))
}
if file, err := fileRepository.Remove(file); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return file, nil
}
}
// 更新文件服务
func (fileService *FileService) UpdateFile(updateFileCommand *command.UpdateFileCommand) (interface{}, error) {
if err := updateFileCommand.ValidateCommand(); err != nil {
return nil, application.ThrowError(application.ARG_ERROR, err.Error())
}
transactionContext, err := factory.CreateTransactionContext(nil)
if err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
if err := transactionContext.StartTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
defer func() {
transactionContext.RollbackTransaction()
}()
var fileRepository domain.FileRepository
if value, err := factory.CreateFileRepository(map[string]interface{}{
"transactionContext": transactionContext,
}); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
fileRepository = value
}
file, err := fileRepository.FindOne(map[string]interface{}{"fileId": updateFileCommand.FileId})
if err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
}
if file == nil {
return nil, application.ThrowError(application.RES_NO_FIND_ERROR, fmt.Sprintf("%s", string(updateFileCommand.FileId)))
}
if err := file.Update(tool_funs.SimpleStructToMap(updateFileCommand)); err != nil {
return nil, application.ThrowError(application.BUSINESS_ERROR, err.Error())
}
if file, err := fileRepository.Save(file); err != nil {
return nil, application.ThrowError(application.INTERNAL_SERVER_ERROR, err.Error())
} else {
if err := transactionContext.CommitTransaction(); err != nil {
return nil, application.ThrowError(application.TRANSACTION_ERROR, err.Error())
}
return file, nil
}
}
func NewFileService(options map[string]interface{}) *FileService {
newFileService := &FileService{}
return newFileService
}
... ...
package application
import (
"github.com/beego/beego/v2/core/validation"
"github.com/linmadan/egglib-go/validation/beego"
)
func init() {
validation.MessageTmpls = beego.ValidationMessageTmpls
}
... ...
package constant
import (
"fmt"
)
var SERVICE_NAME = "character-library-metadata-bastion"
var SERVICE_ENV = "dev"
var HTTP_PORT int = 8081
var CACHE_PREFIX = "character-library-metadata-bastion-dev"
var LOG_LEVEL = "debug"
var LOG_FILE = "app.log"
var PPROF_ON = true
//天联共创基础模块
//var ALLIED_CREATION_BASIC_HOST = "http://localhost:8080" //"http://allied-creation-basic-dev.fjmaimaimai.com"
//天联共创用户模块
var ALLIED_CREATION_USER_HOST = "http://localhost:8081" //"http://allied-creation-user-dev.fjmaimaimai.com"
//天联共创业务模块
//var ALLIED_CREATION_COOPERATION_HOST = "http://localhost:8082" // "http://allied-creation-cooperation-dev.fjmaimaimai.com"
var MMM_BYTE_BANK_HOST = "http://220.250.41.79:8301"
//var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384}
//const CUSTOMER_ACCOUNT_DELIMITER = ","
/***** 1.数据传输 *****/
//const HeaderCompanyId = "companyId"
//const HeaderUserId = "userId"
//const HeaderOrgId = "orgId"
//const HeaderOrgIds = "orgIds"
func init() {
LOG_LEVEL = Configurator.DefaultString("LOG_LEVEL", LOG_LEVEL)
//ALLIED_CREATION_BASIC_HOST = Configurator.DefaultString("ALLIED_CREATION_BASIC_HOST", ALLIED_CREATION_BASIC_HOST)
ALLIED_CREATION_USER_HOST = Configurator.DefaultString("ALLIED_CREATION_USER_HOST", ALLIED_CREATION_USER_HOST)
//ALLIED_CREATION_COOPERATION_HOST = Configurator.DefaultString("ALLIED_CREATION_COOPERATION_HOST", ALLIED_CREATION_COOPERATION_HOST)
MMM_BYTE_BANK_HOST = Configurator.DefaultString("MMM_BYTE_BANK_HOST", MMM_BYTE_BANK_HOST)
SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV)
HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT)
SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV)
PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON)
CACHE_PREFIX = SERVICE_NAME
}
... ...
// go:build !local
//go:build !local
// +build !local
package constant
import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
var Configurator utils.Configurator = utils.NewConfig("ini", "config/app.conf")
... ...
// go:build local
//go:build local
// +build local
package constant
import "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/utils"
var Configurator utils.Configurator = utils.EnvConfigurator{}
... ...
package constant
var (
// kafka 地址
KAFKA_HOST = "192.168.0.250:9092,192.168.0.251:9092,192.168.0.252:9092" //"106.75.231.90:9092"
// kafka topic log stash
TOPIC_LOG_STASH = "go_stash_dev" //"pushMessage"
// kafka topic up_block_chain
TOPIC_UP_BLOCK_CHAIN = "allied_creation_message"
// 是否启用日志收集 (本地不启用)
ENABLE_KAFKA_LOG = false
)
func init() {
KAFKA_HOST = Configurator.DefaultString("KAFKA_HOST", KAFKA_HOST)
ENABLE_KAFKA_LOG = Configurator.DefaultBool("ENABLE_KAFKA_LOG", ENABLE_KAFKA_LOG)
}
... ...
package constant
var POSTGRESQL_DB_NAME = "terms"
var POSTGRESQL_USER = "postgres"
var POSTGRESQL_PASSWORD = "123456"
var POSTGRESQL_HOST = "127.0.0.1"
var POSTGRESQL_PORT = "5432"
var DISABLE_CREATE_TABLE = false
var DISABLE_SQL_GENERATE_PRINT = false
var DISABLE_SQL_GENERATE_COMMENT = true
func init() {
POSTGRESQL_HOST = Configurator.DefaultString("POSTGRESQL_HOST", POSTGRESQL_HOST)
POSTGRESQL_PORT = Configurator.DefaultString("POSTGRESQL_PORT", POSTGRESQL_PORT)
POSTGRESQL_DB_NAME = Configurator.DefaultString("POSTGRESQL_DB_NAME", POSTGRESQL_DB_NAME)
POSTGRESQL_USER = Configurator.DefaultString("POSTGRESQL_USER", POSTGRESQL_USER)
POSTGRESQL_PASSWORD = Configurator.DefaultString("POSTGRESQL_PASSWORD", POSTGRESQL_PASSWORD)
DISABLE_CREATE_TABLE = Configurator.DefaultBool("DISABLE_CREATE_TABLE", DISABLE_CREATE_TABLE)
DISABLE_SQL_GENERATE_PRINT = Configurator.DefaultBool("DISABLE_SQL_GENERATE_PRINT", DISABLE_SQL_GENERATE_PRINT)
}
... ...
package constant
var (
REDIS_HOST = "127.0.0.1"
REDIS_PORT = "6379"
REDIS_AUTH = ""
REDIS_ADDRESS = ""
// 是否关闭仓储层缓存
ENABLE_REPOSITORY_CACHE = true
// 缓存过期时间 单位秒
REPOSITORY_CACHE_EXPIRE = 30 * 60
// redis 考勤机打卡消息队列
REDIS_ZKTECO_KEY = "allied-creation-zkteco"
// redis 车间数据消息队列
REDIS_WORKSHOP_KEY = "allied-creation-workshop"
)
func init() {
REDIS_HOST = Configurator.DefaultString("REDIS_HOST", REDIS_HOST)
REDIS_PORT = Configurator.DefaultString("REDIS_PORT", REDIS_PORT)
REDIS_AUTH = Configurator.DefaultString("REDIS_AUTH", REDIS_AUTH)
ENABLE_REPOSITORY_CACHE = Configurator.DefaultBool("ENABLE_REPOSITORY_CACHE", ENABLE_REPOSITORY_CACHE)
REDIS_ADDRESS = REDIS_HOST + ":" + REDIS_PORT
}
... ...
package domain
// Field 字段
type Field struct {
// 字段Id
FieldId int `json:"fieldId"`
// 索引序号
Index int `json:"index"`
// 名称
Name string `json:"name"`
// 对应数据库名称
SQLName string `json:"sqlName"`
// 对应数据库类型
SQLType string `json:"sqlType"`
// 描述
Description string `json:"description"`
// 标识 1:主表字段 2:手动添加
Flag int `json:"flag"`
}
... ...
package domain
import "time"
// File 文件
type File struct {
// 文件ID
FileId int `json:"fileId"`
// 文件类型
FileType string `json:"fileType"`
// 文件信息
FileInfo *FileInfo `json:"fileInfo"`
// 源文件Id(FileType为TemporaryFile或VerifiedFile时有值)
SourceFileId string `json:"sourceFileId"`
// 操作人
Operator string `json:"operator"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 版本
Version int `json:"version"`
}
type FileRepository interface {
Save(file *File) (*File, error)
Remove(file *File) (*File, error)
FindOne(queryOptions map[string]interface{}) (*File, error)
Find(queryOptions map[string]interface{}) (int64, []*File, error)
}
func (file *File) Identify() interface{} {
if file.FileId == 0 {
return nil
}
return file.FileId
}
func (file *File) Update(data map[string]interface{}) error {
return nil
}
... ...
package domain
// FileInfo 文件信息
type FileInfo struct {
// 名称
Name string `json:"name"`
// 文件地址
Url string `json:"url"`
// 文件大小
FileSize int `json:"fileSize"`
}
... ...
package domain
import "time"
// Log 日志
type Log struct {
// 日志ID
LogId int `json:"logId"`
// 日志类型 1.校验步骤 2.常规日志
LogType int `json:"logType"`
// 源数据ID
SourceId int `json:"sourceId"`
// 日志内容
Entry *LogEntry `json:"entry"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
}
type LogRepository interface {
Save(log *Log) (*Log, error)
Remove(log *Log) (*Log, error)
FindOne(queryOptions map[string]interface{}) (*Log, error)
Find(queryOptions map[string]interface{}) (int64, []*Log, error)
}
func (log *Log) Identify() interface{} {
if log.LogId == 0 {
return nil
}
return log.LogId
}
func (log *Log) Update(data map[string]interface{}) error {
return nil
}
... ...
package domain
// LogEntry 日志内容
type LogEntry struct {
// 对象名称 数据表名 / 文件名
ObjectName string `json:"objectName"`
// 对象类型 1.主表 2.分表 3.副表 4.源文件 5.校验文件
ObjectType string `json:"objectType"`
// 操作类型 1.主表生成 2.主表拆分 3.数据导入 4.分表生成 5.表复制 6.编辑记录 7.文件上传 8.文件校验
OperationType string `json:"operationType"`
// 日志内容
Content string `json:"content"`
// 操作人名称
OperatorName string `json:"operatorName"`
}
... ...
package domain
import "time"
// Table 表
type Table struct {
// 表Id
TableId int `json:"tableId"`
// 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表
TableType string `json:"tableType"`
// 名称
Name string `json:"name"`
// 对应数据库名称
SQLName string `json:"sQLName"`
// 父级ID
ParentId int64 `json:"parentId,string"`
// 数据字段序号
DataFieldIndex int `json:"dataFieldIndex"`
// 主键字段
PK string `json:"pK"`
// 数据列
DataFields string `json:"dataFields"`
// 手动添加的列
ManualFields string `json:"manualFields"`
// 创建时间
CreatedAt time.Time `json:"createdAt"`
// 更新时间
UpdatedAt time.Time `json:"updatedAt"`
// 删除时间
DeletedAt time.Time `json:"deletedAt"`
// 版本
Version int `json:"version"`
}
type TableRepository interface {
Save(table *Table) (*Table, error)
Remove(table *Table) (*Table, error)
FindOne(queryOptions map[string]interface{}) (*Table, error)
Find(queryOptions map[string]interface{}) (int64, []*Table, error)
}
func (table *Table) Identify() interface{} {
if table.TableId == 0 {
return nil
}
return table.TableId
}
func (table *Table) Update(data map[string]interface{}) error {
return nil
}
... ...
package pg
import (
"fmt"
"github.com/go-pg/pg/v10"
"github.com/go-pg/pg/v10/orm"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/constant"
//_ "gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg/models"
"github.com/linmadan/egglib-go/persistent/pg/comment"
"github.com/linmadan/egglib-go/persistent/pg/hooks"
)
var DB *pg.DB
func init() {
DB = pg.Connect(&pg.Options{
User: constant.POSTGRESQL_USER,
Password: constant.POSTGRESQL_PASSWORD,
Database: constant.POSTGRESQL_DB_NAME,
Addr: fmt.Sprintf("%s:%s", constant.POSTGRESQL_HOST, constant.POSTGRESQL_PORT),
})
if !constant.DISABLE_SQL_GENERATE_PRINT {
DB.AddQueryHook(hooks.SqlGeneratePrintHook{})
}
if !constant.DISABLE_CREATE_TABLE {
for _, model := range []interface{}{} {
err := DB.Model(model).CreateTable(&orm.CreateTableOptions{
Temp: false,
IfNotExists: true,
FKConstraints: true,
})
if err != nil {
panic(err)
}
comment.AddComments(DB, model)
}
}
}
... ...
package models
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"time"
)
type File struct {
tableName string `comment:"文件" pg:"metadata.files,alias:file"`
// 文件ID
FileId int `comment:"文件ID" pg:"pk:file_id"`
// 文件类型
FileType string `comment:"文件类型"`
// 文件信息
FileInfo *domain.FileInfo `comment:"文件信息"`
// 源文件Id(FileType为TemporaryFile或VerifiedFile时有值)
SourceFileId string `comment:"源文件Id(FileType为TemporaryFile或VerifiedFile时有值)"`
// 操作人
Operator string `comment:"操作人"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
// 版本
Version int `comment:"版本"`
}
... ...
package models
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"time"
)
type Log struct {
tableName string `comment:"日志" pg:"metadata.logs,alias:log"`
// 日志ID
LogId int `comment:"日志ID" pg:"pk:log_id"`
// 日志类型 1.校验步骤 2.常规日志
LogType int `comment:"日志类型 1.校验步骤 2.常规日志"`
// 源数据ID
SourceId int `comment:"源数据ID"`
// 日志内容
Entry *domain.LogEntry `comment:"日志内容"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
}
... ...
package models
import "time"
type Table struct {
tableName string `comment:"表" pg:"metadata.tables,alias:table"`
// 表Id
TableId int `comment:"表Id" pg:"pk:table_id"`
// 表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表
TableType string `comment:"表类型 MainTable:主表 SideTable:副表 SubTable:分表 ExcelTable:Excel表"`
// 名称
Name string `comment:"名称"`
// 对应数据库名称
SQLName string `comment:"对应数据库名称"`
// 父级ID
ParentId int64 `comment:"父级ID"`
// 数据字段序号
DataFieldIndex int `comment:"数据字段序号"`
// 主键字段
PK string `comment:"主键字段"`
// 数据列
DataFields string `comment:"数据列"`
// 手动添加的列
ManualFields string `comment:"手动添加的列"`
// 创建时间
CreatedAt time.Time `comment:"创建时间"`
// 更新时间
UpdatedAt time.Time `comment:"更新时间"`
// 删除时间
DeletedAt time.Time `comment:"删除时间"`
// 版本
Version int `comment:"版本"`
}
... ...
package transform
import (
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/character-library-metadata-bastion/pkg/infrastructure/pg/models"
)
func TransformToFileDomainModelFromPgModels(fileModel *models.File) (*domain.File, error) {
return &domain.File{
FileId: fileModel.FileId,
FileType: fileModel.FileType,
FileInfo: fileModel.FileInfo,
SourceFileId: fileModel.SourceFileId,
Operator: fileModel.Operator,
CreatedAt: fileModel.CreatedAt,
UpdatedAt: fileModel.UpdatedAt,
DeletedAt: fileModel.DeletedAt,
Version: fileModel.Version,
}, nil
}
... ...