Xingyu Xian пре 8 месеци
родитељ
комит
ae256bbbe9
6 измењених фајлова са 12 додато и 3 уклоњено
  1. 1 1
      db/user.go
  2. 3 0
      handler/code_login.go
  3. 2 2
      model/http_model/register.go
  4. 4 0
      route/init.go
  5. 1 0
      service/enterprise.go
  6. 1 0
      service/login_auth.go

+ 1 - 1
db/user.go

@@ -17,7 +17,7 @@ func CreateUser(ctx context.Context, user gorm_model.YounggeeUser) (*int64, erro
 	return &user.ID, nil
 }
 
-// GetUserByPhone 查不到返回空
+// GetUserByPhone 查不到返回空 根据手机号在User表中查用户数据
 func GetUserByPhone(ctx context.Context, phone string) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
 	user := &gorm_model.YounggeeUser{}

+ 3 - 0
handler/code_login.go

@@ -11,6 +11,7 @@ import (
 	log "github.com/sirupsen/logrus"
 )
 
+/*
 // WrapSendCodeHandler
 // @BasePath /youngee/m/
 // Codelogin godoc
@@ -22,6 +23,8 @@ import (
 // @Param req body http_model.CodeLoginRequest true "登录输入内容请求参数结构体"
 // @Success 200 {object} http_model.CommonResponse{data=http_model.CodeLoginData} "登录返回相应结构体"
 // @Router /login [post]
+*/
+
 func WrapCodeLoginHandler(ctx *gin.Context) {
 	handler := newCodeLoginHandler(ctx)
 	baseRun(handler)

+ 2 - 2
model/http_model/register.go

@@ -4,11 +4,11 @@ type RegisterRequest struct {
 	EnterpriseId int64  `json:"enterprise_id"` // 企业id
 	UserId       int64  `json:"user_id"`       // 对应用户id
 	RealName     string `json:"real_name"`     // 真实姓名
-	Phone        string `json:"phone"`         //手机号
+	Phone        string `json:"phone"`         // 手机号
 	Industry     int64  `json:"industry"`      // 行业,1-14分别代表能源、化工、材料、机械设备/军工、企业服务/造纸印刷、运输设备、旅游酒店、媒体/信息通信服务、批发/零售、消费品、卫生保健/医疗、金融、建材/建筑/房地产、公共事业
 	BusinessName string `json:"business_name"` // 公司或组织名称
 	Email        string `json:"email"`         // 电子邮件
-	Code         string `json:"code"`          //验证码
+	Code         string `json:"code"`          // 验证码
 }
 
 type RegisterData struct {

+ 4 - 0
route/init.go

@@ -13,9 +13,13 @@ import (
 
 func InitRoute(r *gin.Engine) {
 	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
+	// 商家主账号注册
 	r.POST("/register", handler.WrapRegisterHandler)
+	// 商家子账号注册
 	r.POST("/addNewSubAccount", handler.WrapAddNewSubAccountHandler)
+	// 发送登录验证码
 	r.POST("/sendCode", handler.WrapSendCodeHandler)
+	// 商家登录
 	r.POST("/login", handler.WrapCodeLoginHandler)
 	r.GET("/test/ping", func(c *gin.Context) {
 		resp := http_model.CommonResponse{

+ 1 - 0
service/enterprise.go

@@ -117,6 +117,7 @@ func (*enterprise) CreateEnterprise(ctx context.Context, phone string) (*http_mo
 	}
 }
 
+// CreateEnterpriseSubUser ToDo
 // CreateEnterpriseSubUser 创建商家子账号
 func (*enterprise) CreateEnterpriseSubUser(ctx context.Context, newEnterprise http_model.RegisterRequest) (*http_model.RegisterData, error) {
 	// 1. 新建User

+ 1 - 0
service/login_auth.go

@@ -48,6 +48,7 @@ func (l *loginAuth) AuthToken(ctx context.Context, token string) (*redis_model.A
 	return auth, nil
 }
 
+// AuthCode 判断此手机号是否有账号存在 鉴定验证码 用户信息存入redis 并返回Token
 func (l *loginAuth) AuthCode(ctx context.Context, phone string, code string) (string, error) {
 	user, err := db.GetUserByPhone(ctx, phone)
 	fmt.Println("login_auth", user, err)