Commit cd9f9847 authored by alex yao's avatar alex yao

feat: Agent应用分类列表

parent 8a9b0f75
package cn.com.poc.agent_application.convert;
import cn.com.poc.agent_application.entity.BizAgentApplicationCategoryEntity;
import cn.com.poc.agent_application.model.BizAgentApplicationCategoryModel;
public class BizAgentApplicationCategoryConvert {
public static BizAgentApplicationCategoryEntity modelToEntity(BizAgentApplicationCategoryModel model) {
BizAgentApplicationCategoryEntity entity = new BizAgentApplicationCategoryEntity();
entity.setId(model.getId());
entity.setCategory(model.getCategory());
entity.setCategoryTw(model.getCategoryTw());
entity.setCategoryEn(model.getCategoryEn());
return entity;
}
public static BizAgentApplicationCategoryModel entityToModel(BizAgentApplicationCategoryEntity entity) {
BizAgentApplicationCategoryModel model = new BizAgentApplicationCategoryModel();
model.setId(entity.getId());
model.setCategory(entity.getCategory());
model.setCategoryTw(entity.getCategoryTw());
model.setCategoryEn(entity.getCategoryEn());
return model;
}
// public static BizAgentApplicationCategoryDto entityToDto(BizAgentApplicationCategoryEntity entity){
// BizAgentApplicationCategoryDto dto = new BizAgentApplicationCategoryDto();
// dto.setId(entity.getId());
// dto.setCategory(entity.getCategory());
// dto.setCategoryTw(entity.getCategoryTw());
// dto.setCategoryEn(entity.getCategoryEn());
// return dto;
// }
//
// public static BizAgentApplicationCategoryEntity dtoToEntity(BizAgentApplicationCategoryDto dto){
// BizAgentApplicationCategoryEntity entity = new BizAgentApplicationCategoryEntity();
// entity.setId(dto.getId());
// entity.setCategory(dto.getCategory());
// entity.setCategoryTw(dto.getCategoryTw());
// entity.setCategoryEn(dto.getCategoryEn());
// return entity;
// }
}
\ No newline at end of file
package cn.com.poc.agent_application.entity;
public class BizAgentApplicationCategoryEntity {
private static final long serialVersionUID = 1L;
/** id
*
*/
private java.lang.Integer id;
public java.lang.Integer getId(){
return this.id;
}
public void setId(java.lang.Integer id){
this.id = id;
}
/** category
*应用分类 【简体】
*/
private java.lang.String category;
public java.lang.String getCategory(){
return this.category;
}
public void setCategory(java.lang.String category){
this.category = category;
}
/** category_tw
*应用分类 【繁体】
*/
private java.lang.String categoryTw;
public java.lang.String getCategoryTw(){
return this.categoryTw;
}
public void setCategoryTw(java.lang.String categoryTw){
this.categoryTw = categoryTw;
}
/** category_en
*应用分类 【英文】
*/
private java.lang.String categoryEn;
public java.lang.String getCategoryEn(){
return this.categoryEn;
}
public void setCategoryEn(java.lang.String categoryEn){
this.categoryEn = categoryEn;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.model;
import java.io.Serializable;
import cn.com.yict.framemax.data.model.BaseModelClass;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Id;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
/**
* Model class for biz_agent_application_category
* Agent应用分类
*/
@Entity
@Table(name = "biz_agent_application_category")
@DynamicInsert
@DynamicUpdate
public class BizAgentApplicationCategoryModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/** id
*
*/
private java.lang.Integer id;
@Column(name = "id",length = 10)
@Id @GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Integer getId(){
return this.id;
}
public void setId(java.lang.Integer id){
this.id = id;
super.addValidField("id");
}
/** category
*应用分类 【简体】
*/
private java.lang.String category;
@Column(name = "category",length = 100)
public java.lang.String getCategory(){
return this.category;
}
public void setCategory(java.lang.String category){
this.category = category;
super.addValidField("category");
}
/** category_tw
*应用分类 【繁体】
*/
private java.lang.String categoryTw;
@Column(name = "category_tw",length = 100)
public java.lang.String getCategoryTw(){
return this.categoryTw;
}
public void setCategoryTw(java.lang.String categoryTw){
this.categoryTw = categoryTw;
super.addValidField("categoryTw");
}
/** category_en
*应用分类 【英文】
*/
private java.lang.String categoryEn;
@Column(name = "category_en",length = 100)
public java.lang.String getCategoryEn(){
return this.categoryEn;
}
public void setCategoryEn(java.lang.String categoryEn){
this.categoryEn = categoryEn;
super.addValidField("categoryEn");
}
}
\ No newline at end of file
package cn.com.poc.agent_application.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.agent_application.model.BizAgentApplicationCategoryModel;
public interface BizAgentApplicationCategoryRepository extends Repository<BizAgentApplicationCategoryModel,java.lang.Integer> {
}
\ No newline at end of file
...@@ -3,12 +3,16 @@ package cn.com.poc.agent_application.rest; ...@@ -3,12 +3,16 @@ package cn.com.poc.agent_application.rest;
import cn.com.yict.framemax.core.rest.BaseRest; import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.poc.agent_application.dto.BizAgentApplicationMallDto; import cn.com.poc.agent_application.dto.BizAgentApplicationMallDto;
import cn.com.yict.framemax.data.model.PagingInfo; import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.List; import java.util.List;
import cn.com.yict.framemax.web.permission.Access; import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission; import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletRequest;
@Permission(value = Access.Safety) @Permission(value = Access.Safety)
public interface BizAgentApplicationMallRest extends BaseRest { public interface BizAgentApplicationMallRest extends BaseRest {
...@@ -21,11 +25,11 @@ public interface BizAgentApplicationMallRest extends BaseRest { ...@@ -21,11 +25,11 @@ public interface BizAgentApplicationMallRest extends BaseRest {
BizAgentApplicationMallDto getById(@RequestParam java.lang.Integer id) throws Exception; BizAgentApplicationMallDto getById(@RequestParam java.lang.Integer id) throws Exception;
List<BizAgentApplicationMallDto> getListByExample(@RequestBody BizAgentApplicationMallDto example,PagingInfo pagingInfo) throws Exception; List<BizAgentApplicationMallDto> getListByExample(@RequestBody BizAgentApplicationMallDto example, PagingInfo pagingInfo) throws Exception;
/** /**
* 获取【应用广场】的应用列表 * 获取【应用广场】的应用列表
* */ */
List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception; List<BizAgentApplicationMallDto> getList(PagingInfo pagingInfo) throws Exception;
BizAgentApplicationMallDto update(@RequestBody BizAgentApplicationMallDto dto) throws Exception; BizAgentApplicationMallDto update(@RequestBody BizAgentApplicationMallDto dto) throws Exception;
...@@ -36,14 +40,20 @@ public interface BizAgentApplicationMallRest extends BaseRest { ...@@ -36,14 +40,20 @@ public interface BizAgentApplicationMallRest extends BaseRest {
* 收藏/取消收藏应用市场中的应用 * 收藏/取消收藏应用市场中的应用
* *
* @param id 应用广场中的id * @param id 应用广场中的id
* */ */
void collectOrCancelAgentInMall(@RequestParam Integer id) throws Exception; void collectOrCancelAgentInMall(@RequestParam Integer id) throws Exception;
/** /**
* 下架用户在应用市场中的应用 * 下架用户在应用市场中的应用
* *
* @param agentPublishId 发布应用表的id * @param agentPublishId 发布应用表的id
* */ */
void unSaleAgentInMall(@RequestParam Integer agentPublishId) throws Exception; void unSaleAgentInMall(@RequestParam Integer agentPublishId) throws Exception;
/**
* 获取应用广场分类列表
*/
List<String> getMallCategoryList(HttpServletRequest httpServletRequest) throws Exception;
} }
\ No newline at end of file
...@@ -3,13 +3,19 @@ package cn.com.poc.agent_application.rest.impl; ...@@ -3,13 +3,19 @@ package cn.com.poc.agent_application.rest.impl;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.annotation.Resource; import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import cn.com.poc.agent_application.aggregate.AgentApplicationMallService; import cn.com.poc.agent_application.aggregate.AgentApplicationMallService;
import cn.com.poc.agent_application.convert.BizAgentApplicationCategoryConvert;
import cn.com.poc.agent_application.entity.BizAgentApplicationCategoryEntity;
import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity; import cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity;
import cn.com.poc.agent_application.entity.BizMemberAgentApplicationCollectEntity; import cn.com.poc.agent_application.entity.BizMemberAgentApplicationCollectEntity;
import cn.com.poc.agent_application.service.BizAgentApplicationCategoryService;
import cn.com.poc.agent_application.service.BizAgentApplicationPublishService; import cn.com.poc.agent_application.service.BizAgentApplicationPublishService;
import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService; import cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService;
import cn.com.poc.common.constant.CommonConstant; import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.constant.XLangConstant;
import cn.com.poc.common.utils.StringUtils;
import cn.com.yict.framemax.core.exception.BusinessException; import cn.com.yict.framemax.core.exception.BusinessException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import cn.com.poc.agent_application.rest.BizAgentApplicationMallRest; import cn.com.poc.agent_application.rest.BizAgentApplicationMallRest;
...@@ -36,6 +42,9 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR ...@@ -36,6 +42,9 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
@Resource @Resource
private BizAgentApplicationMallService bizAgentApplicationMallService; private BizAgentApplicationMallService bizAgentApplicationMallService;
@Resource
private BizAgentApplicationCategoryService bizAgentApplicationCategoryService;
@Override @Override
public void publishAgentToMall(BizAgentApplicationMallDto dto) throws Exception { public void publishAgentToMall(BizAgentApplicationMallDto dto) throws Exception {
...@@ -130,4 +139,28 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR ...@@ -130,4 +139,28 @@ public class BizAgentApplicationMallRestImpl implements BizAgentApplicationMallR
mallEntity.setIsSale(CommonConstant.IsDeleted.N); mallEntity.setIsSale(CommonConstant.IsDeleted.N);
bizAgentApplicationMallService.update(mallEntity); bizAgentApplicationMallService.update(mallEntity);
} }
@Override
public List<String> getMallCategoryList(HttpServletRequest httpServletRequest) throws Exception {
List<String> result = new ArrayList<>();
String lang = httpServletRequest.getHeader("x-lang");
if (StringUtils.isEmpty(lang)) {
lang = XLangConstant.ZH_CN;
}
List<BizAgentApplicationCategoryEntity> bizAgentApplicationCategoryEntities = bizAgentApplicationCategoryService.findByExample(new BizAgentApplicationCategoryEntity(), null);
for (BizAgentApplicationCategoryEntity entity : bizAgentApplicationCategoryEntities) {
switch (lang) {
case XLangConstant.EN:
result.add(entity.getCategoryEn());
break;
case XLangConstant.ZH_CN:
result.add(entity.getCategory());
break;
case XLangConstant.ZH_TW:
result.add(entity.getCategoryTw());
break;
}
}
return result;
}
} }
\ No newline at end of file
package cn.com.poc.agent_application.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.agent_application.entity.BizAgentApplicationCategoryEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizAgentApplicationCategoryService extends BaseService {
BizAgentApplicationCategoryEntity get(java.lang.Integer id) throws Exception;
List<BizAgentApplicationCategoryEntity> findByExample(BizAgentApplicationCategoryEntity example,PagingInfo pagingInfo) throws Exception;
BizAgentApplicationCategoryEntity save(BizAgentApplicationCategoryEntity entity) throws Exception;
BizAgentApplicationCategoryEntity update(BizAgentApplicationCategoryEntity entity) throws Exception;
void deletedById(java.lang.Integer id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.agent_application.service.impl;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizAgentApplicationCategoryService;
import cn.com.poc.agent_application.model.BizAgentApplicationCategoryModel;
import cn.com.poc.agent_application.entity.BizAgentApplicationCategoryEntity;
import cn.com.poc.agent_application.convert.BizAgentApplicationCategoryConvert;
import cn.com.poc.agent_application.repository.BizAgentApplicationCategoryRepository;
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 BizAgentApplicationCategoryServiceImpl extends BaseServiceImpl
implements BizAgentApplicationCategoryService {
@Resource
private BizAgentApplicationCategoryRepository repository;
public BizAgentApplicationCategoryEntity get(java.lang.Integer id) throws Exception{
Assert.notNull(id);
BizAgentApplicationCategoryModel model = this.repository.get(id);
if (model == null){
return null;
}
return BizAgentApplicationCategoryConvert.modelToEntity(model);
}
public List<BizAgentApplicationCategoryEntity> findByExample(BizAgentApplicationCategoryEntity example,PagingInfo pagingInfo) throws Exception{
List<BizAgentApplicationCategoryEntity> result = new ArrayList<BizAgentApplicationCategoryEntity>();
BizAgentApplicationCategoryModel model = new BizAgentApplicationCategoryModel();
if (example != null){
model = BizAgentApplicationCategoryConvert.entityToModel(example);
}
List<BizAgentApplicationCategoryModel> models = this.repository.findByExample(model,pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizAgentApplicationCategoryConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizAgentApplicationCategoryEntity save(BizAgentApplicationCategoryEntity entity) throws Exception{
Assert.notNull(entity);
entity.setId(null);
BizAgentApplicationCategoryModel model = BizAgentApplicationCategoryConvert.entityToModel(entity);
BizAgentApplicationCategoryModel saveModel = this.repository.save(model);
return BizAgentApplicationCategoryConvert.modelToEntity(saveModel);
}
public BizAgentApplicationCategoryEntity update(BizAgentApplicationCategoryEntity entity) throws Exception{
Assert.notNull(entity);
Assert.notNull(entity.getId(),"update pk can not be null");
BizAgentApplicationCategoryModel model = this.repository.get(entity.getId());
if (entity.getCategory() != null){
model.setCategory(entity.getCategory());
}
if (entity.getCategoryTw() != null){
model.setCategoryTw(entity.getCategoryTw());
}
if (entity.getCategoryEn() != null){
model.setCategoryEn(entity.getCategoryEn());
}
BizAgentApplicationCategoryModel saveModel = this.repository.save(model);
return BizAgentApplicationCategoryConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Integer id) throws Exception{
Assert.notNull(id);
BizAgentApplicationCategoryModel model = this.repository.get(id);
if (model != null){
}
}
}
\ No newline at end of file
package cn.com.poc.common.constant;
/**
* I18N常量
*/
public interface XLangConstant {
String ZH_CN = "zh_cn";
String ZH_TW = "zh_tw";
String EN = "en";
}
...@@ -3,8 +3,11 @@ package cn.com.poc; ...@@ -3,8 +3,11 @@ package cn.com.poc;
import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService; import cn.com.poc.agent_application.aggregate.AgentApplicationInfoService;
import cn.com.poc.common.service.RedisService; import cn.com.poc.common.service.RedisService;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.expose.aggregate.AgentApplicationService; import cn.com.poc.expose.aggregate.AgentApplicationService;
import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService; import cn.com.poc.thirdparty.resource.demand.ai.aggregate.DemandKnowledgeService;
import cn.com.poc.thirdparty.resource.demand.ai.function.long_memory.SetLongMemoryConstants;
import cn.com.poc.thirdparty.resource.demand.ai.function.value_memory.SetValueMemoryConstants;
import cn.com.yict.framemax.core.spring.SingleContextInitializer; import cn.com.yict.framemax.core.spring.SingleContextInitializer;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import org.apache.commons.collections4.ListUtils; import org.apache.commons.collections4.ListUtils;
...@@ -35,12 +38,19 @@ public class AgentApplicationInfoTest { ...@@ -35,12 +38,19 @@ public class AgentApplicationInfoTest {
@Resource @Resource
private RedisService redisService; private RedisService redisService;
@Test
public void del(){
String contentKey = SetValueMemoryConstants.REDIS_PREFIX ;
redisService.del(contentKey);
}
/** /**
* Agent 应用标题,描述生成 * Agent Ӧ�ñ��⣬��������
*/ */
@Test @Test
public void createAgentTitleAndDesc() { public void createAgentTitleAndDesc() {
String input = "测试标题"; String input = "���Ա���";
System.out.println(applicationInfoService.createAgentTitleAndDesc(input)); System.out.println(applicationInfoService.createAgentTitleAndDesc(input));
} }
......
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