From aa38814dac11fbd1c7c1c04cd57aaeaff1daa0f4 Mon Sep 17 00:00:00 2001
From: liuxiaolong <liuxiaolong@aiotlink.com>
Date: 星期一, 27 七月 2020 16:58:54 +0800
Subject: [PATCH] add log

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

diff --git a/controllers/user.go b/controllers/user.go
index 9cf24da..1e7f612 100644
--- a/controllers/user.go
+++ b/controllers/user.go
@@ -113,7 +113,59 @@
 		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")
+	fmt.Println("MyPlateNos userId", userId)
+	var uc models.UserCar
+	all, err := uc.GetByUserId(userId)
+	fmt.Println("all:", all, "err:", err)
+	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()
+}
+
+// @router /delPlateNo [delete]
+func (u *UserController) DelPlateNo() {
+	userId := u.GetString("userId")
+	plateNo := u.GetString("plateNo")
+	resp := code.Code{}
+	var uc models.UserCar
+	i,e := uc.Delete(userId, plateNo)
+	fmt.Println("delPlateNo i:",i, "e:", e)
+	if e ==nil && i >0 {
+		resp.Success = true
+		resp.Status = http.StatusOK
+		resp.Data = "鍒犻櫎鎴愬姛"
+	} else {
+		resp.Success = false
+		resp.Status = http.StatusInternalServerError
+		resp.Data = "鍒犻櫎澶辫触"
 	}
 	u.Data["json"] = resp
 	u.ServeJSON()

--
Gitblit v1.8.0