Commit c7f012b9 authored by alex yao's avatar alex yao

feat:Agent应用插件接口

parent 099a81f3
package cn.com.poc.agent_application.convert;
import cn.com.poc.agent_application.dto.AgentApplicationPluginDto;
import cn.com.poc.agent_application.model.BizAgentApplicationPluginModel;
import cn.com.poc.agent_application.entity.BizAgentApplicationPluginEntity;
import java.util.*;
import static cn.com.poc.common.constant.XLangConstant.*;
public class BizAgentApplicationPluginConvert {
public static BizAgentApplicationPluginEntity modelToEntity(BizAgentApplicationPluginModel model) {
BizAgentApplicationPluginEntity entity = new BizAgentApplicationPluginEntity();
entity.setId(model.getId());
entity.setIcon(model.getIcon());
entity.setPoints(model.getPoints());
entity.setClassification(model.getClassification());
entity.setPluginId(model.getPluginId());
entity.setParentZhCnName(model.getParentZhCnName());
entity.setParentZhTwName(model.getParentZhTwName());
entity.setParentEnName(model.getParentEnName());
entity.setZhCnTitle(model.getZhCnTitle());
entity.setZhTwTitle(model.getZhTwTitle());
entity.setEnTitle(model.getEnTitle());
entity.setZhCnDesc(model.getZhCnDesc());
entity.setZhTwDesc(model.getZhTwDesc());
entity.setEnDesc(model.getEnDesc());
entity.setIsDeleted(model.getIsDeleted());
entity.setCreator(model.getCreator());
entity.setCreatedTime(model.getCreatedTime());
entity.setModifier(model.getModifier());
entity.setModifiedTime(model.getModifiedTime());
entity.setSysVersion(model.getSysVersion());
return entity;
}
public static BizAgentApplicationPluginModel entityToModel(BizAgentApplicationPluginEntity entity) {
BizAgentApplicationPluginModel model = new BizAgentApplicationPluginModel();
model.setId(entity.getId());
model.setIcon(entity.getIcon());
model.setPoints(entity.getPoints());
model.setClassification(entity.getClassification());
model.setPluginId(entity.getPluginId());
model.setParentZhCnName(entity.getParentZhCnName());
model.setParentZhTwName(entity.getParentZhTwName());
model.setParentEnName(entity.getParentEnName());
model.setZhCnTitle(entity.getZhCnTitle());
model.setZhTwTitle(entity.getZhTwTitle());
model.setEnTitle(entity.getEnTitle());
model.setZhCnDesc(entity.getZhCnDesc());
model.setZhTwDesc(entity.getZhTwDesc());
model.setEnDesc(entity.getEnDesc());
model.setIsDeleted(entity.getIsDeleted());
model.setCreator(entity.getCreator());
model.setCreatedTime(entity.getCreatedTime());
model.setModifier(entity.getModifier());
model.setModifiedTime(entity.getModifiedTime());
model.setSysVersion(entity.getSysVersion());
return model;
}
public static List<AgentApplicationPluginDto> entitiesToDtos(List<BizAgentApplicationPluginEntity> entities, String lang) {
List<AgentApplicationPluginDto> result = new ArrayList<>();
Map<String, List<AgentApplicationPluginDto.PluginInfo>> pluginInfoMap = new HashMap<>();
for (BizAgentApplicationPluginEntity entity : entities) {
String title = "";
String desc = "";
String parentClassificationName = "";
switch (lang) {
case ZH_CN:
title = entity.getZhCnTitle();
desc = entity.getZhCnDesc();
parentClassificationName = entity.getParentZhCnName();
break;
case EN:
title = entity.getEnTitle();
desc = entity.getEnDesc();
parentClassificationName = entity.getParentEnName();
break;
case ZH_TW:
title = entity.getZhTwTitle();
desc = entity.getZhTwDesc();
parentClassificationName = entity.getParentZhTwName();
break;
}
AgentApplicationPluginDto.PluginInfo pluginInfo = new AgentApplicationPluginDto.PluginInfo();
pluginInfo.setPoints(entity.getPoints());
pluginInfo.setIcon(entity.getIcon());
pluginInfo.setTitle(title);
pluginInfo.setDescription(desc);
pluginInfo.setPluginId(entity.getPluginId());
if (!pluginInfoMap.containsKey(parentClassificationName)) {
pluginInfoMap.put(parentClassificationName, new ArrayList<>());
}
pluginInfoMap.get(parentClassificationName).add(pluginInfo);
}
Set<String> keySet = pluginInfoMap.keySet();
for (String parentClassificationName : keySet) {
AgentApplicationPluginDto agentApplicationPluginDto = new AgentApplicationPluginDto();
agentApplicationPluginDto.setClassificationName(parentClassificationName);
agentApplicationPluginDto.setPluginInfos(pluginInfoMap.get(parentClassificationName));
result.add(agentApplicationPluginDto);
}
return result;
}
public static AgentApplicationPluginDto entityToDto(BizAgentApplicationPluginEntity entity, String lang) {
Map<String, List<AgentApplicationPluginDto.PluginInfo>> pluginInfoMap = new HashMap<>();
String title = "";
String desc = "";
String parentClassificationName = "";
switch (lang) {
case ZH_CN:
title = entity.getZhCnTitle();
desc = entity.getZhCnDesc();
parentClassificationName = entity.getParentZhCnName();
break;
case EN:
title = entity.getEnTitle();
desc = entity.getEnDesc();
parentClassificationName = entity.getParentEnName();
break;
case ZH_TW:
title = entity.getZhTwTitle();
desc = entity.getZhTwDesc();
parentClassificationName = entity.getParentZhTwName();
break;
}
AgentApplicationPluginDto.PluginInfo pluginInfo = new AgentApplicationPluginDto.PluginInfo();
pluginInfo.setPoints(entity.getPoints());
pluginInfo.setIcon(entity.getIcon());
pluginInfo.setTitle(title);
pluginInfo.setDescription(desc);
pluginInfo.setPluginId(entity.getPluginId());
if (!pluginInfoMap.containsKey(parentClassificationName)) {
pluginInfoMap.put(parentClassificationName, new ArrayList<>());
}
pluginInfoMap.get(parentClassificationName).add(pluginInfo);
AgentApplicationPluginDto agentApplicationPluginDto = new AgentApplicationPluginDto();
agentApplicationPluginDto.setClassificationName(parentClassificationName);
agentApplicationPluginDto.setPluginInfos(pluginInfoMap.get(parentClassificationName));
return agentApplicationPluginDto;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.dto;
import java.util.List;
/**
* @author alex.yao
* @date 2025/1/13
*/
public class AgentApplicationPluginDto {
private List<PluginInfo> pluginInfos;
private String classificationName;
public List<PluginInfo> getPluginInfos() {
return pluginInfos;
}
public void setPluginInfos(List<PluginInfo> pluginInfos) {
this.pluginInfos = pluginInfos;
}
public String getClassificationName() {
return classificationName;
}
public void setClassificationName(String classificationName) {
this.classificationName = classificationName;
}
public static class PluginInfo {
private Double points;
private String pluginId;
private String title;
private String description;
private String icon;
public Double getPoints() {
return points;
}
public void setPoints(Double points) {
this.points = points;
}
public String getIcon() {
return icon;
}
public void setIcon(String icon) {
this.icon = icon;
}
public String getPluginId() {
return pluginId;
}
public void setPluginId(String pluginId) {
this.pluginId = pluginId;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
}
}
package cn.com.poc.agent_application.dto;
public class BizAgentApplicationPluginDto {
private static final long serialVersionUID = 1L;
/** id
*
*/
private java.lang.Long id;
public java.lang.Long getId(){
return this.id;
}
public void setId(java.lang.Long id){
this.id = id;
}
/** classification
*插件类型
*/
private java.lang.String classification;
public java.lang.String getClassification(){
return this.classification;
}
public void setClassification(java.lang.String classification){
this.classification = classification;
}
/** plugin_id
*插件主键
*/
private java.lang.String pluginId;
public java.lang.String getPluginId(){
return this.pluginId;
}
public void setPluginId(java.lang.String pluginId){
this.pluginId = pluginId;
}
/** zh_cn_title
*插件标题(简体)
*/
private java.lang.String zhCnTitle;
public java.lang.String getZhCnTitle(){
return this.zhCnTitle;
}
public void setZhCnTitle(java.lang.String zhCnTitle){
this.zhCnTitle = zhCnTitle;
}
/** zh_tw_title
*繁体
*/
private java.lang.String zhTwTitle;
public java.lang.String getZhTwTitle(){
return this.zhTwTitle;
}
public void setZhTwTitle(java.lang.String zhTwTitle){
this.zhTwTitle = zhTwTitle;
}
/** en_title
*英文
*/
private java.lang.String enTitle;
public java.lang.String getEnTitle(){
return this.enTitle;
}
public void setEnTitle(java.lang.String enTitle){
this.enTitle = enTitle;
}
/** zh_cn_desc
*插件描述(简体)
*/
private java.lang.String zhCnDesc;
public java.lang.String getZhCnDesc(){
return this.zhCnDesc;
}
public void setZhCnDesc(java.lang.String zhCnDesc){
this.zhCnDesc = zhCnDesc;
}
/** zh_tw_desc
*插件描述(繁体)
*/
private java.lang.String zhTwDesc;
public java.lang.String getZhTwDesc(){
return this.zhTwDesc;
}
public void setZhTwDesc(java.lang.String zhTwDesc){
this.zhTwDesc = zhTwDesc;
}
/** en_desc
*插件描述(英文)
*/
private java.lang.String enDesc;
public java.lang.String getEnDesc(){
return this.enDesc;
}
public void setEnDesc(java.lang.String enDesc){
this.enDesc = enDesc;
}
/** is_deleted
*是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted(){
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted){
this.isDeleted = isDeleted;
}
/** CREATOR
*创建人
*/
private java.lang.String creator;
public java.lang.String getCreator(){
return this.creator;
}
public void setCreator(java.lang.String creator){
this.creator = creator;
}
/** CREATED_TIME
*创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime(){
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime){
this.createdTime = createdTime;
}
/** MODIFIER
*修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier(){
return this.modifier;
}
public void setModifier(java.lang.String modifier){
this.modifier = modifier;
}
/** MODIFIED_TIME
*修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime(){
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime){
this.modifiedTime = modifiedTime;
}
/** SYS_VERSION
*乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion(){
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion){
this.sysVersion = sysVersion;
}
}
\ No newline at end of file
package cn.com.poc.agent_application.entity;
public class BizAgentApplicationPluginEntity {
private static final long serialVersionUID = 1L;
/**
* id
*/
private java.lang.Long id;
public java.lang.Long getId() {
return this.id;
}
public void setId(java.lang.Long id) {
this.id = id;
}
/**
* points
*/
private Double points;
public Double getPoints() {
return points;
}
public void setPoints(Double points) {
this.points = points;
}
/**
* classification
* 插件类型
*/
private java.lang.String classification;
public java.lang.String getClassification() {
return this.classification;
}
public void setClassification(java.lang.String classification) {
this.classification = classification;
}
/**
* icon
*/
private java.lang.String icon;
public java.lang.String getIcon() {
return this.icon;
}
public void setIcon(java.lang.String icon) {
this.icon = icon;
}
/**
* parent_zh_cn_name
* 分类名(简体)
*/
private java.lang.String parentZhCnName;
public java.lang.String getParentZhCnName() {
return this.parentZhCnName;
}
public void setParentZhCnName(java.lang.String parentZhCnName) {
this.parentZhCnName = parentZhCnName;
}
/**
* parent_zh_tw_name
* 分类名(繁体)
*/
private java.lang.String parentZhTwName;
public java.lang.String getParentZhTwName() {
return this.parentZhTwName;
}
public void setParentZhTwName(java.lang.String parentZhTwName) {
this.parentZhTwName = parentZhTwName;
}
/**
* parent_en_name
* 分类名(英文)
*/
private java.lang.String parentEnName;
public java.lang.String getParentEnName() {
return this.parentEnName;
}
public void setParentEnName(java.lang.String parentEnName) {
this.parentEnName = parentEnName;
}
/**
* plugin_id
* 插件主键
*/
private java.lang.String pluginId;
public java.lang.String getPluginId() {
return this.pluginId;
}
public void setPluginId(java.lang.String pluginId) {
this.pluginId = pluginId;
}
/**
* zh_cn_title
* 插件标题(简体)
*/
private java.lang.String zhCnTitle;
public java.lang.String getZhCnTitle() {
return this.zhCnTitle;
}
public void setZhCnTitle(java.lang.String zhCnTitle) {
this.zhCnTitle = zhCnTitle;
}
/**
* zh_tw_title
* 繁体
*/
private java.lang.String zhTwTitle;
public java.lang.String getZhTwTitle() {
return this.zhTwTitle;
}
public void setZhTwTitle(java.lang.String zhTwTitle) {
this.zhTwTitle = zhTwTitle;
}
/**
* en_title
* 英文
*/
private java.lang.String enTitle;
public java.lang.String getEnTitle() {
return this.enTitle;
}
public void setEnTitle(java.lang.String enTitle) {
this.enTitle = enTitle;
}
/**
* zh_cn_desc
* 插件描述(简体)
*/
private java.lang.String zhCnDesc;
public java.lang.String getZhCnDesc() {
return this.zhCnDesc;
}
public void setZhCnDesc(java.lang.String zhCnDesc) {
this.zhCnDesc = zhCnDesc;
}
/**
* zh_tw_desc
* 插件描述(繁体)
*/
private java.lang.String zhTwDesc;
public java.lang.String getZhTwDesc() {
return this.zhTwDesc;
}
public void setZhTwDesc(java.lang.String zhTwDesc) {
this.zhTwDesc = zhTwDesc;
}
/**
* en_desc
* 插件描述(英文)
*/
private java.lang.String enDesc;
public java.lang.String getEnDesc() {
return this.enDesc;
}
public void setEnDesc(java.lang.String enDesc) {
this.enDesc = enDesc;
}
/**
* is_deleted
* 是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
public java.lang.String getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted) {
this.isDeleted = isDeleted;
}
/**
* CREATOR
* 创建人
*/
private java.lang.String creator;
public java.lang.String getCreator() {
return this.creator;
}
public void setCreator(java.lang.String creator) {
this.creator = creator;
}
/**
* CREATED_TIME
* 创建时间
*/
private java.util.Date createdTime;
public java.util.Date getCreatedTime() {
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime) {
this.createdTime = createdTime;
}
/**
* MODIFIER
* 修改人
*/
private java.lang.String modifier;
public java.lang.String getModifier() {
return this.modifier;
}
public void setModifier(java.lang.String modifier) {
this.modifier = modifier;
}
/**
* MODIFIED_TIME
* 修改时间
*/
private java.util.Date modifiedTime;
public java.util.Date getModifiedTime() {
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime) {
this.modifiedTime = modifiedTime;
}
/**
* SYS_VERSION
* 乐观锁,版本号
*/
private java.lang.Integer sysVersion;
public java.lang.Integer getSysVersion() {
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion) {
this.sysVersion = sysVersion;
}
}
\ 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.Version;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
/**
* Model class for biz_agent_application_plugin
* 插件信息
*/
@Entity
@Table(name = "biz_agent_application_plugin")
@DynamicInsert
@DynamicUpdate
public class BizAgentApplicationPluginModel extends BaseModelClass implements Serializable {
private static final long serialVersionUID = 1L;
/**
* id
*/
private java.lang.Long id;
@Column(name = "id", length = 19)
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
public java.lang.Long getId() {
return this.id;
}
public void setId(java.lang.Long id) {
this.id = id;
super.addValidField("id");
}
private Double points;
@Column(name = "points", length = 10)
public Double getPoints() {
return points;
}
public void setPoints(Double points) {
this.points = points;
super.addValidField("points");
}
/**
* classification
* 插件类型
*/
private java.lang.String classification;
@Column(name = "classification", length = 100)
public java.lang.String getClassification() {
return this.classification;
}
public void setClassification(java.lang.String classification) {
this.classification = classification;
super.addValidField("classification");
}
/**
* icon
*/
private java.lang.String icon;
@Column(name = "icon", length = 120)
public java.lang.String getIcon() {
return this.icon;
}
public void setIcon(java.lang.String icon) {
this.icon = icon;
super.addValidField("icon");
}
/**
* parent_zh_cn_name
* 分类名(简体)
*/
private java.lang.String parentZhCnName;
@Column(name = "parent_zh_cn_name", length = 100)
public java.lang.String getParentZhCnName() {
return this.parentZhCnName;
}
public void setParentZhCnName(java.lang.String parentZhCnName) {
this.parentZhCnName = parentZhCnName;
super.addValidField("parentZhCnName");
}
/**
* parent_zh_tw_name
* 分类名(繁体)
*/
private java.lang.String parentZhTwName;
@Column(name = "parent_zh_tw_name", length = 100)
public java.lang.String getParentZhTwName() {
return this.parentZhTwName;
}
public void setParentZhTwName(java.lang.String parentZhTwName) {
this.parentZhTwName = parentZhTwName;
super.addValidField("parentZhTwName");
}
/**
* parent_en_name
* 分类名(英文)
*/
private java.lang.String parentEnName;
@Column(name = "parent_en_name", length = 100)
public java.lang.String getParentEnName() {
return this.parentEnName;
}
public void setParentEnName(java.lang.String parentEnName) {
this.parentEnName = parentEnName;
super.addValidField("parentEnName");
}
/**
* plugin_id
* 插件主键
*/
private java.lang.String pluginId;
@Column(name = "plugin_id", length = 100)
public java.lang.String getPluginId() {
return this.pluginId;
}
public void setPluginId(java.lang.String pluginId) {
this.pluginId = pluginId;
super.addValidField("pluginId");
}
/**
* zh_cn_title
* 插件标题(简体)
*/
private java.lang.String zhCnTitle;
@Column(name = "zh_cn_title", length = 100)
public java.lang.String getZhCnTitle() {
return this.zhCnTitle;
}
public void setZhCnTitle(java.lang.String zhCnTitle) {
this.zhCnTitle = zhCnTitle;
super.addValidField("zhCnTitle");
}
/**
* zh_tw_title
* 繁体
*/
private java.lang.String zhTwTitle;
@Column(name = "zh_tw_title", length = 100)
public java.lang.String getZhTwTitle() {
return this.zhTwTitle;
}
public void setZhTwTitle(java.lang.String zhTwTitle) {
this.zhTwTitle = zhTwTitle;
super.addValidField("zhTwTitle");
}
/**
* en_title
* 英文
*/
private java.lang.String enTitle;
@Column(name = "en_title", length = 100)
public java.lang.String getEnTitle() {
return this.enTitle;
}
public void setEnTitle(java.lang.String enTitle) {
this.enTitle = enTitle;
super.addValidField("enTitle");
}
/**
* zh_cn_desc
* 插件描述(简体)
*/
private java.lang.String zhCnDesc;
@Column(name = "zh_cn_desc", length = 2147483647)
public java.lang.String getZhCnDesc() {
return this.zhCnDesc;
}
public void setZhCnDesc(java.lang.String zhCnDesc) {
this.zhCnDesc = zhCnDesc;
super.addValidField("zhCnDesc");
}
/**
* zh_tw_desc
* 插件描述(繁体)
*/
private java.lang.String zhTwDesc;
@Column(name = "zh_tw_desc", length = 2147483647)
public java.lang.String getZhTwDesc() {
return this.zhTwDesc;
}
public void setZhTwDesc(java.lang.String zhTwDesc) {
this.zhTwDesc = zhTwDesc;
super.addValidField("zhTwDesc");
}
/**
* en_desc
* 插件描述(英文)
*/
private java.lang.String enDesc;
@Column(name = "en_desc", length = 2147483647)
public java.lang.String getEnDesc() {
return this.enDesc;
}
public void setEnDesc(java.lang.String enDesc) {
this.enDesc = enDesc;
super.addValidField("enDesc");
}
/**
* is_deleted
* 是否删除 1、Y 是 2、N 否
*/
private java.lang.String isDeleted;
@Column(name = "is_deleted", length = 1)
public java.lang.String getIsDeleted() {
return this.isDeleted;
}
public void setIsDeleted(java.lang.String isDeleted) {
this.isDeleted = isDeleted;
super.addValidField("isDeleted");
}
/**
* CREATOR
* 创建人
*/
private java.lang.String creator;
@Column(name = "CREATOR", length = 225)
public java.lang.String getCreator() {
return this.creator;
}
public void setCreator(java.lang.String creator) {
this.creator = creator;
super.addValidField("creator");
}
/**
* CREATED_TIME
* 创建时间
*/
private java.util.Date createdTime;
@Column(name = "CREATED_TIME", length = 19)
public java.util.Date getCreatedTime() {
return this.createdTime;
}
public void setCreatedTime(java.util.Date createdTime) {
this.createdTime = createdTime;
super.addValidField("createdTime");
}
/**
* MODIFIER
* 修改人
*/
private java.lang.String modifier;
@Column(name = "MODIFIER", length = 225)
public java.lang.String getModifier() {
return this.modifier;
}
public void setModifier(java.lang.String modifier) {
this.modifier = modifier;
super.addValidField("modifier");
}
/**
* MODIFIED_TIME
* 修改时间
*/
private java.util.Date modifiedTime;
@Column(name = "MODIFIED_TIME", length = 19)
public java.util.Date getModifiedTime() {
return this.modifiedTime;
}
public void setModifiedTime(java.util.Date modifiedTime) {
this.modifiedTime = modifiedTime;
super.addValidField("modifiedTime");
}
/**
* SYS_VERSION
* 乐观锁,版本号
*/
private java.lang.Integer sysVersion;
@Column(name = "SYS_VERSION", length = 10)
@Version
public java.lang.Integer getSysVersion() {
return this.sysVersion;
}
public void setSysVersion(java.lang.Integer sysVersion) {
this.sysVersion = sysVersion;
super.addValidField("sysVersion");
}
}
\ 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.BizAgentApplicationPluginModel;
public interface BizAgentApplicationPluginRepository extends Repository<BizAgentApplicationPluginModel,java.lang.Long> {
}
\ No newline at end of file
package cn.com.poc.agent_application.rest;
import cn.com.poc.agent_application.dto.AgentApplicationPluginDto;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.poc.agent_application.dto.BizAgentApplicationPluginDto;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
@Permission(Access.Safety)
public interface BizAgentApplicationPluginRest extends BaseRest {
/**
* 获取插件详情
*
* @param pluginId
* @return
* @throws Exception
*/
AgentApplicationPluginDto getByPluginId(@RequestParam String pluginId) throws Exception;
/**
* 获取插件列表
*
* @param classificationName
* @param pagingInfo
* @return
* @throws Exception
*/
List<AgentApplicationPluginDto> getList(@RequestParam(required = false) String classificationName, PagingInfo pagingInfo) throws Exception;
/**
* 插件分类列表
*/
List<String> classificationList() throws Exception;
}
\ No newline at end of file
package cn.com.poc.agent_application.rest.impl;
import cn.com.poc.agent_application.convert.BizAgentApplicationPluginConvert;
import cn.com.poc.agent_application.dto.AgentApplicationPluginDto;
import cn.com.poc.agent_application.entity.BizAgentApplicationPluginEntity;
import cn.com.poc.agent_application.rest.BizAgentApplicationPluginRest;
import cn.com.poc.agent_application.service.BizAgentApplicationPluginService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.yict.framemax.core.context.Context;
import cn.com.yict.framemax.core.i18n.I18nMessageException;
import cn.com.yict.framemax.data.model.PagingInfo;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;
@Component
public class BizAgentApplicationPluginRestImpl implements BizAgentApplicationPluginRest {
@Resource
private BizAgentApplicationPluginService bizAgentApplicationPluginService;
@Override
public AgentApplicationPluginDto getByPluginId(String pluginId) throws Exception {
Locale currentLocale = Context.get().getMessageSource().getCurrentLocale();
BizAgentApplicationPluginEntity bizAgentApplicationPluginEntity = new BizAgentApplicationPluginEntity();
bizAgentApplicationPluginEntity.setPluginId(pluginId);
BizAgentApplicationPluginEntity entity = bizAgentApplicationPluginService.getInfoById(pluginId);
if (ObjectUtil.isEmpty(entity)) {
//todo
throw new I18nMessageException("");
}
return BizAgentApplicationPluginConvert.entityToDto(entity, currentLocale.toLanguageTag().toLowerCase());
}
@Override
public List<AgentApplicationPluginDto> getList(String classificationName, PagingInfo pagingInfo) throws Exception {
Locale currentLocale = Context.get().getMessageSource().getCurrentLocale();
BizAgentApplicationPluginEntity bizAgentApplicationPluginEntity = new BizAgentApplicationPluginEntity();
bizAgentApplicationPluginEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationPluginEntity> entities = bizAgentApplicationPluginService.findByExample(bizAgentApplicationPluginEntity, pagingInfo);
return BizAgentApplicationPluginConvert.entitiesToDtos(entities.stream().filter(entity -> !"system".equals(entity.getClassification())).collect(Collectors.toList()), currentLocale.toLanguageTag().toLowerCase());
}
@Override
public List<String> classificationList() throws Exception {
return null;
}
}
\ 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.BizAgentApplicationPluginEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizAgentApplicationPluginService extends BaseService {
BizAgentApplicationPluginEntity get(java.lang.Long id) throws Exception;
List<BizAgentApplicationPluginEntity> findByExample(BizAgentApplicationPluginEntity example, PagingInfo pagingInfo) throws Exception;
BizAgentApplicationPluginEntity save(BizAgentApplicationPluginEntity entity) throws Exception;
BizAgentApplicationPluginEntity update(BizAgentApplicationPluginEntity entity) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
BizAgentApplicationPluginEntity getInfoById(java.lang.String pluginId);
}
\ No newline at end of file
package cn.com.poc.agent_application.service.impl;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.agent_application.service.BizAgentApplicationPluginService;
import cn.com.poc.agent_application.model.BizAgentApplicationPluginModel;
import cn.com.poc.agent_application.entity.BizAgentApplicationPluginEntity;
import cn.com.poc.agent_application.convert.BizAgentApplicationPluginConvert;
import cn.com.poc.agent_application.repository.BizAgentApplicationPluginRepository;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.apache.hadoop.fs.shell.Command;
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 BizAgentApplicationPluginServiceImpl extends BaseServiceImpl
implements BizAgentApplicationPluginService {
@Resource
private BizAgentApplicationPluginRepository repository;
public BizAgentApplicationPluginEntity get(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizAgentApplicationPluginModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizAgentApplicationPluginConvert.modelToEntity(model);
}
public List<BizAgentApplicationPluginEntity> findByExample(BizAgentApplicationPluginEntity example, PagingInfo pagingInfo) throws Exception {
List<BizAgentApplicationPluginEntity> result = new ArrayList<BizAgentApplicationPluginEntity>();
BizAgentApplicationPluginModel model = new BizAgentApplicationPluginModel();
if (example != null) {
model = BizAgentApplicationPluginConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizAgentApplicationPluginModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizAgentApplicationPluginConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizAgentApplicationPluginEntity save(BizAgentApplicationPluginEntity entity) throws Exception {
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizAgentApplicationPluginModel model = BizAgentApplicationPluginConvert.entityToModel(entity);
BizAgentApplicationPluginModel saveModel = this.repository.save(model);
return BizAgentApplicationPluginConvert.modelToEntity(saveModel);
}
public BizAgentApplicationPluginEntity update(BizAgentApplicationPluginEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
BizAgentApplicationPluginModel model = this.repository.get(entity.getId());
if (entity.getClassification() != null) {
model.setClassification(entity.getClassification());
}
if (entity.getPluginId() != null) {
model.setPluginId(entity.getPluginId());
}
if (entity.getZhCnTitle() != null) {
model.setZhCnTitle(entity.getZhCnTitle());
}
if (entity.getZhTwTitle() != null) {
model.setZhTwTitle(entity.getZhTwTitle());
}
if (entity.getEnTitle() != null) {
model.setEnTitle(entity.getEnTitle());
}
if (entity.getZhCnDesc() != null) {
model.setZhCnDesc(entity.getZhCnDesc());
}
if (entity.getZhTwDesc() != null) {
model.setZhTwDesc(entity.getZhTwDesc());
}
if (entity.getEnDesc() != null) {
model.setEnDesc(entity.getEnDesc());
}
if (entity.getIsDeleted() != null) {
model.setIsDeleted(entity.getIsDeleted());
}
if (entity.getCreator() != null) {
model.setCreator(entity.getCreator());
}
if (entity.getCreatedTime() != null) {
model.setCreatedTime(entity.getCreatedTime());
}
if (entity.getModifier() != null) {
model.setModifier(entity.getModifier());
}
if (entity.getModifiedTime() != null) {
model.setModifiedTime(entity.getModifiedTime());
}
if (entity.getSysVersion() != null) {
model.setSysVersion(entity.getSysVersion());
}
BizAgentApplicationPluginModel saveModel = this.repository.save(model);
return BizAgentApplicationPluginConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizAgentApplicationPluginModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
@Override
public BizAgentApplicationPluginEntity getInfoById(String pluginId) {
BizAgentApplicationPluginModel model = new BizAgentApplicationPluginModel();
model.setPluginId(pluginId);
model.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAgentApplicationPluginModel> models = this.repository.findByExample(model, null);
if (CollectionUtils.isNotEmpty(models)) {
return BizAgentApplicationPluginConvert.modelToEntity(models.get(0));
}
return null;
}
}
\ No newline at end of file
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