作者 郑周

Merge remote-tracking branch 'origin/dev' into dev

... ... @@ -42,12 +42,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,99 @@ type (
}
)
//保存文章到草稿箱
//创建文章到草稿箱
type (
MiniArticleDraftCreateRequest {
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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、归纳式
Section []string `json:"section"` // 填写的内容
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、归纳式
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`
}
)
//获取我的草稿内容
type (
MiniArticleDraftGetMeRequest {
CompanyId int64 `path:",optional"` // 公司id
AuthorId int64 `path:",optional"` // 发布人
Id int64 `path:"id"`
}
MiniArticleDraftGetMeResponse {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
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"` //
}
)
type (
... ...
... ... @@ -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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
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)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.AuthorId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniDeleteArticleDraftMe(&req)
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 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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
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)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.AuthorId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniSearchArticleDraftMe(&req)
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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/result"
)
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)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.AuthorId = token.UserId
req.CompanyId = token.CompanyId
resp, err := l.MiniUpdateArticleDraft(&req)
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -254,6 +254,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),
... ...
... ... @@ -83,6 +83,7 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
if err != nil {
return err
}
//增加浏览计数
err = l.svcCtx.ArticleRepository.IncreaseCountRead(ctx, c, 1, articleInfo)
return err
}, true)
... ...
... ... @@ -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.Section,
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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"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) {
var conn = l.svcCtx.DefaultDBConn()
draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("删除草稿失败", err)
}
if draftInfo.AuthorId != req.AuthorId {
if err != nil {
return nil, xerr.NewErrMsg("删除草稿失败")
}
}
_, err = l.svcCtx.ArticleDraftRepository.Delete(l.ctx, conn, draftInfo)
if err != nil {
return nil, xerr.NewErrMsgErr("删除草稿失败", err)
}
resp = &types.MiniArticleDraftDeleteMeResponse{
Id: draftInfo.Id,
}
return resp, nil
}
... ...
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"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"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) {
var conn = l.svcCtx.DefaultDBConn()
draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("获取草稿失败", err)
}
if draftInfo.AuthorId != req.AuthorId {
if err != nil {
return nil, xerr.NewErrMsg("获取草稿失败")
}
}
resp = &types.MiniArticleDraftGetMeResponse{
Id: draftInfo.Id,
Template: draftInfo.Template,
Section: draftInfo.Content,
Title: draftInfo.Title,
Images: []string{},
WhoRead: draftInfo.WhoRead,
WhoReview: draftInfo.WhoReview,
Location: types.Location{
Longitude: draftInfo.Location.Longitude,
Latitude: draftInfo.Location.Latitude,
Descript: draftInfo.Location.Descript,
},
}
for _, val := range draftInfo.Images {
resp.Images = append(resp.Images, val.Url)
}
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"
"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"
)
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) {
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().
WithOffsetLimit(req.Page, req.Size).
MustWithKV("authorId", req.AuthorId)
cnt, draftList, err := l.svcCtx.ArticleDraftRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取草稿列表失败", err)
}
resp = &types.MiniArticleDraftSearchMeResponse{
Total: cnt,
List: make([]types.MiniArticleDraftItem, len(draftList)),
}
for i := range draftList {
images := []string{}
for _, val := range draftList[i].Images {
images = append(images, val.Url)
}
resp.List[i] = types.MiniArticleDraftItem{
Id: draftList[i].Id,
Template: draftList[i].Template,
Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
}
}
return resp, nil
}
... ...
... ... @@ -233,7 +233,7 @@ func (l *MiniSetUserLikeLogic) setUserLikeArticle(req *types.MiniSetUserLikeRequ
CommentAuthor: 0,
UserId: req.UserId,
}
// 去除点赞标识
// 添加点赞标识
_, err = l.svcCtx.UserLoveFlagRepository.Insert(ctx, c, &flagInfo)
if err != nil {
return err
... ...
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"
"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"
)
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) {
var conn = l.svcCtx.DefaultDBConn()
draftInfo, err := l.svcCtx.ArticleDraftRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsgErr("更新草稿失败", err)
}
if draftInfo.AuthorId != req.AuthorId {
if err != nil {
return nil, xerr.NewErrMsg("更新草稿失败")
}
}
draftInfo.Content = req.Section
draftInfo.Title = req.Title
draftInfo.Location = domain.Location{
Longitude: req.Location.Longitude,
Latitude: req.Location.Latitude,
Descript: req.Location.Descript,
}
draftInfo.WhoRead = req.WhoRead
draftInfo.WhoReview = req.WhoReview
draftInfo.Images = []domain.Image{}
for _, val := range req.Images {
draftInfo.Images = append(draftInfo.Images, domain.Image{
Url: val,
})
}
_, err = l.svcCtx.ArticleDraftRepository.Update(l.ctx, conn, draftInfo)
if err != nil {
return nil, xerr.NewErrMsgErr("更新草稿失败", err)
}
resp = &types.MiniArticleDraftUpdateResponse{
Id: draftInfo.Id,
}
return
}
... ...
... ... @@ -147,13 +147,84 @@ type MiniArticleMarkUserReadResponse struct {
}
type MiniArticleDraftCreateRequest struct {
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Content []string `json:"content"` // 填写的内容
Title string `json:"title"` //标题
Images []string `json:"images"` //图片
CompanyId int64 `json:",optional"`
AuthorId int64 `json:",optional"` // 发布人
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"section"` // 填写的内容
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、归纳式
Section []string `json:"section"` // 填写的内容
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、归纳式
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
CreatedAt int64 `json:"createdAt"`
}
type MiniArticleDraftGetMeRequest struct {
CompanyId int64 `path:",optional"` // 公司id
AuthorId int64 `path:",optional"` // 发布人
Id int64 `path:"id"`
}
type MiniArticleDraftGetMeResponse struct {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
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"` //
}
type MiniArticleMarkListRequest struct {
... ...
... ... @@ -2,6 +2,7 @@ package models
import (
"fmt"
"time"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
... ... @@ -31,13 +32,14 @@ func (m *ArticleDraft) TableName() string {
}
func (m *ArticleDraft) BeforeCreate(tx *gorm.DB) (err error) {
// m.CreatedAt = time.Now().Unix()
// m.UpdatedAt = time.Now().Unix()
nowTime := time.Now().Unix()
m.CreatedAt = nowTime
m.UpdatedAt = nowTime
return
}
func (m *ArticleDraft) BeforeUpdate(tx *gorm.DB) (err error) {
// m.UpdatedAt = time.Now().Unix()
m.UpdatedAt = time.Now().Unix()
return
}
... ...
... ... @@ -6,6 +6,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gorm.io/gorm"
"gorm.io/plugin/soft_delete"
)
type UserReadArticle struct {
... ... @@ -13,6 +14,7 @@ type UserReadArticle struct {
CreatedAt int64
UpdatedAt int64
DeletedAt int64
IsDel soft_delete.DeletedAt `gorm:"softDelete:flag,DeletedAtField:DeletedAt"`
Version int
CompanyId int64
UserId int64
... ...