feat
This commit is contained in:
parent
19d959db92
commit
b0b568a038
File diff suppressed because it is too large
Load Diff
@ -22,6 +22,8 @@ service Approval {
|
||||
rpc SetStatus(StatusRequest) returns (StatusResponse) {};
|
||||
rpc DetailSetting(DetailSettingRequest) returns (SettingRequest) {};
|
||||
rpc UpdateSetting(SettingRequest) returns (SettingResponse) {};
|
||||
rpc IsExistPayRight(IsExistPayRightRequest) returns (IsExistPayRightResponse) {};//是否有
|
||||
rpc ChangeBundlePay(ChangeBundlePayRequest) returns (CommonResponse) {};//是否有
|
||||
|
||||
rpc CreateType(CreateTypeRequest) returns (TypeResponse) {};
|
||||
rpc DetailType(TypeResponse) returns (CreateTypeRequest) {};
|
||||
@ -31,11 +33,32 @@ service Approval {
|
||||
rpc AllGroup(CommonRequest) returns (AllGroupResponse) {};
|
||||
}
|
||||
|
||||
message CommonResponse {
|
||||
|
||||
}
|
||||
|
||||
message ChangeBundlePayRequest {
|
||||
string Domain = 1 [json_name = "domain"];
|
||||
uint64 ID = 2 [json_name = "ID"];
|
||||
uint64 Status = 3 [json_name = "Status"];
|
||||
}
|
||||
|
||||
message IsExistPayRightRequest {
|
||||
string Domain = 1 [json_name = "domain"];
|
||||
uint64 UserId = 2 [json_name = "userId"];
|
||||
string ShowUid = 3 [json_name = "showUid"];
|
||||
}
|
||||
|
||||
message IsExistPayRightResponse {
|
||||
bool IsPass = 1 [json_name = "isPass"];
|
||||
}
|
||||
|
||||
message KeyInfo {
|
||||
string ApprovalKey = 1 [json_name = "approvalKey"];
|
||||
string ApprovalName = 2 [json_name = "approvalName"];
|
||||
string ApprovalType = 3 [json_name = "approvalType"];
|
||||
string ApprovalValue = 4 [json_name = "approvalValue"];
|
||||
bool ApprovalMark = 5 [json_name = "approvalMark"];
|
||||
}
|
||||
|
||||
message UpdateEhApplyIDRequest {
|
||||
@ -90,6 +113,7 @@ message CreateTypeRequest {
|
||||
message TypeResponse {
|
||||
uint64 ID = 1;
|
||||
string Domain = 2;
|
||||
string Keyword = 3;
|
||||
}
|
||||
|
||||
message AllTypeResponse {
|
||||
@ -129,6 +153,7 @@ message ListRequest {
|
||||
uint64 Status = 4 [json_name = "status"];//0待审批 1-审批成功 2-拒绝 4-是所有
|
||||
string Type = 5 [json_name = "type"]; //类型
|
||||
uint64 UserID = 6 [json_name = "userID"]; //
|
||||
uint64 ApprovedBossId = 7 [json_name = "approvedBossId"]; //
|
||||
}
|
||||
|
||||
message ListResponse {
|
||||
@ -219,6 +244,20 @@ message Exhibition {
|
||||
string ApplyID = 7 [json_name = "applyID"];
|
||||
}
|
||||
|
||||
message BundlePayPrice {
|
||||
string ShowUid = 1 [json_name = "showUid"];
|
||||
uint64 ApprovalID = 2 [json_name = "approvalID"];
|
||||
string ShowName = 3 [json_name = "showName"];
|
||||
string ReceivedAt = 4 [json_name = "receivedAt"];
|
||||
string ShowDate = 5 [json_name = "showDate"];
|
||||
string ShowLowPrice= 6 [json_name = "showLowPrice"];
|
||||
uint64 ArtworkNum = 7 [json_name = "artworkNum"];
|
||||
string ArtworkSize = 8 [json_name = "artworkSize"];
|
||||
string ShowAddress = 9 [json_name = "showAddress"];
|
||||
uint64 ID = 10 [json_name = "ID"];
|
||||
uint64 Status = 11 [json_name = "Status"];
|
||||
}
|
||||
|
||||
message CreateRequest {
|
||||
uint64 ID = 1 [json_name = "ID"];
|
||||
string Domain = 2 [json_name = "domain",(validator.field) = {string_not_empty: true,human_error: "70001"} ];
|
||||
@ -245,6 +284,9 @@ message CreateRequest {
|
||||
string CreatedAt = 25 [json_name = "createdAt"];
|
||||
repeated KeyInfo CustomizeInfo = 26 [json_name = "customizeInfo"];
|
||||
uint64 IsCustom = 27 [json_name = "isCustom"];
|
||||
string TypeName = 28 [json_name = "typeName"];
|
||||
string GroupName = 29 [json_name = "groupName"];
|
||||
BundlePayPrice BundlePayPrice = 30 [json_name = "bundlePayPrice"];
|
||||
}
|
||||
|
||||
message WorkFlow {
|
||||
|
@ -16,6 +16,18 @@ var _ = proto.Marshal
|
||||
var _ = fmt.Errorf
|
||||
var _ = math.Inf
|
||||
|
||||
func (this *CommonResponse) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *ChangeBundlePayRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *IsExistPayRightRequest) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *IsExistPayRightResponse) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *KeyInfo) Validate() error {
|
||||
return nil
|
||||
}
|
||||
@ -170,6 +182,9 @@ func (this *Exhibition) Validate() error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *BundlePayPrice) Validate() error {
|
||||
return nil
|
||||
}
|
||||
func (this *CreateRequest) Validate() error {
|
||||
if this.Domain == "" {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("Domain", fmt.Errorf(`70001`))
|
||||
@ -225,6 +240,11 @@ func (this *CreateRequest) Validate() error {
|
||||
}
|
||||
}
|
||||
}
|
||||
if this.BundlePayPrice != nil {
|
||||
if err := github_com_mwitkow_go_proto_validators.CallValidatorIfExists(this.BundlePayPrice); err != nil {
|
||||
return github_com_mwitkow_go_proto_validators.FieldError("BundlePayPrice", err)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (this *WorkFlow) Validate() error {
|
||||
|
@ -42,6 +42,8 @@ type ApprovalClient interface {
|
||||
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)
|
||||
UpdateSetting(ctx context.Context, in *SettingRequest, opts ...grpc_go.CallOption) (*SettingResponse, common.ErrorWithAttachment)
|
||||
IsExistPayRight(ctx context.Context, in *IsExistPayRightRequest, opts ...grpc_go.CallOption) (*IsExistPayRightResponse, common.ErrorWithAttachment)
|
||||
ChangeBundlePay(ctx context.Context, in *ChangeBundlePayRequest, opts ...grpc_go.CallOption) (*CommonResponse, 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)
|
||||
@ -69,6 +71,8 @@ type ApprovalClientImpl struct {
|
||||
SetStatus func(ctx context.Context, in *StatusRequest) (*StatusResponse, error)
|
||||
DetailSetting func(ctx context.Context, in *DetailSettingRequest) (*SettingRequest, error)
|
||||
UpdateSetting func(ctx context.Context, in *SettingRequest) (*SettingResponse, error)
|
||||
IsExistPayRight func(ctx context.Context, in *IsExistPayRightRequest) (*IsExistPayRightResponse, error)
|
||||
ChangeBundlePay func(ctx context.Context, in *ChangeBundlePayRequest) (*CommonResponse, 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)
|
||||
@ -173,6 +177,18 @@ func (c *approvalClient) UpdateSetting(ctx context.Context, in *SettingRequest,
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/UpdateSetting", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) IsExistPayRight(ctx context.Context, in *IsExistPayRightRequest, opts ...grpc_go.CallOption) (*IsExistPayRightResponse, common.ErrorWithAttachment) {
|
||||
out := new(IsExistPayRightResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/IsExistPayRight", in, out)
|
||||
}
|
||||
|
||||
func (c *approvalClient) ChangeBundlePay(ctx context.Context, in *ChangeBundlePayRequest, opts ...grpc_go.CallOption) (*CommonResponse, common.ErrorWithAttachment) {
|
||||
out := new(CommonResponse)
|
||||
interfaceKey := ctx.Value(constant.InterfaceKey).(string)
|
||||
return out, c.cc.Invoke(ctx, "/"+interfaceKey+"/ChangeBundlePay", 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)
|
||||
@ -227,6 +243,8 @@ type ApprovalServer interface {
|
||||
SetStatus(context.Context, *StatusRequest) (*StatusResponse, error)
|
||||
DetailSetting(context.Context, *DetailSettingRequest) (*SettingRequest, error)
|
||||
UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error)
|
||||
IsExistPayRight(context.Context, *IsExistPayRightRequest) (*IsExistPayRightResponse, error)
|
||||
ChangeBundlePay(context.Context, *ChangeBundlePayRequest) (*CommonResponse, error)
|
||||
CreateType(context.Context, *CreateTypeRequest) (*TypeResponse, error)
|
||||
DetailType(context.Context, *TypeResponse) (*CreateTypeRequest, error)
|
||||
UpdateType(context.Context, *CreateTypeRequest) (*TypeResponse, error)
|
||||
@ -283,6 +301,12 @@ func (UnimplementedApprovalServer) DetailSetting(context.Context, *DetailSetting
|
||||
func (UnimplementedApprovalServer) UpdateSetting(context.Context, *SettingRequest) (*SettingResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method UpdateSetting not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) IsExistPayRight(context.Context, *IsExistPayRightRequest) (*IsExistPayRightResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method IsExistPayRight not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) ChangeBundlePay(context.Context, *ChangeBundlePayRequest) (*CommonResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method ChangeBundlePay not implemented")
|
||||
}
|
||||
func (UnimplementedApprovalServer) CreateType(context.Context, *CreateTypeRequest) (*TypeResponse, error) {
|
||||
return nil, status.Errorf(codes.Unimplemented, "method CreateType not implemented")
|
||||
}
|
||||
@ -735,6 +759,64 @@ func _Approval_UpdateSetting_Handler(srv interface{}, ctx context.Context, dec f
|
||||
return interceptor(ctx, in, info, handler)
|
||||
}
|
||||
|
||||
func _Approval_IsExistPayRight_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(IsExistPayRightRequest)
|
||||
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("IsExistPayRight", 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_ChangeBundlePay_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc_go.UnaryServerInterceptor) (interface{}, error) {
|
||||
in := new(ChangeBundlePayRequest)
|
||||
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("ChangeBundlePay", 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_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 {
|
||||
@ -972,6 +1054,14 @@ var Approval_ServiceDesc = grpc_go.ServiceDesc{
|
||||
MethodName: "UpdateSetting",
|
||||
Handler: _Approval_UpdateSetting_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "IsExistPayRight",
|
||||
Handler: _Approval_IsExistPayRight_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "ChangeBundlePay",
|
||||
Handler: _Approval_ChangeBundlePay_Handler,
|
||||
},
|
||||
{
|
||||
MethodName: "CreateType",
|
||||
Handler: _Approval_CreateType_Handler,
|
||||
|
17
docs/env/prod/conf.ini
vendored
17
docs/env/prod/conf.ini
vendored
@ -2,15 +2,16 @@
|
||||
mode = prod #正式prod #测试dev
|
||||
|
||||
[mysql]
|
||||
Db = mysql
|
||||
DbHost = mysql
|
||||
DbPort = 3306
|
||||
DbUser = fonchain
|
||||
DbPassWord = C250PflXIWv2SQm
|
||||
DbName = fontree-approval
|
||||
Db="mysql"
|
||||
DbHost="172.16.100.30"
|
||||
DbPort="3306"
|
||||
DbUser="root"
|
||||
DbPassWord="IhQmhg8HZjDmU=Ove5PnA^D"
|
||||
DbName="fontree-approval"
|
||||
|
||||
[redis]
|
||||
RedisDB =
|
||||
RedisAddr = 172.16.100.22:6379
|
||||
RedisPW =
|
||||
RedisAddr = "172.16.100.114:6379"
|
||||
RedisPW = "kP6tW4tS3qB2dW4aE6uI5cX2"
|
||||
RedisDBNAme =
|
||||
|
||||
|
4
go.mod
4
go.mod
@ -9,9 +9,7 @@ require (
|
||||
github.com/gin-gonic/gin v1.8.1
|
||||
github.com/golang/protobuf v1.5.2
|
||||
github.com/mwitkow/go-proto-validators v0.3.2
|
||||
github.com/natefinch/lumberjack v2.0.0+incompatible
|
||||
github.com/pkg/errors v0.9.1
|
||||
go.uber.org/zap v1.21.0
|
||||
google.golang.org/protobuf v1.28.0
|
||||
gopkg.in/ini.v1 v1.66.6
|
||||
gorm.io/driver/mysql v1.3.5
|
||||
@ -94,6 +92,7 @@ require (
|
||||
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
|
||||
@ -130,6 +129,7 @@ require (
|
||||
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
|
||||
|
@ -18,6 +18,7 @@ type KeyInfo struct {
|
||||
ApprovalName string
|
||||
ApprovalType string
|
||||
ApprovalValue string
|
||||
ApprovalMark bool
|
||||
}
|
||||
type KeyInfos []KeyInfo
|
||||
|
||||
@ -42,9 +43,11 @@ type Approval struct {
|
||||
Reply string `gorm:"column:reply" json:"reply"`
|
||||
Domain *string `gorm:"column:domain" json:"domain"`
|
||||
Show *Show `gorm:"foreignKey:ApprovalID" json:"Show"`
|
||||
ApprovalType *ApprovalType `gorm:"foreignKey:KeyWord;references:Type" json:"approvalType"` // type类型
|
||||
Work *Work `gorm:"foreignKey:ApprovalID" json:"Work"`
|
||||
Bundle *Bundle `gorm:"foreignKey:ApprovalID" json:"Bundle"`
|
||||
Exhibition *Exhibition `gorm:"foreignKey:ApprovalID" json:"Exhibition"`
|
||||
BundlePayPrice *BundlePayPrice `gorm:"foreignKey:ApprovalID" json:"BundlePayPrice"` //关联的type
|
||||
ApprovalWorkFlows []*ApprovalWorkFlow `gorm:"foreignKey:ApprovalID" json:"ApprovalWorkFlows"`
|
||||
}
|
||||
|
||||
@ -60,11 +63,12 @@ func (j KeyInfos) Value() (driver.Value, error) {
|
||||
}
|
||||
|
||||
const (
|
||||
TypeContent = "content"
|
||||
TypeWork = "work"
|
||||
TypeExhibition = "exhibition"
|
||||
TypeShow = "show"
|
||||
TypeBundle = "bundle"
|
||||
TypeContent = "content"
|
||||
TypeWork = "work"
|
||||
TypeExhibition = "exhibition"
|
||||
TypeShow = "show"
|
||||
TypeBundle = "bundle"
|
||||
TypeBundlePayPrice = "bundlePayPrice"
|
||||
)
|
||||
const (
|
||||
StatusDoing = 1
|
||||
@ -192,6 +196,7 @@ func StoreApproval(in *approval.CreateRequest) (*Approval, error) {
|
||||
}
|
||||
|
||||
fmt.Println(3)
|
||||
fmt.Println(entity)
|
||||
if err := DB.Create(&entity).Error; err != nil {
|
||||
return err
|
||||
}
|
||||
@ -320,6 +325,33 @@ func approvalCalc(filter *Approval) *approval.Information {
|
||||
return info
|
||||
}
|
||||
|
||||
func approvalCalcJsonV2(domain string, userId uint64) *approval.Information {
|
||||
|
||||
var num int64
|
||||
var jsonStr = "json_contains(approval_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: StatusDoing, Domain: &domain, NowUserId: userId}).Count(&num)
|
||||
info.DoingTotal = uint64(num)
|
||||
|
||||
DB.Model(&Approval{}).Where(jsonStr, userId).Where(&Approval{Status: StatusOk, Domain: &domain, NowUserId: userId}).Count(&num)
|
||||
info.SuccessTotal = uint64(num)
|
||||
|
||||
DB.Model(&Approval{}).Where(jsonStr, userId).Where(&Approval{Status: StatusFail, Domain: &domain, NowUserId: userId}).Count(&num)
|
||||
info.FailTotal = uint64(num)
|
||||
|
||||
return info
|
||||
}
|
||||
|
||||
func approvalCalcJson(domain string, userId uint64) *approval.Information {
|
||||
|
||||
var num int64
|
||||
@ -352,7 +384,7 @@ func ApprovalInfo(in *approval.InformationRequest) (*approval.InformationRespons
|
||||
|
||||
response := &approval.InformationResponse{
|
||||
MySubmitInfo: approvalCalc(&Approval{Domain: &in.Domain, SubmitterID: in.UserID}),
|
||||
SubmitMeInfo: approvalCalcJson(in.Domain, in.UserID),
|
||||
SubmitMeInfo: approvalCalcJsonV2(in.Domain, in.UserID),
|
||||
DomainInfo: approvalCalc(&Approval{Domain: &in.Domain}),
|
||||
}
|
||||
|
||||
@ -433,6 +465,7 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
||||
Preload("Show").
|
||||
Preload("Work.ApprovalWorks").
|
||||
Preload("Bundle").
|
||||
Preload("ApprovalType.ApprovalTypeGroup").
|
||||
Preload("ApprovalWorkFlows").
|
||||
Preload("Exhibition.ApprovalExhibitions")
|
||||
|
||||
@ -455,6 +488,17 @@ func MyWorkApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
||||
Or(DB.Where("JSON_CONTAINS(copy_users,JSON_OBJECT('ID', ?))", in.UserID).Where("status = ?", StatusOk))) //抄送人(完成抄送)
|
||||
}
|
||||
|
||||
if in.ApprovedBossId != 0 {
|
||||
|
||||
fmt.Println("---------1--------查看我已经审批过的")
|
||||
subQuery2 := DB.Model(&ApprovalWorkFlow{}).
|
||||
Where("status in (?)", []uint8{StatusOk, StatusFail}).
|
||||
Where(&ApprovalWorkFlow{UserId: in.ApprovedBossId}).
|
||||
Select("approval_id")
|
||||
|
||||
modelObj = modelObj.Where("id in (?)", subQuery2)
|
||||
}
|
||||
|
||||
if in.Status != 0 {
|
||||
modelObj = modelObj.Where(&Approval{Status: int8(in.Status)})
|
||||
}
|
||||
@ -476,6 +520,7 @@ func MySubmitApprovals(in *approval.ListRequest) ([]*Approval, int64) {
|
||||
Preload("Work.ApprovalWorks").
|
||||
Preload("Bundle").
|
||||
Preload("ApprovalWorkFlows").
|
||||
Preload("ApprovalType.ApprovalTypeGroup").
|
||||
Preload("Exhibition.ApprovalExhibitions")
|
||||
|
||||
if in.Status != 0 {
|
||||
@ -562,6 +607,8 @@ func getApprovalContentFactory(typeFiled string) (ApprovalContentInterface, erro
|
||||
return &Bundle{}, nil
|
||||
case TypeExhibition:
|
||||
return &Exhibition{}, nil
|
||||
case TypeBundlePayPrice:
|
||||
return &BundlePayPrice{}, nil
|
||||
default:
|
||||
return &Approval{}, nil
|
||||
}
|
||||
|
@ -40,11 +40,12 @@ var TypeMap = map[string]string{
|
||||
}
|
||||
|
||||
var keyWordMap = map[string]string{
|
||||
"普通审批": "content",
|
||||
"画作申请审批": "work",
|
||||
"画展包审批": "exhibition",
|
||||
"画展包数量审批": "bundle",
|
||||
"画展审批": "show",
|
||||
"普通审批": "content",
|
||||
"画作申请审批": "work",
|
||||
"画展包审批": "exhibition",
|
||||
"画展包数量审批": "bundle",
|
||||
"画展审批": "show",
|
||||
"画展包付款单申请": TypeBundlePayPrice,
|
||||
}
|
||||
|
||||
func DataExist(domain, keyWork, title string) bool {
|
||||
@ -74,6 +75,7 @@ func ToKeyInfos(infos []*approval.KeyInfo) KeyInfos {
|
||||
ApprovalName: t.ApprovalName,
|
||||
ApprovalType: t.ApprovalType,
|
||||
ApprovalValue: t.ApprovalValue,
|
||||
ApprovalMark: t.ApprovalMark,
|
||||
}
|
||||
|
||||
if temp.ApprovalKey == "" {
|
||||
|
91
pkg/model/bundle_pay_price.go
Normal file
91
pkg/model/bundle_pay_price.go
Normal file
@ -0,0 +1,91 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
m2 "github.com/fonchain_enterprise/fonchain-approval/pkg/m"
|
||||
"gorm.io/plugin/soft_delete"
|
||||
"time"
|
||||
)
|
||||
|
||||
// BundlePayPrice 画展包付款单审批
|
||||
type BundlePayPrice 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"` // 更新时间
|
||||
ApprovalID uint64 `gorm:"type:int(11);column:approval_id;default:0;comment:画展的uid" json:"approvalId"`
|
||||
ShowUid string `gorm:"type:varchar(32);column:show_uid;default:'';comment:画展的uid" json:"showUid"`
|
||||
ShowName string `gorm:"type:varchar(32);column:show_name;default:'';comment:画展的名称" json:"showName"`
|
||||
ReceivedAt string `gorm:"type:varchar(32);column:received_at;default:'';comment:领取时间" json:"receivedAt"` // 领取时间
|
||||
ShowDate string `gorm:"type:varchar(32);column:show_date;default:'';comment:画展时间" json:"showDate"`
|
||||
ShowLowPrice string `gorm:"type:varchar(32);column:show_low_price;default:'';comment:画展宝低价" json:"showLowPrice"`
|
||||
ArtworkNum uint64 `gorm:"type:int(11);column:artworkNum;default:0;comment:作品数量" json:"artworkNum"`
|
||||
ArtworkSize string `gorm:"type:varchar(32);column:artwork_size;default:'';comment:作品总平尺" json:"artworkSize"`
|
||||
ShowAddress string `gorm:"type:varchar(32);column:show_address;default:'';comment:画展地址" json:"showAddress"`
|
||||
Status uint64 `gorm:"type:int(11);column:status;default:1;comment:状态" json:"status"`
|
||||
}
|
||||
|
||||
// TableName get sql table name.获取数据库表名
|
||||
func (m *BundlePayPrice) TableName() string {
|
||||
return "bundle_pay_price"
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) SaveApprovalContent(in *approval.CreateRequest, a *Approval) error {
|
||||
|
||||
m.ApprovalID = a.ID
|
||||
m.ShowUid = in.BundlePayPrice.ShowUid
|
||||
m.ShowName = in.BundlePayPrice.ShowName
|
||||
m.ReceivedAt = in.BundlePayPrice.ReceivedAt
|
||||
m.ShowDate = in.BundlePayPrice.ShowDate
|
||||
m.ShowLowPrice = in.BundlePayPrice.ShowLowPrice
|
||||
m.ArtworkNum = in.BundlePayPrice.ArtworkNum
|
||||
m.ArtworkSize = in.BundlePayPrice.ArtworkSize
|
||||
m.ShowAddress = in.BundlePayPrice.ShowAddress
|
||||
|
||||
return DB.Create(&m).Error
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) UpdateApprovalContent(in *approval.CreateRequest, a *Approval) error {
|
||||
|
||||
var entity *BundlePayPrice
|
||||
|
||||
if err := DB.Where(&BundlePayPrice{ApprovalID: a.ID}).First(&entity).Error; err != nil {
|
||||
return errors.New(m2.ErrorNotFound)
|
||||
}
|
||||
|
||||
m.ID = entity.ID
|
||||
m.ShowUid = in.BundlePayPrice.ShowUid
|
||||
m.ShowName = in.BundlePayPrice.ShowName
|
||||
m.ReceivedAt = in.BundlePayPrice.ReceivedAt
|
||||
m.ShowDate = in.BundlePayPrice.ShowDate
|
||||
m.ShowLowPrice = in.BundlePayPrice.ShowLowPrice
|
||||
m.ArtworkNum = in.BundlePayPrice.ArtworkNum
|
||||
m.ArtworkSize = in.BundlePayPrice.ArtworkSize
|
||||
m.ShowAddress = in.BundlePayPrice.ShowAddress
|
||||
|
||||
return DB.Model(&m).Updates(m).Error
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) BuildResContent(a *Approval, request *approval.CreateRequest) {
|
||||
|
||||
if a.BundlePayPrice != nil {
|
||||
request.BundlePayPrice = &approval.BundlePayPrice{
|
||||
ShowUid: a.BundlePayPrice.ShowUid,
|
||||
ApprovalID: a.BundlePayPrice.ApprovalID,
|
||||
ShowName: a.BundlePayPrice.ShowName,
|
||||
ReceivedAt: a.BundlePayPrice.ReceivedAt,
|
||||
ShowDate: a.BundlePayPrice.ShowDate,
|
||||
ShowLowPrice: a.BundlePayPrice.ShowLowPrice,
|
||||
ArtworkNum: a.BundlePayPrice.ArtworkNum,
|
||||
ArtworkSize: a.BundlePayPrice.ArtworkSize,
|
||||
ShowAddress: a.BundlePayPrice.ShowAddress,
|
||||
Status: a.BundlePayPrice.Status,
|
||||
ID: a.BundlePayPrice.ID,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (m *BundlePayPrice) DeleteApproval(p *Approval) error {
|
||||
return DB.Where(&BundlePayPrice{ApprovalID: p.ID}).Delete(&BundlePayPrice{}).Error
|
||||
}
|
@ -8,6 +8,7 @@ import (
|
||||
func migration() {
|
||||
//自动迁移模式
|
||||
addTable(&ApprovalTypeGroup{})
|
||||
addTable(&BundlePayPrice{})
|
||||
|
||||
//增加字段
|
||||
addColumn(&ApprovalType{}, "is_normal")
|
||||
@ -24,6 +25,7 @@ func migration() {
|
||||
addColumn(&Work{}, "artist_uid")
|
||||
|
||||
addColumn(&Approval{}, "value_json")
|
||||
addColumn(&BundlePayPrice{}, "status")
|
||||
}
|
||||
|
||||
//数据迁移
|
||||
|
@ -1,6 +1,7 @@
|
||||
package serializer
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/api/approval"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/e"
|
||||
"github.com/fonchain_enterprise/fonchain-approval/pkg/model"
|
||||
@ -84,7 +85,15 @@ func BuildApproval(entity *model.Approval, userId uint64) *approval.CreateReques
|
||||
response.IsCustom = e.Is_IsCustom_No
|
||||
}
|
||||
|
||||
if entity.ApprovalType != nil {
|
||||
response.TypeName = entity.ApprovalType.Title
|
||||
if entity.ApprovalType.ApprovalTypeGroup != nil {
|
||||
response.GroupName = entity.ApprovalType.ApprovalTypeGroup.Title
|
||||
}
|
||||
}
|
||||
|
||||
_ = entity.SetResContent(response)
|
||||
fmt.Println("check:", response.BundlePayPrice)
|
||||
|
||||
return response
|
||||
}
|
||||
|
@ -39,6 +39,7 @@ func BuildKeyInfo(infos model.KeyInfos) []*approval.KeyInfo {
|
||||
ApprovalName: t.ApprovalName,
|
||||
ApprovalType: t.ApprovalType,
|
||||
ApprovalValue: t.ApprovalValue,
|
||||
ApprovalMark: t.ApprovalMark,
|
||||
}
|
||||
keyInfos = append(keyInfos, temp)
|
||||
}
|
||||
|
@ -166,6 +166,34 @@ func (a *ApprovalProvider) Remove(ctx context.Context, in *approval.RemoveReques
|
||||
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) ChangeBundlePay(ctx context.Context, in *approval.ChangeBundlePayRequest) (*approval.CommonResponse, error) {
|
||||
response := &approval.CommonResponse{}
|
||||
|
||||
m := &model.BundlePayPrice{Status: in.Status}
|
||||
|
||||
model.DB.Model(&model.BundlePayPrice{}).Where(&model.BundlePayPrice{ID: in.ID}).Updates(&m)
|
||||
|
||||
return response, nil
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) IsExistPayRight(ctx context.Context, in *approval.IsExistPayRightRequest) (*approval.IsExistPayRightResponse, error) {
|
||||
response := &approval.IsExistPayRightResponse{IsPass: false}
|
||||
|
||||
var err error
|
||||
var count int64
|
||||
|
||||
subQuery1 := model.DB.Model(&model.Approval{}).Where(&model.Approval{SubmitterID: in.UserId, Type: model.TypeBundlePayPrice, Status: model.StatusOk}).
|
||||
Select("id")
|
||||
|
||||
model.DB.Model(&model.BundlePayPrice{}).Where("approval_id in (?)", subQuery1).Where(&model.BundlePayPrice{ShowUid: in.ShowUid}).Count(&count)
|
||||
|
||||
if count >= 1 {
|
||||
response.IsPass = true
|
||||
}
|
||||
|
||||
return response, err
|
||||
}
|
||||
|
||||
func (a *ApprovalProvider) Detail(ctx context.Context, in *approval.DetailRequest) (*approval.CreateRequest, error) {
|
||||
response := &approval.CreateRequest{}
|
||||
var err error
|
||||
@ -174,6 +202,8 @@ func (a *ApprovalProvider) Detail(ctx context.Context, in *approval.DetailReques
|
||||
Preload("Show").
|
||||
Preload("Work.ApprovalWorks").
|
||||
Preload("Bundle").
|
||||
Preload("ApprovalType").
|
||||
Preload("BundlePayPrice").
|
||||
Preload("Exhibition.ApprovalExhibitions").
|
||||
Preload("ApprovalWorkFlows").
|
||||
First(&entity, in.ID).Error; err != nil {
|
||||
@ -338,8 +368,15 @@ func (a *ApprovalProvider) CreateType(ctx context.Context, in *approval.CreateTy
|
||||
func (a *ApprovalProvider) DetailType(ctx context.Context, in *approval.TypeResponse) (*approval.CreateTypeRequest, error) {
|
||||
response := &approval.CreateTypeRequest{}
|
||||
var typeObj model.ApprovalType
|
||||
var err error
|
||||
|
||||
if err := model.DB.Preload("ApprovalTypeGroup").First(&typeObj, in.ID).Error; err != nil {
|
||||
if in.Keyword != "" {
|
||||
err = model.DB.Preload("ApprovalTypeGroup").Where(&model.ApprovalType{KeyWord: in.Keyword}).First(&typeObj).Error
|
||||
} else {
|
||||
err = model.DB.Preload("ApprovalTypeGroup").First(&typeObj, in.ID).Error
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user