47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"lone-services/pkg/modelbase"
|
|
"lone-services/pkg/utils"
|
|
"lone-services/services/chore/internal/dao"
|
|
"lone-services/services/chore/internal/model"
|
|
|
|
"lone-services/rpc/chore/pb"
|
|
"lone-services/services/chore/internal/svc"
|
|
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
)
|
|
|
|
type ApiAnswerItemsLogic struct {
|
|
ctx context.Context
|
|
svcCtx *svc.ServiceContext
|
|
logx.Logger
|
|
BaseLogic
|
|
}
|
|
|
|
func NewApiAnswerItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiAnswerItemsLogic {
|
|
return &ApiAnswerItemsLogic{
|
|
ctx: ctx,
|
|
svcCtx: svcCtx,
|
|
Logger: logx.WithContext(ctx),
|
|
}
|
|
}
|
|
|
|
func (l *ApiAnswerItemsLogic) ApiAnswerItems(in *chore.EmptyReq) (*chore.Response, error) {
|
|
adminInfo := utils.GetUserFromCtx(l.ctx)
|
|
if adminInfo.ID < utils.NumberOne {
|
|
return l.fail(utils.ErrorNoLoginInfo)
|
|
}
|
|
var info []dao.AnswerInfo
|
|
w := modelbase.Params{Eq: map[string]string{"status": utils.StringStatusOk}}
|
|
|
|
err := model.AnswerModel{}.Init().Items(w, &info)
|
|
if err != nil {
|
|
l.Logger.Error(err)
|
|
return l.fail(utils.Fail)
|
|
}
|
|
|
|
return l.ok(info)
|
|
}
|