瀏覽代碼

Merge branch 'master' of http://git.hiwavo.com/Fohow/fohow_api

abiao 4 年之前
父節點
當前提交
addd24127b

+ 34 - 0
go/gopath/src/fohow.com/apps/controllers/user_controller/user_controller.go

@@ -548,3 +548,37 @@ func (self *UserController) SysUserBind() {
 	self.Data["json"] = ret
 	self.ServeJSON()
 }
+
+//修改用户信息
+func (self *UserController) UpdateUserInfo() {
+
+	nickName := self.GetString("nickname")
+	birthday := self.GetString("birthday")
+	sex, sexErr := self.GetInt64("sex")
+	//qq := self.GetString("qq")
+
+	user := self.GetCurrentUser(false)
+	wxUser := self.GetCurrentWxUser(false)
+	file, _, err := self.GetFile("head")
+	if err == nil {
+		user.UploadHead(file)
+		wxUser.Head = user.Head
+	}
+
+	if sexErr == nil {
+		user.Sex = sex
+		wxUser.Sex = sex
+	}
+
+	if birthday != "" {
+		t, _ := time.Parse("2006-01-02", birthday)
+		user.Birthday = t
+	}
+	user.Nickname = nickName
+	wxUser.Nickname = nickName
+	user.Save()
+	wxUser.Save()
+	// user.BirthdayStr = birthday
+	self.Data["json"] = wxUser
+	self.ServeJSON()
+}

+ 1 - 1
go/gopath/src/fohow.com/apps/models/user_model/user.go

@@ -37,7 +37,7 @@ type User struct {
 	City        string    `orm:"column(city);null"                              json:"-"`        // varchar(20)
 	Sex         int64     `orm:"column(sex);null"                               json:"sex"`      // int(11)
 	Head        string    `orm:"column(head)"     json:"head"`
-	Birthday    time.Time `orm:"column(birthday);null;type(datetime)"          json:"-"`
+	Birthday    time.Time `orm:"column(birthday);null;type(datetime)"          json:"birthday"`
 	InviteId    int64     `orm:"column(invite_id);null"                         json:"invite_id"` // int(11)
 	Age         int64     `orm:"column(age);null"                         json:"age"`             // int(11)
 	//belongs_to :parent_signup_channel, :foreign_key => :signup_channel_id

+ 1 - 1
go/gopath/src/fohow.com/routers/routes.go

@@ -181,7 +181,7 @@ func init() {
 	//一键绑定微信手机号码
 	beego.Router("/v1/wxuser/one_click/binding/phonumer", &user_controller.UserController{}, "post:BindingWxPhoneNew")
 	// //用户上传头像
-	// beego.Router("/v1/user/head/upload", &user_controller.UserController{}, "post:UploadHead")
+	beego.Router("/v1/user/update/info", &user_controller.UserController{}, "post:UpdateUserInfo")
 
 	//----------- 账户相关 -----------
 	//提货券账户变更列表