增加社区列表接口,任务相关接口修改

This commit is contained in:
lianghuanjie
2024-12-19 21:14:14 +08:00
parent 391a9d3481
commit a3c4adfa25
32 changed files with 1163 additions and 197 deletions

View File

@@ -0,0 +1,48 @@
package task
import (
"context"
"nova_task/internal/pkg/errs"
"nova_task/internal/svc"
"nova_task/internal/types"
"github.com/zeromicro/go-zero/core/logx"
)
type GetCommunityListLogic struct {
logx.Logger
ctx context.Context
svcCtx *svc.ServiceContext
}
// 获取社区列表
func NewGetCommunityListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetCommunityListLogic {
return &GetCommunityListLogic{
Logger: logx.WithContext(ctx),
ctx: ctx,
svcCtx: svcCtx,
}
}
func (l *GetCommunityListLogic) GetCommunityList() (*types.GetCommunityListResp, error) {
cs, err := l.svcCtx.CommunityModel.All(l.ctx)
if err != nil {
l.Errorw("get community list error", logx.Field("err", err))
return nil, errs.New(errs.ErrDatabaseOperate, err)
}
var communityList []types.Community
for _, c := range cs {
communityList = append(communityList, types.Community{
Id: c.Id,
Title: c.Title,
Logo: c.Logo,
Description: c.Description,
StartAt: c.StartAt.Time.Unix(),
EndAt: c.EndAt.Time.Unix(),
})
}
return &types.GetCommunityListResp{CommunityList: communityList}, nil
}