article.api 3.9 KB
syntax = "v1"

info(
	title: "文章内容处理"
	desc: "编辑处理文章内容"
	author: "author"
	email: "email"
	version: "v1"
)

// 坐标地点描述
type Location {
	Longitude float64 `json:"longitude,optional"` //经度
	Latitude  float64 `json:"latitude,optional"`  //纬度
	Descript  string  `json:"descript,optional"`  //地点描述
}

// 人员的简单展示信息
type Author {
	Id       int64  `json:"id"`       // 人员id
	Name     string `json:"name"`     // 人员的名字
	Avatar   string `json:"avatar"`   // 人员头像URL
	Group    string `json:"group"`    // 人员的分组
	Position string `json:"position"` // 职位
	Company  string `json:"company"`  // 公司
}

//小程序端创建发布文章
type (
	MiniArticleCreateRequest {
		Title     string   `json:"title"`              //标题
		Section   []string `json:"section"`            //文章的文本内容
		AuthorId  int64    `json:"authorId,optional"`  //发布人id
		Images    []string `json:"images,optional"`    //图片
		WhoRead   []int64  `json:"whoRead,optional"`   //谁可查看
		WhoReview []int64  `json:"whoReview,optional"` //谁可评论
		Location  Location `json:"location,optional"`  //定位坐标
	}
	MiniArticleCreateResponse {
		Id int64 `json:"id"`
	}
)

//小程序端查看文章的详情
type (
	MiniArticleGetRequest {
		Id        int64 `path:"id"` //id
		CompanyId int64 `path:"-"`
	}
	MiniArticleGetResponse {
		Id           int64            `json:"id"`           //id
		Title        string           `json:"title"`        //标题
		AuthorId     int64            `json:"authorId"`     //发布人id
		Author       Author           `json:"author"`       //发布人
		CreatedAt    int64            `json:"createdAt"`    //文章的发布时间
		Section      []ArticleSection `json:"section"`      //文章的文本内容
		Images       []string         `json:"images"`       //图片
		WhoRead      []int64          `json:"whoRead"`      //谁可查看
		WhoReview    []int64          `json:"whoReview"`    //谁可评论
		Location     Location         `json:"location"`     //定位坐标
		CountLove    int              `json:"countLove"`    // 点赞数量
		CountComment int              `json:"countComment"` // 评论数量
		CountRead    int              `json:"countRead"`    // 浏览数量
		Show         int              `json:"show"`         // 评论的展示状态(0显示、1不显示)
	}
	ArticleSection {
		Id           int64  `json:"id"`           //段落id
		Content      string `json:"content"`      // 文本内容
		SortBy       int    `json:"sortBy"`       // 排序
		TotalComment int    `json:"totalComment"` // 评论的数量
	}
)

// 获取我的发文章记录
type (
	MiniArticleSearchMeRequest {
		AuthorId  int64 `json:"-"`
		CompanyId int64 `json:"-"`
		Page      int   `json:"page"`
		Size      int   `json:"size"`
	}

	MiniArticleSearchMeResponse {
		Total int               `json:"total"`
		List  []ArticleSearchMe `json:"list"`
	}

	ArticleSearchMe {
		Id           int64    `json:"id"`           //id
		Title        string   `json:"title"`        //标题
		Images       []string `json:"images"`       //图片
		CreatedAt    int64    `json:"createdAt"`    //文章的创建日期
		CountLove    int      `json:"countLove"`    //点赞数量
		CountComment int      `json:"CountComment"` //评论数量
		Show         int      `json:"show"`         //是否隐藏 [0显示、1不显示]
	}
)

// 小程序接口
@server(
	prefix: v1/mini
	group: article
	jwt: MiniAuth
)
service Core {
	@doc "小程序创建发布内容"
	@handler MiniCreateArticle
	post /article (MiniArticleCreateRequest) returns (MiniArticleCreateResponse)
	@doc "小程序获取我发布的文章"
	@handler MiniArticleSearchMe
	post /article/search/me (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
	@doc "小程序获取文章内容详情"
	@handler MiniGetArticle
	get /article/:id (MiniArticleGetRequest) returns (MiniArticleGetResponse)
}