板块创建成功
This commit is contained in:
@@ -27,7 +27,7 @@ type ForumCommentsColumns struct {
|
|||||||
ParentId string // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
ParentId string // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
||||||
ReplyToUserId string // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
ReplyToUserId string // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
||||||
Content string // 评论内容(支持emoji)
|
Content string // 评论内容(支持emoji)
|
||||||
Status string // 状态:normal=正常 deleted=软删 audit=审核中 reject=驳回
|
Status string // 状态:1=正常 2=软删 3=审核中 4=驳回
|
||||||
LikeCount string // 点赞数(冗余)
|
LikeCount string // 点赞数(冗余)
|
||||||
CreatedAt string // 创建时间
|
CreatedAt string // 创建时间
|
||||||
UpdatedAt string // 更新时间
|
UpdatedAt string // 更新时间
|
||||||
|
|||||||
@@ -2,7 +2,15 @@ package Forum
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
v1 "TrangleAgent/api/forum/v1"
|
v1 "TrangleAgent/api/forum/v1"
|
||||||
|
"TrangleAgent/internal/dao"
|
||||||
|
"TrangleAgent/internal/model"
|
||||||
|
"TrangleAgent/internal/model/entity"
|
||||||
|
"TrangleAgent/internal/model/response"
|
||||||
|
"TrangleAgent/internal/service"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
|
"github.com/gogf/gf/v2/os/gtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type sForumBoards struct{}
|
type sForumBoards struct{}
|
||||||
@@ -11,21 +19,146 @@ func NewForumBoards() *sForumBoards {
|
|||||||
return &sForumBoards{}
|
return &sForumBoards{}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
service.RegisterForumBoards(NewForumBoards())
|
||||||
|
}
|
||||||
|
|
||||||
func (s *sForumBoards) Create(ctx context.Context, req *v1.ForumBoardsCreateReq) (res *v1.ForumBoardsCreateRes, err error) {
|
func (s *sForumBoards) Create(ctx context.Context, req *v1.ForumBoardsCreateReq) (res *v1.ForumBoardsCreateRes, err error) {
|
||||||
return nil, nil
|
// 校验参数
|
||||||
|
if req.Name == "" {
|
||||||
|
return nil, gerror.New("版块名称不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建版块
|
||||||
|
insert := entity.ForumBoards{
|
||||||
|
SectionId: req.SectionId,
|
||||||
|
Name: req.Name,
|
||||||
|
Description: req.Description,
|
||||||
|
CoverImage: req.CoverImage,
|
||||||
|
Status: req.Status,
|
||||||
|
DisplayOrder: req.DisplayOrder,
|
||||||
|
CreatedAt: gtime.Now(),
|
||||||
|
UpdatedAt: gtime.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
// 如果 Status 为空,默认为 normal
|
||||||
|
if insert.Status == "" {
|
||||||
|
insert.Status = "normal"
|
||||||
|
}
|
||||||
|
|
||||||
|
result, err := dao.ForumBoards.Ctx(ctx).Data(insert).Insert()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "创建版块失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
id, err := result.LastInsertId()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "获取版块ID失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.ForumBoardsCreateRes{Id: uint64(id)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sForumBoards) Update(ctx context.Context, req *v1.ForumBoardsUpdateReq) (res *v1.ForumBoardsUpdateRes, err error) {
|
func (s *sForumBoards) Update(ctx context.Context, req *v1.ForumBoardsUpdateReq) (res *v1.ForumBoardsUpdateRes, err error) {
|
||||||
return nil, nil
|
if req.Id == 0 {
|
||||||
|
return nil, gerror.New("版块ID不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 只能修改部分字段
|
||||||
|
|
||||||
|
data := entity.ForumBoards{
|
||||||
|
Id: req.Id,
|
||||||
|
SectionId: req.SectionId,
|
||||||
|
Name: req.Name,
|
||||||
|
Description: req.Description,
|
||||||
|
CoverImage: req.CoverImage,
|
||||||
|
Status: req.Status,
|
||||||
|
DisplayOrder: req.DisplayOrder,
|
||||||
|
UpdatedAt: gtime.Now(),
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = dao.ForumBoards.Ctx(ctx).Data(data).OmitEmpty().Where(dao.ForumBoards.Columns().Id, req.Id).Update()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "更新版块失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.ForumBoardsUpdateRes{Id: req.Id}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sForumBoards) Delete(ctx context.Context, req *v1.ForumBoardsDeleteReq) (res *v1.ForumBoardsDeleteRes, err error) {
|
func (s *sForumBoards) Delete(ctx context.Context, req *v1.ForumBoardsDeleteReq) (res *v1.ForumBoardsDeleteRes, err error) {
|
||||||
return nil, nil
|
if req.Id == 0 {
|
||||||
|
return nil, gerror.New("版块ID不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
// 物理删除
|
||||||
|
_, err = dao.ForumBoards.Ctx(ctx).Where(dao.ForumBoards.Columns().Id, req.Id).Delete()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "删除版块失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.ForumBoardsDeleteRes{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sForumBoards) View(ctx context.Context, req *v1.ForumBoardsViewReq) (res *v1.ForumBoardsViewRes, err error) {
|
func (s *sForumBoards) View(ctx context.Context, req *v1.ForumBoardsViewReq) (res *v1.ForumBoardsViewRes, err error) {
|
||||||
return nil, nil
|
if req.Id == 0 {
|
||||||
|
return nil, gerror.New("版块ID不能为空")
|
||||||
|
}
|
||||||
|
|
||||||
|
var board model.ForumBoardViewParams
|
||||||
|
err = dao.ForumBoards.Ctx(ctx).Where(dao.ForumBoards.Columns().Id, req.Id).Scan(&board)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "查询版块失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.ForumBoardsViewRes{
|
||||||
|
ForumBoardViewParams: board,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sForumBoards) List(ctx context.Context, req *v1.ForumBoardsListReq) (res *v1.ForumBoardsListRes, err error) {
|
func (s *sForumBoards) List(ctx context.Context, req *v1.ForumBoardsListReq) (res *v1.ForumBoardsListRes, err error) {
|
||||||
return nil, nil
|
m := dao.ForumBoards.Ctx(ctx)
|
||||||
|
|
||||||
|
if req.SectionId != 0 {
|
||||||
|
m = m.Where(dao.ForumBoards.Columns().SectionId, req.SectionId)
|
||||||
|
}
|
||||||
|
if req.Name != "" {
|
||||||
|
m = m.WhereLike(dao.ForumBoards.Columns().Name, "%"+req.Name+"%")
|
||||||
|
}
|
||||||
|
if req.Status != "" {
|
||||||
|
m = m.Where(dao.ForumBoards.Columns().Status, req.Status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 默认按 DisplayOrder 降序,Id 升序
|
||||||
|
m = m.OrderDesc(dao.ForumBoards.Columns().DisplayOrder).OrderAsc(dao.ForumBoards.Columns().Id)
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
total, err := m.Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "获取版块总数失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
var list []*model.ForumBoardViewParams
|
||||||
|
|
||||||
|
page := req.Page
|
||||||
|
if page <= 0 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
size := req.PageSize
|
||||||
|
if size <= 0 {
|
||||||
|
size = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
err = m.Page(page, size).Scan(&list)
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "查询版块列表失败")
|
||||||
|
}
|
||||||
|
|
||||||
|
return &v1.ForumBoardsListRes{
|
||||||
|
PageResult: response.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Page: page,
|
||||||
|
PageSize: size,
|
||||||
|
},
|
||||||
|
List: list,
|
||||||
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import (
|
|||||||
v1 "TrangleAgent/api/forum/v1"
|
v1 "TrangleAgent/api/forum/v1"
|
||||||
"TrangleAgent/internal/dao"
|
"TrangleAgent/internal/dao"
|
||||||
"TrangleAgent/internal/model"
|
"TrangleAgent/internal/model"
|
||||||
|
"TrangleAgent/internal/model/entity"
|
||||||
|
"TrangleAgent/internal/model/response"
|
||||||
"TrangleAgent/internal/service"
|
"TrangleAgent/internal/service"
|
||||||
"context"
|
"context"
|
||||||
|
|
||||||
@@ -36,7 +38,7 @@ func (s *sForumPosts) Create(ctx context.Context, req *v1.ForumPostsCreateReq) (
|
|||||||
}
|
}
|
||||||
|
|
||||||
//创建帖子
|
//创建帖子
|
||||||
insert := model.ForumPost{
|
insert := entity.ForumPosts{
|
||||||
BoardId: req.BoardId,
|
BoardId: req.BoardId,
|
||||||
UserId: req.UserId,
|
UserId: req.UserId,
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
@@ -46,6 +48,11 @@ func (s *sForumPosts) Create(ctx context.Context, req *v1.ForumPostsCreateReq) (
|
|||||||
CreatedAt: gtime.Now(),
|
CreatedAt: gtime.Now(),
|
||||||
UpdatedAt: gtime.Now(),
|
UpdatedAt: gtime.Now(),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if insert.Status == "" {
|
||||||
|
insert.Status = "normal"
|
||||||
|
}
|
||||||
|
|
||||||
result, err := dao.ForumPosts.Ctx(ctx).Data(insert).Insert()
|
result, err := dao.ForumPosts.Ctx(ctx).Data(insert).Insert()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, gerror.Wrap(err, "创建帖子失败")
|
return nil, gerror.Wrap(err, "创建帖子失败")
|
||||||
@@ -69,14 +76,14 @@ func (s *sForumPosts) Update(ctx context.Context, req *v1.ForumPostsUpdateReq) (
|
|||||||
return nil, gerror.New("内容长度要在5-10000之间")
|
return nil, gerror.New("内容长度要在5-10000之间")
|
||||||
}
|
}
|
||||||
//只能修改 帖子标题 帖子正文 帖子封面图URL
|
//只能修改 帖子标题 帖子正文 帖子封面图URL
|
||||||
fields := []string{"title", "content", "cover_image"}
|
|
||||||
//更新帖子
|
//更新帖子
|
||||||
_, err = dao.ForumPosts.Ctx(ctx).Data(model.ForumPost{
|
_, err = dao.ForumPosts.Ctx(ctx).Data(entity.ForumPosts{
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
Title: req.Title,
|
Title: req.Title,
|
||||||
Content: req.Content,
|
Content: req.Content,
|
||||||
CoverImage: req.CoverImage,
|
CoverImage: req.CoverImage,
|
||||||
}).Fields(fields).OmitEmpty().Update()
|
UpdatedAt: gtime.Now(),
|
||||||
|
}).Fields("title", "content", "cover_image", "updated_at").OmitEmpty().Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, gerror.Wrap(err, "更新帖子失败")
|
return nil, gerror.Wrap(err, "更新帖子失败")
|
||||||
}
|
}
|
||||||
@@ -116,12 +123,48 @@ func (s *sForumPosts) List(ctx context.Context, req *v1.ForumPostsListReq) (res
|
|||||||
if req.BoardId != 0 {
|
if req.BoardId != 0 {
|
||||||
mod = mod.Where(dao.ForumPosts.Columns().BoardId, req.BoardId)
|
mod = mod.Where(dao.ForumPosts.Columns().BoardId, req.BoardId)
|
||||||
}
|
}
|
||||||
|
if req.UserId != 0 {
|
||||||
|
mod = mod.Where(dao.ForumPosts.Columns().UserId, req.UserId)
|
||||||
|
}
|
||||||
|
if req.Status != "" {
|
||||||
|
mod = mod.Where(dao.ForumPosts.Columns().Status, req.Status)
|
||||||
|
}
|
||||||
|
if req.IsPinned != 0 {
|
||||||
|
mod = mod.Where(dao.ForumPosts.Columns().IsPinned, req.IsPinned)
|
||||||
|
}
|
||||||
|
if req.IsEssence != 0 {
|
||||||
|
mod = mod.Where(dao.ForumPosts.Columns().IsEssence, req.IsEssence)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 排序:优先置顶,然后按创建时间倒序
|
||||||
|
mod = mod.OrderDesc(dao.ForumPosts.Columns().IsPinned).OrderDesc(dao.ForumPosts.Columns().CreatedAt)
|
||||||
|
|
||||||
|
// 分页
|
||||||
|
page := req.Page
|
||||||
|
if page <= 0 {
|
||||||
|
page = 1
|
||||||
|
}
|
||||||
|
size := req.PageSize
|
||||||
|
if size <= 0 {
|
||||||
|
size = 10
|
||||||
|
}
|
||||||
|
|
||||||
|
total, err := mod.Count()
|
||||||
|
if err != nil {
|
||||||
|
return nil, gerror.Wrap(err, "获取帖子总数失败")
|
||||||
|
}
|
||||||
|
|
||||||
var list []*model.ForumPostViewParams
|
var list []*model.ForumPostViewParams
|
||||||
err = mod.Scan(&list)
|
err = mod.Page(page, size).Scan(&list)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, gerror.Wrap(err, "查询帖子列表失败")
|
return nil, gerror.Wrap(err, "查询帖子列表失败")
|
||||||
}
|
}
|
||||||
return &v1.ForumPostsListRes{
|
return &v1.ForumPostsListRes{
|
||||||
|
PageResult: response.PageResult{
|
||||||
|
Total: total,
|
||||||
|
Page: page,
|
||||||
|
PageSize: size,
|
||||||
|
},
|
||||||
List: list,
|
List: list,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ package logic
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
_ "TrangleAgent/internal/logic/Forum"
|
_ "TrangleAgent/internal/logic/Forum"
|
||||||
|
_ "TrangleAgent/internal/logic/chat"
|
||||||
_ "TrangleAgent/internal/logic/containment"
|
_ "TrangleAgent/internal/logic/containment"
|
||||||
_ "TrangleAgent/internal/logic/department"
|
_ "TrangleAgent/internal/logic/department"
|
||||||
_ "TrangleAgent/internal/logic/login"
|
_ "TrangleAgent/internal/logic/login"
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package user
|
package user
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
v1 "TrangleAgent/api/user/v1"
|
v1 "TrangleAgent/api/user/v1"
|
||||||
"TrangleAgent/internal/dao"
|
"TrangleAgent/internal/dao"
|
||||||
"TrangleAgent/internal/model"
|
"TrangleAgent/internal/model"
|
||||||
"TrangleAgent/internal/model/entity"
|
"TrangleAgent/internal/model/entity"
|
||||||
"TrangleAgent/internal/service"
|
"TrangleAgent/internal/service"
|
||||||
|
"context"
|
||||||
|
|
||||||
"github.com/gogf/gf/v2/errors/gcode"
|
"github.com/gogf/gf/v2/errors/gcode"
|
||||||
"github.com/gogf/gf/v2/errors/gerror"
|
"github.com/gogf/gf/v2/errors/gerror"
|
||||||
@@ -77,7 +77,7 @@ func (s *sUser) UserList(ctx context.Context, req *v1.UserListReq) (res *v1.User
|
|||||||
req.PageResult.Page = req.Page
|
req.PageResult.Page = req.Page
|
||||||
req.PageResult.PageSize = req.PageSize
|
req.PageResult.PageSize = req.PageSize
|
||||||
|
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sUser) UserView(ctx context.Context, req *v1.UserViewReq) (res *v1.UserViewRes, err error) {
|
func (s *sUser) UserView(ctx context.Context, req *v1.UserViewReq) (res *v1.UserViewRes, err error) {
|
||||||
@@ -92,10 +92,10 @@ func (s *sUser) UserView(ctx context.Context, req *v1.UserViewReq) (res *v1.User
|
|||||||
res = &v1.UserViewRes{}
|
res = &v1.UserViewRes{}
|
||||||
err = m.Scan(&res.UserViewParams)
|
err = m.Scan(&res.UserViewParams)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "查询用户信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sUser) UserUpdate(ctx context.Context, req *v1.UserUpdateReq) (res *v1.UserUpdateRes, err error) {
|
func (s *sUser) UserUpdate(ctx context.Context, req *v1.UserUpdateReq) (res *v1.UserUpdateRes, err error) {
|
||||||
@@ -105,28 +105,28 @@ func (s *sUser) UserUpdate(ctx context.Context, req *v1.UserUpdateReq) (res *v1.
|
|||||||
// 根据账号更新用户信息
|
// 根据账号更新用户信息
|
||||||
_, err = m.Data(req).Where(dao.Users.Columns().Account, req.Account).Update()
|
_, err = m.Data(req).Where(dao.Users.Columns().Account, req.Account).Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "更新用户信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.UserUpdateRes{}
|
res = &v1.UserUpdateRes{}
|
||||||
// 获取更新后的用户信息
|
// 获取更新后的用户信息
|
||||||
err = m.Where(dao.Users.Columns().Account, req.Account).Scan(&res)
|
err = m.Where(dao.Users.Columns().Account, req.Account).Scan(&res)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "查询用户信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *sUser) UserDelete(ctx context.Context, req *v1.UserDeleteReq) (res *v1.UserDeleteRes, err error) {
|
func (s *sUser) UserDelete(ctx context.Context, req *v1.UserDeleteReq) (res *v1.UserDeleteRes, err error) {
|
||||||
// 根据账号删除用户
|
// 根据账号删除用户
|
||||||
_, err = dao.Users.Ctx(ctx).Where(dao.Users.Columns().Account, req.Account).Delete()
|
_, err = dao.Users.Ctx(ctx).Where(dao.Users.Columns().Account, req.Account).Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "删除用户失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.UserDeleteRes{}
|
res = &v1.UserDeleteRes{}
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleCreate 创建角色
|
// RoleCreate 创建角色
|
||||||
@@ -145,13 +145,13 @@ func (s *sUser) RoleCreate(ctx context.Context, req *v1.RoleCreateReq) (res *v1.
|
|||||||
|
|
||||||
id, err := dao.RoleCards.Ctx(ctx).Data(data).InsertAndGetId()
|
id, err := dao.RoleCards.Ctx(ctx).Data(data).InsertAndGetId()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "创建角色失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.RoleCreateRes{
|
res = &v1.RoleCreateRes{
|
||||||
Id: uint64(id),
|
Id: uint64(id),
|
||||||
}
|
}
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleUpdate 更新角色
|
// RoleUpdate 更新角色
|
||||||
@@ -174,13 +174,13 @@ func (s *sUser) RoleUpdate(ctx context.Context, req *v1.RoleUpdateReq) (res *v1.
|
|||||||
|
|
||||||
_, err = dao.RoleCards.Ctx(ctx).Data(data).Where(dao.RoleCards.Columns().Id, req.Id).Update()
|
_, err = dao.RoleCards.Ctx(ctx).Data(data).Where(dao.RoleCards.Columns().Id, req.Id).Update()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "更新角色失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.RoleUpdateRes{
|
res = &v1.RoleUpdateRes{
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
}
|
}
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleView 查看角色详情
|
// RoleView 查看角色详情
|
||||||
@@ -189,7 +189,7 @@ func (s *sUser) RoleView(ctx context.Context, req *v1.RoleViewReq) (res *v1.Role
|
|||||||
var role entity.RoleCards
|
var role entity.RoleCards
|
||||||
err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.Id).Scan(&role)
|
err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.Id).Scan(&role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "查询角色详情失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.RoleViewRes{
|
res = &v1.RoleViewRes{
|
||||||
@@ -219,7 +219,7 @@ func (s *sUser) RoleView(ctx context.Context, req *v1.RoleViewReq) (res *v1.Role
|
|||||||
QaDiscretion: role.QaDiscretion,
|
QaDiscretion: role.QaDiscretion,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleList 获取角色列表
|
// RoleList 获取角色列表
|
||||||
@@ -293,7 +293,7 @@ func (s *sUser) RoleList(ctx context.Context, req *v1.RoleListReq) (res *v1.Role
|
|||||||
req.PageResult.Page = req.Page
|
req.PageResult.Page = req.Page
|
||||||
req.PageResult.PageSize = req.PageSize
|
req.PageResult.PageSize = req.PageSize
|
||||||
|
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RoleDelete 删除角色
|
// RoleDelete 删除角色
|
||||||
@@ -301,13 +301,13 @@ func (s *sUser) RoleDelete(ctx context.Context, req *v1.RoleDeleteReq) (res *v1.
|
|||||||
// 根据ID删除角色
|
// 根据ID删除角色
|
||||||
_, err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.Id).Delete()
|
_, err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.Id).Delete()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "删除角色失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
res = &v1.RoleDeleteRes{
|
res = &v1.RoleDeleteRes{
|
||||||
Id: req.Id,
|
Id: req.Id,
|
||||||
}
|
}
|
||||||
return
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// RolePermissionCheck 权限查询
|
// RolePermissionCheck 权限查询
|
||||||
@@ -316,7 +316,7 @@ func (s *sUser) RolePermissionCheck(ctx context.Context, req *v1.RolePermissionC
|
|||||||
var role entity.RoleCards
|
var role entity.RoleCards
|
||||||
err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.RoleId).Scan(&role)
|
err = dao.RoleCards.Ctx(ctx).Where(dao.RoleCards.Columns().Id, req.RoleId).Scan(&role)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, gerror.Wrap(err, "查询角色信息失败")
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据轨道类型获取对应的轨道值
|
// 根据轨道类型获取对应的轨道值
|
||||||
@@ -343,5 +343,9 @@ func (s *sUser) RolePermissionCheck(ctx context.Context, req *v1.RolePermissionC
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 权限不足,返回错误
|
// 权限不足,返回错误
|
||||||
return nil, gerror.New("权限不足")
|
res = &v1.RolePermissionCheckRes{
|
||||||
|
Code: 403,
|
||||||
|
Mes: "权限不足",
|
||||||
|
}
|
||||||
|
return res, nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ type ForumComments struct {
|
|||||||
ParentId any // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
ParentId any // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
||||||
ReplyToUserId any // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
ReplyToUserId any // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
||||||
Content any // 评论内容(支持emoji)
|
Content any // 评论内容(支持emoji)
|
||||||
Status any // 状态:normal=正常 deleted=软删 audit=审核中 reject=驳回
|
Status any // 状态:1=正常 2=软删 3=审核中 4=驳回
|
||||||
LikeCount any // 点赞数(冗余)
|
LikeCount any // 点赞数(冗余)
|
||||||
CreatedAt *gtime.Time // 创建时间
|
CreatedAt *gtime.Time // 创建时间
|
||||||
UpdatedAt *gtime.Time // 更新时间
|
UpdatedAt *gtime.Time // 更新时间
|
||||||
|
|||||||
@@ -10,15 +10,15 @@ import (
|
|||||||
|
|
||||||
// ForumComments is the golang structure for table forum_comments.
|
// ForumComments is the golang structure for table forum_comments.
|
||||||
type ForumComments struct {
|
type ForumComments struct {
|
||||||
Id uint64 `json:"id" orm:"id" description:"评论ID(主键)"` // 评论ID(主键)
|
Id uint64 `json:"id" orm:"id" description:"评论ID(主键)"` // 评论ID(主键)
|
||||||
PostId uint64 `json:"postId" orm:"post_id" description:"所属帖子ID(关联 forum_posts.id,无外键)"` // 所属帖子ID(关联 forum_posts.id,无外键)
|
PostId uint64 `json:"postId" orm:"post_id" description:"所属帖子ID(关联 forum_posts.id,无外键)"` // 所属帖子ID(关联 forum_posts.id,无外键)
|
||||||
UserId uint64 `json:"userId" orm:"user_id" description:"评论发布者ID(关联 users.id,无外键)"` // 评论发布者ID(关联 users.id,无外键)
|
UserId uint64 `json:"userId" orm:"user_id" description:"评论发布者ID(关联 users.id,无外键)"` // 评论发布者ID(关联 users.id,无外键)
|
||||||
ParentId uint64 `json:"parentId" orm:"parent_id" description:"父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)"` // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
ParentId uint64 `json:"parentId" orm:"parent_id" description:"父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)"` // 父评论ID:NULL=一级评论;非NULL=二级评论(指向一级评论ID,无外键)
|
||||||
ReplyToUserId uint64 `json:"replyToUserId" orm:"reply_to_user_id" description:"回复的用户ID(可选,用于展示“回复@xxx”,无外键)"` // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
ReplyToUserId uint64 `json:"replyToUserId" orm:"reply_to_user_id" description:"回复的用户ID(可选,用于展示“回复@xxx”,无外键)"` // 回复的用户ID(可选,用于展示“回复@xxx”,无外键)
|
||||||
Content string `json:"content" orm:"content" description:"评论内容(支持emoji)"` // 评论内容(支持emoji)
|
Content string `json:"content" orm:"content" description:"评论内容(支持emoji)"` // 评论内容(支持emoji)
|
||||||
Status string `json:"status" orm:"status" description:"状态:normal=正常 deleted=软删 audit=审核中 reject=驳回"` // 状态:normal=正常 deleted=软删 audit=审核中 reject=驳回
|
Status string `json:"status" orm:"status" description:"状态:1=正常 2=软删 3=审核中 4=驳回"` // 状态:1=正常 2=软删 3=审核中 4=驳回
|
||||||
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数(冗余)"` // 点赞数(冗余)
|
LikeCount uint `json:"likeCount" orm:"like_count" description:"点赞数(冗余)"` // 点赞数(冗余)
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"` // 创建时间
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"` // 更新时间
|
||||||
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
DeletedAt *gtime.Time `json:"deletedAt" orm:"deleted_at" description:"软删除时间"` // 软删除时间
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,19 +6,13 @@ import (
|
|||||||
|
|
||||||
// ForumBoard 论坛版块
|
// ForumBoard 论坛版块
|
||||||
type ForumBoard struct {
|
type ForumBoard struct {
|
||||||
Id uint64 `json:"id" orm:"id" description:"版块ID"`
|
Id uint64 `json:"id" orm:"id" description:"版块ID"`
|
||||||
SectionId uint64 `json:"sectionId" orm:"section_id" description:"所属频道ID"`
|
SectionId uint64 `json:"sectionId" orm:"section_id" description:"所属频道ID"`
|
||||||
Name string `json:"name" orm:"name" description:"版块名称"`
|
Name string `json:"name" orm:"name" description:"版块名称"`
|
||||||
Description string `json:"description" orm:"description" description:"版块简介"`
|
Description string `json:"description" orm:"description" description:"版块简介"`
|
||||||
CoverImage string `json:"coverImage" orm:"cover_image" description:"版块封面图URL"`
|
CoverImage string `json:"coverImage" orm:"cover_image" description:"版块封面图URL"`
|
||||||
Status string `json:"status" orm:"status" description:"版块状态"`
|
Status string `json:"status" orm:"status" description:"版块状态"`
|
||||||
DisplayOrder int `json:"displayOrder" orm:"display_order" description:"排序值"`
|
DisplayOrder int `json:"displayOrder" orm:"display_order" description:"排序值"`
|
||||||
PostCount uint `json:"postCount" orm:"post_count" description:"帖子总数"`
|
|
||||||
TodayPostCount uint `json:"todayPostCount" orm:"today_post_count" description:"今日发帖数"`
|
|
||||||
LastPostId uint64 `json:"lastPostId" orm:"last_post_id" description:"最后一篇帖子ID"`
|
|
||||||
LastPostAt *gtime.Time `json:"lastPostAt" orm:"last_post_at" description:"最后发帖时间"`
|
|
||||||
CreatedAt *gtime.Time `json:"createdAt" orm:"created_at" description:"创建时间"`
|
|
||||||
UpdatedAt *gtime.Time `json:"updatedAt" orm:"updated_at" description:"更新时间"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ForumBoardViewParams 版块查看参数
|
// ForumBoardViewParams 版块查看参数
|
||||||
|
|||||||
8
Backend/internal/service/chat.go
Normal file
8
Backend/internal/service/chat.go
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
// ================================================================================
|
||||||
|
// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT.
|
||||||
|
// You can delete these comments if you wish manually maintain this interface file.
|
||||||
|
// ================================================================================
|
||||||
|
|
||||||
|
package service
|
||||||
|
|
||||||
|
type ()
|
||||||
@@ -11,7 +11,6 @@ import (
|
|||||||
"github.com/gogf/gf/v2/os/gctx"
|
"github.com/gogf/gf/v2/os/gctx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func mai2n() {
|
func main() {
|
||||||
|
|
||||||
cmd.Main.Run(gctx.GetInitCtx())
|
cmd.Main.Run(gctx.GetInitCtx())
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user