Ethan 4 mesi fa
parent
commit
592be09890

+ 4 - 4
consts/error_code.go

@@ -7,10 +7,10 @@ var errorCodeToastMap = map[int32]string{}
 
 const DefaultToast = ""
 
-const ErrorSuccess int32 = 0
-const ErrorNotLogin int32 = 4001
-const ErrorParamCheck int32 = 5001
-const ErrorInternal int32 = 5001
+const ErrorSuccess int32 = 20000
+const ErrorNotLogin int32 = 44000
+const ErrorParamCheck int32 = 40000
+const ErrorInternal int32 = 40000
 
 func init() {
 	errorCodeToastMap[ErrorSuccess] = "请求成功"

+ 3 - 1
handler/CreateSecTaskLogistics.go

@@ -43,8 +43,10 @@ func (c CreateSecTaskLogistics) run() {
 		logrus.Info("CreateSecTaskLogistics fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功添加发货信息"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c CreateSecTaskLogistics) checkParam() error {

+ 2 - 0
handler/CreateSelection.go

@@ -47,6 +47,8 @@ func (c CreateSelection) run() {
 	}
 	c.resp.Message = "成功创建选品"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c CreateSelection) checkParam() error {

+ 3 - 1
handler/GetSecTaskList.go

@@ -44,8 +44,10 @@ func (c GetSecTaskList) run() {
 		logrus.Info("GetSecTaskList fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功查询选品任务"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c GetSecTaskList) checkParam() error {

+ 3 - 1
handler/PassSecTaskCoop.go

@@ -44,8 +44,10 @@ func (c PassSecTaskCoop) run() {
 		logrus.Info("PassSecTaskCoop fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功合作选品任务"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c PassSecTaskCoop) checkParam() error {

+ 3 - 1
handler/PaySelection.go

@@ -45,8 +45,10 @@ func (c PaySelection) run() {
 		logrus.Info("PaySelection fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "支付成功"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c PaySelection) checkParam() error {

+ 3 - 1
handler/RefuseSecTaskCoop.go

@@ -44,8 +44,10 @@ func (c RefuseSecTaskCoop) run() {
 		logrus.Info("RefuseSecTaskCoop fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功拒绝选品任务"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c RefuseSecTaskCoop) checkParam() error {

+ 3 - 0
handler/SettleSecTask.go

@@ -46,6 +46,9 @@ func (c SettleSecTask) run() {
 		return
 	}
 	c.resp.Data = res
+	c.resp.Status = 20000
+	c.resp.Message = "ok"
+	return
 }
 
 func (c SettleSecTask) checkParam() error {

+ 3 - 1
handler/UpdateSecTaskLogistics.go

@@ -43,8 +43,10 @@ func (c UpdateSecTaskLogistics) run() {
 		logrus.Info("UpdateSecTaskLogistics fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "成功修改发货信息"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c UpdateSecTaskLogistics) checkParam() error {

+ 3 - 1
handler/UpdateSelection.go

@@ -45,8 +45,10 @@ func (c UpdateSelection) run() {
 		logrus.Info("UpdateSelection fail,req:%+v", c.req)
 		return
 	}
-	c.resp.Message = "选品更新成功"
+	c.resp.Message = "ok"
 	c.resp.Data = res
+	c.resp.Status = 20000
+	return
 }
 
 func (c UpdateSelection) checkParam() error {

+ 5 - 0
handler/addNewJob.go

@@ -43,7 +43,12 @@ func (h *AddNewJobHandler) run() {
 	err := service.Job.CreateJob(h.ctx, jobData)
 	if err != nil {
 		fmt.Println(err)
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
+		return
 	}
+	h.resp.Status = 20000
+	h.resp.Message = "ok"
 	return
 }
 

+ 9 - 1
handler/addNewSubAccount.go

@@ -43,21 +43,29 @@ func (h *AddNewSubAccountHandler) run() {
 	tag, err := service.LoginAuth.SubAccountAuthCode(h.ctx, newSubAccount.PhoneNumber, newSubAccount.Code)
 	if err != nil {
 		fmt.Println(err)
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
+		return
 	}
 	// 2. 校验通过则创建样叽用户和子账号
 	if tag == "1" {
 		err := service.SubAccount.CreateSubAccount(h.ctx, newSubAccount)
 		if err != nil {
 			fmt.Println(err)
+			h.resp.Status = 40000
 			h.resp.Message = "创建失败"
+			return
 		} else {
+			h.resp.Status = 20000
 			h.resp.Message = "成功创建子账号"
+			return
 		}
 	} else {
 		// 验证码校验不通过的返回值
+		h.resp.Status = 40000
 		h.resp.Message = tag
+		return
 	}
-	return
 }
 
 func (h *AddNewSubAccountHandler) checkParam() error {

+ 3 - 1
handler/code_login.go

@@ -66,8 +66,10 @@ func (h *CodeLoginHandler) run() {
 	}
 	var data *http_model.CodeLoginData
 	data = userData
-	// h.resp.Message = "登陆成功"
+	h.resp.Message = "登陆成功"
 	h.resp.Data = data
+	h.resp.Status = 20000
+	return
 }
 
 func (h *CodeLoginHandler) checkParam() error {

+ 5 - 0
handler/deleteJob.go

@@ -41,7 +41,12 @@ func (h *DeleteJobHandler) run() {
 	err := service.Job.DeleteJob(h.ctx, jobData)
 	if err != nil {
 		fmt.Println(err)
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
+		return
 	}
+	h.resp.Status = 20000
+	h.resp.Message = "ok"
 	return
 }
 

+ 3 - 0
handler/getAllSelection.go

@@ -44,6 +44,9 @@ func (a AllSelectionHandler) run() {
 		return
 	}
 	a.resp.Data = data
+	a.resp.Status = 20000
+	a.resp.Message = "ok"
+	return
 }
 
 func (a AllSelectionHandler) checkParam() error {

+ 3 - 0
handler/register.go

@@ -48,6 +48,8 @@ func (h *RegisterHandler) run() {
 		logrus.Errorf("[RegisterHandler] call AuthRegister err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
 		log.Info("Register fail,req:%+v", h.req)
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
 		return
 	} else if message == "" {
 		// 3. 先后在user表和enterprise表中增加账号信息
@@ -60,6 +62,7 @@ func (h *RegisterHandler) run() {
 		}
 		h.resp.Message = "注册成功"
 		// 4. 返回ok
+		h.resp.Status = 20000
 		h.resp.Data = res
 	} else {
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, message)

+ 2 - 0
handler/selection_delete.go

@@ -40,6 +40,8 @@ func (d DeleteSelectionHandler) run() {
 		return
 	}
 	d.resp.Message = "选品删除成功"
+	d.resp.Status = 20000
+	return
 }
 
 func (d DeleteSelectionHandler) checkParam() error {

+ 2 - 0
handler/selection_detail.go

@@ -44,6 +44,8 @@ func (s SelectionDetailHandler) run() {
 	}
 	s.resp.Message = "成功查询项目"
 	s.resp.Data = res
+	s.resp.Status = 20000
+	return
 }
 
 func (s SelectionDetailHandler) checkParam() error {

+ 3 - 0
handler/selection_find_all.go

@@ -47,6 +47,9 @@ func (f FindAllSelectionHandler) run() {
 		return
 	}
 	f.resp.Data = data
+	f.resp.Status = 20000
+	f.resp.Message = "ok"
+	return
 }
 
 func (f FindAllSelectionHandler) checkParam() error {

+ 4 - 2
handler/send_code.go

@@ -63,6 +63,8 @@ func (h *SendCodeHandler) run() {
 		logrus.Errorf("[SendeCodeHandler] call SetSession err:%+v\n", err)
 		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
 		log.Info("SendeCode fail,req:%+v", h.req)
+		h.resp.Status = 40000
+		h.resp.Message = "发送失败,请重试"
 		return
 	}
 	// if data.Email == "login" {
@@ -89,12 +91,12 @@ func (h *SendCodeHandler) run() {
 	err = service.SendCode.SetSession(h.ctx, data.Phone, vcode)
 	if err != nil {
 		logrus.Errorf("[SendeCodeHandler] call SetSession err:%+v\n", err)
-		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, "")
+		util.HandlerPackErrorResp(h.resp, consts.ErrorInternal, err.Error())
 		log.Info("SendeCode fail,req:%+v", h.req)
 		return
 	}
 	h.resp.Message = "验证码发送成功,请注意查收"
-	h.resp.Status = 200
+	h.resp.Status = 20000
 }
 func (h *SendCodeHandler) checkParam() error {
 	return nil

+ 5 - 0
handler/updateJob.go

@@ -41,7 +41,12 @@ func (h *UpdateNewJobHandler) run() {
 	err := service.Job.UpdateJob(h.ctx, jobData)
 	if err != nil {
 		fmt.Println(err)
+		h.resp.Status = 40000
+		h.resp.Message = err.Error()
+		return
 	}
+	h.resp.Status = 20000
+	h.resp.Message = "ok"
 	return
 }
 

+ 1 - 1
route/init.go

@@ -25,7 +25,7 @@ func InitRoute(r *gin.Engine) {
 		business.POST("/login", handler.WrapCodeLoginHandler)                   // 商家登录
 		business.GET("/test/ping", func(c *gin.Context) {
 			resp := http_model.CommonResponse{
-				Status:  0,
+				Status:  20000,
 				Message: "",
 				Data:    "ping",
 			}