提交 0280c5f2 编写于 作者: Mr.奇淼('s avatar Mr.奇淼(

order test

上级 09bf9dd3
......@@ -247,10 +247,10 @@ go run main.go;
| 昵称 | 项目职务 | 姓 |
| ---- | ---- | ---- |
| [@piexlmax](https://github.com/piexlmax) | 项目发起者 | 蒋 |
| [@granty1](https://github.com/granty1) | 前端开发 | 尹 |
| [@granty1](https://github.com/granty1) | 后台开发 | 印 |
| [@Ruio9244](https://github.com/Ruio9244) | 全栈开发 | 严 |
| [@1319612909](https://github.com/1319612909) | 前端UI开发 | 杜 |
| [@krank666](https://github.com/krank666) | 后台开发 | 印 |
| [@krank666](https://github.com/krank666) | 前端开发 | 尹 |
| [@chen-chen-up](https://github.com/chen-chen-up) | 新手开发 | 宋 |
## 12. 捐赠
......
......@@ -45,11 +45,6 @@ func DeleteApi(c *gin.Context) {
}
}
type AuthAndPathIn struct {
AuthorityId string `json:"authorityId"`
ApiIds []uint `json:"apiIds"`
}
//条件搜索后端看此api
// @Tags SysApi
......@@ -65,10 +60,12 @@ func GetApiList(c *gin.Context) {
type searchParams struct {
model.SysApi
model.PageInfo
OrderKey string `json:"orderKey"`
Desc bool `json:"desc"`
}
var sp searchParams
_ = c.ShouldBindJSON(&sp)
err, list, total := sp.SysApi.GetInfoList(sp.PageInfo)
err, list, total := sp.SysApi.GetInfoList(sp.PageInfo, sp.OrderKey, sp.Desc)
if err != nil {
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取数据失败,%v", err), c)
} else {
......
......@@ -101,7 +101,7 @@ func (a *SysApi) GetAllApis() (err error, apis []SysApi) {
// @return err error
// @return list interface{}
// @return total int
func (a *SysApi) GetInfoList(info PageInfo) (err error, list interface{}, total int) {
func (a *SysApi) GetInfoList(info PageInfo, Order string, Desc bool) (err error, list interface{}, total int) {
limit := info.PageSize
offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB
......@@ -128,7 +128,12 @@ func (a *SysApi) GetInfoList(info PageInfo) (err error, list interface{}, total
if err != nil {
return err, apiList, total
} else {
err = db.Limit(limit).Offset(offset).Order("api_group", true).Find(&apiList).Error
db = db.Limit(limit).Offset(offset)
if Order != "" {
err = db.Order(Order+" desc", true).Find(&apiList).Error
} else {
err = db.Order("api_group", true).Find(&apiList).Error
}
}
return err, apiList, total
}
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册