Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
P
poc-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
poc
poc-api
Commits
b082a584
Commit
b082a584
authored
Dec 19, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: Agent API 配置
parent
ffc12c0b
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
670 additions
and
12 deletions
+670
-12
BizAgentApplicationApiProfileConvert.java
...ication/convert/BizAgentApplicationApiProfileConvert.java
+42
-0
BizAgentApplicationApiProfileEntity.java
...plication/entity/BizAgentApplicationApiProfileEntity.java
+149
-0
BizAgentApplicationApiProfileModel.java
...application/model/BizAgentApplicationApiProfileModel.java
+194
-0
BizAgentApplicationApiProfileRepository.java
...n/repository/BizAgentApplicationApiProfileRepository.java
+7
-0
BizAgentApplicationApiProfileService.java
...ication/service/BizAgentApplicationApiProfileService.java
+22
-0
BizAgentApplicationApiProfileServiceImpl.java
...ervice/impl/BizAgentApplicationApiProfileServiceImpl.java
+128
-0
AgentApplicationService.java
.../cn/com/poc/expose/aggregate/AgentApplicationService.java
+11
-0
AgentApplicationServiceImpl.java
...oc/expose/aggregate/impl/AgentApplicationServiceImpl.java
+18
-11
AgentApplicationApiProfileDto.java
.../cn/com/poc/expose/dto/AgentApplicationApiProfileDto.java
+32
-0
AgentApplicationRest.java
...ain/java/cn/com/poc/expose/rest/AgentApplicationRest.java
+8
-0
AgentApplicationRestImpl.java
...cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
+11
-1
AgentApplicationApiProfileTest.java
...poc/agent_application/AgentApplicationApiProfileTest.java
+48
-0
No files found.
src/main/java/cn/com/poc/agent_application/convert/BizAgentApplicationApiProfileConvert.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
convert
;
import
cn.com.poc.agent_application.model.BizAgentApplicationApiProfileModel
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
public
class
BizAgentApplicationApiProfileConvert
{
public
static
BizAgentApplicationApiProfileEntity
modelToEntity
(
BizAgentApplicationApiProfileModel
model
){
BizAgentApplicationApiProfileEntity
entity
=
new
BizAgentApplicationApiProfileEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setMemberId
(
model
.
getMemberId
());
entity
.
setApiKey
(
model
.
getApiKey
());
entity
.
setApiSecret
(
model
.
getApiSecret
());
entity
.
setIsDeleted
(
model
.
getIsDeleted
());
entity
.
setCreator
(
model
.
getCreator
());
entity
.
setCreatedTime
(
model
.
getCreatedTime
());
entity
.
setModifier
(
model
.
getModifier
());
entity
.
setModifiedTime
(
model
.
getModifiedTime
());
entity
.
setSysVersion
(
model
.
getSysVersion
());
entity
.
setId
(
model
.
getId
());
return
entity
;
}
public
static
BizAgentApplicationApiProfileModel
entityToModel
(
BizAgentApplicationApiProfileEntity
entity
){
BizAgentApplicationApiProfileModel
model
=
new
BizAgentApplicationApiProfileModel
();
model
.
setId
(
entity
.
getId
());
model
.
setMemberId
(
entity
.
getMemberId
());
model
.
setApiKey
(
entity
.
getApiKey
());
model
.
setApiSecret
(
entity
.
getApiSecret
());
model
.
setIsDeleted
(
entity
.
getIsDeleted
());
model
.
setCreator
(
entity
.
getCreator
());
model
.
setCreatedTime
(
entity
.
getCreatedTime
());
model
.
setModifier
(
entity
.
getModifier
());
model
.
setModifiedTime
(
entity
.
getModifiedTime
());
model
.
setSysVersion
(
entity
.
getSysVersion
());
model
.
setId
(
entity
.
getId
());
return
model
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/entity/BizAgentApplicationApiProfileEntity.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
entity
;
import
javax.persistence.Column
;
public
class
BizAgentApplicationApiProfileEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* id
* 主键id
*/
private
java
.
lang
.
Long
id
;
public
java
.
lang
.
Long
getId
()
{
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Long
id
)
{
this
.
id
=
id
;
}
/**
* member_id
* 用户id
*/
private
java
.
lang
.
Long
memberId
;
public
Long
getMemberId
()
{
return
memberId
;
}
public
void
setMemberId
(
Long
memberId
)
{
this
.
memberId
=
memberId
;
}
/**
* api_key
*/
private
java
.
lang
.
String
apiKey
;
public
java
.
lang
.
String
getApiKey
()
{
return
this
.
apiKey
;
}
public
void
setApiKey
(
java
.
lang
.
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
/**
* api_secret
*/
private
java
.
lang
.
String
apiSecret
;
public
java
.
lang
.
String
getApiSecret
()
{
return
this
.
apiSecret
;
}
public
void
setApiSecret
(
java
.
lang
.
String
apiSecret
)
{
this
.
apiSecret
=
apiSecret
;
}
/**
* 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
src/main/java/cn/com/poc/agent_application/model/BizAgentApplicationApiProfileModel.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
model
;
import
java.io.Serializable
;
import
cn.com.yict.framemax.data.model.BaseModelClass
;
import
javax.persistence.*
;
import
org.hibernate.annotations.DynamicInsert
;
import
org.hibernate.annotations.DynamicUpdate
;
/**
* Model class for biz_agent_application_api_profile
* agent应用 API配置信息
*/
@Entity
@Table
(
name
=
"biz_agent_application_api_profile"
)
@DynamicInsert
@DynamicUpdate
public
class
BizAgentApplicationApiProfileModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* id
* 主键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"
);
}
/**
* member_id
* 用户id
*/
private
java
.
lang
.
Long
memberId
;
@Column
(
name
=
"member_id"
,
length
=
19
)
public
Long
getMemberId
()
{
return
memberId
;
}
public
void
setMemberId
(
Long
memberId
)
{
this
.
memberId
=
memberId
;
super
.
addValidField
(
"memberId"
);
}
/**
* api_key
*/
private
java
.
lang
.
String
apiKey
;
@Column
(
name
=
"api_key"
,
length
=
120
)
public
java
.
lang
.
String
getApiKey
()
{
return
this
.
apiKey
;
}
public
void
setApiKey
(
java
.
lang
.
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
super
.
addValidField
(
"apiKey"
);
}
/**
* api_secret
*/
private
java
.
lang
.
String
apiSecret
;
@Column
(
name
=
"api_secret"
,
length
=
120
)
public
java
.
lang
.
String
getApiSecret
()
{
return
this
.
apiSecret
;
}
public
void
setApiSecret
(
java
.
lang
.
String
apiSecret
)
{
this
.
apiSecret
=
apiSecret
;
super
.
addValidField
(
"apiSecret"
);
}
/**
* 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
src/main/java/cn/com/poc/agent_application/repository/BizAgentApplicationApiProfileRepository.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
repository
;
import
cn.com.yict.framemax.data.repository.Repository
;
import
cn.com.poc.agent_application.model.BizAgentApplicationApiProfileModel
;
public
interface
BizAgentApplicationApiProfileRepository
extends
Repository
<
BizAgentApplicationApiProfileModel
,
Long
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/service/BizAgentApplicationApiProfileService.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
service
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.List
;
public
interface
BizAgentApplicationApiProfileService
extends
BaseService
{
BizAgentApplicationApiProfileEntity
getByMemberId
(
Long
memberId
);
BizAgentApplicationApiProfileEntity
initProfile
(
Long
memberId
);
List
<
BizAgentApplicationApiProfileEntity
>
findByExample
(
BizAgentApplicationApiProfileEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
BizAgentApplicationApiProfileEntity
save
(
BizAgentApplicationApiProfileEntity
entity
)
throws
Exception
;
BizAgentApplicationApiProfileEntity
update
(
BizAgentApplicationApiProfileEntity
entity
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/agent_application/service/impl/BizAgentApplicationApiProfileServiceImpl.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
.
service
.
impl
;
import
cn.com.poc.agent_application.convert.BizAgentApplicationApiProfileConvert
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.model.BizAgentApplicationApiProfileModel
;
import
cn.com.poc.agent_application.repository.BizAgentApplicationApiProfileRepository
;
import
cn.com.poc.agent_application.service.BizAgentApplicationApiProfileService
;
import
cn.com.poc.common.constant.CommonConstant
;
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
cn.hutool.core.lang.generator.SnowflakeGenerator
;
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.concurrent.ConcurrentHashMap
;
import
java.util.concurrent.locks.Lock
;
import
java.util.concurrent.locks.ReentrantLock
;
import
java.util.stream.Collectors
;
@Service
public
class
BizAgentApplicationApiProfileServiceImpl
extends
BaseServiceImpl
implements
BizAgentApplicationApiProfileService
{
// 存储agentId到锁对象的映射
private
final
ConcurrentHashMap
<
Long
,
Lock
>
initProfileLocks
=
new
ConcurrentHashMap
<>();
@Resource
private
BizAgentApplicationApiProfileRepository
repository
;
@Override
public
BizAgentApplicationApiProfileEntity
getByMemberId
(
Long
memberId
)
{
BizAgentApplicationApiProfileModel
model
=
new
BizAgentApplicationApiProfileModel
();
model
.
setMemberId
(
memberId
);
model
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizAgentApplicationApiProfileModel
>
models
=
this
.
repository
.
findByExample
(
model
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
return
BizAgentApplicationApiProfileConvert
.
modelToEntity
(
models
.
get
(
0
));
}
return
null
;
}
@Override
public
BizAgentApplicationApiProfileEntity
initProfile
(
Long
memberId
)
{
Lock
lock
=
initProfileLocks
.
computeIfAbsent
(
memberId
,
k
->
new
ReentrantLock
());
lock
.
lock
();
// 获取锁
try
{
BizAgentApplicationApiProfileEntity
entity
=
this
.
getByMemberId
(
memberId
);
if
(
entity
==
null
)
{
BizAgentApplicationApiProfileModel
model
=
new
BizAgentApplicationApiProfileModel
();
model
.
setMemberId
(
memberId
);
SnowflakeGenerator
snowflakeGenerator
=
new
SnowflakeGenerator
();
model
.
setApiKey
(
snowflakeGenerator
.
next
().
toString
());
model
.
setApiSecret
(
UUIDTool
.
getUUID
());
model
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
BizAgentApplicationApiProfileModel
saveModel
=
this
.
repository
.
save
(
model
);
entity
=
BizAgentApplicationApiProfileConvert
.
modelToEntity
(
saveModel
);
}
return
entity
;
}
finally
{
lock
.
unlock
();
}
}
public
List
<
BizAgentApplicationApiProfileEntity
>
findByExample
(
BizAgentApplicationApiProfileEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
List
<
BizAgentApplicationApiProfileEntity
>
result
=
new
ArrayList
<
BizAgentApplicationApiProfileEntity
>();
BizAgentApplicationApiProfileModel
model
=
new
BizAgentApplicationApiProfileModel
();
if
(
example
!=
null
)
{
model
=
BizAgentApplicationApiProfileConvert
.
entityToModel
(
example
);
}
model
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizAgentApplicationApiProfileModel
>
models
=
this
.
repository
.
findByExample
(
model
,
pagingInfo
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
result
=
models
.
stream
().
map
(
BizAgentApplicationApiProfileConvert:
:
modelToEntity
).
collect
(
Collectors
.
toList
());
}
return
result
;
}
public
BizAgentApplicationApiProfileEntity
save
(
BizAgentApplicationApiProfileEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
entity
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
BizAgentApplicationApiProfileModel
model
=
BizAgentApplicationApiProfileConvert
.
entityToModel
(
entity
);
BizAgentApplicationApiProfileModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizAgentApplicationApiProfileConvert
.
modelToEntity
(
saveModel
);
}
public
BizAgentApplicationApiProfileEntity
update
(
BizAgentApplicationApiProfileEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
Assert
.
notNull
(
entity
.
getId
(),
"update pk can not be null"
);
BizAgentApplicationApiProfileModel
model
=
this
.
repository
.
get
(
entity
.
getId
());
if
(
entity
.
getMemberId
()
!=
null
)
{
model
.
setMemberId
(
entity
.
getMemberId
());
}
if
(
entity
.
getApiKey
()
!=
null
)
{
model
.
setApiKey
(
entity
.
getApiKey
());
}
if
(
entity
.
getApiSecret
()
!=
null
)
{
model
.
setApiSecret
(
entity
.
getApiSecret
());
}
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
());
}
BizAgentApplicationApiProfileModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizAgentApplicationApiProfileConvert
.
modelToEntity
(
saveModel
);
}
}
\ No newline at end of file
src/main/java/cn/com/poc/expose/aggregate/AgentApplicationService.java
View file @
b082a584
package
cn
.
com
.
poc
.
expose
.
aggregate
;
package
cn
.
com
.
poc
.
expose
.
aggregate
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.expose.dto.AgentApplicationApiProfileDto
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.springframework.web.bind.annotation.RequestParam
;
import
org.springframework.web.bind.annotation.RequestParam
;
...
@@ -65,4 +67,13 @@ public interface AgentApplicationService {
...
@@ -65,4 +67,13 @@ public interface AgentApplicationService {
*/
*/
String
enableAutoPlay
(
Long
memberId
,
String
agentId
,
String
autoPlay
);
String
enableAutoPlay
(
Long
memberId
,
String
agentId
,
String
autoPlay
);
/**
* 获取应用的API配置
*
* @param memberId 用户ID
* @return 应用API配置
*/
BizAgentApplicationApiProfileEntity
getApiProfile
(
Long
memberId
);
}
}
src/main/java/cn/com/poc/expose/aggregate/impl/AgentApplicationServiceImpl.java
View file @
b082a584
...
@@ -3,16 +3,10 @@ package cn.com.poc.expose.aggregate.impl;
...
@@ -3,16 +3,10 @@ package cn.com.poc.expose.aggregate.impl;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.aggregate.AgentApplicationInfoService
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationDialoguesRecordConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.constant.AgentApplicationGCConfigConstants
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.*
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationGcConfigEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.VoiceConfig
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.service.BizAgentApplicationDialoguesRecordService
;
import
cn.com.poc.agent_application.service.*
;
import
cn.com.poc.agent_application.service.BizAgentApplicationGcConfigService
;
import
cn.com.poc.agent_application.service.BizAgentApplicationPublishService
;
import
cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
import
cn.com.poc.agent_application.utils.AgentApplicationTools
;
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.constant.XLangConstant
;
...
@@ -111,6 +105,9 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -111,6 +105,9 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
@Resource
@Resource
private
DataAnalyzeReportService
dataAnalyzeReportService
;
private
DataAnalyzeReportService
dataAnalyzeReportService
;
@Resource
private
BizAgentApplicationApiProfileService
bizAgentApplicationApiProfileService
;
@Override
@Override
public
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
List
<
String
>
fileUrls
,
String
channel
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
public
void
callAgentApplication
(
String
agentId
,
String
dialogsId
,
String
input
,
List
<
String
>
fileUrls
,
String
channel
,
HttpServletResponse
httpServletResponse
)
throws
Exception
{
...
@@ -172,10 +169,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -172,10 +169,10 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
Long
deducted
=
infoEntity
.
getMemberId
().
longValue
()
==
0L
?
userBaseEntity
.
getUserId
()
:
infoEntity
.
getMemberId
();
Long
deducted
=
infoEntity
.
getMemberId
().
longValue
()
==
0L
?
userBaseEntity
.
getUserId
()
:
infoEntity
.
getMemberId
();
try
{
try
{
reduceSn
=
memberEquityService
.
reducePoint
(
deducted
,
pointDeductionNum
,
ModifyEventEnum
.
use
,
agentUseModifyEventInfo
);
reduceSn
=
memberEquityService
.
reducePoint
(
deducted
,
pointDeductionNum
,
ModifyEventEnum
.
use
,
agentUseModifyEventInfo
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
if
(
deducted
.
equals
(
userBaseEntity
.
getUserId
())){
if
(
deducted
.
equals
(
userBaseEntity
.
getUserId
()))
{
throw
new
I18nMessageException
(
"equity/not.enough.points"
);
throw
new
I18nMessageException
(
"equity/not.enough.points"
);
}
else
{
}
else
{
throw
new
I18nMessageException
(
"equity/creator.points.cannot.be.used"
);
throw
new
I18nMessageException
(
"equity/creator.points.cannot.be.used"
);
}
}
}
}
...
@@ -344,6 +341,16 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
...
@@ -344,6 +341,16 @@ public class AgentApplicationServiceImpl implements AgentApplicationService {
return
autoPlay
;
return
autoPlay
;
}
}
@Override
public
BizAgentApplicationApiProfileEntity
getApiProfile
(
Long
memberId
)
{
BizAgentApplicationApiProfileEntity
agentApplicationApiProfileEntity
=
bizAgentApplicationApiProfileService
.
getByMemberId
(
memberId
);
if
(
null
==
agentApplicationApiProfileEntity
)
{
// 如果没有配置API,则初始化一个默认的API配置
agentApplicationApiProfileEntity
=
bizAgentApplicationApiProfileService
.
initProfile
(
memberId
);
}
return
agentApplicationApiProfileEntity
;
}
private
void
createCNQuestion
()
{
private
void
createCNQuestion
()
{
Message
message
=
new
Message
();
Message
message
=
new
Message
();
message
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
message
.
setRole
(
LLMRoleEnum
.
USER
.
getRole
());
...
...
src/main/java/cn/com/poc/expose/dto/AgentApplicationApiProfileDto.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
expose
.
dto
;
import
java.io.Serializable
;
/**
* @author alex.yao
* @date 2024/12/18
*/
public
class
AgentApplicationApiProfileDto
implements
Serializable
{
private
String
apiKey
;
private
String
apiSecret
;
public
String
getApiKey
()
{
return
apiKey
;
}
public
void
setApiKey
(
String
apiKey
)
{
this
.
apiKey
=
apiKey
;
}
public
String
getApiSecret
()
{
return
apiSecret
;
}
public
void
setApiSecret
(
String
apiSecret
)
{
this
.
apiSecret
=
apiSecret
;
}
}
src/main/java/cn/com/poc/expose/rest/AgentApplicationRest.java
View file @
b082a584
...
@@ -100,4 +100,12 @@ public interface AgentApplicationRest extends BaseRest {
...
@@ -100,4 +100,12 @@ public interface AgentApplicationRest extends BaseRest {
* @param autoPlay 自动播放配置 Y/N
* @param autoPlay 自动播放配置 Y/N
*/
*/
String
enableAutoPlay
(
@RequestParam
String
agentId
,
@RequestParam
String
autoPlay
);
String
enableAutoPlay
(
@RequestParam
String
agentId
,
@RequestParam
String
autoPlay
);
/**
* 获取应用的API配置
*
* @return 应用API配置
*/
AgentApplicationApiProfileDto
getApiProfile
();
}
}
src/main/java/cn/com/poc/expose/rest/impl/AgentApplicationRestImpl.java
View file @
b082a584
...
@@ -6,6 +6,7 @@ import cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert;
...
@@ -6,6 +6,7 @@ import cn.com.poc.agent_application.convert.BizAgentApplicationPublishConvert;
import
cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto
;
import
cn.com.poc.agent_application.dto.AgentApplicationCreateContinueQuesDto
;
import
cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto
;
import
cn.com.poc.agent_application.dto.AgentApplicationInfoSearchDto
;
import
cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto
;
import
cn.com.poc.agent_application.dto.BizAgentApplicationPublishDto
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationDialoguesRecordEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationPublishEntity
;
import
cn.com.poc.agent_application.query.*
;
import
cn.com.poc.agent_application.query.*
;
...
@@ -18,7 +19,6 @@ import cn.com.poc.common.utils.StringUtils;
...
@@ -18,7 +19,6 @@ import cn.com.poc.common.utils.StringUtils;
import
cn.com.poc.common.utils.UUIDTool
;
import
cn.com.poc.common.utils.UUIDTool
;
import
cn.com.poc.equity.aggregate.PointDeductionRulesService
;
import
cn.com.poc.equity.aggregate.PointDeductionRulesService
;
import
cn.com.poc.equity.entity.BizPointDeductionRulesEntity
;
import
cn.com.poc.equity.entity.BizPointDeductionRulesEntity
;
import
cn.com.poc.equity.service.BizPointDeductionRulesService
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.dto.*
;
import
cn.com.poc.expose.dto.*
;
import
cn.com.poc.expose.rest.AgentApplicationRest
;
import
cn.com.poc.expose.rest.AgentApplicationRest
;
...
@@ -259,4 +259,14 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
...
@@ -259,4 +259,14 @@ public class AgentApplicationRestImpl implements AgentApplicationRest {
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
UserBaseEntity
currentUser
=
BlContext
.
getCurrentUser
();
return
agentApplicationService
.
enableAutoPlay
(
currentUser
.
getUserId
(),
agentId
,
autoPlay
);
return
agentApplicationService
.
enableAutoPlay
(
currentUser
.
getUserId
(),
agentId
,
autoPlay
);
}
}
@Override
public
AgentApplicationApiProfileDto
getApiProfile
()
{
UserBaseEntity
userBaseEntity
=
BlContext
.
getCurrentUser
();
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplicationService
.
getApiProfile
(
userBaseEntity
.
getUserId
());
AgentApplicationApiProfileDto
result
=
new
AgentApplicationApiProfileDto
();
result
.
setApiKey
(
apiProfileEntity
.
getApiKey
());
result
.
setApiSecret
(
apiProfileEntity
.
getApiSecret
());
return
result
;
}
}
}
src/test/java/cn/com/poc/agent_application/AgentApplicationApiProfileTest.java
0 → 100644
View file @
b082a584
package
cn
.
com
.
poc
.
agent_application
;
import
cn.com.poc.agent_application.entity.BizAgentApplicationApiProfileEntity
;
import
cn.com.poc.agent_application.service.BizAgentApplicationApiProfileService
;
import
cn.com.poc.common.utils.JsonUtils
;
import
cn.com.poc.expose.aggregate.AgentApplicationService
;
import
cn.com.poc.expose.dto.AgentApplicationApiProfileDto
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
javax.annotation.Resource
;
import
java.io.UnsupportedEncodingException
;
import
java.security.NoSuchAlgorithmException
;
/**
* @author alex.yao
* @date 2024/12/19
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AgentApplicationApiProfileTest
{
@Resource
private
BizAgentApplicationApiProfileService
bizAgentApplicationApiProfileService
;
@Test
public
void
test_initProfile
()
throws
Exception
,
NoSuchAlgorithmException
,
UnsupportedEncodingException
{
bizAgentApplicationApiProfileService
.
initProfile
(
197L
);
}
@Resource
private
AgentApplicationService
agentApplicationService
;
@Test
public
void
test_getApiProfile
()
{
String
agentId
=
"d37d4a9b2fe0421ea991127c247fbbf3"
;
BizAgentApplicationApiProfileEntity
apiProfileEntity
=
agentApplicationService
.
getApiProfile
(
197L
);
AgentApplicationApiProfileDto
result
=
new
AgentApplicationApiProfileDto
();
result
.
setApiKey
(
apiProfileEntity
.
getApiKey
());
result
.
setApiSecret
(
apiProfileEntity
.
getApiSecret
());
System
.
out
.
println
(
JsonUtils
.
serialize
(
result
));
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment