diff --git a/controllers/UserController.go b/controllers/UserController.go index 72062a5..0bb55e5 100644 --- a/controllers/UserController.go +++ b/controllers/UserController.go @@ -22,6 +22,28 @@ func (u *UserController) RegistPage() { u.TplName = "regist.html" } +func (this *UserController) UserInfo() { + idStr := this.Ctx.Input.Param(":id") + id, _ := strconv.ParseInt(idStr, 10, 64) + user, err := service.GetUser(id) + if err != nil { + this.Redirect("/500", 302) + return + } + size := 15 + num, _ := this.GetInt("num") + if num <= 0 { + num = 1 + } + flag, _ := this.GetInt("flag") + if page, err := service.MeBlogs(num, size, flag, id); err == nil { + this.Data["Page"] = page + } + this.Data["User"] = user + this.TplName = "user.html" + return +} + func (this *UserController) PersonBlog() { uid := this.GetSession("userid") if uid == nil { @@ -164,9 +186,9 @@ func (this *UserController) Edit() { user.QQ = this.GetString("qqnum") user.Sex, _ = this.GetInt("catory") user.DescInfo = this.GetString("mdesc") - if _,err :=service.EditUser(user); err !=nil{ + if _, err := service.EditUser(user); err != nil { this.Data["json"] = models.ReurnError(500, "") - }else{ + } else { this.Data["json"] = models.ReurnSuccess("") } this.ServeJSON() diff --git a/routers/UserRouter.go b/routers/UserRouter.go index 8b8d115..3fff668 100644 --- a/routers/UserRouter.go +++ b/routers/UserRouter.go @@ -12,6 +12,7 @@ func init() { beego.Router("/regist", &controllers.UserController{}, "post:Regist") beego.Router("/regist", &controllers.UserController{}, "get:RegistPage") beego.Router("/user/edit", &controllers.UserController{}, "post:Edit") + beego.Router("/u/:id([0-9]+)", &controllers.UserController{}, "get:UserInfo") diff --git a/static/css/u.css b/static/css/u.css new file mode 100644 index 0000000..c135152 --- /dev/null +++ b/static/css/u.css @@ -0,0 +1,20 @@ +.uinfo { + color: #515a6e; + margin: 5px; +} + +.udesc span { + margin-right: 8px; +} + +.blog-list { + display: flex; + font-size: 16px; + min-height: 35px; + line-height: 35px; +} + +a{ + color: #515a6e; + text-decoration: none !important; +} \ No newline at end of file diff --git a/views/T.me.tpl b/views/T.me.tpl index c5b39e8..05bb1c3 100644 --- a/views/T.me.tpl +++ b/views/T.me.tpl @@ -1,8 +1,8 @@ {{define "memenu"}}