Skip to content

Commit

Permalink
model 層を修正
Browse files Browse the repository at this point in the history
  • Loading branch information
H1rono committed Jun 18, 2022
1 parent 95855a1 commit a8514cf
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions model/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func AddCode(ctx context.Context, code *Code) (hash string, err error) {
for i := 0; i < 10; i++ {
h := makeHash()
c := 0
err := db.SelectContext(
err := db.GetContext(
ctx,
&c,
"SELECT COUNT(*) FROM codes WHERE `user_name` = ? AND `hash` = ?",
Expand All @@ -51,7 +51,7 @@ func AddCode(ctx context.Context, code *Code) (hash string, err error) {
ctx,
"INSERT INTO codes "+
"(`user_name`, `hash`, `plain_code`, `stdin`, `title`, `options`) "+
"VALUES (?, ?, ?, ?, ?, ?) WHERE NOT EXIST",
"VALUES (?, ?, ?, ?, ?, ?)",
code.UserName,
h,
code.PlainCode,
Expand All @@ -73,7 +73,7 @@ func GetCode(ctx context.Context, userName string, hash string) (Code, error) {
ctx,
&c,
"SELECT `user_name`, `plain_code`, `stdin`, `title`, `options` "+
"FROM 22hack16 "+
"FROM codes "+
"WHERE `user_name` = ? AND `hash` = ?",
userName,
hash,
Expand Down

0 comments on commit a8514cf

Please sign in to comment.