作者 tangxvhui

暂存

... ... @@ -301,14 +301,16 @@ type (
TagId int64 `json:"tagId"` // 标签id
}
MiniAllArticleTagResponse{
TagGroup []string `json:"tagGroup"`
Tags []ArticleTagItem `json:"tags"`
TagGroup []ArticleTagGroup `json:"tagGroup"`
}
ArticleTagGroup {
Group string `json:"group"`
Tags []ArticleTagItem `json:"tags"`
}
ArticleTagItem {
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Name string `json:"name"`
}
)
... ...
... ... @@ -7,6 +7,8 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/comment"
"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 MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,10 @@ func MiniArticleCommentAtWhoHandler(svcCtx *svc.ServiceContext) http.HandlerFunc
}
l := comment.NewMiniArticleCommentAtWhoLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniArticleCommentAtWho(&req)
if err != nil {
httpx.ErrorCtx(r.Context(), w, err)
} else {
httpx.OkJsonCtx(r.Context(), w, resp)
}
result.HttpResult(r, w, resp, err)
}
}
... ...
... ... @@ -5,6 +5,7 @@ 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/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -24,7 +25,21 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
// todo: add your logic here and delete this line
var conn = l.svcCtx.DefaultDBConn()
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取评论人信息失败", err)
}
if articleInfo.CompanyId != req.CompanyId {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
// userList := []*domain.User{}
// if len(articleInfo.WhoRead) == 0 {
// return
// }
return
}
... ...
... ... @@ -11,6 +11,7 @@ import (
"text/template"
"github.com/samber/lo"
"github.com/zeromicro/go-zero/core/logx"
)
... ... @@ -87,11 +88,15 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
for _, val := range req.AtWho {
uids = append(uids, val.Id)
}
uids = lo.Uniq(uids)
queryOption := domain.NewQueryOptions().WithFindOnly().WithKV("ids", uids)
_, atWhoList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("检查@的人员失败", err)
}
if len(uids) != len(atWhoList) {
return nil, xerr.NewErrMsg("检查@的人员失败")
}
}
// 处理文本内容
content := template.HTMLEscapeString(req.Content)
... ...
... ... @@ -821,8 +821,12 @@ type MiniAllArticleTagRequest struct {
}
type MiniAllArticleTagResponse struct {
TagGroup []string `json:"tagGroup"`
Tags []ArticleTagItem `json:"tags"`
TagGroup []ArticleTagGroup `json:"tagGroup"`
}
type ArticleTagGroup struct {
Group string `json:"group"`
Tags []ArticleTagItem `json:"tags"`
}
type ArticleTagItem struct {
... ...
... ... @@ -8,6 +8,7 @@ import (
"gorm.io/gorm"
)
// 保存文章和标签的关系,主要用于分组统计用
type ArticleAndTag struct {
Id int64 // 唯一标识
CompanyId int64 `json:"companyId"`
... ... @@ -28,7 +29,7 @@ func (m *ArticleAndTag) BeforeCreate(tx *gorm.DB) (err error) {
}
func (m *ArticleAndTag) BeforeUpdate(tx *gorm.DB) (err error) {
// m.UpdatedAt = time.Now().Unix()
m.UpdatedAt = time.Now().Unix()
return
}
... ...
... ... @@ -22,6 +22,7 @@ type ArticleTag struct {
Name string // 标签名称
Group string // 标签分类
Remark string // 备注
SortBy int64 // 顺序
}
func (m *ArticleTag) TableName() string {
... ...
... ... @@ -19,6 +19,7 @@ type ArticleTag struct {
Name string `json:"name"` // 标签名称
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
SortBy int64 `json:"sortBy"` // 顺序
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
... ...