From 9b5710f23d6cbda9f2b0e650cf8916e7707d5588 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 29 六月 2020 19:27:14 +0800
Subject: [PATCH] addPlateNo and findMyPlateNos

---
 controllers/user.go |   29 +++++++++++++++++++++++++++++
 1 files changed, 29 insertions(+), 0 deletions(-)

diff --git a/controllers/user.go b/controllers/user.go
index 9cf24da..1947e7c 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -113,7 +113,36 @@
 		resp.Status = http.StatusBadRequest
 		resp.Data = "鍙傛暟鏈夎"
 	} else {
+		var sv service.UserService
+		if sv.AddPlateNo(reqBody.UserId, reqBody.PlateNo) {
+			resp.Success = true
+			resp.Status = http.StatusOK
+			resp.Data = "娣诲姞鎴愬姛"
+		} else {
+			resp.Success = false
+			resp.Status = http.StatusBadRequest
+			resp.Data = "娣诲姞澶辫触"
+		}
+	}
+	u.Data["json"] = resp
+	u.ServeJSON()
+}
 
+// @router /myPlateNos [get]
+func (u *UserController) MyPlateNos() {
+	userId := u.GetString("userId")
+	var uc models.UserCar
+	all, err := uc.GetByUserId(userId)
+	var nos = make([]string, 0)
+	if err == nil && all != nil {
+		for _,p := range all {
+			nos = append(nos, p.PlateNo)
+		}
+	}
+	resp := code.Code{
+		Success: true,
+		Status: http.StatusOK,
+		Data: nos,
 	}
 	u.Data["json"] = resp
 	u.ServeJSON()

--
Gitblit v1.8.0