mirror of
https://github.com/Li4n0/revsuit.git
synced 2026-09-26 16:41:53 +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
@@ -101,10 +101,7 @@ func ListRules(c *gin.Context) {
|
||||
}
|
||||
|
||||
db := database.DB.Model(&dnsRule)
|
||||
if dnsRule.Name != "" {
|
||||
db.Where("name = ?", dnsRule.Name)
|
||||
}
|
||||
db.Count(&count)
|
||||
db.Where(&dnsRule).Count(&count)
|
||||
|
||||
page, err := strconv.Atoi(c.Query("page"))
|
||||
if err != nil {
|
||||
@@ -138,10 +135,7 @@ func ListRules(c *gin.Context) {
|
||||
|
||||
// UpsertRules creates or updates dns rule from user submit
|
||||
func UpsertRules(c *gin.Context) {
|
||||
var (
|
||||
dnsRule Rule
|
||||
update bool
|
||||
)
|
||||
var dnsRule Rule
|
||||
|
||||
if err := c.ShouldBind(&dnsRule); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
@@ -152,10 +146,6 @@ func UpsertRules(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if dnsRule.ID != 0 {
|
||||
update = true
|
||||
}
|
||||
|
||||
if err := dnsRule.CreateOrUpdate(); err != nil {
|
||||
c.JSON(400, gin.H{
|
||||
"status": "failed",
|
||||
@@ -165,7 +155,7 @@ func UpsertRules(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
if update {
|
||||
if dnsRule.ID != 0 {
|
||||
log.Trace("DNS rule[id:%d] has been updated", dnsRule.ID)
|
||||
} else {
|
||||
log.Trace("DNS rule[id:%d] has been created", dnsRule.ID)
|
||||
|
||||
Reference in New Issue
Block a user