-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fix refresh and delete in cert and site after sort
- Loading branch information
Showing
13 changed files
with
270 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package object | ||
|
||
import ( | ||
"fmt" | ||
"github.com/casbin/caswaf/util" | ||
"github.com/xorm-io/xorm" | ||
) | ||
|
||
func GetSession(owner string, offset, limit int, field, value, sortField, sortOrder string) *xorm.Session { | ||
session := ormer.Engine.Prepare() | ||
if offset != -1 && limit != -1 { | ||
session.Limit(limit, offset) | ||
} | ||
if owner != "" { | ||
session = session.And("owner=?", owner) | ||
} | ||
if field != "" && value != "" { | ||
if util.FilterField(field) { | ||
session = session.And(fmt.Sprintf("%s like ?", util.SnakeString(field)), fmt.Sprintf("%%%s%%", value)) | ||
} | ||
} | ||
if sortField == "" || sortOrder == "" { | ||
sortField = "created_time" | ||
} | ||
if sortOrder == "ascend" { | ||
session = session.Asc(util.SnakeString(sortField)) | ||
} else { | ||
session = session.Desc(util.SnakeString(sortField)) | ||
} | ||
return session | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package util | ||
|
||
import "regexp" | ||
|
||
var ( | ||
ReWhiteSpace *regexp.Regexp | ||
ReFieldWhiteList *regexp.Regexp | ||
) | ||
|
||
func init() { | ||
ReWhiteSpace, _ = regexp.Compile(`\s`) | ||
ReFieldWhiteList, _ = regexp.Compile(`^[A-Za-z0-9]+$`) | ||
} | ||
|
||
func FilterField(field string) bool { | ||
return ReFieldWhiteList.MatchString(field) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.