|
@@ -3,13 +3,13 @@ package xunji_service
|
|
import (
|
|
import (
|
|
"context"
|
|
"context"
|
|
|
|
|
|
- "wechat-api/ent/xunjiservice"
|
|
|
|
"wechat-api/ent/predicate"
|
|
"wechat-api/ent/predicate"
|
|
|
|
+ "wechat-api/ent/xunjiservice"
|
|
"wechat-api/internal/svc"
|
|
"wechat-api/internal/svc"
|
|
"wechat-api/internal/types"
|
|
"wechat-api/internal/types"
|
|
"wechat-api/internal/utils/dberrorhandler"
|
|
"wechat-api/internal/utils/dberrorhandler"
|
|
|
|
|
|
- "github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
|
|
|
+ "github.com/suyuan32/simple-admin-common/msg/errormsg"
|
|
|
|
|
|
"github.com/suyuan32/simple-admin-common/utils/pointy"
|
|
"github.com/suyuan32/simple-admin-common/utils/pointy"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
"github.com/zeromicro/go-zero/core/logx"
|
|
@@ -40,7 +40,7 @@ func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceLi
|
|
if req.ApiKey != nil {
|
|
if req.ApiKey != nil {
|
|
predicates = append(predicates, xunjiservice.APIKeyContains(*req.ApiKey))
|
|
predicates = append(predicates, xunjiservice.APIKeyContains(*req.ApiKey))
|
|
}
|
|
}
|
|
- data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
|
+ data, err := l.svcCtx.DB.XunjiService.Query().Where(predicates...).WithAgent().Page(l.ctx, req.Page, req.PageSize)
|
|
|
|
|
|
if err != nil {
|
|
if err != nil {
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
return nil, dberrorhandler.DefaultEntError(l.Logger, err, req)
|
|
@@ -51,21 +51,38 @@ func (l *GetXunjiServiceListLogic) GetXunjiServiceList(req *types.XunjiServiceLi
|
|
resp.Data.Total = data.PageDetails.Total
|
|
resp.Data.Total = data.PageDetails.Total
|
|
|
|
|
|
for _, v := range data.List {
|
|
for _, v := range data.List {
|
|
|
|
+ var agent types.AgentInfo
|
|
|
|
+ if v.Edges.Agent != nil {
|
|
|
|
+ agent = types.AgentInfo{
|
|
|
|
+ BaseIDInfo: types.BaseIDInfo{
|
|
|
|
+ Id: &v.AgentID,
|
|
|
|
+ CreatedAt: pointy.GetPointer(v.Edges.Agent.CreatedAt.UnixMilli()),
|
|
|
|
+ UpdatedAt: pointy.GetPointer(v.Edges.Agent.UpdatedAt.UnixMilli()),
|
|
|
|
+ },
|
|
|
|
+ Name: &v.Edges.Agent.Name,
|
|
|
|
+ Role: &v.Edges.Agent.Role,
|
|
|
|
+ Status: &v.Edges.Agent.Status,
|
|
|
|
+ Background: &v.Edges.Agent.Background,
|
|
|
|
+ Examples: &v.Edges.Agent.Examples,
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
resp.Data.Data = append(resp.Data.Data,
|
|
resp.Data.Data = append(resp.Data.Data,
|
|
- types.XunjiServiceInfo{
|
|
|
|
- BaseIDInfo: types.BaseIDInfo{
|
|
|
|
- Id: &v.ID,
|
|
|
|
- CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
|
|
|
|
- UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
|
|
|
|
- },
|
|
|
|
- Status: &v.Status,
|
|
|
|
- XunjiId: &v.XunjiID,
|
|
|
|
- AgentId: &v.AgentID,
|
|
|
|
- OrganizationId: &v.OrganizationID,
|
|
|
|
- Wxid: &v.Wxid,
|
|
|
|
- ApiBase: &v.APIBase,
|
|
|
|
- ApiKey: &v.APIKey,
|
|
|
|
- })
|
|
|
|
|
|
+ types.XunjiServiceInfo{
|
|
|
|
+ BaseIDInfo: types.BaseIDInfo{
|
|
|
|
+ Id: &v.ID,
|
|
|
|
+ CreatedAt: pointy.GetPointer(v.CreatedAt.UnixMilli()),
|
|
|
|
+ UpdatedAt: pointy.GetPointer(v.UpdatedAt.UnixMilli()),
|
|
|
|
+ },
|
|
|
|
+ Status: &v.Status,
|
|
|
|
+ XunjiId: &v.XunjiID,
|
|
|
|
+ AgentId: &v.AgentID,
|
|
|
|
+ AgentInfo: &agent,
|
|
|
|
+ OrganizationId: &v.OrganizationID,
|
|
|
|
+ Wxid: &v.Wxid,
|
|
|
|
+ ApiBase: &v.APIBase,
|
|
|
|
+ ApiKey: &v.APIKey,
|
|
|
|
+ })
|
|
}
|
|
}
|
|
|
|
|
|
return resp, nil
|
|
return resp, nil
|