dddd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

107 lines
2.7 KiB

package shiyan
import (
"fmt"
"strconv"
"github.com/flipped-aurora/gin-vue-admin/server/commonus"
"github.com/flipped-aurora/gin-vue-admin/server/global"
"github.com/flipped-aurora/gin-vue-admin/server/model/common/response"
"github.com/flipped-aurora/gin-vue-admin/server/model/testpage"
"github.com/flipped-aurora/gin-vue-admin/server/model/wechat"
"github.com/gin-gonic/gin"
)
type ShiyanApi struct {
}
func (a *ShiyanApi) AddBaseMenu(c *gin.Context) {
var answerMap testpage.Answer
err := global.GVA_DB_Master.First(&answerMap)
if err != nil {
}
fmt.Printf("%v\n", answerMap)
response.Ok(c)
}
//get请求获参
func (a *ShiyanApi) GetRequestOperation(c *gin.Context) {
id := c.Query("id")
fmt.Printf("====>%v\n", id)
response.Ok(c)
}
//get请求获参
type postGroupCanshu struct {
Id int `json:"id" from:"id"`
}
func (a *ShiyanApi) PostRequestOperation(c *gin.Context) {
var ids postGroupCanshu
_ = c.ShouldBindJSON(&ids)
// name := c.Query("id")
fmt.Printf("====>%v\n", ids.Id)
response.Ok(c)
}
//实验递归
func (s *ShiyanApi) DiGui(c *gin.Context) {
var group []wechat.GroupForm
listErr := global.GVA_DB_WatchDate.Find(&group).Error
if listErr == nil {
}
var ids wechat.GroupForm
_ = c.ShouldBindJSON(&ids)
var setid int64
setid = 51
if ids.Id != 0 {
setid = ids.Id
}
// var parentId []int64
// var dd Ddigui
// dd.faherDigui(81, group, parentId)
// dd.Date = commonus.BubbleSort(dd.Date)
var dd commonus.ErgodicStruct
dd.ParentId = 1
dd.ErgodicParentClassGroup(setid, group)
dd.Date = append(dd.Date, setid)
dd.Date = commonus.BubbleSort(dd.Date)
setidIntString := strconv.FormatInt(setid, 10)
setidInt, _ := strconv.Atoi(setidIntString)
depart, isTrue := commonus.GetDepartment(setidInt)
dateary := commonus.MapOut()
dateary["data"] = depart
dateary["istrue"] = isTrue
dateary["digui"] = dd.Date
response.Result(0, dateary, "查询失败", c)
}
type Ddigui struct {
Date []int64
}
//递归递归函数
func (d *Ddigui) faherDigui(id int64, groupStruct []wechat.GroupForm, parentId []int64) []int64 {
var parentIds []int64
// parentId = append(parentId, id)
for _, v := range groupStruct {
if v.Id == id {
d.Date = append(d.Date, v.Parentid)
d.faherDigui(v.Parentid, groupStruct, parentId)
// parentId = append(parentId, v.Parentid)
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
// parentIds = parentId
// parentIds = faherDigui(v.Parentid, groupStruct, parentIds)
// parentId = append(parentId, v.Parentid)
// fmt.Printf("%v==========>%v*******%v\n", id, v.Parentid, parentId)
}
}
// parentId = parentIds
// fmt.Printf("%v==========>*******\n", parentIds)
return parentIds
}