| | |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.exception.FebsException; |
| | | import cc.mrbird.febs.common.utils.AppContants; |
| | | import cc.mrbird.febs.common.utils.LoginUserUtil; |
| | | import cc.mrbird.febs.common.utils.RedisUtils; |
| | | import cc.mrbird.febs.common.utils.YHLoginUserUtil; |
| | | import cc.mrbird.febs.rabbit.producter.AgentProducer; |
| | |
| | | |
| | | private final YhAiMemberMapper yhAiMemberMapper; |
| | | private final YHAiCompanyMapper yhAiCompanyMapper; |
| | | private final YHAiBannerMapper yhAiBannerMapper; |
| | | private final YHAiLogoMapper yhAiLogoMapper; |
| | | |
| | | private final YHAiAgentCategoryMapper yhAiAgentCategoryMapper; |
| | | private final YHAiAgentMapper yhAiAgentMapper; |
| | | private final YHAiAgentStartQuestionMapper yhAiAgentStartQuestionMapper; |
| | | private final YHAiAgentKnowledgeMapper yhAiAgentKnowledgeMapper; |
| | | private final YHAiKnowledgeMapper yhAiKnowledgeMapper; |
| | | private final YHAiAgentLinkMapper yhAiAgentLinkMapper; |
| | | private final YHAiAgentCategoryLinkMapper yhAiAgentCategoryLinkMapper; |
| | | |
| | | private final YhSysAgentCategoryMapper yhSysAgentCategoryMapper; |
| | | private final YHSysAgentStartQuestionMapper yhSysAgentStartQuestionMapper; |
| | |
| | | return new FebsResponse().success().data(yhMemberVo); |
| | | } |
| | | |
| | | private boolean isDefaultCompany(String companyId){ |
| | | String companyCode = yhAiCompanyMapper.selectDictLabel("xcx_register_default","default"); |
| | | YHAiCompany yhAiCompany = yhAiCompanyMapper.selectOne( |
| | | Wrappers.lambdaQuery(YHAiCompany.class) |
| | | .eq(YHAiCompany::getId, companyId) |
| | | ); |
| | | if (ObjectUtil.isEmpty(yhAiCompany)){ |
| | | return false; |
| | | } |
| | | return companyCode.equals(yhAiCompany.getCode()); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse categoryList(YHCategoryDto dto) { |
| | | String companyId = YHLoginUserUtil.getLoginUser().getCompanyId(); |
| | | List<YHCategoryVo> yhCategoryVos = new ArrayList<>(); |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | YhAiMember yhAiMember = yhAiMemberMapper.selectOne(Wrappers.lambdaQuery(YhAiMember.class).eq(YhAiMember::getMemberUuid, memberUuid)); |
| | | String companyId = yhAiMember.getCompanyId(); |
| | | |
| | | boolean defaultCompany = isDefaultCompany(companyId); |
| | | |
| | | List<YHCategoryVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<YHAiAgentCategory> query = Wrappers.lambdaQuery(YHAiAgentCategory.class); |
| | | |
| | | List<String> yhAiAgentCategoryLinksIds = new ArrayList<>(); |
| | | |
| | | log.info("开始查询智能体分类{}",defaultCompany); |
| | | if (!defaultCompany){ |
| | | List<YHAiAgentCategoryLink> yhAiAgentCategoryLinks = yhAiAgentCategoryLinkMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiAgentCategoryLink.class) |
| | | .eq(YHAiAgentCategoryLink::getCompanyId, companyId) |
| | | .eq(YHAiAgentCategoryLink::getMemberUuid, memberUuid) |
| | | ); |
| | | if (CollUtil.isEmpty(yhAiAgentCategoryLinks)){ |
| | | return new FebsResponse().success().data(vos); |
| | | } |
| | | for (YHAiAgentCategoryLink yhAiAgentCategoryLink : yhAiAgentCategoryLinks) { |
| | | yhAiAgentCategoryLinksIds.add(yhAiAgentCategoryLink.getAgentCategoryId()); |
| | | } |
| | | query.in(YHAiAgentCategory::getId,yhAiAgentCategoryLinksIds); |
| | | } |
| | | |
| | | query.eq(YHAiAgentCategory::getCompanyId,companyId); |
| | | query.eq(YHAiAgentCategory::getState,1); |
| | | if (ObjectUtil.isNotEmpty(dto.getId())){ |
| | | query.eq(YHAiAgentCategory::getId,dto.getId()); |
| | | } |
| | | if (ObjectUtil.isNotEmpty(dto.getHotState())){ |
| | | query.eq(YHAiAgentCategory::getHotState,dto.getHotState()); |
| | | } |
| | |
| | | YHCategoryVo yhCategoryVo = new YHCategoryVo(); |
| | | yhCategoryVo.setName(yhAiAgentCategory.getName()); |
| | | yhCategoryVo.setId(yhAiAgentCategory.getId()); |
| | | yhCategoryVos.add(yhCategoryVo); |
| | | vos.add(yhCategoryVo); |
| | | } |
| | | } |
| | | |
| | | return new FebsResponse().success().data(yhCategoryVos); |
| | | return new FebsResponse().success().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse agentList(YHAgentDto dto) { |
| | | String companyId = YHLoginUserUtil.getLoginUser().getCompanyId(); |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | YhAiMember yhAiMember = yhAiMemberMapper.selectOne(Wrappers.lambdaQuery(YhAiMember.class).eq(YhAiMember::getMemberUuid, memberUuid)); |
| | | String companyId = yhAiMember.getCompanyId(); |
| | | |
| | | ArrayList<YHAgentVo> yhAgentVos = new ArrayList<>(); |
| | | |
| | | LambdaQueryWrapper<YHAiAgent> query = Wrappers.lambdaQuery(YHAiAgent.class); |
| | | |
| | | boolean defaultCompany = isDefaultCompany(companyId); |
| | | if (!defaultCompany){ |
| | | |
| | | List<YHAiAgentLink> yhAiAgentLinks = yhAiAgentLinkMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiAgentLink.class) |
| | | .eq(YHAiAgentLink::getCompanyId, companyId) |
| | | .eq(YHAiAgentLink::getMemberUuid, memberUuid) |
| | | ); |
| | | if (CollUtil.isEmpty(yhAiAgentLinks)){ |
| | | return new FebsResponse().success().data(yhAgentVos); |
| | | } |
| | | List<String> yhAiAgentLinksIds = new ArrayList<>(); |
| | | for (YHAiAgentLink yhAiAgentLink : yhAiAgentLinks) { |
| | | yhAiAgentLinksIds.add(yhAiAgentLink.getAgentId()); |
| | | } |
| | | query.in(YHAiAgent::getId,yhAiAgentLinksIds); |
| | | } |
| | | query.eq(YHAiAgent::getCompanyId,companyId); |
| | | query.eq(YHAiAgent::getState,1); |
| | | if (ObjectUtil.isNotEmpty(dto.getAgentCategoryId())){ |
| | |
| | | @Override |
| | | public FebsResponse agentInfo(YHAgentInitDto dto) { |
| | | |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | String companyId = YHLoginUserUtil.getLoginUser().getCompanyId(); |
| | | YHAgentInitVo yhAgentInitVo = new YHAgentInitVo(); |
| | | |
| | | String id = dto.getId(); |
| | | |
| | | YHAgentInitVo yhAgentInitVo = new YHAgentInitVo(); |
| | | |
| | | |
| | | boolean defaultCompany = isDefaultCompany(companyId); |
| | | if (!defaultCompany){ |
| | | List<YHAiAgentLink> yhAiAgentLinks = yhAiAgentLinkMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiAgentLink.class) |
| | | .eq(YHAiAgentLink::getAgentId, id) |
| | | .eq(YHAiAgentLink::getMemberUuid, memberUuid) |
| | | ); |
| | | if (CollUtil.isEmpty(yhAiAgentLinks)){ |
| | | throw new FebsException("无权限"); |
| | | } |
| | | } |
| | | |
| | | YHAiAgent yhAiAgent = yhAiAgentMapper.selectById(id); |
| | | if (ObjectUtil.isNotEmpty(yhAiAgent)){ |
| | | yhAgentInitVo.setId(yhAiAgent.getId()); |
| | |
| | | |
| | | @Override |
| | | public FebsResponse logout() { |
| | | String memberUuid = LoginUserUtil.getLoginUser().getMemberUuid(); |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | |
| | | String redisKey = AppContants.XCX_LOGIN_PREFIX + memberUuid; |
| | | String existToken = redisUtils.getString(redisKey); |
| | |
| | | |
| | | @Override |
| | | public FebsResponse initSend(YHSendInitDto dto) { |
| | | String memberUuid = LoginUserUtil.getLoginUser().getMemberUuid(); |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | |
| | | YHSendInitVo vo = new YHSendInitVo(); |
| | | |
| | |
| | | } |
| | | return messages; |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse bannerList() { |
| | | List<YHBannerVo> vos = new ArrayList<>(); |
| | | List<YHAiBanner> list = yhAiBannerMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiBanner.class) |
| | | .eq(YHAiBanner::getState, 1) |
| | | .isNull(YHAiBanner::getCompanyId) |
| | | .orderByDesc(YHAiBanner::getSort) |
| | | ); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | for (YHAiBanner aiBanner : list){ |
| | | YHBannerVo vo = new YHBannerVo(); |
| | | vo.setName(aiBanner.getName()); |
| | | vo.setImageUrl(aiBanner.getImageUrl()); |
| | | vo.setSort(aiBanner.getSort()); |
| | | vos.add(vo); |
| | | } |
| | | } |
| | | return new FebsResponse().success().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse logoInfo() { |
| | | YHLogoVo yhLogoVo = new YHLogoVo(); |
| | | |
| | | List<YHAiLogo> yhAiLogos = yhAiLogoMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiLogo.class) |
| | | .eq(YHAiLogo::getState, 1) |
| | | .isNull(YHAiLogo::getCompanyId) |
| | | ); |
| | | if (CollUtil.isNotEmpty(yhAiLogos)){ |
| | | YHAiLogo yhAiLogo = yhAiLogos.get(0); |
| | | yhLogoVo.setName(yhAiLogo.getName()); |
| | | yhLogoVo.setImageUrl(yhAiLogo.getImageUrl()); |
| | | yhLogoVo.setDesription(yhAiLogo.getDesription()); |
| | | } |
| | | |
| | | return new FebsResponse().success().data(yhLogoVo); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse loginBannerList() { |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | YhAiMember yhAiMember = yhAiMemberMapper.selectOne(Wrappers.lambdaQuery(YhAiMember.class).eq(YhAiMember::getMemberUuid, memberUuid)); |
| | | String companyId = yhAiMember.getCompanyId(); |
| | | |
| | | List<YHBannerVo> vos = new ArrayList<>(); |
| | | List<YHAiBanner> list = yhAiBannerMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiBanner.class) |
| | | .eq(YHAiBanner::getState, 1) |
| | | .eq(YHAiBanner::getCompanyId, companyId) |
| | | .orderByAsc(YHAiBanner::getSort) |
| | | ); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | for (YHAiBanner aiBanner : list){ |
| | | YHBannerVo vo = new YHBannerVo(); |
| | | vo.setName(aiBanner.getName()); |
| | | vo.setImageUrl(aiBanner.getImageUrl()); |
| | | vo.setSort(aiBanner.getSort()); |
| | | vos.add(vo); |
| | | } |
| | | } |
| | | return new FebsResponse().success().data(vos); |
| | | } |
| | | |
| | | @Override |
| | | public FebsResponse loginLogoInfo() { |
| | | String memberUuid = YHLoginUserUtil.getLoginUser().getMemberUuid(); |
| | | YhAiMember yhAiMember = yhAiMemberMapper.selectOne(Wrappers.lambdaQuery(YhAiMember.class).eq(YhAiMember::getMemberUuid, memberUuid)); |
| | | String companyId = yhAiMember.getCompanyId(); |
| | | |
| | | YHLogoVo yhLogoVo = new YHLogoVo(); |
| | | |
| | | List<YHAiLogo> yhAiLogos = yhAiLogoMapper.selectList( |
| | | Wrappers.lambdaQuery(YHAiLogo.class) |
| | | .eq(YHAiLogo::getState, 1) |
| | | .eq(YHAiLogo::getCompanyId, companyId) |
| | | ); |
| | | if (CollUtil.isNotEmpty(yhAiLogos)){ |
| | | YHAiLogo yhAiLogo = yhAiLogos.get(0); |
| | | yhLogoVo.setName(yhAiLogo.getName()); |
| | | yhLogoVo.setImageUrl(yhAiLogo.getImageUrl()); |
| | | yhLogoVo.setDesription(yhAiLogo.getDesription()); |
| | | } |
| | | |
| | | return new FebsResponse().success().data(yhLogoVo); |
| | | } |
| | | } |