package controllers import ( categoryQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/query" categoryService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerCategory/service" partnerQuery "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/query" partnerInfoService "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/application/partnerInfo/service" "gitlab.fjmaimaimai.com/mmm-go/partnermg/pkg/domain" ) 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() { companyId := c.GetUserCompany() query := partnerQuery.ListPartnerInfoQuery{ Limit: 1000, Offset: 0, CompanyId: companyId, } 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) } // GetPartnerCategory 下拉选项数据通用接口,获取合伙人分类列表 func (c *CommonController) GetPartnerCategory() { newService := categoryService.NewPartnerCategoryService(nil) _, categorys, err := newService.ListPartnerCategory(categoryQuery.ListPartnerCategoryCommand{}) if err != nil { c.ResponseError(err) return } resp := []map[string]interface{}{} for i := range categorys { m := map[string]interface{}{ "id": categorys[i].Id, "name": categorys[i].Name, } resp = append(resp, m) } c.ResponseData(resp) } // GetOrderType 下拉选项数据通用接口,获取订单类型列表 func (c *CommonController) GetOrderType() { resp := []map[string]interface{}{ map[string]interface{}{ "id": domain.OrderReal, "name": domain.GetOrderBaseTypeName(domain.OrderReal), }, map[string]interface{}{ "id": domain.OrderTypeBestShop, "name": domain.GetOrderBaseTypeName(domain.OrderTypeBestShop), }, } c.ResponseData(resp) }