作者 yangfu
测试环境服务端域名 http://sumifcc-discuss-test.sumifcc.com/
\ No newline at end of file
# 说明
### 测试环境
服务端域名 http://sumifcc-discuss-test.sumifcc.com/
### 可设置环境变量
- DataSource
数据库连接,样例
``` code
host=数据库IP地址 user=用户名 password=密码 dbname=数据库名 port=31543 sslmode=disable TimeZone=Asia/Shanghai
```
\ No newline at end of file
... ...
... ... @@ -48,7 +48,7 @@ type (
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
TagCreateResponse {
... ... @@ -65,7 +65,7 @@ type (
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
TagEditResponse {
... ...
... ... @@ -248,7 +248,7 @@ type (
MiniArticleDraftGetMeResponse {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
... ... @@ -356,6 +356,7 @@ type (
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
)
... ...
... ... @@ -229,7 +229,7 @@ type (
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
... ...
... ... @@ -71,9 +71,9 @@ type (
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
CompanyName string `json:"companyName,omitempty"` // 公司名称
Name string `json:"name,omitempty"` // 名称
Avatar string `json:"avatar,omitempty"` // 头像
Position string `json:"position,omitempty"` // 职位
Name string `json:"name"` // 名称
Avatar string `json:"avatar"` // 头像
Position string `json:"position"` // 职位
}
... ...
... ... @@ -71,7 +71,7 @@ service Core {
post /mini/user/unfollow (FollowRequest)
@doc "我点赞的文章或评论"
@handler miniMyLike
post /user/mylike (MiniMyLikeRequest)returns (MiniMyLikeResponse)
post /mini/user/mylike (MiniMyLikeRequest)returns (MiniMyLikeResponse)
}
type(
... ... @@ -183,9 +183,10 @@ type(
}
Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
CompanyId int64 `json:"companyId"` // 公司ID
ParentId int64 `json:"parentId"` // 父级ID
Name string `json:"name"` // 部门名称
UserIds []int64 `json:"userIds"` // 部门下的用户
}
UserSearchRequest{
Page int `json:"page,optional"`
... ...
... ... @@ -242,7 +242,7 @@ func RegisterHandlers(server *rest.Server, serverCtx *svc.ServiceContext) {
},
{
Method: http.MethodPost,
Path: "/user/mylike",
Path: "/mini/user/mylike",
Handler: user.MiniMyLikeHandler(serverCtx),
},
},
... ...
... ... @@ -51,6 +51,8 @@ func (l *MiniArticleMarkUserReadLogic) MiniArticleMarkUserRead(req *types.MiniAr
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
}
if len(markRecord) > 0 {
markRecord[0].Author = articleData.Author
markRecord[0].Title = articleData.Title
_, err = l.svcCtx.UserReadArticleRepository.Update(l.ctx, conn, markRecord[0])
if err != nil {
return nil, xerr.NewErrMsgErr("标记浏览记录失败", err)
... ...
... ... @@ -170,11 +170,11 @@ func (l *MiniCreateArticleLogic) MiniCreateArticle(req *types.MiniArticleCreateR
}
//设置内容概要
if len(sectionList) > 0 {
// 截取内容 30个字
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range sectionList[0].Content {
if runeNumber > 30 {
if runeNumber > 50 {
break
}
runeNumber += 1
... ...
... ... @@ -52,6 +52,7 @@ func (l *MiniSearchArticleDraftMeLogic) MiniSearchArticleDraftMe(req *types.Mini
Section: draftList[i].Content,
Title: draftList[i].Title,
Images: images,
CreatedAt: draftList[i].CreatedAt,
}
}
return resp, nil
... ...
... ... @@ -65,6 +65,7 @@ func (l *SystemGetArticleLogic) SystemGetArticle(req *types.SystemArticleGetRequ
CountRead: article.CountRead,
Show: int(article.Show),
Tags: make([]types.ArticleTagItem, 0),
TargetUser: int(article.TargetUser),
}
//标签
if len(article.Tags) > 0 {
... ...
... ... @@ -4,6 +4,8 @@ import (
"context"
"strconv"
"strings"
"github.com/samber/lo"
"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"
... ... @@ -11,7 +13,6 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/tool/oss"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"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"
... ... @@ -147,11 +148,11 @@ func (l *SystemUpdateArticleLogic) SystemUpdateArticle(req *types.SystemArticleU
})
//设置内容概要
if len(req.Section) > 0 {
// 截取内容 30个字
// 截取内容 50个字
runeNumber := 0 //字数
stringIndex := 0 //字符串长度
for i := range req.Section[0].Content {
if runeNumber > 30 {
if runeNumber > 50 {
break
}
runeNumber += 1
... ...
... ... @@ -57,6 +57,7 @@ func (l *SystemAddLogic) SystemAdd(req *types.DepartmentAddRequest) (resp *types
if len(req.Ids) > 0 {
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().
WithOffsetLimit(1, len(req.Ids)).WithFindOnly().
WithKV("ids", req.Ids).
WithKV("companyId", userToken.CompanyId))
if err != nil {
return err
... ...
... ... @@ -4,6 +4,8 @@ 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/contextdata"
"gitlab.fjmaimaimai.com/allied-creation/sumifcc-discuss/pkg/xerr"
"github.com/zeromicro/go-zero/core/logx"
... ... @@ -24,17 +26,32 @@ func NewSystemGetLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SystemG
}
func (l *SystemGetLogic) SystemGet(req *types.DepartmentGetRequest) (resp *types.DepartmentGetResponse, err error) {
var userToken = contextdata.GetUserTokenFromCtx(l.ctx)
var conn = l.svcCtx.DefaultDBConn()
department, err := l.svcCtx.DepartmentRepository.FindOne(l.ctx, conn, req.Id)
if err != nil {
return nil, xerr.NewErrMsg("数据不存在")
}
// 部门下的用户
_, users, err := l.svcCtx.UserRepository.Find(l.ctx, conn, domain.NewQueryOptions().WithFindOnly().
WithKV("companyId", userToken.CompanyId).
WithKV("auditStatus", domain.UserAuditStatusPassed).
WithKV("departmentId", department.Id))
if err != nil {
return nil, err
}
ids := make([]int64, 0)
for i := range users {
ids = append(ids, users[i].Id)
}
resp = &types.DepartmentGetResponse{
Department: types.Department{
Id: department.Id,
CompanyId: department.CompanyId,
ParentId: department.ParentId,
Name: department.Name,
UserIds: ids,
},
}
return resp, nil
... ...
... ... @@ -43,10 +43,7 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
if cnt > 0 {
return nil, xerr.NewErrMsg(fmt.Sprintf("已存在标签 分类[%s]名称[%s]", req.Category, req.Name))
}
//获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
newTag := &domain.ArticleTag{
Id: 0,
CompanyId: req.CompanyId,
... ... @@ -54,17 +51,23 @@ func (l *CreateTagLogic) CreateTag(req *types.TagCreateRequest) (resp *types.Tag
UpdatedAt: 0,
DeletedAt: 0,
Version: 0,
Image: domain.Image{
Url: req.Image,
Width: w,
Height: h,
},
Image: domain.Image{},
Name: req.Name,
Category: req.Category,
Remark: req.Remark,
Other: req.Other,
}
if len(req.Image) > 0 {
//获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
newTag.Image = domain.Image{
Url: req.Image,
Width: w,
Height: h,
}
}
newTag, err = l.svcCtx.ArticleTagRepository.Insert(l.ctx, conn, newTag)
if err != nil {
return nil, xerr.NewErrMsgErr("添加标签失败", err)
... ...
... ... @@ -54,16 +54,19 @@ func (l *EditTagLogic) EditTag(req *types.TagEditRequest) (resp *types.TagEditRe
if oldTag.CompanyId != req.CompanyId {
return nil, xerr.NewErrMsg("修改标签失败")
}
//获取图片的尺寸大小
oldTag.Image = domain.Image{}
if len(req.Image) > 0 {
// 获取图片的尺寸大小
fInfo, _ := oss.GetImageInfo(req.Image)
w, _ := strconv.Atoi(fInfo.ImageWidth.Value)
h, _ := strconv.Atoi(fInfo.ImageHeight.Value)
oldTag.Category = req.Category
oldTag.Image = domain.Image{
Url: req.Image,
Width: w,
Height: h,
}
}
oldTag.Category = req.Category
oldTag.Name = req.Name
oldTag.Remark = req.Remark
oldTag.Other = req.Other
... ...
... ... @@ -28,10 +28,10 @@ func (l *SearchTagLogic) SearchTag(req *types.TagListRequest) (resp *types.TagLi
queryOptions := domain.NewQueryOptions().WithOffsetLimit(req.Page, req.Size)
if len(req.Category) > 0 {
queryOptions = queryOptions.MustWithKV("group", req.Category)
queryOptions = queryOptions.MustWithKV("group", "%"+req.Category+"%")
}
if len(req.TagName) > 0 {
queryOptions = queryOptions.MustWithKV("name", req.TagName)
queryOptions = queryOptions.MustWithKV("name", "%"+req.TagName+"%")
}
if len(req.Remark) > 0 {
... ...
... ... @@ -140,7 +140,7 @@ type SystemArticleCommentSearchRequest struct {
Page int `json:"page"`
Size int `json:"size"`
ArticleId int64 `json:"articleId"` // 文章ID
TopId int64 `json:"topId"` // 文章顶层ID
TopId int64 `json:"topId,optional"` // 文章顶层ID
AuthorId int64 `json:"authorId,optional"` // 用户
Show int `json:"show,optional"` // 显示状态
BeginTime int64 `json:"beginTime,optional"` // 开始时间
... ... @@ -296,9 +296,9 @@ type SimpleUser struct {
Id int64 `json:"id"`
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
CompanyName string `json:"companyName,omitempty"` // 公司名称
Name string `json:"name,omitempty"` // 名称
Avatar string `json:"avatar,omitempty"` // 头像
Position string `json:"position,omitempty"` // 职位
Name string `json:"name"` // 名称
Avatar string `json:"avatar"` // 头像
Position string `json:"position"` // 职位
}
type SimpleArticle struct {
... ... @@ -316,7 +316,7 @@ type TagCreateRequest struct {
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
type TagCreateResponse struct {
... ... @@ -330,7 +330,7 @@ type TagEditRequest struct {
Name string `json:"name"` // 标签名称
Category string `json:"category"` // 标签分类
Remark string `json:"remark,optional"` // 备注
Other string `json:"other"`
Other string `json:"other,optional"`
}
type TagEditResponse struct {
... ... @@ -520,9 +520,10 @@ type Account struct {
type Department struct {
Id int64 `json:"id,omitempty"` // 部门ID
CompanyId int64 `json:"companyId,omitempty"` // 公司ID
ParentId int64 `json:"parentId,omitempty"` // 父级ID
Name string `json:"name,omitempty"` // 部门名称
CompanyId int64 `json:"companyId"` // 公司ID
ParentId int64 `json:"parentId"` // 父级ID
Name string `json:"name"` // 部门名称
UserIds []int64 `json:"userIds"` // 部门下的用户
}
type UserSearchRequest struct {
... ... @@ -949,7 +950,7 @@ type MiniArticleDraftGetMeRequest struct {
type MiniArticleDraftGetMeResponse struct {
Id int64 `json:"id"` //
Template int `json:"template"` // 使用哪个模板进行编辑 0、无 1、演绎式 2、归纳式
Section []string `json:"Section"` // 填写的内容
Section []string `json:"section"` // 填写的内容
Title string `json:"title"` // 标题
Images []string `json:"images"` // 图片
WhoRead []int64 `json:"whoRead"` // 谁可以看
... ... @@ -1047,6 +1048,7 @@ type SystemArticleGetResponse struct {
CountRead int `json:"countRead"` // 浏览数量
Show int `json:"show"` // 评论的展示状态(0显示、1不显示)
Tags []ArticleTagItem `json:"tags"` //标签
TargetUser int `json:"targetUser"` //分发方式 [0分发给所有人、1分发给指定的人]
}
type SystemArticleSearchRequest struct {
... ...
... ... @@ -136,7 +136,9 @@ func (repository *ArticleRepository) Find(ctx context.Context, conn transaction.
if v, ok := queryOptions["endCreatedAt"]; ok {
tx = tx.Where("created_at < ?", v)
}
if v, ok := queryOptions["authorId"]; ok {
tx = tx.Where("author_id=?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...
... ... @@ -155,7 +155,9 @@ func (repository *ArticleTagRepository) Find(ctx context.Context, conn transacti
if v, ok := queryOptions["ids"]; ok {
tx = tx.Where("id in (?)", v)
}
if v, ok := queryOptions["remark"]; ok {
tx = tx.Where("remark like ?", v)
}
if total, tx = transaction.PaginationAndCount(ctx, tx, queryOptions, &ms); tx.Error != nil {
return dms, tx.Error
}
... ...