Skip to content

Commit

Permalink
fix: search stra
Browse files Browse the repository at this point in the history
  • Loading branch information
710leo committed Apr 9, 2020
1 parent 2dd14c6 commit 3dc69b7
Showing 4 changed files with 7 additions and 8 deletions.
Empty file modified control
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions install.sh
Original file line number Diff line number Diff line change
@@ -12,5 +12,5 @@ if [ ! -d "$GOPATH/src/github.com/710leo/urlooker" ]; then
else
cd $GOPATH/src/github.com/710leo/urlooker && git pull
fi
cd $GOPATH/src/github.com/710leo/urlooker && ./control.sh build
echo "install ok! run cd $GOPATH/src/github.com/710leo/urlooker && ./control.sh start all"
cd $GOPATH/src/github.com/710leo/urlooker && ./control build
echo "install ok! run cd $GOPATH/src/github.com/710leo/urlooker && ./control start all"
10 changes: 5 additions & 5 deletions modules/web/model/strategy.go
Original file line number Diff line number Diff line change
@@ -10,14 +10,14 @@ type Strategy dataobj.Strategy
func GetAllStrategyCount(mine int, query, username string) (int64, error) {
if mine == 1 {
if query != "" {
return Orm.Where("url LIKE ? AND creator = ? ORDER BY id", "%"+query+"%", username).Count(new(Strategy))
return Orm.Where("url LIKE ? AND creator = ?", "%"+query+"%", username).Count(new(Strategy))
} else {
num, err := Orm.Where("creator = ?", username).Count(new(Strategy))
return num, err
}
} else {
if query != "" {
return Orm.Where("url LIKE ? ORDER BY id", "%"+query+"%").Count(new(Strategy))
return Orm.Where("url LIKE ?", "%"+query+"%").Count(new(Strategy))
} else {
num, err := Orm.Count(new(Strategy))
return num, err
@@ -32,13 +32,13 @@ func GetAllStrategy(mine, limit, offset int, query, username string) ([]*Strateg
var err error
if mine == 1 {
if query != "" {
err = Orm.Where("url LIKE ? AND creator = ? ORDER BY id", "%"+query+"%", username).Limit(limit, offset).Find(&items)
err = Orm.Where("url LIKE ? AND creator = ?", "%"+query+"%", username).Limit(limit, offset).OrderBy("id").Find(&items)
} else {
err = Orm.Where("creator = ?", username).Limit(limit, offset).Find(&items)
err = Orm.Where("creator = ?", username).Limit(limit, offset).OrderBy("id").Find(&items)
}
} else {
if query != "" {
err = Orm.Where("url LIKE ? ORDER BY id", "%"+query+"%").Limit(limit, offset).Find(&items)
err = Orm.Where("url LIKE ?", "%"+query+"%").Limit(limit, offset).OrderBy("id").Find(&items)
} else {
err = Orm.Limit(limit, offset).Find(&items)
}
1 change: 0 additions & 1 deletion modules/web/store/mysql.go
Original file line number Diff line number Diff line change
@@ -15,7 +15,6 @@ func InitMysql() {
cfg := g.Config

var err error
log.Println(g.Config)
Orm, err = xorm.NewEngine("mysql", cfg.Mysql.Addr)
if err != nil {
log.Fatalln("fail to connect mysql", err)

0 comments on commit 3dc69b7

Please sign in to comment.