feat 多级审批
feat 审批类型
This commit is contained in:
parent
4f3cb9fe45
commit
130a73bf70
File diff suppressed because it is too large
Load Diff
@ -12,25 +12,68 @@ service Approval {
|
|||||||
rpc Update(CreateRequest) returns (ApprovalResponse) {};
|
rpc Update(CreateRequest) returns (ApprovalResponse) {};
|
||||||
rpc Remove(DetailRequest) returns (RemoveResponse) {};
|
rpc Remove(DetailRequest) returns (RemoveResponse) {};
|
||||||
rpc List(ListRequest) returns (ListResponse) {};
|
rpc List(ListRequest) returns (ListResponse) {};
|
||||||
|
rpc NowLevelByInfo(NowLevelByInfoRequest) returns (WorkFlowResponse) {};
|
||||||
rpc Information(InformationRequest) returns (InformationResponse) {};
|
rpc Information(InformationRequest) returns (InformationResponse) {};
|
||||||
rpc Viewed(ViewedRequest) returns (ApprovalResponse) {};
|
rpc Viewed(ViewedRequest) returns (ApprovalResponse) {};
|
||||||
rpc SetStatus(StatusRequest) returns (StatusResponse) {};
|
rpc SetStatus(StatusRequest) returns (StatusResponse) {};
|
||||||
|
|
||||||
rpc DetailSetting(DetailSettingRequest) returns (SettingRequest) {};
|
rpc DetailSetting(DetailSettingRequest) returns (SettingRequest) {};
|
||||||
rpc UpdateSetting(SettingRequest) returns (SettingResponse) {};
|
rpc UpdateSetting(SettingRequest) returns (SettingResponse) {};
|
||||||
|
|
||||||
|
rpc CreateType(CreateTypeRequest) returns (TypeResponse) {};
|
||||||
|
rpc DetailType(TypeResponse) returns (CreateTypeRequest) {};
|
||||||
|
rpc UpdateType(CreateTypeRequest) returns (TypeResponse) {};
|
||||||
|
rpc AllType(CommonRequest) returns (AllTypeResponse) {};
|
||||||
|
rpc RemoveType(TypeResponse) returns (TypeResponse) {};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message NowLevelByInfoRequest {
|
||||||
|
string Domain = 1 [json_name = "domain"];
|
||||||
|
uint64 ApprovalID = 2 [json_name = "ApprovalID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message WorkFlowResponse {
|
||||||
|
uint64 ID = 2 [json_name = "ID"];
|
||||||
|
string Reply = 3 [json_name = "Reply"];
|
||||||
|
uint64 Status = 5 [json_name = "status"];
|
||||||
|
uint64 UserID = 7 [json_name = "userID"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message CommonRequest {
|
||||||
|
string Domain = 1 [json_name = "domain"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message CreateTypeRequest {
|
||||||
|
string Domain = 1 [json_name = "domain"];
|
||||||
|
uint64 ID = 2 [json_name = "ID"];
|
||||||
|
string Title = 3 [json_name = "title"];
|
||||||
|
string KeyWord = 4 [json_name = "keyWord"];
|
||||||
|
}
|
||||||
|
|
||||||
|
message TypeResponse {
|
||||||
|
uint64 ID = 1;
|
||||||
|
string Domain = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message AllTypeResponse {
|
||||||
|
repeated CreateTypeRequest Data = 1;
|
||||||
|
uint64 Count = 2;
|
||||||
|
}
|
||||||
|
|
||||||
enum StatusType {
|
enum StatusType {
|
||||||
Doing = 0;
|
Doing = 0;
|
||||||
Ok = 1;
|
Ok = 1;
|
||||||
Fail = 2;
|
Fail = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
message StatusRequest {
|
message StatusRequest {
|
||||||
string Domain = 1 [json_name = "domain"];
|
string Domain = 1 [json_name = "domain"];
|
||||||
uint64 ID = 2 [json_name = "ID"];
|
uint64 ID = 2 [json_name = "ID"];
|
||||||
string Replay = 3 [json_name = "replay"];
|
string Reply = 3 [json_name = "Reply"];
|
||||||
StatusType Status = 4 [json_name = "status",(validator.field) = {is_in_enum: true,human_error: "状态非法"}];
|
uint64 WorkFlowId = 4 [json_name = "workFlowId"];
|
||||||
|
StatusType Status = 5 [json_name = "status",(validator.field) = {is_in_enum: true,human_error: "状态非法"}];
|
||||||
|
uint64 Level = 6 [json_name = "level"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message StatusResponse {
|
message StatusResponse {
|
||||||
@ -143,6 +186,19 @@ message CreateRequest {
|
|||||||
Show Show = 14 [json_name = "show"];
|
Show Show = 14 [json_name = "show"];
|
||||||
Exhibition Exhibition = 15 [json_name = "exhibition"];
|
Exhibition Exhibition = 15 [json_name = "exhibition"];
|
||||||
Bundle Bundle = 16 [json_name = "bundle"];
|
Bundle Bundle = 16 [json_name = "bundle"];
|
||||||
|
repeated ApprovalUser ApprovalUsers= 17 [json_name = "approvalUsers"];//审批的人
|
||||||
|
bool CanApproval = 18 [json_name = "canApproval"];//审批的人
|
||||||
|
repeated WorkFlow WorkFlows = 19 [json_name = "workFlows"];//审批的人
|
||||||
|
}
|
||||||
|
|
||||||
|
message WorkFlow {
|
||||||
|
uint64 ID = 1 [json_name = "ID"];
|
||||||
|
uint64 UserID = 3 [json_name = "userID"];
|
||||||
|
string Name = 4 [json_name = "name"];
|
||||||
|
uint64 Level = 5 [json_name = "level"];
|
||||||
|
uint64 Status = 6 [json_name = "status"];
|
||||||
|
string Reply = 7 [json_name = "reply"];
|
||||||
|
string OperatedAt = 8 [json_name = "operatedAt"];
|
||||||
}
|
}
|
||||||
|
|
||||||
message DetailRequest {
|
message DetailRequest {
|
||||||
@ -187,20 +243,25 @@ message CopyUser {
|
|||||||
bool IsViewed =3 [json_name = "isViewed"];
|
bool IsViewed =3 [json_name = "isViewed"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message ApprovalUser {
|
||||||
|
uint64 ID =1 [json_name = "ID"];
|
||||||
|
string Name =2 [json_name = "name"];
|
||||||
|
string Level =3 [json_name = "Level"];
|
||||||
|
}
|
||||||
|
|
||||||
message SettingRequest {
|
message SettingRequest {
|
||||||
uint64 ID=1 [json_name = "ID"];
|
uint64 ID = 1 [json_name = "ID"];
|
||||||
uint64 DeletedAt=2 [json_name = "deletedAt"];
|
uint64 DeletedAt = 2 [json_name = "deletedAt"];
|
||||||
string CreatedAt=3 [json_name = "createdAt"];
|
string CreatedAt = 3 [json_name = "createdAt"];
|
||||||
string UpdatedAt=4 [json_name = "updatedAt"];
|
string UpdatedAt = 4 [json_name = "updatedAt"];
|
||||||
uint64 DepartmentID=5 [json_name = "departmentID"];
|
string KeyWord = 5 [json_name = "keyWord"];
|
||||||
repeated CopyUser CopyUsers=6 [json_name = "copyUsers"];
|
repeated CopyUser CopyUsers = 6 [json_name = "copyUsers"];
|
||||||
uint64 ApproverID=7 [json_name = "approverID"];
|
repeated ApprovalUser ApprovalUsers = 9 [json_name = "approvalUsers"];
|
||||||
string ApproverName=8 [json_name = "approverName"];
|
string Domain = 10 [json_name = "domain"];
|
||||||
string Domain=9 [json_name = "domain"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
message DetailSettingRequest {
|
message DetailSettingRequest {
|
||||||
uint64 DepartmentID=1 [json_name = "departmentID"];
|
string KeyWord=1 [json_name = "keyWord"];
|
||||||
string Domain=2 [json_name = "domain"];
|
string Domain=2 [json_name = "domain"];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,31 @@ var _ = proto.Marshal
|
|||||||
var _ = fmt.Errorf
|
var _ = fmt.Errorf
|
||||||
var _ = math.Inf
|
var _ = math.Inf
|
||||||
|
|
||||||
|
func (this *NowLevelByInfoRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *WorkFlowResponse) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *CommonRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *CreateTypeRequest) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *TypeResponse) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *AllTypeResponse) 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 *StatusRequest) Validate() error {
|
func (this *StatusRequest) Validate() error {
|
||||||
if _, ok := StatusType_name[int32(this.Status)]; !ok {
|
if _, ok := StatusType_name[int32(this.Status)]; !ok {
|
||||||
return github_com_mwitkow_go_proto_validators.FieldError("Status", fmt.Errorf(`状态非法`))
|
return github_com_mwitkow_go_proto_validators.FieldError("Status", fmt.Errorf(`状态非法`))
|
||||||
@ -140,6 +165,23 @@ func (this *CreateRequest) Validate() error {
|
|||||||
return github_com_mwitkow_go_proto_validators.FieldError("Bundle", err)
|
return github_com_mwitkow_go_proto_validators.FieldError("Bundle", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, item := range this.ApprovalUsers {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("ApprovalUsers", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for _, item := range this.WorkFlows {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("WorkFlows", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
func (this *WorkFlow) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *DetailRequest) Validate() error {
|
func (this *DetailRequest) Validate() error {
|
||||||
@ -163,6 +205,9 @@ func (this *ApprovalExhibitionDetail) Validate() error {
|
|||||||
func (this *CopyUser) Validate() error {
|
func (this *CopyUser) Validate() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
func (this *ApprovalUser) Validate() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
func (this *SettingRequest) Validate() error {
|
func (this *SettingRequest) Validate() error {
|
||||||
for _, item := range this.CopyUsers {
|
for _, item := range this.CopyUsers {
|
||||||
if item != nil {
|
if item != nil {
|
||||||
@ -171,6 +216,13 @@ func (this *SettingRequest) Validate() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for _, item := range this.ApprovalUsers {
|
||||||
|
if item != nil {
|
||||||
|
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(item); err != nil {
|
||||||
|
return github_com_mwitkow_go_proto_validators.FieldError("ApprovalUsers", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
func (this *DetailSettingRequest) Validate() error {
|
func (this *DetailSettingRequest) Validate() error {
|
||||||
|
@ -33,11 +33,17 @@ type ApprovalClient interface {
|
|||||||
Update(ctx context.Context, in *CreateRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
Update(ctx context.Context, in *CreateRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
||||||
Remove(ctx context.Context, in *DetailRequest, opts ...grpc_go.CallOption) (*RemoveResponse, common.ErrorWithAttachment)
|
Remove(ctx context.Context, in *DetailRequest, opts ...grpc_go.CallOption) (*RemoveResponse, common.ErrorWithAttachment)
|
||||||
List(ctx context.Context, in *ListRequest, opts ...grpc_go.CallOption) (*ListResponse, common.ErrorWithAttachment)
|
List(ctx context.Context, in *ListRequest, opts ...grpc_go.CallOption) (*ListResponse, common.ErrorWithAttachment)
|
||||||
|
NowLevelByInfo(ctx context.Context, in *NowLevelByInfoRequest, opts ...grpc_go.CallOption) (*WorkFlowResponse, common.ErrorWithAttachment)
|
||||||
Information(ctx context.Context, in *InformationRequest, opts ...grpc_go.CallOption) (*InformationResponse, common.ErrorWithAttachment)
|
Information(ctx context.Context, in *InformationRequest, opts ...grpc_go.CallOption) (*InformationResponse, common.ErrorWithAttachment)
|
||||||
Viewed(ctx context.Context, in *ViewedRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
Viewed(ctx context.Context, in *ViewedRequest, opts ...grpc_go.CallOption) (*ApprovalResponse, common.ErrorWithAttachment)
|
||||||
SetStatus(ctx context.Context, in *StatusRequest, opts ...grpc_go.CallOption) (*StatusResponse, common.ErrorWithAttachment)
|
SetStatus(ctx context.Context, in *StatusRequest, opts ...grpc_go.CallOption) (*StatusResponse, common.ErrorWithAttachment)
|
||||||
DetailSetting(ctx context.Context, in *DetailSettingRequest, opts ...grpc_go.CallOption) (*SettingRequest, 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)
|
UpdateSetting(ctx context.Context, in *SettingRequest, opts ...grpc_go.CallOption) (*SettingResponse, common.ErrorWithAttachment)
|
||||||
|
CreateType(ctx context.Context, in *CreateTypeRequest, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment)
|
||||||
|
DetailType(ctx context.Context, in *TypeResponse, opts ...grpc_go.CallOption) (*CreateTypeRequest, common.ErrorWithAttachment)
|
||||||
|
UpdateType(ctx context.Context, in *CreateTypeRequest, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment)
|
||||||
|
AllType(ctx context.Context, in *CommonRequest, opts ...grpc_go.CallOption) (*AllTypeResponse, common.ErrorWithAttachment)
|
||||||
|
RemoveType(ctx context.Context, in *TypeResponse, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment)
|
||||||
}
|
}
|
||||||
|
|
||||||
type approvalClient struct {
|
type approvalClient struct {
|
||||||
@ -50,11 +56,17 @@ type ApprovalClientImpl struct {
|
|||||||
Update func(ctx context.Context, in *CreateRequest) (*ApprovalResponse, error)
|
Update func(ctx context.Context, in *CreateRequest) (*ApprovalResponse, error)
|
||||||
Remove func(ctx context.Context, in *DetailRequest) (*RemoveResponse, error)
|
Remove func(ctx context.Context, in *DetailRequest) (*RemoveResponse, error)
|
||||||
List func(ctx context.Context, in *ListRequest) (*ListResponse, error)
|
List func(ctx context.Context, in *ListRequest) (*ListResponse, error)
|
||||||
|
NowLevelByInfo func(ctx context.Context, in *NowLevelByInfoRequest) (*WorkFlowResponse, error)
|
||||||
Information func(ctx context.Context, in *InformationRequest) (*InformationResponse, error)
|
Information func(ctx context.Context, in *InformationRequest) (*InformationResponse, error)
|
||||||
Viewed func(ctx context.Context, in *ViewedRequest) (*ApprovalResponse, error)
|
Viewed func(ctx context.Context, in *ViewedRequest) (*ApprovalResponse, error)
|
||||||
SetStatus func(ctx context.Context, in *StatusRequest) (*StatusResponse, error)
|
SetStatus func(ctx context.Context, in *StatusRequest) (*StatusResponse, error)
|
||||||
DetailSetting func(ctx context.Context, in *DetailSettingRequest) (*SettingRequest, error)
|
DetailSetting func(ctx context.Context, in *DetailSettingRequest) (*SettingRequest, error)
|
||||||
UpdateSetting func(ctx context.Context, in *SettingRequest) (*SettingResponse, error)
|
UpdateSetting func(ctx context.Context, in *SettingRequest) (*SettingResponse, error)
|
||||||
|
CreateType func(ctx context.Context, in *CreateTypeRequest) (*TypeResponse, error)
|
||||||
|
DetailType func(ctx context.Context, in *TypeResponse) (*CreateTypeRequest, error)
|
||||||
|
UpdateType func(ctx context.Context, in *CreateTypeRequest) (*TypeResponse, error)
|
||||||
|
AllType func(ctx context.Context, in *CommonRequest) (*AllTypeResponse, error)
|
||||||
|
RemoveType func(ctx context.Context, in *TypeResponse) (*TypeResponse, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ApprovalClientImpl) GetDubboStub(cc *triple.TripleConn) ApprovalClient {
|
func (c *ApprovalClientImpl) GetDubboStub(cc *triple.TripleConn) ApprovalClient {
|
||||||
@ -99,6 +111,12 @@ func (c *approvalClient) List(ctx context.Context, in *ListRequest, opts ...grpc
|
|||||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/List", in, out)
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/List", in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) NowLevelByInfo(ctx context.Context, in *NowLevelByInfoRequest, opts ...grpc_go.CallOption) (*WorkFlowResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(WorkFlowResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/NowLevelByInfo", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *approvalClient) Information(ctx context.Context, in *InformationRequest, opts ...grpc_go.CallOption) (*InformationResponse, common.ErrorWithAttachment) {
|
func (c *approvalClient) Information(ctx context.Context, in *InformationRequest, opts ...grpc_go.CallOption) (*InformationResponse, common.ErrorWithAttachment) {
|
||||||
out := new(InformationResponse)
|
out := new(InformationResponse)
|
||||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
@ -129,6 +147,36 @@ func (c *approvalClient) UpdateSetting(ctx context.Context, in *SettingRequest,
|
|||||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateSetting", in, out)
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateSetting", in, out)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) CreateType(ctx context.Context, in *CreateTypeRequest, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(TypeResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CreateType", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) DetailType(ctx context.Context, in *TypeResponse, opts ...grpc_go.CallOption) (*CreateTypeRequest, common.ErrorWithAttachment) {
|
||||||
|
out := new(CreateTypeRequest)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/DetailType", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) UpdateType(ctx context.Context, in *CreateTypeRequest, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(TypeResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateType", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) AllType(ctx context.Context, in *CommonRequest, opts ...grpc_go.CallOption) (*AllTypeResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(AllTypeResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/AllType", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *approvalClient) RemoveType(ctx context.Context, in *TypeResponse, opts ...grpc_go.CallOption) (*TypeResponse, common.ErrorWithAttachment) {
|
||||||
|
out := new(TypeResponse)
|
||||||
|
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||||
|
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/RemoveType", in, out)
|
||||||
|
}
|
||||||
|
|
||||||
// ApprovalServer is the server API for Approval service.
|
// ApprovalServer is the server API for Approval service.
|
||||||
// All implementations must embed UnimplementedApprovalServer
|
// All implementations must embed UnimplementedApprovalServer
|
||||||
// for forward compatibility
|
// for forward compatibility
|
||||||
@ -138,11 +186,17 @@ type ApprovalServer interface {
|
|||||||
Update(context.Context, *CreateRequest) (*ApprovalResponse, error)
|
Update(context.Context, *CreateRequest) (*ApprovalResponse, error)
|
||||||
Remove(context.Context, *DetailRequest) (*RemoveResponse, error)
|
Remove(context.Context, *DetailRequest) (*RemoveResponse, error)
|
||||||
List(context.Context, *ListRequest) (*ListResponse, error)
|
List(context.Context, *ListRequest) (*ListResponse, error)
|
||||||
|
NowLevelByInfo(context.Context, *NowLevelByInfoRequest) (*WorkFlowResponse, error)
|
||||||
Information(context.Context, *InformationRequest) (*InformationResponse, error)
|
Information(context.Context, *InformationRequest) (*InformationResponse, error)
|
||||||
Viewed(context.Context, *ViewedRequest) (*ApprovalResponse, error)
|
Viewed(context.Context, *ViewedRequest) (*ApprovalResponse, error)
|
||||||
SetStatus(context.Context, *StatusRequest) (*StatusResponse, error)
|
SetStatus(context.Context, *StatusRequest) (*StatusResponse, error)
|
||||||
DetailSetting(context.Context, *DetailSettingRequest) (*SettingRequest, error)
|
DetailSetting(context.Context, *DetailSettingRequest) (*SettingRequest, error)
|
||||||
UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error)
|
UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error)
|
||||||
|
CreateType(context.Context, *CreateTypeRequest) (*TypeResponse, error)
|
||||||
|
DetailType(context.Context, *TypeResponse) (*CreateTypeRequest, error)
|
||||||
|
UpdateType(context.Context, *CreateTypeRequest) (*TypeResponse, error)
|
||||||
|
AllType(context.Context, *CommonRequest) (*AllTypeResponse, error)
|
||||||
|
RemoveType(context.Context, *TypeResponse) (*TypeResponse, error)
|
||||||
mustEmbedUnimplementedApprovalServer()
|
mustEmbedUnimplementedApprovalServer()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,6 +220,9 @@ func (UnimplementedApprovalServer) Remove(context.Context, *DetailRequest) (*Rem
|
|||||||
func (UnimplementedApprovalServer) List(context.Context, *ListRequest) (*ListResponse, error) {
|
func (UnimplementedApprovalServer) List(context.Context, *ListRequest) (*ListResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method List not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedApprovalServer) NowLevelByInfo(context.Context, *NowLevelByInfoRequest) (*WorkFlowResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method NowLevelByInfo not implemented")
|
||||||
|
}
|
||||||
func (UnimplementedApprovalServer) Information(context.Context, *InformationRequest) (*InformationResponse, error) {
|
func (UnimplementedApprovalServer) Information(context.Context, *InformationRequest) (*InformationResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method Information not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method Information not implemented")
|
||||||
}
|
}
|
||||||
@ -181,6 +238,21 @@ func (UnimplementedApprovalServer) DetailSetting(context.Context, *DetailSetting
|
|||||||
func (UnimplementedApprovalServer) UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error) {
|
func (UnimplementedApprovalServer) UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error) {
|
||||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateSetting not implemented")
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateSetting not implemented")
|
||||||
}
|
}
|
||||||
|
func (UnimplementedApprovalServer) CreateType(context.Context, *CreateTypeRequest) (*TypeResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method CreateType not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApprovalServer) DetailType(context.Context, *TypeResponse) (*CreateTypeRequest, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method DetailType not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApprovalServer) UpdateType(context.Context, *CreateTypeRequest) (*TypeResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method UpdateType not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApprovalServer) AllType(context.Context, *CommonRequest) (*AllTypeResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method AllType not implemented")
|
||||||
|
}
|
||||||
|
func (UnimplementedApprovalServer) RemoveType(context.Context, *TypeResponse) (*TypeResponse, error) {
|
||||||
|
return nil, status.Errorf(codes.Unimplemented, "method RemoveType not implemented")
|
||||||
|
}
|
||||||
func (s *UnimplementedApprovalServer) XXX_SetProxyImpl(impl protocol.Invoker) {
|
func (s *UnimplementedApprovalServer) XXX_SetProxyImpl(impl protocol.Invoker) {
|
||||||
s.proxyImpl = impl
|
s.proxyImpl = impl
|
||||||
}
|
}
|
||||||
@ -354,6 +426,35 @@ func _Approval_List_Handler(srv interface{}, ctx context.Context, dec func(inter
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Approval_NowLevelByInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(NowLevelByInfoRequest)
|
||||||
|
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("NowLevelByInfo", 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_Information_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
func _Approval_Information_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
in := new(InformationRequest)
|
in := new(InformationRequest)
|
||||||
if err := dec(in); err != nil {
|
if err := dec(in); err != nil {
|
||||||
@ -499,6 +600,151 @@ func _Approval_UpdateSetting_Handler(srv interface{}, ctx context.Context, dec f
|
|||||||
return interceptor(ctx, in, info, handler)
|
return interceptor(ctx, in, info, handler)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _Approval_CreateType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateTypeRequest)
|
||||||
|
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("CreateType", 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_DetailType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(TypeResponse)
|
||||||
|
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("DetailType", 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_UpdateType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CreateTypeRequest)
|
||||||
|
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("UpdateType", 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_AllType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(CommonRequest)
|
||||||
|
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("AllType", 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_RemoveType_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||||
|
in := new(TypeResponse)
|
||||||
|
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("RemoveType", 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.
|
// Approval_ServiceDesc is the grpc_go.ServiceDesc for Approval service.
|
||||||
// It's only intended for direct use with grpc_go.RegisterService,
|
// It's only intended for direct use with grpc_go.RegisterService,
|
||||||
// and not to be introspected or modified (even as a copy)
|
// and not to be introspected or modified (even as a copy)
|
||||||
@ -526,6 +772,10 @@ var Approval_ServiceDesc = grpc_go.ServiceDesc{
|
|||||||
MethodName: "List",
|
MethodName: "List",
|
||||||
Handler: _Approval_List_Handler,
|
Handler: _Approval_List_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "NowLevelByInfo",
|
||||||
|
Handler: _Approval_NowLevelByInfo_Handler,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
MethodName: "Information",
|
MethodName: "Information",
|
||||||
Handler: _Approval_Information_Handler,
|
Handler: _Approval_Information_Handler,
|
||||||
@ -546,6 +796,26 @@ var Approval_ServiceDesc = grpc_go.ServiceDesc{
|
|||||||
MethodName: "UpdateSetting",
|
MethodName: "UpdateSetting",
|
||||||
Handler: _Approval_UpdateSetting_Handler,
|
Handler: _Approval_UpdateSetting_Handler,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
MethodName: "CreateType",
|
||||||
|
Handler: _Approval_CreateType_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "DetailType",
|
||||||
|
Handler: _Approval_DetailType_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "UpdateType",
|
||||||
|
Handler: _Approval_UpdateType_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "AllType",
|
||||||
|
Handler: _Approval_AllType_Handler,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
MethodName: "RemoveType",
|
||||||
|
Handler: _Approval_RemoveType_Handler,
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Streams: []grpc_go.StreamDesc{},
|
Streams: []grpc_go.StreamDesc{},
|
||||||
Metadata: "api/approval/approval.proto",
|
Metadata: "api/approval/approval.proto",
|
||||||
|
@ -19,3 +19,7 @@ const (
|
|||||||
ErrorWrongStatus = "当前状态无法修改"
|
ErrorWrongStatus = "当前状态无法修改"
|
||||||
ErrorChangeType = "无法修改其类型"
|
ErrorChangeType = "无法修改其类型"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
ErrorOperate = "操作顺序错误"
|
||||||
|
)
|
||||||
|
@ -4,7 +4,7 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/common/page"
|
"github.com/fonchain_enterprise/fonchain-approval/pkg/common/page"
|
||||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
msg "github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||||
"gorm.io/gorm"
|
"gorm.io/gorm"
|
||||||
"gorm.io/plugin/soft_delete"
|
"gorm.io/plugin/soft_delete"
|
||||||
"time"
|
"time"
|
||||||
@ -12,24 +12,28 @@ import (
|
|||||||
|
|
||||||
// Approval 审批
|
// Approval 审批
|
||||||
type Approval struct {
|
type Approval struct {
|
||||||
ID uint64 `gorm:"primaryKey;column:id" json:"id"` // ID
|
ID uint64 `gorm:"primaryKey;column:id" json:"id"`
|
||||||
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"` // 删除时间
|
DeletedAt soft_delete.DeletedAt `gorm:"column:deleted_at" json:"deletedAt"`
|
||||||
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"` // 创建时间
|
CreatedAt time.Time `gorm:"column:created_at" json:"createdAt"`
|
||||||
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"` // 更新时间
|
UpdatedAt time.Time `gorm:"column:updated_at" json:"updatedAt"`
|
||||||
SubmitterID uint64 `gorm:"column:submitter_id" json:"submitterId"` // 提交人ID
|
SubmitterID uint64 `gorm:"column:submitter_id" json:"submitterId"`
|
||||||
ApproverID uint64 `gorm:"column:approver_id" json:"approverId"` // 审核人ID
|
Status int8 `gorm:"column:status" json:"status"`
|
||||||
Status int8 `gorm:"column:status" json:"status"` // 状态0-待 1-可 2-否
|
SubmitterName string `gorm:"column:submitter_name" json:"submitterName"`
|
||||||
SubmitterName string `gorm:"column:submitter_name" json:"submitterName"` // 提交人名称缓存
|
CopyUsers CopyUsers `gorm:"column:copy_users" json:"copyUsers"`
|
||||||
ApproverName string `gorm:"column:approver_name" json:"approverName"` // 审核人名称缓存
|
ApprovalUsers ApprovalUsers `gorm:"column:approval_users" json:"approvalUsers"`
|
||||||
CopyUsers CopyUsers `gorm:"column:copy_users" json:"copyUsers"` // 抄送人
|
Type string `gorm:"column:type" json:"type"`
|
||||||
Type string `gorm:"column:type" json:"type"` // 类型
|
Level uint8 `gorm:"column:level" json:"level"`
|
||||||
Content string `gorm:"column:content" json:"content"` // 提交审批内容
|
NowLevel uint8 `gorm:"column:now_level" json:"nowLevel"`
|
||||||
Reply string `gorm:"column:reply" json:"reply"` // 回复内容
|
NowUserId uint64 `gorm:"column:now_user_id" json:"nowUserId"`
|
||||||
Domain *string `gorm:"column:domain" json:"domain"` // 环境变量
|
NowUserName string `gorm:"column:now_user_name" json:"nowUserName"`
|
||||||
Show *Show `gorm:"foreignKey:ApprovalID" json:"Show"` // 环境变量
|
Content string `gorm:"column:content" json:"content"`
|
||||||
Work *Work `gorm:"foreignKey:ApprovalID" json:"Work"` // 环境变量
|
Reply string `gorm:"column:reply" json:"reply"`
|
||||||
Bundle *Bundle `gorm:"foreignKey:ApprovalID" json:"Bundle"` // 环境变量
|
Domain *string `gorm:"column:domain" json:"domain"`
|
||||||
Exhibition *Exhibition `gorm:"foreignKey:ApprovalID" json:"Exhibition"` // 环境变量
|
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"`
|
||||||
|
ApprovalWorkFlows []*ApprovalWorkFlow `gorm:"foreignKey:ApprovalID" json:"ApprovalWorkFlows"`
|
||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -62,16 +66,24 @@ func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
|||||||
|
|
||||||
err := DB.Transaction(func(tx *gorm.DB) error {
|
err := DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
||||||
|
setting, terr := GetApprovalSettingFromKeyWord(in.Domain, in.Type)
|
||||||
|
if terr != nil {
|
||||||
|
return terr
|
||||||
|
}
|
||||||
|
|
||||||
// 保存基本信息
|
// 保存基本信息
|
||||||
entity = &Approval{
|
entity = &Approval{
|
||||||
Domain: &in.Domain,
|
Domain: &in.Domain,
|
||||||
SubmitterID: in.SubmitterID,
|
SubmitterID: in.SubmitterID,
|
||||||
SubmitterName: in.SubmitterName,
|
SubmitterName: in.SubmitterName,
|
||||||
ApproverID: in.ApproverID,
|
CopyUsers: setting.CopyUsers,
|
||||||
ApproverName: in.ApproverName,
|
ApprovalUsers: setting.ApprovalUsers,
|
||||||
CopyUsers: FormatCopyUsers(in.CopyUsers),
|
|
||||||
Type: in.Type,
|
Type: in.Type,
|
||||||
Content: in.Content,
|
Content: in.Content,
|
||||||
|
Level: uint8(len(setting.ApprovalUsers)),
|
||||||
|
NowLevel: 1,
|
||||||
|
NowUserId: setting.ApprovalUsers[0].ID,
|
||||||
|
NowUserName: setting.ApprovalUsers[0].Name,
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := DB.Create(&entity).Error; err != nil {
|
if err := DB.Create(&entity).Error; err != nil {
|
||||||
@ -81,7 +93,11 @@ func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
|||||||
// 不同类型保存不同的结构体
|
// 不同类型保存不同的结构体
|
||||||
err := entity.SaveContent(in)
|
err := entity.SaveContent(in)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return BatchSave(setting.ApprovalUsers, entity.ID)
|
||||||
})
|
})
|
||||||
|
|
||||||
return entity, err
|
return entity, err
|
||||||
@ -94,7 +110,7 @@ func Viewed(in *approval.ViewedRequest) error {
|
|||||||
var err error
|
var err error
|
||||||
|
|
||||||
if err = DB.First(&entity, in.ID).Error; err != nil {
|
if err = DB.First(&entity, in.ID).Error; err != nil {
|
||||||
return errors.New(m.ErrorNotFound)
|
return errors.New(msg.ErrorNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
copyUsers := entity.CopyUsers
|
copyUsers := entity.CopyUsers
|
||||||
@ -116,15 +132,15 @@ func UpdateApproval(in *approval.CreateRequest) (*Approval, error) {
|
|||||||
err := DB.Transaction(func(tx *gorm.DB) error {
|
err := DB.Transaction(func(tx *gorm.DB) error {
|
||||||
|
|
||||||
if departErr := DB.First(&entity, in.ID).Error; departErr != nil {
|
if departErr := DB.First(&entity, in.ID).Error; departErr != nil {
|
||||||
return errors.New(m.ErrorNotFound)
|
return errors.New(msg.ErrorNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
if entity.Type != in.Type {
|
if entity.Type != in.Type {
|
||||||
return errors.New(m.ErrorChangeType)
|
return errors.New(msg.ErrorChangeType)
|
||||||
}
|
}
|
||||||
|
|
||||||
if entity.Status != StatusDoing {
|
if entity.Status != StatusDoing {
|
||||||
return errors.New(m.ErrorWrongStatus)
|
return errors.New(msg.ErrorWrongStatus)
|
||||||
} else if in.Status != StatusDoing { //审批
|
} else if in.Status != StatusDoing { //审批
|
||||||
// 保存基本信息
|
// 保存基本信息
|
||||||
entity = &Approval{
|
entity = &Approval{
|
||||||
@ -190,12 +206,39 @@ func approvalCalc(filter *Approval) *approval.Information {
|
|||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func approvalCalcJson(domain string, userId uint64) *approval.Information {
|
||||||
|
|
||||||
|
var num int64
|
||||||
|
var jsonStr = "JSON_CONTAINS(approve_users,JSON_OBJECT('ID', ?))"
|
||||||
|
|
||||||
|
info := &approval.Information{
|
||||||
|
Total: 0,
|
||||||
|
DoingTotal: 0,
|
||||||
|
SuccessTotal: 0,
|
||||||
|
FailTotal: 0,
|
||||||
|
}
|
||||||
|
|
||||||
|
DB.Model(&Approval{}).Where(jsonStr, userId).Count(&num)
|
||||||
|
info.Total = uint64(num)
|
||||||
|
|
||||||
|
DB.Model(&Approval{}).Where(jsonStr, userId).Where(&Approval{Status: StatusOk, Domain: &domain}).Count(&num)
|
||||||
|
info.DoingTotal = uint64(num)
|
||||||
|
|
||||||
|
DB.Model(&Approval{}).Where(jsonStr, userId).Where(&Approval{Status: StatusOk, Domain: &domain}).Count(&num)
|
||||||
|
info.SuccessTotal = uint64(num)
|
||||||
|
|
||||||
|
DB.Model(&Approval{}).Where(jsonStr, userId).Where(&Approval{Status: StatusFail, Domain: &domain}).Count(&num)
|
||||||
|
info.FailTotal = uint64(num)
|
||||||
|
|
||||||
|
return info
|
||||||
|
}
|
||||||
|
|
||||||
// ApprovalInfo 统计
|
// ApprovalInfo 统计
|
||||||
func ApprovalInfo(in *approval.InformationRequest) (*approval.InformationResponse, error) {
|
func ApprovalInfo(in *approval.InformationRequest) (*approval.InformationResponse, error) {
|
||||||
|
|
||||||
response := &approval.InformationResponse{
|
response := &approval.InformationResponse{
|
||||||
MySubmitInfo: approvalCalc(&Approval{Domain: &in.Domain, SubmitterID: in.UserID}),
|
MySubmitInfo: approvalCalc(&Approval{Domain: &in.Domain, SubmitterID: in.UserID}),
|
||||||
SubmitMeInfo: approvalCalc(&Approval{Domain: &in.Domain, ApproverID: in.UserID}),
|
SubmitMeInfo: approvalCalcJson(in.Domain, in.UserID),
|
||||||
DomainInfo: approvalCalc(&Approval{Domain: &in.Domain}),
|
DomainInfo: approvalCalc(&Approval{Domain: &in.Domain}),
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -217,7 +260,7 @@ func (m *Approval) DeleteApproval(p *Approval) error {
|
|||||||
|
|
||||||
func (m *Approval) DeleteContent() error {
|
func (m *Approval) DeleteContent() error {
|
||||||
|
|
||||||
factory, err := GetApprovalContentFactory(m.Type)
|
factory, err := getApprovalContentFactory(m.Type)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -232,7 +275,7 @@ func (m *Approval) BuildResContent(a *Approval, request *approval.CreateRequest)
|
|||||||
|
|
||||||
func (m *Approval) SetResContent(request *approval.CreateRequest) error {
|
func (m *Approval) SetResContent(request *approval.CreateRequest) error {
|
||||||
|
|
||||||
factory, err := GetApprovalContentFactory(m.Type)
|
factory, err := getApprovalContentFactory(m.Type)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -245,7 +288,7 @@ func (m *Approval) SetResContent(request *approval.CreateRequest) error {
|
|||||||
|
|
||||||
func (m *Approval) SaveContent(in *approval.CreateRequest) error {
|
func (m *Approval) SaveContent(in *approval.CreateRequest) error {
|
||||||
|
|
||||||
factory, err := GetApprovalContentFactory(in.Type)
|
factory, err := getApprovalContentFactory(in.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -257,7 +300,7 @@ func (m *Approval) SaveContent(in *approval.CreateRequest) error {
|
|||||||
|
|
||||||
func (m *Approval) UpdateContent(in *approval.CreateRequest) error {
|
func (m *Approval) UpdateContent(in *approval.CreateRequest) error {
|
||||||
|
|
||||||
factory, err := GetApprovalContentFactory(in.Type)
|
factory, err := getApprovalContentFactory(in.Type)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -276,6 +319,7 @@ func ApprovalList(in *approval.ListRequest) ([]*Approval, int64) {
|
|||||||
Preload("Show").
|
Preload("Show").
|
||||||
Preload("Work.ApprovalWorks").
|
Preload("Work.ApprovalWorks").
|
||||||
Preload("Bundle").
|
Preload("Bundle").
|
||||||
|
Preload("ApprovalWorkFlows").
|
||||||
Preload("Exhibition.ApprovalExhibitions")
|
Preload("Exhibition.ApprovalExhibitions")
|
||||||
|
|
||||||
if in.Type != "" {
|
if in.Type != "" {
|
||||||
@ -283,7 +327,7 @@ func ApprovalList(in *approval.ListRequest) ([]*Approval, int64) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if in.UserID != 0 {
|
if in.UserID != 0 {
|
||||||
modelObj = modelObj.Where(DB.Where(&Approval{ApproverID: in.UserID}).
|
modelObj = modelObj.Where(DB.Where("JSON_CONTAINS(approve_users,JSON_OBJECT('ID', ?))", in.UserID).
|
||||||
Or("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID))
|
Or("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,7 +342,59 @@ func ApprovalList(in *approval.ListRequest) ([]*Approval, int64) {
|
|||||||
return list, count
|
return list, count
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetApprovalContentFactory(typeFiled string) (ApprovalContentInterface, error) {
|
func (m *Approval) Pass(reply string, workFlowId uint64) error {
|
||||||
|
return m.operateStatus(StatusOk, reply, workFlowId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Approval) Refuse(reply string, workFlowId uint64) error {
|
||||||
|
return m.operateStatus(StatusFail, reply, workFlowId)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *Approval) operateStatus(status uint8, reply string, workFlowId uint64) error {
|
||||||
|
|
||||||
|
var workFlow ApprovalWorkFlow
|
||||||
|
|
||||||
|
if err := DB.Model(&ApprovalWorkFlow{ApprovalID: m.ID, Status: StatusDoing}).First(&workFlow, workFlowId).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if m.NowLevel != workFlow.Level {
|
||||||
|
return errors.New(msg.ErrorOperate)
|
||||||
|
}
|
||||||
|
|
||||||
|
if status == StatusFail { //拒绝
|
||||||
|
m.Status = StatusFail
|
||||||
|
m.Reply = reply
|
||||||
|
|
||||||
|
if err := DB.Save(m).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workFlow.Refuse(reply)
|
||||||
|
}
|
||||||
|
|
||||||
|
//层级审批通过
|
||||||
|
if m.Level == m.NowLevel { // 整个审批通过
|
||||||
|
m.Status = StatusOk
|
||||||
|
} else { //审批层级通过
|
||||||
|
m.NowLevel = workFlow.Level + 1
|
||||||
|
nextFlow, err := GetWorkFlowByLevel(m.ID, m.NowLevel)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
m.NowUserId = nextFlow.UserId
|
||||||
|
m.NowUserName = nextFlow.Name
|
||||||
|
}
|
||||||
|
|
||||||
|
m.Reply = reply
|
||||||
|
if err := DB.Save(m).Error; err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workFlow.Pass(reply)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getApprovalContentFactory(typeFiled string) (ApprovalContentInterface, error) {
|
||||||
switch typeFiled {
|
switch typeFiled {
|
||||||
case TypeContent:
|
case TypeContent:
|
||||||
return &Approval{}, nil
|
return &Approval{}, nil
|
||||||
@ -311,39 +407,6 @@ func GetApprovalContentFactory(typeFiled string) (ApprovalContentInterface, erro
|
|||||||
case TypeExhibition:
|
case TypeExhibition:
|
||||||
return &Exhibition{}, nil
|
return &Exhibition{}, nil
|
||||||
default:
|
default:
|
||||||
return nil, errors.New(m.ErrorApprovalType)
|
return &Approval{}, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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",
|
|
||||||
}
|
|
||||||
|
118
pkg/model/approval_setting.go
Normal file
118
pkg/model/approval_setting.go
Normal file
@ -0,0 +1,118 @@
|
|||||||
|
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
|
||||||
|
IsViewed bool
|
||||||
|
}
|
||||||
|
|
||||||
|
type CopyUsers []CopyUser
|
||||||
|
|
||||||
|
type ApprovalUser struct {
|
||||||
|
ID uint64
|
||||||
|
Name string
|
||||||
|
}
|
||||||
|
|
||||||
|
type ApprovalUsers []ApprovalUser
|
||||||
|
|
||||||
|
// ApprovalSetting 部门抄送人设置
|
||||||
|
type ApprovalSetting 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"` // 更新时间
|
||||||
|
KeyWord string `gorm:"column:key_word" json:"keyWord"`
|
||||||
|
ApprovalUsers ApprovalUsers `gorm:"column:approval_users" json:"approvalUsers"`
|
||||||
|
CopyUsers CopyUsers `gorm:"column:copy_users" json:"copyUsers"`
|
||||||
|
Domain string `gorm:"column:domain" json:"domain"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName get sql table name.获取数据库表名
|
||||||
|
func (m *ApprovalSetting) TableName() string {
|
||||||
|
return "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 (j *ApprovalUsers) Scan(src interface{}) error {
|
||||||
|
return json.Unmarshal(src.([]byte), j)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (j ApprovalUsers) Value() (driver.Value, error) {
|
||||||
|
|
||||||
|
v, err := json.Marshal(j)
|
||||||
|
|
||||||
|
return string(v), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetApprovalSettingFromKeyWord(Domain, keyWord string) (setting *ApprovalSetting, err error) {
|
||||||
|
|
||||||
|
err = DB.Model(&ApprovalSetting{}).Where(&ApprovalSetting{KeyWord: keyWord, Domain: Domain}).First(&setting).Error
|
||||||
|
|
||||||
|
return setting, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
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 FormatApproveUsers(copyUsers []*approval.ApprovalUser) ApprovalUsers {
|
||||||
|
var res ApprovalUsers
|
||||||
|
|
||||||
|
// copyer
|
||||||
|
for _, copyUser := range copyUsers {
|
||||||
|
temp := ApprovalUser{
|
||||||
|
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,
|
||||||
|
IsViewed: copyUser.IsViewed,
|
||||||
|
}
|
||||||
|
|
||||||
|
res = append(res, temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
return res
|
||||||
|
}
|
22
pkg/model/approval_type.go
Normal file
22
pkg/model/approval_type.go
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"gorm.io/plugin/soft_delete"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ApprovalType 审批类型
|
||||||
|
type ApprovalType 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"` // 更新时间
|
||||||
|
KeyWord string `gorm:"column:key_word" json:"keyWord"` // 回复内容
|
||||||
|
Domain string `gorm:"column:domain" json:"domain"` // 回复内容
|
||||||
|
Title string `gorm:"column:title" json:"title"` // 回复内容
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName get sql table name.获取数据库表名
|
||||||
|
func (m *ApprovalType) TableName() string {
|
||||||
|
return "approval_type"
|
||||||
|
}
|
86
pkg/model/approval_workflow.go
Normal file
86
pkg/model/approval_workflow.go
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"errors"
|
||||||
|
"github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||||
|
"gorm.io/plugin/soft_delete"
|
||||||
|
"time"
|
||||||
|
)
|
||||||
|
|
||||||
|
// ApprovalWorkFlow 审批流
|
||||||
|
type ApprovalWorkFlow struct {
|
||||||
|
ID uint64 `gorm:"primaryKey;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"`
|
||||||
|
ApprovalID uint64 `gorm:"column:approval_id" json:"approvalId"`
|
||||||
|
UserId uint64 `gorm:"column:user_id" json:"userId"`
|
||||||
|
Name string `gorm:"column:name" json:"name"`
|
||||||
|
Level uint8 `gorm:"column:level" json:"Level"`
|
||||||
|
Status uint8 `gorm:"column:status" json:"Status"`
|
||||||
|
Reply string `gorm:"column:reply" json:"Reply"`
|
||||||
|
OperatedAt time.Time `gorm:"column:operated_at" json:"operatedAt"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetNowWorkFlowByApprovalId(approvalId uint64) (*ApprovalWorkFlow, error) {
|
||||||
|
var workFlow *ApprovalWorkFlow
|
||||||
|
|
||||||
|
if err := DB.Model(&ApprovalWorkFlow{ApprovalID: approvalId, Status: StatusDoing}).Order("level asc").First(&workFlow).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workFlow, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetWorkFlowByLevel(approvalId uint64, level uint8) (*ApprovalWorkFlow, error) {
|
||||||
|
var workFlow *ApprovalWorkFlow
|
||||||
|
|
||||||
|
if err := DB.Model(&ApprovalWorkFlow{ApprovalID: approvalId, Level: level}).First(&workFlow).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
return workFlow, nil
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func BatchSave(users ApprovalUsers, approvalId uint64) error {
|
||||||
|
var insertRaws []*ApprovalWorkFlow
|
||||||
|
|
||||||
|
if users == nil && len(users) == 0 {
|
||||||
|
return errors.New(m.ErrorNotFound)
|
||||||
|
}
|
||||||
|
|
||||||
|
for index, user := range users {
|
||||||
|
temp := &ApprovalWorkFlow{
|
||||||
|
UserId: user.ID,
|
||||||
|
Name: user.Name,
|
||||||
|
ApprovalID: approvalId,
|
||||||
|
Level: uint8(index + 1),
|
||||||
|
}
|
||||||
|
|
||||||
|
insertRaws = append(insertRaws, temp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return DB.Create(&insertRaws).Error
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApprovalWorkFlow) TableName() string {
|
||||||
|
return "approval_workflow"
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApprovalWorkFlow) Pass(replay string) error {
|
||||||
|
return m.SetStatus(StatusOk, replay)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApprovalWorkFlow) Refuse(replay string) error {
|
||||||
|
return m.SetStatus(StatusFail, replay)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (m *ApprovalWorkFlow) SetStatus(status uint8, reply string) error {
|
||||||
|
m.Status = status
|
||||||
|
m.Reply = reply
|
||||||
|
DB.Save(m)
|
||||||
|
return DB.Save(m).Error
|
||||||
|
}
|
@ -1,102 +0,0 @@
|
|||||||
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
|
|
||||||
IsViewed bool
|
|
||||||
}
|
|
||||||
|
|
||||||
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,
|
|
||||||
IsViewed: copyUser.IsViewed,
|
|
||||||
}
|
|
||||||
|
|
||||||
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",
|
|
||||||
}
|
|
@ -35,7 +35,7 @@ func (m *Show) UpdateApprovalContent(in *approval.CreateRequest, a *Approval) er
|
|||||||
|
|
||||||
var entity *Show
|
var entity *Show
|
||||||
|
|
||||||
if err := DB.Where(&Show{ApprovalID: a.ApproverID}).First(&entity).Error; err != nil {
|
if err := DB.Where(&Show{ApprovalID: a.ID}).First(&entity).Error; err != nil {
|
||||||
return errors.New(m2.ErrorNotFound)
|
return errors.New(m2.ErrorNotFound)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -207,20 +207,3 @@ func (m *Work) DeleteApproval(p *Approval) error {
|
|||||||
|
|
||||||
return DB.Where(&Work{ApprovalID: p.ID}).Delete(&Work{}).Error
|
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",
|
|
||||||
}
|
|
||||||
|
@ -11,7 +11,9 @@ func BuildApproval(entity *model.Approval, userId uint64) *approval.CreateReques
|
|||||||
var show *approval.Show
|
var show *approval.Show
|
||||||
var exhibition *approval.Exhibition
|
var exhibition *approval.Exhibition
|
||||||
var bundle *approval.Bundle
|
var bundle *approval.Bundle
|
||||||
|
var workFlows []*approval.WorkFlow
|
||||||
isViewed := false
|
isViewed := false
|
||||||
|
canApproval := false
|
||||||
|
|
||||||
copyUsers := model.FormatToResponse(entity.CopyUsers)
|
copyUsers := model.FormatToResponse(entity.CopyUsers)
|
||||||
|
|
||||||
@ -21,18 +23,36 @@ func BuildApproval(entity *model.Approval, userId uint64) *approval.CreateReques
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, tt := range entity.ApprovalWorkFlows {
|
||||||
|
temp := &approval.WorkFlow{
|
||||||
|
ID: tt.ID,
|
||||||
|
UserID: tt.UserId,
|
||||||
|
Name: tt.Name,
|
||||||
|
Level: uint64(tt.Level),
|
||||||
|
Status: uint64(tt.Status),
|
||||||
|
Reply: tt.Reply,
|
||||||
|
OperatedAt: entity.CreatedAt.Format("2006-01-02 15:04:05"),
|
||||||
|
}
|
||||||
|
workFlows = append(workFlows, temp)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if entity.Status == model.StatusDoing && entity.NowUserId == userId {
|
||||||
|
canApproval = true
|
||||||
|
}
|
||||||
|
|
||||||
response := &approval.CreateRequest{
|
response := &approval.CreateRequest{
|
||||||
ID: entity.ID,
|
ID: entity.ID,
|
||||||
Domain: *entity.Domain,
|
Domain: *entity.Domain,
|
||||||
Status: approval.StatusType(uint64(entity.Status)),
|
Status: approval.StatusType(uint64(entity.Status)),
|
||||||
Type: entity.Type,
|
Type: entity.Type,
|
||||||
ApproverID: entity.ApproverID,
|
|
||||||
ApproverName: entity.ApproverName,
|
|
||||||
CopyUsers: copyUsers,
|
CopyUsers: copyUsers,
|
||||||
SubmitterID: entity.SubmitterID,
|
SubmitterID: entity.SubmitterID,
|
||||||
SubmitterName: entity.SubmitterName,
|
SubmitterName: entity.SubmitterName,
|
||||||
Content: entity.Content,
|
Content: entity.Content,
|
||||||
IsViewed: isViewed,
|
IsViewed: isViewed,
|
||||||
|
CanApproval: canApproval,
|
||||||
|
WorkFlows: workFlows,
|
||||||
Reply: entity.Reply,
|
Reply: entity.Reply,
|
||||||
Work: work,
|
Work: work,
|
||||||
Show: show,
|
Show: show,
|
||||||
|
28
pkg/serializer/approval_type.go
Normal file
28
pkg/serializer/approval_type.go
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package serializer
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||||
|
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
//BuildType 处理单个detail返回
|
||||||
|
func BuildType(entity *model.ApprovalType) *approval.CreateTypeRequest {
|
||||||
|
|
||||||
|
response := &approval.CreateTypeRequest{
|
||||||
|
ID: entity.ID,
|
||||||
|
Domain: entity.Domain,
|
||||||
|
KeyWord: entity.KeyWord,
|
||||||
|
Title: entity.Title,
|
||||||
|
}
|
||||||
|
|
||||||
|
return response
|
||||||
|
}
|
||||||
|
|
||||||
|
func BuildTypes(entity []*model.ApprovalType) (details []*approval.CreateTypeRequest) {
|
||||||
|
|
||||||
|
for _, temp := range entity {
|
||||||
|
details = append(details, BuildType(temp))
|
||||||
|
}
|
||||||
|
|
||||||
|
return details
|
||||||
|
}
|
@ -6,8 +6,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
//BuildSetting 处理单个detail返回
|
//BuildSetting 处理单个detail返回
|
||||||
func BuildSetting(entity *model.DepartmentApprovalSetting) *approval.SettingRequest {
|
func BuildSetting(entity *model.ApprovalSetting) *approval.SettingRequest {
|
||||||
var copyUsers []*approval.CopyUser
|
var copyUsers []*approval.CopyUser
|
||||||
|
var approvalUser []*approval.ApprovalUser
|
||||||
|
|
||||||
for _, copyUser := range entity.CopyUsers {
|
for _, copyUser := range entity.CopyUsers {
|
||||||
temp := &approval.CopyUser{
|
temp := &approval.CopyUser{
|
||||||
@ -18,13 +19,21 @@ func BuildSetting(entity *model.DepartmentApprovalSetting) *approval.SettingRequ
|
|||||||
copyUsers = append(copyUsers, temp)
|
copyUsers = append(copyUsers, temp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, approvaUser := range entity.ApprovalUsers {
|
||||||
|
temp := &approval.ApprovalUser{
|
||||||
|
ID: approvaUser.ID,
|
||||||
|
Name: approvaUser.Name,
|
||||||
|
}
|
||||||
|
|
||||||
|
approvalUser = append(approvalUser, temp)
|
||||||
|
}
|
||||||
|
|
||||||
response := &approval.SettingRequest{
|
response := &approval.SettingRequest{
|
||||||
ID: entity.ID,
|
ID: entity.ID,
|
||||||
Domain: entity.Domain,
|
Domain: entity.Domain,
|
||||||
DepartmentID: entity.DepartmentID,
|
KeyWord: entity.KeyWord,
|
||||||
CopyUsers: copyUsers,
|
CopyUsers: copyUsers,
|
||||||
ApproverID: entity.ApproverID,
|
ApprovalUsers: approvalUser,
|
||||||
ApproverName: entity.ApproverName,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return response
|
return response
|
||||||
|
@ -38,10 +38,36 @@ func (a *ApprovalProvider) Update(ctx context.Context, in *approval.CreateReques
|
|||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) NowLevelByInfo(ctx context.Context, in *approval.NowLevelByInfoRequest) (*approval.WorkFlowResponse, error) {
|
||||||
|
|
||||||
|
response := &approval.WorkFlowResponse{}
|
||||||
|
var approvalObj *model.Approval
|
||||||
|
|
||||||
|
if err := model.DB.First(&approvalObj, in.ApprovalID).Error; err != nil {
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
|
||||||
|
workFlow, err1 := model.GetNowWorkFlowByApprovalId(approvalObj.ID)
|
||||||
|
|
||||||
|
if err1 != nil {
|
||||||
|
return response, err1
|
||||||
|
}
|
||||||
|
response.ID = workFlow.ID
|
||||||
|
response.Status = uint64(workFlow.Status)
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
func (a *ApprovalProvider) SetStatus(ctx context.Context, in *approval.StatusRequest) (*approval.StatusResponse, error) {
|
func (a *ApprovalProvider) SetStatus(ctx context.Context, in *approval.StatusRequest) (*approval.StatusResponse, error) {
|
||||||
|
|
||||||
response := &approval.StatusResponse{}
|
response := &approval.StatusResponse{}
|
||||||
|
|
||||||
var approvalObj *model.Approval
|
var approvalObj *model.Approval
|
||||||
|
var err error
|
||||||
|
|
||||||
|
if in.Status == model.StatusDoing {
|
||||||
|
return response, errors.New("status code wrong")
|
||||||
|
}
|
||||||
|
|
||||||
if err := model.DB.First(&approvalObj, in.ID).Error; err != nil {
|
if err := model.DB.First(&approvalObj, in.ID).Error; err != nil {
|
||||||
return response, err
|
return response, err
|
||||||
@ -51,8 +77,12 @@ func (a *ApprovalProvider) SetStatus(ctx context.Context, in *approval.StatusReq
|
|||||||
return response, errors.New(m.ErrorWrongStatus)
|
return response, errors.New(m.ErrorWrongStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
err := model.DB.Where(&model.Approval{ID: in.ID, Domain: &in.Domain}).
|
// 审批人审批内容
|
||||||
Updates(&model.Approval{Status: int8(in.Status), Reply: in.Replay}).Error
|
if in.Status == model.StatusFail {
|
||||||
|
err = approvalObj.Refuse(in.Reply, in.WorkFlowId)
|
||||||
|
} else {
|
||||||
|
err = approvalObj.Pass(in.Reply, in.WorkFlowId)
|
||||||
|
}
|
||||||
|
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
@ -105,6 +135,7 @@ func (a *ApprovalProvider) Detail(ctx context.Context, in *approval.DetailReques
|
|||||||
Preload("Work.ApprovalWorks").
|
Preload("Work.ApprovalWorks").
|
||||||
Preload("Bundle").
|
Preload("Bundle").
|
||||||
Preload("Exhibition.ApprovalExhibitions").
|
Preload("Exhibition.ApprovalExhibitions").
|
||||||
|
Preload("ApprovalWorkFlows").
|
||||||
First(&entity, in.ID).Error; err != nil {
|
First(&entity, in.ID).Error; err != nil {
|
||||||
return response, err
|
return response, err
|
||||||
}
|
}
|
||||||
@ -156,31 +187,35 @@ func (a *ApprovalProvider) UpdateSetting(ctx context.Context, in *approval.Setti
|
|||||||
|
|
||||||
var err error
|
var err error
|
||||||
response := &approval.SettingResponse{}
|
response := &approval.SettingResponse{}
|
||||||
var setting model.DepartmentApprovalSetting
|
var setting model.ApprovalSetting
|
||||||
copyUsers := model.FormatCopyUsers(in.CopyUsers)
|
copyUsers := model.FormatCopyUsers(in.CopyUsers)
|
||||||
|
approvalUsers := model.FormatApproveUsers(in.ApprovalUsers)
|
||||||
|
if approvalUsers == nil && len(approvalUsers) == 0 {
|
||||||
|
return response, errors.New("必须要有抄送人")
|
||||||
|
}
|
||||||
|
|
||||||
//首次
|
//首次
|
||||||
if err := model.DB.Model(&model.DepartmentApprovalSetting{}).
|
if err := model.DB.Model(&model.ApprovalSetting{}).
|
||||||
Where(&model.DepartmentApprovalSetting{Domain: in.Domain, DepartmentID: in.DepartmentID}).
|
Where(&model.ApprovalSetting{Domain: in.Domain, KeyWord: in.KeyWord}).
|
||||||
First(&setting).Error; err != nil {
|
First(&setting).Error; err != nil {
|
||||||
|
|
||||||
setting = model.DepartmentApprovalSetting{
|
setting = model.ApprovalSetting{
|
||||||
DepartmentID: in.DepartmentID,
|
KeyWord: in.KeyWord,
|
||||||
CopyUsers: copyUsers,
|
CopyUsers: copyUsers,
|
||||||
ApproverID: in.ApproverID,
|
ApprovalUsers: approvalUsers,
|
||||||
ApproverName: in.ApproverName,
|
|
||||||
Domain: in.Domain,
|
Domain: in.Domain,
|
||||||
}
|
}
|
||||||
|
|
||||||
err = model.DB.Save(&setting).Error
|
err = model.DB.Save(&setting).Error
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
setting.DepartmentID = in.DepartmentID
|
setting.KeyWord = in.KeyWord
|
||||||
setting.CopyUsers = copyUsers
|
setting.CopyUsers = copyUsers
|
||||||
setting.ApproverID = in.ApproverID
|
setting.ApprovalUsers = approvalUsers
|
||||||
setting.ApproverName = in.ApproverName
|
//setting.ApproverID = in.ApproverID
|
||||||
|
//setting.ApproverName = in.ApproverName
|
||||||
|
|
||||||
err = model.DB.Where(&model.DepartmentApprovalSetting{Domain: in.Domain, DepartmentID: in.DepartmentID}).Updates(&setting).Error
|
err = model.DB.Where(&model.ApprovalSetting{Domain: in.Domain, KeyWord: in.KeyWord}).Updates(&setting).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -194,10 +229,10 @@ func (a *ApprovalProvider) UpdateSetting(ctx context.Context, in *approval.Setti
|
|||||||
func (a *ApprovalProvider) DetailSetting(ctx context.Context, in *approval.DetailSettingRequest) (*approval.SettingRequest, error) {
|
func (a *ApprovalProvider) DetailSetting(ctx context.Context, in *approval.DetailSettingRequest) (*approval.SettingRequest, error) {
|
||||||
|
|
||||||
response := &approval.SettingRequest{}
|
response := &approval.SettingRequest{}
|
||||||
var setting model.DepartmentApprovalSetting
|
var setting model.ApprovalSetting
|
||||||
|
|
||||||
if err := model.DB.Model(&model.DepartmentApprovalSetting{}).
|
if err := model.DB.Model(&model.ApprovalSetting{}).
|
||||||
Where(&model.DepartmentApprovalSetting{Domain: in.Domain, DepartmentID: in.DepartmentID}).
|
Where(&model.ApprovalSetting{Domain: in.Domain, KeyWord: in.KeyWord}).
|
||||||
First(&setting).Error; err != nil {
|
First(&setting).Error; err != nil {
|
||||||
response.Domain = in.Domain
|
response.Domain = in.Domain
|
||||||
} else {
|
} else {
|
||||||
@ -206,3 +241,87 @@ func (a *ApprovalProvider) DetailSetting(ctx context.Context, in *approval.Detai
|
|||||||
|
|
||||||
return response, nil
|
return response, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) CreateType(ctx context.Context, in *approval.CreateTypeRequest) (*approval.TypeResponse, error) {
|
||||||
|
response := &approval.TypeResponse{}
|
||||||
|
|
||||||
|
typeObj := model.ApprovalType{
|
||||||
|
KeyWord: in.KeyWord,
|
||||||
|
Title: in.Title,
|
||||||
|
Domain: in.Domain,
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := model.DB.Create(&typeObj).Error; err != nil {
|
||||||
|
return response, err
|
||||||
|
}
|
||||||
|
response.ID = typeObj.ID
|
||||||
|
response.Domain = typeObj.Domain
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) DetailType(ctx context.Context, in *approval.TypeResponse) (*approval.CreateTypeRequest, error) {
|
||||||
|
response := &approval.CreateTypeRequest{}
|
||||||
|
var typeObj model.ApprovalType
|
||||||
|
|
||||||
|
if err := model.DB.First(&typeObj, in.ID).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response = serializer.BuildType(&typeObj)
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) UpdateType(ctx context.Context, in *approval.CreateTypeRequest) (*approval.TypeResponse, error) {
|
||||||
|
response := &approval.TypeResponse{}
|
||||||
|
var typeObj model.ApprovalType
|
||||||
|
|
||||||
|
if err := model.DB.First(&typeObj, in.ID).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
typeObj.Title = in.Title
|
||||||
|
typeObj.KeyWord = in.Title
|
||||||
|
|
||||||
|
if err := model.DB.Save(&typeObj).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.ID = in.ID
|
||||||
|
response.Domain = in.Domain
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) AllType(ctx context.Context, in *approval.CommonRequest) (*approval.AllTypeResponse, error) {
|
||||||
|
|
||||||
|
response := &approval.AllTypeResponse{}
|
||||||
|
var list []*model.ApprovalType
|
||||||
|
|
||||||
|
if err := model.DB.Where(&model.ApprovalType{Domain: in.Domain}).Find(&list).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
response.Data = serializer.BuildTypes(list)
|
||||||
|
|
||||||
|
response.Count = uint64(len(list))
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (a *ApprovalProvider) RemoveType(ctx context.Context, in *approval.TypeResponse) (*approval.TypeResponse, error) {
|
||||||
|
response := &approval.TypeResponse{}
|
||||||
|
var typeObj model.ApprovalType
|
||||||
|
|
||||||
|
if err := model.DB.First(&typeObj, in.ID).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := model.DB.Delete(&typeObj, in.ID).Error; err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
response.ID = in.ID
|
||||||
|
response.Domain = in.Domain
|
||||||
|
|
||||||
|
return response, nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user