新增画作可编辑状态检测

This commit is contained in:
徐俊杰 2023-03-01 08:34:45 +08:00
parent c8c093654d
commit b88c957a78
6 changed files with 674 additions and 259 deletions

View File

@ -20,6 +20,11 @@ type ArtistInfoArtworkProvider struct {
artistInfoLogic logic.ArtistInfoArtworkLogic
}
// 检查画作是否可编辑
func (a ArtistInfoArtworkProvider) CheckArtworkEditable(ctx context.Context, request *artistInfoArtwork.ArtworkUidRequest) (*artistInfoArtwork.CheckArtworkEditableResponse, error) {
return a.artistInfoLogic.CheckArtworkEditable(request)
}
func (a ArtistInfoArtworkProvider) UpdateArtworkAuditStatus(ctx context.Context, request *artistInfoArtwork.UpdateArtworkAuditStatusRequest) (*artistInfoArtwork.ArtworkCommonNoParams, error) {
return a.artistInfoLogic.UpdateArtworkAuditStatus(request)
}

View File

@ -156,3 +156,17 @@ func (a ArtistInfoArtworkLogic) UpdateArtworkAuditStatus(request *artistInfoArtw
err = dao.UpdateAuditStatus(request.ArtworkUid, request.AuditStatus, request.AuditMark, request.AuditMark2)
return
}
func (a ArtistInfoArtworkLogic) CheckArtworkEditable(request *artistInfoArtwork.ArtworkUidRequest) (res *artistInfoArtwork.CheckArtworkEditableResponse, err error) {
res = &artistInfoArtwork.CheckArtworkEditableResponse{
Editable: false,
}
lockDetail, err := dao.GetArtworkLockDetail(request.ArtworkUid)
if err != nil {
return nil, err
}
//如果画作为锁定状态 并且有锁定时间 并且状态不是已通过
if lockDetail.Status == 1 && lockDetail.LockTime != "" && lockDetail.AuditStatus != 2 {
res.Editable = true
}
return
}

File diff suppressed because it is too large Load Diff

View File

@ -137,6 +137,110 @@ var _ interface {
ErrorName() string
} = ArtworkCommonNoParamsValidationError{}
// Validate checks the field values on ArtworkUidRequest with the rules defined
// in the proto definition for this message. If any rules are violated, the
// first error encountered is returned, or nil if there are no violations.
func (m *ArtworkUidRequest) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on ArtworkUidRequest with the rules
// defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// ArtworkUidRequestMultiError, or nil if none found.
func (m *ArtworkUidRequest) ValidateAll() error {
return m.validate(true)
}
func (m *ArtworkUidRequest) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for ArtworkUid
if len(errors) > 0 {
return ArtworkUidRequestMultiError(errors)
}
return nil
}
// ArtworkUidRequestMultiError is an error wrapping multiple validation errors
// returned by ArtworkUidRequest.ValidateAll() if the designated constraints
// aren't met.
type ArtworkUidRequestMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m ArtworkUidRequestMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m ArtworkUidRequestMultiError) AllErrors() []error { return m }
// ArtworkUidRequestValidationError is the validation error returned by
// ArtworkUidRequest.Validate if the designated constraints aren't met.
type ArtworkUidRequestValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e ArtworkUidRequestValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e ArtworkUidRequestValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e ArtworkUidRequestValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e ArtworkUidRequestValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e ArtworkUidRequestValidationError) ErrorName() string {
return "ArtworkUidRequestValidationError"
}
// Error satisfies the builtin error interface
func (e ArtworkUidRequestValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sArtworkUidRequest.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = ArtworkUidRequestValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = ArtworkUidRequestValidationError{}
// Validate checks the field values on CreateArtworkLockRecordReq with the
// rules defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
@ -1647,3 +1751,108 @@ var _ interface {
Cause() error
ErrorName() string
} = UpdateArtworkAuditStatusRequestValidationError{}
// Validate checks the field values on CheckArtworkEditableResponse with the
// rules defined in the proto definition for this message. If any rules are
// violated, the first error encountered is returned, or nil if there are no violations.
func (m *CheckArtworkEditableResponse) Validate() error {
return m.validate(false)
}
// ValidateAll checks the field values on CheckArtworkEditableResponse with the
// rules defined in the proto definition for this message. If any rules are
// violated, the result is a list of violation errors wrapped in
// CheckArtworkEditableResponseMultiError, or nil if none found.
func (m *CheckArtworkEditableResponse) ValidateAll() error {
return m.validate(true)
}
func (m *CheckArtworkEditableResponse) validate(all bool) error {
if m == nil {
return nil
}
var errors []error
// no validation rules for Editable
if len(errors) > 0 {
return CheckArtworkEditableResponseMultiError(errors)
}
return nil
}
// CheckArtworkEditableResponseMultiError is an error wrapping multiple
// validation errors returned by CheckArtworkEditableResponse.ValidateAll() if
// the designated constraints aren't met.
type CheckArtworkEditableResponseMultiError []error
// Error returns a concatenation of all the error messages it wraps.
func (m CheckArtworkEditableResponseMultiError) Error() string {
var msgs []string
for _, err := range m {
msgs = append(msgs, err.Error())
}
return strings.Join(msgs, "; ")
}
// AllErrors returns a list of validation violation errors.
func (m CheckArtworkEditableResponseMultiError) AllErrors() []error { return m }
// CheckArtworkEditableResponseValidationError is the validation error returned
// by CheckArtworkEditableResponse.Validate if the designated constraints
// aren't met.
type CheckArtworkEditableResponseValidationError struct {
field string
reason string
cause error
key bool
}
// Field function returns field value.
func (e CheckArtworkEditableResponseValidationError) Field() string { return e.field }
// Reason function returns reason value.
func (e CheckArtworkEditableResponseValidationError) Reason() string { return e.reason }
// Cause function returns cause value.
func (e CheckArtworkEditableResponseValidationError) Cause() error { return e.cause }
// Key function returns key value.
func (e CheckArtworkEditableResponseValidationError) Key() bool { return e.key }
// ErrorName returns error name.
func (e CheckArtworkEditableResponseValidationError) ErrorName() string {
return "CheckArtworkEditableResponseValidationError"
}
// Error satisfies the builtin error interface
func (e CheckArtworkEditableResponseValidationError) Error() string {
cause := ""
if e.cause != nil {
cause = fmt.Sprintf(" | caused by: %v", e.cause)
}
key := ""
if e.key {
key = "key for "
}
return fmt.Sprintf(
"invalid %sCheckArtworkEditableResponse.%s: %s%s",
key,
e.field,
e.reason,
cause)
}
var _ error = CheckArtworkEditableResponseValidationError{}
var _ interface {
Field() string
Reason() string
Key() bool
Cause() error
ErrorName() string
} = CheckArtworkEditableResponseValidationError{}

View File

@ -36,6 +36,7 @@ type ArtistInfoArtworkClient interface {
DeleteArtworkRecord(ctx context.Context, in *DeleteArtworkRecordRequest, opts ...grpc_go.CallOption) (*ArtworkCommonNoParams, common.ErrorWithAttachment)
GetArtworkLockDetail(ctx context.Context, in *GetArtworkLockDetailRequest, opts ...grpc_go.CallOption) (*ArtistLockInfo, common.ErrorWithAttachment)
UpdateArtworkAuditStatus(ctx context.Context, in *UpdateArtworkAuditStatusRequest, opts ...grpc_go.CallOption) (*ArtworkCommonNoParams, common.ErrorWithAttachment)
CheckArtworkEditable(ctx context.Context, in *ArtworkUidRequest, opts ...grpc_go.CallOption) (*CheckArtworkEditableResponse, common.ErrorWithAttachment)
}
type artistInfoArtworkClient struct {
@ -50,6 +51,7 @@ type ArtistInfoArtworkClientImpl struct {
DeleteArtworkRecord func(ctx context.Context, in *DeleteArtworkRecordRequest) (*ArtworkCommonNoParams, error)
GetArtworkLockDetail func(ctx context.Context, in *GetArtworkLockDetailRequest) (*ArtistLockInfo, error)
UpdateArtworkAuditStatus func(ctx context.Context, in *UpdateArtworkAuditStatusRequest) (*ArtworkCommonNoParams, error)
CheckArtworkEditable func(ctx context.Context, in *ArtworkUidRequest) (*CheckArtworkEditableResponse, error)
}
func (c *ArtistInfoArtworkClientImpl) GetDubboStub(cc *triple.TripleConn) ArtistInfoArtworkClient {
@ -106,6 +108,12 @@ func (c *artistInfoArtworkClient) UpdateArtworkAuditStatus(ctx context.Context,
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateArtworkAuditStatus", in, out)
}
func (c *artistInfoArtworkClient) CheckArtworkEditable(ctx context.Context, in *ArtworkUidRequest, opts ...grpc_go.CallOption) (*CheckArtworkEditableResponse, common.ErrorWithAttachment) {
out := new(CheckArtworkEditableResponse)
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/CheckArtworkEditable", in, out)
}
// ArtistInfoArtworkServer is the server API for ArtistInfoArtwork service.
// All implementations must embed UnimplementedArtistInfoArtworkServer
// for forward compatibility
@ -118,6 +126,7 @@ type ArtistInfoArtworkServer interface {
DeleteArtworkRecord(context.Context, *DeleteArtworkRecordRequest) (*ArtworkCommonNoParams, error)
GetArtworkLockDetail(context.Context, *GetArtworkLockDetailRequest) (*ArtistLockInfo, error)
UpdateArtworkAuditStatus(context.Context, *UpdateArtworkAuditStatusRequest) (*ArtworkCommonNoParams, error)
CheckArtworkEditable(context.Context, *ArtworkUidRequest) (*CheckArtworkEditableResponse, error)
mustEmbedUnimplementedArtistInfoArtworkServer()
}
@ -147,6 +156,9 @@ func (UnimplementedArtistInfoArtworkServer) GetArtworkLockDetail(context.Context
func (UnimplementedArtistInfoArtworkServer) UpdateArtworkAuditStatus(context.Context, *UpdateArtworkAuditStatusRequest) (*ArtworkCommonNoParams, error) {
return nil, status.Errorf(codes.Unimplemented, "method UpdateArtworkAuditStatus not implemented")
}
func (UnimplementedArtistInfoArtworkServer) CheckArtworkEditable(context.Context, *ArtworkUidRequest) (*CheckArtworkEditableResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method CheckArtworkEditable not implemented")
}
func (s *UnimplementedArtistInfoArtworkServer) XXX_SetProxyImpl(impl protocol.Invoker) {
s.proxyImpl = impl
}
@ -378,6 +390,35 @@ func _ArtistInfoArtwork_UpdateArtworkAuditStatus_Handler(srv interface{}, ctx co
return interceptor(ctx, in, info, handler)
}
func _ArtistInfoArtwork_CheckArtworkEditable_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
in := new(ArtworkUidRequest)
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("CheckArtworkEditable", 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)
}
// ArtistInfoArtwork_ServiceDesc is the grpc_go.ServiceDesc for ArtistInfoArtwork service.
// It's only intended for direct use with grpc_go.RegisterService,
// and not to be introspected or modified (even as a copy)
@ -413,6 +454,10 @@ var ArtistInfoArtwork_ServiceDesc = grpc_go.ServiceDesc{
MethodName: "UpdateArtworkAuditStatus",
Handler: _ArtistInfoArtwork_UpdateArtworkAuditStatus_Handler,
},
{
MethodName: "CheckArtworkEditable",
Handler: _ArtistInfoArtwork_CheckArtworkEditable_Handler,
},
},
Streams: []grpc_go.StreamDesc{},
Metadata: "pb/artistinfoArtwork.proto",

View File

@ -5,6 +5,7 @@ option go_package = "./;artistInfoArtwork";
import "validate.proto";
import public "google/protobuf/timestamp.proto";
// protoc -I . -I ./pb --proto_path=. --go_out=./pb/artistInfoArtwork --go-triple_out=./pb/artistInfoArtwork --validate_out="lang=go:./pb/artistInfoArtwork" ./pb/artistinfoArtwork.proto
service ArtistInfoArtwork {
//
rpc CreateArtworkLockRecord(CreateArtworkLockRecordReq)returns(ArtworkCommonNoParams){} //
@ -14,10 +15,13 @@ service ArtistInfoArtwork {
rpc DeleteArtworkRecord(DeleteArtworkRecordRequest)returns(ArtworkCommonNoParams){} //
rpc GetArtworkLockDetail(GetArtworkLockDetailRequest)returns(ArtistLockInfo){}//
rpc UpdateArtworkAuditStatus(UpdateArtworkAuditStatusRequest)returns(ArtworkCommonNoParams){}//
rpc CheckArtworkEditable(ArtworkUidRequest)returns(CheckArtworkEditableResponse){}//
}
message ArtworkCommonNoParams{}
message ArtworkUidRequest{
string ArtworkUid =1;
}
message CreateArtworkLockRecordReq{
string artistUid=1 [(validate.rules).message.required = true];//uid
string artworkUid=2 [(validate.rules).message.required = true];//uid
@ -70,7 +74,7 @@ message GetArtworkLockHistoryRequest{
string artistUid=1;
}
message GetArtworkLockDetailRequest{
string artworkUid=1 [(validate.rules).message.required = true];//uid;
string artworkUid=1 [(validate.rules).message.required = true];//uid;
}
//----
message ArtworkPreviewInfo {
@ -104,4 +108,7 @@ message UpdateArtworkAuditStatusRequest{
int64 auditStatus=5;
string auditMark=6;
string auditMark2=7;
}
message CheckArtworkEditableResponse{
bool editable =1;
}