mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-26 08:31:52 +08:00
feat(ldap): add ldap protocol support (#50)
Co-authored-by: tardc <[email protected]> Co-authored-by: E99p1ant <[email protected]>
This commit is contained in:
+3
-13
@@ -84,10 +84,7 @@ func ListRules(c *gin.Context) {
|
||||
}
|
||||
|
||||
db := database.DB.Model(&mysqlRule)
|
||||
if mysqlRule.Name != "" {
|
||||
db.Where("name = ?", mysqlRule.Name)
|
||||
}
|
||||
db.Count(&count)
|
||||
db.Where(&mysqlRule).Count(&count)
|
||||
|
||||
page, err := strconv.Atoi(c.Query("page"))
|
||||
if err != nil {
|
||||
@@ -121,10 +118,7 @@ func ListRules(c *gin.Context) {
|
||||
|
||||
// UpsertRules create or update mysql rule from user submit
|
||||
func UpsertRules(c *gin.Context) {
|
||||
var (
|
||||
mysqlRule Rule
|
||||
update bool
|
||||
)
|
||||
var mysqlRule Rule
|
||||
|
||||
if err := c.ShouldBind(&mysqlRule); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
@@ -135,10 +129,6 @@ func UpsertRules(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if mysqlRule.ID != 0 {
|
||||
update = true
|
||||
}
|
||||
|
||||
if err := mysqlRule.CreateOrUpdate(); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
@@ -148,7 +138,7 @@ func UpsertRules(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if update {
|
||||
if mysqlRule.ID != 0 {
|
||||
log.Trace("MySQL rule[id:%d] has been updated", mysqlRule.ID)
|
||||
} else {
|
||||
log.Trace("MySQL rule[id:%d] has been created", mysqlRule.ID)
|
||||
|
||||
Reference in New Issue
Block a user