common_controller.go 1.1 KB
package controllers

import (
	partnerQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query"
	partnerInfoService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/service"
)

type CommonController struct {
	BaseController
}

////Prepare 重写 BaseController 的Prepare方法
func (c *CommonController) Prepare() {
	c.BaseController.Prepare()
	if ok := c.ValidJWTToken(); !ok {
		return
	}
}

// GetPartnerList 下拉选项数据通用接口,获取合伙人列表
func (c *CommonController) GetPartnerList() {
	query := partnerQuery.ListPartnerInfoQuery{
		Limit:  5000,
		Offset: 0,
	}
	newPartnerService := partnerInfoService.NewPartnerInfoService(nil)
	_, partners, err := newPartnerService.ListPartnerInfo(&query)
	if err != nil {
		c.ResponseError(err)
		return
	}
	resp := []map[string]interface{}{}
	for i := range partners {
		m := map[string]interface{}{
			"id":          partners[i].Partner.Id,
			"account":     partners[i].Partner.Account,
			"partnerName": partners[i].Partner.PartnerName,
		}

		resp = append(resp, m)
	}
	c.ResponseData(resp)
}