增加社区列表接口,任务相关接口修改
This commit is contained in:
48
internal/logic/task/get_community_list_logic.go
Normal file
48
internal/logic/task/get_community_list_logic.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user