14 gewijzigde bestanden met toevoegingen van 383 en 45 verwijderingen
			
			
		| @ -1,8 +1,54 @@ | |||
| package controllers | |||
| 
 | |||
| import "github.com/astaxie/beego" | |||
| import ( | |||
| 	"github.com/astaxie/beego" | |||
| 	"strconv" | |||
| 	"beeblog/models" | |||
| 	"beeblog/service" | |||
| 	"fmt" | |||
| ) | |||
| 
 | |||
| type NoteController struct { | |||
| 	beego.Controller | |||
| } | |||
| 
 | |||
| func (this *NoteController) Save() { | |||
| 	pid,_ := this.GetInt64("pid") | |||
| 	fmt.Println("pid",pid) | |||
| 	title := this.GetString("title") | |||
| 	uid := this.GetSession("userid").(int64) | |||
| 
 | |||
| 	note := &models.Note{Title: title, Pid: pid, UserId: uid} | |||
| 	err := service.SaveNote(note) | |||
| 	if err == nil { | |||
| 		this.Data["json"] =  note | |||
| 	} else { | |||
| 		this.Data["json"] = models.ReurnError("保存失败") | |||
| 	} | |||
| 	this.ServeJSON() | |||
| } | |||
| 
 | |||
| func (this *NoteController) SaveNoteColl() { | |||
| 	title := this.GetString("title") | |||
| 	uid := this.GetSession("userid").(int64) | |||
| 
 | |||
| 	note := &models.NoteColl{Title: title, UserId: uid} | |||
| 	err := service.SaveNoteColl(note) | |||
| 	if err == nil { | |||
| 		this.Data["json"] =  note | |||
| 	} else { | |||
| 		this.Data["json"] = models.ReurnError("保存失败") | |||
| 	} | |||
| 	this.ServeJSON() | |||
| } | |||
| 
 | |||
| func (this *NoteController) Get() { | |||
| 	idStr := this.Ctx.Input.Param(":id") | |||
| 	id, _ := strconv.ParseInt(idStr, 10, 64) | |||
| 	note := &models.Note{Id: id} | |||
| 	err := service.GetNote(note) | |||
| 	if err == nil { | |||
| 		this.Data["json"] = note | |||
| 	} | |||
| 	this.ServeJSON() | |||
| } | |||
|  | |||
								
									Binary file not shown.
								
							
						
					| @ -1,10 +1,15 @@ | |||
| package models | |||
| 
 | |||
| import "time" | |||
| 
 | |||
| /** | |||
|  笔记 | |||
|  */ | |||
| type Note struct { | |||
| 	Id     int64 | |||
| 	UserId int64 | |||
| 	Title string | |||
| 	NoteVal string `orm:"size(3500)"` | |||
| 	NoteHtml string `orm:"size(5000)"` | |||
| 	Pid int64 | |||
| } | |||
| 	Id       int64 | |||
| 	UserId   int64 | |||
| 	Title    string | |||
| 	NoteHtml string    `type(text)"` | |||
| 	Pid      int64 | |||
| 	Utime    time.Time `orm:"auto_now_add;type(datetime)"` | |||
| } | |||
|  | |||
| @ -0,0 +1,9 @@ | |||
| package models | |||
| /** | |||
| 	文章 | |||
|  */ | |||
| type NoteColl struct { | |||
| 	Id     int64 | |||
| 	UserId int64 | |||
| 	Title string | |||
| } | |||
| @ -0,0 +1,12 @@ | |||
| package routers | |||
| 
 | |||
| import ( | |||
| 	"github.com/astaxie/beego" | |||
| 	"beeblog/controllers" | |||
| ) | |||
| 
 | |||
| func init() { | |||
| 	beego.Router("/note/:id([0-9]+)", &controllers.NoteController{}, "get:Get") | |||
| 	beego.Router("/notecoll/save", &controllers.NoteController{}, "post:SaveNoteColl") | |||
| 	beego.Router("/note/save", &controllers.NoteController{}, "post:Save") | |||
| } | |||
| @ -0,0 +1,49 @@ | |||
| package service | |||
| 
 | |||
| import ( | |||
| 	"beeblog/models" | |||
| 	"github.com/astaxie/beego/orm" | |||
| ) | |||
| 
 | |||
| type NoteService struct { | |||
| } | |||
| 
 | |||
| func SaveNote(note *models.Note) error { | |||
| 	o := orm.NewOrm() | |||
| 	id, err := o.Insert(note) | |||
| 	if err == nil { | |||
| 		note.Id = id | |||
| 	} | |||
| 	return err | |||
| } | |||
| 
 | |||
| func GetNote(note *models.Note) error { | |||
| 	o := orm.NewOrm() | |||
| 	return o.Read(note) | |||
| } | |||
| 
 | |||
| func GetNoteByPid(pid int64) ([]*models.Note, error) { | |||
| 	var notes []*models.Note | |||
| 	o := orm.NewOrm() | |||
| 	qs := o.QueryTable(models.Note{}) | |||
| 	_, err := qs.Filter("Pid", pid).All(notes) | |||
| 	return notes,err | |||
| } | |||
| 
 | |||
| 
 | |||
| func SaveNoteColl(note *models.NoteColl) error { | |||
| 	o := orm.NewOrm() | |||
| 	id, err := o.Insert(note) | |||
| 	if err == nil { | |||
| 		note.Id = id | |||
| 	} | |||
| 	return err | |||
| } | |||
| 
 | |||
| func GetNoteColl(uid int64) ([]*models.NoteColl, error) { | |||
| 	var notes []*models.NoteColl | |||
| 	o := orm.NewOrm() | |||
| 	qs := o.QueryTable(models.NoteColl{}) | |||
| 	_, err := qs.Filter("UserId", uid).All(notes) | |||
| 	return notes,err | |||
| } | |||
| @ -0,0 +1,73 @@ | |||
| .note-nav{ | |||
|     position: fixed; | |||
|     left: 0; | |||
|     top: 50%; | |||
|     z-index: 99999; | |||
| } | |||
| 
 | |||
| 
 | |||
| input[id*="joacims-menu"] { | |||
|     display:none; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"] + label { | |||
|     display:block; | |||
|     width:35px; | |||
|     height:35px; | |||
|     background:#222; | |||
|     cursor:pointer; | |||
|     font-size:30px; | |||
|     color:#fff; | |||
|     position:relative; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"] + label span { | |||
|     display:block; | |||
|     position:absolute; | |||
|     top: 2px; | |||
|     left: 5px; | |||
|     transition:.2s; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"]:checked + label span { | |||
|     transform:rotate(45deg); | |||
|     font-size:34px; | |||
|     top:0px; | |||
|     left:5px; | |||
| } | |||
| 
 | |||
| .note-nav a { | |||
|     display:block; | |||
|     height:40px; | |||
|     line-height:40px; | |||
|     background:#3e3e3e; | |||
|     width:100px; | |||
|     padding-left:10px; | |||
|     text-decoration:none; | |||
|     color:white; | |||
|     box-shadow:5px 0 0 #000; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(1) { box-shadow:5px 0 0 #3498db; transition-delay:.05s; } | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(2) { box-shadow:5px 0 0 #2ecc71; transition-delay:.10s; } | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(3) { box-shadow:5px 0 0 #e67e22; transition-delay:.15s; } | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(4) { box-shadow:5px 0 0 #c0392b; transition-delay:.20s; } | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(5) { box-shadow:5px 0 0 #2c3e50; transition-delay:.25s; } | |||
| input[id*="joacims-menu"] ~ nav a:nth-child(6) { box-shadow:5px 0 0 #f1c40f; transition-delay:.30s; } | |||
| 
 | |||
| input[id*="joacims-menu"]:checked ~ nav a { | |||
|     margin-left:0px; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"]:checked ~ nav a:hover { | |||
|     width:110px; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"] ~ nav a { | |||
|     margin-left:-110px; | |||
|     transition:.6s margin; | |||
| } | |||
| 
 | |||
| input[id*="joacims-menu"] ~ nav a:hover { | |||
|     background:#999; | |||
| } | |||
| Na Breedte: | Hoogte: | Grootte: 297 B | 
| @ -0,0 +1,79 @@ | |||
| <!DOCTYPE html> | |||
| <html> | |||
| <head> | |||
|     <meta charset="utf-8"> | |||
|     <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |||
|     <meta name="description" content="个人随笔是一个面向IT技术人员,提供个人平时工作总结和在线记录学习笔记,个人技术博客,在线云笔记,码农笔录,最新的技术博客,www.aiprose.com"> | |||
|     <meta name="keywords" | |||
|           content="个人随笔,博客,个人博客,个人笔记,技术博客,免费云笔记,云笔记,随笔,IT博客,谷歌地图,码农笔录,www.aiprose.com,aiprose.com,aiprose"> | |||
|     <link rel="stylesheet" href="//g.alicdn.com/sui/sui3/0.0.18/css/sui.min.css"> | |||
|     <script type="text/javascript" src="//g.alicdn.com/sj/lib/jquery/dist/jquery.min.js"></script> | |||
|     <script type="text/javascript" src="//g.alicdn.com/sui/sui3/0.0.18/js/sui.min.js"></script> | |||
|     <script type="text/javascript" src="/static/js/layer.js"></script> | |||
|     <title>首页 - 个人随笔</title> | |||
|     <style> | |||
|         .common { | |||
|             margin: 15px 0; | |||
|             display: flex; | |||
|             height: 32px; | |||
|             line-height: 32px; | |||
|         } | |||
| 
 | |||
|     </style> | |||
| </head> | |||
| <body> | |||
| <div style="margin: 20px 35px;"> | |||
|     <div class="common"> | |||
|         <span>所属文件夹:</span> | |||
|         <span style="flex: 1"> | |||
|             <select class="form-control " style="display: inline-block;height: 32px" id="catory"> | |||
|                 <option>1</option> | |||
|                 <option>2</option> | |||
|                 <option>3</option> | |||
|                 <option>4</option> | |||
|                 <option>5</option> | |||
|             </select> | |||
|         </span> | |||
|     </div> | |||
|     <div class="common"> | |||
|         <span>新笔记名称:</span> | |||
|         <input type="text" placeholder="输入标签" class="input-xfat" style="height: 32px;flex: 1" id="lable"> | |||
|     </div> | |||
|     <div class="common" style="text-align: center"> | |||
|         <button type="button" class="btn btn-primary btn-lg btn-block" id="saveBtn">保存</button> | |||
|     </div> | |||
| </div> | |||
| </body> | |||
| <script> | |||
|     $(function () { | |||
|         // if (parent.tobj.catory) { | |||
|         //     $("#catory").val(parent.tobj.catory) | |||
|         // } | |||
|         // if (parent.tobj.labels) { | |||
|         //     for (var i = 0; i < parent.tobj.labels.length; i++) { | |||
|         //         var child = "<label class='tag tag-primary'>" + parent.tobj.labels[i] + "<a name='remove'><i class=\"iconfont icon-close\"></i></a> " | |||
|         //                 + "<input type='checkbox' class='simple-tag' name='simple-tag-1' value='" + parent.tobj.labels[i] + "' checked='checked'/></label>" | |||
|         //         $("#labels").append(child) | |||
|         //     } | |||
|         // } | |||
| 
 | |||
| 
 | |||
|         $("#saveBtn").click(function () { | |||
|             var pid = $("#catory").val() | |||
|             var title = $("#lable").val() | |||
|             $.post('/note/save', { | |||
|                         pid: pid, | |||
|                         title: title | |||
|                     }, | |||
|                     function (data) { | |||
|                         debugger | |||
|                         if (!data.Status) { | |||
|                             parent.layer.msg("保存成功", {icon: 6}); | |||
|                             var index = parent.layer.getFrameIndex(window.name); | |||
|                             parent.layer.close(index); | |||
|                         } | |||
|                     }, 'json') | |||
|         }) | |||
|     }) | |||
| </script> | |||
| </html> | |||
					Laden…
					
					
				
		Reference in new issue