ljw 1 год назад
Родитель
Сommit
1191ade8af
4 измененных файлов с 24 добавлено и 1 удалено
  1. 18 0
      http/controller/admin/peer.go
  2. 4 0
      http/request/admin/peer.go
  3. 1 0
      http/router/admin.go
  4. 1 1
      model/peer.go

+ 18 - 0
http/controller/admin/peer.go

@@ -207,3 +207,21 @@ func (ct *Peer) BatchDelete(c *gin.Context) {
207 207
 	}
208 208
 	response.Success(c, nil)
209 209
 }
210
+
211
+func (ct *Peer) SimpleData(c *gin.Context) {
212
+	f := &admin.SimpleDataQuery{}
213
+	if err := c.ShouldBindJSON(f); err != nil {
214
+		response.Fail(c, 101, response.TranslateMsg(c, "ParamsError")+err.Error())
215
+		return
216
+	}
217
+	if len(f.Ids) == 0 {
218
+		response.Fail(c, 101, response.TranslateMsg(c, "ParamsError"))
219
+		return
220
+	}
221
+	res := service.AllService.PeerService.List(1, 99999, func(tx *gorm.DB) {
222
+		//可以公开的情报
223
+		tx.Select("id,version")
224
+		tx.Where("id in (?)", f.Ids)
225
+	})
226
+	response.Success(c, res)
227
+}

+ 4 - 0
http/request/admin/peer.go

@@ -39,3 +39,7 @@ type PeerQuery struct {
39 39
 	Id       string `json:"id" form:"id"`
40 40
 	Hostname string `json:"hostname" form:"hostname"`
41 41
 }
42
+
43
+type SimpleDataQuery struct {
44
+	Ids []string `json:"ids" form:"ids"`
45
+}

+ 1 - 0
http/router/admin.go

@@ -112,6 +112,7 @@ func PeerBind(rg *gin.RouterGroup) {
112 112
 		aR.POST("/create", cont.Create)
113 113
 		aR.POST("/update", cont.Update)
114 114
 		aR.POST("/delete", cont.Delete)
115
+		aR.POST("/simpleData", cont.SimpleData)
115 116
 
116 117
 		arp := aR.Use(middleware.AdminPrivilege())
117 118
 		arp.POST("/batchDelete", cont.BatchDelete)

+ 1 - 1
model/peer.go

@@ -11,7 +11,7 @@ type Peer struct {
11 11
 	Uuid           string `json:"uuid"  gorm:"default:'';not null;index"`
12 12
 	Version        string `json:"version"  gorm:"default:'';not null;"`
13 13
 	UserId         uint   `json:"user_id"  gorm:"default:0;not null;index"`
14
-	User           User   `json:"user,omitempty" gorm:""`
14
+	User           *User  `json:"user,omitempty"`
15 15
 	LastOnlineTime int64  `json:"last_online_time"  gorm:"default:0;not null;"`
16 16
 	TimeModel
17 17
 }