文档评分功能

dev
truthhun 1 year ago
parent 367cef5876
commit c20de3c9b3

3
.gitignore vendored

@ -10,4 +10,5 @@ uploads
documents
watch.bat
indexes
sitemap
sitemap
license.cert

@ -1045,6 +1045,90 @@ func (m *SearchDocumentRequest) GetExt() string {
return ""
}
type DocumentScore struct {
Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
DocumentId int64 `protobuf:"varint,2,opt,name=document_id,json=documentId,proto3" json:"document_id,omitempty"`
UserId int64 `protobuf:"varint,3,opt,name=user_id,json=userId,proto3" json:"user_id,omitempty"`
Score int32 `protobuf:"varint,4,opt,name=score,proto3" json:"score,omitempty"`
CreatedAt *time.Time `protobuf:"bytes,5,opt,name=created_at,json=createdAt,proto3,stdtime" json:"created_at,omitempty"`
UpdatedAt *time.Time `protobuf:"bytes,6,opt,name=updated_at,json=updatedAt,proto3,stdtime" json:"updated_at,omitempty"`
}
func (m *DocumentScore) Reset() { *m = DocumentScore{} }
func (m *DocumentScore) String() string { return proto.CompactTextString(m) }
func (*DocumentScore) ProtoMessage() {}
func (*DocumentScore) Descriptor() ([]byte, []int) {
return fileDescriptor_55a584ae3a7fc022, []int{13}
}
func (m *DocumentScore) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *DocumentScore) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_DocumentScore.Marshal(b, m, deterministic)
} else {
b = b[:cap(b)]
n, err := m.MarshalToSizedBuffer(b)
if err != nil {
return nil, err
}
return b[:n], nil
}
}
func (m *DocumentScore) XXX_Merge(src proto.Message) {
xxx_messageInfo_DocumentScore.Merge(m, src)
}
func (m *DocumentScore) XXX_Size() int {
return m.Size()
}
func (m *DocumentScore) XXX_DiscardUnknown() {
xxx_messageInfo_DocumentScore.DiscardUnknown(m)
}
var xxx_messageInfo_DocumentScore proto.InternalMessageInfo
func (m *DocumentScore) GetId() int64 {
if m != nil {
return m.Id
}
return 0
}
func (m *DocumentScore) GetDocumentId() int64 {
if m != nil {
return m.DocumentId
}
return 0
}
func (m *DocumentScore) GetUserId() int64 {
if m != nil {
return m.UserId
}
return 0
}
func (m *DocumentScore) GetScore() int32 {
if m != nil {
return m.Score
}
return 0
}
func (m *DocumentScore) GetCreatedAt() *time.Time {
if m != nil {
return m.CreatedAt
}
return nil
}
func (m *DocumentScore) GetUpdatedAt() *time.Time {
if m != nil {
return m.UpdatedAt
}
return nil
}
type SearchDocumentReply struct {
Total int64 `protobuf:"varint,1,opt,name=total,proto3" json:"total,omitempty"`
Spend string `protobuf:"bytes,2,opt,name=spend,proto3" json:"spend,omitempty"`
@ -1055,7 +1139,7 @@ func (m *SearchDocumentReply) Reset() { *m = SearchDocumentReply{} }
func (m *SearchDocumentReply) String() string { return proto.CompactTextString(m) }
func (*SearchDocumentReply) ProtoMessage() {}
func (*SearchDocumentReply) Descriptor() ([]byte, []int) {
return fileDescriptor_55a584ae3a7fc022, []int{13}
return fileDescriptor_55a584ae3a7fc022, []int{14}
}
func (m *SearchDocumentReply) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1113,7 +1197,7 @@ func (m *DownloadDocumentReply) Reset() { *m = DownloadDocumentReply{} }
func (m *DownloadDocumentReply) String() string { return proto.CompactTextString(m) }
func (*DownloadDocumentReply) ProtoMessage() {}
func (*DownloadDocumentReply) Descriptor() ([]byte, []int) {
return fileDescriptor_55a584ae3a7fc022, []int{14}
return fileDescriptor_55a584ae3a7fc022, []int{15}
}
func (m *DownloadDocumentReply) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
@ -1163,6 +1247,7 @@ func init() {
proto.RegisterType((*ListDocumentForHomeItem)(nil), "api.v1.ListDocumentForHomeItem")
proto.RegisterType((*ListDocumentForHomeResponse)(nil), "api.v1.ListDocumentForHomeResponse")
proto.RegisterType((*SearchDocumentRequest)(nil), "api.v1.SearchDocumentRequest")
proto.RegisterType((*DocumentScore)(nil), "api.v1.DocumentScore")
proto.RegisterType((*SearchDocumentReply)(nil), "api.v1.SearchDocumentReply")
proto.RegisterType((*DownloadDocumentReply)(nil), "api.v1.DownloadDocumentReply")
}
@ -1170,102 +1255,107 @@ func init() {
func init() { proto.RegisterFile("api/v1/document.proto", fileDescriptor_55a584ae3a7fc022) }
var fileDescriptor_55a584ae3a7fc022 = []byte{
// 1515 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xcd, 0x6e, 0xdb, 0xc6,
0x16, 0x0e, 0x45, 0xd9, 0x96, 0x8f, 0x64, 0xc5, 0x1e, 0x5b, 0x36, 0x4d, 0xd9, 0x92, 0x42, 0x5f,
0xdf, 0xab, 0x18, 0x17, 0x16, 0xe2, 0x8b, 0xdb, 0x45, 0xb3, 0x28, 0x1c, 0x27, 0x4d, 0x0d, 0x14,
0x45, 0xc0, 0x34, 0x08, 0x90, 0x8d, 0xc1, 0x88, 0x63, 0x89, 0x28, 0x25, 0xb2, 0xe4, 0xc8, 0xaa,
0x8d, 0x76, 0x53, 0x74, 0x5d, 0x04, 0x28, 0xd0, 0x37, 0xe8, 0x1b, 0x74, 0xd7, 0x17, 0xe8, 0x32,
0x40, 0x37, 0x05, 0xba, 0x68, 0x91, 0xf4, 0x41, 0x8a, 0x39, 0x33, 0x43, 0x51, 0x22, 0x65, 0x07,
0xd9, 0xf1, 0x9c, 0x39, 0xf3, 0x7d, 0x73, 0x7e, 0x67, 0x24, 0xa8, 0x39, 0xa1, 0xd7, 0xb9, 0xb8,
0xd7, 0x71, 0x83, 0xee, 0x68, 0x40, 0x87, 0xec, 0x30, 0x8c, 0x02, 0x16, 0x90, 0x45, 0x27, 0xf4,
0x0e, 0x2f, 0xee, 0x99, 0xcd, 0x5e, 0x10, 0xf4, 0x7c, 0xda, 0x41, 0xed, 0xcb, 0xd1, 0x79, 0x87,
0x79, 0x03, 0x1a, 0x33, 0x67, 0x10, 0x0a, 0x43, 0x73, 0xa3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xd6, 0x90,
0xec, 0x7b, 0xff, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xd1, 0x18, 0x50, 0xbe, 0xb4, 0x12, 0x00, 0x00,
}
// Reference imports to suppress errors if they are not otherwise used.
@ -1290,6 +1380,10 @@ type DocumentAPIClient interface {
DownloadDocument(ctx context.Context, in *Document, opts ...grpc.CallOption) (*DownloadDocumentReply, error)
ListDocument(ctx context.Context, in *ListDocumentRequest, opts ...grpc.CallOption) (*ListDocumentReply, error)
SearchDocument(ctx context.Context, in *SearchDocumentRequest, opts ...grpc.CallOption) (*SearchDocumentReply, error)
// 设置文档评分
SetDocumentScore(ctx context.Context, in *DocumentScore, opts ...grpc.CallOption) (*emptypb.Empty, error)
// 获取当前登录用户的文档评分
GetDocumentScore(ctx context.Context, in *DocumentScore, opts ...grpc.CallOption) (*DocumentScore, error)
}
type documentAPIClient struct {
@ -1390,6 +1484,24 @@ func (c *documentAPIClient) SearchDocument(ctx context.Context, in *SearchDocume
return out, nil
}
func (c *documentAPIClient) SetDocumentScore(ctx context.Context, in *DocumentScore, opts ...grpc.CallOption) (*emptypb.Empty, error) {
out := new(emptypb.Empty)
err := c.cc.Invoke(ctx, "/api.v1.DocumentAPI/SetDocumentScore", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
func (c *documentAPIClient) GetDocumentScore(ctx context.Context, in *DocumentScore, opts ...grpc.CallOption) (*DocumentScore, error) {
out := new(DocumentScore)
err := c.cc.Invoke(ctx, "/api.v1.DocumentAPI/GetDocumentScore", in, out, opts...)
if err != nil {
return nil, err
}
return out, nil
}
// DocumentAPIServer is the server API for DocumentAPI service.
type DocumentAPIServer interface {
ListDocumentForHome(context.Context, *ListDocumentForHomeRequest) (*ListDocumentForHomeResponse, error)
@ -1402,6 +1514,10 @@ type DocumentAPIServer interface {
DownloadDocument(context.Context, *Document) (*DownloadDocumentReply, error)
ListDocument(context.Context, *ListDocumentRequest) (*ListDocumentReply, error)
SearchDocument(context.Context, *SearchDocumentRequest) (*SearchDocumentReply, error)
// 设置文档评分
SetDocumentScore(context.Context, *DocumentScore) (*emptypb.Empty, error)
// 获取当前登录用户的文档评分
GetDocumentScore(context.Context, *DocumentScore) (*DocumentScore, error)
}
// UnimplementedDocumentAPIServer can be embedded to have forward compatible implementations.
@ -1438,6 +1554,12 @@ func (*UnimplementedDocumentAPIServer) ListDocument(ctx context.Context, req *Li
func (*UnimplementedDocumentAPIServer) SearchDocument(ctx context.Context, req *SearchDocumentRequest) (*SearchDocumentReply, error) {
return nil, status.Errorf(codes.Unimplemented, "method SearchDocument not implemented")
}
func (*UnimplementedDocumentAPIServer) SetDocumentScore(ctx context.Context, req *DocumentScore) (*emptypb.Empty, error) {
return nil, status.Errorf(codes.Unimplemented, "method SetDocumentScore not implemented")
}
func (*UnimplementedDocumentAPIServer) GetDocumentScore(ctx context.Context, req *DocumentScore) (*DocumentScore, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetDocumentScore not implemented")
}
func RegisterDocumentAPIServer(s *grpc.Server, srv DocumentAPIServer) {
s.RegisterService(&_DocumentAPI_serviceDesc, srv)
@ -1623,6 +1745,42 @@ func _DocumentAPI_SearchDocument_Handler(srv interface{}, ctx context.Context, d
return interceptor(ctx, in, info, handler)
}
func _DocumentAPI_SetDocumentScore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DocumentScore)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DocumentAPIServer).SetDocumentScore(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/api.v1.DocumentAPI/SetDocumentScore",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DocumentAPIServer).SetDocumentScore(ctx, req.(*DocumentScore))
}
return interceptor(ctx, in, info, handler)
}
func _DocumentAPI_GetDocumentScore_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DocumentScore)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(DocumentAPIServer).GetDocumentScore(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: "/api.v1.DocumentAPI/GetDocumentScore",
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(DocumentAPIServer).GetDocumentScore(ctx, req.(*DocumentScore))
}
return interceptor(ctx, in, info, handler)
}
var _DocumentAPI_serviceDesc = grpc.ServiceDesc{
ServiceName: "api.v1.DocumentAPI",
HandlerType: (*DocumentAPIServer)(nil),
@ -1667,6 +1825,14 @@ var _DocumentAPI_serviceDesc = grpc.ServiceDesc{
MethodName: "SearchDocument",
Handler: _DocumentAPI_SearchDocument_Handler,
},
{
MethodName: "SetDocumentScore",
Handler: _DocumentAPI_SetDocumentScore_Handler,
},
{
MethodName: "GetDocumentScore",
Handler: _DocumentAPI_GetDocumentScore_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "api/v1/document.proto",
@ -2788,6 +2954,69 @@ func (m *SearchDocumentRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil
}
func (m *DocumentScore) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
n, err := m.MarshalToSizedBuffer(dAtA[:size])
if err != nil {
return nil, err
}
return dAtA[:n], nil
}
func (m *DocumentScore) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *DocumentScore) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if m.UpdatedAt != nil {
n25, err25 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.UpdatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.UpdatedAt):])
if err25 != nil {
return 0, err25
}
i -= n25
i = encodeVarintDocument(dAtA, i, uint64(n25))
i--
dAtA[i] = 0x32
}
if m.CreatedAt != nil {
n26, err26 := github_com_gogo_protobuf_types.StdTimeMarshalTo(*m.CreatedAt, dAtA[i-github_com_gogo_protobuf_types.SizeOfStdTime(*m.CreatedAt):])
if err26 != nil {
return 0, err26
}
i -= n26
i = encodeVarintDocument(dAtA, i, uint64(n26))
i--
dAtA[i] = 0x2a
}
if m.Score != 0 {
i = encodeVarintDocument(dAtA, i, uint64(m.Score))
i--
dAtA[i] = 0x20
}
if m.UserId != 0 {
i = encodeVarintDocument(dAtA, i, uint64(m.UserId))
i--
dAtA[i] = 0x18
}
if m.DocumentId != 0 {
i = encodeVarintDocument(dAtA, i, uint64(m.DocumentId))
i--
dAtA[i] = 0x10
}
if m.Id != 0 {
i = encodeVarintDocument(dAtA, i, uint64(m.Id))
i--
dAtA[i] = 0x8
}
return len(dAtA) - i, nil
}
func (m *SearchDocumentReply) Marshal() (dAtA []byte, err error) {
size := m.Size()
dAtA = make([]byte, size)
@ -3272,6 +3501,35 @@ func (m *SearchDocumentRequest) Size() (n int) {
return n
}
func (m *DocumentScore) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if m.Id != 0 {
n += 1 + sovDocument(uint64(m.Id))
}
if m.DocumentId != 0 {
n += 1 + sovDocument(uint64(m.DocumentId))
}
if m.UserId != 0 {
n += 1 + sovDocument(uint64(m.UserId))
}
if m.Score != 0 {
n += 1 + sovDocument(uint64(m.Score))
}
if m.CreatedAt != nil {
l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.CreatedAt)
n += 1 + l + sovDocument(uint64(l))
}
if m.UpdatedAt != nil {
l = github_com_gogo_protobuf_types.SizeOfStdTime(*m.UpdatedAt)
n += 1 + l + sovDocument(uint64(l))
}
return n
}
func (m *SearchDocumentReply) Size() (n int) {
if m == nil {
return 0
@ -6205,6 +6463,204 @@ func (m *SearchDocumentRequest) Unmarshal(dAtA []byte) error {
}
return nil
}
func (m *DocumentScore) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0
for iNdEx < l {
preIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
wireType := int(wire & 0x7)
if wireType == 4 {
return fmt.Errorf("proto: DocumentScore: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: DocumentScore: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType)
}
m.Id = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Id |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 2:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field DocumentId", wireType)
}
m.DocumentId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.DocumentId |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 3:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field UserId", wireType)
}
m.UserId = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.UserId |= int64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Score", wireType)
}
m.Score = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Score |= int32(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 5:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field CreatedAt", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthDocument
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthDocument
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.CreatedAt == nil {
m.CreatedAt = new(time.Time)
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.CreatedAt, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
case 6:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field UpdatedAt", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowDocument
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthDocument
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthDocument
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.UpdatedAt == nil {
m.UpdatedAt = new(time.Time)
}
if err := github_com_gogo_protobuf_types.StdTimeUnmarshal(m.UpdatedAt, dAtA[iNdEx:postIndex]); err != nil {
return err
}
iNdEx = postIndex
default:
iNdEx = preIndex
skippy, err := skipDocument(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthDocument
}
if (iNdEx + skippy) > l {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
if iNdEx > l {
return io.ErrUnexpectedEOF
}
return nil
}
func (m *SearchDocumentReply) Unmarshal(dAtA []byte) error {
l := len(dAtA)
iNdEx := 0

@ -388,6 +388,76 @@ func local_request_DocumentAPI_SearchDocument_0(ctx context.Context, marshaler r
}
func request_DocumentAPI_SetDocumentScore_0(ctx context.Context, marshaler runtime.Marshaler, client DocumentAPIClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DocumentScore
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.SetDocumentScore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_DocumentAPI_SetDocumentScore_0(ctx context.Context, marshaler runtime.Marshaler, server DocumentAPIServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DocumentScore
var metadata runtime.ServerMetadata
newReader, berr := utilities.IOReaderFactory(req.Body)
if berr != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", berr)
}
if err := marshaler.NewDecoder(newReader()).Decode(&protoReq); err != nil && err != io.EOF {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.SetDocumentScore(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_DocumentAPI_GetDocumentScore_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
func request_DocumentAPI_GetDocumentScore_0(ctx context.Context, marshaler runtime.Marshaler, client DocumentAPIClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DocumentScore
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DocumentAPI_GetDocumentScore_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetDocumentScore(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_DocumentAPI_GetDocumentScore_0(ctx context.Context, marshaler runtime.Marshaler, server DocumentAPIServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq DocumentScore
var metadata runtime.ServerMetadata
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_DocumentAPI_GetDocumentScore_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetDocumentScore(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_RecycleAPI_ListRecycleDocument_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
@ -748,6 +818,52 @@ func RegisterDocumentAPIHandlerServer(ctx context.Context, mux *runtime.ServeMux
})
mux.Handle("POST", pattern_DocumentAPI_SetDocumentScore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_DocumentAPI_SetDocumentScore_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_DocumentAPI_SetDocumentScore_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_DocumentAPI_GetDocumentScore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := local_request_DocumentAPI_GetDocumentScore_0(rctx, inboundMarshaler, server, req, pathParams)
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_DocumentAPI_GetDocumentScore_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -1090,6 +1206,46 @@ func RegisterDocumentAPIHandlerClient(ctx context.Context, mux *runtime.ServeMux
})
mux.Handle("POST", pattern_DocumentAPI_SetDocumentScore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_DocumentAPI_SetDocumentScore_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_DocumentAPI_SetDocumentScore_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_DocumentAPI_GetDocumentScore_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
rctx, err := runtime.AnnotateContext(ctx, mux, req)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
resp, md, err := request_DocumentAPI_GetDocumentScore_0(rctx, inboundMarshaler, client, req, pathParams)
ctx = runtime.NewServerMetadataContext(ctx, md)
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
}
forward_DocumentAPI_GetDocumentScore_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
@ -1113,6 +1269,10 @@ var (
pattern_DocumentAPI_ListDocument_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "document", "list"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_DocumentAPI_SearchDocument_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "document", "search"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_DocumentAPI_SetDocumentScore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "document", "score"}, "", runtime.AssumeColonVerbOpt(true)))
pattern_DocumentAPI_GetDocumentScore_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"api", "v1", "document", "score"}, "", runtime.AssumeColonVerbOpt(true)))
)
var (
@ -1135,6 +1295,10 @@ var (
forward_DocumentAPI_ListDocument_0 = runtime.ForwardResponseMessage
forward_DocumentAPI_SearchDocument_0 = runtime.ForwardResponseMessage
forward_DocumentAPI_SetDocumentScore_0 = runtime.ForwardResponseMessage
forward_DocumentAPI_GetDocumentScore_0 = runtime.ForwardResponseMessage
)
// RegisterRecycleAPIHandlerFromEndpoint is same as RegisterRecycleAPIHandler but

@ -114,6 +114,15 @@ message SearchDocumentRequest {
string ext = 7; //
}
message DocumentScore {
int64 id = 1;
int64 document_id = 2;
int64 user_id = 3;
int32 score = 4;
google.protobuf.Timestamp created_at = 5 [ (gogoproto.stdtime) = true ];
google.protobuf.Timestamp updated_at = 6 [ (gogoproto.stdtime) = true ];
}
message SearchDocumentReply {
int64 total = 1;
string spend = 2; //
@ -187,6 +196,21 @@ service DocumentAPI {
get : '/api/v1/document/search',
};
}
//
rpc SetDocumentScore(DocumentScore) returns (google.protobuf.Empty) {
option (google.api.http) = {
post : '/api/v1/document/score',
body : '*',
};
}
//
rpc GetDocumentScore(DocumentScore) returns (DocumentScore) {
option (google.api.http) = {
get : '/api/v1/document/score',
};
}
}
service RecycleAPI {

@ -672,3 +672,41 @@ func (s *DocumentAPIService) GetRelatedDocuments(ctx context.Context, req *pb.Do
util.CopyStruct(&docs, &res.Document)
return res, nil
}
// 获取文档评分
func (s *DocumentAPIService) GetDocumentScore(ctx context.Context, req *pb.DocumentScore) (res *pb.DocumentScore, err error) {
userClaims, err := s.checkLogin(ctx)
if err != nil {
return nil, err
}
score, _ := s.dbModel.GetDocumentScore(userClaims.UserId, req.DocumentId)
res = &pb.DocumentScore{}
util.CopyStruct(&score, res)
return res, nil
}
// 设置文档评分
func (s *DocumentAPIService) SetDocumentScore(ctx context.Context, req *pb.DocumentScore) (res *emptypb.Empty, err error) {
userClaims, err := s.checkLogin(ctx)
if err != nil {
return nil, err
}
score, _ := s.dbModel.GetDocumentScore(userClaims.UserId, req.DocumentId)
if score.Id > 0 {
return nil, status.Errorf(codes.PermissionDenied, "您已经评分过了")
}
score = model.DocumentScore{
UserId: userClaims.UserId,
DocumentId: req.DocumentId,
Score: int(req.Score),
}
err = s.dbModel.CreateDocumentScore(&score)
if err != nil {
return nil, status.Errorf(codes.Internal, "评分失败:%s", err.Error())
}
return &emptypb.Empty{}, nil
}

@ -50,7 +50,7 @@ type Document struct {
ViewCount int `form:"view_count" json:"view_count,omitempty" gorm:"column:view_count;type:int(11);size:11;default:0;comment:浏览人次;"`
FavoriteCount int `form:"favorite_count" json:"favorite_count,omitempty" gorm:"column:favorite_count;type:int(11);size:11;default:0;comment:收藏人次;"`
CommentCount int `form:"comment_count" json:"comment_count,omitempty" gorm:"column:comment_count;type:int(11);size:11;default:0;comment:评论人次;"`
Score int `form:"score" json:"score,omitempty" gorm:"column:score;type:int(11);size:11;default:0;comment:评分3位整数表示500表示5分;"`
Score int `form:"score" json:"score,omitempty" gorm:"column:score;type:int(11);size:11;default:300;comment:评分3位整数表示500表示5分;"`
ScoreCount int `form:"score_count" json:"score_count,omitempty" gorm:"column:score_count;type:int(11);size:11;default:0;comment:评分数量;"`
Price int `form:"price" json:"price,omitempty" gorm:"column:price;type:int(11);size:11;default:0;comment:价格0表示免费;"`
Size int64 `form:"size" json:"size,omitempty" gorm:"column:size;type:bigint(20);size:20;default:0;comment:文件大小;"`

@ -2,7 +2,6 @@ package model
import (
"fmt"
"strings"
"time"
"go.uber.org/zap"
@ -11,163 +10,58 @@ import (
type DocumentScore struct {
Id int64 `form:"id" json:"id,omitempty" gorm:"primaryKey;autoIncrement;column:id;comment:;"`
DocumentId int64 `form:"document_id" json:"document_id,omitempty" gorm:"column:document_id;type:bigint(20);size:20;default:0;comment:文档ID;"`
UserId int64 `form:"user_id" json:"user_id,omitempty" gorm:"column:user_id;type:bigint(20);size:20;default:0;comment:用户ID;"`
DocumentId int64 `form:"document_id" json:"document_id,omitempty" gorm:"column:document_id;type:bigint(20);size:20;default:0;comment:文档ID;index:idx_document_user,unique"`
UserId int64 `form:"user_id" json:"user_id,omitempty" gorm:"column:user_id;type:bigint(20);size:20;default:0;comment:用户ID;index:idx_document_user,unique"`
Score int `form:"score" json:"score,omitempty" gorm:"column:score;type:int(11);size:11;default:0;comment:文档评分值3位数如500表示5分;"`
CreatedAt *time.Time `form:"created_at" json:"created_at,omitempty" gorm:"column:created_at;type:datetime;comment:创建时间;"`
UpdatedAt *time.Time `form:"updated_at" json:"updated_at,omitempty" gorm:"column:updated_at;type:datetime;comment:更新时间;"`
}
// 这里是proto文件中的结构体可以根据需要删除或者调整
//message DocumentScore {
// int64 id = 1;
// int64 document_id = 2;
// int64 user_id = 3;
// int32 score = 4;
// google.protobuf.Timestamp created_at = 5 [ (gogoproto.stdtime) = true ];
// google.protobuf.Timestamp updated_at = 6 [ (gogoproto.stdtime) = true ];
//}
func (DocumentScore) TableName() string {
return tablePrefix + "document_score"
}
// CreateDocumentScore 创建DocumentScore
// TODO: 创建成功之后,注意相关表统计字段数值的增减
func (m *DBModel) CreateDocumentScore(documentScore *DocumentScore) (err error) {
err = m.db.Create(documentScore).Error
if err != nil {
m.logger.Error("CreateDocumentScore", zap.Error(err))
doc, _ := m.GetDocument(documentScore.DocumentId, "id", "score_count", "score")
if doc.Id == 0 {
err = fmt.Errorf("文档不存在")
return
}
return
}
// UpdateDocumentScore 更新DocumentScore如果需要更新指定字段则请指定updateFields参数
func (m *DBModel) UpdateDocumentScore(documentScore *DocumentScore, updateFields ...string) (err error) {
db := m.db.Model(documentScore)
updateFields = m.FilterValidFields(DocumentScore{}.TableName(), updateFields...)
if len(updateFields) > 0 { // 更新指定字段
db = db.Select(updateFields)
}
err = db.Where("id = ?", documentScore.Id).Updates(documentScore).Error
if err != nil {
m.logger.Error("UpdateDocumentScore", zap.Error(err))
}
return
}
// GetDocumentScore 根据id获取DocumentScore
func (m *DBModel) GetDocumentScore(id interface{}, fields ...string) (documentScore DocumentScore, err error) {
db := m.db
fields = m.FilterValidFields(DocumentScore{}.TableName(), fields...)
if len(fields) > 0 {
db = db.Select(fields)
}
err = db.Where("id = ?", id).First(&documentScore).Error
return
}
type OptionGetDocumentScoreList struct {
Page int
Size int
WithCount bool // 是否返回总数
Ids []interface{} // id列表
SelectFields []string // 查询字段
QueryRange map[string][2]interface{} // map[field][]{min,max}
QueryIn map[string][]interface{} // map[field][]{value1,value2,...}
QueryLike map[string][]interface{} // map[field][]{value1,value2,...}
Sort []string
}
// GetDocumentScoreList 获取DocumentScore列表
func (m *DBModel) GetDocumentScoreList(opt OptionGetDocumentScoreList) (documentScoreList []DocumentScore, total int64, err error) {
db := m.db.Model(&DocumentScore{})
for field, rangeValue := range opt.QueryRange {
fields := m.FilterValidFields(DocumentScore{}.TableName(), field)
if len(fields) == 0 {
continue
}
if rangeValue[0] != nil {
db = db.Where(fmt.Sprintf("%s >= ?", field), rangeValue[0])
}
if rangeValue[1] != nil {
db = db.Where(fmt.Sprintf("%s <= ?", field), rangeValue[1])
}
}
for field, values := range opt.QueryIn {
fields := m.FilterValidFields(DocumentScore{}.TableName(), field)
if len(fields) == 0 {
continue
}
db = db.Where(fmt.Sprintf("%s in (?)", field), values)
}
for field, values := range opt.QueryLike {
fields := m.FilterValidFields(DocumentScore{}.TableName(), field)
if len(fields) == 0 {
continue
}
db = db.Where(strings.TrimSuffix(fmt.Sprintf(strings.Join(make([]string, len(values)+1), "%s like ? or"), field), "or"), values...)
}
if len(opt.Ids) > 0 {
db = db.Where("id in (?)", opt.Ids)
}
if opt.WithCount {
err = db.Count(&total).Error
tx := m.db.Begin()
defer func() {
if err != nil {
m.logger.Error("GetDocumentScoreList", zap.Error(err))
return
tx.Rollback()
} else {
tx.Commit()
}
}
opt.SelectFields = m.FilterValidFields(DocumentScore{}.TableName(), opt.SelectFields...)
if len(opt.SelectFields) > 0 {
db = db.Select(opt.SelectFields)
}
}()
if len(opt.Sort) > 0 {
var sorts []string
for _, sort := range opt.Sort {
slice := strings.Split(sort, " ")
if len(m.FilterValidFields(DocumentScore{}.TableName(), slice[0])) == 0 {
continue
}
if len(slice) == 2 {
sorts = append(sorts, fmt.Sprintf("%s %s", slice[0], slice[1]))
} else {
sorts = append(sorts, fmt.Sprintf("%s desc", slice[0]))
}
}
if len(sorts) > 0 {
db = db.Order(strings.Join(sorts, ","))
}
// 创建评分记录
err = tx.Create(documentScore).Error
if err != nil {
m.logger.Error("CreateDocumentScore", zap.Error(err))
return
}
db = db.Offset((opt.Page - 1) * opt.Size).Limit(opt.Size)
err = db.Find(&documentScoreList).Error
if err != nil && err != gorm.ErrRecordNotFound {
m.logger.Error("GetDocumentScoreList", zap.Error(err))
score := (documentScore.Score + doc.Score*doc.ScoreCount) / (doc.ScoreCount + 1)
// 对应文档,评分总数+1评分总值+score
err = tx.Model(&Document{}).Where("id = ?", documentScore.DocumentId).Updates(
map[string]interface{}{
"score_count": gorm.Expr("score_count + ?", 1),
"score": score,
},
).Error
if err != nil {
m.logger.Error("CreateDocumentScore", zap.Error(err))
return
}
return
}
// DeleteDocumentScore 删除数据
// TODO: 删除数据之后,存在 document_score_id 的关联表,需要删除对应数据,同时相关表的统计数值,也要随着减少
func (m *DBModel) DeleteDocumentScore(ids []interface{}) (err error) {
err = m.db.Where("id in (?)", ids).Delete(&DocumentScore{}).Error
if err != nil {
m.logger.Error("DeleteDocumentScore", zap.Error(err))
}
// GetDocumentScore 获取DocumentScore
func (m *DBModel) GetDocumentScore(userId, documentId int64) (documentScore DocumentScore, err error) {
err = m.db.Where("user_id = ? and document_id = ?", userId, documentId).Find(&documentScore).Error
return
}

@ -111,3 +111,19 @@ export const clearRecycleDocument = (params) => {
params,
})
}
export const getDocumentScore = (params) => {
return service({
url: '/api/v1/document/score',
method: 'get',
params,
})
}
export const setDocumentScore = (data) => {
return service({
url: '/api/v1/document/score',
method: 'post',
data,
})
}

@ -145,7 +145,28 @@
shadow="never"
class="mgt-20px"
>
<FormComment :document-id="document.id" @success="commentSuccess" />
<div>
<span class="score-tips">文档打分 </span>
<el-rate
:disabled="disabledScore"
v-model="score"
show-text
@change="setDocumentScore"
:texts="[
'该文档令人失望',
'该文档不怎么样',
'该文档一般般',
'该文档很让我满意',
'该文档非常棒',
]"
>
</el-rate>
</div>
<FormComment
:document-id="document.id"
@success="commentSuccess"
class="mgt-20px"
/>
<comment-list ref="commentList" :document-id="document.id" />
</el-card>
</el-col>
@ -265,6 +286,8 @@ import {
getDocument,
downloadDocument,
getRelatedDocuments,
setDocumentScore,
getDocumentScore,
} from '~/api/document'
import { getFavorite, createFavorite, deleteFavorite } from '~/api/favorite'
import { formatDatetime, formatBytes, getIcon } from '~/utils/utils'
@ -288,6 +311,8 @@ export default {
hash: '',
},
},
score: null,
disabledScore: false,
downloading: false,
documentId: parseInt(this.$route.params.id) || 0,
pages: [],
@ -338,6 +363,7 @@ export default {
this.getDocument(),
this.getFavorite(),
this.getRelatedDocuments(),
this.getDocumentScore(),
])
},
mounted() {
@ -647,6 +673,41 @@ export default {
})
}
},
async setDocumentScore() {
if (!this.score) {
return
}
const res = await setDocumentScore({
document_id: this.documentId,
score: this.score * 100,
})
if (res.status === 200) {
this.$message.success('提交评分成功')
this.disabledScore = true
} else {
this.$message.error(res.data.message)
}
},
async getDocumentScore() {
//
let userId = 0
try {
userId = this.$store.state.user.user.id || 0
} catch (error) {}
if (!userId) {
return
}
const res = await getDocumentScore({
document_id: this.documentId,
})
if (res.status === 200) {
const score = res.data.score / 100 || null
this.score = score
if (score) this.disabledScore = true
} else {
this.$message.error(res.data.message)
}
},
},
}
</script>
@ -778,5 +839,11 @@ export default {
}
}
}
.score-tips {
position: relative;
top: 3px;
margin-right: 10px;
color: #565656;
}
}
</style>

Loading…
Cancel
Save