syntax = "proto3";
package cms;
option go_package = "bsm/full/module/base/cms/pb;cms";
import "protobuf/blocks.proto";

// 正文
service Post{
	//文章列表
  rpc Fetch(PostListRequest) returns (PostListReply) {};

	//获取文章详情 By Identity
  rpc GetByIdentity (GetPostRequest) returns (PostItem) {};

    //获取文章详情 By Key
  rpc GetByKey (GetPostByKeyRequest) returns (PostItem) {};

    //搜索文章
  rpc Search (blocks.CmsSearchRequest) returns (PostListReply) {};

	//发布文章
  rpc Create(PostItem) returns (blocks.StatusReply) {};

	//修改文章
  rpc Modify(PostItem) returns (blocks.StatusReply) {};

	//删除文章
  rpc Delete(blocks.IdentRequest) returns (blocks.StatusReply) {};

	// 文章点赞处理
  rpc IncrPostLike(PostOpIdentityRequest) returns (blocks.StatusReply) {};

    // 文章点赞取消处理
  rpc DescPostLike(PostOpIdentityRequest) returns (blocks.StatusReply) {};

	// 文章点踩处理
  rpc IncrPostUnlike(PostOpIdentityRequest) returns (blocks.StatusReply) {};

    // 文章点踩取消处理
  rpc DescPostUnlike(PostOpIdentityRequest) returns (blocks.StatusReply) {};

	//评论列表
  rpc CommentList(CommentListRequest) returns (CommentListResponse) {};

	//发布评论
  rpc AddComment(CommentItem) returns (blocks.StatusReply) {};

	//修改评论
  rpc ModifyComment(CommentItem) returns (blocks.StatusReply) {};

	//删除评论
  rpc DeleteComment(DeleteCommentRequest) returns (blocks.StatusReply) {};

	// 评论点赞处理
  rpc IncrCommentLike(CommentOpIdentityRequest) returns (blocks.StatusReply) {};

    // 评论点赞取消处理
  rpc DescCommentLike(CommentOpIdentityRequest) returns (blocks.StatusReply) {};

	// 评论点踩处理
  rpc IncrCommentUnlike(CommentOpIdentityRequest) returns (blocks.StatusReply) {};

    // 评论点踩取消处理
  rpc DescCommentUnlike(CommentOpIdentityRequest) returns (blocks.StatusReply) {};
}

// 删除评论
message DeleteCommentRequest{
  string identity      = 1; // 需要删除的评论的唯一标识
  string post_identity = 2 [json_name = "post_identity"]; // 文章唯一标识
}

// 根据KEY获取内容请求
message GetPostByKeyRequest{
  string key = 3; //<必传> 内容页的key
}

// 文章
message PostItem{
  string          site_identity            = 1 [json_name = "site_identity"];
  string          identity                 = 2; // 文章唯一标识
  int64           owner_id                 = 3 [json_name = "owner_id"]; // 作者ID
  string          owner_identity           = 4 [json_name = "owner_identity"]; // 作者唯一标识
  repeated string category_identity_array  = 5 [json_name = "category_identity_array"]; // <必传>,所属分类Identity 列表
  repeated string tags_identity_array      = 6 [json_name = "tags_identity_array"]; // 标签集Identity 列表
  string          title                    = 7; // <必传>,标题
  string          cover_path               = 8 [json_name = "cover_path"]; //封面
  string          author                   = 9; // 作者
  string          author_identity          = 10 [json_name = "author_identity"];
  string          content                  = 11; // <必传>,内容
  string          target_url               = 12 [json_name = "target_url"]; // 跳转目标地址
  string          source_url               = 13 [json_name = "source_url"]; // 文章来源地址
  int64           hits                     = 14; //点击量
  repeated string accessory_identity_array = 15 [json_name = "accessory_identity_array"]; //附件Identity 列表
  bool            has_accessory            = 16 [json_name = "has_accessory"]; //是否有附件,默认没有
  string          created_at               = 17 [json_name = "created_at"]; // 创建时间
  string          updated_at               = 18 [json_name = "updated_at"]; //更新时间
  string          description              = 19; //简介
  int64           like_hits                = 20 [json_name = "like_hits"]; //点赞量
  int64           unlike_hits              = 21 [json_name = "unlike_hits"]; //点踩量
  int64           comment_hits             = 22 [json_name = "comment_hits"]; //评论量
  int32           post_type                = 23 [json_name = "post_type"]; // 用户自定义文章类型
  string          rights                   = 24; //权限

  repeated blocks.CmsCategoryItem  category_data  = 26 [json_name = "category_data"]; // 分类数据
  repeated blocks.CmsTagsItem      tags_data      = 27 [json_name = "tags_data"]; // 标签数据
  repeated blocks.CmsAccessoryItem accessory_data = 28 [json_name = "accessory_data"]; //附件数据

  string lang          = 29 [json_name = "lang"]; // 语言
  string source_origin = 30 [json_name = "source_origin"]; // 来源方简称

  string extend_url  = 31 [json_name = "extend_url"]; // 扩展：URL
  string extend_data = 32 [json_name = "extend_data"]; // 扩展：数据
  string extend_img  = 33 [json_name = "extend_img"]; // 扩展：图片
  string extend_desc = 34 [json_name = "extend_desc"]; // 扩展：描述

  string published = 35 [json_name = "published"]; // 事件发生时间

  // 扩展：文章唯一键值（用于URL等）
  string hash = 36 [json_name = "hash"];
}

// 文章列表请求
message PostListRequest{
  int64  page              = 1; // 页码,默认第一页
  int64  size              = 2; // 单页显示数量,默认10,最多50
  string author_identity   = 3 [json_name = "author_identity"]; //发布者唯一标识,可选
  string category_identity = 4 [json_name = "category_identity"]; // 文章类型,可选
  string keyword           = 5; // 根据文章名称模糊查找
  int32  type              = 6; // 根据用户自定义文章类型过滤,可选,默认0,全部查找
}

// 文章列表回复
message PostListReply{
  repeated PostItem data  = 1; // 数据
  int64             count = 2; // 总数量
}

// 获取文章详情请求
message GetPostRequest {
  string identity        = 1; // 必传唯一标识
  string author_identity = 2 [json_name = "author_identity"]; // 必传作者唯一标识
}

// 评论
message CommentItem {
  string               identity       = 1; // 评论唯一标识
  string               post_identity  = 2 [json_name = "post_identity"]; // 文章唯一标识
  int64                parent_id      = 3 [json_name = "parent_id"]; // 为空表示顶级评论
  string               Cms            = 4; // 评论内容
  string               reply_identity = 5 [json_name = "reply_identity"]; // 回复者唯一 标识
  string               created_at     = 6 [json_name = "created_at"]; // 创建时间
  string               updated_at     = 7 [json_name = "updated_at"]; // 更新时间
  repeated CommentItem list           = 8; //回复列表
  int64                like_hits      = 9 [json_name = "like_hits"]; // 点赞量
  int64                unlike_hits    = 10 [json_name = "unlike_hits"]; // 点踩量
  int64                comment_hits   = 11 [json_name = "comment_hits"]; // 评论量
  string               owner_name     = 12 [json_name = "owner_name"]; // 作者名称
  string               owner_identity = 13 [json_name = "owner_identity"]; //  作者标识
  string               role           = 14 [json_name = "role"]; // 角色
}

// 评论列表
message CommentListRequest{
  string post_identity = 1 [json_name = "post_identity"]; //必填 评论唯一标识
  int64  page          = 2; // 页码,默认第一页
  int64  size          = 3; // 单页显示数量,默认10,最多50
}

// 评论列表回复
message CommentListResponse{
  repeated CommentItem list  = 1; // 数据
  int64                count = 2; // 总数量
}

// 文章点赞处理请求
message PostOpIdentityRequest{
  string post_identity = 1 [json_name = "post_identity"]; //必传 文章唯一标识
  string op_identity   = 2 [json_name = "op_identity"]; // 必传 操作者唯一标识
}

// 评论点赞处理请求
message CommentOpIdentityRequest{
  string comment_identity = 1 [json_name = "comment_identity"]; //必填 评论唯一标识
  string op_identity      = 2 [json_name = "op_identity"]; //必填 操作者唯一标识
}