Merge branch 'feat-hjj-ReportsManage' into dev
This commit is contained in:
commit
4f7627a6de
33
.vscode/launch.json
vendored
Normal file
33
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
{
|
||||
// 使用 IntelliSense 了解相关属性。
|
||||
// 悬停以查看现有属性的描述。
|
||||
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Launch Package",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "auto",
|
||||
"env": {
|
||||
"GOPATH":"C:\\Users\\lenovo\\go",
|
||||
"GOOS":"windows"
|
||||
},
|
||||
"program": "${workspaceFolder}\\cmd",
|
||||
"args":[]
|
||||
},
|
||||
{
|
||||
"name": "Run app.go",
|
||||
"type": "go",
|
||||
"request": "launch",
|
||||
"mode": "debug",
|
||||
"program": "${workspaceFolder}/cmd/app.go",
|
||||
"cwd": "${workspaceFolder}/cmd",
|
||||
"env": {
|
||||
"DEBUG": "true",
|
||||
"DUBBO_GO_CONFIG_PATH": "${workspaceFolder}/conf/dubbogo.yaml"
|
||||
},
|
||||
"dlvFlags": ["--check-go-version=false"]
|
||||
}
|
||||
]
|
||||
}
|
22
.vscode/settings.json
vendored
Normal file
22
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
"workbench.colorCustomizations": {
|
||||
"activityBar.activeBackground": "#fa1b49",
|
||||
"activityBar.background": "#fa1b49",
|
||||
"activityBar.foreground": "#e7e7e7",
|
||||
"activityBar.inactiveForeground": "#e7e7e799",
|
||||
"activityBarBadge.background": "#155e02",
|
||||
"activityBarBadge.foreground": "#e7e7e7",
|
||||
"commandCenter.border": "#e7e7e799",
|
||||
"sash.hoverBorder": "#fa1b49",
|
||||
"statusBar.background": "#dd0531",
|
||||
"statusBar.foreground": "#e7e7e7",
|
||||
"statusBarItem.hoverBackground": "#fa1b49",
|
||||
"statusBarItem.remoteBackground": "#dd0531",
|
||||
"statusBarItem.remoteForeground": "#e7e7e7",
|
||||
"titleBar.activeBackground": "#dd0531",
|
||||
"titleBar.activeForeground": "#e7e7e7",
|
||||
"titleBar.inactiveBackground": "#dd053199",
|
||||
"titleBar.inactiveForeground": "#e7e7e799"
|
||||
},
|
||||
"peacock.color": "#dd0531"
|
||||
}
|
1850
api/reports/reports.pb.go
Normal file
1850
api/reports/reports.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
148
api/reports/reports.proto
Normal file
148
api/reports/reports.proto
Normal file
@ -0,0 +1,148 @@
|
||||
syntax = "proto3";
|
||||
package reports;
|
||||
//import "descriptor.proto";
|
||||
//import "validator.proto";
|
||||
|
||||
option go_package = "./;reports";
|
||||
|
||||
service Reports{
|
||||
//==================================年度报告======================================
|
||||
rpc GetAnnualReportList(GetAnnualReportListReq) returns (GetAnnualReportListResp);
|
||||
rpc AddAnnualReport(AddAnnualReportReq) returns (AddAnnualReportResp);
|
||||
rpc EditAnnualReport(EditAnnualReportReq) returns (EditAnnualReportResp);
|
||||
rpc DeleteAnnualReport(DeleteAnnualReportReq) returns (DeleteAnnualReportResp);
|
||||
//==================================季度报告======================================
|
||||
rpc GetQuarterlyReportList(GetQuarterlyReportListReq) returns (GetQuarterlyReportListResp);
|
||||
rpc AddQuarterlyReport(AddQuarterlyReportReq) returns (AddQuarterlyReportResp);
|
||||
rpc EditQuarterlyReport(EditQuarterlyReportReq) returns (EditQuarterlyReportResp);
|
||||
rpc DeleteQuarterlyReport(DeleteQuarterlyReportReq) returns (DeleteQuarterlyReportResp);
|
||||
}
|
||||
|
||||
message Filtrate{
|
||||
string fileName = 3;//文件名称
|
||||
int32 status = 4;//状态(1:上架,2:下架)
|
||||
}
|
||||
//==================================年度报告======================================
|
||||
message GetAnnualReportListReq{
|
||||
int32 page = 1;
|
||||
int32 pageSize = 2;
|
||||
Filtrate filtrate = 3;
|
||||
}
|
||||
|
||||
message GetAnnualReportListResp{
|
||||
string msg = 1;
|
||||
int32 page=2;
|
||||
int32 pageSize =3;
|
||||
int32 total = 4;
|
||||
repeated AnnualReport data = 5;
|
||||
}
|
||||
|
||||
message AnnualReport{
|
||||
int32 id = 1; //id
|
||||
string fileName = 2; //文件名称
|
||||
string date = 3; //日期
|
||||
string fileUrl = 4; //访问地址
|
||||
int32 status = 5; //状态(1:上架,2:下架)
|
||||
int32 sort = 6; //排序
|
||||
string updateTime = 7; //最近更新时间
|
||||
string operator = 8; //操作人
|
||||
int32 operatorId = 9; //操作人Id
|
||||
}
|
||||
|
||||
message AddAnnualReportReq{
|
||||
string fileName = 1; //文件名称
|
||||
string date = 2; //日期
|
||||
string fileUrl = 3; //访问地址
|
||||
string operator = 4; //操作人
|
||||
int32 operatorId = 5; //操作人Id
|
||||
}
|
||||
|
||||
message AddAnnualReportResp{
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
message EditAnnualReportReq{
|
||||
int32 id = 1; //id
|
||||
string fileName = 2; //文件名称
|
||||
string date = 3; //日期
|
||||
string fileUrl = 4; //访问地址
|
||||
int32 sort = 5; //排序
|
||||
int32 status = 6; //状态(1:上架,2:下架)
|
||||
string operator = 7; //操作人
|
||||
int32 operatorId = 8; //操作人Id
|
||||
}
|
||||
|
||||
message EditAnnualReportResp{
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
message DeleteAnnualReportReq{
|
||||
int32 id = 1;
|
||||
}
|
||||
|
||||
message DeleteAnnualReportResp{
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
//==================================季度报告======================================
|
||||
message GetQuarterlyReportListReq{
|
||||
int32 page = 1;
|
||||
int32 pageSize = 2;
|
||||
Filtrate filtrate = 3;
|
||||
}
|
||||
|
||||
message GetQuarterlyReportListResp{
|
||||
string msg = 1;
|
||||
int32 page=2;
|
||||
int32 pageSize =3;
|
||||
int32 total = 4;
|
||||
repeated QuarterlyReport data = 5;
|
||||
}
|
||||
|
||||
message QuarterlyReport{
|
||||
int32 id = 1; //id
|
||||
string fileName = 2; //文件名称
|
||||
string fileIntroduce = 3; //文件介绍
|
||||
int32 sort = 4; //排序
|
||||
int32 status = 5; //状态(1:上架,2:下架)
|
||||
string updateTime = 6; //最近更新时间
|
||||
string operator = 7; //操作人
|
||||
int32 operatorId = 8; //操作人Id
|
||||
}
|
||||
|
||||
message AddQuarterlyReportReq{
|
||||
string fileName = 1; //文件名称
|
||||
string fileIntroduce = 2; //文件介绍
|
||||
string attachment = 3; //附件
|
||||
string attachmentName = 4; //附件名称
|
||||
string operator = 5; //操作人
|
||||
int32 operatorId = 6; //操作人Id
|
||||
}
|
||||
|
||||
message AddQuarterlyReportResp{
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
message EditQuarterlyReportReq{
|
||||
int32 id = 1; //id
|
||||
string fileName = 2; //文件名称
|
||||
string fileIntroduce = 3; //文件介绍
|
||||
string attachment = 4; //附件
|
||||
string attachmentName = 5; //附件名称
|
||||
int32 sort = 6; //排序
|
||||
int32 status = 7; //状态(1:上架,2:下架)
|
||||
string operator = 8; //操作人
|
||||
int32 operatorId = 9; //操作人Id
|
||||
}
|
||||
|
||||
message EditQuarterlyReportResp{
|
||||
string msg = 1;
|
||||
}
|
||||
|
||||
message DeleteQuarterlyReportReq{
|
||||
int32 id = 1;
|
||||
}
|
||||
|
||||
message DeleteQuarterlyReportResp{
|
||||
string msg = 1;
|
||||
}
|
98
api/reports/reports.validator.pb.go
Normal file
98
api/reports/reports.validator.pb.go
Normal file
@ -0,0 +1,98 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: api/reports/reports.proto
|
||||
|
||||
package reports
|
||||
|
||||
import (
|
||||
fmt "fmt"
|
||||
math "math"
|
||||
proto "github.com/golang/protobuf/proto"
|
||||
github_com_mwitkow_go_proto_validators "github.com/mwitkow/go-proto-validators"
|
||||
)
|
||||
|
||||
// Reference imports to suppress errors if they are not otherwise used.
|
||||
var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
func (this *Filtrate) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetAnnualReportListReq) Validate() error {
|
||||
if this.Filtrate != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Filtrate); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Filtrate", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetAnnualReportListResp) Validate() error {
|
||||
for _, item := range this.Data {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *AnnualReport) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *AddAnnualReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *AddAnnualReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *EditAnnualReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *EditAnnualReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteAnnualReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteAnnualReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *GetQuarterlyReportListReq) Validate() error {
|
||||
if this.Filtrate != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.Filtrate); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Filtrate", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *GetQuarterlyReportListResp) Validate() error {
|
||||
for _, item := range this.Data {
|
||||
if item != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Data", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *QuarterlyReport) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *AddQuarterlyReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *AddQuarterlyReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *EditQuarterlyReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *EditQuarterlyReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteQuarterlyReportReq) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *DeleteQuarterlyReportResp) Validate() error {
|
||||
return nil
|
||||
}
|
466
api/reports/reports_triple.pb.go
Normal file
466
api/reports/reports_triple.pb.go
Normal file
@ -0,0 +1,466 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.5
|
||||
// - protoc v5.26.0
|
||||
// source: api/reports/reports.proto
|
||||
|
||||
package reports
|
||||
|
||||
import (
|
||||
context "context"
|
||||
protocol "dubbo.apache.org/dubbo-go/v3/protocol"
|
||||
dubbo3 "dubbo.apache.org/dubbo-go/v3/protocol/dubbo3"
|
||||
invocation "dubbo.apache.org/dubbo-go/v3/protocol/invocation"
|
||||
grpc_go "github.com/dubbogo/grpc-go"
|
||||
codes "github.com/dubbogo/grpc-go/codes"
|
||||
metadata "github.com/dubbogo/grpc-go/metadata"
|
||||
status "github.com/dubbogo/grpc-go/status"
|
||||
common "github.com/dubbogo/triple/pkg/common"
|
||||
constant "github.com/dubbogo/triple/pkg/common/constant"
|
||||
triple "github.com/dubbogo/triple/pkg/triple"
|
||||
)
|
||||
|
||||
// This is a compile-time assertion to ensure that this generated file
|
||||
// is compatible with the grpc package it is being compiled against.
|
||||
const _ = grpc_go.SupportPackageIsVersion7
|
||||
|
||||
// ReportsClient is the client API for Reports service.
|
||||
//
|
||||
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
|
||||
type ReportsClient interface {
|
||||
// ==================================年度报告======================================
|
||||
GetAnnualReportList(ctx context.Context, in *GetAnnualReportListReq, opts ...grpc_go.CallOption) (*GetAnnualReportListResp, common.ErrorWithAttachment)
|
||||
AddAnnualReport(ctx context.Context, in *AddAnnualReportReq, opts ...grpc_go.CallOption) (*AddAnnualReportResp, common.ErrorWithAttachment)
|
||||
EditAnnualReport(ctx context.Context, in *EditAnnualReportReq, opts ...grpc_go.CallOption) (*EditAnnualReportResp, common.ErrorWithAttachment)
|
||||
DeleteAnnualReport(ctx context.Context, in *DeleteAnnualReportReq, opts ...grpc_go.CallOption) (*DeleteAnnualReportResp, common.ErrorWithAttachment)
|
||||
// ==================================季度报告======================================
|
||||
GetQuarterlyReportList(ctx context.Context, in *GetQuarterlyReportListReq, opts ...grpc_go.CallOption) (*GetQuarterlyReportListResp, common.ErrorWithAttachment)
|
||||
AddQuarterlyReport(ctx context.Context, in *AddQuarterlyReportReq, opts ...grpc_go.CallOption) (*AddQuarterlyReportResp, common.ErrorWithAttachment)
|
||||
EditQuarterlyReport(ctx context.Context, in *EditQuarterlyReportReq, opts ...grpc_go.CallOption) (*EditQuarterlyReportResp, common.ErrorWithAttachment)
|
||||
DeleteQuarterlyReport(ctx context.Context, in *DeleteQuarterlyReportReq, opts ...grpc_go.CallOption) (*DeleteQuarterlyReportResp, common.ErrorWithAttachment)
|
||||
}
|
||||
|
||||
type reportsClient struct {
|
||||
cc *triple.TripleConn
|
||||
}
|
||||
|
||||
type ReportsClientImpl struct {
|
||||
GetAnnualReportList func(ctx context.Context, in *GetAnnualReportListReq) (*GetAnnualReportListResp, error)
|
||||
AddAnnualReport func(ctx context.Context, in *AddAnnualReportReq) (*AddAnnualReportResp, error)
|
||||
EditAnnualReport func(ctx context.Context, in *EditAnnualReportReq) (*EditAnnualReportResp, error)
|
||||
DeleteAnnualReport func(ctx context.Context, in *DeleteAnnualReportReq) (*DeleteAnnualReportResp, error)
|
||||
GetQuarterlyReportList func(ctx context.Context, in *GetQuarterlyReportListReq) (*GetQuarterlyReportListResp, error)
|
||||
AddQuarterlyReport func(ctx context.Context, in *AddQuarterlyReportReq) (*AddQuarterlyReportResp, error)
|
||||
EditQuarterlyReport func(ctx context.Context, in *EditQuarterlyReportReq) (*EditQuarterlyReportResp, error)
|
||||
DeleteQuarterlyReport func(ctx context.Context, in *DeleteQuarterlyReportReq) (*DeleteQuarterlyReportResp, error)
|
||||
}
|
||||
|
||||
func (c *ReportsClientImpl) GetDubboStub(cc *triple.TripleConn) ReportsClient {
|
||||
return NewReportsClient(cc)
|
||||
}
|
||||
|
||||
func (c *ReportsClientImpl) XXX_InterfaceName() string {
|
||||
return "reports.Reports"
|
||||
}
|
||||
|
||||
func NewReportsClient(cc *triple.TripleConn) ReportsClient {
|
||||
return &reportsClient{cc}
|
||||
}
|
||||
|
||||
func (c *reportsClient) GetAnnualReportList(ctx context.Context, in *GetAnnualReportListReq, opts ...grpc_go.CallOption) (*GetAnnualReportListResp, common.ErrorWithAttachment) {
|
||||
out := new(GetAnnualReportListResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetAnnualReportList", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) AddAnnualReport(ctx context.Context, in *AddAnnualReportReq, opts ...grpc_go.CallOption) (*AddAnnualReportResp, common.ErrorWithAttachment) {
|
||||
out := new(AddAnnualReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/AddAnnualReport", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) EditAnnualReport(ctx context.Context, in *EditAnnualReportReq, opts ...grpc_go.CallOption) (*EditAnnualReportResp, common.ErrorWithAttachment) {
|
||||
out := new(EditAnnualReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/EditAnnualReport", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) DeleteAnnualReport(ctx context.Context, in *DeleteAnnualReportReq, opts ...grpc_go.CallOption) (*DeleteAnnualReportResp, common.ErrorWithAttachment) {
|
||||
out := new(DeleteAnnualReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteAnnualReport", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) GetQuarterlyReportList(ctx context.Context, in *GetQuarterlyReportListReq, opts ...grpc_go.CallOption) (*GetQuarterlyReportListResp, common.ErrorWithAttachment) {
|
||||
out := new(GetQuarterlyReportListResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/GetQuarterlyReportList", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) AddQuarterlyReport(ctx context.Context, in *AddQuarterlyReportReq, opts ...grpc_go.CallOption) (*AddQuarterlyReportResp, common.ErrorWithAttachment) {
|
||||
out := new(AddQuarterlyReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/AddQuarterlyReport", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) EditQuarterlyReport(ctx context.Context, in *EditQuarterlyReportReq, opts ...grpc_go.CallOption) (*EditQuarterlyReportResp, common.ErrorWithAttachment) {
|
||||
out := new(EditQuarterlyReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/EditQuarterlyReport", in, out)
|
||||
}
|
||||
|
||||
func (c *reportsClient) DeleteQuarterlyReport(ctx context.Context, in *DeleteQuarterlyReportReq, opts ...grpc_go.CallOption) (*DeleteQuarterlyReportResp, common.ErrorWithAttachment) {
|
||||
out := new(DeleteQuarterlyReportResp)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DeleteQuarterlyReport", in, out)
|
||||
}
|
||||
|
||||
// ReportsServer is the server API for Reports service.
|
||||
// All implementations must embed UnimplementedReportsServer
|
||||
// for forward compatibility
|
||||
type ReportsServer interface {
|
||||
// ==================================年度报告======================================
|
||||
GetAnnualReportList(context.Context, *GetAnnualReportListReq) (*GetAnnualReportListResp, error)
|
||||
AddAnnualReport(context.Context, *AddAnnualReportReq) (*AddAnnualReportResp, error)
|
||||
EditAnnualReport(context.Context, *EditAnnualReportReq) (*EditAnnualReportResp, error)
|
||||
DeleteAnnualReport(context.Context, *DeleteAnnualReportReq) (*DeleteAnnualReportResp, error)
|
||||
// ==================================季度报告======================================
|
||||
GetQuarterlyReportList(context.Context, *GetQuarterlyReportListReq) (*GetQuarterlyReportListResp, error)
|
||||
AddQuarterlyReport(context.Context, *AddQuarterlyReportReq) (*AddQuarterlyReportResp, error)
|
||||
EditQuarterlyReport(context.Context, *EditQuarterlyReportReq) (*EditQuarterlyReportResp, error)
|
||||
DeleteQuarterlyReport(context.Context, *DeleteQuarterlyReportReq) (*DeleteQuarterlyReportResp, error)
|
||||
mustEmbedUnimplementedReportsServer()
|
||||
}
|
||||
|
||||
// UnimplementedReportsServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedReportsServer struct {
|
||||
proxyImpl protocol.Invoker
|
||||
}
|
||||
|
||||
func (UnimplementedReportsServer) GetAnnualReportList(context.Context, *GetAnnualReportListReq) (*GetAnnualReportListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetAnnualReportList not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) AddAnnualReport(context.Context, *AddAnnualReportReq) (*AddAnnualReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddAnnualReport not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) EditAnnualReport(context.Context, *EditAnnualReportReq) (*EditAnnualReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EditAnnualReport not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) DeleteAnnualReport(context.Context, *DeleteAnnualReportReq) (*DeleteAnnualReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteAnnualReport not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) GetQuarterlyReportList(context.Context, *GetQuarterlyReportListReq) (*GetQuarterlyReportListResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method GetQuarterlyReportList not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) AddQuarterlyReport(context.Context, *AddQuarterlyReportReq) (*AddQuarterlyReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method AddQuarterlyReport not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) EditQuarterlyReport(context.Context, *EditQuarterlyReportReq) (*EditQuarterlyReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method EditQuarterlyReport not implemented")
|
||||
}
|
||||
func (UnimplementedReportsServer) DeleteQuarterlyReport(context.Context, *DeleteQuarterlyReportReq) (*DeleteQuarterlyReportResp, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DeleteQuarterlyReport not implemented")
|
||||
}
|
||||
func (s *UnimplementedReportsServer) XXX_SetProxyImpl(impl protocol.Invoker) {
|
||||
s.proxyImpl = impl
|
||||
}
|
||||
|
||||
func (s *UnimplementedReportsServer) XXX_GetProxyImpl() protocol.Invoker {
|
||||
return s.proxyImpl
|
||||
}
|
||||
|
||||
func (s *UnimplementedReportsServer) XXX_ServiceDesc() *grpc_go.ServiceDesc {
|
||||
return &Reports_ServiceDesc
|
||||
}
|
||||
func (s *UnimplementedReportsServer) XXX_InterfaceName() string {
|
||||
return "reports.Reports"
|
||||
}
|
||||
|
||||
func (UnimplementedReportsServer) mustEmbedUnimplementedReportsServer() {}
|
||||
|
||||
// UnsafeReportsServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ReportsServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeReportsServer interface {
|
||||
mustEmbedUnimplementedReportsServer()
|
||||
}
|
||||
|
||||
func RegisterReportsServer(s grpc_go.ServiceRegistrar, srv ReportsServer) {
|
||||
s.RegisterService(&Reports_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Reports_GetAnnualReportList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetAnnualReportListReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("GetAnnualReportList", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_AddAnnualReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddAnnualReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("AddAnnualReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_EditAnnualReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EditAnnualReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("EditAnnualReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_DeleteAnnualReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteAnnualReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("DeleteAnnualReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_GetQuarterlyReportList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(GetQuarterlyReportListReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("GetQuarterlyReportList", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_AddQuarterlyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(AddQuarterlyReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("AddQuarterlyReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_EditQuarterlyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(EditQuarterlyReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("EditQuarterlyReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Reports_DeleteQuarterlyReport_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DeleteQuarterlyReportReq)
|
||||
if err := dec(in); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
base := srv.(dubbo3.Dubbo3GrpcService)
|
||||
args := []interface{}{}
|
||||
args = append(args, in)
|
||||
md, _ := metadata.FromIncomingContext(ctx)
|
||||
invAttachment := make(map[string]interface{}, len(md))
|
||||
for k, v := range md {
|
||||
invAttachment[k] = v
|
||||
}
|
||||
invo := invocation.NewRPCInvocation("DeleteQuarterlyReport", args, invAttachment)
|
||||
if interceptor == nil {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
info := &grpc_go.UnaryServerInfo{
|
||||
Server: srv,
|
||||
FullMethod: ctx.Value("XXX_TRIPLE_GO_INTERFACE_NAME").(string),
|
||||
}
|
||||
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
|
||||
result := base.XXX_GetProxyImpl().Invoke(ctx, invo)
|
||||
return result, result.Error()
|
||||
}
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
// Reports_ServiceDesc is the grpc_go.ServiceDesc for Reports service.
|
||||
// It's only intended for direct use with grpc_go.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Reports_ServiceDesc = grpc_go.ServiceDesc{
|
||||
ServiceName: "reports.Reports",
|
||||
HandlerType: (*ReportsServer)(nil),
|
||||
Methods: []grpc_go.MethodDesc{
|
||||
{
|
||||
MethodName: "GetAnnualReportList",
|
||||
Handler: _Reports_GetAnnualReportList_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddAnnualReport",
|
||||
Handler: _Reports_AddAnnualReport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "EditAnnualReport",
|
||||
Handler: _Reports_EditAnnualReport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteAnnualReport",
|
||||
Handler: _Reports_DeleteAnnualReport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "GetQuarterlyReportList",
|
||||
Handler: _Reports_GetQuarterlyReportList_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "AddQuarterlyReport",
|
||||
Handler: _Reports_AddQuarterlyReport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "EditQuarterlyReport",
|
||||
Handler: _Reports_EditQuarterlyReport_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DeleteQuarterlyReport",
|
||||
Handler: _Reports_DeleteQuarterlyReport_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc_go.StreamDesc{},
|
||||
Metadata: "api/reports/reports.proto",
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: api/secFilings/secFilings.proto
|
||||
// source: secFilings.proto
|
||||
|
||||
package secFilings
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.8
|
||||
// - protoc v5.29.2
|
||||
// source: api/secFilings/secFilings.proto
|
||||
// - protoc v3.20.3
|
||||
// source: secFilings.proto
|
||||
|
||||
package secFilings
|
||||
|
||||
@ -503,5 +503,5 @@ var SecFilings_ServiceDesc = grpc_go.ServiceDesc{
|
||||
},
|
||||
},
|
||||
Streams: []grpc_go.StreamDesc{},
|
||||
Metadata: "api/secFilings/secFilings.proto",
|
||||
Metadata: "secFilings.proto",
|
||||
}
|
||||
|
2
clear.sh
Normal file
2
clear.sh
Normal file
@ -0,0 +1,2 @@
|
||||
ls api/reports/*.pb.go | xargs -n1 -IX bash -c 'sed s/,omitempty// X > X.tmp && mv X{.tmp,}';
|
||||
|
@ -21,6 +21,8 @@ func main() {
|
||||
config.SetProviderService(&controller.GovernanceProvider{})
|
||||
config.SetProviderService(&controller.PressReleasesProvider{})
|
||||
config.SetProviderService(&controller.SecFilingsProvider{})
|
||||
config.SetProviderService(&controller.AnnualReportProvider{})
|
||||
config.SetProviderService(&controller.QuarterlyReportProvider{})
|
||||
|
||||
if err := config.Load(); err != nil {
|
||||
panic(err)
|
||||
|
5
conf/prod/config.yaml
Normal file
5
conf/prod/config.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
docDb:
|
||||
host: inner-svc-fontree-mysql-service:3306
|
||||
user: fonchain_opv
|
||||
password: IhQmhg8HZjDmU=Ove5PnA^D
|
||||
dbName: micro-document
|
20
conf/prod/dubbogo.yaml
Normal file
20
conf/prod/dubbogo.yaml
Normal file
@ -0,0 +1,20 @@
|
||||
dubbo:
|
||||
registries:
|
||||
demoZK:
|
||||
protocol: zookeeper
|
||||
address: zookeeper:2181
|
||||
protocols:
|
||||
triple:
|
||||
name: tri
|
||||
port: 20028
|
||||
provider:
|
||||
services:
|
||||
GovernanceProvider:
|
||||
protocol: tri
|
||||
interface: governance.Governance # must be compatible with grpc or dubbo-java
|
||||
PressReleasesProvider:
|
||||
protocol: tri
|
||||
interface: pressreleases.PressReleases # must be compatible with grpc or dubbo-java
|
||||
SecFilingsProvider:
|
||||
protocol: tri
|
||||
interface: com.fontree.microservices.fiee.SecFiling # must be compatible with grpc or dubbo-java
|
31
internel/controller/annualReports.go
Normal file
31
internel/controller/annualReports.go
Normal file
@ -0,0 +1,31 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/logic"
|
||||
)
|
||||
|
||||
type AnnualReportProvider struct {
|
||||
reports.UnimplementedReportsServer
|
||||
}
|
||||
|
||||
// 获取年度报告列表
|
||||
func (AnnualReportProvider) List(_ context.Context, req *reports.GetAnnualReportListReq) (resp *reports.GetAnnualReportListResp, err error) {
|
||||
return logic.AnnualReportsLogic.List(req)
|
||||
}
|
||||
|
||||
// 新增年度报告
|
||||
func (AnnualReportProvider) Add(_ context.Context, req *reports.AddAnnualReportReq) (resp *reports.AddAnnualReportResp, err error) {
|
||||
return logic.AnnualReportsLogic.Add(req)
|
||||
}
|
||||
|
||||
// 编辑年度报告
|
||||
func (AnnualReportProvider) Edit(_ context.Context, req *reports.EditAnnualReportReq) (resp *reports.EditAnnualReportResp, err error) {
|
||||
return logic.AnnualReportsLogic.Edit(req)
|
||||
}
|
||||
|
||||
// 删除年度报告
|
||||
func (AnnualReportProvider) Delete(_ context.Context, req *reports.DeleteAnnualReportReq) (resp *reports.DeleteAnnualReportResp, err error) {
|
||||
return logic.AnnualReportsLogic.Delete(req)
|
||||
}
|
31
internel/controller/quarterlyReport.go
Normal file
31
internel/controller/quarterlyReport.go
Normal file
@ -0,0 +1,31 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"context"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/logic"
|
||||
)
|
||||
|
||||
type QuarterlyReportProvider struct {
|
||||
reports.UnimplementedReportsServer
|
||||
}
|
||||
|
||||
// 获取季度报告列表
|
||||
func (QuarterlyReportProvider) List(_ context.Context, req *reports.GetQuarterlyReportListReq) (resp *reports.GetQuarterlyReportListResp, err error) {
|
||||
return logic.QuarterlyReportsLogic.List(req)
|
||||
}
|
||||
|
||||
// 增加季度报告
|
||||
func (QuarterlyReportProvider) Add(_ context.Context, req *reports.AddQuarterlyReportReq) (resp *reports.AddQuarterlyReportResp, err error) {
|
||||
return logic.QuarterlyReportsLogic.Add(req)
|
||||
}
|
||||
|
||||
// 编辑季度报告
|
||||
func (QuarterlyReportProvider) Edit(_ context.Context, req *reports.EditQuarterlyReportReq) (resp *reports.EditQuarterlyReportResp, err error) {
|
||||
return logic.QuarterlyReportsLogic.Edit(req)
|
||||
}
|
||||
|
||||
// 删除季度报告
|
||||
func (QuarterlyReportProvider) Delete(_ context.Context, req *reports.DeleteQuarterlyReportReq) (resp *reports.DeleteQuarterlyReportResp, err error) {
|
||||
return logic.QuarterlyReportsLogic.Delete(req)
|
||||
}
|
71
internel/dao/annualReports.go
Normal file
71
internel/dao/annualReports.go
Normal file
@ -0,0 +1,71 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/model"
|
||||
"micro-document/pkg/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
type annualReportsDao struct{}
|
||||
|
||||
var AnnualReportsDao = new(annualReportsDao)
|
||||
|
||||
func (annualReportsDao) List(req *reports.GetAnnualReportListReq) (data []model.AnnualReport, total int64, err error) {
|
||||
dbQuery := db.DocDB.Model(&model.AnnualReport{})
|
||||
if req.Filtrate != nil {
|
||||
if req.Filtrate.FileName != "" {
|
||||
dbQuery = dbQuery.Where("file_name LIKE ?", "%"+req.Filtrate.FileName+"%")
|
||||
}
|
||||
if req.Filtrate.Status != 0 {
|
||||
dbQuery = dbQuery.Where("status = ?", req.Filtrate.Status)
|
||||
}
|
||||
}
|
||||
//数据查询
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(req.Page, req.PageSize)).Find(&data).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (annualReportsDao) Add(req *reports.AddAnnualReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.AnnualReport{}).Create(&model.AnnualReport{
|
||||
FileName: req.FileName,
|
||||
Date: req.Date,
|
||||
FileUrl: req.FileUrl,
|
||||
Operator: req.Operator,
|
||||
OperatorID: req.OperatorId,
|
||||
}).Error
|
||||
if err != nil {
|
||||
return errors.New("新增年度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (annualReportsDao) Edit(req *reports.EditAnnualReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.AnnualReport{}).Where("id = ?", req.Id).UpdateColumns(&model.AnnualReport{
|
||||
FileName: req.FileName,
|
||||
Date: req.Date,
|
||||
FileUrl: req.FileUrl,
|
||||
Status: req.Status,
|
||||
Sort: req.Sort,
|
||||
Operator: req.Operator,
|
||||
OperatorID: req.OperatorId,
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
return errors.New("编辑年度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (annualReportsDao) Delete(req *reports.DeleteAnnualReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.AnnualReport{}).Where("id = ?", req.Id).Delete(&model.AnnualReport{}).Error
|
||||
if err != nil {
|
||||
return errors.New("删除年度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
@ -8,7 +8,6 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/go-sql-driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/clause"
|
||||
)
|
||||
|
||||
@ -35,10 +34,8 @@ func (governanceDao) List(req *governance.ListReq) (data []model.Governance, tot
|
||||
|
||||
func (governanceDao) Delete(req *governance.DeleteReq) (err error) {
|
||||
return db.DocDB.Delete(&model.Governance{
|
||||
Model: gorm.Model{
|
||||
ID: uint(req.Id),
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
ID: uint(req.Id),
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
}
|
||||
|
||||
@ -51,9 +48,7 @@ func (governanceDao) Edit(req *governance.EditReq) (err error) {
|
||||
AttachmentName: req.AttachmentName,
|
||||
Operator: req.Operator,
|
||||
OperatorID: int(req.OperatorId),
|
||||
Model: gorm.Model{
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
var mysqlErr *mysql.MySQLError
|
||||
|
@ -92,10 +92,8 @@ func (pressReleasesDao) Edit(req *pressreleases.EditReq) (err error) {
|
||||
OperatorID: uint(req.OperatorId),
|
||||
Content: req.Content,
|
||||
Display: int(req.Display),
|
||||
Model: gorm.Model{
|
||||
CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
var mysqlErr *mysql.MySQLError
|
||||
@ -129,10 +127,8 @@ func (pressReleasesDao) Create(req *pressreleases.CreateReq) (err error) {
|
||||
Content: req.Content,
|
||||
Summary: req.Summary,
|
||||
Display: int(req.Display),
|
||||
Model: gorm.Model{
|
||||
CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
|
||||
UpdatedAt: time.Now(),
|
||||
},
|
||||
CreatedAt: time.UnixMilli(int64(req.CreatedAt)),
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
var mysqlErr *mysql.MySQLError
|
||||
@ -156,9 +152,7 @@ func (pressReleasesDao) Create(req *pressreleases.CreateReq) (err error) {
|
||||
|
||||
func (pressReleasesDao) Delete(req *pressreleases.DeleteReq) (err error) {
|
||||
return db.DocDB.Delete(&model.PressReleases{
|
||||
Model: gorm.Model{
|
||||
ID: uint(req.Id),
|
||||
},
|
||||
ID: uint(req.Id),
|
||||
}).Error
|
||||
}
|
||||
|
||||
|
72
internel/dao/quarterlyReports.go
Normal file
72
internel/dao/quarterlyReports.go
Normal file
@ -0,0 +1,72 @@
|
||||
package dao
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/model"
|
||||
"micro-document/pkg/db"
|
||||
"time"
|
||||
)
|
||||
|
||||
type quarterlyReportsDao struct{}
|
||||
|
||||
var QuarterlyReportsDao = new(quarterlyReportsDao)
|
||||
|
||||
func (quarterlyReportsDao) List(req *reports.GetQuarterlyReportListReq) (data []model.QuarterlyReport, total int64, err error) {
|
||||
dbQuery := db.DocDB.Model(&model.QuarterlyReport{})
|
||||
if req.Filtrate != nil {
|
||||
if req.Filtrate.FileName != "" {
|
||||
dbQuery = dbQuery.Where("file_name LIKE ?", "%"+req.Filtrate.FileName+"%")
|
||||
}
|
||||
if req.Filtrate.Status != 0 {
|
||||
dbQuery = dbQuery.Where("status = ?", req.Filtrate.Status)
|
||||
}
|
||||
}
|
||||
dbQuery.Count(&total)
|
||||
err = dbQuery.Scopes(db.Pagination(req.Page, req.PageSize)).Find(&data).Error
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (quarterlyReportsDao) Add(req *reports.AddQuarterlyReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.QuarterlyReport{}).Create(&model.QuarterlyReport{
|
||||
FileName: req.FileName,
|
||||
FileIntroduce: req.FileIntroduce,
|
||||
Attachment: req.Attachment,
|
||||
AttachmentName: req.AttachmentName,
|
||||
Operator: req.Operator,
|
||||
OperatorID: req.OperatorId,
|
||||
}).Error
|
||||
if err != nil {
|
||||
return errors.New("新增季度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (quarterlyReportsDao) Edit(req *reports.EditQuarterlyReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.QuarterlyReport{}).Where("id = ?", req.Id).UpdateColumns(&model.QuarterlyReport{
|
||||
FileName: req.FileName,
|
||||
FileIntroduce: req.FileIntroduce,
|
||||
Attachment: req.Attachment,
|
||||
AttachmentName: req.AttachmentName,
|
||||
Status: req.Status,
|
||||
Sort: req.Sort,
|
||||
Operator: req.Operator,
|
||||
OperatorID: req.OperatorId,
|
||||
UpdatedAt: time.Now(),
|
||||
}).Error
|
||||
if err != nil {
|
||||
return errors.New("编辑季度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (quarterlyReportsDao) Delete(req *reports.DeleteQuarterlyReportReq) (err error) {
|
||||
err = db.DocDB.Model(&model.QuarterlyReport{}).Where("id = ?", req.Id).Delete(&model.QuarterlyReport{}).Error
|
||||
if err != nil {
|
||||
return errors.New("删除季度报告失败")
|
||||
}
|
||||
return
|
||||
}
|
@ -30,7 +30,7 @@ func (secFilingsDao) CreateSecFiling(req *secFilings.CreateSecFilingReq) (*secFi
|
||||
}
|
||||
j, err := json.Marshal(dataFiles)
|
||||
if err != nil {
|
||||
return nil, errors.New("datafiles文件json转换失败: " + err.Error())
|
||||
return nil, errors.New("文件转换失败")
|
||||
}
|
||||
filingKey := model.GenFilingKey(req.FilingDate, req.Form, req.FileLink)
|
||||
var count int64
|
||||
@ -38,7 +38,7 @@ func (secFilingsDao) CreateSecFiling(req *secFilings.CreateSecFilingReq) (*secFi
|
||||
return nil, err
|
||||
}
|
||||
if count != 0 {
|
||||
return nil, errors.New("filing_key已存在")
|
||||
return nil, errors.New("key已存在,创建失败")
|
||||
}
|
||||
if err := db.DocDB.Model(&model.SecFilings{}).Create(&model.SecFilings{
|
||||
FilingKey: filingKey,
|
||||
@ -57,7 +57,6 @@ func (secFilingsDao) CreateSecFiling(req *secFilings.CreateSecFilingReq) (*secFi
|
||||
return nil, err
|
||||
}
|
||||
resp.FilingKey = filingKey
|
||||
resp.Msg = "create success"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsDao) UpdateSecFiling(query map[string]string, column map[string]interface{}) (*secFilings.CommonResp, error) {
|
||||
@ -65,7 +64,6 @@ func (secFilingsDao) UpdateSecFiling(query map[string]string, column map[string]
|
||||
if err := db.DocDB.Model(&model.SecFilings{}).Where("filing_key = ?", query["filing_key"]).Updates(column).Error; err != nil {
|
||||
return nil, err
|
||||
}
|
||||
resp.Msg = "update success"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsDao) ListSecFiling(req *secFilings.ListSecFilingReq) (res []*model.SecFilings, total int64, err error) {
|
||||
@ -75,7 +73,7 @@ func (secFilingsDao) ListSecFiling(req *secFilings.ListSecFilingReq) (res []*mod
|
||||
query = query.Where("form LIKE ?", "%"+form+"%")
|
||||
}
|
||||
if req.FilingDateBegin != "" && req.FilingDateEnd != "" && req.FilingDateBegin > req.FilingDateEnd {
|
||||
return nil, 0, errors.New("开始日期不能大于结束日期")
|
||||
return nil, 0, errors.New("开始日期超过结束日期")
|
||||
|
||||
}
|
||||
|
||||
@ -143,7 +141,6 @@ func (secFilingsDao) UpdateSecFilingStatus(query map[string]string, column map[s
|
||||
return nil, err
|
||||
}
|
||||
resp.FilingKey = query["filing_key"]
|
||||
resp.Msg = "update status success"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsDao) ListFormType(req *secFilings.ListFormTypeReq) (res []*model.FormType, total int64, err error) {
|
||||
|
60
internel/logic/annualReports.go
Normal file
60
internel/logic/annualReports.go
Normal file
@ -0,0 +1,60 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/dao"
|
||||
util "micro-document/pkg/utils"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type annualReportsLogic struct{}
|
||||
|
||||
var AnnualReportsLogic = new(annualReportsLogic)
|
||||
|
||||
func (annualReportsLogic) List(req *reports.GetAnnualReportListReq) (result *reports.GetAnnualReportListResp, err error) {
|
||||
result = &reports.GetAnnualReportListResp{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
data, total, err := dao.AnnualReportsDao.List(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询年度报告失败")
|
||||
}
|
||||
result.Total = int32(total)
|
||||
if err = copier.CopyWithOption(&result.Data, &data, util.CopierProtoOptions); err != nil {
|
||||
return nil, errors.New("复制年度报告失败")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (annualReportsLogic) Add(req *reports.AddAnnualReportReq) (result *reports.AddAnnualReportResp, err error) {
|
||||
result = &reports.AddAnnualReportResp{}
|
||||
err = dao.AnnualReportsDao.Add(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("新增年度报告失败")
|
||||
}
|
||||
result.Msg = "新增年度报告成功"
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (annualReportsLogic) Edit(req *reports.EditAnnualReportReq) (result *reports.EditAnnualReportResp, err error) {
|
||||
result = &reports.EditAnnualReportResp{}
|
||||
err = dao.AnnualReportsDao.Edit(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("编辑年度报告失败")
|
||||
}
|
||||
result.Msg = "编辑年度报告成功"
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (annualReportsLogic) Delete(req *reports.DeleteAnnualReportReq) (result *reports.DeleteAnnualReportResp, err error) {
|
||||
result = &reports.DeleteAnnualReportResp{}
|
||||
err = dao.AnnualReportsDao.Delete(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("删除年度报告失败")
|
||||
}
|
||||
result.Msg = "删除年度报告成功"
|
||||
return result, nil
|
||||
}
|
64
internel/logic/quarterlyReports.go
Normal file
64
internel/logic/quarterlyReports.go
Normal file
@ -0,0 +1,64 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"micro-document/api/reports"
|
||||
"micro-document/internel/dao"
|
||||
util "micro-document/pkg/utils"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
type quarterlyReportsLogic struct{}
|
||||
|
||||
var QuarterlyReportsLogic = new(quarterlyReportsLogic)
|
||||
|
||||
// 获取季度报告列表
|
||||
func (quarterlyReportsLogic) List(req *reports.GetQuarterlyReportListReq) (result *reports.GetQuarterlyReportListResp, err error) {
|
||||
result = &reports.GetQuarterlyReportListResp{
|
||||
Page: req.Page,
|
||||
PageSize: req.PageSize,
|
||||
}
|
||||
data, total, err := dao.QuarterlyReportsDao.List(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询季度报告失败")
|
||||
}
|
||||
result.Total = int32(total)
|
||||
if err = copier.CopyWithOption(&result.Data, &data, util.CopierProtoOptions); err != nil {
|
||||
return nil, errors.New("复制季度报告失败")
|
||||
}
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 增加季度报告
|
||||
func (quarterlyReportsLogic) Add(req *reports.AddQuarterlyReportReq) (result *reports.AddQuarterlyReportResp, err error) {
|
||||
result = &reports.AddQuarterlyReportResp{}
|
||||
err = dao.QuarterlyReportsDao.Add(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("新增季度报告失败")
|
||||
}
|
||||
result.Msg = "新增季度报告成功"
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 编辑季度报告
|
||||
func (quarterlyReportsLogic) Edit(req *reports.EditQuarterlyReportReq) (result *reports.EditQuarterlyReportResp, err error) {
|
||||
result = &reports.EditQuarterlyReportResp{}
|
||||
err = dao.QuarterlyReportsDao.Edit(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("编辑季度报告失败")
|
||||
}
|
||||
result.Msg = "编辑季度报告成功"
|
||||
return result, nil
|
||||
}
|
||||
|
||||
// 删除季度报告
|
||||
func (quarterlyReportsLogic) Delete(req *reports.DeleteQuarterlyReportReq) (result *reports.DeleteQuarterlyReportResp, err error) {
|
||||
result = &reports.DeleteQuarterlyReportResp{}
|
||||
err = dao.QuarterlyReportsDao.Delete(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("删除季度报告失败")
|
||||
}
|
||||
result.Msg = "删除季度报告成功"
|
||||
return result, nil
|
||||
}
|
@ -16,14 +16,13 @@ var SecFilingsLogic = new(secFilingsLogic)
|
||||
func (secFilingsLogic) CreateSecFiling(req *secFilings.CreateSecFilingReq) (*secFilings.CommonResp, error) {
|
||||
resp, err := dao.SecFilingsDao.CreateSecFiling(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("创建失败:" + err.Error())
|
||||
return nil, errors.New("创建失败")
|
||||
}
|
||||
resp.Msg = "创建成功"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsLogic) UpdateSecFiling(req *secFilings.UpdateSecFilingReq) (*secFilings.CommonResp, error) {
|
||||
if req.FilingKey == "" {
|
||||
return nil, errors.New("filing_key is empty")
|
||||
return nil, errors.New("参数缺失")
|
||||
}
|
||||
filingKey := model.GenFilingKey(req.FilingDate, req.Form, req.FileLink)
|
||||
column := map[string]interface{}{
|
||||
@ -44,10 +43,9 @@ func (secFilingsLogic) UpdateSecFiling(req *secFilings.UpdateSecFilingReq) (*sec
|
||||
}
|
||||
resp, err := dao.SecFilingsDao.UpdateSecFiling(query, column)
|
||||
if err != nil {
|
||||
return nil, errors.New("更新失败:" + err.Error())
|
||||
return nil, errors.New("更新失败")
|
||||
}
|
||||
resp.FilingKey = filingKey
|
||||
resp.Msg = "更新成功"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsLogic) ListSecFiling(req *secFilings.ListSecFilingReq) (*secFilings.SecFilingListResp, error) {
|
||||
@ -55,13 +53,13 @@ func (secFilingsLogic) ListSecFiling(req *secFilings.ListSecFilingReq) (*secFili
|
||||
datas := []*secFilings.SecFiling{}
|
||||
list, total, err := dao.SecFilingsDao.ListSecFiling(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询失败:" + err.Error())
|
||||
return nil, errors.New("查询失败")
|
||||
}
|
||||
for _, item := range list {
|
||||
dataFiles := []*secFilings.DataFiles{}
|
||||
if item.DataFiles != nil && len(item.DataFiles) != 0 {
|
||||
if err := json.Unmarshal(item.DataFiles, &dataFiles); err != nil {
|
||||
return nil, errors.New("datafiles文件json转换失败: " + err.Error())
|
||||
return nil, errors.New("文件转换失败")
|
||||
}
|
||||
}
|
||||
datas = append(datas, &secFilings.SecFiling{
|
||||
@ -84,7 +82,6 @@ func (secFilingsLogic) ListSecFiling(req *secFilings.ListSecFilingReq) (*secFili
|
||||
})
|
||||
}
|
||||
resp.Total = uint32(total)
|
||||
resp.Msg = "查询成功"
|
||||
resp.Data = datas
|
||||
return resp, nil
|
||||
|
||||
@ -92,15 +89,15 @@ func (secFilingsLogic) ListSecFiling(req *secFilings.ListSecFilingReq) (*secFili
|
||||
func (secFilingsLogic) DetailSecFiling(req *secFilings.DetailSecFilingReq) (*secFilings.SecFilingDetailResp, error) {
|
||||
resp := &secFilings.SecFilingDetailResp{}
|
||||
if req.FilingKey == "" {
|
||||
return nil, errors.New("filing_key is empty")
|
||||
return nil, errors.New("参数缺失")
|
||||
}
|
||||
detail, err := dao.SecFilingsDao.DetailSecFiling(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询失败:" + err.Error())
|
||||
return nil, errors.New("查询失败")
|
||||
}
|
||||
var dataFiles []*secFilings.DataFiles
|
||||
if err := json.Unmarshal(detail.DataFiles, &dataFiles); err != nil {
|
||||
return nil, errors.New("datafiles文件json转换失败: " + err.Error())
|
||||
return nil, errors.New("文件转换失败")
|
||||
}
|
||||
data := &secFilings.SecFiling{
|
||||
FilingKey: detail.FilingKey,
|
||||
@ -119,41 +116,39 @@ func (secFilingsLogic) DetailSecFiling(req *secFilings.DetailSecFilingReq) (*sec
|
||||
CreatedAt: time.Unix(detail.CreatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||
UpdatedAt: time.Unix(detail.UpdatedAt, 0).Format("2006-01-02 15:04:05"),
|
||||
}
|
||||
resp.Msg = "查询成功"
|
||||
resp.Data = data
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsLogic) DeleteSecFiling(req *secFilings.DeleteSecFilingReq) (*secFilings.CommonResp, error) {
|
||||
resp := &secFilings.CommonResp{}
|
||||
if req.FilingKey == "" {
|
||||
return nil, errors.New("filing_key is empty")
|
||||
return nil, errors.New("参数缺失")
|
||||
}
|
||||
if err := dao.SecFilingsDao.DeleteSecFiling(req); err != nil {
|
||||
return nil, errors.New("删除失败:" + err.Error())
|
||||
return nil, errors.New("删除失败")
|
||||
}
|
||||
resp.Msg = "删除成功"
|
||||
return resp, nil
|
||||
}
|
||||
|
||||
func (secFilingsLogic) IsSecFilingExist(req *secFilings.IsSecFilingExistReq) (*secFilings.IsSecFilingExistResp, error) {
|
||||
resp := &secFilings.IsSecFilingExistResp{}
|
||||
if req.FilingDate == "" || req.Form == "" || req.FinalLink == "" {
|
||||
return nil, errors.New("filing_date or form_type or final_link is empty")
|
||||
return nil, errors.New("参数缺失")
|
||||
}
|
||||
filingKey := model.GenFilingKey(req.FilingDate, req.Form, req.FinalLink)
|
||||
exist, err := dao.SecFilingsDao.IsSecFilingExist(filingKey, req.FilingDate)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询失败:" + err.Error())
|
||||
return nil, errors.New("查询失败")
|
||||
}
|
||||
resp.Exist = exist
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsLogic) UpdateSecFilingStatus(req *secFilings.UpdateSecFilingStatusReq) (*secFilings.CommonResp, error) {
|
||||
if req.FilingKey == "" {
|
||||
return nil, errors.New("filing_key is empty")
|
||||
return nil, errors.New("参数缺失")
|
||||
}
|
||||
if req.Status != 1 && req.Status != 2 {
|
||||
return nil, errors.New("invalid status value")
|
||||
return nil, errors.New("状态值无效")
|
||||
}
|
||||
column := map[string]interface{}{
|
||||
"status": req.Status,
|
||||
@ -165,16 +160,15 @@ func (secFilingsLogic) UpdateSecFilingStatus(req *secFilings.UpdateSecFilingStat
|
||||
}
|
||||
resp, err := dao.SecFilingsDao.UpdateSecFilingStatus(query, column)
|
||||
if err != nil {
|
||||
return nil, errors.New("更新状态失败:" + err.Error())
|
||||
return nil, errors.New("更新状态失败")
|
||||
}
|
||||
resp.Msg = "状态更新成功"
|
||||
return resp, nil
|
||||
}
|
||||
func (secFilingsLogic) ListFormType(req *secFilings.ListFormTypeReq) (*secFilings.FormTypeListResp, error) {
|
||||
resp := &secFilings.FormTypeListResp{}
|
||||
list, total, err := dao.SecFilingsDao.ListFormType(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询失败:" + err.Error())
|
||||
return nil, errors.New("查询失败")
|
||||
}
|
||||
for _, item := range list {
|
||||
resp.FormType = append(resp.FormType, &secFilings.FormType{
|
||||
@ -190,13 +184,13 @@ func (secFilingsLogic) WebListSecFiling(req *secFilings.WebListSecFilingReq) (*s
|
||||
datas := []*secFilings.SecFiling{}
|
||||
list, total, err := dao.SecFilingsDao.WebListSecFiling(req)
|
||||
if err != nil {
|
||||
return nil, errors.New("查询失败:" + err.Error())
|
||||
return nil, errors.New("查询失败")
|
||||
}
|
||||
for _, item := range list {
|
||||
dataFiles := []*secFilings.DataFiles{}
|
||||
if item.DataFiles != nil && len(item.DataFiles) != 0 {
|
||||
if err := json.Unmarshal(item.DataFiles, &dataFiles); err != nil {
|
||||
return nil, errors.New("datafiles文件json转换失败: " + err.Error())
|
||||
return nil, errors.New("文件转换失败")
|
||||
}
|
||||
}
|
||||
datas = append(datas, &secFilings.SecFiling{
|
||||
@ -219,7 +213,6 @@ func (secFilingsLogic) WebListSecFiling(req *secFilings.WebListSecFilingReq) (*s
|
||||
})
|
||||
}
|
||||
resp.Total = uint32(total)
|
||||
resp.Msg = "查询成功"
|
||||
resp.Data = datas
|
||||
return resp, nil
|
||||
}
|
||||
|
@ -1,16 +1,23 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type Governance struct {
|
||||
gorm.Model
|
||||
Title string `gorm:"type:varchar(100);uniqueIndex:governance_unique;not null"`
|
||||
Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"`
|
||||
AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"`
|
||||
Sort int `gorm:"comment:排序"`
|
||||
Status int `gorm:"comment:状态 1下架 2 上架"`
|
||||
Operator string `gorm:"type:varchar(50);comment:操作人"`
|
||||
OperatorID int `gorm:"column:operator_id;comment:操作人Id"`
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"`
|
||||
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"`
|
||||
Attachment string `gorm:"type:varchar(1024);not null;default:'';comment:附件链接"`
|
||||
AttachmentName string `gorm:"type:varchar(1024);not null;default:'';comment:附件文件名"`
|
||||
Sort int `gorm:"comment:排序"`
|
||||
Status int `gorm:"comment:状态 1下架 2 上架"`
|
||||
Operator string `gorm:"type:varchar(50);comment:操作人"`
|
||||
OperatorID int `gorm:"column:operator_id;comment:操作人Id"`
|
||||
}
|
||||
|
||||
func (*Governance) TableName() string {
|
||||
|
@ -1,19 +1,26 @@
|
||||
package model
|
||||
|
||||
import "gorm.io/gorm"
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type PressReleases struct {
|
||||
gorm.Model
|
||||
Title string `gorm:"type:varchar(100);uniqueIndex:press_releases_unique"`
|
||||
Sort uint `gorm:"not null"`
|
||||
Content string `gorm:"type:longtext"`
|
||||
Attachment string `gorm:"type:varchar(1024)"`
|
||||
Display int `gorm:"comment:状态 1不展示 2 展示"`
|
||||
Summary string `gorm:"type:text;comment:摘要"`
|
||||
Status int `gorm:"comment:状态 1下架 2 上架"`
|
||||
Operator string `gorm:"type:varchar(100)"`
|
||||
OperatorID uint `gorm:"column:operator_id"`
|
||||
AttachmentName string `gorm:"type:varchar(1024)"`
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_governance_deleted_at;uniqueIndex:governance_unique;"`
|
||||
Title string `gorm:"column:title;type:varchar(100);not null;uniqueIndex:governance_unique"`
|
||||
Sort uint `gorm:"not null"`
|
||||
Content string `gorm:"type:longtext"`
|
||||
Attachment string `gorm:"type:varchar(1024)"`
|
||||
Display int `gorm:"comment:状态 1不展示 2 展示"`
|
||||
Summary string `gorm:"type:text;comment:摘要"`
|
||||
Status int `gorm:"comment:状态 1下架 2 上架"`
|
||||
Operator string `gorm:"type:varchar(100)"`
|
||||
OperatorID uint `gorm:"column:operator_id"`
|
||||
AttachmentName string `gorm:"type:varchar(1024)"`
|
||||
}
|
||||
|
||||
func (*PressReleases) TableName() string {
|
||||
|
44
internel/model/reports.go
Normal file
44
internel/model/reports.go
Normal file
@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type AnnualReport struct {
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_annual_report_deleted_at;"`
|
||||
FileName string `gorm:"column:file_name;type:varchar(100);not null;default:'';comment:文件名称"`
|
||||
Date string `gorm:"column:date;type:varchar(100);not null;default:'';comment:日期"`
|
||||
FileUrl string `gorm:"column:file_url;type:varchar(100);not null;default:'';comment:访问地址"`
|
||||
Status int32 `gorm:"column:status;type:int;not null;default:2;comment:状态:1上架 2 下架"`
|
||||
Sort int32 `gorm:"column:sort;type:int;not null;default:1;comment:排序"`
|
||||
Operator string `gorm:"column:operator;type:varchar(100);not null;default:'';comment:操作人"`
|
||||
OperatorID int32 `gorm:"column:operator_id;comment:操作人Id"`
|
||||
}
|
||||
|
||||
func (*AnnualReport) TableName() string {
|
||||
return "annual_report"
|
||||
}
|
||||
|
||||
type QuarterlyReport struct {
|
||||
ID uint `gorm:"primarykey"`
|
||||
CreatedAt time.Time
|
||||
UpdatedAt time.Time
|
||||
DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;index:idx_quarterly_report_deleted_at;"`
|
||||
FileName string `gorm:"column:file_name;type:varchar(100);not null;default:'';comment:文件名称"`
|
||||
FileIntroduce string `gorm:"column:file_introduce;type:varchar(100);not null;default:'';comment:文件介绍"`
|
||||
Attachment string `gorm:"column:attachment;type:varchar(100);not null;default:'';comment:附件"`
|
||||
AttachmentName string `gorm:"column:attachment_name;type:varchar(100);not null;default:'';comment:附件名称"`
|
||||
Status int32 `gorm:"column:status;type:int;not null;default:2;comment:状态:1上架 2 下架"`
|
||||
Sort int32 `gorm:"column:sort;type:int;not null;default:1;comment:排序"`
|
||||
Operator string `gorm:"column:operator;type:varchar(100);not null;default:'';comment:操作人"`
|
||||
OperatorID int32 `gorm:"column:operator_id;comment:操作人Id"`
|
||||
}
|
||||
|
||||
func (*QuarterlyReport) TableName() string {
|
||||
return "quarterly_report"
|
||||
}
|
@ -35,6 +35,13 @@ func DbInit() {
|
||||
}
|
||||
DocDB = dbq.Debug()
|
||||
DocDB.Set("gorm:table_options", "ENGINE=InnoDB default charset=utf8")
|
||||
DocDB.AutoMigrate(&model.Governance{}, &model.PressReleases{}, &model.SecFilings{}, &model.FormType{})
|
||||
DocDB.AutoMigrate(
|
||||
&model.Governance{},
|
||||
&model.PressReleases{},
|
||||
&model.SecFilings{},
|
||||
&model.FormType{},
|
||||
&model.AnnualReport{},
|
||||
&model.QuarterlyReport{},
|
||||
)
|
||||
}
|
||||
}
|
||||
|
13
pkg/db/dto.go
Normal file
13
pkg/db/dto.go
Normal file
@ -0,0 +1,13 @@
|
||||
package db
|
||||
|
||||
import "gorm.io/gorm"
|
||||
|
||||
func Pagination[T int | int32 | int64](page T, pageSize T) func(db *gorm.DB) *gorm.DB {
|
||||
if page == 0 || pageSize == 0 {
|
||||
page = 1
|
||||
pageSize = 15
|
||||
}
|
||||
return func(db *gorm.DB) *gorm.DB {
|
||||
return db.Limit(int(pageSize)).Offset(int((page - 1) * pageSize))
|
||||
}
|
||||
}
|
40
pkg/utils/copierOptions.go
Normal file
40
pkg/utils/copierOptions.go
Normal file
@ -0,0 +1,40 @@
|
||||
package util
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"micro-document/pkg/utils/stime"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
var CopierProtoOptions = copier.Option{
|
||||
IgnoreEmpty: true,
|
||||
DeepCopy: true,
|
||||
Converters: []copier.TypeConverter{
|
||||
{
|
||||
SrcType: time.Time{},
|
||||
DstType: copier.String,
|
||||
Fn: func(src interface{}) (interface{}, error) {
|
||||
s, ok := src.(time.Time)
|
||||
if !ok {
|
||||
return nil, errors.New("src type :time.Time not matching")
|
||||
}
|
||||
return s.Format(stime.Format_Normal_YMDhms), nil
|
||||
},
|
||||
},
|
||||
{
|
||||
SrcType: copier.String,
|
||||
DstType: time.Time{},
|
||||
Fn: func(src interface{}) (interface{}, error) {
|
||||
s, ok := src.(string)
|
||||
if !ok {
|
||||
return nil, errors.New("src type :time.Time not matching")
|
||||
}
|
||||
tt, err := stime.StringToTimeWithFormat(s, stime.Format_Normal_YMDhms)
|
||||
return *tt, err
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
84
pkg/utils/stime/common.go
Normal file
84
pkg/utils/stime/common.go
Normal file
@ -0,0 +1,84 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
var Loc loc
|
||||
|
||||
type loc time.Location
|
||||
|
||||
func (l loc) Shanghai() *time.Location {
|
||||
var shanghai, err = time.LoadLocation("Asia/Shanghai")
|
||||
if err != nil {
|
||||
shanghai = time.FixedZone("CST", 8*3600)
|
||||
}
|
||||
return shanghai
|
||||
}
|
||||
|
||||
const (
|
||||
//常规时间格式(日期带横杠)
|
||||
Format_Normal_YMDhms = "2006-01-02 15:04:05"
|
||||
Format_Normal_YMD = "2006-01-02"
|
||||
Format_Normal_hms = "15:04:05"
|
||||
Format_Normal_hm = "15:04"
|
||||
Format_Normal_YM = "2006-01"
|
||||
//带斜杠的时间格式
|
||||
Format_Slash_YMDhms = "2006/01/02 15:04:05"
|
||||
Format_Slash_YMD = "2006/01/02"
|
||||
//无间隔符
|
||||
Format_NoSpacer_YMDhms = "20060102150405"
|
||||
Format_NoSpacer_YMD = "20060102"
|
||||
Format_ChinaChar_YMD = "2006年01月02日"
|
||||
Format_ChinaChar_YMDhm = "2006年01月02日 15时04分"
|
||||
Format_DB_YMDhms = "2006-01-02T15:04:05+08:00"
|
||||
)
|
||||
|
||||
var MonthStrMap = map[string]string{
|
||||
"January": "01",
|
||||
"February": "02",
|
||||
"March": "03",
|
||||
"April": "04",
|
||||
"May": "05",
|
||||
"June": "06",
|
||||
"July": "07",
|
||||
"August": "08",
|
||||
"September": "09",
|
||||
"October": "10",
|
||||
"November": "11",
|
||||
"December": "12",
|
||||
}
|
||||
var MonthIntMap = map[string]int{
|
||||
"January": 1,
|
||||
"February": 2,
|
||||
"March": 3,
|
||||
"April": 4,
|
||||
"May": 5,
|
||||
"June": 6,
|
||||
"July": 7,
|
||||
"August": 8,
|
||||
"September": 9,
|
||||
"October": 10,
|
||||
"November": 11,
|
||||
"December": 12,
|
||||
}
|
||||
|
||||
var WeekIntMap = map[string]int{
|
||||
"Monday": 1,
|
||||
"Tuesday": 2,
|
||||
"Wednesday": 3,
|
||||
"Thursday": 4,
|
||||
"Friday": 5,
|
||||
"Saturday": 6,
|
||||
"Sunday": 7,
|
||||
}
|
||||
|
||||
var WeekStrMap = map[string]string{
|
||||
"Monday": "一",
|
||||
"Tuesday": "二",
|
||||
"Wednesday": "三",
|
||||
"Thursday": "四",
|
||||
"Friday": "五",
|
||||
"Saturday": "六",
|
||||
"Sunday": "日",
|
||||
}
|
150
pkg/utils/stime/getTime.go
Normal file
150
pkg/utils/stime/getTime.go
Normal file
@ -0,0 +1,150 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func StrNowDate() string {
|
||||
return TimeToString(time.Now(), Format_Normal_YMD)
|
||||
}
|
||||
|
||||
func StrNowYearMonth() string {
|
||||
return TimeToString(time.Now(), Format_Normal_YM)
|
||||
}
|
||||
|
||||
// ThisMorming 今天凌晨
|
||||
func ThisMorming(format string) (strTime string) {
|
||||
thisTime := time.Now()
|
||||
year := thisTime.Year()
|
||||
month := MonthStrMap[thisTime.Month().String()]
|
||||
day := fmt.Sprintf("%02d", thisTime.Day())
|
||||
strTime = fmt.Sprintf("%v-%v-%v 00:00:00", year, month, day)
|
||||
if format != Format_Normal_YMDhms {
|
||||
t1, _ := time.ParseInLocation(Format_Normal_YMDhms, strTime, Loc.Shanghai())
|
||||
strTime = t1.Format(format)
|
||||
}
|
||||
return strTime
|
||||
}
|
||||
|
||||
// ThisMorningUnix 获取当日凌晨的时间戳
|
||||
func ThisMorningToUnix() int64 {
|
||||
thist := time.Now()
|
||||
zero_tm := time.Date(thist.Year(), thist.Month(), thist.Day(), 0, 0, 0, 0, thist.Location()).Unix()
|
||||
return zero_tm
|
||||
}
|
||||
|
||||
// TomorrowMorning 第二天凌晨
|
||||
func TomorrowMorning(baseTime time.Time) *time.Time {
|
||||
year := baseTime.Year()
|
||||
month := MonthStrMap[baseTime.Month().String()]
|
||||
day := fmt.Sprintf("%02d", baseTime.Day()+1)
|
||||
strTime := fmt.Sprintf("%v-%v-%v 00:00:00", year, month, day)
|
||||
res, _ := StringToTime(strTime)
|
||||
return res
|
||||
}
|
||||
|
||||
// ThisTimeUnix 获取当前时间的时间戳
|
||||
func CurrentimeToUnix() int64 {
|
||||
return time.Now().Unix()
|
||||
}
|
||||
|
||||
// Currentime 获取当前时间
|
||||
func Currentime(format string) (strTime string) {
|
||||
strTime = time.Now().Format(format)
|
||||
return
|
||||
}
|
||||
|
||||
// HoursAgo 若干小时之前的时间
|
||||
func HoursAgo(hours time.Duration, format string) (lastTimeStr string) {
|
||||
lastStamp := time.Now().Unix() - int64((time.Hour * hours).Seconds())
|
||||
lastTime := time.Unix(lastStamp, 0).In(Loc.Shanghai())
|
||||
lastTimeStr = lastTime.Format(format)
|
||||
return
|
||||
}
|
||||
|
||||
// TimeToString 时间转字符串
|
||||
func TimeToString(t time.Time, format string) string {
|
||||
return t.Format(format)
|
||||
}
|
||||
|
||||
// 计算指定月份的天数
|
||||
func YearMonthToDayNumber(year int, month int) int {
|
||||
// 有31天的月份
|
||||
day31 := map[int]bool{
|
||||
1: true,
|
||||
3: true,
|
||||
5: true,
|
||||
7: true,
|
||||
8: true,
|
||||
10: true,
|
||||
12: true,
|
||||
}
|
||||
if day31[month] == true {
|
||||
return 31
|
||||
}
|
||||
// 有30天的月份
|
||||
day30 := map[int]bool{
|
||||
4: true,
|
||||
6: true,
|
||||
9: true,
|
||||
11: true,
|
||||
}
|
||||
if day30[month] == true {
|
||||
return 30
|
||||
}
|
||||
// 计算是平年还是闰年
|
||||
if (year%4 == 0 && year%100 != 0) || year%400 == 0 {
|
||||
// 得出2月的天数
|
||||
return 29
|
||||
}
|
||||
// 得出2月的天数
|
||||
return 28
|
||||
}
|
||||
|
||||
// 求时间差(返回一个数字,该数字单位由传过来的unit决定。若unit为60,则单位是分钟。)
|
||||
func GetDiffTime(start_time string, end_time string, unit int64) int64 {
|
||||
// 转成时间戳
|
||||
if len(start_time) == 10 {
|
||||
start_time = fmt.Sprintf("%v 00:00:00", start_time)
|
||||
}
|
||||
if len(end_time) == 10 {
|
||||
end_time = fmt.Sprintf("%v 00:00:00", end_time)
|
||||
}
|
||||
startUnix, _ := time.ParseInLocation("2006-01-02 15:04:05", start_time, Loc.Shanghai())
|
||||
endUnix, _ := time.ParseInLocation("2006-01-02 15:04:05", end_time, Loc.Shanghai())
|
||||
startTime := startUnix.Unix()
|
||||
endTime := endUnix.Unix()
|
||||
// 求相差天数
|
||||
date := (endTime - startTime) / unit
|
||||
return date
|
||||
}
|
||||
|
||||
func TimeSince(pastTime string, format string) string {
|
||||
|
||||
t, err := time.Parse(format, pastTime)
|
||||
if err != nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
diff := time.Since(t)
|
||||
if diff.Minutes() < 15 {
|
||||
return "刚刚"
|
||||
} else if diff.Minutes() >= 15 && diff.Minutes() < 30 {
|
||||
return "15分钟前"
|
||||
} else if diff.Minutes() >= 30 && diff.Minutes() < 60 {
|
||||
return "半小时前"
|
||||
} else if diff.Hours() >= 1 && diff.Hours() < 24 {
|
||||
return fmt.Sprintf("%d小时前", int(diff.Hours()))
|
||||
} else if diff.Hours() >= 24 && diff.Hours() < 24*15 {
|
||||
return fmt.Sprintf("%d天前", int(diff.Hours()/24))
|
||||
} else if diff.Hours() < 24*30 {
|
||||
return "半月前"
|
||||
} else if diff.Hours() < 24*30*6 { //小于半年
|
||||
return fmt.Sprintf("%d月前", int(diff.Hours()/24/30))
|
||||
} else if diff.Hours() < 24*365 { //小于1年
|
||||
return "半年前"
|
||||
} else {
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
}
|
101
pkg/utils/stime/getTimeExt.go
Normal file
101
pkg/utils/stime/getTimeExt.go
Normal file
@ -0,0 +1,101 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
// 根据指定时间获取后面的若干天工作日列表
|
||||
// param baseOn 指定基准时间
|
||||
// param daysNum 获取工作日的数量
|
||||
func GetWorkDayList(baseOn *time.Time, daysNum int) []time.Time {
|
||||
var timeList []time.Time
|
||||
var basCount = 1
|
||||
var workDay time.Time
|
||||
for {
|
||||
if len(timeList) == daysNum {
|
||||
break
|
||||
}
|
||||
workDay = baseOn.AddDate(0, 0, basCount)
|
||||
switch workDay.Weekday() {
|
||||
case time.Saturday:
|
||||
basCount += 2
|
||||
continue
|
||||
case time.Sunday:
|
||||
basCount++
|
||||
continue
|
||||
default:
|
||||
timeList = append(timeList, workDay)
|
||||
basCount++
|
||||
}
|
||||
}
|
||||
return timeList
|
||||
}
|
||||
|
||||
// 根据指定时间获取后面的若干天工作日列表
|
||||
// param baseOn 指定基准时间
|
||||
// param daysNum 获取工作日的数量
|
||||
func GetWorkDayStrList(baseOn *time.Time, daysNum int) []string {
|
||||
var timeList []string
|
||||
var basCount = 1
|
||||
var workDay time.Time
|
||||
for {
|
||||
if len(timeList) == daysNum {
|
||||
break
|
||||
}
|
||||
workDay = baseOn.AddDate(0, 0, basCount)
|
||||
switch workDay.Weekday() {
|
||||
case time.Saturday:
|
||||
basCount += 2
|
||||
continue
|
||||
case time.Sunday:
|
||||
basCount++
|
||||
continue
|
||||
default:
|
||||
timeList = append(timeList, TimeToString(workDay, Format_Normal_YMD))
|
||||
basCount++
|
||||
}
|
||||
}
|
||||
return timeList
|
||||
}
|
||||
|
||||
// 获取时间差文字描述
|
||||
func GetTimeDifferenceDesc(now *time.Time, before *time.Time) string {
|
||||
if before == nil {
|
||||
return ""
|
||||
}
|
||||
if now.After(*before) {
|
||||
subTimestamp := now.Unix() - before.Unix()
|
||||
day := subTimestamp / (3600 * 24)
|
||||
hour := (subTimestamp - day*3600*24) / 3600
|
||||
minute := (subTimestamp - day*3600*24 - hour*3600) / 60
|
||||
second := subTimestamp - day*3600*24 - hour*3600 - minute*60
|
||||
|
||||
switch {
|
||||
case day > 0:
|
||||
if hour > 0 {
|
||||
return fmt.Sprintf("%d天%d小时", day, hour)
|
||||
} else {
|
||||
return fmt.Sprintf("%d天", day)
|
||||
}
|
||||
case hour > 0:
|
||||
if minute < 10 {
|
||||
return fmt.Sprintf("%d小时", hour)
|
||||
} else {
|
||||
return fmt.Sprintf("%d小时%d", hour, minute)
|
||||
}
|
||||
case hour == 0 && minute > 0:
|
||||
return fmt.Sprintf("%d分钟", minute)
|
||||
case hour == 0 && minute == 0:
|
||||
return fmt.Sprintf("%d秒", second)
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// TimeStampToBytes 时间戳转字节
|
||||
func TimeStampToBytes(stamp int64) []byte {
|
||||
timeStr := strconv.FormatInt(stamp, 2)
|
||||
return []byte(timeStr)
|
||||
}
|
12
pkg/utils/stime/getTimeExt_test.go
Normal file
12
pkg/utils/stime/getTimeExt_test.go
Normal file
@ -0,0 +1,12 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetWorkDayStrList(t *testing.T) {
|
||||
now := time.Now()
|
||||
result := GetWorkDayStrList(&now, 5)
|
||||
t.Log(result)
|
||||
}
|
64
pkg/utils/stime/timeTranslate.go
Normal file
64
pkg/utils/stime/timeTranslate.go
Normal file
@ -0,0 +1,64 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func GetTimestampMillisecond() int64 {
|
||||
now := time.Now()
|
||||
return now.UnixNano() / 1e6
|
||||
}
|
||||
|
||||
func StringToTime(strTime string) (*time.Time, error) {
|
||||
const TIME_LAYOUT = "2006-01-02 15:04:05" //此时间不可更改
|
||||
timeobj, err := time.ParseInLocation(TIME_LAYOUT, strTime, Loc.Shanghai())
|
||||
return &timeobj, err
|
||||
}
|
||||
|
||||
func StringToTimeWithFormat(strTime string, timeFormat string) (*time.Time, error) {
|
||||
timeobj, err := time.ParseInLocation(timeFormat, strTime, Loc.Shanghai())
|
||||
return &timeobj, err
|
||||
}
|
||||
|
||||
// 去除精确时间后面的小数点
|
||||
func NowTimeToTime(layout string) *time.Time {
|
||||
otime := time.Now().Format(layout) //"2006-01-02 15:04:05" and so on
|
||||
tt, _ := StringToTime(otime)
|
||||
return tt
|
||||
}
|
||||
|
||||
// 时间之间的转换
|
||||
func TimeStampToString(value interface{}, after_type string) {
|
||||
switch value.(type) {
|
||||
case string:
|
||||
fmt.Println(value.(string))
|
||||
case int64:
|
||||
fmt.Println(value.(int64))
|
||||
case int32:
|
||||
fmt.Println(value.(int32))
|
||||
}
|
||||
}
|
||||
|
||||
func GetAge(birthday time.Time) int {
|
||||
if birthday.IsZero() {
|
||||
return 0
|
||||
}
|
||||
now := time.Now()
|
||||
year, month, day := now.Date()
|
||||
if year == 0 || month == 0 || day == 0 {
|
||||
return 0
|
||||
}
|
||||
age := year - birthday.Year() - 1
|
||||
//判断年龄
|
||||
if birthday.Month() < month || birthday.Month() == month && birthday.Day() <= day {
|
||||
age++
|
||||
}
|
||||
return age
|
||||
}
|
||||
func ParseTimeStamp(unix int64) (result time.Time) {
|
||||
if unix == 0 {
|
||||
return
|
||||
}
|
||||
return time.Unix(unix, 0)
|
||||
}
|
19
pkg/utils/stime/timeTranslate_test.go
Normal file
19
pkg/utils/stime/timeTranslate_test.go
Normal file
@ -0,0 +1,19 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestTime(t *testing.T) {
|
||||
result := NowTimeToTime(Format_Normal_YMDhms)
|
||||
fmt.Println(result)
|
||||
}
|
||||
func TestGetAge(t *testing.T) {
|
||||
age := GetAge(time.Date(1991, 3, 6, 0, 0, 0, 0, Loc.Shanghai()))
|
||||
fmt.Println(age)
|
||||
if age != 31 {
|
||||
t.Errorf("want 31 but get %v", age)
|
||||
}
|
||||
}
|
47
pkg/utils/stime/week.go
Normal file
47
pkg/utils/stime/week.go
Normal file
@ -0,0 +1,47 @@
|
||||
package stime
|
||||
|
||||
import "time"
|
||||
|
||||
func NowWeekDay() string {
|
||||
var weekday = [7]string{"七", "一", "二", "三", "四", "五", "六"}
|
||||
week := int(time.Now().Weekday())
|
||||
return weekday[week]
|
||||
}
|
||||
|
||||
// 获取按年算的周数
|
||||
func GetYearWeek(t *time.Time) int {
|
||||
yearDay := t.YearDay()
|
||||
yearFirstDay := t.AddDate(0, 0, -yearDay+1)
|
||||
firstDayInWeek := int(yearFirstDay.Weekday())
|
||||
|
||||
//今年第一周有几天
|
||||
firstWeekDays := 1
|
||||
if firstDayInWeek != 0 {
|
||||
firstWeekDays = 7 - firstDayInWeek + 1
|
||||
}
|
||||
var week int
|
||||
if yearDay <= firstWeekDays {
|
||||
week = 1
|
||||
} else {
|
||||
week = (yearDay-firstWeekDays)/7 + 2
|
||||
}
|
||||
return week
|
||||
}
|
||||
|
||||
// GetWeekDate 获取基准时间范围最最近的某个星期时间
|
||||
//
|
||||
// param baseOn: 基准时间
|
||||
// param weekNum: 中国星期数 1~7
|
||||
// return *time.Time
|
||||
func GetWeekDate(baseOn time.Time, weekNum int) *time.Time {
|
||||
if baseOn.IsZero() || (weekNum <= 0 || weekNum > 7) {
|
||||
return nil
|
||||
}
|
||||
baseDate := time.Date(baseOn.Year(), baseOn.Month(), baseOn.Day(), 0, 0, 0, 0, Loc.Shanghai())
|
||||
var (
|
||||
w = int(baseOn.Weekday())
|
||||
weekDate time.Time
|
||||
)
|
||||
weekDate = baseDate.AddDate(0, 0, weekNum-w)
|
||||
return &weekDate
|
||||
}
|
14
pkg/utils/stime/week_test.go
Normal file
14
pkg/utils/stime/week_test.go
Normal file
@ -0,0 +1,14 @@
|
||||
package stime
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestGetYearWeek(t *testing.T) {
|
||||
now := time.Now()
|
||||
t.Log(GetYearWeek(&now))
|
||||
var w = int(now.Weekday())
|
||||
t.Log(now.AddDate(0, 0, -w+1).Weekday())
|
||||
t.Log(now.AddDate(0, 0, 7-w).Weekday())
|
||||
}
|
3
protocReports.bat
Normal file
3
protocReports.bat
Normal file
@ -0,0 +1,3 @@
|
||||
@echo off
|
||||
protoc -I . -I ./api/reports --proto_path=./api/reports --go_out=./api/reports --go-triple_out=./api/reports --govalidators_out=./api/reports ./api/reports/reports.proto
|
||||
.\clear.sh
|
Loading…
Reference in New Issue
Block a user