|
@@ -2,15 +2,17 @@
|
|
|
package admin
|
|
|
|
|
|
import (
|
|
|
- "github.com/gin-contrib/sessions"
|
|
|
- "github.com/gin-gonic/gin"
|
|
|
- "gopkg.in/mgo.v2/bson"
|
|
|
. "jy/mongodbutil"
|
|
|
"jy/util"
|
|
|
+ "log"
|
|
|
"net/http"
|
|
|
qu "qfw/util"
|
|
|
"strings"
|
|
|
"time"
|
|
|
+
|
|
|
+ "github.com/gin-contrib/sessions"
|
|
|
+ "github.com/gin-gonic/gin"
|
|
|
+ "gopkg.in/mgo.v2/bson"
|
|
|
)
|
|
|
|
|
|
func init() {
|
|
@@ -27,20 +29,20 @@ func init() {
|
|
|
})
|
|
|
//根据_id查询版本详细信息
|
|
|
Admin.GET("/version/dataById", func(c *gin.Context) {
|
|
|
- gid ,b :=c.GetQuery("_id")
|
|
|
- if !b || !bson.IsObjectIdHex(gid){
|
|
|
- c.JSON(400,gin.H{"req":false})
|
|
|
+ gid, b := c.GetQuery("_id")
|
|
|
+ if !b || !bson.IsObjectIdHex(gid) {
|
|
|
+ c.JSON(400, gin.H{"req": false})
|
|
|
return
|
|
|
}
|
|
|
|
|
|
data, _ := Mgo.FindOne("version", `{"_id":"`+gid+`","delete":false}`)
|
|
|
- c.JSON(200, gin.H{"req":true,"data": data})
|
|
|
+ c.JSON(200, gin.H{"req": true, "data": data})
|
|
|
})
|
|
|
Admin.POST("/version/save", func(c *gin.Context) {
|
|
|
_id, _ := c.GetPostForm("_id")
|
|
|
data := GetPostForm(c)
|
|
|
- if data["s_filefileds"]!=nil{
|
|
|
- data["s_filefileds"] = strings.Split(data["s_filefileds"].(string),",")
|
|
|
+ if data["s_filefileds"] != nil {
|
|
|
+ data["s_filefileds"] = strings.Split(data["s_filefileds"].(string), ",")
|
|
|
}
|
|
|
if _id != "" {
|
|
|
Mgo.UpdateById("version", _id, map[string]interface{}{"$set": data})
|
|
@@ -249,6 +251,70 @@ func init() {
|
|
|
//b := Mgo.Del("versioninfo", `{"_id":"`+_id+`"}`)
|
|
|
c.JSON(200, gin.H{"rep": b})
|
|
|
})
|
|
|
+ //分块配置
|
|
|
+ Admin.GET("/version/blockinfo", func(c *gin.Context) {
|
|
|
+ vid := c.Query("vid")
|
|
|
+ c.HTML(http.StatusOK, "blockinfo.html", gin.H{"vid": vid})
|
|
|
+ })
|
|
|
+ Admin.POST("/version/blockinfo_list", func(c *gin.Context) {
|
|
|
+ vid, _ := c.GetPostForm("vid")
|
|
|
+ data, _ := Mgo.Find("block_info", bson.M{"vid": vid, "delete": false}, `{"index":-1}`, `{"block_reg":1,"title_reg":1,"index":1}`, false, -1, -1)
|
|
|
+ for _, v := range *data {
|
|
|
+ v["id"] = qu.BsonIdToSId(v["_id"])
|
|
|
+ }
|
|
|
+ c.JSON(http.StatusOK, gin.H{"data": data})
|
|
|
+ })
|
|
|
+ //分块配置保存
|
|
|
+ Admin.POST("/version/blockinfo_save", func(c *gin.Context) {
|
|
|
+ status := false
|
|
|
+ _id, _ := c.GetPostForm("_id")
|
|
|
+ block_reg, _ := c.GetPostForm("block_reg")
|
|
|
+ title_reg, _ := c.GetPostForm("title_reg")
|
|
|
+ if _id != "" {
|
|
|
+ status = Mgo.UpdateById("block_info", _id, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "l_updatetime": time.Now().Unix(),
|
|
|
+ "block_reg": block_reg,
|
|
|
+ "title_reg": title_reg,
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ vid, _ := c.GetPostForm("vid")
|
|
|
+ list, flag := Mgo.Find("block_info", bson.M{"vid": vid}, `{"index": 1}`, `{"index":1}`, false, 0, 1)
|
|
|
+ index := -1
|
|
|
+ if flag && len(*list) == 1 {
|
|
|
+ index = qu.IntAllDef((*list)[0]["index"], 1) - 1
|
|
|
+ }
|
|
|
+ status = Mgo.Save("block_info", bson.M{
|
|
|
+ "delete": false,
|
|
|
+ "index": index,
|
|
|
+ "block_reg": block_reg,
|
|
|
+ "title_reg": title_reg,
|
|
|
+ "vid": vid,
|
|
|
+ "l_createtime": time.Now().Unix(),
|
|
|
+ "s_username": sessions.Default(c).Get("username"),
|
|
|
+ }) != ""
|
|
|
+ }
|
|
|
+ c.JSON(http.StatusOK, gin.H{"status": status})
|
|
|
+ })
|
|
|
+ Admin.POST("/version/blockinfo_updateindex", func(c *gin.Context) {
|
|
|
+ _ids := c.PostFormArray("_ids")
|
|
|
+ indexs := c.PostFormArray("indexs")
|
|
|
+ log.Println(_ids, indexs)
|
|
|
+ for k, _id := range _ids {
|
|
|
+ Mgo.UpdateById("block_info", _id, bson.M{
|
|
|
+ "$set": bson.M{
|
|
|
+ "index": qu.IntAll(indexs[k]),
|
|
|
+ },
|
|
|
+ })
|
|
|
+ }
|
|
|
+ c.JSON(http.StatusOK, gin.H{})
|
|
|
+ })
|
|
|
+ Admin.POST("/version/blockinfo_delete", func(c *gin.Context) {
|
|
|
+ _id, _ := c.GetPostForm("_id")
|
|
|
+ status := Mgo.UpdateById("block_info", _id, bson.M{"$set": bson.M{"delete": true}})
|
|
|
+ c.JSON(http.StatusOK, gin.H{"status": status})
|
|
|
+ })
|
|
|
}
|
|
|
|
|
|
//克隆版本通用属性
|