mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-23 10:58:35 +08:00
[fix]异常处理
This commit is contained in:
@@ -3,6 +3,7 @@ package api
|
||||
import (
|
||||
entity "pandax/apps/system/entity"
|
||||
services "pandax/apps/system/services"
|
||||
"pandax/kit/biz"
|
||||
"pandax/kit/casbin"
|
||||
"pandax/kit/model"
|
||||
"pandax/kit/restfulx"
|
||||
@@ -17,12 +18,14 @@ type SystemApiApi struct {
|
||||
func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) {
|
||||
var api entity.SysApi
|
||||
restfulx.BindJsonAndValid(rc, &api)
|
||||
s.ApiApp.Insert(api)
|
||||
_, err := s.ApiApp.Insert(api)
|
||||
biz.ErrIsNil(err, "添加APi失败")
|
||||
}
|
||||
|
||||
func (s *SystemApiApi) DeleteApi(rc *restfulx.ReqCtx) {
|
||||
ids := rc.Request.PathParameter("id")
|
||||
s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids))
|
||||
err := s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids))
|
||||
biz.ErrIsNil(err, "删除APi失败")
|
||||
}
|
||||
|
||||
func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
|
||||
@@ -33,7 +36,8 @@ func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
|
||||
method := rc.Request.QueryParameter("method")
|
||||
apiGroup := rc.Request.QueryParameter("apiGroup")
|
||||
api := entity.SysApi{Path: path, Description: description, Method: method, ApiGroup: apiGroup}
|
||||
list, total := s.ApiApp.FindListPage(pageNum, pageSize, api)
|
||||
list, total, err := s.ApiApp.FindListPage(pageNum, pageSize, api)
|
||||
biz.ErrIsNil(err, "查询APi分页列表失败")
|
||||
rc.ResData = model.ResultPage{
|
||||
Total: total,
|
||||
PageNum: int64(pageNum),
|
||||
@@ -44,18 +48,23 @@ func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
|
||||
|
||||
func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) {
|
||||
id := restfulx.QueryInt(rc, "id", 0)
|
||||
rc.ResData = s.ApiApp.FindOne(int64(id))
|
||||
data, err := s.ApiApp.FindOne(int64(id))
|
||||
biz.ErrIsNil(err, "查询APi失败")
|
||||
rc.ResData = data
|
||||
|
||||
}
|
||||
|
||||
func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) {
|
||||
var api entity.SysApi
|
||||
restfulx.BindJsonAndValid(rc, &api)
|
||||
s.ApiApp.Update(api)
|
||||
err := s.ApiApp.Update(api)
|
||||
biz.ErrIsNil(err, "查询APi失败")
|
||||
}
|
||||
|
||||
func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) {
|
||||
rc.ResData = s.ApiApp.FindList(entity.SysApi{})
|
||||
data, err := s.ApiApp.FindList(entity.SysApi{})
|
||||
biz.ErrIsNil(err, "查询APi列表失败")
|
||||
rc.ResData = data
|
||||
}
|
||||
|
||||
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) {
|
||||
|
||||
Reference in New Issue
Block a user