Forráskód Böngészése

feat:附件删除

wangshan 3 éve
szülő
commit
7d9ded1a4a

+ 2 - 1
api/info.go

@@ -1,10 +1,10 @@
 package main
 
 import (
-	"fmt"
 	c "app.yhyue.com/moapp/jyInfo/api/common"
 	"app.yhyue.com/moapp/jyInfo/api/internal/handler"
 	"app.yhyue.com/moapp/jyInfo/api/internal/svc"
+	"fmt"
 	"log"
 	"os"
 	"os/signal"
@@ -17,6 +17,7 @@ import (
 )
 
 func main() {
+	//注册代理服务
 	closeNotify, err := node.NewNode(c.C.Gateway.Etcd...).Register(c.C.Gateway.ServerCode, mc.InterfaceToStr(c.C.Port))
 	if err != nil {
 		panic(err)

+ 28 - 0
api/internal/handler/infofiledelhandler.go

@@ -0,0 +1,28 @@
+package handler
+
+import (
+	"net/http"
+
+	"app.yhyue.com/moapp/jyInfo/api/internal/logic"
+	"app.yhyue.com/moapp/jyInfo/api/internal/svc"
+	"app.yhyue.com/moapp/jyInfo/api/internal/types"
+	"github.com/zeromicro/go-zero/rest/httpx"
+)
+
+func infoFileDelHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
+	return func(w http.ResponseWriter, r *http.Request) {
+		var req types.InfoFileDelReq
+		if err := httpx.Parse(r, &req); err != nil {
+			httpx.Error(w, err)
+			return
+		}
+
+		l := logic.NewInfoFileDelLogic(r.Context(), svcCtx)
+		resp, err := l.InfoFileDel(&req)
+		if err != nil {
+			httpx.Error(w, err)
+		} else {
+			httpx.OkJson(w, resp)
+		}
+	}
+}

+ 5 - 0
api/internal/handler/routes.go

@@ -77,6 +77,11 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
 				Path:    "/jyinfo/infoFile/upload",
 				Handler: uploadHandler(serverCtx),
 			},
+			{
+				Method:  http.MethodPost,
+				Path:    "/jyinfo/infoFileDel",
+				Handler: infoFileDelHandler(serverCtx),
+			},
 			{
 				Method:  http.MethodPost,
 				Path:    "/jyinfo/manage/infoList",

+ 42 - 0
api/internal/logic/infofiledellogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	"app.yhyue.com/moapp/jyInfo/api/internal/svc"
+	"app.yhyue.com/moapp/jyInfo/api/internal/types"
+	"app.yhyue.com/moapp/jyInfo/rpc/consumer/consumer"
+	"app.yhyue.com/moapp/jybase/common"
+	"context"
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type InfoFileDelLogic struct {
+	logx.Logger
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+}
+
+func NewInfoFileDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoFileDelLogic {
+	return &InfoFileDelLogic{
+		Logger: logx.WithContext(ctx),
+		ctx:    ctx,
+		svcCtx: svcCtx,
+	}
+}
+
+func (l *InfoFileDelLogic) InfoFileDel(req *types.InfoFileDelReq) (resp *types.CommonRes, err error) {
+	res, err0 := l.svcCtx.Consumer.InfoFileDel(l.ctx, &consumer.InfoFileDelReq{
+		Fid:   req.FileId,
+		Fname: req.FileName,
+	})
+	if err0 != nil {
+		return &types.CommonRes{
+			Err_code: -1,
+			Err_msg:  "错误",
+			Data:     err0,
+		}, nil
+	}
+	return &types.CommonRes{
+		Err_code: common.IntAll(res.ErrCode),
+		Err_msg:  res.ErrMsg,
+	}, nil
+}

+ 5 - 0
api/internal/types/types.go

@@ -104,6 +104,11 @@ type UploadReq struct {
 	FileName string `json:"fileName,optional"`
 }
 
+type InfoFileDelReq struct {
+	FileName string `json:"fileName,optional"` //附件名称
+	FileId   string `json:"fileId,optional"`   //附件key
+}
+
 type CommonReq struct {
 	UserId  string `json:"userId,optional"`
 	EntId   int64  `json:"entId,optional"`

+ 9 - 0
api/jyinfo.api

@@ -89,9 +89,15 @@ type (
 		MsgId   string `json:"msgId"`
 		MsgType int64  `json:"msgType"`
 	}
+	//附件上传
 	uploadReq {
 		FileName string `json:"fileName,optional"`
 	}
+	//附件删除
+	infoFileDelReq {
+		FileName string `json:"fileName,optional"` //附件名称
+		FileId   string `json:"fileId,optional"`   //附件key
+	}
 	commonReq {
 		UserId  string `json:"userId,optional"`
 		EntId   int64  `json:"entId,optional"`
@@ -145,6 +151,9 @@ service Info-api {
 	//附件上传
 	@handler upload
 	post /jyinfo/infoFile/upload (uploadReq) returns (commonRes)
+	//附件删除
+	@handler infoFileDel
+	post /jyinfo/infoFileDel (infoFileDelReq) returns (commonRes)
 	//管理后台获取信息列表
 	@handler infoList
 	post /jyinfo/manage/infoList (infoListReq) returns (commonRes)

+ 12 - 0
rpc/consumer/consumer.proto

@@ -295,6 +295,16 @@ message InfoFileUploadData {
 	string size = 4;//单位KB
 	string ossurl = 5;//oss域名
 }
+//删除附件Req
+message InfoFileDelReq{
+	string fid = 1;//key
+	string fname = 2;//附件名称
+}
+//BaseResp
+message  BaseResp{
+	int64 err_code = 1;//resp 代码
+	string err_msg = 2;//resp 信息
+}
 //servie
 service consumer {
 	//发布信息
@@ -317,4 +327,6 @@ service consumer {
 	
 	//上传附件
 	rpc InfoFileUpload(InfoFileUploadReq) returns(InfoFileUploadResp);
+	//删除附件
+	rpc InfoFileDel(InfoFileDelReq) returns(BaseResp);
 }

+ 10 - 0
rpc/consumer/consumer/consumer.go

@@ -13,6 +13,7 @@ import (
 )
 
 type (
+	BaseResp             = consumer.BaseResp
 	Contact              = consumer.Contact
 	InfoByUserIdData     = consumer.InfoByUserIdData
 	InfoByUserIdResp     = consumer.InfoByUserIdResp
@@ -23,6 +24,7 @@ type (
 	InfoDetailData       = consumer.InfoDetailData
 	InfoDetailReq        = consumer.InfoDetailReq
 	InfoDetailResp       = consumer.InfoDetailResp
+	InfoFileDelReq       = consumer.InfoFileDelReq
 	InfoFileUploadData   = consumer.InfoFileUploadData
 	InfoFileUploadReq    = consumer.InfoFileUploadReq
 	InfoFileUploadResp   = consumer.InfoFileUploadResp
@@ -68,6 +70,8 @@ type (
 		SupplyInfoDetail(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*SupplyInfoDetailResp, error)
 		// 上传附件
 		InfoFileUpload(ctx context.Context, in *InfoFileUploadReq, opts ...grpc.CallOption) (*InfoFileUploadResp, error)
+		// 删除附件
+		InfoFileDel(ctx context.Context, in *InfoFileDelReq, opts ...grpc.CallOption) (*BaseResp, error)
 	}
 
 	defaultConsumer struct {
@@ -134,3 +138,9 @@ func (m *defaultConsumer) InfoFileUpload(ctx context.Context, in *InfoFileUpload
 	client := consumer.NewConsumerClient(m.cli.Conn())
 	return client.InfoFileUpload(ctx, in, opts...)
 }
+
+// 删除附件
+func (m *defaultConsumer) InfoFileDel(ctx context.Context, in *InfoFileDelReq, opts ...grpc.CallOption) (*BaseResp, error) {
+	client := consumer.NewConsumerClient(m.cli.Conn())
+	return client.InfoFileDel(ctx, in, opts...)
+}

+ 42 - 0
rpc/consumer/internal/logic/infofiledellogic.go

@@ -0,0 +1,42 @@
+package logic
+
+import (
+	IC "app.yhyue.com/moapp/jyInfo/rpc/consumer/init"
+	model "app.yhyue.com/moapp/jyInfo/rpc/model/oss"
+	"context"
+	"fmt"
+	"log"
+
+	"app.yhyue.com/moapp/jyInfo/rpc/consumer/internal/svc"
+	"app.yhyue.com/moapp/jyInfo/rpc/consumer/type/consumer"
+
+	"github.com/zeromicro/go-zero/core/logx"
+)
+
+type InfoFileDelLogic struct {
+	ctx    context.Context
+	svcCtx *svc.ServiceContext
+	logx.Logger
+}
+
+func NewInfoFileDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoFileDelLogic {
+	return &InfoFileDelLogic{
+		ctx:    ctx,
+		svcCtx: svcCtx,
+		Logger: logx.WithContext(ctx),
+	}
+}
+
+// 删除附件
+func (l *InfoFileDelLogic) InfoFileDel(in *consumer.InfoFileDelReq) (*consumer.BaseResp, error) {
+	var resp = &consumer.BaseResp{}
+	if in.Fid != "" && IC.C.Oss.OssBucketName != "" {
+		b, err := model.OssDelObject(in.Fid, IC.C.Oss.OssBucketName)
+		if !b || err != nil {
+			log.Println("rpc fileDel false :", err)
+			resp.ErrCode = -1
+			resp.ErrMsg = fmt.Sprintf("附件 %s 删除异常", in.Fname)
+		}
+	}
+	return resp, nil
+}

+ 6 - 0
rpc/consumer/internal/server/consumerserver.go

@@ -75,3 +75,9 @@ func (s *ConsumerServer) InfoFileUpload(ctx context.Context, in *consumer.InfoFi
 	l := logic.NewInfoFileUploadLogic(ctx, s.svcCtx)
 	return l.InfoFileUpload(in)
 }
+
+// 删除附件
+func (s *ConsumerServer) InfoFileDel(ctx context.Context, in *consumer.InfoFileDelReq) (*consumer.BaseResp, error) {
+	l := logic.NewInfoFileDelLogic(ctx, s.svcCtx)
+	return l.InfoFileDel(in)
+}

+ 206 - 54
rpc/consumer/type/consumer/consumer.pb.go

@@ -2819,6 +2819,118 @@ func (x *InfoFileUploadData) GetOssurl() string {
 	return ""
 }
 
+//删除附件Req
+type InfoFileDelReq struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	Fid   string `protobuf:"bytes,1,opt,name=fid,proto3" json:"fid,omitempty"`     //key
+	Fname string `protobuf:"bytes,2,opt,name=fname,proto3" json:"fname,omitempty"` //附件名称
+}
+
+func (x *InfoFileDelReq) Reset() {
+	*x = InfoFileDelReq{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_consumer_proto_msgTypes[35]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *InfoFileDelReq) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*InfoFileDelReq) ProtoMessage() {}
+
+func (x *InfoFileDelReq) ProtoReflect() protoreflect.Message {
+	mi := &file_consumer_proto_msgTypes[35]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use InfoFileDelReq.ProtoReflect.Descriptor instead.
+func (*InfoFileDelReq) Descriptor() ([]byte, []int) {
+	return file_consumer_proto_rawDescGZIP(), []int{35}
+}
+
+func (x *InfoFileDelReq) GetFid() string {
+	if x != nil {
+		return x.Fid
+	}
+	return ""
+}
+
+func (x *InfoFileDelReq) GetFname() string {
+	if x != nil {
+		return x.Fname
+	}
+	return ""
+}
+
+//BaseResp
+type BaseResp struct {
+	state         protoimpl.MessageState
+	sizeCache     protoimpl.SizeCache
+	unknownFields protoimpl.UnknownFields
+
+	ErrCode int64  `protobuf:"varint,1,opt,name=err_code,json=errCode,proto3" json:"err_code,omitempty"` //resp 代码
+	ErrMsg  string `protobuf:"bytes,2,opt,name=err_msg,json=errMsg,proto3" json:"err_msg,omitempty"`     //resp 信息
+}
+
+func (x *BaseResp) Reset() {
+	*x = BaseResp{}
+	if protoimpl.UnsafeEnabled {
+		mi := &file_consumer_proto_msgTypes[36]
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		ms.StoreMessageInfo(mi)
+	}
+}
+
+func (x *BaseResp) String() string {
+	return protoimpl.X.MessageStringOf(x)
+}
+
+func (*BaseResp) ProtoMessage() {}
+
+func (x *BaseResp) ProtoReflect() protoreflect.Message {
+	mi := &file_consumer_proto_msgTypes[36]
+	if protoimpl.UnsafeEnabled && x != nil {
+		ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
+		if ms.LoadMessageInfo() == nil {
+			ms.StoreMessageInfo(mi)
+		}
+		return ms
+	}
+	return mi.MessageOf(x)
+}
+
+// Deprecated: Use BaseResp.ProtoReflect.Descriptor instead.
+func (*BaseResp) Descriptor() ([]byte, []int) {
+	return file_consumer_proto_rawDescGZIP(), []int{36}
+}
+
+func (x *BaseResp) GetErrCode() int64 {
+	if x != nil {
+		return x.ErrCode
+	}
+	return 0
+}
+
+func (x *BaseResp) GetErrMsg() string {
+	if x != nil {
+		return x.ErrMsg
+	}
+	return ""
+}
+
 var File_consumer_proto protoreflect.FileDescriptor
 
 var file_consumer_proto_rawDesc = []byte{
@@ -3172,48 +3284,60 @@ var file_consumer_proto_rawDesc = []byte{
 	0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x66, 0x69, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x73, 0x69, 0x7a,
 	0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x73, 0x69, 0x7a, 0x65, 0x12, 0x16, 0x0a,
 	0x06, 0x6f, 0x73, 0x73, 0x75, 0x72, 0x6c, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x6f,
-	0x73, 0x73, 0x75, 0x72, 0x6c, 0x32, 0xfc, 0x04, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
-	0x65, 0x72, 0x12, 0x42, 0x0a, 0x0b, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x49, 0x6e, 0x66,
-	0x6f, 0x12, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x50, 0x75, 0x62,
-	0x6c, 0x69, 0x73, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x6f,
+	0x73, 0x73, 0x75, 0x72, 0x6c, 0x22, 0x38, 0x0a, 0x0e, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c,
+	0x65, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x69, 0x64, 0x18, 0x01,
+	0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x66, 0x69, 0x64, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x6e, 0x61,
+	0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x66, 0x6e, 0x61, 0x6d, 0x65, 0x22,
+	0x3e, 0x0a, 0x08, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x19, 0x0a, 0x08, 0x65,
+	0x72, 0x72, 0x5f, 0x63, 0x6f, 0x64, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x03, 0x52, 0x07, 0x65,
+	0x72, 0x72, 0x43, 0x6f, 0x64, 0x65, 0x12, 0x17, 0x0a, 0x07, 0x65, 0x72, 0x72, 0x5f, 0x6d, 0x73,
+	0x67, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x65, 0x72, 0x72, 0x4d, 0x73, 0x67, 0x32,
+	0xb9, 0x05, 0x0a, 0x08, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x12, 0x42, 0x0a, 0x0b,
+	0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x12, 0x18, 0x2e, 0x63, 0x6f,
 	0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x49, 0x6e,
-	0x66, 0x6f, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79,
-	0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65,
-	0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, 0x6f,
-	0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x55, 0x73, 0x65,
-	0x72, 0x49, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3d, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x52,
-	0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65,
-	0x72, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x6f,
-	0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x6c, 0x61, 0x74,
-	0x65, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x48, 0x0a, 0x0d, 0x4d, 0x79, 0x50, 0x75, 0x62, 0x6c,
-	0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x12, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
-	0x65, 0x72, 0x2e, 0x4d, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74,
-	0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x4d,
-	0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70,
-	0x12, 0x3f, 0x0a, 0x0a, 0x49, 0x6e, 0x66, 0x6f, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x17,
-	0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65,
-	0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
-	0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73,
-	0x70, 0x12, 0x38, 0x0a, 0x0b, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x51, 0x75, 0x65, 0x72, 0x79,
-	0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74,
-	0x75, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72,
-	0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x51, 0x0a, 0x10, 0x53,
-	0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12,
-	0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c,
-	0x79, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x1e,
-	0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79,
-	0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x47,
-	0x0a, 0x10, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74, 0x61,
-	0x69, 0x6c, 0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x74,
-	0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
-	0x65, 0x72, 0x2e, 0x73, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74,
-	0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x4b, 0x0a, 0x0e, 0x49, 0x6e, 0x66, 0x6f, 0x46,
-	0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x12, 0x1b, 0x2e, 0x63, 0x6f, 0x6e, 0x73,
-	0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c,
-	0x6f, 0x61, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1c, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65,
-	0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64,
-	0x52, 0x65, 0x73, 0x70, 0x42, 0x0c, 0x5a, 0x0a, 0x2e, 0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
-	0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
+	0x66, 0x6f, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72,
+	0x2e, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x3f, 0x0a, 0x0c, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64,
+	0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72,
+	0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72,
+	0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x42, 0x79, 0x55, 0x73, 0x65, 0x72, 0x49, 0x64, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x3d, 0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64,
+	0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x55, 0x73, 0x65, 0x72,
+	0x49, 0x64, 0x52, 0x65, 0x71, 0x1a, 0x19, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72,
+	0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x65, 0x64, 0x52, 0x65, 0x73, 0x70,
+	0x12, 0x48, 0x0a, 0x0d, 0x4d, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73,
+	0x74, 0x12, 0x1a, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x4d, 0x79, 0x50,
+	0x75, 0x62, 0x6c, 0x69, 0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x1b, 0x2e,
+	0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x4d, 0x79, 0x50, 0x75, 0x62, 0x6c, 0x69,
+	0x73, 0x68, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3f, 0x0a, 0x0a, 0x49, 0x6e,
+	0x66, 0x6f, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x12, 0x17, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75,
+	0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65,
+	0x71, 0x1a, 0x18, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66,
+	0x6f, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x38, 0x0a, 0x0b, 0x53,
+	0x74, 0x61, 0x74, 0x75, 0x73, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x13, 0x2e, 0x63, 0x6f, 0x6e,
+	0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65, 0x71, 0x1a,
+	0x14, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75,
+	0x73, 0x52, 0x65, 0x73, 0x70, 0x12, 0x51, 0x0a, 0x10, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49,
+	0x6e, 0x66, 0x6f, 0x53, 0x65, 0x61, 0x72, 0x63, 0x68, 0x12, 0x1d, 0x2e, 0x63, 0x6f, 0x6e, 0x73,
+	0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x53,
+	0x65, 0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x71, 0x1a, 0x1e, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75,
+	0x6d, 0x65, 0x72, 0x2e, 0x53, 0x75, 0x70, 0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x53, 0x65,
+	0x61, 0x72, 0x63, 0x68, 0x52, 0x65, 0x73, 0x70, 0x12, 0x47, 0x0a, 0x10, 0x73, 0x75, 0x70, 0x70,
+	0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x13, 0x2e, 0x63,
+	0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x65,
+	0x71, 0x1a, 0x1e, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x73, 0x75, 0x70,
+	0x70, 0x6c, 0x79, 0x49, 0x6e, 0x66, 0x6f, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73,
+	0x70, 0x12, 0x4b, 0x0a, 0x0e, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c,
+	0x6f, 0x61, 0x64, 0x12, 0x1b, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49,
+	0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x71,
+	0x1a, 0x1c, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f,
+	0x46, 0x69, 0x6c, 0x65, 0x55, 0x70, 0x6c, 0x6f, 0x61, 0x64, 0x52, 0x65, 0x73, 0x70, 0x12, 0x3b,
+	0x0a, 0x0b, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c, 0x65, 0x44, 0x65, 0x6c, 0x12, 0x18, 0x2e,
+	0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x2e, 0x49, 0x6e, 0x66, 0x6f, 0x46, 0x69, 0x6c,
+	0x65, 0x44, 0x65, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d,
+	0x65, 0x72, 0x2e, 0x42, 0x61, 0x73, 0x65, 0x52, 0x65, 0x73, 0x70, 0x42, 0x0c, 0x5a, 0x0a, 0x2e,
+	0x2f, 0x63, 0x6f, 0x6e, 0x73, 0x75, 0x6d, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
+	0x33,
 }
 
 var (
@@ -3228,7 +3352,7 @@ func file_consumer_proto_rawDescGZIP() []byte {
 	return file_consumer_proto_rawDescData
 }
 
-var file_consumer_proto_msgTypes = make([]protoimpl.MessageInfo, 35)
+var file_consumer_proto_msgTypes = make([]protoimpl.MessageInfo, 37)
 var file_consumer_proto_goTypes = []interface{}{
 	(*PublishInfoReq)(nil),       // 0: consumer.PublishInfoReq
 	(*Contact)(nil),              // 1: consumer.Contact
@@ -3265,6 +3389,8 @@ var file_consumer_proto_goTypes = []interface{}{
 	(*InfoFileUploadReq)(nil),    // 32: consumer.InfoFileUploadReq
 	(*InfoFileUploadResp)(nil),   // 33: consumer.InfoFileUploadResp
 	(*InfoFileUploadData)(nil),   // 34: consumer.InfoFileUploadData
+	(*InfoFileDelReq)(nil),       // 35: consumer.InfoFileDelReq
+	(*BaseResp)(nil),             // 36: consumer.BaseResp
 }
 var file_consumer_proto_depIdxs = []int32{
 	1,  // 0: consumer.PublishInfoReq.contact:type_name -> consumer.Contact
@@ -3296,17 +3422,19 @@ var file_consumer_proto_depIdxs = []int32{
 	25, // 26: consumer.consumer.SupplyInfoSearch:input_type -> consumer.SupplyInfoSearchReq
 	22, // 27: consumer.consumer.supplyInfoDetail:input_type -> consumer.StatusReq
 	32, // 28: consumer.consumer.InfoFileUpload:input_type -> consumer.InfoFileUploadReq
-	2,  // 29: consumer.consumer.PublishInfo:output_type -> consumer.PublishInfoResp
-	5,  // 30: consumer.consumer.InfoByUserId:output_type -> consumer.InfoByUserIdResp
-	7,  // 31: consumer.consumer.InfoRelated:output_type -> consumer.InfoRelatedResp
-	10, // 32: consumer.consumer.MyPublishList:output_type -> consumer.MyPublishListResp
-	14, // 33: consumer.consumer.InfoChange:output_type -> consumer.InfoDetailResp
-	23, // 34: consumer.consumer.StatusQuery:output_type -> consumer.StatusResp
-	26, // 35: consumer.consumer.SupplyInfoSearch:output_type -> consumer.SupplyInfoSearchResp
-	29, // 36: consumer.consumer.supplyInfoDetail:output_type -> consumer.supplyInfoDetailResp
-	33, // 37: consumer.consumer.InfoFileUpload:output_type -> consumer.InfoFileUploadResp
-	29, // [29:38] is the sub-list for method output_type
-	20, // [20:29] is the sub-list for method input_type
+	35, // 29: consumer.consumer.InfoFileDel:input_type -> consumer.InfoFileDelReq
+	2,  // 30: consumer.consumer.PublishInfo:output_type -> consumer.PublishInfoResp
+	5,  // 31: consumer.consumer.InfoByUserId:output_type -> consumer.InfoByUserIdResp
+	7,  // 32: consumer.consumer.InfoRelated:output_type -> consumer.InfoRelatedResp
+	10, // 33: consumer.consumer.MyPublishList:output_type -> consumer.MyPublishListResp
+	14, // 34: consumer.consumer.InfoChange:output_type -> consumer.InfoDetailResp
+	23, // 35: consumer.consumer.StatusQuery:output_type -> consumer.StatusResp
+	26, // 36: consumer.consumer.SupplyInfoSearch:output_type -> consumer.SupplyInfoSearchResp
+	29, // 37: consumer.consumer.supplyInfoDetail:output_type -> consumer.supplyInfoDetailResp
+	33, // 38: consumer.consumer.InfoFileUpload:output_type -> consumer.InfoFileUploadResp
+	36, // 39: consumer.consumer.InfoFileDel:output_type -> consumer.BaseResp
+	30, // [30:40] is the sub-list for method output_type
+	20, // [20:30] is the sub-list for method input_type
 	20, // [20:20] is the sub-list for extension type_name
 	20, // [20:20] is the sub-list for extension extendee
 	0,  // [0:20] is the sub-list for field type_name
@@ -3738,6 +3866,30 @@ func file_consumer_proto_init() {
 				return nil
 			}
 		}
+		file_consumer_proto_msgTypes[35].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*InfoFileDelReq); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
+		file_consumer_proto_msgTypes[36].Exporter = func(v interface{}, i int) interface{} {
+			switch v := v.(*BaseResp); i {
+			case 0:
+				return &v.state
+			case 1:
+				return &v.sizeCache
+			case 2:
+				return &v.unknownFields
+			default:
+				return nil
+			}
+		}
 	}
 	type x struct{}
 	out := protoimpl.TypeBuilder{
@@ -3745,7 +3897,7 @@ func file_consumer_proto_init() {
 			GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
 			RawDescriptor: file_consumer_proto_rawDesc,
 			NumEnums:      0,
-			NumMessages:   35,
+			NumMessages:   37,
 			NumExtensions: 0,
 			NumServices:   1,
 		},

+ 38 - 0
rpc/consumer/type/consumer/consumer_grpc.pb.go

@@ -40,6 +40,8 @@ type ConsumerClient interface {
 	SupplyInfoDetail(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*SupplyInfoDetailResp, error)
 	//上传附件
 	InfoFileUpload(ctx context.Context, in *InfoFileUploadReq, opts ...grpc.CallOption) (*InfoFileUploadResp, error)
+	//删除附件
+	InfoFileDel(ctx context.Context, in *InfoFileDelReq, opts ...grpc.CallOption) (*BaseResp, error)
 }
 
 type consumerClient struct {
@@ -131,6 +133,15 @@ func (c *consumerClient) InfoFileUpload(ctx context.Context, in *InfoFileUploadR
 	return out, nil
 }
 
+func (c *consumerClient) InfoFileDel(ctx context.Context, in *InfoFileDelReq, opts ...grpc.CallOption) (*BaseResp, error) {
+	out := new(BaseResp)
+	err := c.cc.Invoke(ctx, "/consumer.consumer/InfoFileDel", in, out, opts...)
+	if err != nil {
+		return nil, err
+	}
+	return out, nil
+}
+
 // ConsumerServer is the server API for Consumer service.
 // All implementations must embed UnimplementedConsumerServer
 // for forward compatibility
@@ -153,6 +164,8 @@ type ConsumerServer interface {
 	SupplyInfoDetail(context.Context, *StatusReq) (*SupplyInfoDetailResp, error)
 	//上传附件
 	InfoFileUpload(context.Context, *InfoFileUploadReq) (*InfoFileUploadResp, error)
+	//删除附件
+	InfoFileDel(context.Context, *InfoFileDelReq) (*BaseResp, error)
 	mustEmbedUnimplementedConsumerServer()
 }
 
@@ -187,6 +200,9 @@ func (UnimplementedConsumerServer) SupplyInfoDetail(context.Context, *StatusReq)
 func (UnimplementedConsumerServer) InfoFileUpload(context.Context, *InfoFileUploadReq) (*InfoFileUploadResp, error) {
 	return nil, status.Errorf(codes.Unimplemented, "method InfoFileUpload not implemented")
 }
+func (UnimplementedConsumerServer) InfoFileDel(context.Context, *InfoFileDelReq) (*BaseResp, error) {
+	return nil, status.Errorf(codes.Unimplemented, "method InfoFileDel not implemented")
+}
 func (UnimplementedConsumerServer) mustEmbedUnimplementedConsumerServer() {}
 
 // UnsafeConsumerServer may be embedded to opt out of forward compatibility for this service.
@@ -362,6 +378,24 @@ func _Consumer_InfoFileUpload_Handler(srv interface{}, ctx context.Context, dec
 	return interceptor(ctx, in, info, handler)
 }
 
+func _Consumer_InfoFileDel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
+	in := new(InfoFileDelReq)
+	if err := dec(in); err != nil {
+		return nil, err
+	}
+	if interceptor == nil {
+		return srv.(ConsumerServer).InfoFileDel(ctx, in)
+	}
+	info := &grpc.UnaryServerInfo{
+		Server:     srv,
+		FullMethod: "/consumer.consumer/InfoFileDel",
+	}
+	handler := func(ctx context.Context, req interface{}) (interface{}, error) {
+		return srv.(ConsumerServer).InfoFileDel(ctx, req.(*InfoFileDelReq))
+	}
+	return interceptor(ctx, in, info, handler)
+}
+
 // Consumer_ServiceDesc is the grpc.ServiceDesc for Consumer service.
 // It's only intended for direct use with grpc.RegisterService,
 // and not to be introspected or modified (even as a copy)
@@ -405,6 +439,10 @@ var Consumer_ServiceDesc = grpc.ServiceDesc{
 			MethodName: "InfoFileUpload",
 			Handler:    _Consumer_InfoFileUpload_Handler,
 		},
+		{
+			MethodName: "InfoFileDel",
+			Handler:    _Consumer_InfoFileDel_Handler,
+		},
 	},
 	Streams:  []grpc.StreamDesc{},
 	Metadata: "consumer.proto",

+ 24 - 7
rpc/model/oss/oss.go

@@ -30,16 +30,33 @@ func OssPutObject(objectName string, fd io.Reader, ossBucketName string) (bool,
 		fmt.Println("Error:", err)
 		return false, err
 	}
-	// 上传文件流。 文件超过1M 上传时间超时
-	go func(objectName string, fd io.Reader) {
-		err = bucket.PutObject(objectName, fd)
-		if err != nil {
-			fmt.Println("file upload false:", err)
-		}
-	}(objectName, fd)
+	// 上传文件流。 文件超过1M 上传时间超时(发现是受控制台日志打印影响,现已把日志单独处理,注释协程)
+	//go func(objectName string, fd io.Reader) {
+	err = bucket.PutObject(objectName, fd)
+	if err != nil {
+		fmt.Println("file upload false:", err)
+		return false, err
+	}
+	//}(objectName, fd)
 	return true, nil
 }
 
+//删除附件
+func OssDelObject(objectName, ossBucketName string) (bool, error) {
+	common.Catch()
+	// 获取存储信息
+	bucket, err := ossclient.Bucket(ossBucketName)
+	if err != nil {
+		fmt.Println("Error:", err)
+		return false, err
+	}
+	err = bucket.DeleteObject(objectName)
+	if err != nil {
+		fmt.Println("file del false:", err)
+		return false, err
+	}
+	return true, err
+}
 func GetHashKey(bs []byte) string {
 	common.Catch()
 	ha := sha256.New()