package employee import ( "context" "github.com/suyuan32/simple-admin-common/msg/errormsg" "github.com/suyuan32/simple-admin-common/utils/pointy" "wechat-api/ent/employee" "wechat-api/internal/utils/dberrorhandler" "wechat-api/internal/svc" "wechat-api/internal/types" "github.com/zeromicro/go-zero/core/logx" ) type GetApiEmployeeDetailLogic struct { logx.Logger ctx context.Context svcCtx *svc.ServiceContext } func NewGetApiEmployeeDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GetApiEmployeeDetailLogic { return &GetApiEmployeeDetailLogic{ Logger: logx.WithContext(ctx), ctx: ctx, svcCtx: svcCtx} } func (l *GetApiEmployeeDetailLogic) GetApiEmployeeDetail(req *types.IDReq) (*types.EmployeeInfoResp, error) { data, err := l.svcCtx.DB.Employee.Query().Where(employee.ID(req.Id)).Only(l.ctx) if err != nil { return nil, dberrorhandler.DefaultEntError(l.Logger, err, req) } // 是否显示聊天,是否显示Ai连线,是否显示VIP var showChat, isVip bool if data.APIKey != "" && data.APIBase != "" { showChat = true } if data.IsVip != 0 { isVip = true } return &types.EmployeeInfoResp{ BaseDataInfo: types.BaseDataInfo{ Code: 0, Msg: errormsg.Success, }, Data: types.EmployeeInfo{ BaseIDInfo: types.BaseIDInfo{ Id: &data.ID, CreatedAt: pointy.GetPointer(data.CreatedAt.UnixMilli()), UpdatedAt: pointy.GetPointer(data.UpdatedAt.UnixMilli()), }, Title: &data.Title, Avatar: &data.Avatar, Tags: &data.Tags, HireCount: &data.HireCount, ServiceCount: &data.ServiceCount, AchievementCount: &data.AchievementCount, Intro: &data.Intro, Estimate: &data.Estimate, Skill: &data.Skill, AbilityType: &data.AbilityType, Scene: &data.Scene, SwitchIn: &data.SwitchIn, VideoUrl: &data.VideoURL, CategoryId: &data.CategoryID, ShowChat: &showChat, IsVip: &isVip, ChatUrl: &data.ChatURL, }, }, nil }