Browse Source

order test

main
pixel 5 years ago
parent
commit
0280c5f25c
  1. 4
      README-zh_CN.md
  2. 9
      server/api/v1/sys_api.go
  3. 9
      server/model/sys_api.go
  4. 4
      web/package-lock.json

4
README-zh_CN.md

@ -247,10 +247,10 @@ go run main.go;
| 昵称 | 项目职务 | 姓 | | 昵称 | 项目职务 | 姓 |
| ---- | ---- | ---- | | ---- | ---- | ---- |
| [@piexlmax](https://github.com/piexlmax) | 项目发起者 | 蒋 | | [@piexlmax](https://github.com/piexlmax) | 项目发起者 | 蒋 |
| [@granty1](https://github.com/granty1) | 前端开发 | 尹 |
| [@granty1](https://github.com/granty1) | 后台开发 | 印 |
| [@Ruio9244](https://github.com/Ruio9244) | 全栈开发 | 严 | | [@Ruio9244](https://github.com/Ruio9244) | 全栈开发 | 严 |
| [@1319612909](https://github.com/1319612909) | 前端UI开发 | 杜 | | [@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) | 新手开发 | 宋 | | [@chen-chen-up](https://github.com/chen-chen-up) | 新手开发 | 宋 |
## 12. 捐赠 ## 12. 捐赠

9
server/api/v1/sys_api.go

@ -45,11 +45,6 @@ func DeleteApi(c *gin.Context) {
} }
} }
type AuthAndPathIn struct {
AuthorityId string `json:"authorityId"`
ApiIds []uint `json:"apiIds"`
}
//条件搜索后端看此api //条件搜索后端看此api
// @Tags SysApi // @Tags SysApi
@ -65,10 +60,12 @@ func GetApiList(c *gin.Context) {
type searchParams struct { type searchParams struct {
model.SysApi model.SysApi
model.PageInfo model.PageInfo
OrderKey string `json:"orderKey"`
Desc bool `json:"desc"`
} }
var sp searchParams var sp searchParams
_ = c.ShouldBindJSON(&sp) _ = 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 { if err != nil {
response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取数据失败,%v", err), c) response.Result(response.ERROR, gin.H{}, fmt.Sprintf("获取数据失败,%v", err), c)
} else { } else {

9
server/model/sys_api.go

@ -101,7 +101,7 @@ func (a *SysApi) GetAllApis() (err error, apis []SysApi) {
// @return err error // @return err error
// @return list interface{} // @return list interface{}
// @return total int // @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 limit := info.PageSize
offset := info.PageSize * (info.Page - 1) offset := info.PageSize * (info.Page - 1)
db := global.GVA_DB db := global.GVA_DB
@ -128,7 +128,12 @@ func (a *SysApi) GetInfoList(info PageInfo) (err error, list interface{}, total
if err != nil { if err != nil {
return err, apiList, total return err, apiList, total
} else { } 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 return err, apiList, total
} }

4
web/package-lock.json

@ -1280,7 +1280,7 @@
"@vue/component-compiler-utils": "^3.0.0", "@vue/component-compiler-utils": "^3.0.0",
"@vue/preload-webpack-plugin": "^1.1.0", "@vue/preload-webpack-plugin": "^1.1.0",
"@vue/web-component-wrapper": "^1.2.0", "@vue/web-component-wrapper": "^1.2.0",
"acorn": "^6.1.1",
"acorn": "^6.4.1",
"acorn-walk": "^6.1.1", "acorn-walk": "^6.1.1",
"address": "^1.0.3", "address": "^1.0.3",
"autoprefixer": "^9.5.1", "autoprefixer": "^9.5.1",
@ -1310,7 +1310,7 @@
"lodash.mapvalues": "^4.6.0", "lodash.mapvalues": "^4.6.0",
"lodash.transform": "^4.6.0", "lodash.transform": "^4.6.0",
"mini-css-extract-plugin": "^0.6.0", "mini-css-extract-plugin": "^0.6.0",
"minimist": "^1.2.0",
"minimist": "^1.2.3",
"ora": "^3.4.0", "ora": "^3.4.0",
"portfinder": "^1.0.20", "portfinder": "^1.0.20",
"postcss-loader": "^3.0.0", "postcss-loader": "^3.0.0",

Loading…
Cancel
Save