Commit ed056161 authored by alex yao's avatar alex yao

feat: add interface to get user collect agent application list in index

parent 4a83ac4b
select baap.member_id as member_id,
baap.agent_id as agent_id,
baap.agent_title as agent_title,
baap.agent_desc as agent_desc,
baap.agent_avatar as agent_avatar
from biz_member_agent_application_collect bmaac
left join biz_agent_application_publish baap on baap.agent_id = bmaac.agent_id and baap.is_deleted = 'N'
where bmaac.is_deleted = 'N' <<and bmaac.is_collect = :isCollect>>
<<and bmaac.member_id = :memberId>>
order by baap.created_time desc
\ No newline at end of file
package cn.com.poc.agent_application.query;
import java.io.Serializable;
/**
* Query Condition class for MemberCollectQuery
*/
public class MemberCollectQueryCondition implements Serializable{
private static final long serialVersionUID = 1L;
private java.lang.String isCollect;
public java.lang.String getIsCollect(){
return this.isCollect;
}
public void setIsCollect(java.lang.String isCollect){
this.isCollect = isCollect;
}
private java.lang.Long memberId;
public java.lang.Long getMemberId(){
return this.memberId;
}
public void setMemberId(java.lang.Long memberId){
this.memberId = memberId;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.query;
import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import cn.com.yict.framemax.data.model.BaseItemClass;
/**
* Query Item class for MemberCollectQuery
*/
@Entity
public class MemberCollectQueryItem extends BaseItemClass implements Serializable{
private static final long serialVersionUID = 1L;
/** member_id
*member_id
*/
private java.lang.Integer memberId;
@Column(name = "member_id")
public java.lang.Integer getMemberId(){
return this.memberId;
}
public void setMemberId(java.lang.Integer memberId){
this.memberId = memberId;
}
/** agent_id
*agent_id
*/
private java.lang.String agentId;
@Column(name = "agent_id")
public java.lang.String getAgentId(){
return this.agentId;
}
public void setAgentId(java.lang.String agentId){
this.agentId = agentId;
}
/** agent_title
*agent_title
*/
private java.lang.String agentTitle;
@Column(name = "agent_title")
public java.lang.String getAgentTitle(){
return this.agentTitle;
}
public void setAgentTitle(java.lang.String agentTitle){
this.agentTitle = agentTitle;
}
/** agent_desc
*agent_desc
*/
private java.lang.String agentDesc;
@Column(name = "agent_desc")
public java.lang.String getAgentDesc(){
return this.agentDesc;
}
public void setAgentDesc(java.lang.String agentDesc){
this.agentDesc = agentDesc;
}
/** agent_avatar
*agent_avatar
*/
private java.lang.String agentAvatar;
@Column(name = "agent_avatar")
public java.lang.String getAgentAvatar(){
return this.agentAvatar;
}
public void setAgentAvatar(java.lang.String agentAvatar){
this.agentAvatar = agentAvatar;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.service;
import cn.com.poc.agent_application.query.MemberCollectQueryCondition;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.agent_application.entity.BizMemberAgentApplicationCollectEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.List;
public interface BizMemberAgentApplicationCollectService extends BaseService {
......@@ -11,12 +14,14 @@ public interface BizMemberAgentApplicationCollectService extends BaseService {
BizMemberAgentApplicationCollectEntity getByAgentId(java.lang.String agentId) throws Exception;
List<BizMemberAgentApplicationCollectEntity> findByExample(BizMemberAgentApplicationCollectEntity example,PagingInfo pagingInfo) throws Exception;
List<BizMemberAgentApplicationCollectEntity> findByExample(BizMemberAgentApplicationCollectEntity example, PagingInfo pagingInfo) throws Exception;
BizMemberAgentApplicationCollectEntity save(BizMemberAgentApplicationCollectEntity entity) throws Exception;
BizMemberAgentApplicationCollectEntity update(BizMemberAgentApplicationCollectEntity entity) throws Exception;
void deletedById(java.lang.Integer id) throws Exception;
List<MemberCollectQueryItem> queryMemberCollect(MemberCollectQueryCondition condition, PagingInfo pagingInfo) ;
}
\ No newline at end of file
package cn.com.poc.agent_application.service.impl;
package cn.com.poc.agent_application.service.impl;
import cn.com.poc.agent_application.query.MemberCollectQueryCondition;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService;
import cn.com.poc.agent_application.model.BizMemberAgentApplicationCollectModel;
......@@ -10,30 +12,32 @@ import cn.com.yict.framemax.data.model.PagingInfo;
import org.springframework.stereotype.Service;
import org.apache.commons.collections4.CollectionUtils;
import java.util.ArrayList;
import java.util.stream.Collectors;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.util.Assert;
@Service
public class BizMemberAgentApplicationCollectServiceImpl extends BaseServiceImpl
implements BizMemberAgentApplicationCollectService {
@Resource
private BizMemberAgentApplicationCollectRepository repository;
public BizMemberAgentApplicationCollectEntity get(java.lang.Integer id) throws Exception{
implements BizMemberAgentApplicationCollectService {
@Resource
private BizMemberAgentApplicationCollectRepository repository;
public BizMemberAgentApplicationCollectEntity get(java.lang.Integer id) throws Exception {
Assert.notNull(id);
BizMemberAgentApplicationCollectModel model = this.repository.get(id);
if (model == null){
BizMemberAgentApplicationCollectModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())){
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizMemberAgentApplicationCollectConvert.modelToEntity(model);
}
}
@Override
public BizMemberAgentApplicationCollectEntity getByAgentId(String agentId) throws Exception {
......@@ -41,66 +45,70 @@ public class BizMemberAgentApplicationCollectServiceImpl extends BaseServiceImpl
model.setAgentId(agentId);
model.setIsDeleted("N");
List<BizMemberAgentApplicationCollectModel> models = this.repository.findByExample(model);
if(!models.isEmpty()){
if (!models.isEmpty()) {
return BizMemberAgentApplicationCollectConvert.modelToEntity(models.get(0));
}
return null;
}
public List<BizMemberAgentApplicationCollectEntity> findByExample(BizMemberAgentApplicationCollectEntity example,PagingInfo pagingInfo) throws Exception{
List<BizMemberAgentApplicationCollectEntity> result = new ArrayList<BizMemberAgentApplicationCollectEntity>();
public List<BizMemberAgentApplicationCollectEntity> findByExample(BizMemberAgentApplicationCollectEntity example, PagingInfo pagingInfo) throws Exception {
List<BizMemberAgentApplicationCollectEntity> result = new ArrayList<BizMemberAgentApplicationCollectEntity>();
BizMemberAgentApplicationCollectModel model = new BizMemberAgentApplicationCollectModel();
if (example != null){
if (example != null) {
model = BizMemberAgentApplicationCollectConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizMemberAgentApplicationCollectModel> models = this.repository.findByExample(model,pagingInfo);
List<BizMemberAgentApplicationCollectModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizMemberAgentApplicationCollectConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizMemberAgentApplicationCollectEntity save(BizMemberAgentApplicationCollectEntity entity) throws Exception{
public BizMemberAgentApplicationCollectEntity save(BizMemberAgentApplicationCollectEntity entity) throws Exception {
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizMemberAgentApplicationCollectModel model = BizMemberAgentApplicationCollectConvert.entityToModel(entity);
BizMemberAgentApplicationCollectModel saveModel = this.repository.save(model);
BizMemberAgentApplicationCollectModel saveModel = this.repository.save(model);
return BizMemberAgentApplicationCollectConvert.modelToEntity(saveModel);
}
public BizMemberAgentApplicationCollectEntity update(BizMemberAgentApplicationCollectEntity entity) throws Exception{
public BizMemberAgentApplicationCollectEntity update(BizMemberAgentApplicationCollectEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(),"update pk can not be null");
Assert.notNull(entity.getId(), "update pk can not be null");
BizMemberAgentApplicationCollectModel model = this.repository.get(entity.getId());
if (entity.getMemberId() != null){
model.setMemberId(entity.getMemberId());
}
if (entity.getAgentId() != null){
model.setAgentId(entity.getAgentId());
}
if(entity.getIsCollect() != null){
model.setIsCollect(entity.getIsCollect());
}
if (entity.getIsDeleted() != null){
model.setIsDeleted(entity.getIsDeleted());
}
BizMemberAgentApplicationCollectModel saveModel = this.repository.save(model);
if (entity.getMemberId() != null) {
model.setMemberId(entity.getMemberId());
}
if (entity.getAgentId() != null) {
model.setAgentId(entity.getAgentId());
}
if (entity.getIsCollect() != null) {
model.setIsCollect(entity.getIsCollect());
}
if (entity.getIsDeleted() != null) {
model.setIsDeleted(entity.getIsDeleted());
}
BizMemberAgentApplicationCollectModel saveModel = this.repository.save(model);
return BizMemberAgentApplicationCollectConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Integer id) throws Exception{
public void deletedById(java.lang.Integer id) throws Exception {
Assert.notNull(id);
BizMemberAgentApplicationCollectModel model = this.repository.get(id);
if (model != null){
if ("N".equals(model.getIsDeleted())){
BizMemberAgentApplicationCollectModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
}
}
@Override
public List<MemberCollectQueryItem> queryMemberCollect(MemberCollectQueryCondition condition, PagingInfo pagingInfo) {
return this.sqlDao.query(condition, MemberCollectQueryItem.class, pagingInfo);
}
}
\ No newline at end of file
package cn.com.poc.expose.aggregate;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.yict.framemax.data.model.PagingInfo;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
......@@ -30,4 +33,9 @@ public interface AgentApplicationService {
*/
void createRecommendQuestion() throws InterruptedException;
/**
* 【首页】 获取用户已收藏的应用列表
*/
List<MemberCollectQueryItem> getCollectedApplications(Long memberId, PagingInfo pagingInfo);
}
......@@ -6,9 +6,12 @@ import cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants;
import cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
import cn.com.poc.agent_application.query.MemberCollectQueryCondition;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService;
import cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService;
import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext;
......@@ -25,6 +28,7 @@ import cn.com.poc.thirdparty.resource.demand.ai.entity.largemodel.LargeModelResp
import cn.com.poc.thirdparty.resource.demand.ai.function.LargeModelFunctionEnum;
import cn.com.poc.thirdparty.service.LLMService;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.com.yict.framemax.data.model.PagingInfo;
import com.fasterxml.jackson.core.type.TypeReference;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
......@@ -48,6 +52,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
final private String AGENT_APPLICATION_RECOMMEND_QUESTIONS = "AGENT_APPLICATION_RECOMMEND_QUESTIONS";
@Resource
private BizMemberAgentApplicationCollectService bizMemberAgentApplicationCollectService;
@Resource
private KnowledgeService knowledgeService;
......@@ -234,6 +242,15 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
redisService.lSet(AGENT_APPLICATION_RECOMMEND_QUESTIONS, questions);
}
@Override
public List<MemberCollectQueryItem> getCollectedApplications(Long memberId, PagingInfo pagingInfo) {
MemberCollectQueryCondition condition = new MemberCollectQueryCondition();
condition.setMemberId(memberId);
condition.setIsCollect(CommonConstant.YOrN.Y);
List<MemberCollectQueryItem> memberCollectQueryItems = bizMemberAgentApplicationCollectService.queryMemberCollect(condition, pagingInfo);
return memberCollectQueryItems;
}
private List<Message> buildMessages(String dialogsId, String agentId, Long userId, String input) throws Exception {
List<Message> messages = new ArrayList<>();
BizAgentApplicationDialoguesRecordEntity recordEntity = new BizAgentApplicationDialoguesRecordEntity();
......
package cn.com.poc.expose.dto;
import java.io.Serializable;
public class UserCollectDto implements Serializable {
/**
* 应用id
*/
private String agentId;
/**
* 应用名称
*/
private String agentTitle;
/**
* 应用描述
*/
private String agentDesc;
/**
* 应用头像
*/
private String agentAvatar;
public String getAgentId() {
return agentId;
}
public void setAgentId(String agentId) {
this.agentId = agentId;
}
public String getAgentTitle() {
return agentTitle;
}
public void setAgentTitle(String agentTitle) {
this.agentTitle = agentTitle;
}
public String getAgentDesc() {
return agentDesc;
}
public void setAgentDesc(String agentDesc) {
this.agentDesc = agentDesc;
}
public String getAgentAvatar() {
return agentAvatar;
}
public void setAgentAvatar(String agentAvatar) {
this.agentAvatar = agentAvatar;
}
}
......@@ -3,10 +3,7 @@ package cn.com.poc.expose.rest;
import cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto;
import cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto;
import cn.com.poc.expose.dto.AgentApplicationDto;
import cn.com.poc.expose.dto.DialoguesContextDto;
import cn.com.poc.expose.dto.SearchAgentApplicationDto;
import cn.com.poc.expose.dto.UserDialoguesDto;
import cn.com.poc.expose.dto.*;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.com.yict.framemax.web.permission.Access;
......@@ -25,6 +22,11 @@ public interface AgentApplicationRest extends BaseRest {
*/
List<String> getRecommendQuestions() throws Exception;
/**
* 【首页】获取用户已收藏应用
*/
List<UserCollectDto> getCollectedApplications(PagingInfo pagingInfo);
/**
* 创建对话
*/
......
......@@ -8,6 +8,7 @@ import cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto;
import cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto;
import cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
import cn.com.poc.agent_application.query.MemberCollectQueryItem;
import cn.com.poc.agent_application.query.MemberDialoguesQueryItem;
import cn.com.poc.agent_application.query.PublishAgentApplicationQueryCondition;
import cn.com.poc.agent_application.query.PublishAgentApplicationQueryItem;
......@@ -19,10 +20,7 @@ import cn.com.poc.common.utils.BlContext;
import cn.com.poc.common.utils.StringUtils;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.expose.dto.AgentApplicationDto;
import cn.com.poc.expose.dto.DialoguesContextDto;
import cn.com.poc.expose.dto.SearchAgentApplicationDto;
import cn.com.poc.expose.dto.UserDialoguesDto;
import cn.com.poc.expose.dto.*;
import cn.com.poc.expose.rest.AgentApplicationRest;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
......@@ -59,6 +57,28 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
return agentApplicationService.getRecommendQuestions();
}
@Override
public List<UserCollectDto> getCollectedApplications(PagingInfo pagingInfo) {
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (userBaseEntity == null) {
throw new BusinessException("用户未登录");
}
Long memberId = userBaseEntity.getUserId();
List<MemberCollectQueryItem> collectedApplications = agentApplicationService.getCollectedApplications(memberId, pagingInfo);
List<UserCollectDto> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(collectedApplications)) {
for (MemberCollectQueryItem item : collectedApplications) {
UserCollectDto collectDto = new UserCollectDto();
collectDto.setAgentId(item.getAgentId());
collectDto.setAgentTitle(item.getAgentTitle());
collectDto.setAgentDesc(item.getAgentDesc());
collectDto.setAgentAvatar(item.getAgentAvatar());
result.add(collectDto);
}
}
return result;
}
@Override
public String createDialogues() {
return "DIA_" + UUIDTool.getUUID();
......@@ -152,7 +172,7 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
result = memberDialoguesQueryItems.stream().map(item -> {
UserDialoguesDto userDialoguesDto = new UserDialoguesDto();
userDialoguesDto.setDialogsId(item.getDialogsId());
String content = item.getContent().length() > 20 ? item.getContent().substring(0, 20) : item.getContent();
String content = item.getContent().length() > 20 ? item.getContent().substring(0, 20) : item.getContent();
userDialoguesDto.setContent(content);
return userDialoguesDto;
}).collect(Collectors.toList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment