Browse Source

enterprise_account_auth

Xingyu Xian 6 days ago
parent
commit
2a5c3c724e
2 changed files with 34 additions and 18 deletions
  1. 1 1
      db/user.go
  2. 33 17
      route/init.go

+ 1 - 1
db/user.go

@@ -35,7 +35,7 @@ func GetUserByPhone(ctx context.Context, phone string) (*gorm_model.YounggeeUser
 func GetSubUserByPhone(ctx context.Context, phone string) (*gorm_model.YounggeeUser, error) {
 	db := GetReadDB(ctx)
 	user := &gorm_model.YounggeeUser{}
-	err := db.Model(user).Where("phone = ? AND role = 4", phone).First(user).Error
+	err := db.Model(user).Where("phone = ?", phone).First(user).Error
 	if err != nil {
 		if err == gorm.ErrRecordNotFound {
 			fmt.Println("record not found")

+ 33 - 17
route/init.go

@@ -15,23 +15,9 @@ func InitRoute(r *gin.Engine) {
 	r.GET("/swagger/*any", ginSwagger.WrapHandler(swaggerFiles.Handler))
 	business := r.Group("/youngee")
 	{
-		business.POST("/register", handler.WrapRegisterHandler)                    // 商家主账号注册
-		business.POST("/sendCode", handler.WrapSendCodeHandler)                    // 发送登录验证码
-		business.POST("/login", handler.WrapCodeLoginHandler)                      // 商家登录
-		business.POST("/subAccount/create", handler.WrapAddNewSubAccountHandler)   // 商家子账号注册
-		business.POST("/subAccount/get", handler.WrapFindAllSubAccountHandler)     // 查找商家全部所属子账号
-		business.POST("/subAccount/delete", handler.WrapDeleteSubAccountHandler)   // 删除商家子账号
-		business.POST("/subAccount/update", handler.WrapFindAllSubAccountHandler)  // 修改商家子账号
-		business.POST("/job/get", handler.WrapFindAllJobHandler)                   // 查找商家全部所属岗位
-		business.POST("/job/create", handler.WrapaddNewJobHandler)                 // 商家新增岗位
-		business.POST("/job/update", handler.WrapupdateJobHandler)                 // 商家修改岗位
-		business.POST("/job/delete", handler.WrapdeleteJobHandler)                 // 商家删除岗位
-		business.POST("/getUserInfo", handler.WrapGetUserInfoHandler)              // 商家用户信息
-		business.POST("/accountInfo/get", handler.WrapGetAccountInfoHandler)       // 账号管理-账号信息查询
-		business.POST("/accountInfo/update", handler.WrapUpdateAccountInfoHandler) // 账号管理-账号信息更新
-		business.POST("/reviewInfo/get", handler.WrapGetReviewInfoHandler)         // 账号管理-认证信息查询
-		business.POST("/contactInfo/get", handler.WrapGetContactInfoHandler)       // 联系方式-查询
-		business.POST("/contactInfo/update", handler.WrapUpdateContactInfoHandler) // 联系方式-更新
+		business.POST("/register", handler.WrapRegisterHandler) // 商家主账号注册
+		business.POST("/sendCode", handler.WrapSendCodeHandler) // 发送登录验证码
+		business.POST("/login", handler.WrapCodeLoginHandler)   // 商家登录
 		business.GET("/test/ping", func(c *gin.Context) {
 			resp := http_model.CommonResponse{
 				Status:  20000,
@@ -41,6 +27,36 @@ func InitRoute(r *gin.Engine) {
 			c.JSON(200, resp)
 		})
 	}
+
+	subAccount := r.Group("/youngee/subAccount")
+	{
+		subAccount.Use(middleware.LoginAuthMiddleware)
+		subAccount.POST("/create", handler.WrapAddNewSubAccountHandler)  // 商家子账号注册
+		subAccount.POST("/get", handler.WrapFindAllSubAccountHandler)    // 查找商家全部所属子账号
+		subAccount.POST("/delete", handler.WrapDeleteSubAccountHandler)  // 删除商家子账号
+		subAccount.POST("/update", handler.WrapFindAllSubAccountHandler) // 修改商家子账号
+	}
+
+	job := r.Group("/youngee/job")
+	{
+		job.Use(middleware.LoginAuthMiddleware)
+		job.POST("/get", handler.WrapFindAllJobHandler)   // 查找商家全部所属岗位
+		job.POST("/create", handler.WrapaddNewJobHandler) // 商家新增岗位
+		job.POST("/update", handler.WrapupdateJobHandler) // 商家修改岗位
+		job.POST("/delete", handler.WrapdeleteJobHandler) // 商家删除岗位
+	}
+
+	accountInfo := r.Group("/youngee")
+	{
+		accountInfo.Use(middleware.LoginAuthMiddleware)
+		accountInfo.POST("/getUserInfo", handler.WrapGetUserInfoHandler)              // 商家用户信息
+		accountInfo.POST("/accountInfo/get", handler.WrapGetAccountInfoHandler)       // 账号管理-账号信息查询
+		accountInfo.POST("/accountInfo/update", handler.WrapUpdateAccountInfoHandler) // 账号管理-账号信息更新
+		accountInfo.POST("/reviewInfo/get", handler.WrapGetReviewInfoHandler)         // 账号管理-认证信息查询
+		accountInfo.POST("/contactInfo/get", handler.WrapGetContactInfoHandler)       // 联系方式-查询
+		accountInfo.POST("/contactInfo/update", handler.WrapUpdateContactInfoHandler) // 联系方式-更新
+	}
+
 	//r.Any("/testDemo", func(c *gin.Context) {
 	//	resp := http_model.CommonResponse{
 	//		Status:  0,