chore: 并入 iotlcm-admin-svr 历史到 admin-svr/(原提交 49818c6)
This commit is contained in:
@@ -0,0 +1,69 @@
|
||||
package agent
|
||||
|
||||
import (
|
||||
"context"
|
||||
v1 "git.5iot.com/iotlcm-public/iotlcm-admin-svr/api/agent/v1"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model"
|
||||
"git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/service"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
// TApiResourceList 查询开放接口资源列表。
|
||||
func (c *ControllerV1) TApiResourceList(ctx context.Context, req *v1.TApiResourceListReq) (res *v1.TApiResourceListRes, err error) {
|
||||
list, totalCount, err := service.AgentTApiResource().List(ctx, &req.TApiResourceListParam)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if list == nil {
|
||||
list = []*model.TApiResourceListModel{}
|
||||
}
|
||||
res = new(v1.TApiResourceListRes)
|
||||
res.Items = list
|
||||
res.PageResult.Page = req.Page
|
||||
res.PageResult.PageSize = req.PageSize
|
||||
res.PageResult.Total = totalCount
|
||||
return
|
||||
}
|
||||
|
||||
// TApiResourceExport 导出开放接口资源列表。
|
||||
func (c *ControllerV1) TApiResourceExport(ctx context.Context, req *v1.TApiResourceExportReq) (res *v1.TApiResourceExportRes, err error) {
|
||||
err = service.AgentTApiResource().Export(ctx, &req.TApiResourceListParam)
|
||||
return
|
||||
}
|
||||
|
||||
// TApiResourceEdit 新增或修改开放接口资源。
|
||||
func (c *ControllerV1) TApiResourceEdit(ctx context.Context, req *v1.TApiResourceEditReq) (res *v1.TApiResourceEditRes, err error) {
|
||||
param := req.TApiResourceEditParam
|
||||
g.Log().Info(ctx, "TApiResourceEdit", param)
|
||||
if r := g.RequestFromCtx(ctx); r != nil {
|
||||
if err = r.Parse(¶m); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
err = service.AgentTApiResource().Edit(ctx, ¶m)
|
||||
return
|
||||
}
|
||||
|
||||
// TApiResourceView 查询开放接口资源详情。
|
||||
func (c *ControllerV1) TApiResourceView(ctx context.Context, req *v1.TApiResourceViewReq) (res *v1.TApiResourceViewRes, err error) {
|
||||
data, err := service.AgentTApiResource().View(ctx, &req.TApiResourceViewParam)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
res = new(v1.TApiResourceViewRes)
|
||||
res.TApiResourceViewModel = data
|
||||
return
|
||||
}
|
||||
|
||||
// TApiResourceDelete 删除开放接口资源,并清理权限组资源关联。
|
||||
func (c *ControllerV1) TApiResourceDelete(ctx context.Context, req *v1.TApiResourceDeleteReq) (res *v1.TApiResourceDeleteRes, err error) {
|
||||
err = service.AgentTApiResource().Delete(ctx, &req.TApiResourceDeleteParam)
|
||||
return
|
||||
}
|
||||
|
||||
// TApiResourceStatus 更新开放接口资源启停状态。
|
||||
func (c *ControllerV1) TApiResourceStatus(ctx context.Context, req *v1.TApiResourceStatusReq) (res *v1.TApiResourceStatusRes, err error) {
|
||||
err = service.AgentTApiResource().Status(ctx, &req.TApiResourceStatusParam)
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user