作者 tangxvhui

新建接口

... ... @@ -38,12 +38,27 @@ service Core {
@doc "小程序创建文章进草稿箱"
@handler MiniCreateArticleDraft
post /article_draft (MiniArticleSearchMeRequest) returns (MiniArticleSearchMeResponse)
post /article_draft (MiniArticleDraftCreateRequest) returns (MiniArticleDraftCreateResponse)
@doc "小程序更新文章草稿"
@handler MiniUpdateArticleDraft
put /article_draft (MiniArticleDraftUpdateRequest) returns (MiniArticleDraftUpdateResponse)
@doc "小程序获取我的草稿箱列表"
@handler MiniSearchArticleDraftMe
post /article_draft/search/me (MiniArticleDraftSearchMeRequest) returns (MiniArticleDraftSearchMeResponse)
@doc "小程序获取我的草稿内容"
@handler MiniGetArticleDraftMe
get /article_draft/me/:id (MiniArticleDraftGetMeRequest) returns (MiniArticleDraftGetMeResponse)
@doc "小程序获取我的草稿内容"
@handler MiniDeleteArticleDraftMe
delete /article_draft/me/:id (MiniArticleDraftDeleteMeRequest) returns (MiniArticleDraftDeleteMeResponse)
@doc "小程序获取文章的编辑记录"
@handler MiniArticleBackupSearch
post /article_backup/search (MiniArticleBackupSearchRequest) returns (MiniArticleBackupSearchResponse)
}
// 管理后台接口
... ...
... ... @@ -160,16 +160,106 @@ type (
}
)
//保存文章到草稿箱
//创建文章到草稿箱
type (
MiniArticleDraftCreateRequest {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
MiniArticleDraftCreateResponse struct{}
MiniArticleDraftCreateResponse {
Id int64 `json:"id"`
}
)
//更新文章草稿
type (
MiniArticleDraftUpdateRequest {
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
MiniArticleDraftUpdateResponse {
Id int64 `json:"id"`
}
)
//获取我的草稿列表
type (
MiniArticleDraftSearchMeRequest {
CompanyId int64 `json:",optional"` // 公司id
AuthorId int64 `json:",optional"` // 发布人
Page int `json:"page"`
Size int `json:"size"`
}
MiniArticleDraftSearchMeResponse {
Total int64 `json:"total"`
List []MiniArticleDraftItem `json:"list"`
}
MiniArticleDraftItem {
Id int64 `json:"id"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
}
)
//获取我的草稿内容
type (
MiniArticleDraftGetMeRequest {
CompanyId int64 `json:",optional"` // 公司id
AuthorId int64 `json:",optional"` // 发布人
Page int `json:"page"`
Size int `json:"size"`
}
MiniArticleDraftGetMeResponse {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
)
//删除我的草稿内容
type (
MiniArticleDraftDeleteMeRequest {
CompanyId int64 `path:",optional"` // 公司id
AuthorId int64 `path:",optional"` // 发布人
Id int64 `path:"id"`
}
MiniArticleDraftDeleteMeResponse {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
)
//管理后台获取文章详情
... ...
... ... @@ -7,22 +7,23 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
func MiniCreateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleSearchMeRequest
var req types.MiniArticleDraftCreateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniCreateArticleDraftLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.AuthorId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniCreateArticleDraft(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniDeleteArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleDraftDeleteMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniDeleteArticleDraftMeLogic(r.Context(), svcCtx)
resp, err := l.MiniDeleteArticleDraftMe(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniGetArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleDraftGetMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniGetArticleDraftMeLogic(r.Context(), svcCtx)
resp, err := l.MiniGetArticleDraftMe(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniSearchArticleDraftMeHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleDraftSearchMeRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniSearchArticleDraftMeLogic(r.Context(), svcCtx)
resp, err := l.MiniSearchArticleDraftMe(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
package article
import (
"net/http"
"github.com/zeromicro/go-zero/rest/httpx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/article"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
)
func MiniUpdateArticleDraftHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
var req types.MiniArticleDraftUpdateRequest
if err := httpx.Parse(r, &req); err != nil {
httpx.ErrorCtx(r.Context(), w, err)
return
}
l := article.NewMiniUpdateArticleDraftLogic(r.Context(), svcCtx)
resp, err := l.MiniUpdateArticleDraft(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
}
}
... ...
... ... @@ -224,6 +224,26 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
Handler: article.MiniCreateArticleDraftHandler(serverCtx),
},
{
Method: http.MethodPut,
Path: "/article_draft",
Handler: article.MiniUpdateArticleDraftHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_draft/search/me",
Handler: article.MiniSearchArticleDraftMeHandler(serverCtx),
},
{
Method: http.MethodGet,
Path: "/article_draft/me/:id",
Handler: article.MiniGetArticleDraftMeHandler(serverCtx),
},
{
Method: http.MethodDelete,
Path: "/article_draft/me/:id",
Handler: article.MiniDeleteArticleDraftMeHandler(serverCtx),
},
{
Method: http.MethodPost,
Path: "/article_backup/search",
Handler: article.MiniArticleBackupSearchHandler(serverCtx),
... ...
... ... @@ -5,6 +5,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -23,8 +25,43 @@ func NewMiniCreateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceCont
}
}
func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleSearchMeRequest) (resp *types.MiniArticleSearchMeResponse, err error) {
// todo: add your logic here and delete this line
// 保存文章进草稿箱
func (l *MiniCreateArticleDraftLogic) MiniCreateArticleDraft(req *types.MiniArticleDraftCreateRequest) (resp *types.MiniArticleDraftCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
newDraft := domain.ArticleDraft{
Id: 0,
CompanyId: req.CompanyId,
CreatedAt: 0,
UpdatedAt: 0,
DeletedAt: 0,
Version: 0,
Template: req.Template,
Content: req.Content,
AuthorId: req.AuthorId,
Title: req.Title,
Images: []domain.Image{},
WhoRead: req.WhoRead,
WhoReview: req.WhoReview,
Location: domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
},
}
for _, val := range req.Images {
newDraft.Images = append(newDraft.Images, domain.Image{
Url: val,
})
}
_, err = l.svcCtx.ArticleDraftRepository.Insert(l.ctx, conn, &newDraft)
if err != nil {
return nil, xerr.NewErrMsgErr("保存草稿失败", err)
}
resp = &types.MiniArticleDraftCreateResponse{
Id: newDraft.Id,
}
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniDeleteArticleDraftMeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniDeleteArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniDeleteArticleDraftMeLogic {
return &MiniDeleteArticleDraftMeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniDeleteArticleDraftMeLogic) MiniDeleteArticleDraftMe(req *types.MiniArticleDraftDeleteMeRequest) (resp *types.MiniArticleDraftDeleteMeResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniGetArticleDraftMeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniGetArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniGetArticleDraftMeLogic {
return &MiniGetArticleDraftMeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniGetArticleDraftMeLogic) MiniGetArticleDraftMe(req *types.MiniArticleDraftGetMeRequest) (resp *types.MiniArticleDraftGetMeResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniSearchArticleDraftMeLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniSearchArticleDraftMeLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniSearchArticleDraftMeLogic {
return &MiniSearchArticleDraftMeLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.MiniArticleDraftSearchMeRequest) (resp *types.MiniArticleDraftSearchMeResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type MiniUpdateArticleDraftLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
func NewMiniUpdateArticleDraftLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniUpdateArticleDraftLogic {
return &MiniUpdateArticleDraftLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *MiniUpdateArticleDraftLogic) MiniUpdateArticleDraft(req *types.MiniArticleDraftUpdateRequest) (resp *types.MiniArticleDraftUpdateResponse, err error) {
// todo: add your logic here and delete this line
return
}
... ...
... ... @@ -147,13 +147,91 @@ type MiniArticleMarkUserReadResponse struct {
}
type MiniArticleDraftCreateRequest struct {
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
type MiniArticleDraftCreateResponse struct {
Id int64 `json:"id"`
}
type MiniArticleDraftUpdateRequest struct {
Id int64 `json:"id"`
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
type MiniArticleDraftUpdateResponse struct {
Id int64 `json:"id"`
}
type MiniArticleDraftSearchMeRequest struct {
CompanyId int64 `json:",optional"` // 公司id
AuthorId int64 `json:",optional"` // 发布人
Page int `json:"page"`
Size int `json:"size"`
}
type MiniArticleDraftSearchMeResponse struct {
Total int64 `json:"total"`
List []MiniArticleDraftItem `json:"list"`
}
type MiniArticleDraftItem struct {
Id int64 `json:"id"`
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
}
type MiniArticleDraftGetMeRequest struct {
CompanyId int64 `json:",optional"` // 公司id
AuthorId int64 `json:",optional"` // 发布人
Page int `json:"page"`
Size int `json:"size"`
}
type MiniArticleDraftGetMeResponse struct {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
type MiniArticleDraftDeleteMeRequest struct {
CompanyId int64 `path:",optional"` // 公司id
AuthorId int64 `path:",optional"` // 发布人
Id int64 `path:"id"`
}
type MiniArticleDraftDeleteMeResponse struct {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
WhoReview []int64 `json:"whoReview"` // 评论人
Location Location `json:"location"` // 坐标
}
type SystemArticleGetRequest struct {
... ...