作者 yangfu

feat: 内容安全

... ... @@ -1013,6 +1013,64 @@
]
}
},
"v1/mini/message/subscribe/add": {
"post": {
"summary": "增加订阅消息次数",
"operationId": "miniMessageSubscribeAdd",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MessageSubscribeAddResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": " 增加消息订阅次数",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MessageSubscribeAddRequest"
}
}
],
"requestBody": {},
"tags": [
"message"
]
}
},
"v1/mini/message/subscribe/list": {
"post": {
"summary": "获取订阅消息次数",
"operationId": "miniMessageSubscribeList",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MessageSubscribeListResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": "订阅消息次数详情",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MessageSubscribeListRequest"
}
}
],
"requestBody": {},
"tags": [
"message"
]
}
},
"v1/mini/message/system": {
"post": {
"summary": "系统消息",
... ... @@ -1661,6 +1719,52 @@
]
}
},
"v1/mini/wechat/bind": {
"post": {
"summary": "绑定微信",
"operationId": "miniWechatBind",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniWechatBindResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/MiniWechatBindRequest"
}
}
],
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/mini/wechat/info": {
"get": {
"summary": "检测是否绑定微信",
"operationId": "miniWechatInfo",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/MiniWechatInfoResponse"
}
}
},
"requestBody": {},
"tags": [
"user"
]
}
},
"v1/system/account": {
"post": {
"summary": "系统新增账号",
... ... @@ -2623,6 +2727,89 @@
]
}
},
"v1/system/article_security/audit": {
"post": {
"summary": "内容安全-审核",
"operationId": "articleSecurityAudit",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleSecurityAuditResponse"
}
}
},
"parameters": [
{
"name": "body",
"description": " ArticleSecuritySaveRequest struct{, ArticleSecurity ArticleSecurityItem `json:\"article_security\"`, }, ArticleSecuritySaveResponse struct{},, ArticleSecurityDeleteRequest struct{, Id int64 `path:\"id\"`, }, ArticleSecurityDeleteResponse struct{},, ArticleSecurityUpdateRequest struct{, Id int64 `path:\"id\"`, ArticleSecurity ArticleSecurityItem `json:\"article_security\"`, }, ArticleSecurityUpdateResponse struct{}",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleSecurityAuditRequest"
}
}
],
"requestBody": {},
"tags": [
"secuirty"
]
}
},
"v1/system/article_security/search": {
"post": {
"summary": "内容安全-搜索",
"operationId": "articleSecuritySearch",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleSecuritySearchResponse"
}
}
},
"parameters": [
{
"name": "body",
"in": "body",
"required": true,
"schema": {
"$ref": "#/definitions/ArticleSecuritySearchRequest"
}
}
],
"requestBody": {},
"tags": [
"secuirty"
]
}
},
"v1/system/article_security/{id}": {
"get": {
"summary": "详情",
"operationId": "articleSecurityGet",
"responses": {
"200": {
"description": "A successful response.",
"schema": {
"$ref": "#/definitions/ArticleSecurityGetResponse"
}
}
},
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"type": "string"
}
],
"requestBody": {},
"tags": [
"secuirty"
]
}
},
"v1/system/article_tag": {
"post": {
"summary": "后台创建文章标签",
... ... @@ -3765,6 +3952,16 @@
"format": "int64"
},
"description": "谁可查看"
},
"isDel": {
"type": "integer",
"format": "int32",
"description": "是否删除 1-删除 0-否"
},
"deletedType": {
"type": "integer",
"format": "int32",
"description": "类型 1-运营删除 2-用户删除"
}
},
"title": "ArticleSearchMe",
... ... @@ -3778,7 +3975,9 @@
"countRead",
"show",
"targetUser",
"whoRead"
"whoRead",
"isDel",
"deletedType"
]
},
"ArticleSection": {
... ... @@ -3812,6 +4011,199 @@
"totalComment"
]
},
"ArticleSecurityAuditRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": "id"
},
"status": {
"type": "integer",
"format": "int32",
"description": " 1:成功 0:失败"
}
},
"title": "ArticleSecurityAuditRequest",
"required": [
"id",
"status"
]
},
"ArticleSecurityAuditResponse": {
"type": "object",
"title": "ArticleSecurityAuditResponse"
},
"ArticleSecurityGetRequest": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleSecurityGetRequest",
"required": [
"id"
]
},
"ArticleSecurityGetResponse": {
"type": "object",
"properties": {
"item": {
"$ref": "#/definitions/ArticleSecurityItem"
}
},
"title": "ArticleSecurityGetResponse",
"required": [
"item"
]
},
"ArticleSecurityItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 唯一标识"
},
"contentKeyWords": {
"type": "string",
"description": " 内容关键字"
},
"content": {
"$ref": "#/definitions/ContentDetailItem",
"description": " 内容详情"
},
"label": {
"type": "string",
"description": " 风控标签"
},
"prob": {
"type": "integer",
"format": "int32",
"description": " 分值"
},
"suggest": {
"type": "string",
"description": " 建议 通过、风险、人工审核"
},
"author": {
"type": "string",
"description": " 发布人"
},
"releaseAt": {
"type": "string",
"description": " 发布时间"
},
"reviewStatus": {
"type": "integer",
"format": "int32",
"description": " 审核结果 1:待审核 2:通过 3:拒绝"
},
"reviewer": {
"type": "string",
"description": " 审核人"
},
"reviewAt": {
"type": "integer",
"format": "int64",
"description": " 审核时间(人工处置时间)"
},
"checkList": {
"type": "array",
"items": {
"$ref": "#/definitions/CheckDetailItem"
},
"description": " 检查列表"
}
},
"title": "ArticleSecurityItem",
"required": [
"id",
"contentKeyWords",
"content",
"label",
"prob",
"suggest",
"author",
"releaseAt",
"reviewStatus",
"reviewer",
"reviewAt",
"checkList"
]
},
"ArticleSecuritySearchRequest": {
"type": "object",
"properties": {
"page": {
"type": "integer",
"format": "int32"
},
"size": {
"type": "integer",
"format": "int32"
},
"reviewStatus": {
"type": "integer",
"format": "int32",
"description": " 审核结果 1:待审核 2:通过 3:拒绝"
},
"suggest": {
"type": "string",
"description": " 建议 通过、风险、人工审核"
},
"contentType": {
"type": "integer",
"format": "int32",
"description": " 内容类型 (1:文章 2:评论)"
},
"authorName": {
"type": "string",
"description": " 作者名称"
},
"beginTime": {
"type": "integer",
"format": "int64",
"description": " 开始时间"
},
"endTime": {
"type": "integer",
"format": "int64",
"description": " 结束时间"
}
},
"title": "ArticleSecuritySearchRequest",
"required": [
"suggest",
"contentType",
"authorName",
"beginTime",
"endTime"
]
},
"ArticleSecuritySearchResponse": {
"type": "object",
"properties": {
"list": {
"type": "array",
"items": {
"$ref": "#/definitions/ArticleSecurityItem"
}
},
"total": {
"type": "integer",
"format": "int64"
}
},
"title": "ArticleSecuritySearchResponse",
"required": [
"list",
"total"
]
},
"ArticleTagCount": {
"type": "object",
"properties": {
... ... @@ -3967,12 +4359,18 @@
"label": {
"type": "string",
"description": " 分组名称"
},
"enable": {
"type": "integer",
"format": "int32",
"description": " 启用状态 1:启用"
}
},
"title": "CategoryOptions",
"required": [
"value",
"label"
"label",
"enable"
]
},
"CategoryOptionsRequest": {
... ... @@ -4001,6 +4399,29 @@
"options"
]
},
"CheckDetailItem": {
"type": "object",
"properties": {
"label": {
"type": "string",
"description": " 命中标签"
},
"prob": {
"$ref": "#/definitions/uint",
"description": " 置信度。0-100,越高代表越有可能属于当前返回的标签(label)"
},
"suggest": {
"type": "string",
"description": " 建议"
}
},
"title": "CheckDetailItem",
"required": [
"label",
"prob",
"suggest"
]
},
"CommentAtWho": {
"type": "object",
"properties": {
... ... @@ -4200,6 +4621,31 @@
"type": "object",
"title": "CompanyVisibleSwitchResponse"
},
"ContentDetailItem": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int64",
"description": " 内容ID"
},
"type": {
"type": "integer",
"format": "int32",
"description": " 内容类型 (1:文章 2:评论)"
},
"text": {
"type": "string",
"description": " 内容文本"
}
},
"title": "ContentDetailItem",
"required": [
"id",
"type",
"text"
]
},
"Department": {
"type": "object",
"properties": {
... ... @@ -4229,6 +4675,11 @@
"format": "int64"
},
"description": " 部门下的用户"
},
"totalUser": {
"type": "integer",
"format": "int32",
"description": " 累计用户"
}
},
"title": "Department",
... ... @@ -4237,7 +4688,8 @@
"companyId",
"parentId",
"name",
"userIds"
"userIds",
"totalUser"
]
},
"DepartmentAddRequest": {
... ... @@ -4297,6 +4749,16 @@
"size": {
"type": "integer",
"format": "int32"
},
"includeRootCompany": {
"type": "boolean",
"format": "boolean",
"description": " 包含公司(把公司当作部门作为顶级节点 部门ID:0)"
},
"includeDefaultDepartment": {
"type": "boolean",
"format": "boolean",
"description": " 包含默认分组"
}
},
"title": "DepartmentListRequest",
... ... @@ -4497,6 +4959,89 @@
"size"
]
},
"MessageSubscribeAddRequest": {
"type": "object",
"properties": {
"types": {
"type": "array",
"items": {
"type": "integer",
"format": "int32"
},
"description": " 订阅消息类型"
}
},
"title": "MessageSubscribeAddRequest",
"required": [
"types"
]
},
"MessageSubscribeAddResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSubscribeItem"
}
}
},
"title": "MessageSubscribeAddResponse",
"required": [
"items"
]
},
"MessageSubscribeItem": {
"type": "object",
"properties": {
"type": {
"type": "integer",
"format": "int32",
"description": " 订阅消息类型"
},
"count": {
"type": "integer",
"format": "int32",
"description": " 订阅次数"
},
"userId": {
"type": "integer",
"format": "int64",
"description": " 用户ID"
},
"companyId": {
"type": "integer",
"format": "int64",
"description": " 公司ID"
}
},
"title": "MessageSubscribeItem",
"required": [
"type",
"count",
"userId",
"companyId"
]
},
"MessageSubscribeListRequest": {
"type": "object",
"title": "MessageSubscribeListRequest"
},
"MessageSubscribeListResponse": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"$ref": "#/definitions/MessageSubscribeItem"
}
}
},
"title": "MessageSubscribeListResponse",
"required": [
"items"
]
},
"MessageSystemItem": {
"type": "object",
"properties": {
... ... @@ -6975,10 +7520,89 @@
"keywords": {
"type": "string",
"description": " 按关键字搜索(名称)"
},
"departmentId": {
"$ref": "#/definitions/int64",
"description": " 按部门过滤"
}
},
"title": "MiniUsersListRequest"
},
"MiniWechatBindRequest": {
"type": "object",
"properties": {
"wechatAuthcode": {
"type": "string",
"description": " 微信登录 授权码"
},
"wechatEncryptedData": {
"type": "string",
"description": " 微信登录 加密数据"
},
"wechatIV": {
"type": "string",
"description": " 微信登录 加密算法初始向量"
}
},
"title": "MiniWechatBindRequest",
"required": [
"wechatAuthcode",
"wechatEncryptedData",
"wechatIV"
]
},
"MiniWechatBindResponse": {
"type": "object",
"properties": {
"bind": {
"type": "boolean",
"format": "boolean",
"description": " 绑定结果 true-已绑定 false-未绑定"
},
"openId": {
"type": "string",
"description": " 绑定的微信openId"
},
"phone": {
"type": "string",
"description": " 绑定手机号"
}
},
"title": "MiniWechatBindResponse",
"required": [
"bind",
"openId",
"phone"
]
},
"MiniWechatInfoRequest": {
"type": "object",
"title": "MiniWechatInfoRequest"
},
"MiniWechatInfoResponse": {
"type": "object",
"properties": {
"bind": {
"type": "boolean",
"format": "boolean",
"description": " 绑定结果 true-已绑定 false-未绑定"
},
"openId": {
"type": "string",
"description": " 绑定的微信openId"
},
"phone": {
"type": "string",
"description": " 绑定手机号"
}
},
"title": "MiniWechatInfoResponse",
"required": [
"bind",
"openId",
"phone"
]
},
"MyBeLikedItem": {
"type": "object",
"properties": {
... ... @@ -7828,11 +8452,16 @@
"type": "integer",
"format": "int64",
"description": "id"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDeleteRequest",
"required": [
"id"
"id",
"x-mmm-accesstoken"
]
},
"SystemArticleDeleteResponse": {
... ... @@ -7866,11 +8495,16 @@
"type": "integer",
"format": "int64",
"description": "ID"
},
"AccessToken": {
"type": "string",
"description": " 授权token"
}
},
"title": "SystemArticleDeletedRestoreRequest",
"required": [
"id"
"id",
"x-mmm-accesstoken"
]
},
"SystemArticleDeletedRestoreResponse": {
... ... @@ -10180,6 +10814,10 @@
},
"code": {
"type": "string"
},
"companyVisible": {
"type": "boolean",
"format": "boolean"
}
},
"title": "SystemUserInfoResponse",
... ... @@ -10189,7 +10827,8 @@
"avatar",
"companyId",
"companyName",
"code"
"code",
"companyVisible"
]
},
"SystemUserSearchRequest": {
... ... @@ -10221,8 +10860,7 @@
"description": " 启用状态 1:启用 2:禁用"
},
"departmentId": {
"type": "integer",
"format": "int64",
"$ref": "#/definitions/int64",
"description": " 所属部门"
}
},
... ...
... ... @@ -68,7 +68,7 @@ type (
Prob int `json:"prob"` // 分值
Suggest string `json:"suggest"` // 建议 通过、风险、人工审核
Author string `json:"author"` // 发布人
ReleaseAt string `json:"releaseAt"` // 发布时间
ReleaseAt int64 `json:"releaseAt"` // 发布时间
ReviewStatus int `json:"reviewStatus"` // 审核结果 1:待审核 2:通过 3:拒绝
Reviewer string `json:"reviewer"` // 审核人
... ...
... ... @@ -2,8 +2,8 @@ package article
import (
"context"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/core"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"strconv"
"strings"
"text/template"
... ... @@ -208,7 +208,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
// 内容安全检查
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, conn, "", core.NewContentFromArticle(newArticle, sectionList)); err != nil {
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, c, author, core.NewContentFromArticle(newArticle, sectionList)); err != nil {
return err
}
return nil
... ...
... ... @@ -214,7 +214,7 @@ func (l *MiniCreateArticleCommentLogic) MiniCreateArticleComment(req *types.Mini
}
// 内容安全检查
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, conn, "", core.NewContentFromComment(&newComment)); err != nil {
if err = core.ContentSecurityCheck(l.ctx, l.svcCtx, conn, fromUser, core.NewContentFromComment(&newComment)); err != nil {
return err
}
return nil
... ...
... ... @@ -5,6 +5,7 @@ import (
"context"
"fmt"
"github.com/silenceper/wechat/v2/miniprogram/security"
"github.com/zeromicro/go-zero/core/executors"
"github.com/zeromicro/go-zero/core/logx"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/svc"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
... ... @@ -12,7 +13,7 @@ import (
"time"
)
func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, openId string, content ContentBody) error {
func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, toUser *domain.User, content ContentBody) error {
if !svcCtx.Config.ContentSecurityCheck {
return nil
}
... ... @@ -25,10 +26,15 @@ func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn
scene = security.MsgSceneComment
}
var (
resp domain.MsgCheckDetail
resp domain.MsgCheckDetail
userWechat *domain.UserWechat
)
if userWechat, _ = svcCtx.UserWechatRepository.FindOneByPhone(ctx, conn, toUser.Phone); userWechat == nil {
logx.Debug(fmt.Sprintf("用户%s(%s)未绑定微信,无法进行内容检查", toUser.Name, toUser.Phone))
return nil
}
respTmp, err := svcCtx.MiniProgram.GetSecurity().MsgCheck(&security.MsgCheckRequest{
OpenID: openId,
OpenID: userWechat.OpenId,
Scene: scene,
Content: content.Content,
})
... ... @@ -38,7 +44,7 @@ func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn
}
resp = domain.MsgCheckDetail(respTmp)
var (
keyWords []string
keyWords = make([]string, 0)
prob int
)
for i := range resp.Detail {
... ... @@ -46,13 +52,18 @@ func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn
if prob == 0 {
prob = int(item.Prob)
}
if item.Keyword == "" {
continue
}
keyWords = append(keyWords, item.Keyword)
}
dm := &domain.ArticleSecurity{
CompanyId: toUser.CompanyId,
ContentKeyWords: keyWords,
ContentType: content.Type,
ContentId: content.Id,
AuthorId: content.AuthorId,
AuthorName: toUser.Name,
Reviewer: 0,
ReviewStatus: domain.ReviewStatusWait,
Label: resp.Result.Label.String(),
... ... @@ -65,11 +76,17 @@ func ContentSecurityCheck(ctx context.Context, svcCtx *svc.ServiceContext, conn
if resp.Result.Suggest == security.CheckSuggestPass {
dm.ReviewStatus = domain.ReviewStatusPass
}
// 延迟任务(认定为风险的、人工审核),帖子或评论先隐藏,状态改为非法
if resp.Result.Suggest == security.CheckSuggestRisky || resp.Result.Suggest == security.CheckSuggestReview {
executors.NewDelayExecutor(func() {
HandlerSecurityContent(ctx, svcCtx, svcCtx.DefaultDBConn(), content, dm.ReviewStatus)
}, time.Second*5).Trigger()
}
if dm, err = svcCtx.ArticleSecurityRepository.Insert(ctx, conn, dm); err != nil {
logx.Error(err)
return nil
}
return HandlerSecurityContent(ctx, svcCtx, conn, content, dm.ReviewStatus)
return nil
}
func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, conn transaction.Conn, c ContentBody, status int) error {
... ... @@ -80,15 +97,16 @@ func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, con
article *domain.Article
comment *domain.ArticleComment
err error
show = int(domain.ArticleShowIllegal)
)
if status == domain.ReviewStatusPass {
return nil
show = int(domain.ArticleShowEnable)
}
if c.Type == domain.TypeArticle {
if article, err = svcCtx.ArticleRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("文章不存在")
}
article.Show = domain.ArticleShowDisable
article.Show = domain.ArticleShow(show)
if _, err = svcCtx.ArticleRepository.UpdateWithVersion(ctx, conn, article); err != nil {
return err
}
... ... @@ -96,7 +114,7 @@ func HandlerSecurityContent(ctx context.Context, svcCtx *svc.ServiceContext, con
if comment, err = svcCtx.ArticleCommentRepository.FindOne(ctx, conn, c.Id); err != nil {
return fmt.Errorf("评论不存在")
}
comment.Show = domain.CommentShowDisable
comment.Show = domain.CommentShow(show)
if _, err = svcCtx.ArticleCommentRepository.UpdateWithVersion(ctx, conn, comment); err != nil {
return err
}
... ... @@ -129,7 +147,7 @@ func NewContentFromArticle(c *domain.Article, sections []*domain.ArticleSection)
}
return ContentBody{
Id: c.Id,
Type: domain.TypeComment,
Type: domain.TypeArticle,
Content: content.String(),
AuthorId: c.AuthorId,
Summary: c.Summary,
... ...
... ... @@ -37,9 +37,9 @@ func (l *ArticleSecurityAuditLogic) ArticleSecurityAudit(req *types.ArticleSecur
return nil, xerr.NewErrMsgErr("不存在", err)
}
// 不可编辑判断
if dm.ReviewStatus != domain.ReviewStatusWait {
return nil, xerr.NewErrMsgErr("内容已审核", err)
}
//if dm.ReviewStatus != domain.ReviewStatusWait {
// return nil, xerr.NewErrMsgErr("内容已审核", err)
//}
// 赋值
if req.Status == 1 {
dm.ReviewStatus = domain.ReviewStatusPass
... ...
... ... @@ -30,6 +30,8 @@ func (l *ArticleSecurityGetLogic) ArticleSecurityGet(req *types.ArticleSecurityG
conn = l.svcCtx.DefaultDBConn()
dm *domain.ArticleSecurity
reviewer *domain.User
article *domain.Article
comment *domain.ArticleComment
)
// 货号唯一
if dm, err = l.svcCtx.ArticleSecurityRepository.FindOne(l.ctx, conn, req.Id); err != nil {
... ... @@ -43,5 +45,14 @@ func (l *ArticleSecurityGetLogic) ArticleSecurityGet(req *types.ArticleSecurityG
resp = &types.ArticleSecurityGetResponse{
ArticleSecurity: NewTypesArticleSecurity(dm, reviewer),
}
if dm.ContentType == domain.TypeArticle {
if article, _ = l.svcCtx.ArticleRepository.FindOne(l.ctx, conn, dm.ContentId); article != nil {
resp.ArticleSecurity.Content.Text = article.Summary
}
} else if dm.ContentType == domain.TypeComment {
if comment, _ = l.svcCtx.ArticleCommentRepository.FindOne(l.ctx, conn, dm.ContentId); comment != nil {
resp.ArticleSecurity.Content.Text = comment.Content
}
}
return
}
... ...
... ... @@ -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/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"strings"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -26,12 +27,13 @@ func NewArticleSecuritySearchLogic(ctx context.Context, svcCtx *svc.ServiceConte
func (l *ArticleSecuritySearchLogic) ArticleSecuritySearch(req *types.ArticleSecuritySearchRequest) (resp *types.ArticleSecuritySearchResponse, err error) {
var (
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleSecurity
total int64
conn = l.svcCtx.DefaultDBConn()
dms []*domain.ArticleSecurity
total int64
userToken = contextdata.GetUserTokenFromCtx(l.ctx)
)
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size).
queryOptions := domain.IndexCompanyId(userToken.CompanyId)().WithOffsetLimit(req.Page, req.Size).
WithKV("reviewStatus", req.ReviewStatus).
WithKV("suggest", req.Suggest).
WithKV("contentType", req.ContentType).
... ... @@ -57,7 +59,11 @@ func NewDomainArticleSecurity(item types.ArticleSecurityItem) *domain.ArticleSec
func NewTypesArticleSecurity(item *domain.ArticleSecurity, reviewer *domain.User) types.ArticleSecurityItem {
result := types.ArticleSecurityItem{
Id: item.Id,
Id: item.Id,
Content: types.ContentDetailItem{
Id: item.ContentId,
Type: item.ContentType,
},
ContentKeyWords: strings.Join(item.ContentKeyWords, ","),
Label: item.Label,
Prob: item.Prob,
... ... @@ -65,13 +71,16 @@ func NewTypesArticleSecurity(item *domain.ArticleSecurity, reviewer *domain.User
Author: item.AuthorName,
ReviewAt: item.CreatedAt,
ReviewStatus: item.ReviewStatus,
Reviewer: "",
ReleaseAt: item.CreatedAt,
Reviewer: "",
}
if reviewer != nil {
result.Reviewer = reviewer.Name
}
for _, detail := range item.Detail.Detail {
if detail.Label.String() == "0" {
continue
}
result.CheckList = append(result.CheckList, types.CheckDetailItem{
Label: detail.Label.String(),
Prob: detail.Prob,
... ...
... ... @@ -1890,7 +1890,7 @@ type ArticleSecurityItem struct {
Prob int `json:"prob"` // 分值
Suggest string `json:"suggest"` // 建议 通过、风险、人工审核
Author string `json:"author"` // 发布人
ReleaseAt string `json:"releaseAt"` // 发布时间
ReleaseAt int64 `json:"releaseAt"` // 发布时间
ReviewStatus int `json:"reviewStatus"` // 审核结果 1:待审核 2:通过 3:拒绝
Reviewer string `json:"reviewer"` // 审核人
ReviewAt int64 `json:"reviewAt"` // 审核时间(人工处置时间)
... ...
... ... @@ -26,11 +26,11 @@ func Migrate(db *gorm.DB) {
//&models.ArticleAndTag{},
//&models.ArticleDraftOperation{},
//&models.ArticleCategory{},
&models.UserSubscribe{},
&models.MessageSubscribe{},
&models.UserWechat{},
&models.ArticleDraftOperation{},
&models.ArticleCategory{},
//&models.UserSubscribe{},
//&models.MessageSubscribe{},
//&models.UserWechat{},
//&models.ArticleDraftOperation{},
//&models.ArticleCategory{},
&models.ArticleSecurity{},
}
... ...
... ... @@ -9,15 +9,15 @@ import (
)
type ArticleSecurity struct {
Id int64 // 唯一标识
ContentKeyWords []string // 内容关键字
ContentType int `json:"contentType,omitempty"` // 内容类型 (1:文章 2:评论)
ContentId int64 `json:"contentId,omitempty"` // 内容ID
AuthorId int64 `json:"authorId,omitempty"` // 发布人
AuthorName string `json:"authorName,omitempty"` // 发布人
Reviewer int64 `json:"reviewer,omitempty"` // 审核人
ReviewStatus int `json:"reviewStatus,omitempty"` // 审核状态 0:待审核 1:通过 2:拒绝
Id int64 // 唯一标识
CompanyId int64
ContentKeyWords []string `gorm:"type:jsonb;serializer:json"` // 内容关键字
ContentType int `json:"contentType,omitempty"` // 内容类型 (1:文章 2:评论)
ContentId int64 `json:"contentId,omitempty"` // 内容ID
AuthorId int64 `json:"authorId,omitempty"` // 发布人
AuthorName string `json:"authorName,omitempty"` // 发布人
Reviewer int64 `json:"reviewer,omitempty"` // 审核人
ReviewStatus int `json:"reviewStatus,omitempty"` // 审核状态 0:待审核 1:通过 2:拒绝
Label string // 标签
Prob int // 分值
Suggest string // 建议 通过、风险、人工审核
... ...
... ... @@ -121,6 +121,9 @@ func (repository *ArticleSecurityRepository) Find(ctx context.Context, conn tran
)
queryFunc := func() (interface{}, error) {
tx = tx.Model(&ms).Order("id desc")
if v, ok := queryOptions["companyId"]; ok {
tx.Where("company_id = ?", v)
}
if v, ok := queryOptions["authorName"]; ok {
tx.Where("author_name like ? ", fmt.Sprintf("%%%v%%", v))
}
... ...
... ... @@ -95,6 +95,7 @@ type ArticleShow int
const (
ArticleShowEnable ArticleShow = 1
ArticleShowDisable ArticleShow = 2
ArticleShowIllegal ArticleShow = 3
)
func (a ArticleShow) Named() string {
... ... @@ -103,6 +104,8 @@ func (a ArticleShow) Named() string {
return "显示"
case ArticleShowDisable:
return "隐藏"
case ArticleShowIllegal:
return "违规"
}
return ""
}
... ...
... ... @@ -39,6 +39,7 @@ type CommentShow int
const (
CommentShowEnable CommentShow = 1
CommentShowDisable CommentShow = 2
CommentShowIllegal CommentShow = 3
)
func (show CommentShow) Named() string {
... ... @@ -47,6 +48,8 @@ func (show CommentShow) Named() string {
return "显示"
case CommentShowDisable:
return "隐藏"
case CommentShowIllegal:
return "违规"
}
return ""
}
... ...
... ... @@ -7,8 +7,8 @@ import (
)
type ArticleSecurity struct {
Id int64 // 唯一标识
Id int64 // 唯一标识
CompanyId int64
ContentKeyWords []string // 内容关键字
ContentType int `json:"contentType,omitempty"` // 内容类型 (1:文章 2:评论)
ContentId int64 `json:"contentId,omitempty"` // 内容ID
... ...