syntax = "proto3";

import "base.proto";

package com.ywt.gapi.user;

option java_generic_services = true;
option java_multiple_files = true;
option java_package = "com.ywt.gapi.user";
option go_package = "/gapi";

//资讯    created by daiyihua
message Article {
    int32 artId = 1; //资讯ID
    string artTitle = 2; //资讯标题
    int32 status = 3; //状态，0-未读，1-已读
    int32 viewCount = 4; //浏览数
    int32 doctorCount = 5; //推荐医生数
    int32 type = 6; //1-图文，2-视频， 3-文件
    string artContent = 7;
    string urlData = 8; //当type=2时，存放视频地址
    int32 classificationId = 9; //快讯分类id，对应articles_type_id
}

//快讯分类
message ArticleClassification {
    string name = 1; //分类名称
    int32 id = 2; //分类id
    repeated Article article = 3; //快讯列表
}

//获取分类快讯列表请求
message GetClassifiedArticlesRequest {
    int32 userId = 1; //用户id
}

//获取分类快讯列表响应
message GetClassifiedArticlesResponse {
    Result result = 1;
    repeated ArticleClassification classification = 2; //分类列表
    int32 noReadCount = 3; //未读数量
}

//得到用户资讯列表Request   created by daiyihua
message GetArticlesRequest {
    int32 userId = 1;
    int32 pageIndex = 2; //当前页
    int32 pageSize = 3; //每页大小
}

//得到用户资讯列表          created by daiyihua
message GetArticlesResponse {
    Result result = 1;
    repeated Article article = 2; //资讯
    int32 count = 3; //总条数
    int32 totalPages = 4; //总页数
    int32 noReadCount = 5; //未读数量
}

//根据资讯ID得到资讯内容Request  created by daiyihua
message GetArticleByIdRequest {
    int32 artId = 1;
    int32 doctorId = 2; //医生ID，用于判断医生有没有阅读文章
}

//根据资讯ID得到资讯内容Response  created by daiyihua
message GetArticleByIdResponse {
    Result result = 1;
    Article article = 2; //资讯
}

message GetDisplayArticleListRequest {
    int32 pageIndex = 1;
    int32 pageSize = 2;
    int32 doctorId = 3;
}

message GetDisplayArticleListResponse {
    int32 code = 1;
    string msg = 2;
    repeated Article article = 3; //资讯
    int32 count = 4; //总条数
    int32 totalPages = 5; //总页数
}

//获取资讯详情，并记录浏览相关信息
message GetArticleRequest {
    int32 artId = 1;
    int32 ownerId = 2;
    int32 userId = 3;
    int32 type = 4;
}

message GetArticleResponse {
    int32 code = 1;
    string msg = 2;
    Article article = 3; //资讯
}

message GetPdfInfoRequest {
    int32 infoId = 1; //快讯id
}

message GetPdfInfoResponse {
    Result result = 1;
    bytes pdf = 2;
}

//获取医学界文章分页列表request
message GetArticlesPagedListRequest {
    int32 terminal = 1;//终端类型
    string keyword = 2;//keyword for searching
    int32 pageIndex = 3;
    int32 pageSize = 4;
    int32 userId = 5;
    int32 providerId = 6;
}

//医学界文章
message ArticleItem {
    int32 artId = 1; //资讯ID
    string title = 2; //资讯标题
    int32 viewCount = 3; //浏览数
    int32 type = 4; //1-图文，2-视频， 3-文件
    string digest = 5;//摘要
    int32 price = 6;//价格
    string previewUrl = 7;//预览图
    string author = 8;//作者
    string jobTitle = 9;//职称
    string dept = 10;//科室
    string hospital = 11;//医院
    string publishTime = 12;//发表时间
    int32 hasPaid = 13;//是否已购
    string diagnosis = 14;//诊断分类
    int32 likeCount = 15;//点赞数
    int32 videoStatus = 16;//视频转码状态：0-转码中；1-成功；2-失败
    string videoConvertingRemark = 17;//视频转码备注
    int32 auditStatus = 18;//审核状态：0-审核中;1-审核不通过;2-审核通过
}

//获取医学界文章分页列表response
message GetArticlesPagedListResponse {
    int32 code = 1;
    string msg = 2;
    repeated ArticleItem article = 3; //文章
    int32 count = 4; //总条数
    int32 totalPages = 5; //总页数
}

message GetArticleDetailRequest {
    int32 artId = 1;
    int32 userId = 2;
    int32 terminal = 3;
}

message ArticleComment {
    int32 id = 1;
    int32 articleId = 2;
    int32 replyId = 3;
    int32 parentId = 4;
    string content = 5;
    int32 userId = 6;
    string createTime = 7;
    string updateTime = 8;
    string name = 9;
    string jobTitle = 10;
    string dept = 11;
    string hospital = 12;
    string avatar = 13;
    repeated ArticleComment replies = 14;
    string replyName = 15;//回复的二级评论评论者名称
}

message GetCommentsRequest {
    int32 articleId = 1;
    int32 pageIndex = 2;
    int32 pageSize = 3;
    int32 userId = 4;
}

message GetCommentsResponse {
    int32 code = 1;
    string msg = 2;
    repeated ArticleComment comments = 3; //评论
    int32 count = 4; //总条数
    int32 totalPages = 5; //总页数
}

message AddCommentRequest {
    int32 articleId = 1;
    int32 replyId = 2;
    int32 parentId = 3;
    string content = 4;
    int32 userId = 5;
}

message GetArticleDetailResponse {
    int32 artId = 1;
    string title = 2;
    string publishTime = 3;
    int32 viewCount = 4;
    string author = 5;
    string dept = 6;
    string hospital = 7;
    string jobTitle = 8;
    string urlData = 9;
    int32 type = 10;
    string content = 11;
    int32 hasPaid = 12;
    int32 commentCounts = 13;
    int32 isFavorite = 14;
    int32 code = 15;
    string msg = 16;
    string extra = 17;
    string previewUrl = 18;
    int32 isLike = 19;
    int32 likeCount = 20;
    repeated string likedUsers = 21;//点赞用户名
    string qrCode1Url = 22;
    string qrCode2Url = 23;
    string qrCode1Remark = 24;
    string qrCode2Remark = 25;
}

message OperateFavoritesRequest {
    int32 artId = 1;
    int32 userId = 2;
    int32 isFavorite = 3;
}

message GetArticlesFavoritesRequest {
    int32 userId = 1;
    int32 pageIndex = 2;
    int32 pageSize = 3;
}

message GetPaidArticlesRequest {
    int32 userId = 1;
    int32 pageIndex = 2;
    int32 pageSize = 3;
}

message GetPublishArticlesRequest {
    int32 userId = 1;
    int32 pageIndex = 2;
    int32 pageSize = 3;
    int32 currentUserId = 4;
    int32 terminal = 5;
}

message PublishMedicalFieldArticleRequest {
    int32 providerId = 1;
    string title = 2;
    string content = 3;
    string previewUrl = 4;
    string qrCode1Url = 5;
    string qrCode2Url = 6;
    string qrCode1Remark = 7;
    string qrCode2Remark = 8;
}

message PublishMedicalFieldArticleResponse {
    Result result = 1;
    int32 articleId = 2;
}

message PublishMedicalFieldVideoRequest {
    int32 providerId = 1;
    string title = 2;
    string videoUrl = 3;
    string previewUrl = 4;
    string specialistIntro = 5;
    string contentIntro = 6;
    string qrCode1Url = 7;
    string qrCode2Url = 8;
    string qrCode1Remark = 9;
    string qrCode2Remark = 10;
}

message PublishMedicalFieldVideoResponse {
    Result result = 1;
    int32 articleId = 2;
}

message EditArticleSettingRequest {
    int32 articleId = 1;
    int32 price = 2;
    int32 pushType = 3;
    int32 userId = 4;
    string diagnosisType = 5;//诊断分类
}

message GetArticleSettingRequest {
    int32 articleId = 1;
}

message GetLastArticleSettingRequest {
    int32 userId = 1;
}

message GetArticleSettingResponse {
    Result result = 1;
    int32 pushType = 2;
    int32 price = 3;
    string diagnosisType = 4;//诊断分类
}

message CreateOrderRequest {
    int32 userId = 1;
    int32 articleId = 2;
}

message CreateOrderResponse {
    Result result = 1;
    int32 orderId = 2;
    string orderNo = 3;
    int32 amount = 4;
}

message OrderPaymentCallbackNotifyRequest {
    string orderNo = 1;
    int32 orderId = 2;
    int32 payType = 3; //1: 微信; 2: 管理员线下收费
    string custom = 4; //回发创建单时设置的自定义数据
    int32 bizId = 5;
    string paymentNo = 6; //订单中心支付流水号
    int32 userId = 7;//用户id
    string prepayId = 8; //本次支付微信 prepay_id
    int32 terminal = 9;  //发起支付终端
    string openid = 10; //完成微信支付的微信用户 openid
    int32 paymentChannel = 11;
    string oneTimeCustom = 12;//本次操作自定义数据
}

message OperateLikeRequest {
    int32 artId = 1;
    int32 userId = 2;
    int32 isLike = 3;
}

message GetLikedUsersRequest {
    int32 articleId = 1;
}

message LikedUserInfo {
    int32 id = 1;
    string name = 2;
    string avatar = 3;
    int32 isVirtual = 4;//是否真实点赞用户，0-真实用户，1-虚拟用户
    int32 userType = 5;//用户类型
}

message GetLikedUsersResponse {
    Result result = 1;
    repeated LikedUserInfo likedUsers = 2;
}

message ConvertVideoCallbackRequest {
    string newVideoUrl = 1;
    int32 articleId = 2;
    int32 status = 3;
    string remark = 4;
}

//药商及代表相关服务        // 对应 rpc 项目的 ArticleServiceImpl 类
service ArticleService {

    //得到用户资讯列表  created by daiyihua
    rpc getArticles (GetArticlesRequest) returns (GetArticlesResponse);

    //根据资讯ID得到资讯内容  created by daiyihua
    rpc getArticleById (GetArticleByIdRequest) returns (GetArticleByIdResponse);

    //得到药商推送给医生的资讯列表  created by daiyihua
    rpc getDoctorArticles (GetArticlesRequest) returns (GetArticlesResponse);

    //根据资讯ID得到资讯内容  created by daiyihua
    rpc getDoctorArticleById (GetArticleByIdRequest) returns (GetArticleByIdResponse);

    //获取医生显示的文章列表
    rpc getDisplayArticleList (GetDisplayArticleListRequest) returns (GetDisplayArticleListResponse);

    //获取资讯详情，并记录浏览相关信息
    rpc getArticle (GetArticleRequest) returns (GetArticleResponse);

    //获取快讯分类列表
    rpc getClassifiedArticles (GetClassifiedArticlesRequest) returns (GetClassifiedArticlesResponse);

    //获取快讯pdf
    rpc getPdfInfo (GetPdfInfoRequest) returns (GetPdfInfoResponse);

    //获取药商推送给医生的快讯分类列表
    rpc getDoctorClassifiedArticles (GetClassifiedArticlesRequest) returns (GetClassifiedArticlesResponse);

    //获取医学界文章分页列表
    rpc getArticlesPagedList (GetArticlesPagedListRequest) returns (GetArticlesPagedListResponse);

    //获取医学界文章详情
    rpc getArticleDetail (GetArticleDetailRequest) returns (GetArticleDetailResponse);
    //处理收藏/取消收藏文章
    rpc operateArticleFavorite (OperateFavoritesRequest) returns (Result);
    //获取收藏列表
    rpc getArticlesFavoritesList (GetArticlesFavoritesRequest) returns (GetArticlesPagedListResponse);
    //获取已购列表
    rpc getPaidArticles (GetPaidArticlesRequest) returns (GetArticlesPagedListResponse);
    //获取发表列表
    rpc getPublishArticles (GetPublishArticlesRequest) returns (GetArticlesPagedListResponse);
    //发表医学界文章
    rpc publishMedicalFieldArticle (PublishMedicalFieldArticleRequest) returns (PublishMedicalFieldArticleResponse);
    //发表医学界视频
    rpc publishMedicalFieldVideo (PublishMedicalFieldVideoRequest) returns (PublishMedicalFieldVideoResponse);
    //添加评论
    rpc addComment (AddCommentRequest) returns (Result);
    //获取评论列表
    rpc getCommentList (GetCommentsRequest) returns (GetCommentsResponse);
    //修改文章设置
    rpc editArticleSetting (EditArticleSettingRequest) returns (Result);
    //获取文章设置
    rpc getArticleSetting (GetArticleSettingRequest) returns (GetArticleSettingResponse);
    //获取上一次的文章设置
    rpc getLastArticleSetting (GetLastArticleSettingRequest) returns (GetArticleSettingResponse);
    //创建订单
    rpc createOrder (CreateOrderRequest) returns (CreateOrderResponse);
    //订单支付回调
    rpc orderPaymentCallbackNotify (OrderPaymentCallbackNotifyRequest) returns (Result);
    //文章点赞操作
    rpc operateArticleLike (OperateLikeRequest) returns (Result);
    //获取点赞列表
    rpc getLikedUsers (GetLikedUsersRequest) returns (GetLikedUsersResponse);
    //视频转换后的回调方法
    rpc convertVideoCallback (ConvertVideoCallbackRequest) returns (Result);
}
