mirror of
https://github.com/usememos/memos.git
synced 2024-12-26 07:01:17 +08:00
update utils file structure
This commit is contained in:
parent
b20741cca8
commit
63d9f092c5
6 changed files with 17 additions and 17 deletions
|
@ -7,9 +7,9 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"memos/api/e"
|
||||
"memos/common"
|
||||
"memos/config"
|
||||
"memos/store"
|
||||
"memos/utils"
|
||||
"net/http"
|
||||
|
||||
"github.com/gorilla/mux"
|
||||
|
@ -222,7 +222,7 @@ func handleGithubAuthCallback(w http.ResponseWriter, r *http.Request) {
|
|||
username := githubUser.Name
|
||||
usernameUsable, _ := store.CheckUsernameUsable(username)
|
||||
for !usernameUsable {
|
||||
username = githubUser.Name + common.GenUUID()
|
||||
username = githubUser.Name + utils.GenUUID()
|
||||
usernameUsable, _ = store.CheckUsernameUsable(username)
|
||||
}
|
||||
user, _ = store.CreateNewUser(username, username, githubUser.Login, "")
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package api
|
||||
|
||||
import (
|
||||
"memos/common"
|
||||
"memos/utils"
|
||||
|
||||
"github.com/gorilla/sessions"
|
||||
)
|
||||
|
||||
var SessionStore = sessions.NewCookieStore([]byte(common.GenUUID()))
|
||||
var SessionStore = sessions.NewCookieStore([]byte(utils.GenUUID()))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"memos/common"
|
||||
"memos/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -15,9 +15,9 @@ type Memo struct {
|
|||
}
|
||||
|
||||
func CreateNewMemo(content string, userId string) (Memo, error) {
|
||||
nowDateTimeStr := common.GetNowDateTimeStr()
|
||||
nowDateTimeStr := utils.GetNowDateTimeStr()
|
||||
newMemo := Memo{
|
||||
Id: common.GenUUID(),
|
||||
Id: utils.GenUUID(),
|
||||
Content: content,
|
||||
UserId: userId,
|
||||
DeletedAt: "",
|
||||
|
@ -48,7 +48,7 @@ func UpdateMemo(id string, memoPatch *MemoPatch) (Memo, error) {
|
|||
memo.DeletedAt = *v
|
||||
set, args = append(set, "deleted_at=?"), append(args, *v)
|
||||
}
|
||||
set, args = append(set, "updated_at=?"), append(args, common.GetNowDateTimeStr())
|
||||
set, args = append(set, "updated_at=?"), append(args, utils.GetNowDateTimeStr())
|
||||
args = append(args, id)
|
||||
|
||||
sqlQuery := `UPDATE memos SET ` + strings.Join(set, ",") + ` WHERE id=?`
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
package store
|
||||
|
||||
import (
|
||||
"memos/common"
|
||||
"memos/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -16,9 +16,9 @@ type Query struct {
|
|||
}
|
||||
|
||||
func CreateNewQuery(title string, querystring string, userId string) (Query, error) {
|
||||
nowDateTimeStr := common.GetNowDateTimeStr()
|
||||
nowDateTimeStr := utils.GetNowDateTimeStr()
|
||||
newQuery := Query{
|
||||
Id: common.GenUUID(),
|
||||
Id: utils.GenUUID(),
|
||||
Title: title,
|
||||
Querystring: querystring,
|
||||
UserId: userId,
|
||||
|
@ -55,7 +55,7 @@ func UpdateQuery(id string, queryPatch *QueryPatch) (Query, error) {
|
|||
query.PinnedAt = *v
|
||||
set, args = append(set, "pinned_at=?"), append(args, *v)
|
||||
}
|
||||
set, args = append(set, "updated_at=?"), append(args, common.GetNowDateTimeStr())
|
||||
set, args = append(set, "updated_at=?"), append(args, utils.GetNowDateTimeStr())
|
||||
args = append(args, id)
|
||||
|
||||
sqlQuery := `UPDATE queries SET ` + strings.Join(set, ",") + ` WHERE id=?`
|
||||
|
|
|
@ -3,7 +3,7 @@ package store
|
|||
import (
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"memos/common"
|
||||
"memos/utils"
|
||||
"strings"
|
||||
)
|
||||
|
||||
|
@ -18,9 +18,9 @@ type User struct {
|
|||
}
|
||||
|
||||
func CreateNewUser(username string, password string, githubName string, wxOpenId string) (User, error) {
|
||||
nowDateTimeStr := common.GetNowDateTimeStr()
|
||||
nowDateTimeStr := utils.GetNowDateTimeStr()
|
||||
newUser := User{
|
||||
Id: common.GenUUID(),
|
||||
Id: utils.GenUUID(),
|
||||
Username: username,
|
||||
Password: password,
|
||||
WxOpenId: wxOpenId,
|
||||
|
@ -62,7 +62,7 @@ func UpdateUser(id string, userPatch *UserPatch) (User, error) {
|
|||
user.WxOpenId = *v
|
||||
set, args = append(set, "wx_open_id=?"), append(args, *v)
|
||||
}
|
||||
set, args = append(set, "updated_at=?"), append(args, common.GetNowDateTimeStr())
|
||||
set, args = append(set, "updated_at=?"), append(args, utils.GetNowDateTimeStr())
|
||||
args = append(args, id)
|
||||
|
||||
sqlQuery := `UPDATE users SET ` + strings.Join(set, ",") + ` WHERE id=?`
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package common
|
||||
package utils
|
||||
|
||||
import (
|
||||
"time"
|
Loading…
Reference in a new issue