huangyan il y a 5 mois
Parent
commit
3c826b7255
2 fichiers modifiés avec 7 ajouts et 5 suppressions
  1. 7 2
      app/controller/pageManage.go
  2. 0 3
      nats/Nats.go

+ 7 - 2
app/controller/pageManage.go

@@ -16,6 +16,9 @@ var PageManage service.Page = &model.PageManage{}
 func GetPageManage(c *gin.Context) {
 	var page unity.QueryPageParams
 	uid := unity.GetUId(c)
+	// 查询条件:查询name
+	queryCond := "name like ?"
+	page.Query = "%" + page.Query + "%"
 	err := c.ShouldBindJSON(&page)
 	if err != nil {
 		e.ResponseWithMsg(c, e.JSONParsingFailed, e.JSONParsingFailed.GetMsg())
@@ -25,7 +28,7 @@ func GetPageManage(c *gin.Context) {
 		e.ResponseWithMsg(c, e.ERROR, "用户不存在")
 		return
 	} else if uid == 1 {
-		result, total, err := unity.PaginateWithCondition(page, model.PageManage{}, nil)
+		result, total, err := unity.PaginateWithCondition(page, model.PageManage{}, queryCond)
 		if err != nil {
 			e.ResponseWithMsg(c, e.PaginationFailed, e.PaginationFailed.GetMsg())
 			return
@@ -35,7 +38,7 @@ func GetPageManage(c *gin.Context) {
 	}
 	var manage model.PageManage
 	manage.UserId = uid
-	result, total, err := PageManage.GetPageManage(page, manage, nil)
+	result, total, err := PageManage.GetPageManage(page, manage, queryCond)
 	if err != nil {
 		e.ResponseWithMsg(c, e.PaginationFailed, e.PaginationFailed.GetMsg())
 		return
@@ -64,6 +67,7 @@ func GetPageManageById(c *gin.Context) {
 			return
 		}
 		e.ResponseSuccess(c, result)
+		return
 	}
 	byId, err := PageManage.GetPageManageById(uid, id)
 	if err != nil {
@@ -127,6 +131,7 @@ func UpdatePageManage(c *gin.Context) {
 		e.ResponseWithMsg(c, e.TheUserIsEmpty, e.TheUserIsEmpty.GetMsg())
 		return
 	} else if uid == 1 {
+		page.UserId = 0
 		_, err = unity.UpdateById(id, &page)
 		if err != nil {
 			e.ResponseWithMsg(c, e.UPDATEFAIL, e.UPDATEFAIL.GetMsg())

+ 0 - 3
nats/Nats.go

@@ -4,7 +4,6 @@ import (
 	"Panel_development/global"
 	"Panel_development/simple_zap"
 	"context"
-	"fmt"
 	"github.com/nats-io/nats.go"
 )
 
@@ -12,11 +11,9 @@ var Nats *nats.Conn
 
 func SetupNats() {
 	var err error
-	fmt.Println(global.NatsSetting.NatsServerUrl)
 	Nats, err = nats.Connect(global.NatsSetting.NatsServerUrl)
 	if err != nil {
 		simple_zap.WithCtx(context.Background()).Sugar().Warn(err, "nats 连接失败")
 		panic(err)
 	}
-	simple_zap.WithCtx(context.Background()).Sugar().Info(err, "nats 连接成功")
 }