Ethan 3 mēneši atpakaļ
vecāks
revīzija
6eb6a634c1

+ 20 - 0
app/controller/common_controller.go

@@ -0,0 +1,20 @@
+package controller
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_b_api/app/service"
+)
+
+type CommonController struct{}
+
+// 获取合作平台列表
+func (t CommonController) CooperationPlatform(c *gin.Context) {
+	result, err := service.CommonService{}.CooperationPlatform()
+	if err != nil {
+		logrus.Errorf("[CooperationPlatform] call Show err:%+v\n", err)
+		returnError(c, 40000, err.Error())
+		return
+	}
+	returnSuccess(c, 20000, result)
+}

+ 12 - 0
app/dao/common_dao.go

@@ -0,0 +1,12 @@
+package dao
+
+import "youngee_b_api/app/entity"
+
+type CommonDao struct{}
+
+// 获取所有合作平台icon
+func (d CommonDao) GetCoopPlatform() ([]entity.CoopPlatform, error) {
+	var coopPlatforms []entity.CoopPlatform
+	err := Db.Model(&entity.CoopPlatform{}).Find(&coopPlatforms).Order("id").Error
+	return coopPlatforms, err
+}

+ 12 - 0
app/entity/coop_platform.go

@@ -0,0 +1,12 @@
+// Code generated by sql2gorm. DO NOT EDIT.
+package entity
+
+// 合作平台表
+type CoopPlatform struct {
+	ID           int64  `gorm:"column:id;primary_key;AUTO_INCREMENT"` // id
+	PlatformIcon string `gorm:"column:platform_icon;NOT NULL"`        // 平台icon
+}
+
+func (m *CoopPlatform) TableName() string {
+	return "younggee_coop_platform"
+}

+ 17 - 0
app/service/common_service.go

@@ -0,0 +1,17 @@
+package service
+
+import "youngee_b_api/app/dao"
+
+type CommonService struct{}
+
+func (s CommonService) CooperationPlatform() ([]string, error) {
+	var icons []string
+	coopPlatforms, err := dao.CommonDao{}.GetCoopPlatform()
+	if err != nil {
+		return nil, err
+	}
+	for _, coopPlatform := range coopPlatforms {
+		icons = append(icons, coopPlatform.PlatformIcon)
+	}
+	return icons, nil
+}

+ 5 - 0
route/init.go

@@ -348,4 +348,9 @@ func InitRoute(r *gin.Engine) {
 		account.Use(middleware.LoginAuthMiddleware)
 		account.POST("/businessLicense", controller.AccountController{}.OCRIdentify) // 营业执照OCR识别/认证
 	}
+	// 账号管理
+	common := r.Group("/youngee/b/common")
+	{
+		common.POST("/platform", controller.CommonController{}.CooperationPlatform) // 获取合作平台icon
+	}
 }