Commit 760d93f7 authored by alex yao's avatar alex yao

feat:门户页接口 + 通用对话列表接口

parent 6c72fa18
...@@ -1057,7 +1057,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService { ...@@ -1057,7 +1057,7 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
private String modelConvert(String largeModel) { private String modelConvert(String largeModel) {
BizAgentApplicationLargeModelListEntity largeModelEntity = bizAgentApplicationLargeModelListService.findByModelNickName(largeModel); BizAgentApplicationLargeModelListEntity largeModelEntity = bizAgentApplicationLargeModelListService.findByModelNickName(largeModel);
if (largeModelEntity == null) { if (largeModelEntity == null) {
throw new I18nMessageException("模型不存在"); throw new BusinessException("模型不存在");
} }
return largeModelEntity.getModelName(); return largeModelEntity.getModelName();
} }
......
package cn.com.poc.ai_dialogues.aggregate;
import cn.com.poc.ai_dialogues.constant.AiDialoguesTypeEnum;
import cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/19
*/
public interface AiDialoguesService {
/**
* 创建对话
*/
String create(AiDialoguesTypeEnum type, Long userId) throws Exception;
/**
* 获取对话列表
*
* @param type 对话类型
* @param userId 用户ID
*/
List<AiDialoguesRecordDto> getList(AiDialoguesTypeEnum type, Long userId) throws Exception;
/**
* 批量删除对话列表
*
* @param dialoguesIds 对话ID列表
* @param userId 用户ID
*/
void batchDelete(List<String> dialoguesIds, Long userId) throws Exception;
}
package cn.com.poc.ai_dialogues.aggregate.impl;
import cn.com.poc.ai_dialogues.aggregate.AiDialoguesService;
import cn.com.poc.ai_dialogues.constant.AiDialoguesTypeEnum;
import cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto;
import cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity;
import cn.com.poc.ai_dialogues.service.BizAiDialoguesService;
import cn.com.poc.common.constant.CommonConstant;
import cn.com.poc.common.service.BizFileUploadRecordService;
import cn.com.poc.common.utils.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author alex.yao
* @date 2025/6/19
*/
@Service
public class AiDialoguesServiceImpl implements AiDialoguesService {
private final Logger logger = LoggerFactory.getLogger(AiDialoguesService.class);
@Resource
private BizAiDialoguesService bizAiDialoguesService;
@Resource
private BizFileUploadRecordService bizFileUploadRecordService;
@Override
public String create(AiDialoguesTypeEnum type, Long userId) throws Exception {
return bizAiDialoguesService.create(type.getType(), userId);
}
@Override
public List<AiDialoguesRecordDto> getList(AiDialoguesTypeEnum type, Long userId) throws Exception {
logger.info("get ai dialogues list type:{}, userId:{}", type, userId);
BizAiDialoguesEntity bizAiDialoguesEntity = new BizAiDialoguesEntity();
bizAiDialoguesEntity.setDialoguesType(type.getType());
bizAiDialoguesEntity.setMemberId(userId);
bizAiDialoguesEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAiDialoguesEntity> entities = bizAiDialoguesService.findByExample(bizAiDialoguesEntity, null);
List<AiDialoguesRecordDto> result = new ArrayList<>();
if (CollectionUtils.isNotEmpty(entities)) {
result = entities.stream()
.map(entity -> {
AiDialoguesRecordDto dto = new AiDialoguesRecordDto();
dto.setDialoguesId(entity.getDialoguesId());
dto.setDialoguesType(entity.getDialoguesType());
dto.setTitle(entity.getTitle());
dto.setMemberId(entity.getMemberId());
if (StringUtils.isNotBlank(entity.getFileUrl())) {
dto.setFileUrl(entity.getFileUrl());
dto.setFileName(bizFileUploadRecordService.getFileNameByFileUrl(entity.getFileUrl()));
}
dto.setCreatedTime(entity.getCreatedTime());
return dto;
})
.sorted(Comparator.comparing(AiDialoguesRecordDto::getCreatedTime).reversed())
.collect(Collectors.toList());
}
logger.debug("get ai dialogues list result:{}", result);
return result;
}
@Override
public void batchDelete(List<String> dialoguesIds, Long userId) throws Exception {
logger.info("batchDelete dialoguesIds:{}", dialoguesIds);
for (String dialoguesId : dialoguesIds) {
BizAiDialoguesEntity bizAiDialoguesEntity = new BizAiDialoguesEntity();
bizAiDialoguesEntity.setDialoguesId(dialoguesId);
bizAiDialoguesEntity.setMemberId(userId);
bizAiDialoguesEntity.setIsDeleted(CommonConstant.IsDeleted.N);
List<BizAiDialoguesEntity> entities = bizAiDialoguesService.findByExample(bizAiDialoguesEntity, null);
if (CollectionUtils.isEmpty(entities)) {
continue;
}
bizAiDialoguesService.deletedById(entities.get(0).getId());
}
}
}
package cn.com.poc.ai_dialogues.constant;
/**
* @author alex.yao
* @date 2025/6/19
*/
public enum AiDialoguesTypeEnum {
PORTAL("portal", "门户页对话"),
LONG_TEXT_DOCUMENT("long_text_document", "长文本文档"),
;
private String type;
private String desc;
AiDialoguesTypeEnum(String type, String desc) {
this.type = type;
this.desc = desc;
}
public String getType() {
return type;
}
public String getDesc() {
return desc;
}
public static AiDialoguesTypeEnum getByType(String type) {
for (AiDialoguesTypeEnum aiDialoguesTypeEnum : AiDialoguesTypeEnum.values()) {
if (aiDialoguesTypeEnum.getType().equals(type)) {
return aiDialoguesTypeEnum;
}
}
return null;
}
}
package cn.com.poc.ai_dialogues.convert;
import cn.com.poc.ai_dialogues.model.BizAiDialoguesModel;
import cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity;
import cn.com.poc.ai_dialogues.dto.BizAiDialoguesDto;
public class BizAiDialoguesConvert {
public static BizAiDialoguesEntity modelToEntity(BizAiDialoguesModel model) {
BizAiDialoguesEntity entity = new BizAiDialoguesEntity();
entity.setId(model.getId());
entity.setDialoguesId(model.getDialoguesId());
entity.setDialoguesType(model.getDialoguesType());
entity.setTitle(model.getTitle());
entity.setMemberId(model.getMemberId());
entity.setFileUrl(model.getFileUrl());
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 BizAiDialoguesModel entityToModel(BizAiDialoguesEntity entity) {
BizAiDialoguesModel model = new BizAiDialoguesModel();
model.setId(entity.getId());
model.setDialoguesId(entity.getDialoguesId());
model.setDialoguesType(entity.getDialoguesType());
model.setTitle(entity.getTitle());
model.setMemberId(entity.getMemberId());
model.setFileUrl(entity.getFileUrl());
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 BizAiDialoguesDto entityToDto(BizAiDialoguesEntity entity) {
BizAiDialoguesDto dto = new BizAiDialoguesDto();
dto.setId(entity.getId());
dto.setDialoguesId(entity.getDialoguesId());
dto.setDialoguesType(entity.getDialoguesType());
dto.setTitle(entity.getTitle());
dto.setMemberId(entity.getMemberId());
dto.setFileUrl(entity.getFileUrl());
dto.setIsDeleted(entity.getIsDeleted());
dto.setCreator(entity.getCreator());
dto.setCreatedTime(entity.getCreatedTime());
dto.setModifier(entity.getModifier());
dto.setModifiedTime(entity.getModifiedTime());
dto.setSysVersion(entity.getSysVersion());
return dto;
}
public static BizAiDialoguesEntity dtoToEntity(BizAiDialoguesDto dto) {
BizAiDialoguesEntity entity = new BizAiDialoguesEntity();
entity.setId(dto.getId());
entity.setDialoguesId(dto.getDialoguesId());
entity.setDialoguesType(dto.getDialoguesType());
entity.setTitle(dto.getTitle());
entity.setMemberId(dto.getMemberId());
entity.setFileUrl(dto.getFileUrl());
entity.setIsDeleted(dto.getIsDeleted());
entity.setCreator(dto.getCreator());
entity.setCreatedTime(dto.getCreatedTime());
entity.setModifier(dto.getModifier());
entity.setModifiedTime(dto.getModifiedTime());
entity.setSysVersion(dto.getSysVersion());
return entity;
}
}
\ No newline at end of file
package cn.com.poc.ai_dialogues.dto;
/**
* 对话记录Dto
*
* @author alex.yao
* @date 2025/6/19
*/
public class AiDialoguesRecordDto {
/**
* dialogues_id
* 对话ID
*/
private java.lang.String dialoguesId;
public java.lang.String getDialoguesId() {
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId) {
this.dialoguesId = dialoguesId;
}
/**
* dialogues_type
* 对话类型
*/
private java.lang.String dialoguesType;
public java.lang.String getDialoguesType() {
return this.dialoguesType;
}
public void setDialoguesType(java.lang.String dialoguesType) {
this.dialoguesType = dialoguesType;
}
/**
* title
* 标题
*/
private java.lang.String title;
public java.lang.String getTitle() {
return this.title;
}
public void setTitle(java.lang.String title) {
this.title = title;
}
/**
* member_id
* 用户
*/
private java.lang.Long memberId;
public java.lang.Long getMemberId() {
return this.memberId;
}
public void setMemberId(java.lang.Long memberId) {
this.memberId = memberId;
}
/**
* file_url
* 文件地址
*/
private java.lang.String fileUrl;
public java.lang.String getFileUrl() {
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl) {
this.fileUrl = fileUrl;
}
/**
* 文件名
*/
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
/**
* 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;
}
@Override
public String toString() {
return "{" +
"dialoguesId='" + dialoguesId + '\'' +
", dialoguesType='" + dialoguesType + '\'' +
", title='" + title + '\'' +
", memberId=" + memberId +
", fileUrl='" + fileUrl + '\'' +
", fileName='" + fileName + '\'' +
", createdTime=" + createdTime +
'}';
}
}
package cn.com.poc.ai_dialogues.dto;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/19
*/
public class BatchDelAiDialoguesDto {
private List<String> dialoguesIds;
public List<String> getDialoguesIds() {
return dialoguesIds;
}
public void setDialoguesIds(List<String> dialoguesIds) {
this.dialoguesIds = dialoguesIds;
}
}
package cn.com.poc.ai_dialogues.dto;
public class BizAiDialoguesDto {
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;
}
/** dialogues_id
*对话ID
*/
private java.lang.String dialoguesId;
public java.lang.String getDialoguesId(){
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId){
this.dialoguesId = dialoguesId;
}
/** dialogues_type
*对话类型
*/
private java.lang.String dialoguesType;
public java.lang.String getDialoguesType(){
return this.dialoguesType;
}
public void setDialoguesType(java.lang.String dialoguesType){
this.dialoguesType = dialoguesType;
}
/** title
*标题
*/
private java.lang.String title;
public java.lang.String getTitle(){
return this.title;
}
public void setTitle(java.lang.String title){
this.title = title;
}
/** member_id
*用户
*/
private java.lang.Long memberId;
public java.lang.Long getMemberId(){
return this.memberId;
}
public void setMemberId(java.lang.Long memberId){
this.memberId = memberId;
}
/** file_url
*文件地址
*/
private java.lang.String fileUrl;
public java.lang.String getFileUrl(){
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl){
this.fileUrl = fileUrl;
}
/** 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.ai_dialogues.entity;
public class BizAiDialoguesEntity {
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;
}
/**
* dialogues_id
* 对话ID
*/
private java.lang.String dialoguesId;
public java.lang.String getDialoguesId() {
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId) {
this.dialoguesId = dialoguesId;
}
/**
* dialogues_type
* 对话类型
*/
private java.lang.String dialoguesType;
public java.lang.String getDialoguesType() {
return this.dialoguesType;
}
public void setDialoguesType(java.lang.String dialoguesType) {
this.dialoguesType = dialoguesType;
}
/**
* title
* 标题
*/
private java.lang.String title;
public java.lang.String getTitle() {
return this.title;
}
public void setTitle(java.lang.String title) {
this.title = title;
}
/**
* member_id
* 用户
*/
private java.lang.Long memberId;
public java.lang.Long getMemberId() {
return this.memberId;
}
public void setMemberId(java.lang.Long memberId) {
this.memberId = memberId;
}
/**
* file_url
* 文件地址
*/
private java.lang.String fileUrl;
public java.lang.String getFileUrl() {
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl) {
this.fileUrl = fileUrl;
}
/**
* 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.ai_dialogues.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_ai_dialogues
* AI对话
*/
@Entity
@Table(name = "biz_ai_dialogues")
@DynamicInsert
@DynamicUpdate
public class BizAiDialoguesModel 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");
}
/**
* dialogues_id
* 对话ID
*/
private java.lang.String dialoguesId;
@Column(name = "dialogues_id", length = 120)
public java.lang.String getDialoguesId() {
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId) {
this.dialoguesId = dialoguesId;
super.addValidField("dialoguesId");
}
/**
* dialogues_type
* 对话类型
*/
private java.lang.String dialoguesType;
@Column(name = "dialogues_type", length = 120)
public java.lang.String getDialoguesType() {
return this.dialoguesType;
}
public void setDialoguesType(java.lang.String dialoguesType) {
this.dialoguesType = dialoguesType;
super.addValidField("dialoguesType");
}
/**
* title
* 标题
*/
private java.lang.String title;
@Column(name = "title", length = 150)
public java.lang.String getTitle() {
return this.title;
}
public void setTitle(java.lang.String title) {
this.title = title;
super.addValidField("title");
}
/**
* member_id
* 用户
*/
private java.lang.Long memberId;
@Column(name = "member_id", length = 19)
public java.lang.Long getMemberId() {
return this.memberId;
}
public void setMemberId(java.lang.Long memberId) {
this.memberId = memberId;
super.addValidField("memberId");
}
/**
* file_url
* 文件地址
*/
private java.lang.String fileUrl;
@Column(name = "file_url", length = 150)
public java.lang.String getFileUrl() {
return this.fileUrl;
}
public void setFileUrl(java.lang.String fileUrl) {
this.fileUrl = fileUrl;
super.addValidField("fileUrl");
}
/**
* 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.ai_dialogues.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.ai_dialogues.model.BizAiDialoguesModel;
public interface BizAiDialoguesRepository extends Repository<BizAiDialoguesModel,java.lang.Long> {
}
\ No newline at end of file
package cn.com.poc.ai_dialogues.rest;
import cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto;
import cn.com.poc.ai_dialogues.dto.BatchDelAiDialoguesDto;
import cn.com.yict.framemax.core.rest.BaseRest;
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;
import java.util.List;
@Permission(Access.Safety)
public interface AiDialoguesRest extends BaseRest {
/**
* 创建对话
*
* @param fileUrl
* @param type
* @return
* @throws Exception
*/
String create(@RequestParam(required = false) String fileUrl, @RequestParam String type) throws Exception;
/**
* 获取对话列表
*/
List<AiDialoguesRecordDto> getList(@RequestParam String type) throws Exception;
/**
* 批量删除对话列表
*/
void batchDelete(@RequestBody BatchDelAiDialoguesDto dto) throws Exception;
/**
* 获取对话上下文
*/
}
package cn.com.poc.ai_dialogues.rest.impl;
import cn.com.poc.ai_dialogues.aggregate.AiDialoguesService;
import cn.com.poc.ai_dialogues.constant.AiDialoguesTypeEnum;
import cn.com.poc.ai_dialogues.dto.AiDialoguesRecordDto;
import cn.com.poc.ai_dialogues.dto.BatchDelAiDialoguesDto;
import cn.com.poc.ai_dialogues.rest.AiDialoguesRest;
import cn.com.poc.ai_dialogues.service.BizAiDialoguesService;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.List;
@Component
public class AiDialoguesRestImpl implements AiDialoguesRest {
@Resource
private AiDialoguesService aiDialoguesService;
@Override
public String create(String fileUrl, String type) throws Exception {
Assert.notBlank(type, "对话类型不能为空");
Assert.isTrue(AiDialoguesTypeEnum.getByType(type) != null, "对话类型不存在");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (ObjectUtil.isEmpty(userBaseEntity)) {
throw new BusinessException("用户未登录");
}
return aiDialoguesService.create(AiDialoguesTypeEnum.getByType(type), userBaseEntity.getUserId());
}
@Override
public List<AiDialoguesRecordDto> getList(String type) throws Exception {
Assert.notBlank(type, "对话类型不能为空");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (ObjectUtil.isEmpty(userBaseEntity)) {
throw new BusinessException("用户未登录");
}
return aiDialoguesService.getList(AiDialoguesTypeEnum.getByType(type), userBaseEntity.getUserId());
}
@Override
public void batchDelete(BatchDelAiDialoguesDto dto) throws Exception {
Assert.notEmpty(dto.getDialoguesIds(), "对话id列表不能为空");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (ObjectUtil.isEmpty(userBaseEntity)) {
throw new BusinessException("用户未登录");
}
aiDialoguesService.batchDelete(dto.getDialoguesIds(), userBaseEntity.getUserId());
}
}
\ No newline at end of file
package cn.com.poc.ai_dialogues.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.List;
public interface BizAiDialoguesService extends BaseService {
/**
* 创建对话
*
* @param userId
* @return
*/
String create(String type,Long userId);
BizAiDialoguesEntity get(java.lang.Long id) throws Exception;
List<BizAiDialoguesEntity> findByExample(BizAiDialoguesEntity example, PagingInfo pagingInfo) throws Exception;
BizAiDialoguesEntity save(BizAiDialoguesEntity entity) throws Exception;
BizAiDialoguesEntity update(BizAiDialoguesEntity entity) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.ai_dialogues.service.impl;
import cn.com.poc.ai_dialogues.convert.BizAiDialoguesConvert;
import cn.com.poc.ai_dialogues.entity.BizAiDialoguesEntity;
import cn.com.poc.ai_dialogues.model.BizAiDialoguesModel;
import cn.com.poc.ai_dialogues.repository.BizAiDialoguesRepository;
import cn.com.poc.ai_dialogues.service.BizAiDialoguesService;
import cn.com.poc.common.utils.UUIDTool;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.yict.framemax.data.model.PagingInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@Service
public class BizAiDialoguesServiceImpl extends BaseServiceImpl
implements BizAiDialoguesService {
@Resource
private BizAiDialoguesRepository repository;
@Override
public String create(String type, Long userId) {
String dialoguesId = type + "_" + UUIDTool.getUUID();
BizAiDialoguesModel model = new BizAiDialoguesModel();
model.setDialoguesId(dialoguesId);
model.setDialoguesType(type);
model.setMemberId(userId);
this.repository.save(model);
return dialoguesId;
}
public BizAiDialoguesEntity get(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizAiDialoguesModel model = this.repository.get(id);
if (model == null) {
return null;
}
if ("Y".equals(model.getIsDeleted())) {
return null;
}
return BizAiDialoguesConvert.modelToEntity(model);
}
public List<BizAiDialoguesEntity> findByExample(BizAiDialoguesEntity example, PagingInfo pagingInfo) throws Exception {
List<BizAiDialoguesEntity> result = new ArrayList<BizAiDialoguesEntity>();
BizAiDialoguesModel model = new BizAiDialoguesModel();
if (example != null) {
model = BizAiDialoguesConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizAiDialoguesModel> models = this.repository.findByExample(model, pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizAiDialoguesConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizAiDialoguesEntity save(BizAiDialoguesEntity entity) throws Exception {
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizAiDialoguesModel model = BizAiDialoguesConvert.entityToModel(entity);
BizAiDialoguesModel saveModel = this.repository.save(model);
return BizAiDialoguesConvert.modelToEntity(saveModel);
}
public BizAiDialoguesEntity update(BizAiDialoguesEntity entity) throws Exception {
Assert.notNull(entity);
Assert.notNull(entity.getId(), "update pk can not be null");
BizAiDialoguesModel model = this.repository.get(entity.getId());
if (entity.getDialoguesId() != null) {
model.setDialoguesId(entity.getDialoguesId());
}
if (entity.getTitle() != null) {
model.setTitle(entity.getTitle());
}
if (entity.getMemberId() != null) {
model.setMemberId(entity.getMemberId());
}
if (entity.getFileUrl() != null) {
model.setFileUrl(entity.getFileUrl());
}
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());
}
BizAiDialoguesModel saveModel = this.repository.save(model);
return BizAiDialoguesConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Long id) throws Exception {
Assert.notNull(id);
BizAiDialoguesModel model = this.repository.get(id);
if (model != null) {
if ("N".equals(model.getIsDeleted())) {
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
}
\ No newline at end of file
...@@ -9,6 +9,8 @@ import java.util.List; ...@@ -9,6 +9,8 @@ import java.util.List;
public interface BizFileUploadRecordService extends BaseService { public interface BizFileUploadRecordService extends BaseService {
String getFileNameByFileUrl(String fileUrl);
BizFileUploadRecordModel get(Long id) throws Exception; BizFileUploadRecordModel get(Long id) throws Exception;
List<BizFileUploadRecordModel> findByExample(BizFileUploadRecordModel example,PagingInfo pagingInfo) throws Exception; List<BizFileUploadRecordModel> findByExample(BizFileUploadRecordModel example,PagingInfo pagingInfo) throws Exception;
......
...@@ -3,8 +3,10 @@ package cn.com.poc.common.service.impl; ...@@ -3,8 +3,10 @@ package cn.com.poc.common.service.impl;
import cn.com.poc.common.model.BizFileUploadRecordModel; import cn.com.poc.common.model.BizFileUploadRecordModel;
import cn.com.poc.common.repository.BizFileUploadRecordRepository; import cn.com.poc.common.repository.BizFileUploadRecordRepository;
import cn.com.poc.common.service.BizFileUploadRecordService; import cn.com.poc.common.service.BizFileUploadRecordService;
import cn.com.poc.common.utils.StringUtils;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl; import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.yict.framemax.data.model.PagingInfo; import cn.com.yict.framemax.data.model.PagingInfo;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -13,39 +15,54 @@ import java.util.List; ...@@ -13,39 +15,54 @@ import java.util.List;
@Service @Service
public class BizFileUploadRecordServiceImpl extends BaseServiceImpl public class BizFileUploadRecordServiceImpl extends BaseServiceImpl
implements BizFileUploadRecordService { implements BizFileUploadRecordService {
@Resource @Resource
private BizFileUploadRecordRepository repository; private BizFileUploadRecordRepository repository;
public BizFileUploadRecordModel get(Long id) throws Exception{ @Override
return this.repository.get(id); public String getFileNameByFileUrl(String fileUrl) {
} if (StringUtils.isBlank(fileUrl)) {
return null;
public List<BizFileUploadRecordModel> findByExample(BizFileUploadRecordModel example,PagingInfo pagingInfo) throws Exception{ }
if(example == null){ BizFileUploadRecordModel bizFileUploadRecordModel = new BizFileUploadRecordModel();
example = new BizFileUploadRecordModel(); bizFileUploadRecordModel.setFileUrl(fileUrl);
} List<BizFileUploadRecordModel> models = this.repository.findByExample(bizFileUploadRecordModel);
return this.repository.findByExample(example,pagingInfo);
} if (CollectionUtils.isEmpty(models)) {
return null;
public void delete(BizFileUploadRecordModel model) throws Exception{ }
this.repository.remove(model); return models.get(0).getFileName();
} }
public void deleteById(Long id) throws Exception{ public BizFileUploadRecordModel get(Long id) throws Exception {
this.repository.removeByPk(id); return this.repository.get(id);
} }
public void deleteAll(Collection<Long> ids) throws Exception{ public List<BizFileUploadRecordModel> findByExample(BizFileUploadRecordModel example, PagingInfo pagingInfo) throws Exception {
this.repository.removeAllByPk(ids); if (example == null) {
} example = new BizFileUploadRecordModel();
}
public BizFileUploadRecordModel save(BizFileUploadRecordModel model) { return this.repository.findByExample(example, pagingInfo);
return this.repository.save(model); }
}
public void delete(BizFileUploadRecordModel model) throws Exception {
public Collection<BizFileUploadRecordModel> saveAll(Collection<BizFileUploadRecordModel> models) throws Exception{ this.repository.remove(model);
return this.repository.saveAll(models); }
}
public void deleteById(Long id) throws Exception {
this.repository.removeByPk(id);
}
public void deleteAll(Collection<Long> ids) throws Exception {
this.repository.removeAllByPk(ids);
}
public BizFileUploadRecordModel save(BizFileUploadRecordModel model) {
return this.repository.save(model);
}
public Collection<BizFileUploadRecordModel> saveAll(Collection<BizFileUploadRecordModel> models) throws Exception {
return this.repository.saveAll(models);
}
} }
\ No newline at end of file
package cn.com.poc.portal.aggregate;
import cn.com.poc.portal.entity.PortalDialoguesCallEntity;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/19
*/
public interface PortalService {
/**
* 执行对话
*
* @param callEntity 对话调用实体
* @param userId 用户id
*/
void call(PortalDialoguesCallEntity callEntity, Long userId) throws Exception;
}
package cn.com.poc.portal.convert;
import cn.com.poc.portal.entity.BizPortalDialoguesEntity;
import cn.com.poc.portal.model.BizPortalDialoguesModel;
public class BizPortalDialoguesConvert {
public static BizPortalDialoguesEntity modelToEntity(BizPortalDialoguesModel model) {
BizPortalDialoguesEntity entity = new BizPortalDialoguesEntity();
entity.setId(model.getId());
entity.setDialoguesId(model.getDialoguesId());
entity.setUserId(model.getUserId());
entity.setTitle(model.getTitle());
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 BizPortalDialoguesModel entityToModel(BizPortalDialoguesEntity entity) {
BizPortalDialoguesModel model = new BizPortalDialoguesModel();
model.setId(entity.getId());
model.setDialoguesId(entity.getDialoguesId());
model.setUserId(entity.getUserId());
model.setTitle(entity.getTitle());
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;
}
}
\ No newline at end of file
package cn.com.poc.portal.convert;
import cn.com.poc.portal.dto.PortalDialoguesDto;
import cn.com.poc.portal.entity.PortalDialoguesCallEntity;
/**
* @author alex.yao
* @date 2025/6/19
*/
public class PortalConvert {
public static PortalDialoguesCallEntity callDtoToEntity(PortalDialoguesDto dto) {
PortalDialoguesCallEntity portalDialoguesCallEntity = new PortalDialoguesCallEntity();
portalDialoguesCallEntity.setDialoguesId(dto.getDialoguesId());
portalDialoguesCallEntity.setInput(dto.getInput());
portalDialoguesCallEntity.setEnableSearchEngine(dto.getEnableSearchEngine());
portalDialoguesCallEntity.setEnableDeepThinking(dto.getEnableDeepThinking());
portalDialoguesCallEntity.setFileUrl(dto.getFileUrl());
portalDialoguesCallEntity.setKnowledgeIds(dto.getKnowledgeIds());
return portalDialoguesCallEntity;
}
}
package cn.com.poc.portal.dto;
/**
* 门户页 对话调用实体DTO
*
* @author alex.yao
* @date 2025/6/19
*/
public class PortalDialoguesDto {
/**
* 对话id
*/
private String dialoguesId;
/**
* 问题
*/
private String input;
/**
* 是否启用搜索引擎
*/
private Boolean enableSearchEngine;
/**
* 是否开启深度思考
*/
private Boolean enableDeepThinking;
/**
* 文件地址
*/
private String fileUrl;
/**
* 知识库ids
*/
private Integer[] knowledgeIds;
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public String getDialoguesId() {
return dialoguesId;
}
public void setDialoguesId(String dialoguesId) {
this.dialoguesId = dialoguesId;
}
public Boolean getEnableSearchEngine() {
return enableSearchEngine;
}
public void setEnableSearchEngine(Boolean enableSearchEngine) {
this.enableSearchEngine = enableSearchEngine;
}
public Boolean getEnableDeepThinking() {
return enableDeepThinking;
}
public void setEnableDeepThinking(Boolean enableDeepThinking) {
this.enableDeepThinking = enableDeepThinking;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public Integer[] getKnowledgeIds() {
return knowledgeIds;
}
public void setKnowledgeIds(Integer[] knowledgeIds) {
this.knowledgeIds = knowledgeIds;
}
}
package cn.com.poc.portal.entity;
public class BizPortalDialoguesEntity {
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;
}
/** dialogues_id
*对话id
*/
private java.lang.String dialoguesId;
public java.lang.String getDialoguesId(){
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId){
this.dialoguesId = dialoguesId;
}
/** user_id
*用户id
*/
private java.lang.Long userId;
public java.lang.Long getUserId(){
return this.userId;
}
public void setUserId(java.lang.Long userId){
this.userId = userId;
}
/** title
*标题
*/
private java.lang.String title;
public java.lang.String getTitle(){
return this.title;
}
public void setTitle(java.lang.String title){
this.title = title;
}
/** 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.portal.entity;
import java.util.List;
/**
* @author alex.yao
* @date 2025/6/19
*/
public class PortalDialoguesCallEntity {
/**
* 对话id
*/
private String dialoguesId;
/**
* 问题
*/
private String input;
/**
* 是否启用搜索引擎
*/
private Boolean enableSearchEngine;
/**
* 是否开启深度思考
*/
private Boolean enableDeepThinking;
/**
* 文件地址
*/
private String fileUrl;
/**
* 知识库ids
*/
private Integer[] knowledgeIds;
public String getDialoguesId() {
return dialoguesId;
}
public void setDialoguesId(String dialoguesId) {
this.dialoguesId = dialoguesId;
}
public String getInput() {
return input;
}
public void setInput(String input) {
this.input = input;
}
public Boolean getEnableSearchEngine() {
return enableSearchEngine;
}
public void setEnableSearchEngine(Boolean enableSearchEngine) {
this.enableSearchEngine = enableSearchEngine;
}
public Boolean getEnableDeepThinking() {
return enableDeepThinking;
}
public void setEnableDeepThinking(Boolean enableDeepThinking) {
this.enableDeepThinking = enableDeepThinking;
}
public String getFileUrl() {
return fileUrl;
}
public void setFileUrl(String fileUrl) {
this.fileUrl = fileUrl;
}
public Integer[] getKnowledgeIds() {
return knowledgeIds;
}
public void setKnowledgeIds(Integer[] knowledgeIds) {
this.knowledgeIds = knowledgeIds;
}
}
package cn.com.poc.portal.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_portal_dialogues
* 首页对话
*/
@Entity
@Table(name = "biz_portal_dialogues")
@DynamicInsert
@DynamicUpdate
public class BizPortalDialoguesModel 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");
}
/** dialogues_id
*对话id
*/
private java.lang.String dialoguesId;
@Column(name = "dialogues_id",length = 120)
public java.lang.String getDialoguesId(){
return this.dialoguesId;
}
public void setDialoguesId(java.lang.String dialoguesId){
this.dialoguesId = dialoguesId;
super.addValidField("dialoguesId");
}
/** user_id
*用户id
*/
private java.lang.Long userId;
@Column(name = "user_id",length = 19)
public java.lang.Long getUserId(){
return this.userId;
}
public void setUserId(java.lang.Long userId){
this.userId = userId;
super.addValidField("userId");
}
/** title
*标题
*/
private java.lang.String title;
@Column(name = "title",length = 100)
public java.lang.String getTitle(){
return this.title;
}
public void setTitle(java.lang.String title){
this.title = title;
super.addValidField("title");
}
/** 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.portal.repository;
import cn.com.yict.framemax.data.repository.Repository;
import cn.com.poc.portal.model.BizPortalDialoguesModel;
public interface BizPortalDialoguesRepository extends Repository<BizPortalDialoguesModel,java.lang.Long> {
}
\ No newline at end of file
package cn.com.poc.portal.rest;
import cn.com.poc.portal.dto.PortalDialoguesDto;
import cn.com.yict.framemax.core.rest.BaseRest;
import cn.com.yict.framemax.web.permission.Access;
import cn.com.yict.framemax.web.permission.Permission;
import org.springframework.web.bind.annotation.RequestBody;
/**
* 门户页对话接口
*
* @author alex.yao
* @date 2025/6/19
*/
@Permission(Access.Safety)
public interface PortalRest extends BaseRest {
/**
* 执行对话
*
* @param dto 对话调用实体DTO
*/
void call(@RequestBody PortalDialoguesDto dto) throws Exception;
}
package cn.com.poc.portal.rest.impl;
import cn.com.poc.common.utils.Assert;
import cn.com.poc.common.utils.BlContext;
import cn.com.poc.portal.aggregate.PortalService;
import cn.com.poc.portal.convert.PortalConvert;
import cn.com.poc.portal.dto.PortalDialoguesDto;
import cn.com.poc.portal.entity.PortalDialoguesCallEntity;
import cn.com.poc.portal.rest.PortalRest;
import cn.com.poc.support.security.oauth.entity.UserBaseEntity;
import cn.com.yict.framemax.core.exception.BusinessException;
import cn.hutool.core.util.ObjectUtil;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* @author alex.yao
* @date 2025/6/19
*/
@Component
public class PortalRestImpl implements PortalRest {
@Resource
private PortalService portalService;
@Override
public void call(PortalDialoguesDto dto) throws Exception {
Assert.notNull(dto, "请求参数不能为空");
UserBaseEntity userBaseEntity = BlContext.getCurrentUserNotException();
if (ObjectUtil.isEmpty(userBaseEntity)) {
throw new BusinessException("用户未登录");
}
PortalDialoguesCallEntity callEntity = PortalConvert.callDtoToEntity(dto);
portalService.call(callEntity, userBaseEntity.getUserId());
}
}
package cn.com.poc.portal.service;
import cn.com.yict.framemax.core.service.BaseService;
import cn.com.poc.portal.entity.BizPortalDialoguesEntity;
import cn.com.yict.framemax.data.model.PagingInfo;
import java.util.Collection;
import java.util.List;
public interface BizPortalDialoguesService extends BaseService {
BizPortalDialoguesEntity get(java.lang.Long id) throws Exception;
List<BizPortalDialoguesEntity> findByExample(BizPortalDialoguesEntity example,PagingInfo pagingInfo) throws Exception;
BizPortalDialoguesEntity save(BizPortalDialoguesEntity entity) throws Exception;
BizPortalDialoguesEntity update(BizPortalDialoguesEntity entity) throws Exception;
void deletedById(java.lang.Long id) throws Exception;
}
\ No newline at end of file
package cn.com.poc.portal.service.impl;
import cn.com.yict.framemax.core.service.impl.BaseServiceImpl;
import cn.com.poc.portal.service.BizPortalDialoguesService;
import cn.com.poc.portal.model.BizPortalDialoguesModel;
import cn.com.poc.portal.entity.BizPortalDialoguesEntity;
import cn.com.poc.portal.convert.BizPortalDialoguesConvert;
import cn.com.poc.portal.repository.BizPortalDialoguesRepository;
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 BizPortalDialoguesServiceImpl extends BaseServiceImpl
implements BizPortalDialoguesService {
@Resource
private BizPortalDialoguesRepository repository;
public BizPortalDialoguesEntity get(java.lang.Long id) throws Exception{
Assert.notNull(id);
BizPortalDialoguesModel model = this.repository.get(id);
if (model == null){
return null;
}
if ("Y".equals(model.getIsDeleted())){
return null;
}
return BizPortalDialoguesConvert.modelToEntity(model);
}
public List<BizPortalDialoguesEntity> findByExample(BizPortalDialoguesEntity example,PagingInfo pagingInfo) throws Exception{
List<BizPortalDialoguesEntity> result = new ArrayList<BizPortalDialoguesEntity>();
BizPortalDialoguesModel model = new BizPortalDialoguesModel();
if (example != null){
model = BizPortalDialoguesConvert.entityToModel(example);
}
model.setIsDeleted("N");
List<BizPortalDialoguesModel> models = this.repository.findByExample(model,pagingInfo);
if (CollectionUtils.isNotEmpty(models)) {
result = models.stream().map(BizPortalDialoguesConvert::modelToEntity).collect(Collectors.toList());
}
return result;
}
public BizPortalDialoguesEntity save(BizPortalDialoguesEntity entity) throws Exception{
Assert.notNull(entity);
entity.setId(null);
entity.setIsDeleted("N");
BizPortalDialoguesModel model = BizPortalDialoguesConvert.entityToModel(entity);
BizPortalDialoguesModel saveModel = this.repository.save(model);
return BizPortalDialoguesConvert.modelToEntity(saveModel);
}
public BizPortalDialoguesEntity update(BizPortalDialoguesEntity entity) throws Exception{
Assert.notNull(entity);
Assert.notNull(entity.getId(),"update pk can not be null");
BizPortalDialoguesModel model = this.repository.get(entity.getId());
if (entity.getDialoguesId() != null){
model.setDialoguesId(entity.getDialoguesId());
}
if (entity.getUserId() != null){
model.setUserId(entity.getUserId());
}
if (entity.getTitle() != null){
model.setTitle(entity.getTitle());
}
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());
}
BizPortalDialoguesModel saveModel = this.repository.save(model);
return BizPortalDialoguesConvert.modelToEntity(saveModel);
}
public void deletedById(java.lang.Long id) throws Exception{
Assert.notNull(id);
BizPortalDialoguesModel model = this.repository.get(id);
if (model != null){
if ("N".equals(model.getIsDeleted())){
model.setIsDeleted("Y");
this.repository.save(model);
}
}
}
}
\ 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