瀏覽代碼

getUserInfo

yuliang1112 2 年之前
父節點
當前提交
8c8b01061f

+ 1 - 1
consts/project.go

@@ -22,7 +22,7 @@ func GetProjectStatus(status int64) string {
 }
 
 var ProjectPlatformMap = map[int64]string{
-	1: "小红书",
+	1: "红book",
 	2: "抖音",
 	3: "微博",
 	4: "快手",

+ 60 - 0
handler/get_userInfo.go

@@ -0,0 +1,60 @@
+package handler
+
+import (
+	"github.com/gin-gonic/gin"
+	"github.com/sirupsen/logrus"
+	"youngee_m_api/consts"
+	"youngee_m_api/model/http_model"
+	"youngee_m_api/service"
+	"youngee_m_api/util"
+)
+
+func WrapGetUserInfoHandler(ctx *gin.Context) {
+	handler := newGetUserInfo(ctx)
+	baseRun(handler)
+}
+
+func newGetUserInfo(ctx *gin.Context) *UserInfo {
+	return &UserInfo{
+		req:  http_model.NewUserInfoRequest(),
+		resp: http_model.NewUserInfoResponse(),
+		ctx:  ctx,
+	}
+}
+
+type UserInfo struct {
+	req  *http_model.UserInfoRequest
+	resp *http_model.CommonResponse
+	ctx  *gin.Context
+}
+
+func (u UserInfo) getContext() *gin.Context {
+	return u.ctx
+}
+
+func (u UserInfo) getResponse() interface{} {
+	return u.resp
+}
+
+func (u UserInfo) getRequest() interface{} {
+	return u.req
+}
+
+func (u UserInfo) run() {
+	userInfo, err := service.LoginAuth.AuthToken(u.ctx, u.req.Token)
+	if err != nil {
+		logrus.Errorf("[CodeLoginHandler] call AuthCode err:%+v\n", err)
+		util.HandlerPackErrorResp(u.resp, consts.ErrorInternal, u.req.Token)
+		logrus.Info("login fail,req:%+v", u.req)
+		return
+	}
+	data := http_model.UserInfoResponse{}
+	data.User = userInfo.User
+	data.Username = userInfo.Username
+	data.Role = userInfo.Role
+	u.resp.Data = data
+}
+
+func (u UserInfo) checkParam() error {
+	return nil
+}

+ 1 - 1
model/gorm_model/project.go

@@ -10,7 +10,7 @@ type ProjectInfo struct {
 	ProjectName     string    `gorm:"column:project_name"`                          // 项目名称
 	ProjectStatus   int64     `gorm:"column:project_status"`                        // 项目状态,1-10分别代表创建中、待审核、审核通过、招募中、招募完毕、待支付、已支付、失效、执行中、已结案
 	ProjectType     int64     `gorm:"column:project_type"`                          // 项目类型,1代表全流程项目,2代表专项项目
-	ProjectPlatform int64     `gorm:"column:project_platform"`                      // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectPlatform int64     `gorm:"column:project_platform"`                      // 项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
 	ProjectForm     int64     `gorm:"column:project_form"`                          // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
 	TalentType      string    `gorm:"column:talent_type"`                           // 达人类型
 	RecruitDdl      time.Time `gorm:"column:recruit_ddl"`                           // 招募截止时间

+ 1 - 1
model/http_model/project_create.go

@@ -20,7 +20,7 @@ type CreateProjectRequest struct {
 	ProjectName      string                  `json:"project_name"`      // 项目名称
 	ProjectStatus    int64                   `json:"project_status"`    // 项目状态,1-7分别代表创建中、待审核、招募中、待支付、失效、执行中、已结案
 	ProjectType      int64                   `json:"project_type"`      // 项目类型,1代表全流程项目,2代表专项项目
-	ProjectPlatform  int64                   `json:"project_platform"`  // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectPlatform  int64                   `json:"project_platform"`  // 项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
 	ProjectForm      int64                   `json:"project_form"`      // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
 	TalentType       string                  `json:"talent_type"`       // 达人类型
 	RecruitDdl       time.Time               `json:"recruit_ddl"`       // 招募截止时间

+ 1 - 1
model/http_model/project_show.go

@@ -20,7 +20,7 @@ type ShowProjectData struct {
 	ProjectName      string                `json:"project_name"`      // 项目名称
 	ProjectStatus    string                `json:"project_status"`    // 项目状态,1-7分别代表创建中、待审核、招募中、待支付、失效、执行中、已结案
 	ProjectType      string                `json:"project_type"`      // 项目类型,1代表全流程项目,2代表专项项目
-	ProjectPlatform  string                `json:"project_platform"`  // 项目平台,1-7分别代表小红书、抖音、微博、快手、b站、大众点评、知乎
+	ProjectPlatform  string                `json:"project_platform"`  // 项目平台,1-7分别代表红book、抖音、微博、快手、b站、大众点评、知乎
 	ProjectForm      string                `json:"project_form"`      // 项目形式,1-4分别代表实体商品寄拍、虚拟产品测评、线下探店打卡、素材微原创
 	TalentType       string                `json:"talent_type"`       // 达人类型
 	RecruitDdl       time.Time             `json:"recruit_ddl"`       // 招募截止时间

+ 21 - 0
model/http_model/userInfo.go

@@ -0,0 +1,21 @@
+package http_model
+
+type UserInfoRequest struct {
+	Token string
+}
+
+type UserInfoResponse struct {
+	User     string
+	Username string
+	Role     string
+}
+
+func NewUserInfoRequest() *UserInfoRequest {
+	return new(UserInfoRequest)
+}
+
+func NewUserInfoResponse() *CommonResponse {
+	resp := new(CommonResponse)
+	resp.Data = new(UserInfoResponse)
+	return resp
+}

+ 1 - 0
route/init.go

@@ -10,6 +10,7 @@ func InitRoute(r *gin.Engine) {
 
 	r.POST("/login", handler.WrapCodeLoginHandler)
 	r.GET("/getLoginUser", handler.WrapGetLoginUserHandler)
+	r.POST("/userInfo", handler.WrapGetUserInfoHandler)
 	r.GET("/test/ping", func(c *gin.Context) {
 		resp := http_model.CommonResponse{
 			Status:  0,