作者 tangxvhui

处理定性标签

... ... @@ -107,6 +107,7 @@ type (
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
Position string `json:"position"` // 职位
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
)
... ... @@ -297,8 +298,6 @@ type (
MiniAllArticleTagRequest{
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
MiniAllArticleTagResponse{
TagGroup []ArticleTagGroup `json:"tagGroup"`
... ... @@ -311,6 +310,7 @@ type (
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Image string `json:"image"`
}
)
... ...
... ... @@ -78,8 +78,9 @@ type (
}
CommentAtWho {
Id int64 `json:"id"`
Name string `json:"name,optional"`
Id int64 `json:"id"`
Name string `json:"name,optional"`
FirstLetter string `json:"firstLetter,optional"`
}
MiniCreateArticleCommentResponse {
Id int64 `json:"id"`
... ...
... ... @@ -29,4 +29,4 @@ DB:
ApiAuth:
Name: ApiAuth
Host: http://digital-platform-dev.fjmaimaimai.com
Timeout: 0s
\ No newline at end of file
Timeout: 0s
... ...
... ... @@ -7,6 +7,8 @@ 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 MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
... ... @@ -18,11 +20,10 @@ func MiniAllArticleTagHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
}
l := article.NewMiniAllArticleTagLogic(r.Context(), svcCtx)
token := contextdata.GetUserTokenFromCtx(r.Context())
req.CompanyId = token.CompanyId
req.UserId = token.UserId
resp, err := l.MiniAllArticleTag(&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,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"
)
... ... @@ -24,7 +26,44 @@ func NewMiniAllArticleTagLogic(ctx context.Context, svcCtx *svc.ServiceContext)
}
func (l *MiniAllArticleTagLogic) MiniAllArticleTag(req *types.MiniAllArticleTagRequest) (resp *types.MiniAllArticleTagResponse, err error) {
// todo: add your logic here and delete this line
return
var conn = l.svcCtx.DefaultDBConn()
queryOption := domain.NewQueryOptions().WithFindOnly()
_, tagList, err := l.svcCtx.ArticleTagRepository.Find(l.ctx, conn, req.CompanyId, queryOption)
if err != nil {
return nil, xerr.NewErrMsgErr("获取标签列表失败", err)
}
// 合并输出数据
var group []string
tagMap := map[string][]types.ArticleTagItem{}
for _, val := range tagList {
if m, ok := tagMap[val.Group]; ok {
m = append(m, types.ArticleTagItem{
Id: val.Id,
Group: val.Group,
Name: val.Name,
Image: val.Image.Url,
})
tagMap[val.Group] = m
} else {
group = append(group, val.Group)
tagMap[val.Group] = []types.ArticleTagItem{
{
Id: val.Id,
Group: val.Group,
Name: val.Name,
Image: val.Image.Url,
},
}
}
}
resp = &types.MiniAllArticleTagResponse{
TagGroup: make([]types.ArticleTagGroup, 0),
}
for i := range group {
resp.TagGroup = append(resp.TagGroup, types.ArticleTagGroup{
Group: group[i],
Tags: tagMap[group[i]],
})
}
return resp, nil
}
... ...
... ... @@ -71,6 +71,7 @@ func (l *MiniUserLikeArticleLogic) MiniUserLikeArticle(req *types.MiniUserLikeAr
if u, ok := userMap[val.UserId]; ok {
item.Name = u.Name
item.Avatar = u.Avatar
item.Position = u.Position
}
resp.List[i] = item
}
... ...
... ... @@ -2,9 +2,12 @@ package comment
import (
"context"
"sort"
"strings"
"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"
... ... @@ -24,6 +27,7 @@ func NewMiniArticleCommentAtWhoLogic(ctx context.Context, svcCtx *svc.ServiceCon
}
}
// MiniArticleCommentAtWho 填写评估时@谁 的可选择者列表
func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniArticleCommentAtWhoRequest) (resp *types.MiniArticleCommentAtWhoResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
articleInfo, err := l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, req.ArticleId)
... ... @@ -35,11 +39,42 @@ func (l *MiniArticleCommentAtWhoLogic) MiniArticleCommentAtWho(req *types.MiniAr
return resp, nil
}
// userList := []*domain.User{}
// if len(articleInfo.WhoRead) == 0 {
var userList []*domain.User
if len(articleInfo.WhoRead) == 0 {
//获取所有人
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("companyId", articleInfo.CompanyId)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
} else {
queryOption := domain.NewQueryOptions().WithFindOnly().MustWithKV("ids", articleInfo.WhoRead)
_, userList, err = l.svcCtx.UserRepository.Find(l.ctx, conn, queryOption)
if err != nil {
resp = &types.MiniArticleCommentAtWhoResponse{}
return resp, nil
}
}
// return
// }
uList := make([]types.CommentAtWho, len(userList))
return
for i := range userList {
uList[i] = types.CommentAtWho{
Id: userList[i].Id,
Name: userList[i].Name,
FirstLetter: "",
}
for _, val := range userList[i].PinYinName {
uList[i].FirstLetter = strings.ToUpper(string(val))
break
}
}
sort.Slice(uList, func(i, j int) bool {
return uList[i].FirstLetter < uList[j].FirstLetter
})
resp = &types.MiniArticleCommentAtWhoResponse{
List: uList,
}
return resp, nil
}
... ...
... ... @@ -52,12 +52,12 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
return nil, xerr.NewErrMsg("没有评论权限")
}
//查看评论权限,
// if len(articleInfo.WhoReview) > 0 {
// ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
// if ok < 0 {
// return nil, xerr.NewErrMsg("没有评论权限")
// }
// }
if len(articleInfo.WhoReview) > 0 {
ok := lo.IndexOf(articleInfo.WhoReview, req.FromUserId)
if ok < 0 {
return nil, xerr.NewErrMsg("没有评论权限")
}
}
// 对段落进行评论
var selctionInfo *domain.ArticleSection
if req.SectionId > 0 {
... ...
... ... @@ -27,8 +27,9 @@ type MiniCreateArticleCommentRequest struct {
}
type CommentAtWho struct {
Id int64 `json:"id"`
Name string `json:"name,optional"`
Id int64 `json:"id"`
Name string `json:"name,optional"`
FirstLetter string `json:"firstLetter,optional"`
}
type MiniCreateArticleCommentResponse struct {
... ... @@ -656,6 +657,7 @@ type WhichUserLikeArticle struct {
UserId int64 `json:"userId"` // 人员id
Name string `json:"name"` // 人员名称
Avatar string `json:"avatar"` // 人员头像
Position string `json:"position"` // 职位
CreatedAt int64 `json:"createdAt"` // 点赞记录的时间
}
... ... @@ -818,8 +820,6 @@ type MiniArticleSetTagResponse struct {
type MiniAllArticleTagRequest struct {
CompanyId int64 `json:",optional"` // 公司id
UserId int64 `json:",optional"` // 公司id
ArticleId int64 `json:"articleId"` // 文章id
TagId int64 `json:"tagId"` // 标签id
}
type MiniAllArticleTagResponse struct {
... ... @@ -835,6 +835,7 @@ type ArticleTagItem struct {
Id int64 `json:"id"`
Group string `json:"group"`
Name string `json:"name"`
Image string `json:"image"`
}
type SystemArticleGetRequest struct {
... ...
... ... @@ -22,6 +22,7 @@ func Migrate(db *gorm.DB) {
&models.MessageSystem{},
&models.MessageBusiness{},
&models.Department{},
&models.ArticleAndTag{},
}
db.AutoMigrate(modelsList...)
... ...
... ... @@ -10,12 +10,12 @@ import (
// 保存文章和标签的关系,主要用于分组统计用
type ArticleAndTag struct {
Id int64 // 唯一标识
CompanyId int64 `json:"companyId"`
CreatedAt int64 `json:"createdAt,omitempty"`
UpdatedAt int64 `json:"updatedAt,omitempty"`
ArticleId int64 `json:"articleId"`
TagId int64 `json:"tagId"`
Id int64 `gorm:"primaryKey"` // 唯一标识
CompanyId int64
CreatedAt int64
UpdatedAt int64
ArticleId int64
TagId int64
}
func (m *ArticleAndTag) TableName() string {
... ...
... ... @@ -22,6 +22,7 @@ type ArticleTag struct {
Name string // 标签名称
Group string // 标签分类
Remark string // 备注
Other string // 其他内容
SortBy int64 // 顺序
}
... ...
... ... @@ -20,6 +20,7 @@ type ArticleTag struct {
Group string `json:"group"` // 标签分类
Remark string `json:"remark"` // 备注
SortBy int64 `json:"sortBy"` // 顺序
Other string `json:"other"` //
}
type ArticleTagRepository interface {
Insert(ctx context.Context, conn transaction.Conn, dm *ArticleTag) (*ArticleTag, error)
... ...