95 lines
2.3 KiB
Go
95 lines
2.3 KiB
Go
package server
|
|
|
|
import (
|
|
"admin/apps/game/model/dto"
|
|
"admin/internal/consts"
|
|
"admin/internal/context"
|
|
"admin/lib/httpclient"
|
|
"admin/lib/xlog"
|
|
"strings"
|
|
)
|
|
|
|
func (ctl *controller) CommandList(ctx *context.WebContext, params *dto.CommandListReq, rsp *dto.CommandListRsp) error {
|
|
|
|
url := params.Addr + "/api/commandlist"
|
|
|
|
xlog.Debugf("request url:%v command list", url)
|
|
|
|
cmdListRsp := make(map[string]any)
|
|
err := httpclient.Request(url, "get", nil, &cmdListRsp)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
xlog.Debugf("command list rsp:%+v", cmdListRsp)
|
|
|
|
ctx.Ok(cmdListRsp)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (ctl *controller) ProjectResourceList(ctx *context.WebContext, params *dto.CommonListReq, rsp *dto.CommonListRsp) error {
|
|
projectId := getCtxURIProjectId(ctx)
|
|
resource := getCtxURIResource(ctx)
|
|
|
|
apiAddr, err := ctl.svc.GetProjectInvokeApiAddr(projectId, nil)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
url := apiAddr[0] + "/api/" + resource
|
|
|
|
listRsp := make(map[string]any)
|
|
err = httpclient.Request(url, "get", nil, &listRsp)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
xlog.Debugf("receive project %v resource %v list", "projectId", resource)
|
|
return nil
|
|
}
|
|
|
|
func (ctl *controller) ProjectResourcePost(ctx *context.WebContext, params *dto.CommonPostReq, rsp *dto.CommonPostRsp) error {
|
|
|
|
return nil
|
|
}
|
|
|
|
func (ctl *controller) ProjectResourcePut(ctx *context.WebContext, params *dto.CommonPutReq, rsp *dto.CommonPutRsp) error {
|
|
|
|
return nil
|
|
}
|
|
|
|
func (ctl *controller) ProjectResourceDelete(ctx *context.WebContext, params *dto.CommonDeleteReq, rsp *dto.CommonDeleteRsp) error {
|
|
|
|
return nil
|
|
}
|
|
|
|
func (ctl *controller) getProjectResourceCommandApiAddr(ctx *context.WebContext) ([]string, error) {
|
|
projectId := getCtxURIProjectId(ctx)
|
|
//resouce := getCtxURIResource(ctx)
|
|
return ctl.svc.GetProjectInvokeApiAddr(projectId, nil)
|
|
}
|
|
|
|
func getCtxURIProjectIdAndResource(ctx *context.WebContext) (string, string) {
|
|
return getCtxURIProjectId(ctx), getCtxURIResource(ctx)
|
|
}
|
|
|
|
func getCtxURIResource(ctx *context.WebContext) string {
|
|
resource := ctx.GinCtx().Param("resource")
|
|
if resource == "" {
|
|
if strings.HasPrefix(ctx.GinCtx().Request.RequestURI, "/api/"+consts.ResourcesName_Project) {
|
|
return consts.ResourcesName_Project
|
|
}
|
|
}
|
|
return resource
|
|
}
|
|
|
|
func getCtxURIProjectId(ctx *context.WebContext) string {
|
|
projectId := ctx.GinCtx().Param("projectId")
|
|
return projectId
|
|
}
|
|
|
|
func (ctl *controller) apiRequest() {
|
|
|
|
}
|