func archiveNote(rq rsrq.ArchiveNoteRQ) error {
	db, dbErr := data.GetDataConnection()
	if dbErr != nil {
		log.Fatal(dbErr)
	}
	defer db.Close()

	archiveNoteUpdate := data.ARCHIVE_NOTE_UPDATE
	archiveNoteUpdate = strings.Replace(archiveNoteUpdate, "{ID}", rq.NoteId, 1)
	archiveNoteUpdate = strings.Replace(archiveNoteUpdate, "{USERID}", rq.UserToken, 1)

	return data.ExecStatement(db, archiveNoteUpdate)
}
Example #2
0
//TODO add this to Note Data Controller (DAO / Registry)
func insertNewNote(user string, noteId string, parentId string) error {
	db, dbErr := data.GetDataConnection()
	if dbErr != nil {
		log.Fatal(dbErr)
	}
	defer db.Close()

	insertQuery := data.INSERT_NOTE
	insertQuery = strings.Replace(insertQuery, "{ID}", noteId, 1)
	insertQuery = strings.Replace(insertQuery, "{PARENTID}", parentId, 1)
	insertQuery = strings.Replace(insertQuery, "{NAME}", "New Note", 1) //todo constant for new note name
	insertQuery = strings.Replace(insertQuery, "{CONTENT}", "", 1)
	insertQuery = strings.Replace(insertQuery, "{STATUS}", strconv.Itoa(data.NEW), 1)
	insertQuery = strings.Replace(insertQuery, "{CREATED}", strconv.FormatInt(time.Now().UnixNano(), 10), 1)
	insertQuery = strings.Replace(insertQuery, "{MODIFIED}", strconv.FormatInt(time.Now().UnixNano(), 10), 1)
	insertQuery = strings.Replace(insertQuery, "{USERID}", user, 1) //TODO put in order

	return data.ExecStatement(db, insertQuery)
}