作者 yangfu
正在显示 28 个修改的文件 包含 847 行增加80 行删除
... ... @@ -9,7 +9,7 @@ Timeout: 30000
LogRequest: true # 记录详细请求日志
Log:
Mode: file
# Mode: file
Encoding: plain
Level: debug # info
MaxSize: 1 # 2MB
... ...
... ... @@ -35,15 +35,9 @@ func NewMiniCreateArticleLogic(ctx context.Context, svcCtx *svc.ServiceContext)
// 创建新文章
func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateRequest) (resp *types.MiniArticleCreateResponse, err error) {
var conn = l.svcCtx.DefaultDBConn()
// 检查文字数量
wordNum := 0
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i])
wordNum += num
}
if wordNum >= 1000 {
return nil, xerr.NewErrMsgErr("最多只能输入1000字", err)
err = l.validateTextLimit(req)
if err != nil {
return nil, err
}
// 检查发布人
author, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, req.AuthorId)
... ... @@ -181,19 +175,7 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
newArticle.MatchUrl[k] = v
}
//设置内容概要
if len(sectionList) > 0 {
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range sectionList[0].Content {
if runeNumber > 50 {
break
}
runeNumber += 1
stringIndex = i
}
newArticle.Summary = sectionList[0].Content[0:stringIndex]
}
newArticle.SetSummary(sectionList)
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
newArticle, err = l.svcCtx.ArticleRepository.Insert(ctx, c, newArticle)
... ... @@ -208,13 +190,6 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
return xerr.NewErrMsgErr("创建文章内容失败", err)
}
}
// 设置保存备份
// backup := newArticle.MakeBackup(newArticle.Author, sectionList)
// backup.Action = "新增"
// _, err = l.svcCtx.ArticleBackupRepository.Insert(ctx, c, backup)
// if err != nil {
// return xerr.NewErrMsgErr("创建文章内容失败", err)
// }
return nil
}, true)
if err != nil {
... ... @@ -226,3 +201,22 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
return
}
// validateTextLimit 验证输入文本长度
func (l *MiniCreateArticleLogic) validateTextLimit(req *types.MiniArticleCreateRequest) error {
titleWordNum := utf8.RuneCountInString(req.Title)
if titleWordNum > 64 {
return xerr.NewErrMsg("标题最多只能输入64字")
}
wordNum := 0
for i := range req.Section {
num := utf8.RuneCountInString(req.Section[i])
wordNum += num
}
if wordNum > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
}
return nil
}
... ...
... ... @@ -41,6 +41,7 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
if articleInfo.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("没有查看权限")
}
// 检查文章的可查看人
if articleInfo.AuthorId != int64(req.UserId) {
if len(articleInfo.WhoRead) > 0 {
inWhoRead := false
... ... @@ -51,23 +52,25 @@ func (l *MiniGetArticleLogic) MiniGetArticle(req *types.MiniArticleGetRequest) (
}
if !inWhoRead {
// 文章内容不显示
resp = &types.MiniArticleGetResponse{
Id: articleInfo.Id,
Title: articleInfo.Title,
Show: int(domain.ArticleShowDisable),
}
return resp, nil
// resp = &types.MiniArticleGetResponse{
// Id: articleInfo.Id,
// Title: articleInfo.Title,
// Show: int(domain.ArticleShowDisable),
// }
// return resp, nil
return nil, xerr.NewErrMsg("没有查看权限")
}
}
}
if articleInfo.Show == domain.ArticleShowDisable {
// 文章内容不显示
resp = &types.MiniArticleGetResponse{
Id: articleInfo.Id,
Title: articleInfo.Title,
Show: int(domain.ArticleShowDisable),
}
return resp, nil
// resp = &types.MiniArticleGetResponse{
// Id: articleInfo.Id,
// Title: articleInfo.Title,
// Show: int(domain.ArticleShowDisable),
// }
// return resp, nil
return nil, xerr.NewErrMsg("没有查看权限")
}
queryOption := domain.NewQueryOptions().
... ...
... ... @@ -77,6 +77,8 @@ func (l *SystemArticleRestoreLogic) SystemArticleRestore(req *types.SystemArticl
})
})
article.SetSummary(articleSections)
err = transaction.UseTrans(l.ctx, conn.DB(), func(ctx context.Context, c transaction.Conn) error {
//保存文章
_, err = l.svcCtx.ArticleRepository.Update(ctx, c, article)
... ...
... ... @@ -2,11 +2,12 @@ package article
import (
"context"
"github.com/jinzhu/copier"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"strconv"
"unicode/utf8"
"github.com/jinzhu/copier"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/api/internal/logic/message"
"strings"
"github.com/samber/lo"
... ... @@ -116,19 +117,7 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
//文章内容
articleSections := l.getSections(req, article)
//设置内容概要
if len(req.Section) > 0 {
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range req.Section[0].Content {
if runeNumber > 50 {
break
}
runeNumber += 1
stringIndex = i
}
article.Summary = req.Section[0].Content[0:stringIndex]
}
article.SetSummary(articleSections)
err = transaction.UseTrans(l.ctx, l.conn.DB(), func(ctx context.Context, c transaction.Conn) error {
_, err = l.svcCtx.ArticleRepository.Update(l.ctx, c, article)
... ... @@ -199,8 +188,8 @@ func (l *SystemUpdateArticleLogic) validateTextLimit(req *types.SystemArticleUpd
num := utf8.RuneCountInString(req.Section[i].Content)
wordNum += num
}
if wordNum >= 1000 {
return xerr.NewErrMsg("最多只能输入1000字")
if wordNum > 1000 {
return xerr.NewErrMsg("内容最多只能输入1000字")
}
return nil
}
... ...
... ... @@ -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/db/transaction"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/domain"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
... ... @@ -15,6 +16,7 @@ type MiniTop5ArticleCommentLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
userCache map[int64]types.CommentAuthor
}
func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceContext) *MiniTop5ArticleCommentLogic {
... ... @@ -22,6 +24,7 @@ func NewMiniTop5ArticleCommentLogic(ctx context.Context, svcCtx *svc.ServiceCont
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
userCache: make(map[int64]types.CommentAuthor),
}
}
... ... @@ -50,9 +53,15 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5
resp = &types.MiniTop5ArticleCommentResponse{
List: make([]types.ArticleCommentItem, len(commentList)),
}
companyInfo, err := l.svcCtx.CompanyRepository.FindOne(l.ctx, conn, req.CompanyId)
if err != nil {
return nil, xerr.NewErrMsgErr("获取公司信息失败", err)
}
for i, val := range commentList {
item := NewArticleCommentItem(val)
item.FromUser = l.getCommentAuthor(conn, val.FromUserId, companyInfo.Name)
item.ToUser = l.getCommentAuthor(conn, val.ToUserId, companyInfo.Name)
if _, ok := flagMap[val.Id]; ok {
item.MeLoveFlag = 1
}
... ... @@ -70,6 +79,25 @@ func (l *MiniTop5ArticleCommentLogic) MiniTop5ArticleComment(req *types.MiniTop5
return
}
func (l *MiniTop5ArticleCommentLogic) getCommentAuthor(conn transaction.Conn, userid int64, companyName string) types.CommentAuthor {
if u, ok := l.userCache[userid]; ok {
return u
}
toUser, err := l.svcCtx.UserRepository.FindOne(l.ctx, conn, userid)
if err == nil {
commentToUser := types.CommentAuthor{
Id: toUser.Id,
Name: toUser.Name,
Avatar: toUser.Avatar,
Position: toUser.Position,
Company: companyName,
}
l.userCache[toUser.Id] = commentToUser
return commentToUser
}
return types.CommentAuthor{}
}
func NewArticleCommentItem(val *domain.ArticleComment) types.ArticleCommentItem {
item := types.ArticleCommentItem{
Id: val.Id,
... ...
... ... @@ -30,7 +30,7 @@ type Article struct {
CountRead int // 浏览数量
CountComment int // 评论数量
Tags []int64 `gorm:"type:jsonb;serializer:json"` //定性标签
Show int // 评论的展示状态(0显示、1不显示)
Show int // 评论的展示状态(1显示、2不显示)
Summary string // 内容概要
MatchUrl map[string]string `gorm:"type:jsonb;serializer:json"` // 匹配文章内容中的url文本
}
... ...
... ... @@ -44,7 +44,7 @@ func (repository *ArticleAndTagRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *ArticleBackupRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -46,7 +46,7 @@ func (repository *ArticleCommentRepository) Update(ctx context.Context, conn tra
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *ArticleDraftRepository) Update(ctx context.Context, conn trans
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -66,7 +66,7 @@ func (repository *ArticleTagRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -43,7 +44,7 @@ func (repository *CompanyRepository) Update(ctx context.Context, conn transactio
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DepartmentRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionAcceptRepository) Update(ctx context.Context, conn t
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionOpinionRepository) Update(ctx context.Context, conn
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *DiscussionRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -43,7 +43,7 @@ func (repository *MessageBusinessRepository) Update(ctx context.Context, conn tr
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -43,7 +43,7 @@ func (repository *MessageSystemRepository) Update(ctx context.Context, conn tran
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *RoleRepository) Update(ctx context.Context, conn transaction.C
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *UserFollowRepository) Update(ctx context.Context, conn transac
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -42,7 +42,7 @@ func (repository *UserLoveFlagRepository) Update(ctx context.Context, conn trans
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -43,7 +43,7 @@ func (repository *UserReadArticleRepository) Update(ctx context.Context, conn tr
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -3,6 +3,7 @@ package repository
import (
"context"
"fmt"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -43,7 +44,7 @@ func (repository *UserRepository) Update(ctx context.Context, conn transaction.C
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package repository
import (
"context"
"github.com/jinzhu/copier"
"github.com/pkg/errors"
"github.com/tiptok/gocomm/pkg/cache"
... ... @@ -42,7 +43,7 @@ func (repository *UserRoleRepository) Update(ctx context.Context, conn transacti
return nil, err
}
queryFunc := func() (interface{}, error) {
tx = tx.Model(m).Updates(m)
tx = tx.Model(m).Select("*").Updates(m)
return nil, tx.Error
}
if _, err = repository.Query(queryFunc, m.CacheKeyFunc()); err != nil {
... ...
... ... @@ -2,6 +2,7 @@ package domain
import (
"context"
"strings"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/cmd/discuss/interanl/pkg/db/transaction"
)
... ... @@ -119,6 +120,7 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
WhoReview: m.WhoReview,
Tags: m.Tags,
MatchUrl: map[string]string{},
Location: m.Location,
}
copy(b.Videos, m.Videos)
copy(b.Images, m.Images)
... ... @@ -127,3 +129,30 @@ func (m *Article) MakeBackup(operator UserSimple, section []*ArticleSection) *Ar
}
return &b
}
func (m *Article) SetSummary(sectionList []ArticleSection) {
if len(sectionList) == 0 {
return
}
//设置内容概要
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
content := ""
for i := range sectionList {
str := strings.TrimSpace(sectionList[i].Content)
if len(str) > 0 {
content = str
break
}
}
for i := range content {
if runeNumber > 50 {
break
}
runeNumber += 1
stringIndex = i
}
m.Summary = content[0:stringIndex]
}
... ...
... ... @@ -61,7 +61,7 @@ type ArticleCommentShow struct {
CountReply int // 回复数量
CountUserLove int // 用户点赞数量
CountAdminLove int // 运营点赞数量
Show int // 评论的展示状态(0显示、1不显示)
Show int // 评论的展示状态(1显示、2不显示)
CreatedAt int64 // 评论的创建时间
}
... ...
-- public.article definition
-- Drop table
-- DROP TABLE public.article;
CREATE TABLE public.article(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
is_del int8 NULL, -- 是否删除
"version" int8 NULL DEFAULT 0, -- 版本
author_id int8 NULL DEFAULT 0, -- 发布人
author jsonb NULL DEFAULT '{}' ::jsonb, -- 发布人对象
title text NULL, -- 文章标题
images jsonb NULL DEFAULT '[]' ::jsonb, -- 图片
who_read jsonb NULL DEFAULT '[]' ::jsonb, -- 谁可以看
who_review jsonb NULL DEFAULT '[]' ::jsonb, -- 评论人
"location" jsonb NULL DEFAULT '{}' ::jsonb, -- 坐标
target_user int8 NULL DEFAULT 0, -- 分发方式 0 分发给所有人 1 分发给指定的人
count_love int8 NULL DEFAULT 0, -- 点赞数量
count_comment int8 NULL DEFAULT 0, -- 评论数量
"show" int8 NULL DEFAULT 1, -- 评论的展示状态(1显示、2不显示)
tags jsonb NULL DEFAULT '[]' ::jsonb, -- 标签
count_read int8 NULL DEFAULT 0, -- 已读数量
summary text NULL,
match_url jsonb NULL DEFAULT '{}' ::jsonb,
videos jsonb NULL DEFAULT '[]' ::jsonb,
CONSTRAINT article_pkey PRIMARY KEY (id)
);
CREATE INDEX article_company_id_idx ON public.article USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article.id IS 'ID';
COMMENT ON COLUMN public.article.company_id IS '公司ID';
COMMENT ON COLUMN public.article.created_at IS '创建时间';
COMMENT ON COLUMN public.article.updated_at IS '更新时间';
COMMENT ON COLUMN public.article.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article.is_del IS '是否删除';
COMMENT ON COLUMN public.article. "version" IS '版本';
COMMENT ON COLUMN public.article.author_id IS '发布人';
COMMENT ON COLUMN public.article.author IS '发布人对象';
COMMENT ON COLUMN public.article.title IS '文章标题';
COMMENT ON COLUMN public.article.images IS '图片';
COMMENT ON COLUMN public.article.who_read IS '谁可以看';
COMMENT ON COLUMN public.article.who_review IS '评论人';
COMMENT ON COLUMN public.article. "location" IS '坐标';
COMMENT ON COLUMN public.article.target_user IS '分发方式 0 分发给所有人 1 分发给指定的人';
COMMENT ON COLUMN public.article.count_love IS '点赞数量';
COMMENT ON COLUMN public.article.count_comment IS '评论数量';
COMMENT ON COLUMN public.article. "show" IS '评论的展示状态(1显示、2不显示)';
COMMENT ON COLUMN public.article.tags IS '标签';
COMMENT ON COLUMN public.article.count_read IS '已读数量';
-- public.article_and_tag definition
-- Drop table
-- DROP TABLE public.article_and_tag;
CREATE TABLE public.article_and_tag(
id bigserial NOT NULL,
company_id int8 NULL,
created_at int8 NULL,
updated_at int8 NULL,
article_id int8 NULL,
tag_id int8 NULL,
CONSTRAINT article_and_tag_pkey PRIMARY KEY (id)
);
CREATE INDEX article_and_tag_company_id_idx ON public.article_and_tag USING btree(company_id);
-- public.article_backup definition
-- Drop table
-- DROP TABLE public.article_backup;
CREATE TABLE public.article_backup(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
is_del int8 NULL, -- 是否删除
"version" int8 NULL, -- 版本
"operator" jsonb NULL, -- 操作人
title text NULL, -- 标题
"section" jsonb NULL, -- 分段内容
images jsonb NULL, -- 图片
"action" text NULL, -- 操作
who_read jsonb NULL, -- 谁可以看
who_review jsonb NULL, -- 评论人
tags jsonb NULL, -- 标签
target_user int8 NULL, -- 分发方式 0 分发给所有人 1 分发给指定的人
article_id int8 NULL,
"location" jsonb NULL,
match_url jsonb NULL DEFAULT '{}' ::jsonb,
videos jsonb NULL DEFAULT '[]' ::jsonb,
CONSTRAINT article_backup_pkey PRIMARY KEY (id)
);
CREATE INDEX article_backup_company_id_idx ON public.article_backup USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article_backup.id IS 'ID';
COMMENT ON COLUMN public.article_backup.company_id IS '公司ID';
COMMENT ON COLUMN public.article_backup.created_at IS '创建时间';
COMMENT ON COLUMN public.article_backup.updated_at IS '更新时间';
COMMENT ON COLUMN public.article_backup.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article_backup.is_del IS '是否删除';
COMMENT ON COLUMN public.article_backup. "version" IS '版本';
COMMENT ON COLUMN public.article_backup. "operator" IS '操作人';
COMMENT ON COLUMN public.article_backup.title IS '标题';
COMMENT ON COLUMN public.article_backup. "section" IS '分段内容';
COMMENT ON COLUMN public.article_backup.images IS '图片';
COMMENT ON COLUMN public.article_backup. "action" IS '操作';
COMMENT ON COLUMN public.article_backup.who_read IS '谁可以看';
COMMENT ON COLUMN public.article_backup.who_review IS '评论人';
COMMENT ON COLUMN public.article_backup.tags IS '标签';
COMMENT ON COLUMN public.article_backup.target_user IS '分发方式 0 分发给所有人 1 分发给指定的人';
-- public.article_comment definition
-- Drop table
-- DROP TABLE public.article_comment;
CREATE TABLE public.article_comment(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
is_del int8 NULL, -- 是否删除
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
pid int8 NULL DEFAULT 0, -- 对哪个评论进行回复
top_id int8 NULL DEFAULT 0, -- 归属于最上级的哪个评论
article_id int8 NULL DEFAULT 0, -- 文章id
section_id int8 NULL DEFAULT 0, -- 文本段落内容id
section_content text NULL, -- 引用的文章内容文本
from_user_id int8 NULL DEFAULT 0, -- 谁填写的评论
from_user jsonb NULL DEFAULT '{}' ::jsonb, -- 谁填写的评论对象
to_user_id int8 NULL DEFAULT 0, -- 回复谁的评论
to_user jsonb NULL DEFAULT '{}' ::jsonb, -- 回复谁的评论对象
"content" text NULL, -- 评论内容
count_reply int8 NULL DEFAULT 0, -- 回复数量
count_user_love int8 NULL DEFAULT 0, -- 用户点赞数量
count_admin_love int8 NULL DEFAULT 0, -- 运营点赞数量
"show" int8 NULL DEFAULT 1, -- 评论的展示状态(1显示、2不显示)
at_who jsonb NULL DEFAULT '[]' ::jsonb, -- 填写评论时@的人
match_url jsonb NULL DEFAULT '{}' ::jsonb, -- 评论内容中出现的url.
CONSTRAINT article_comment_pkey PRIMARY KEY (id)
);
CREATE INDEX article_comment_company_id_idx ON public.article_comment USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article_comment.id IS 'ID';
COMMENT ON COLUMN public.article_comment.company_id IS '公司ID';
COMMENT ON COLUMN public.article_comment.created_at IS '创建时间';
COMMENT ON COLUMN public.article_comment.updated_at IS '更新时间';
COMMENT ON COLUMN public.article_comment.is_del IS '是否删除';
COMMENT ON COLUMN public.article_comment.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article_comment. "version" IS '版本';
COMMENT ON COLUMN public.article_comment.pid IS '对哪个评论进行回复';
COMMENT ON COLUMN public.article_comment.top_id IS '归属于最上级的哪个评论';
COMMENT ON COLUMN public.article_comment.article_id IS '文章id';
COMMENT ON COLUMN public.article_comment.section_id IS '文本段落内容id';
COMMENT ON COLUMN public.article_comment.section_content IS '引用的文章内容文本';
COMMENT ON COLUMN public.article_comment.from_user_id IS '谁填写的评论';
COMMENT ON COLUMN public.article_comment.from_user IS '谁填写的评论对象';
COMMENT ON COLUMN public.article_comment.to_user_id IS '回复谁的评论';
COMMENT ON COLUMN public.article_comment.to_user IS '回复谁的评论对象';
COMMENT ON COLUMN public.article_comment. "content" IS '评论内容';
COMMENT ON COLUMN public.article_comment.count_reply IS '回复数量';
COMMENT ON COLUMN public.article_comment.count_user_love IS '用户点赞数量';
COMMENT ON COLUMN public.article_comment.count_admin_love IS '运营点赞数量';
COMMENT ON COLUMN public.article_comment. "show" IS '评论的展示状态(1显示、2不显示)';
COMMENT ON COLUMN public.article_comment.at_who IS '填写评论时@的人';
COMMENT ON COLUMN public.article_comment.match_url IS '评论内容中出现的url.';
-- public.article_draft definition
-- Drop table
-- DROP TABLE public.article_draft;
CREATE TABLE public.article_draft(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
is_del int8 NULL, -- 是否删除
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
"template" int8 NULL, -- 填写内容时用的样板0、无 1、演绎式 2、归纳式
"content" jsonb NULL, -- 文章内容
author_id int8 NULL, -- 发布人
title text NULL, -- 文章标题
images jsonb NULL, -- 图片
who_read jsonb NULL, -- 谁可以看
who_review jsonb NULL, -- 评论人
"location" jsonb NULL, -- 坐标
match_url jsonb NULL DEFAULT '{}' ::jsonb,
CONSTRAINT article_draft_pkey PRIMARY KEY (id)
);
CREATE INDEX article_draft_company_id_idx ON public.article_draft USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article_draft.id IS 'ID';
COMMENT ON COLUMN public.article_draft.company_id IS '公司ID';
COMMENT ON COLUMN public.article_draft.created_at IS '创建时间';
COMMENT ON COLUMN public.article_draft.updated_at IS '更新时间';
COMMENT ON COLUMN public.article_draft.is_del IS '是否删除';
COMMENT ON COLUMN public.article_draft.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article_draft. "version" IS '版本';
COMMENT ON COLUMN public.article_draft. "template" IS '填写内容时用的样板0、无 1、演绎式 2、归纳式';
COMMENT ON COLUMN public.article_draft. "content" IS '文章内容';
COMMENT ON COLUMN public.article_draft.author_id IS '发布人';
COMMENT ON COLUMN public.article_draft.title IS '文章标题';
COMMENT ON COLUMN public.article_draft.images IS '图片';
COMMENT ON COLUMN public.article_draft.who_read IS '谁可以看';
COMMENT ON COLUMN public.article_draft.who_review IS '评论人';
COMMENT ON COLUMN public.article_draft. "location" IS '坐标';
-- public.article_section definition
-- Drop table
-- DROP TABLE public.article_section;
CREATE TABLE public.article_section(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
is_del int8 NULL, -- 是否删除
"version" int8 NULL, -- 版本
article_id int8 NULL, -- 文章id
"content" text NULL, -- 文本内容
sort_by int8 NULL, -- 排序
total_comment int8 NULL, -- 评论的数量
CONSTRAINT article_section_pkey PRIMARY KEY (id)
);
CREATE INDEX article_section_article_id_idx ON public.article_section USING btree(article_id);
CREATE INDEX article_section_company_id_idx ON public.article_section USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article_section.id IS 'ID';
COMMENT ON COLUMN public.article_section.company_id IS '公司ID';
COMMENT ON COLUMN public.article_section.created_at IS '创建时间';
COMMENT ON COLUMN public.article_section.updated_at IS '更新时间';
COMMENT ON COLUMN public.article_section.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article_section.is_del IS '是否删除';
COMMENT ON COLUMN public.article_section. "version" IS '版本';
COMMENT ON COLUMN public.article_section.article_id IS '文章id';
COMMENT ON COLUMN public.article_section. "content" IS '文本内容';
COMMENT ON COLUMN public.article_section.sort_by IS '排序';
COMMENT ON COLUMN public.article_section.total_comment IS '评论的数量';
-- public.article_tag definition
-- Drop table
-- DROP TABLE public.article_tag;
CREATE TABLE public.article_tag(
id bigserial NOT NULL, -- ID
company_id int8 NULL, -- 公司ID
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
is_del int8 NULL DEFAULT 0, -- 是否删除
"version" int8 NULL, -- 版本
image jsonb NULL, -- 图片
"name" text NULL, -- 标签名称
category text NULL, -- 标签分类
remark text NULL, -- 备注
sort_by int8 NULL DEFAULT 0,
other text NULL,
CONSTRAINT article_tag_pkey PRIMARY KEY (id)
);
CREATE INDEX article_tag_company_id_idx ON public.article_tag USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public.article_tag.id IS 'ID';
COMMENT ON COLUMN public.article_tag.company_id IS '公司ID';
COMMENT ON COLUMN public.article_tag.created_at IS '创建时间';
COMMENT ON COLUMN public.article_tag.updated_at IS '更新时间';
COMMENT ON COLUMN public.article_tag.deleted_at IS '删除时间';
COMMENT ON COLUMN public.article_tag.is_del IS '是否删除';
COMMENT ON COLUMN public.article_tag. "version" IS '版本';
COMMENT ON COLUMN public.article_tag.image IS '图片';
COMMENT ON COLUMN public.article_tag. "name" IS '标签名称';
COMMENT ON COLUMN public.article_tag.category IS '标签分类';
COMMENT ON COLUMN public.article_tag.remark IS '备注';
-- public.company definition
-- Drop table
-- DROP TABLE public.company;
CREATE TABLE public.company(
id bigserial NOT NULL, -- ID
"name" text NULL, -- 名称
code text NULL, -- 编码(搜索使用,4位字母数字)
logo text NULL, -- 公司LOGO
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
CONSTRAINT company_pkey PRIMARY KEY (id),
CONSTRAINT idx_company_code UNIQUE (code)
);
-- Column comments
COMMENT ON COLUMN public.company.id IS 'ID';
COMMENT ON COLUMN public.company. "name" IS '名称';
COMMENT ON COLUMN public.company.code IS '编码(搜索使用,4位字母数字)';
COMMENT ON COLUMN public.company.logo IS '公司LOGO';
COMMENT ON COLUMN public.company.created_at IS '创建时间';
COMMENT ON COLUMN public.company.updated_at IS '更新时间';
COMMENT ON COLUMN public.company.deleted_at IS '删除时间';
COMMENT ON COLUMN public.company. "version" IS '版本';
-- public.department definition
-- Drop table
-- DROP TABLE public.department;
CREATE TABLE public.department(
id bigserial NOT NULL,
company_id int8 NULL,
parent_id int8 NULL,
"name" text NULL,
created_at int8 NULL,
updated_at int8 NULL,
deleted_at int8 NULL,
"version" int8 NULL,
is_del int8 NULL,
CONSTRAINT department_pkey PRIMARY KEY (id)
);
-- public.message_business definition
-- Drop table
-- DROP TABLE public.message_business;
CREATE TABLE public.message_business(
id bigserial NOT NULL,
"type" int8 NULL,
opt_type int8 NULL,
company_id int8 NULL,
user_id int8 NULL,
recipient_id int8 NULL,
article_id int8 NULL,
comment_id int8 NULL,
comment_parent_id int8 NULL,
created_at int8 NULL,
updated_at int8 NULL,
deleted_at int8 NULL,
"version" int8 NULL,
is_del int8 NULL,
CONSTRAINT message_business_pkey PRIMARY KEY (id)
);
-- public.message_system definition
-- Drop table
-- DROP TABLE public.message_system;
CREATE TABLE public.message_system(
id bigserial NOT NULL,
company_id int8 NULL, -- 公司ID
recipient_id int8 NULL, -- 接收者ID
"type" int8 NULL, -- 系统分类(0待定、1业务正常通知、2业务异常通知)
title text NULL, -- 标题
"content" text NULL, -- 内容
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
is_del int8 NULL, -- 是否删除
CONSTRAINT message_system_pkey PRIMARY KEY (id)
);
-- Column comments
COMMENT ON COLUMN public.message_system.company_id IS '公司ID';
COMMENT ON COLUMN public.message_system.recipient_id IS '接收者ID';
COMMENT ON COLUMN public.message_system. "type" IS '系统分类(0待定、1业务正常通知、2业务异常通知)';
COMMENT ON COLUMN public.message_system.title IS '标题';
COMMENT ON COLUMN public.message_system. "content" IS '内容';
COMMENT ON COLUMN public.message_system.created_at IS '创建时间';
COMMENT ON COLUMN public.message_system.updated_at IS '更新时间';
COMMENT ON COLUMN public.message_system.deleted_at IS '删除时间';
COMMENT ON COLUMN public.message_system. "version" IS '版本';
COMMENT ON COLUMN public.message_system.is_del IS '是否删除';
-- public."role" definition
-- Drop table
-- DROP TABLE public."role";
CREATE TABLE public."role"(
id bigserial NOT NULL, -- ID
"name" text NULL, -- 角色名称
auths jsonb NULL, -- 角色权限列表
remark text NULL, -- 备注
users jsonb NULL, -- 绑定的用户
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
is_del int8 NULL, -- 是否删除
company_id int8 NULL, -- 公司ID
CONSTRAINT role_pkey PRIMARY KEY (id)
);
CREATE INDEX idx_role_company_id ON public.role USING btree(company_id);
-- Column comments
COMMENT ON COLUMN public."role".id IS 'ID';
COMMENT ON COLUMN public."role"."name" IS '角色名称';
COMMENT ON COLUMN public."role".auths IS '角色权限列表';
COMMENT ON COLUMN public."role".remark IS '备注';
COMMENT ON COLUMN public."role".users IS '绑定的用户';
COMMENT ON COLUMN public."role".created_at IS '创建时间';
COMMENT ON COLUMN public."role".updated_at IS '更新时间';
COMMENT ON COLUMN public."role".deleted_at IS '删除时间';
COMMENT ON COLUMN public."role"."version" IS '版本';
COMMENT ON COLUMN public."role".is_del IS '是否删除';
COMMENT ON COLUMN public."role".company_id IS '公司ID';
-- public."user" definition
-- Drop table
-- DROP TABLE public."user";
CREATE TABLE public."user"(
id bigserial NOT NULL, -- 唯一标识
company_id int8 NULL, -- 公司ID
roles jsonb NULL, -- 角色
flag int8 NULL, -- 标识 1:管理员 2:普通用户 (有绑定角色是管理员)
"name" text NULL, -- 名称
avatar text NULL, -- 头像
phone text NULL, -- 手机号 唯一
"position" text NULL, -- 职位
"enable" int8 NULL, -- 启用状态 1:启用 2:禁用
audit_status int8 NULL, -- 审核状态 0:待审核 1:审核通过 2:拒绝
follower jsonb NULL, -- 关注我的人 (冗余)
"following" jsonb NULL, -- 我关注的人 (冗余)
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
is_del int8 NULL, -- 是否删除
departments jsonb NULL, -- 所属部门
account_from text NULL, -- 账号来源 后台新增、扫码注册
pin_yin_name text NULL, -- 拼音
audit_at int8 NULL,
CONSTRAINT user_pkey PRIMARY KEY (id)
);
CREATE INDEX idx_user_company_id ON public."user" USING btree(company_id);
CREATE INDEX idx_user_phone ON public."user" USING btree(phone);
-- Column comments
COMMENT ON COLUMN public."user".id IS '唯一标识';
COMMENT ON COLUMN public."user".company_id IS '公司ID';
COMMENT ON COLUMN public."user".roles IS '角色';
COMMENT ON COLUMN public."user".flag IS '标识 1:管理员 2:普通用户 (有绑定角色是管理员)';
COMMENT ON COLUMN public."user"."name" IS '名称';
COMMENT ON COLUMN public."user".avatar IS '头像';
COMMENT ON COLUMN public."user".phone IS '手机号 唯一';
COMMENT ON COLUMN public."user"."position" IS '职位';
COMMENT ON COLUMN public."user"."enable" IS '启用状态 1:启用 2:禁用';
COMMENT ON COLUMN public."user".audit_status IS '审核状态 0:待审核 1:审核通过 2:拒绝';
COMMENT ON COLUMN public."user".follower IS '关注我的人 (冗余)';
COMMENT ON COLUMN public."user"."following" IS '我关注的人 (冗余)';
COMMENT ON COLUMN public."user".created_at IS '创建时间';
COMMENT ON COLUMN public."user".updated_at IS '更新时间';
COMMENT ON COLUMN public."user".deleted_at IS '删除时间';
COMMENT ON COLUMN public."user"."version" IS '版本';
COMMENT ON COLUMN public."user".is_del IS '是否删除';
COMMENT ON COLUMN public."user".departments IS '所属部门';
COMMENT ON COLUMN public."user".account_from IS '账号来源 后台新增、扫码注册';
COMMENT ON COLUMN public."user".pin_yin_name IS '拼音';
-- public.user_follow definition
-- Drop table
-- DROP TABLE public.user_follow;
CREATE TABLE public.user_follow(
id bigserial NOT NULL,
created_at int8 NULL,
updated_at int8 NULL,
deleted_at int8 NULL,
"version" int8 NULL,
from_user_id int8 NULL,
to_user_id int8 NULL,
last_read_at int8 NULL,
CONSTRAINT user_follow_pkey PRIMARY KEY (id)
);
CREATE INDEX idx_user_follow_from_user_id ON public.user_follow USING btree(from_user_id);
-- public.user_love_flag definition
-- Drop table
-- DROP TABLE public.user_love_flag;
CREATE TABLE public.user_love_flag(
id bigserial NOT NULL,
article_id int8 NULL, -- 点赞文章时,文章id
comment_id int8 NULL, -- 点赞评论时,填评论id
user_id int8 NULL, -- 用户ID,谁点赞
created_at int8 NULL, -- 创建时间
updated_at int8 NULL, -- 更新时间
deleted_at int8 NULL, -- 删除时间
"version" int8 NULL, -- 版本
is_del int8 NULL, -- 是否删除
article_author int8 NULL, -- 文章作者id
comment_author int8 NULL, -- 填写评论的人员id
to_user_id int8 NULL, -- 点赞的接受人
company_id int8 NULL DEFAULT 0,
CONSTRAINT user_love_flag_pkey PRIMARY KEY (id)
);
CREATE INDEX user_love_flag_comment_id_idx ON public.user_love_flag USING btree(comment_id);
CREATE INDEX user_love_flag_user_id_idx ON public.user_love_flag USING btree(user_id);
-- Column comments
COMMENT ON COLUMN public.user_love_flag.article_id IS '点赞文章时,文章id';
COMMENT ON COLUMN public.user_love_flag.comment_id IS '点赞评论时,填评论id';
COMMENT ON COLUMN public.user_love_flag.user_id IS '用户ID,谁点赞';
COMMENT ON COLUMN public.user_love_flag.created_at IS '创建时间';
COMMENT ON COLUMN public.user_love_flag.updated_at IS '更新时间';
COMMENT ON COLUMN public.user_love_flag.deleted_at IS '删除时间';
COMMENT ON COLUMN public.user_love_flag. "version" IS '版本';
COMMENT ON COLUMN public.user_love_flag.is_del IS '是否删除';
COMMENT ON COLUMN public.user_love_flag.article_author IS '文章作者id';
COMMENT ON COLUMN public.user_love_flag.comment_author IS '填写评论的人员id';
COMMENT ON COLUMN public.user_love_flag.to_user_id IS '点赞的接受人';
-- public.user_read_article definition
-- Drop table
-- DROP TABLE public.user_read_article;
CREATE TABLE public.user_read_article(
id bigserial NOT NULL,
created_at int8 NULL,
updated_at int8 NULL,
deleted_at int8 NULL,
"version" int8 NULL,
company_id int8 NULL,
user_id int8 NULL,
article_id int8 NULL,
title text NULL,
author jsonb NULL DEFAULT '{}' ::jsonb,
is_del int8 NULL DEFAULT 0,
CONSTRAINT user_read_article_pkey PRIMARY KEY (id)
);
CREATE INDEX user_read_article_company_id_idx ON public.user_read_article USING btree(company_id);
CREATE INDEX user_read_article_user_id_idx ON public.user_read_article USING btree(user_id);
-- public.user_role definition
-- Drop table
-- DROP TABLE public.user_role;
CREATE TABLE public.user_role(
id bigserial NOT NULL,
company_id int8 NULL,
user_id int8 NULL,
role_id int8 NULL,
created_at int8 NULL,
updated_at int8 NULL,
deleted_at int8 NULL,
"version" int8 NULL,
CONSTRAINT user_role_pkey PRIMARY KEY (id)
);
-- public.user_simples definition
-- Drop table
-- DROP TABLE public.user_simples;
CREATE TABLE public.user_simples(
id bigserial NOT NULL,
"name" text NULL,
avatar text NULL,
"group" text NULL,
"position" text NULL,
CONSTRAINT user_simples_pkey PRIMARY KEY (id)
);
... ...