123456789101112131415161718192021222324252627282930313233343536 |
- // Copyright 2019 getensh.com. All rights reserved.
- // Use of this source code is governed by getensh.com.
- package provider
- import (
- "context"
- "gd_management/apis"
- "gd_management/errors"
- "fmt"
- "github.com/astaxie/beego/orm"
- )
- func ManagementGetProviderMerchantApiList(ctx context.Context, req *apis.ManagementGetProviderMerchantApiListReq, reply *apis.ManagementGetProviderMerchantApiListReply) error {
- o := orm.NewOrm()
- sql := fmt.Sprintf("select t1.day_count,"+
- "sum(t1.enable) as enable_count,"+
- " t1.inventory, t1.merchant_child_api_id, "+
- "t4.merchant_name, t5.name as api_name from "+
- "t_gd_merchant_api_provider_api_relation as t1 "+
- "left join t_gd_merchant_child_data_api as t2 on t2.id=t1.merchant_child_api_id "+
- "left join t_gd_merchant_data_api as t3 on t3.id=t2.merchant_data_api_id "+
- "left join t_gd_merchants as t4 on t4.id=t3.merchant_id "+
- "left join t_gd_api as t5 on t5.id=t2.api_id where t1.provider_api_id=%d group by t1.merchant_child_api_id", req.ProviderApiId)
- _, err := o.Raw(sql).QueryRows(&reply.ProviderMerchantApiList)
- if err != nil && err != orm.ErrNoRows {
- return errors.DataBaseError
- }
- for i, v := range reply.ProviderMerchantApiList {
- if v.EnableCount > 0 {
- reply.ProviderMerchantApiList[i].Enable = true
- }
- }
- return nil
- }
|