[优化]base模块提出

This commit is contained in:
PandaGoAdmin
2022-08-02 22:37:37 +08:00
parent 0555922a90
commit 2cb23c0ecf
151 changed files with 550 additions and 5255 deletions

View File

@@ -1,12 +1,12 @@
package api
import (
"github.com/XM-GO/PandaKit/casbin"
"github.com/XM-GO/PandaKit/restfulx"
"github.com/XM-GO/PandaKit/utils"
"log"
entity "pandax/apps/system/entity"
services "pandax/apps/system/services"
"pandax/base/casbin"
"pandax/base/ginx"
"pandax/base/utils"
"strconv"
)
@@ -22,9 +22,9 @@ type SystemApiApi struct {
// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"创建成功"}"
// @Router /system/api [post]
func (s *SystemApiApi) CreateApi(rc *ginx.ReqCtx) {
func (s *SystemApiApi) CreateApi(rc *restfulx.ReqCtx) {
var api entity.SysApi
ginx.BindJsonAndValid(rc.GinCtx, &api)
restfulx.BindJsonAndValid(rc.GinCtx, &api)
log.Println(api)
s.ApiApp.Insert(api)
}
@@ -36,7 +36,7 @@ func (s *SystemApiApi) CreateApi(rc *ginx.ReqCtx) {
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"删除成功"}"
// @Router /system/api/{id} [delete]
func (s *SystemApiApi) DeleteApi(rc *ginx.ReqCtx) {
func (s *SystemApiApi) DeleteApi(rc *restfulx.ReqCtx) {
ids := rc.GinCtx.Param("id")
s.ApiApp.Delete(utils.IdsStrToIdsIntGroup(ids))
}
@@ -54,9 +54,9 @@ func (s *SystemApiApi) DeleteApi(rc *ginx.ReqCtx) {
// @Param pageNum query int false "页码"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/list [get]
func (s *SystemApiApi) GetApiList(rc *ginx.ReqCtx) {
pageNum := ginx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := ginx.QueryInt(rc.GinCtx, "pageSize", 10)
func (s *SystemApiApi) GetApiList(rc *restfulx.ReqCtx) {
pageNum := restfulx.QueryInt(rc.GinCtx, "pageNum", 1)
pageSize := restfulx.QueryInt(rc.GinCtx, "pageSize", 10)
path := rc.GinCtx.Query("path")
description := rc.GinCtx.Query("description")
method := rc.GinCtx.Query("method")
@@ -79,8 +79,8 @@ func (s *SystemApiApi) GetApiList(rc *ginx.ReqCtx) {
// @Param id path int true "根据id获取api"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/{id} [get]
func (s *SystemApiApi) GetApiById(rc *ginx.ReqCtx) {
id := ginx.QueryInt(rc.GinCtx, "id", 0)
func (s *SystemApiApi) GetApiById(rc *restfulx.ReqCtx) {
id := restfulx.QueryInt(rc.GinCtx, "id", 0)
rc.ResData = s.ApiApp.FindOne(int64(id))
}
@@ -93,9 +93,9 @@ func (s *SystemApiApi) GetApiById(rc *ginx.ReqCtx) {
// @Param data body entity.SysApi true "api路径, api中文描述, api组, 方法"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"修改成功"}"
// @Router /api/api [put]
func (s *SystemApiApi) UpdateApi(rc *ginx.ReqCtx) {
func (s *SystemApiApi) UpdateApi(rc *restfulx.ReqCtx) {
var api entity.SysApi
ginx.BindJsonAndValid(rc.GinCtx, &api)
restfulx.BindJsonAndValid(rc.GinCtx, &api)
s.ApiApp.Update(api)
}
@@ -106,7 +106,7 @@ func (s *SystemApiApi) UpdateApi(rc *ginx.ReqCtx) {
// @Produce application/json
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /system/api/all [get]
func (s *SystemApiApi) GetAllApis(rc *ginx.ReqCtx) {
func (s *SystemApiApi) GetAllApis(rc *restfulx.ReqCtx) {
rc.ResData = s.ApiApp.FindList(entity.SysApi{})
}
@@ -118,7 +118,7 @@ func (s *SystemApiApi) GetAllApis(rc *ginx.ReqCtx) {
// @Param roleKey query string true "权限id, 权限模型列表"
// @Success 200 {string} string "{"success":true,"data":{},"msg":"获取成功"}"
// @Router /casbin/getPolicyPathByRoleId [get]
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *ginx.ReqCtx) {
func (s *SystemApiApi) GetPolicyPathByRoleId(rc *restfulx.ReqCtx) {
roleKey := rc.GinCtx.Query("roleKey")
tenantId := strconv.Itoa(int(rc.LoginAccount.TenantId))
rc.ResData = casbin.GetPolicyPathByRoleId(tenantId, roleKey)