feat(subscription): add Language parameter to GetSubscription request and update query logic
This commit is contained in:
@@ -27,16 +27,25 @@ func NewGetSubscriptionLogic(ctx context.Context, svcCtx *svc.ServiceContext) *G
|
||||
}
|
||||
}
|
||||
|
||||
func (l *GetSubscriptionLogic) GetSubscription() (resp *types.GetSubscriptionResponse, err error) {
|
||||
func (l *GetSubscriptionLogic) GetSubscription(req *types.GetSubscriptionRequest) (resp *types.GetSubscriptionResponse, err error) {
|
||||
resp = &types.GetSubscriptionResponse{
|
||||
List: make([]types.Subscribe, 0),
|
||||
}
|
||||
// Get the subscription list
|
||||
data, err := l.svcCtx.SubscribeModel.QuerySubscribeListByShow(l.ctx)
|
||||
data, err := l.svcCtx.SubscribeModel.QuerySubscribeListByShow(l.ctx, req.Language)
|
||||
if err != nil {
|
||||
l.Errorw("[Site GetSubscription]", logger.Field("err", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get subscription list error: %v", err.Error())
|
||||
}
|
||||
// If no data is found for the specified language, query default language data
|
||||
if len(data) == 0 && req.Language != "" {
|
||||
data, err = l.svcCtx.SubscribeModel.QuerySubscribeListByShow(l.ctx, "")
|
||||
if err != nil {
|
||||
l.Errorw("[Site GetSubscription]", logger.Field("err", err.Error()))
|
||||
return nil, errors.Wrapf(xerr.NewErrCode(xerr.DatabaseQueryError), "get subscription list error: %v", err.Error())
|
||||
}
|
||||
}
|
||||
|
||||
list := make([]types.Subscribe, len(data))
|
||||
for i, item := range data {
|
||||
var sub types.Subscribe
|
||||
|
||||
Reference in New Issue
Block a user