feat(subscription): add Language parameter to GetSubscription request and update query logic

This commit is contained in:
Chang lue Tsen
2025-09-04 03:14:31 -04:00
parent f632ea2c89
commit 10757612f5
5 changed files with 32 additions and 7 deletions
@@ -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