feat
DetailSetting UpdateSetting 已完成 Create Detail Remove List 待调试 Update 未开始
This commit is contained in:
parent
910a62c5a3
commit
ae137a6883
3456
api/approval/approval.pb.go
Normal file
3456
api/approval/approval.pb.go
Normal file
File diff suppressed because it is too large
Load Diff
332
api/approval/approval.proto
Normal file
332
api/approval/approval.proto
Normal file
@ -0,0 +1,332 @@
|
||||
syntax = "proto3";
|
||||
package approval;
|
||||
|
||||
option go_package = "./;approval";
|
||||
|
||||
// The approval service definition.
|
||||
service Approval {
|
||||
|
||||
|
||||
rpc Create(ApprovalRequest) returns (ApprovalResponse) {};
|
||||
|
||||
rpc Detail(ApprovalDetail) returns (ApprovalRequest) {};
|
||||
rpc Update(ApprovalRequest) returns (ApprovalResponse) {};
|
||||
rpc Remove(ApprovalDetail) returns (ApprovalRemove) {};
|
||||
rpc List(ApprovalListRequest) returns (ApprovalListResponse) {};
|
||||
|
||||
rpc DetailSetting(DetailSettingRequest) returns (SettingRequest) {};
|
||||
rpc UpdateSetting(SettingRequest) returns (SettingResponse) {};
|
||||
|
||||
|
||||
/*
|
||||
rpc RemoveApprovalWork(ApprovalWorkDetail) returns (ApprovalWorkRemove) {};
|
||||
rpc ListApprovalWork(ApprovalWorkDetail) returns (ApprovalWorkRequest) {};
|
||||
rpc DetailApprovalWork(ApprovalWorkDetail) returns (ApprovalWorkRequest) {};
|
||||
rpc CreateApprovalWork(ApprovalWorkRequest) returns (ApprovalWorkResponse) {};
|
||||
rpc UpdateApprovalWork(ApprovalWorkRequest) returns (ApprovalWorkResponse) {};
|
||||
rpc ListDepartmentApprovalSetting(DepartmentApprovalSettingDetail) returns (DepartmentApprovalSettingRequest) {};
|
||||
rpc DetailDepartmentApprovalSetting(DepartmentApprovalSettingDetail) returns (DepartmentApprovalSettingRequest) {};
|
||||
rpc CreateDepartmentApprovalSetting(DepartmentApprovalSettingRequest) returns (DepartmentApprovalSettingResponse) {};
|
||||
rpc UpdateDepartmentApprovalSetting(DepartmentApprovalSettingRequest) returns (DepartmentApprovalSettingResponse) {};
|
||||
rpc RemoveDepartmentApprovalSetting(DepartmentApprovalSettingDetail) returns (DepartmentApprovalSettingRemove) {};
|
||||
rpc RemoveExhibition(ExhibitionDetail) returns (ExhibitionRemove) {};
|
||||
rpc ListExhibition(ExhibitionDetail) returns (ExhibitionRequest) {};
|
||||
rpc DetailExhibition(ExhibitionDetail) returns (ExhibitionRequest) {};
|
||||
rpc CreateExhibition(ExhibitionRequest) returns (ExhibitionResponse) {};
|
||||
rpc UpdateExhibition(ExhibitionRequest) returns (ExhibitionResponse) {};
|
||||
rpc RemoveExhibitionNum(ExhibitionNumDetail) returns (ExhibitionNumRemove) {};
|
||||
rpc ListExhibitionNum(ExhibitionNumDetail) returns (ExhibitionNumRequest) {};
|
||||
rpc DetailExhibitionNum(ExhibitionNumDetail) returns (ExhibitionNumRequest) {};
|
||||
rpc CreateExhibitionNum(ExhibitionNumRequest) returns (ExhibitionNumResponse) {};
|
||||
rpc UpdateExhibitionNum(ExhibitionNumRequest) returns (ExhibitionNumResponse) {};
|
||||
rpc DetailWork(WorkDetail) returns (WorkRequest) {};
|
||||
rpc CreateWork(WorkRequest) returns (WorkResponse) {};
|
||||
rpc UpdateWork(WorkRequest) returns (WorkResponse) {};
|
||||
rpc RemoveWork(WorkDetail) returns (WorkRemove) {};
|
||||
rpc ListWork(WorkDetail) returns (WorkRequest) {};
|
||||
|
||||
rpc UpdateApprovalExhibition(ApprovalExhibitionRequest) returns (ApprovalExhibitionResponse) {};
|
||||
rpc RemoveApprovalExhibition(ApprovalExhibitionDetail) returns (ApprovalExhibitionRemove) {};
|
||||
rpc ListApprovalExhibition(ApprovalExhibitionDetail) returns (ApprovalExhibitionRequest) {};
|
||||
rpc DetailApprovalExhibition(ApprovalExhibitionDetail) returns (ApprovalExhibitionRequest) {};
|
||||
rpc CreateApprovalExhibition(ApprovalExhibitionRequest) returns (ApprovalExhibitionResponse) {};
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
message Bundle {
|
||||
uint64 ID = 1 [json_name = "ID"];
|
||||
string ReturnAt = 2 [json_name = "returnAt"];
|
||||
string ReceivedAt = 3 [json_name = "receivedAt"];
|
||||
uint64 ApplicationsNum = 4 [json_name = "applicationsNum"];
|
||||
}
|
||||
|
||||
message Show {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
uint64 ArtistNum =2 [json_name = "artistNum"];
|
||||
string ShowAt =3 [json_name = "ShowAt"];
|
||||
}
|
||||
|
||||
message ApprovalWork {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
uint64 WorkId =2 [json_name = "WorkId"];
|
||||
uint64 ApprovalID =3 [json_name = "WorkId"];
|
||||
uint64 ArtworkId =4 [json_name = "artworkId"];
|
||||
string ArtworkName =5 [json_name = "artworkName"];
|
||||
string ArtistName =6 [json_name = "artistName"];
|
||||
string ArtworkCover =7 [json_name = "artworkCover"];
|
||||
uint64 ArtworkNumber =8 [json_name = "artworkNumber"];
|
||||
}
|
||||
|
||||
message Work {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
string ReturnAt = 2 [json_name = "returnAt"];
|
||||
string ReceivedAt = 3 [json_name = "receivedAt"];
|
||||
repeated ApprovalWork ApprovalWorks = 4 [json_name = "approvalWorks"];
|
||||
}
|
||||
|
||||
|
||||
message ApprovalExhibition {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
uint64 ExhibitionID =2 [json_name = "exhibitionID"];
|
||||
uint64 ApprovalID =3 [json_name = "ApprovalID"];
|
||||
string ExhibitionName =4 [json_name = "exhibitionName"];
|
||||
uint64 ArtworkId =5 [json_name = "artworkId"];
|
||||
uint64 ExhibitionSize =6 [json_name = "exhibitionSize"];
|
||||
string ExhibitionNumber =7 [json_name = "exhibitionNumber"];
|
||||
}
|
||||
|
||||
message Exhibition {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
string ReceivedAt =2 [json_name = "receivedAt"];
|
||||
string Address =3 [json_name = "address"];
|
||||
repeated ApprovalExhibition ApprovalExhibitions = 4 [json_name = "approvalExhibitions"];
|
||||
}
|
||||
|
||||
message ApprovalListRequest {
|
||||
string Domain = 1 [json_name = "domain"];
|
||||
uint64 Limit = 2 [json_name = "limit"]; //
|
||||
uint64 Offset = 3 [json_name = "offset"]; //
|
||||
uint64 Status = 4 [json_name = "status"];//0待审批 1-审批成功 2-拒绝
|
||||
string Type = 5 [json_name = "type"]; //类型
|
||||
}
|
||||
|
||||
message ApprovalListResponse {
|
||||
uint64 Count = 1 [json_name = "count"];
|
||||
repeated ApprovalRequest data = 2 [json_name = "data"];
|
||||
}
|
||||
|
||||
message ApprovalRequest {
|
||||
uint64 ID = 1 [json_name = "ID"];
|
||||
string Domain = 2 [json_name = "domain"];
|
||||
uint64 Status = 3 [json_name = "status"];//0待审批 1-审批成功 2-拒绝
|
||||
string Type = 4 [json_name = "type"]; //类型
|
||||
uint64 ApproverId = 5 [json_name = "approverId"];//申请人
|
||||
string ApproverName = 6 [json_name = "approverName"];
|
||||
uint64 SubmitterId = 7 [json_name = "submitterId"];//审批人
|
||||
string SubmitterName = 8 [json_name = "submitterName"];
|
||||
repeated CopyUser CopyUsers = 9 [json_name = "copyName"];//抄送人
|
||||
string Content = 10 [json_name = "content"];//申请内容
|
||||
string Reply = 11 [json_name = "reply"];//回复
|
||||
Work Work = 12 [json_name = "work"];
|
||||
Show Show = 13 [json_name = "show"];
|
||||
Exhibition Exhibition = 14 [json_name = "exhibition"];
|
||||
Bundle Bundle = 15 [json_name = "bundle"];
|
||||
}
|
||||
|
||||
message ExhibitionNumRequest {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
uint64 DeletedAt =2 [json_name = "deletedAt"];
|
||||
string CreatedAt =3 [json_name = "createdAt"];
|
||||
string UpdatedAt =4 [json_name = "updatedAt"];
|
||||
string ReceivedAt =5 [json_name = "receivedAt"];
|
||||
uint64 ApplicationsNum =6 [json_name = "applicationsNum"];
|
||||
uint64 ApprovalId =7 [json_name = "approvalId"];
|
||||
}
|
||||
|
||||
message ExhibitionNumDetail {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
string Domain =2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionNumResponse {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
bool Success =2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionNumRemove {
|
||||
bool Success =1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message WorkResponse {
|
||||
uint64 ID = 1 [json_name = "ID"];
|
||||
bool Success = 2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message WorkRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message WorkRequest {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
||||
string CreatedAt=3 [json_name = "createdAt"];
|
||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
||||
string ReturnAt=5 [json_name = "returnAt"];
|
||||
string ReceivedAt=6 [json_name = "receivedAt"];
|
||||
|
||||
}
|
||||
|
||||
message WorkDetail {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
message ApprovalDetail {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalResponse {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
bool Success=2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalExhibitionRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalExhibitionRequest {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
||||
string CreatedAt=3 [json_name = "createdAt"];
|
||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
||||
uint64 ApprovalId=5 [json_name = "approvalId"];
|
||||
uint64 ExhibitionId=6 [json_name = "exhibitionId"];
|
||||
string ExhibitionName=7 [json_name = "exhibitionName"];
|
||||
uint64 ArtworkId=8 [json_name = "artworkId"];
|
||||
string ExhibitionSize=9 [json_name = "exhibitionSize"];
|
||||
string ExhibitionNumber=10 [json_name = "exhibitionNumber"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalExhibitionDetail {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalExhibitionResponse {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
bool Success=2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalWorkRequest {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
||||
string CreatedAt=3 [json_name = "createdAt"];
|
||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
||||
uint64 ApprovalId=5 [json_name = "approvalId"];
|
||||
uint64 WorkId=6 [json_name = "workId"];
|
||||
uint64 ArtworkId=7 [json_name = "artworkId"];
|
||||
string ArtworkName=8 [json_name = "artworkName"];
|
||||
string ArtistName=9 [json_name = "artistName"];
|
||||
string ArtworkCover=10 [json_name = "artworkCover"];
|
||||
string ArtworkNumber=11 [json_name = "artworkNumber"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalWorkDetail {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalWorkResponse {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
bool Success=2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ApprovalWorkRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
|
||||
message CopyUser {
|
||||
uint64 ID =1 [json_name = "ID"];
|
||||
string Name =2 [json_name = "name"];
|
||||
}
|
||||
|
||||
message SettingRequest {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
||||
string CreatedAt=3 [json_name = "createdAt"];
|
||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
||||
uint64 DepartmentId=5 [json_name = "departmentId"];
|
||||
repeated CopyUser CopyUsers=6 [json_name = "copyUsers"];
|
||||
uint64 ApproverId=7 [json_name = "approverId"];
|
||||
string ApproverName=8 [json_name = "approverName"];
|
||||
string Domain=9 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message DetailSettingRequest {
|
||||
uint64 DepartmentId=1 [json_name = "departmentId"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
}
|
||||
|
||||
message SettingResponse {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
bool Success=2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message DepartmentApprovalSettingRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionRequest {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
||||
string CreatedAt=3 [json_name = "createdAt"];
|
||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
||||
string ReceivedAt=5 [json_name = "receivedAt"];
|
||||
uint64 ApprovalId=6 [json_name = "approvalId"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionDetail {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
string Domain=2 [json_name = "domain"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionResponse {
|
||||
uint64 ID=1 [json_name = "ID"];
|
||||
bool Success=2 [json_name = "success"];
|
||||
|
||||
}
|
||||
|
||||
message ExhibitionRemove {
|
||||
bool Success=1 [json_name = "success"];
|
||||
}
|
417
api/approval/approval_triple.pb.go
Normal file
417
api/approval/approval_triple.pb.go
Normal file
@ -0,0 +1,417 @@
|
||||
// Code generated by protoc-gen-go-triple. DO NOT EDIT.
|
||||
// versions:
|
||||
// - protoc-gen-go-triple v1.0.5
|
||||
// - protoc v3.21.2
|
||||
// source: api/approval/approval.proto
|
||||
|
||||
package approval
|
||||
|
||||
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
|
||||
|
||||
// ApprovalClient is the client API for Approval 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 ApprovalClient interface {
|
||||
Create(ctx context.Context, in *ApprovalRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
||||
Detail(ctx context.Context, in *ApprovalDetail, opts ...grpc_go.CallOption) (*ApprovalRequest, common.ErrorWithAttachment)
|
||||
Update(ctx context.Context, in *ApprovalRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
||||
Remove(ctx context.Context, in *ApprovalDetail, opts ...grpc_go.CallOption) (*ApprovalRemove, common.ErrorWithAttachment)
|
||||
List(ctx context.Context, in *ApprovalListRequest, opts ...grpc_go.CallOption) (*ApprovalListResponse, common.ErrorWithAttachment)
|
||||
DetailSetting(ctx context.Context, in *DetailSettingRequest, opts ...grpc_go.CallOption) (*SettingRequest, common.ErrorWithAttachment)
|
||||
UpdateSetting(ctx context.Context, in *SettingRequest, opts ...grpc_go.CallOption) (*SettingResponse, common.ErrorWithAttachment)
|
||||
}
|
||||
|
||||
type approvalClient struct {
|
||||
cc *triple.TripleConn
|
||||
}
|
||||
|
||||
type ApprovalClientImpl struct {
|
||||
Create func(ctx context.Context, in *ApprovalRequest) (*ApprovalResponse, error)
|
||||
Detail func(ctx context.Context, in *ApprovalDetail) (*ApprovalRequest, error)
|
||||
Update func(ctx context.Context, in *ApprovalRequest) (*ApprovalResponse, error)
|
||||
Remove func(ctx context.Context, in *ApprovalDetail) (*ApprovalRemove, error)
|
||||
List func(ctx context.Context, in *ApprovalListRequest) (*ApprovalListResponse, error)
|
||||
DetailSetting func(ctx context.Context, in *DetailSettingRequest) (*SettingRequest, error)
|
||||
UpdateSetting func(ctx context.Context, in *SettingRequest) (*SettingResponse, error)
|
||||
}
|
||||
|
||||
func (c *ApprovalClientImpl) GetDubboStub(cc *triple.TripleConn) ApprovalClient {
|
||||
return NewApprovalClient(cc)
|
||||
}
|
||||
|
||||
func (c *ApprovalClientImpl) XXX_InterfaceName() string {
|
||||
return "approval.Approval"
|
||||
}
|
||||
|
||||
func NewApprovalClient(cc *triple.TripleConn) ApprovalClient {
|
||||
return &approvalClient{cc}
|
||||
}
|
||||
|
||||
func (c *approvalClient) Create(ctx context.Context, in *ApprovalRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment) {
|
||||
out := new(ApprovalResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Create", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) Detail(ctx context.Context, in *ApprovalDetail, opts ...grpc_go.CallOption) (*ApprovalRequest, common.ErrorWithAttachment) {
|
||||
out := new(ApprovalRequest)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Detail", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) Update(ctx context.Context, in *ApprovalRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment) {
|
||||
out := new(ApprovalResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Update", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) Remove(ctx context.Context, in *ApprovalDetail, opts ...grpc_go.CallOption) (*ApprovalRemove, common.ErrorWithAttachment) {
|
||||
out := new(ApprovalRemove)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/Remove", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) List(ctx context.Context, in *ApprovalListRequest, opts ...grpc_go.CallOption) (*ApprovalListResponse, common.ErrorWithAttachment) {
|
||||
out := new(ApprovalListResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/List", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) DetailSetting(ctx context.Context, in *DetailSettingRequest, opts ...grpc_go.CallOption) (*SettingRequest, common.ErrorWithAttachment) {
|
||||
out := new(SettingRequest)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DetailSetting", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) UpdateSetting(ctx context.Context, in *SettingRequest, opts ...grpc_go.CallOption) (*SettingResponse, common.ErrorWithAttachment) {
|
||||
out := new(SettingResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateSetting", in, out)
|
||||
}
|
||||
|
||||
// ApprovalServer is the server API for Approval service.
|
||||
// All implementations must embed UnimplementedApprovalServer
|
||||
// for forward compatibility
|
||||
type ApprovalServer interface {
|
||||
Create(context.Context, *ApprovalRequest) (*ApprovalResponse, error)
|
||||
Detail(context.Context, *ApprovalDetail) (*ApprovalRequest, error)
|
||||
Update(context.Context, *ApprovalRequest) (*ApprovalResponse, error)
|
||||
Remove(context.Context, *ApprovalDetail) (*ApprovalRemove, error)
|
||||
List(context.Context, *ApprovalListRequest) (*ApprovalListResponse, error)
|
||||
DetailSetting(context.Context, *DetailSettingRequest) (*SettingRequest, error)
|
||||
UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error)
|
||||
mustEmbedUnimplementedApprovalServer()
|
||||
}
|
||||
|
||||
// UnimplementedApprovalServer must be embedded to have forward compatible implementations.
|
||||
type UnimplementedApprovalServer struct {
|
||||
proxyImpl protocol.Invoker
|
||||
}
|
||||
|
||||
func (UnimplementedApprovalServer) Create(context.Context, *ApprovalRequest) (*ApprovalResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Create not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) Detail(context.Context, *ApprovalDetail) (*ApprovalRequest, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Detail not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) Update(context.Context, *ApprovalRequest) (*ApprovalResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Update not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) Remove(context.Context, *ApprovalDetail) (*ApprovalRemove, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method Remove not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) List(context.Context, *ApprovalListRequest) (*ApprovalListResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) DetailSetting(context.Context, *DetailSettingRequest) (*SettingRequest, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method DetailSetting not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateSetting not implemented")
|
||||
}
|
||||
func (s *UnimplementedApprovalServer) XXX_SetProxyImpl(impl protocol.Invoker) {
|
||||
s.proxyImpl = impl
|
||||
}
|
||||
|
||||
func (s *UnimplementedApprovalServer) XXX_GetProxyImpl() protocol.Invoker {
|
||||
return s.proxyImpl
|
||||
}
|
||||
|
||||
func (s *UnimplementedApprovalServer) XXX_ServiceDesc() *grpc_go.ServiceDesc {
|
||||
return &Approval_ServiceDesc
|
||||
}
|
||||
func (s *UnimplementedApprovalServer) XXX_InterfaceName() string {
|
||||
return "approval.Approval"
|
||||
}
|
||||
|
||||
func (UnimplementedApprovalServer) mustEmbedUnimplementedApprovalServer() {}
|
||||
|
||||
// UnsafeApprovalServer may be embedded to opt out of forward compatibility for this service.
|
||||
// Use of this interface is not recommended, as added methods to ApprovalServer will
|
||||
// result in compilation errors.
|
||||
type UnsafeApprovalServer interface {
|
||||
mustEmbedUnimplementedApprovalServer()
|
||||
}
|
||||
|
||||
func RegisterApprovalServer(s grpc_go.ServiceRegistrar, srv ApprovalServer) {
|
||||
s.RegisterService(&Approval_ServiceDesc, srv)
|
||||
}
|
||||
|
||||
func _Approval_Create_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApprovalRequest)
|
||||
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("Create", 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 _Approval_Detail_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApprovalDetail)
|
||||
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("Detail", 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 _Approval_Update_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApprovalRequest)
|
||||
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("Update", 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 _Approval_Remove_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApprovalDetail)
|
||||
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("Remove", 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 _Approval_List_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ApprovalListRequest)
|
||||
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("List", 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 _Approval_DetailSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(DetailSettingRequest)
|
||||
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("DetailSetting", 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 _Approval_UpdateSetting_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(SettingRequest)
|
||||
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("UpdateSetting", 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)
|
||||
}
|
||||
|
||||
// Approval_ServiceDesc is the grpc_go.ServiceDesc for Approval service.
|
||||
// It's only intended for direct use with grpc_go.RegisterService,
|
||||
// and not to be introspected or modified (even as a copy)
|
||||
var Approval_ServiceDesc = grpc_go.ServiceDesc{
|
||||
ServiceName: "approval.Approval",
|
||||
HandlerType: (*ApprovalServer)(nil),
|
||||
Methods: []grpc_go.MethodDesc{
|
||||
{
|
||||
MethodName: "Create",
|
||||
Handler: _Approval_Create_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Detail",
|
||||
Handler: _Approval_Detail_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Update",
|
||||
Handler: _Approval_Update_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "Remove",
|
||||
Handler: _Approval_Remove_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "List",
|
||||
Handler: _Approval_List_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "DetailSetting",
|
||||
Handler: _Approval_DetailSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "UpdateSetting",
|
||||
Handler: _Approval_UpdateSetting_Handler,
|
||||
},
|
||||
},
|
||||
Streams: []grpc_go.StreamDesc{},
|
||||
Metadata: "api/approval/approval.proto",
|
||||
}
|
36
cmd/app.go
Normal file
36
cmd/app.go
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"dubbo.apache.org/dubbo-go/v3/config"
|
||||
_ "dubbo.apache.org/dubbo-go/v3/filter/token"
|
||||
_ "dubbo.apache.org/dubbo-go/v3/imports"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/service"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//注册服务
|
||||
config.SetProviderService(&service.ApprovalProvider{})
|
||||
|
||||
if err := config.Load(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
select {}
|
||||
}
|
13
conf/conf.ini
Normal file
13
conf/conf.ini
Normal file
@ -0,0 +1,13 @@
|
||||
[mysql]
|
||||
Db = mysql
|
||||
DbHost = 127.0.0.1
|
||||
DbPort = 3306
|
||||
DbUser = root
|
||||
DbPassWord = 123456
|
||||
DbName = fontree-approval
|
||||
|
||||
[redis]
|
||||
RedisDB =
|
||||
RedisAddr = 127.0.0.1:6379
|
||||
RedisPW =
|
||||
RedisDBNAme =
|
22
conf/dubbogo.yaml
Normal file
22
conf/dubbogo.yaml
Normal file
@ -0,0 +1,22 @@
|
||||
dubbo:
|
||||
registries:
|
||||
demoZK:
|
||||
protocol: zookeeper
|
||||
address: 127.0.0.1:2181
|
||||
protocols:
|
||||
triple:
|
||||
name: tri
|
||||
port: 20009
|
||||
provider:
|
||||
services:
|
||||
ApprovalProvider:
|
||||
interface: com.fontree.microservices.common.Approval # must be compatible with grpc or dubbo-java
|
||||
|
||||
# logger:
|
||||
# lumberjack-config:
|
||||
# filename: logs.log
|
||||
# maxsize: 1
|
||||
# maxage: 3
|
||||
# maxbackups: 5
|
||||
# localtime: true
|
||||
# compress: true
|
142
go.mod
Normal file
142
go.mod
Normal file
@ -0,0 +1,142 @@
|
||||
module github.com/fonchain_enterprise/fonchain-approval
|
||||
|
||||
go 1.18
|
||||
|
||||
require (
|
||||
dubbo.apache.org/dubbo-go/v3 v3.0.2
|
||||
github.com/dubbogo/grpc-go v1.42.9
|
||||
github.com/dubbogo/triple v1.1.8
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/ini.v1 v1.66.6
|
||||
gorm.io/datatypes v1.0.7
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
gorm.io/gorm v1.23.8
|
||||
gorm.io/plugin/soft_delete v1.2.0
|
||||
)
|
||||
|
||||
require (
|
||||
cloud.google.com/go v0.65.0 // indirect
|
||||
contrib.go.opencensus.io/exporter/prometheus v0.4.1 // indirect
|
||||
github.com/RoaringBitmap/roaring v1.1.0 // indirect
|
||||
github.com/StackExchange/wmi v0.0.0-20190523213315-cbe66965904d // indirect
|
||||
github.com/Workiva/go-datastructures v1.0.52 // indirect
|
||||
github.com/afex/hystrix-go v0.0.0-20180502004556-fa1af6a1f4f5 // indirect
|
||||
github.com/alibaba/sentinel-golang v1.0.4 // indirect
|
||||
github.com/aliyun/alibaba-cloud-sdk-go v1.61.18 // indirect
|
||||
github.com/apache/dubbo-getty v1.4.8 // indirect
|
||||
github.com/apache/dubbo-go-hessian2 v1.11.0 // indirect
|
||||
github.com/beorn7/perks v1.0.1 // indirect
|
||||
github.com/bits-and-blooms/bitset v1.2.0 // indirect
|
||||
github.com/buger/jsonparser v1.1.1 // indirect
|
||||
github.com/census-instrumentation/opencensus-proto v0.2.1 // indirect
|
||||
github.com/cespare/xxhash/v2 v2.1.2 // indirect
|
||||
github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4 // indirect
|
||||
github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1 // indirect
|
||||
github.com/coreos/go-semver v0.3.0 // indirect
|
||||
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
|
||||
github.com/creasty/defaults v1.5.2 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 // indirect
|
||||
github.com/dubbogo/gost v1.11.25 // indirect
|
||||
github.com/emicklei/go-restful/v3 v3.7.4 // indirect
|
||||
github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1 // indirect
|
||||
github.com/envoyproxy/protoc-gen-validate v0.1.0 // indirect
|
||||
github.com/fsnotify/fsnotify v1.5.4 // indirect
|
||||
github.com/ghodss/yaml v1.0.0 // indirect
|
||||
github.com/gin-contrib/sse v0.1.0 // indirect
|
||||
github.com/go-co-op/gocron v1.9.0 // indirect
|
||||
github.com/go-errors/errors v1.0.1 // indirect
|
||||
github.com/go-kit/log v0.1.0 // indirect
|
||||
github.com/go-logfmt/logfmt v0.5.0 // indirect
|
||||
github.com/go-logr/logr v1.2.3 // indirect
|
||||
github.com/go-logr/stdr v1.2.2 // indirect
|
||||
github.com/go-ole/go-ole v1.2.4 // indirect
|
||||
github.com/go-playground/locales v0.14.0 // indirect
|
||||
github.com/go-playground/universal-translator v0.18.0 // indirect
|
||||
github.com/go-playground/validator/v10 v10.11.0 // indirect
|
||||
github.com/go-resty/resty/v2 v2.7.0 // indirect
|
||||
github.com/go-sql-driver/mysql v1.6.0 // indirect
|
||||
github.com/goccy/go-json v0.9.7 // indirect
|
||||
github.com/gogo/protobuf v1.3.2 // indirect
|
||||
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
|
||||
github.com/golang/mock v1.5.0 // indirect
|
||||
github.com/golang/protobuf v1.5.2 // indirect
|
||||
github.com/golang/snappy v0.0.4 // indirect
|
||||
github.com/google/uuid v1.3.0 // indirect
|
||||
github.com/gorilla/websocket v1.4.2 // indirect
|
||||
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
|
||||
github.com/hashicorp/errwrap v1.1.0 // indirect
|
||||
github.com/hashicorp/go-multierror v1.1.1 // indirect
|
||||
github.com/hashicorp/hcl v1.0.0 // indirect
|
||||
github.com/hashicorp/vault/sdk v0.3.0 // indirect
|
||||
github.com/jinzhu/copier v0.3.5 // indirect
|
||||
github.com/jinzhu/inflection v1.0.0 // indirect
|
||||
github.com/jinzhu/now v1.1.5 // indirect
|
||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/k0kubun/pp v3.0.1+incompatible // indirect
|
||||
github.com/knadh/koanf v1.4.1 // indirect
|
||||
github.com/leodido/go-urn v1.2.1 // indirect
|
||||
github.com/magiconair/properties v1.8.6 // indirect
|
||||
github.com/mattn/go-colorable v0.1.7 // indirect
|
||||
github.com/mattn/go-isatty v0.0.14 // indirect
|
||||
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
|
||||
github.com/mitchellh/copystructure v1.2.0 // indirect
|
||||
github.com/mitchellh/go-homedir v1.1.0 // indirect
|
||||
github.com/mitchellh/mapstructure v1.5.0 // indirect
|
||||
github.com/mitchellh/reflectwalk v1.0.2 // indirect
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mschoch/smat v0.2.0 // indirect
|
||||
github.com/nacos-group/nacos-sdk-go v1.1.1 // indirect
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
|
||||
github.com/opentracing/opentracing-go v1.2.0 // indirect
|
||||
github.com/pelletier/go-toml v1.7.0 // indirect
|
||||
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
|
||||
github.com/pierrec/lz4 v2.5.2+incompatible // indirect
|
||||
github.com/pkg/errors v0.9.1 // indirect
|
||||
github.com/polarismesh/polaris-go v1.1.0 // indirect
|
||||
github.com/prometheus/client_golang v1.12.2 // indirect
|
||||
github.com/prometheus/client_model v0.2.0 // indirect
|
||||
github.com/prometheus/common v0.32.1 // indirect
|
||||
github.com/prometheus/procfs v0.7.3 // indirect
|
||||
github.com/prometheus/statsd_exporter v0.21.0 // indirect
|
||||
github.com/robfig/cron/v3 v3.0.1 // indirect
|
||||
github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b // indirect
|
||||
github.com/shirou/gopsutil v3.20.11+incompatible // indirect
|
||||
github.com/shirou/gopsutil/v3 v3.21.6 // indirect
|
||||
github.com/spaolacci/murmur3 v1.1.0 // indirect
|
||||
github.com/spf13/afero v1.2.2 // indirect
|
||||
github.com/spf13/cast v1.3.0 // indirect
|
||||
github.com/spf13/jwalterweatherman v1.0.0 // indirect
|
||||
github.com/spf13/pflag v1.0.5 // indirect
|
||||
github.com/spf13/viper v1.7.1 // indirect
|
||||
github.com/subosito/gotenv v1.2.0 // indirect
|
||||
github.com/tklauser/go-sysconf v0.3.6 // indirect
|
||||
github.com/tklauser/numcpus v0.2.2 // indirect
|
||||
github.com/uber/jaeger-client-go v2.29.1+incompatible // indirect
|
||||
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
|
||||
github.com/ugorji/go/codec v1.2.7 // indirect
|
||||
github.com/zouyx/agollo/v3 v3.4.5 // indirect
|
||||
go.etcd.io/etcd/api/v3 v3.5.4 // indirect
|
||||
go.etcd.io/etcd/client/pkg/v3 v3.5.4 // indirect
|
||||
go.etcd.io/etcd/client/v3 v3.5.4 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
go.opentelemetry.io/otel v1.7.0 // indirect
|
||||
go.opentelemetry.io/otel/trace v1.7.0 // indirect
|
||||
go.uber.org/atomic v1.9.0 // indirect
|
||||
go.uber.org/multierr v1.6.0 // indirect
|
||||
go.uber.org/zap v1.21.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220214200702-86341886e292 // indirect
|
||||
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect
|
||||
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8 // indirect
|
||||
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c // indirect
|
||||
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad // indirect
|
||||
golang.org/x/text v0.3.7 // indirect
|
||||
google.golang.org/appengine v1.6.6 // indirect
|
||||
google.golang.org/genproto v0.0.0-20211104193956-4c6863e31247 // indirect
|
||||
google.golang.org/grpc v1.47.0 // indirect
|
||||
gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
)
|
15
pkg/m/msg.go
Normal file
15
pkg/m/msg.go
Normal file
@ -0,0 +1,15 @@
|
||||
package m
|
||||
|
||||
const (
|
||||
SERVER_CONFIG = "../conf/conf.ini"
|
||||
)
|
||||
|
||||
const (
|
||||
SUCCESS = "success"
|
||||
FAILED = "failed"
|
||||
)
|
||||
|
||||
const (
|
||||
ERRORCONFIG = "配置文件读取错误,请检查文件路径:"
|
||||
ErrorApprovalType = "类型不支持"
|
||||
)
|
206
pkg/model/approval.go
Normal file
206
pkg/model/approval.go
Normal file
@ -0,0 +1,206 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Approval 审批
|
||||
type Approval struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
SubmitterID uint64 `gorm:"column:submitter_id" json:"submitterId"` // 提交人ID
|
||||
ApproverID uint64 `gorm:"column:approver_id" json:"approverId"` // 审核人ID
|
||||
Status int8 `gorm:"column:status" json:"status"` // 状态0-待 1-可 2-否
|
||||
SubmitterName string `gorm:"column:submitter_name" json:"submitterName"` // 提交人名称缓存
|
||||
ApproverName string `gorm:"column:approver_name" json:"approverName"` // 审核人名称缓存
|
||||
CopyUsers CopyUsers `gorm:"column:copy_users" json:"copyUsers"` // 抄送人
|
||||
Type string `gorm:"column:type" json:"type"` // 类型
|
||||
Content string `gorm:"column:content" json:"content"` // 提交审批内容
|
||||
Reply string `gorm:"column:reply" json:"reply"` // 回复内容
|
||||
Domain string `gorm:"column:domain" json:"domain"` // 环境变量
|
||||
Show *Show //`gorm:"foreignKey:ApprovalID" json:"Show"` // 环境变量
|
||||
Work *Work //`gorm:"foreignKey:ApprovalID" json:"Work"` // 环境变量
|
||||
Bundle *Bundle //`gorm:"foreignKey:ApprovalID" json:"Bundle"` // 环境变量
|
||||
Exhibition *Exhibition //`gorm:"foreignKey:ApprovalID" json:"Exhibition"` // 环境变量
|
||||
}
|
||||
|
||||
const (
|
||||
TypeContent = "content"
|
||||
TypeWork = "work"
|
||||
TypeExhibition = "exhibition"
|
||||
TypeShow = "show"
|
||||
TypeBundle = "bundle"
|
||||
)
|
||||
|
||||
type ApprovalContentInterface interface {
|
||||
SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error
|
||||
BuildResContent(a *Approval, request *approval.ApprovalRequest)
|
||||
DeleteApproval(p *Approval) error
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *Approval) TableName() string {
|
||||
return "approval"
|
||||
}
|
||||
|
||||
func StoreApproval(in *approval.ApprovalRequest) (*Approval, error) {
|
||||
var entity *Approval
|
||||
|
||||
err := DB.Transaction(func(tx *gorm.DB) error {
|
||||
|
||||
// 保存基本信息
|
||||
entity = &Approval{
|
||||
Domain: in.Domain,
|
||||
SubmitterID: in.SubmitterId,
|
||||
SubmitterName: in.SubmitterName,
|
||||
ApproverID: in.ApproverId,
|
||||
ApproverName: in.ApproverName,
|
||||
CopyUsers: FormatCopyUsers(in.CopyUsers),
|
||||
Type: in.Type,
|
||||
Content: in.Content,
|
||||
}
|
||||
|
||||
if err := DB.Create(&entity).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// 不同类型保存不同的结构体
|
||||
err := entity.SaveContent(in)
|
||||
|
||||
return err
|
||||
})
|
||||
|
||||
return entity, err
|
||||
|
||||
}
|
||||
|
||||
func (m *Approval) SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Approval) DeleteApproval(p *Approval) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Approval) DeleteContent() error {
|
||||
|
||||
factory, err := GetApprovalContentFactory(m.Type)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return factory.DeleteApproval(m)
|
||||
}
|
||||
|
||||
func (m *Approval) BuildResContent(a *Approval, request *approval.ApprovalRequest) {
|
||||
|
||||
}
|
||||
|
||||
func (m *Approval) SetResContent(request *approval.ApprovalRequest) error {
|
||||
|
||||
factory, err := GetApprovalContentFactory(m.Type)
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
factory.BuildResContent(m, request)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *Approval) SaveContent(in *approval.ApprovalRequest) error {
|
||||
|
||||
factory, err := GetApprovalContentFactory(in.Type)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
err = factory.SaveApprovalContent(in, m)
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func ApprovalList(in *approval.ApprovalListRequest) ([]*Approval, int64) {
|
||||
var list []*Approval
|
||||
var count int64
|
||||
|
||||
//list
|
||||
modelObj := DB.Preload("Show.Rule").
|
||||
Preload("Work.RuleDatum").
|
||||
Preload("Bundle.RuleDatum").
|
||||
Preload("Exhibition.RuleDatum").
|
||||
Limit(int(in.Limit)).Offset(int(in.Offset))
|
||||
|
||||
if in.Type != "" {
|
||||
modelObj = modelObj.Where(&Approval{Type: in.Type})
|
||||
}
|
||||
|
||||
if in.Status != 0 {
|
||||
modelObj = modelObj.Where(&Approval{Status: int8(in.Status)})
|
||||
}
|
||||
|
||||
modelObj.Count(&count)
|
||||
|
||||
modelObj.Order("id desc").Find(&list)
|
||||
|
||||
return list, count
|
||||
}
|
||||
|
||||
func GetApprovalContentFactory(typeFiled string) (ApprovalContentInterface, error) {
|
||||
switch typeFiled {
|
||||
case TypeContent:
|
||||
return &Approval{}, nil
|
||||
case TypeShow:
|
||||
return &Show{}, nil
|
||||
case TypeWork:
|
||||
return &Work{}, nil
|
||||
case TypeBundle:
|
||||
return &Bundle{}, nil
|
||||
case TypeExhibition:
|
||||
return &Exhibition{}, nil
|
||||
default:
|
||||
return nil, errors.New(m.ErrorApprovalType)
|
||||
}
|
||||
}
|
||||
|
||||
// ApprovalColumns get sql column name.获取数据库列名
|
||||
var ApprovalColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
SubmitterID string
|
||||
ApproverID string
|
||||
Status string
|
||||
SubmitterName string
|
||||
ApproverName string
|
||||
CopyName string
|
||||
Type string
|
||||
Content string
|
||||
Reply string
|
||||
Domain string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
SubmitterID: "submitter_id",
|
||||
ApproverID: "approver_id",
|
||||
Status: "status",
|
||||
SubmitterName: "submitter_name",
|
||||
ApproverName: "approver_name",
|
||||
CopyName: "copy_name",
|
||||
Type: "type",
|
||||
Content: "content",
|
||||
Reply: "reply",
|
||||
Domain: "domain",
|
||||
}
|
50
pkg/model/approval_exhibition.go
Normal file
50
pkg/model/approval_exhibition.go
Normal file
@ -0,0 +1,50 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ApprovalExhibition 绑定的画展包
|
||||
type ApprovalExhibition struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 申请的id
|
||||
ExhibitionID uint64 `gorm:"column:exhibition_id" json:"exhibitionId"` // 画展包的id
|
||||
ExhibitionName string `gorm:"column:exhibition_name" json:"exhibitionName"` // 作品名称
|
||||
ArtworkID uint64 `gorm:"column:artwork_id" json:"artworkId"` // 作品类型id
|
||||
ExhibitionSize uint64 `gorm:"column:exhibition_size" json:"exhibitionSize"` // 平尺数
|
||||
ExhibitionNumber string `gorm:"column:exhibition_number" json:"exhibitionNumber"` // 序号
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *ApprovalExhibition) TableName() string {
|
||||
return "approval_exhibition"
|
||||
}
|
||||
|
||||
// ApprovalExhibitionColumns get sql column name.获取数据库列名
|
||||
var ApprovalExhibitionColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
ApprovalID string
|
||||
ExhibitionID string
|
||||
ExhibitionName string
|
||||
ArtworkID string
|
||||
ExhibitionSize string
|
||||
ExhibitionNumber string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
ApprovalID: "approval_id",
|
||||
ExhibitionID: "exhibition_id",
|
||||
ExhibitionName: "exhibition_name",
|
||||
ArtworkID: "artwork_id",
|
||||
ExhibitionSize: "exhibition_size",
|
||||
ExhibitionNumber: "exhibition_number",
|
||||
}
|
53
pkg/model/approval_work.go
Normal file
53
pkg/model/approval_work.go
Normal file
@ -0,0 +1,53 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// ApprovalWork 审批绑定画作表
|
||||
type ApprovalWork struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 申请的id
|
||||
WorkID uint64 `gorm:"column:work_id" json:"workId"` // 作品类型id
|
||||
ArtworkID uint64 `gorm:"column:artwork_id" json:"artworkId"` // 作品id
|
||||
ArtworkName string `gorm:"column:artwork_name" json:"artworkName"` // 作品名称
|
||||
ArtistName string `gorm:"column:artist_name" json:"artistName"` // 作家名称
|
||||
ArtworkCover string `gorm:"column:artwork_cover" json:"artworkCover"` // 作品封面
|
||||
ArtworkNumber uint64 `gorm:"column:artwork_number" json:"artworkNumber"` // 作品序号
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *ApprovalWork) TableName() string {
|
||||
return "approval_work"
|
||||
}
|
||||
|
||||
// ApprovalWorkColumns get sql column name.获取数据库列名
|
||||
var ApprovalWorkColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
ApprovalID string
|
||||
WorkID string
|
||||
ArtworkID string
|
||||
ArtworkName string
|
||||
ArtistName string
|
||||
ArtworkCover string
|
||||
ArtworkNumber string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
ApprovalID: "approval_id",
|
||||
WorkID: "work_id",
|
||||
ArtworkID: "artwork_id",
|
||||
ArtworkName: "artwork_name",
|
||||
ArtistName: "artist_name",
|
||||
ArtworkCover: "artwork_cover",
|
||||
ArtworkNumber: "artwork_number",
|
||||
}
|
44
pkg/model/bundle.go
Normal file
44
pkg/model/bundle.go
Normal file
@ -0,0 +1,44 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Bundle 画展包审批
|
||||
type Bundle struct {
|
||||
ID uint64 `gorm:"column:id" json:"id"`
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ReceivedAt string `gorm:"column:received_at" json:"receivedAt"` // 领取时间
|
||||
ApplicationsNum uint64 `gorm:"column:applications_num" json:"applicationsNum"` // 申请数量
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 绑定的申请id
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *Bundle) TableName() string {
|
||||
return "bundle"
|
||||
}
|
||||
|
||||
func (m *Bundle) SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error {
|
||||
|
||||
m.ApprovalID = a.ID
|
||||
m.ReceivedAt = in.Bundle.ReceivedAt
|
||||
m.ApplicationsNum = in.Bundle.ApplicationsNum
|
||||
|
||||
return DB.Create(&m).Error
|
||||
}
|
||||
|
||||
func (m *Bundle) BuildResContent(a *Approval, request *approval.ApprovalRequest) {
|
||||
request.Bundle = &approval.Bundle{
|
||||
ID: m.ID,
|
||||
ReceivedAt: m.ReceivedAt,
|
||||
ApplicationsNum: m.ApplicationsNum,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Bundle) DeleteApproval(p *Approval) error {
|
||||
return DB.Where(&Bundle{ApprovalID: p.ID}).Delete(&Bundle{}).Error
|
||||
}
|
100
pkg/model/department_approval_setting.go
Normal file
100
pkg/model/department_approval_setting.go
Normal file
@ -0,0 +1,100 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"database/sql/driver"
|
||||
"encoding/json"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
type CopyUser struct {
|
||||
ID uint64
|
||||
Name string
|
||||
}
|
||||
|
||||
type CopyUsers []CopyUser
|
||||
|
||||
// DepartmentApprovalSetting 部门抄送人设置
|
||||
type DepartmentApprovalSetting struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除标记
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
DepartmentID uint64 `gorm:"column:department_id" json:"departmentId"` // 绑定的部门ID
|
||||
CopyUsers CopyUsers `gorm:"column:copy_users" json:"copyUsers"` // 抄送人
|
||||
ApproverID uint64 `gorm:"column:approver_id" json:"approverId"` // 审批人ID
|
||||
ApproverName string `gorm:"column:approver_name" json:"approverName"` // 审批人名称
|
||||
Domain string `gorm:"column:domain" json:"domain"` // 环境env
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *DepartmentApprovalSetting) TableName() string {
|
||||
return "department_approval_setting"
|
||||
}
|
||||
|
||||
type JSON json.RawMessage
|
||||
|
||||
func (j *CopyUsers) Scan(src interface{}) error {
|
||||
return json.Unmarshal(src.([]byte), j)
|
||||
}
|
||||
|
||||
func (j CopyUsers) Value() (driver.Value, error) {
|
||||
|
||||
v, err := json.Marshal(j)
|
||||
|
||||
return string(v), err
|
||||
}
|
||||
|
||||
func FormatCopyUsers(copyUsers []*approval.CopyUser) CopyUsers {
|
||||
var res CopyUsers
|
||||
|
||||
// copyer
|
||||
for _, copyUser := range copyUsers {
|
||||
temp := CopyUser{
|
||||
ID: copyUser.ID,
|
||||
Name: copyUser.Name,
|
||||
}
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
func FormatToResponse(copyUsers CopyUsers) []*approval.CopyUser {
|
||||
var res []*approval.CopyUser
|
||||
|
||||
for _, copyUser := range copyUsers {
|
||||
temp := &approval.CopyUser{
|
||||
ID: copyUser.ID,
|
||||
Name: copyUser.Name,
|
||||
}
|
||||
|
||||
res = append(res, temp)
|
||||
}
|
||||
|
||||
return res
|
||||
}
|
||||
|
||||
// DepartmentApprovalSettingColumns get sql column name.获取数据库列名
|
||||
var DepartmentApprovalSettingColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
DepartmentID string
|
||||
CopyUsers string
|
||||
ApproverID string
|
||||
ApproverName string
|
||||
Domain string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
DepartmentID: "department_id",
|
||||
CopyUsers: "copy_users",
|
||||
ApproverID: "approver_id",
|
||||
ApproverName: "approver_name",
|
||||
Domain: "domain",
|
||||
}
|
105
pkg/model/exhibition.go
Normal file
105
pkg/model/exhibition.go
Normal file
@ -0,0 +1,105 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Exhibition 审批-画展包
|
||||
type Exhibition struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ReceivedAt string `gorm:"column:received_at" json:"receivedAt"` // 领取时间
|
||||
Address string `gorm:"column:address" json:"Address"` // 地点
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 关联申请的ID
|
||||
ApprovalExhibitions []*ApprovalExhibition `gorm:"foreignKey:ExhibitionID" json:"ApprovalExhibitions"` //关联包
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *Exhibition) TableName() string {
|
||||
return "exhibition"
|
||||
}
|
||||
|
||||
func (m *Exhibition) SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error {
|
||||
|
||||
//主体保存
|
||||
m.ApprovalID = a.ID
|
||||
m.ReceivedAt = in.Exhibition.ReceivedAt
|
||||
|
||||
err := DB.Create(m).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//绑定画作保存
|
||||
var approvalWorks []ApprovalWork
|
||||
for _, approvalWork := range in.Work.ApprovalWorks {
|
||||
fmt.Println(approvalWork)
|
||||
temp := ApprovalWork{
|
||||
|
||||
ApprovalID: a.ID,
|
||||
WorkID: m.ID,
|
||||
ArtworkID: approvalWork.ArtworkId,
|
||||
ArtworkName: approvalWork.ArtworkName,
|
||||
ArtistName: approvalWork.ArtistName,
|
||||
ArtworkCover: approvalWork.ArtworkCover,
|
||||
ArtworkNumber: approvalWork.ArtworkNumber,
|
||||
}
|
||||
|
||||
approvalWorks = append(approvalWorks, temp)
|
||||
}
|
||||
|
||||
if len(approvalWorks) > 0 {
|
||||
err = DB.Create(&approvalWorks).Error
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Exhibition) BuildResContent(a *Approval, request *approval.ApprovalRequest) {
|
||||
//ApprovalWorks []*ApprovalWork `protobuf:"bytes,4,rep,name=ApprovalWorks,json=approvalWorks,proto3" json:"ApprovalWorks,omitempty"`
|
||||
var approvalExhibitions []*approval.ApprovalExhibition
|
||||
|
||||
for _, one := range m.ApprovalExhibitions {
|
||||
temp := &approval.ApprovalExhibition{
|
||||
|
||||
ID: one.ID,
|
||||
ApprovalID: one.ApprovalID,
|
||||
ArtworkId: one.ArtworkID,
|
||||
ExhibitionID: one.ExhibitionID,
|
||||
ExhibitionName: one.ExhibitionName,
|
||||
ExhibitionSize: one.ExhibitionSize,
|
||||
ExhibitionNumber: one.ExhibitionNumber,
|
||||
}
|
||||
approvalExhibitions = append(approvalExhibitions, temp)
|
||||
|
||||
}
|
||||
|
||||
request.Exhibition = &approval.Exhibition{
|
||||
ID: m.ID,
|
||||
ReceivedAt: m.ReceivedAt,
|
||||
Address: m.Address,
|
||||
|
||||
ApprovalExhibitions: approvalExhibitions,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Exhibition) DeleteApproval(p *Approval) error {
|
||||
var err error
|
||||
|
||||
if err = DB.Where(&ApprovalExhibition{ApprovalID: p.ID}).
|
||||
Delete(&ApprovalExhibition{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = DB.Where(&Exhibition{ApprovalID: p.ID}).
|
||||
Delete(&Exhibition{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
80
pkg/model/init.go
Normal file
80
pkg/model/init.go
Normal file
@ -0,0 +1,80 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gopkg.in/ini.v1"
|
||||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
"gorm.io/gorm/schema"
|
||||
)
|
||||
|
||||
var DB *gorm.DB
|
||||
|
||||
var (
|
||||
Db string
|
||||
DbHost string
|
||||
DbPort string
|
||||
DbUser string
|
||||
DbPassWord string
|
||||
DbName string
|
||||
)
|
||||
|
||||
func init() {
|
||||
//从本地读取环境变量
|
||||
file, err := ini.Load(m.SERVER_CONFIG)
|
||||
if err != nil {
|
||||
fmt.Println(m.ERRORCONFIG, err)
|
||||
}
|
||||
//加载数据库配置
|
||||
LoadMysqlData(file)
|
||||
|
||||
//MySQL数据库
|
||||
path := strings.Join([]string{DbUser, ":", DbPassWord, "@tcp(", DbHost, ":", DbPort, ")/", DbName, "?charset=utf8&parseTime=true"}, "")
|
||||
//连接数据库
|
||||
Database(path)
|
||||
}
|
||||
|
||||
func LoadMysqlData(file *ini.File) {
|
||||
Db = file.Section("mysql").Key("Db").String()
|
||||
DbHost = file.Section("mysql").Key("DbHost").String()
|
||||
DbPort = file.Section("mysql").Key("DbPort").String()
|
||||
DbUser = file.Section("mysql").Key("DbUser").String()
|
||||
DbPassWord = file.Section("mysql").Key("DbPassWord").String()
|
||||
DbName = file.Section("mysql").Key("DbName").String()
|
||||
}
|
||||
|
||||
func Database(conn string) {
|
||||
var ormLogger logger.Interface
|
||||
if gin.Mode() == "debug" {
|
||||
ormLogger = logger.Default.LogMode(logger.Info)
|
||||
} else {
|
||||
ormLogger = logger.Default
|
||||
}
|
||||
db, err := gorm.Open(mysql.New(mysql.Config{
|
||||
DSN: conn, // DSN data source name
|
||||
DefaultStringSize: 256, // string 类型字段的默认长度
|
||||
DisableDatetimePrecision: true, // 禁用 datetime 精度,MySQL 5.6 之前的数据库不支持
|
||||
DontSupportRenameIndex: true, // 重命名索引时采用删除并新建的方式,MySQL 5.7 之前的数据库和 MariaDB 不支持重命名索引
|
||||
DontSupportRenameColumn: true, // 用 `change` 重命名列,MySQL 8 之前的数据库和 MariaDB 不支持重命名列
|
||||
SkipInitializeWithVersion: false, // 根据版本自动配置
|
||||
}), &gorm.Config{
|
||||
Logger: ormLogger,
|
||||
NamingStrategy: schema.NamingStrategy{
|
||||
SingularTable: true,
|
||||
},
|
||||
})
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
sqlDB, _ := db.DB()
|
||||
sqlDB.SetMaxIdleConns(20) //设置连接池,空闲
|
||||
sqlDB.SetMaxOpenConns(100) //打开
|
||||
sqlDB.SetConnMaxLifetime(time.Second * 30)
|
||||
DB = db
|
||||
}
|
57
pkg/model/show.go
Normal file
57
pkg/model/show.go
Normal file
@ -0,0 +1,57 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Show 画展审批
|
||||
type Show struct {
|
||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
||||
DeletedAt int `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ArtistNum uint64 `gorm:"column:artist_num" json:"artistNum"` // 艺术家数量
|
||||
ShowAt string `gorm:"column:show_at" json:"showAt"` // 画展时间
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 关联申请的ID
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *Show) TableName() string {
|
||||
return "show"
|
||||
}
|
||||
|
||||
func (m *Show) SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error {
|
||||
m.ArtistNum = in.Show.ArtistNum
|
||||
m.ApprovalID = a.ApproverID
|
||||
m.ShowAt = in.Show.ShowAt
|
||||
return DB.Create(&m).Error
|
||||
}
|
||||
func (m *Show) BuildResContent(a *Approval, request *approval.ApprovalRequest) {
|
||||
request.Show = &approval.Show{
|
||||
ID: m.ID,
|
||||
ArtistNum: m.ArtistNum,
|
||||
ShowAt: m.ShowAt,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Show) DeleteApproval(p *Approval) error {
|
||||
return DB.Where(&Show{ApprovalID: p.ID}).Delete(&Show{}).Error
|
||||
}
|
||||
|
||||
// ShowColumns get sql column name.获取数据库列名
|
||||
var ShowColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
ArtistNum string
|
||||
ShowAt string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
ArtistNum: "artist_num",
|
||||
ShowAt: "show_at",
|
||||
}
|
119
pkg/model/work.go
Normal file
119
pkg/model/work.go
Normal file
@ -0,0 +1,119 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// Work 画作申请审批
|
||||
type Work struct {
|
||||
ID uint64 `gorm:"column:id" json:"id"`
|
||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
||||
ReturnAt string `gorm:"column:return_at" json:"returnAt"` // 送还时间
|
||||
ReceivedAt string `gorm:"column:received_at" json:"receivedAt"` // 领取时间
|
||||
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"` // 关联申请的ID
|
||||
ApprovalWorks []*ApprovalWork `gorm:"foreignKey:WorkId" json:"ApprovalWorks"` //type:string comment:备注 version:2022-06-12 15:10
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *Work) TableName() string {
|
||||
return "work"
|
||||
}
|
||||
|
||||
func (m *Work) SaveApprovalContent(in *approval.ApprovalRequest, a *Approval) error {
|
||||
|
||||
//主体保存
|
||||
m.ApprovalID = a.ApproverID
|
||||
m.ReturnAt = in.Work.ReturnAt
|
||||
m.ReceivedAt = in.Work.ReceivedAt
|
||||
|
||||
err := DB.Create(m).Error
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//绑定画作保存
|
||||
var approvalWorks []ApprovalWork
|
||||
for _, approvalWork := range in.Work.ApprovalWorks {
|
||||
fmt.Println(approvalWork)
|
||||
temp := ApprovalWork{
|
||||
|
||||
ApprovalID: a.ID,
|
||||
WorkID: m.ID,
|
||||
ArtworkID: approvalWork.ArtworkId,
|
||||
ArtworkName: approvalWork.ArtworkName,
|
||||
ArtistName: approvalWork.ArtistName,
|
||||
ArtworkCover: approvalWork.ArtworkCover,
|
||||
ArtworkNumber: approvalWork.ArtworkNumber,
|
||||
}
|
||||
|
||||
approvalWorks = append(approvalWorks, temp)
|
||||
}
|
||||
|
||||
if len(approvalWorks) > 0 {
|
||||
err = DB.Create(&approvalWorks).Error
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (m *Work) BuildResContent(a *Approval, request *approval.ApprovalRequest) {
|
||||
|
||||
//ApprovalWorks []*ApprovalWork `protobuf:"bytes,4,rep,name=ApprovalWorks,json=approvalWorks,proto3" json:"ApprovalWorks,omitempty"`
|
||||
var approvalWorks []*approval.ApprovalWork
|
||||
|
||||
for _, one := range m.ApprovalWorks {
|
||||
temp := &approval.ApprovalWork{
|
||||
|
||||
ID: one.ID,
|
||||
WorkId: one.WorkID,
|
||||
ApprovalID: one.ApprovalID,
|
||||
ArtworkId: one.ArtworkID,
|
||||
ArtworkName: one.ArtworkName,
|
||||
ArtistName: one.ArtistName,
|
||||
ArtworkCover: one.ArtworkCover,
|
||||
ArtworkNumber: one.ArtworkNumber,
|
||||
}
|
||||
approvalWorks = append(approvalWorks, temp)
|
||||
|
||||
}
|
||||
|
||||
request.Work = &approval.Work{
|
||||
ID: m.ID,
|
||||
ReturnAt: m.ReturnAt,
|
||||
ReceivedAt: m.ReceivedAt,
|
||||
ApprovalWorks: approvalWorks,
|
||||
}
|
||||
}
|
||||
|
||||
func (m *Work) DeleteApproval(p *Approval) error {
|
||||
|
||||
var err error
|
||||
if err = DB.Where(&ApprovalWork{ApprovalID: p.ID}).
|
||||
Delete(&ApprovalWork{}).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return DB.Where(&Work{ApprovalID: p.ID}).Delete(&Work{}).Error
|
||||
}
|
||||
|
||||
// WorkColumns get sql column name.获取数据库列名
|
||||
var WorkColumns = struct {
|
||||
ID string
|
||||
DeletedAt string
|
||||
CreatedAt string
|
||||
UpdatedAt string
|
||||
ReturnAt string
|
||||
ReceivedAt string
|
||||
}{
|
||||
ID: "id",
|
||||
DeletedAt: "deleted_at",
|
||||
CreatedAt: "created_at",
|
||||
UpdatedAt: "updated_at",
|
||||
ReturnAt: "return_at",
|
||||
ReceivedAt: "received_at",
|
||||
}
|
47
pkg/serializer/approval.go
Normal file
47
pkg/serializer/approval.go
Normal file
@ -0,0 +1,47 @@
|
||||
package serializer
|
||||
|
||||
import (
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
||||
)
|
||||
|
||||
//BuildApproval 处理单个detail返回
|
||||
func BuildApproval(entity *model.Approval) *approval.ApprovalRequest {
|
||||
var work *approval.Work
|
||||
var show *approval.Show
|
||||
var exhibition *approval.Exhibition
|
||||
var bundle *approval.Bundle
|
||||
|
||||
response := &approval.ApprovalRequest{
|
||||
ID: entity.ID,
|
||||
Domain: entity.Domain,
|
||||
Status: uint64(entity.Status),
|
||||
Type: entity.Type,
|
||||
ApproverId: entity.ApproverID,
|
||||
ApproverName: entity.ApproverName,
|
||||
CopyUsers: model.FormatToResponse(entity.CopyUsers),
|
||||
SubmitterId: entity.SubmitterID,
|
||||
SubmitterName: entity.SubmitterName,
|
||||
Content: entity.Content,
|
||||
Reply: entity.Reply,
|
||||
Work: work,
|
||||
Show: show,
|
||||
Exhibition: exhibition,
|
||||
Bundle: bundle,
|
||||
}
|
||||
|
||||
_ = entity.SetResContent(response)
|
||||
|
||||
return response
|
||||
}
|
||||
|
||||
//BuildApproval 处理单个detail返回
|
||||
func BuildApprovals(list []*model.Approval) (details []*approval.ApprovalRequest) {
|
||||
|
||||
for _, item := range list {
|
||||
temp := BuildApproval(item)
|
||||
details = append(details, temp)
|
||||
}
|
||||
|
||||
return details
|
||||
}
|
31
pkg/serializer/department_approval_setting.go
Normal file
31
pkg/serializer/department_approval_setting.go
Normal file
@ -0,0 +1,31 @@
|
||||
package serializer
|
||||
|
||||
import (
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
||||
)
|
||||
|
||||
//BuildSetting 处理单个detail返回
|
||||
func BuildSetting(entity *model.DepartmentApprovalSetting) *approval.SettingRequest {
|
||||
var copyUsers []*approval.CopyUser
|
||||
|
||||
for _, copyUser := range entity.CopyUsers {
|
||||
temp := &approval.CopyUser{
|
||||
ID: copyUser.ID,
|
||||
Name: copyUser.Name,
|
||||
}
|
||||
|
||||
copyUsers = append(copyUsers, temp)
|
||||
}
|
||||
|
||||
response := &approval.SettingRequest{
|
||||
ID: entity.ID,
|
||||
Domain: entity.Domain,
|
||||
DepartmentId: entity.DepartmentID,
|
||||
CopyUsers: copyUsers,
|
||||
ApproverId: entity.ApproverID,
|
||||
ApproverName: entity.ApproverName,
|
||||
}
|
||||
|
||||
return response
|
||||
}
|
150
pkg/service/approval.go
Normal file
150
pkg/service/approval.go
Normal file
@ -0,0 +1,150 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/serializer"
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type ApprovalProvider struct {
|
||||
approval.UnimplementedApprovalServer
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) Create(ctx context.Context, in *approval.ApprovalRequest) (*approval.ApprovalResponse, error) {
|
||||
response := &approval.ApprovalResponse{}
|
||||
|
||||
entity, err := model.StoreApproval(in)
|
||||
response.ID = entity.ID
|
||||
response.Success = true
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) Update(ctx context.Context, in *approval.ApprovalRequest) (*approval.ApprovalResponse, error) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) Remove(ctx context.Context, in *approval.ApprovalDetail) (*approval.ApprovalRemove, error) {
|
||||
|
||||
response := &approval.ApprovalRemove{}
|
||||
|
||||
err := model.DB.Transaction(func(tx *gorm.DB) error {
|
||||
|
||||
var err error
|
||||
var entity *model.Approval
|
||||
|
||||
// 确定有数据则执行删除
|
||||
if err = model.DB.Where(&model.Approval{Domain: in.Domain}).
|
||||
Find(&entity, in.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
//删除子关联数据
|
||||
if err = entity.DeleteContent(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = model.DB.Where(&model.Approval{Domain: in.Domain}).
|
||||
Delete(&model.Approval{}, in.ID).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
response.Success = true
|
||||
|
||||
return response, nil
|
||||
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) Detail(ctx context.Context, in *approval.ApprovalDetail) (*approval.ApprovalRequest, error) {
|
||||
response := &approval.ApprovalRequest{}
|
||||
var err error
|
||||
var entity *model.Approval
|
||||
if err := model.DB.First(&entity, in.ID).Error; err != nil {
|
||||
return response, err
|
||||
}
|
||||
|
||||
response = serializer.BuildApproval(entity)
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) List(ctx context.Context, in *approval.ApprovalListRequest) (*approval.ApprovalListResponse, error) {
|
||||
|
||||
//获取人的 部门角色(1、管理组 2、超级管理 3、Leader角色)
|
||||
response := &approval.ApprovalListResponse{}
|
||||
|
||||
var list []*model.Approval
|
||||
var count int64
|
||||
|
||||
list, count = model.ApprovalList(in)
|
||||
|
||||
response.Count = uint64(count)
|
||||
response.Data = serializer.BuildApprovals(list)
|
||||
return response, nil
|
||||
}
|
||||
|
||||
// UpdateSetting 设置配置抄送者和审核者
|
||||
func (a *ApprovalProvider) UpdateSetting(ctx context.Context, in *approval.SettingRequest) (*approval.SettingResponse, error) {
|
||||
|
||||
exhibit := ""
|
||||
exhibit += in.Domain
|
||||
|
||||
fmt.Println(exhibit)
|
||||
|
||||
response := &approval.SettingResponse{}
|
||||
var setting model.DepartmentApprovalSetting
|
||||
copyUsers := model.FormatCopyUsers(in.CopyUsers)
|
||||
|
||||
if err := model.DB.Model(&model.DepartmentApprovalSetting{}).
|
||||
Where(&model.DepartmentApprovalSetting{Domain: in.Domain, DepartmentID: in.DepartmentId}).
|
||||
First(&setting).Error; err != nil {
|
||||
|
||||
setting = model.DepartmentApprovalSetting{
|
||||
DepartmentID: in.DepartmentId,
|
||||
CopyUsers: copyUsers,
|
||||
ApproverID: in.ApproverId,
|
||||
ApproverName: in.ApproverName,
|
||||
Domain: in.Domain,
|
||||
}
|
||||
|
||||
model.DB.Create(&setting)
|
||||
} else {
|
||||
setting.DepartmentID = in.DepartmentId
|
||||
setting.CopyUsers = copyUsers
|
||||
setting.ApproverID = in.ApproverId
|
||||
setting.ApproverName = in.ApproverName
|
||||
model.DB.Save(&setting)
|
||||
}
|
||||
|
||||
response.ID = setting.ID
|
||||
response.Success = true
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) DetailSetting(ctx context.Context, in *approval.DetailSettingRequest) (*approval.SettingRequest, error) {
|
||||
|
||||
response := &approval.SettingRequest{}
|
||||
var setting model.DepartmentApprovalSetting
|
||||
|
||||
if err := model.DB.Model(&model.DepartmentApprovalSetting{}).
|
||||
Where(&model.DepartmentApprovalSetting{Domain: in.Domain, DepartmentID: in.DepartmentId}).
|
||||
First(&setting).Error; err != nil {
|
||||
response.Domain = in.Domain
|
||||
} else {
|
||||
response = serializer.BuildSetting(&setting)
|
||||
}
|
||||
|
||||
return response, nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user