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
3e64b773
Commit
3e64b773
authored
Nov 27, 2024
by
alex yao
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 获取音色列表 / 获取音色详情
parent
306dd349
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1014 additions
and
0 deletions
+1014
-0
pom.xml
pom.xml
+6
-0
BizVoiceTimbreConvert.java
...java/cn/com/poc/timbre/convert/BizVoiceTimbreConvert.java
+128
-0
GetTimbreDto.java
src/main/java/cn/com/poc/timbre/dto/GetTimbreDto.java
+32
-0
TimbreInfo.java
src/main/java/cn/com/poc/timbre/dto/TimbreInfo.java
+40
-0
BizVoiceTimbreEntity.java
...n/java/cn/com/poc/timbre/entity/BizVoiceTimbreEntity.java
+163
-0
BizVoiceTimbreModel.java
...ain/java/cn/com/poc/timbre/model/BizVoiceTimbreModel.java
+238
-0
BizVoiceTimbreRepository.java
...n/com/poc/timbre/repository/BizVoiceTimbreRepository.java
+6
-0
BizVoiceTimbreRest.java
src/main/java/cn/com/poc/timbre/rest/BizVoiceTimbreRest.java
+29
-0
BizVoiceTimbreRest.java
.../java/cn/com/poc/timbre/rest/impl/BizVoiceTimbreRest.java
+45
-0
BizVoiceTimbreService.java
...java/cn/com/poc/timbre/service/BizVoiceTimbreService.java
+24
-0
BizVoiceTimbreServiceImpl.java
...om/poc/timbre/service/impl/BizVoiceTimbreServiceImpl.java
+132
-0
AgentApplicationServiceTest.java
...com/poc/expose/aggregate/AgentApplicationServiceTest.java
+83
-0
BizVoiceTimbreRestTest.java
...t/java/cn/com/poc/timbre/rest/BizVoiceTimbreRestTest.java
+88
-0
No files found.
pom.xml
View file @
3e64b773
...
...
@@ -157,6 +157,12 @@
<version>
3.7.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.mockito
</groupId>
<artifactId>
mockito-inline
</artifactId>
<version>
3.7.7
</version>
<scope>
test
</scope>
</dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
...
...
src/main/java/cn/com/poc/timbre/convert/BizVoiceTimbreConvert.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
convert
;
import
cn.com.poc.common.constant.XLangConstant
;
import
cn.com.poc.common.utils.ListUtils
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.dto.TimbreInfo
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
import
cn.hutool.core.collection.ListUtil
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
public
class
BizVoiceTimbreConvert
{
public
static
BizVoiceTimbreEntity
modelToEntity
(
BizVoiceTimbreModel
model
)
{
BizVoiceTimbreEntity
entity
=
new
BizVoiceTimbreEntity
();
entity
.
setId
(
model
.
getId
());
entity
.
setTimbreId
(
model
.
getTimbreId
());
entity
.
setLanguage
(
model
.
getLanguage
());
entity
.
setTimbreName
(
model
.
getTimbreName
());
entity
.
setTimbreNameEn
(
model
.
getTimbreNameEn
());
entity
.
setTimbreNameTw
(
model
.
getTimbreNameTw
());
entity
.
setVoiceUrl
(
model
.
getVoiceUrl
());
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
BizVoiceTimbreModel
entityToModel
(
BizVoiceTimbreEntity
entity
)
{
BizVoiceTimbreModel
model
=
new
BizVoiceTimbreModel
();
model
.
setId
(
entity
.
getId
());
model
.
setTimbreId
(
entity
.
getTimbreId
());
model
.
setLanguage
(
entity
.
getLanguage
());
model
.
setTimbreName
(
entity
.
getTimbreName
());
model
.
setTimbreNameEn
(
entity
.
getTimbreNameEn
());
model
.
setTimbreNameTw
(
entity
.
getTimbreNameTw
());
model
.
setVoiceUrl
(
entity
.
getVoiceUrl
());
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
GetTimbreDto
entityToGetTimbreDto
(
BizVoiceTimbreEntity
entity
,
Locale
locale
)
{
GetTimbreDto
getTimbreDto
=
new
GetTimbreDto
();
getTimbreDto
.
setLanguage
(
entity
.
getLanguage
());
TimbreInfo
timbreInfo
=
setTimbreInfo
(
locale
,
entity
);
getTimbreDto
.
setTimbreInfo
(
ListUtil
.
toList
(
timbreInfo
));
return
getTimbreDto
;
}
/**
* entities转换为GetTimbreDto列表
*
* @param entities
* @param locale 语言 zh-cn 中文简体 en 英文 zh-tw 中文繁体
* @return
*/
public
static
List
<
GetTimbreDto
>
entitiesToGetTimbreDtoList
(
List
<
BizVoiceTimbreEntity
>
entities
,
Locale
locale
)
{
List
<
GetTimbreDto
>
dtos
=
new
ArrayList
<>();
// 初始化三个Dto对象 cnDto 中文 enDto 英文 twDto 粤语
List
<
TimbreInfo
>
cnTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
cnDto
=
new
GetTimbreDto
();
cnDto
.
setLanguage
(
0
);
cnDto
.
setTimbreInfo
(
cnTimbreInfos
);
List
<
TimbreInfo
>
cantonTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
cantonDto
=
new
GetTimbreDto
();
cantonDto
.
setLanguage
(
1
);
cantonDto
.
setTimbreInfo
(
cantonTimbreInfos
);
List
<
TimbreInfo
>
enTimbreInfos
=
new
ArrayList
<>();
GetTimbreDto
enDto
=
new
GetTimbreDto
();
enDto
.
setLanguage
(
2
);
enDto
.
setTimbreInfo
(
enTimbreInfos
);
for
(
BizVoiceTimbreEntity
entity
:
entities
)
{
Integer
language
=
entity
.
getLanguage
();
TimbreInfo
timbreInfo
=
setTimbreInfo
(
locale
,
entity
);
switch
(
language
.
intValue
())
{
case
0
:
cnTimbreInfos
.
add
(
timbreInfo
);
break
;
case
1
:
cantonTimbreInfos
.
add
(
timbreInfo
);
break
;
case
2
:
enTimbreInfos
.
add
(
timbreInfo
);
break
;
}
}
dtos
.
add
(
cnDto
);
dtos
.
add
(
cantonDto
);
dtos
.
add
(
enDto
);
return
dtos
;
}
private
static
TimbreInfo
setTimbreInfo
(
Locale
locale
,
BizVoiceTimbreEntity
entity
)
{
TimbreInfo
timbreInfo
=
new
TimbreInfo
();
timbreInfo
.
setVoiceUrl
(
entity
.
getVoiceUrl
());
if
(
Locale
.
SIMPLIFIED_CHINESE
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreName
());
}
else
if
(
Locale
.
ENGLISH
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreNameEn
());
}
else
if
(
Locale
.
TRADITIONAL_CHINESE
.
equals
(
locale
))
{
timbreInfo
.
setTimbreName
(
entity
.
getTimbreNameTw
());
}
return
timbreInfo
;
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/dto/GetTimbreDto.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
dto
;
import
java.util.List
;
public
class
GetTimbreDto
{
/**
* 音色语言分类 0-中文 1-粤语 2-英文
*/
private
Integer
language
;
/**
* 音色信息
*/
private
List
<
TimbreInfo
>
timbreInfo
;
public
Integer
getLanguage
()
{
return
language
;
}
public
void
setLanguage
(
Integer
language
)
{
this
.
language
=
language
;
}
public
List
<
TimbreInfo
>
getTimbreInfo
()
{
return
timbreInfo
;
}
public
void
setTimbreInfo
(
List
<
TimbreInfo
>
timbreInfo
)
{
this
.
timbreInfo
=
timbreInfo
;
}
}
src/main/java/cn/com/poc/timbre/dto/TimbreInfo.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
dto
;
/**
* 音色信息
* @author alex.yao
*/
public
class
TimbreInfo
{
/**
* 音色ID
*/
private
String
timbreId
;
/**
* 音色名称
*/
private
String
timbreName
;
/**
* 音色预览文件地址
*/
private
String
voiceUrl
;
public
String
getTimbreName
()
{
return
timbreName
;
}
public
void
setTimbreName
(
String
timbreName
)
{
this
.
timbreName
=
timbreName
;
}
public
String
getVoiceUrl
()
{
return
voiceUrl
;
}
public
void
setVoiceUrl
(
String
voiceUrl
)
{
this
.
voiceUrl
=
voiceUrl
;
}
}
src/main/java/cn/com/poc/timbre/entity/BizVoiceTimbreEntity.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
entity
;
public
class
BizVoiceTimbreEntity
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Integer
id
;
public
java
.
lang
.
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Integer
id
){
this
.
id
=
id
;
}
/** timbre_id
*音色ID
*/
private
java
.
lang
.
String
timbreId
;
public
java
.
lang
.
String
getTimbreId
(){
return
this
.
timbreId
;
}
public
void
setTimbreId
(
java
.
lang
.
String
timbreId
){
this
.
timbreId
=
timbreId
;
}
/** language
*音色语言分类 0-中文 1-粤语 2-英文
*/
private
java
.
lang
.
Integer
language
;
public
java
.
lang
.
Integer
getLanguage
(){
return
this
.
language
;
}
public
void
setLanguage
(
java
.
lang
.
Integer
language
){
this
.
language
=
language
;
}
/** timbre_name
*音色名-简体中文
*/
private
java
.
lang
.
String
timbreName
;
public
java
.
lang
.
String
getTimbreName
(){
return
this
.
timbreName
;
}
public
void
setTimbreName
(
java
.
lang
.
String
timbreName
){
this
.
timbreName
=
timbreName
;
}
/** timbre_name_en
*音色名-英文
*/
private
java
.
lang
.
String
timbreNameEn
;
public
java
.
lang
.
String
getTimbreNameEn
(){
return
this
.
timbreNameEn
;
}
public
void
setTimbreNameEn
(
java
.
lang
.
String
timbreNameEn
){
this
.
timbreNameEn
=
timbreNameEn
;
}
/** timbre_name_tw
*音色名-繁体
*/
private
java
.
lang
.
String
timbreNameTw
;
public
java
.
lang
.
String
getTimbreNameTw
(){
return
this
.
timbreNameTw
;
}
public
void
setTimbreNameTw
(
java
.
lang
.
String
timbreNameTw
){
this
.
timbreNameTw
=
timbreNameTw
;
}
/** voice_url
*音色预览地址
*/
private
java
.
lang
.
String
voiceUrl
;
public
java
.
lang
.
String
getVoiceUrl
(){
return
this
.
voiceUrl
;
}
public
void
setVoiceUrl
(
java
.
lang
.
String
voiceUrl
){
this
.
voiceUrl
=
voiceUrl
;
}
/** is_deleted
*是否删除 Y 是 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/timbre/model/BizVoiceTimbreModel.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
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_voice_timbre
* 音频音色表
*/
@Entity
@Table
(
name
=
"biz_voice_timbre"
)
@DynamicInsert
@DynamicUpdate
public
class
BizVoiceTimbreModel
extends
BaseModelClass
implements
Serializable
{
private
static
final
long
serialVersionUID
=
1L
;
/** id
*主键
*/
private
java
.
lang
.
Integer
id
;
@Column
(
name
=
"id"
,
length
=
10
)
@Id
@GeneratedValue
(
strategy
=
GenerationType
.
AUTO
)
public
java
.
lang
.
Integer
getId
(){
return
this
.
id
;
}
public
void
setId
(
java
.
lang
.
Integer
id
){
this
.
id
=
id
;
super
.
addValidField
(
"id"
);
}
/** timbre_id
*音色ID
*/
private
java
.
lang
.
String
timbreId
;
@Column
(
name
=
"timbre_id"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreId
(){
return
this
.
timbreId
;
}
public
void
setTimbreId
(
java
.
lang
.
String
timbreId
){
this
.
timbreId
=
timbreId
;
super
.
addValidField
(
"timbreId"
);
}
/** language
*音色语言分类 0-中文 1-粤语 2-英文
*/
private
java
.
lang
.
Integer
language
;
@Column
(
name
=
"language"
,
length
=
10
)
public
java
.
lang
.
Integer
getLanguage
(){
return
this
.
language
;
}
public
void
setLanguage
(
java
.
lang
.
Integer
language
){
this
.
language
=
language
;
super
.
addValidField
(
"language"
);
}
/** timbre_name
*音色名-简体中文
*/
private
java
.
lang
.
String
timbreName
;
@Column
(
name
=
"timbre_name"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreName
(){
return
this
.
timbreName
;
}
public
void
setTimbreName
(
java
.
lang
.
String
timbreName
){
this
.
timbreName
=
timbreName
;
super
.
addValidField
(
"timbreName"
);
}
/** timbre_name_en
*音色名-英文
*/
private
java
.
lang
.
String
timbreNameEn
;
@Column
(
name
=
"timbre_name_en"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreNameEn
(){
return
this
.
timbreNameEn
;
}
public
void
setTimbreNameEn
(
java
.
lang
.
String
timbreNameEn
){
this
.
timbreNameEn
=
timbreNameEn
;
super
.
addValidField
(
"timbreNameEn"
);
}
/** timbre_name_tw
*音色名-繁体
*/
private
java
.
lang
.
String
timbreNameTw
;
@Column
(
name
=
"timbre_name_tw"
,
length
=
100
)
public
java
.
lang
.
String
getTimbreNameTw
(){
return
this
.
timbreNameTw
;
}
public
void
setTimbreNameTw
(
java
.
lang
.
String
timbreNameTw
){
this
.
timbreNameTw
=
timbreNameTw
;
super
.
addValidField
(
"timbreNameTw"
);
}
/** voice_url
*音色预览地址
*/
private
java
.
lang
.
String
voiceUrl
;
@Column
(
name
=
"voice_url"
,
length
=
120
)
public
java
.
lang
.
String
getVoiceUrl
(){
return
this
.
voiceUrl
;
}
public
void
setVoiceUrl
(
java
.
lang
.
String
voiceUrl
){
this
.
voiceUrl
=
voiceUrl
;
super
.
addValidField
(
"voiceUrl"
);
}
/** is_deleted
*是否删除 Y 是 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
=
50
)
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
=
50
)
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/timbre/repository/BizVoiceTimbreRepository.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
repository
;
import
cn.com.yict.framemax.data.repository.Repository
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
public
interface
BizVoiceTimbreRepository
extends
Repository
<
BizVoiceTimbreModel
,
java
.
lang
.
Integer
>
{
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/rest/BizVoiceTimbreRest.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
rest
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
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.RequestParam
;
import
java.util.List
;
@Permission
(
Access
.
Anonymous
)
public
interface
BizVoiceTimbreRest
extends
BaseRest
{
/**
* 获取音色列表
*
* @return
*/
List
<
GetTimbreDto
>
getTimbreList
()
throws
Exception
;
/**
* 获取音色详情
*
* @param timbreId
*/
GetTimbreDto
getTimbreInfo
(
@RequestParam
String
timbreId
)
;
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/rest/impl/BizVoiceTimbreRest.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
rest
.
impl
;
import
cn.com.poc.timbre.convert.BizVoiceTimbreConvert
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.yict.framemax.core.context.Context
;
import
cn.hutool.core.lang.Assert
;
import
org.apache.commons.collections4.CollectionUtils
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
static
cn
.
com
.
poc
.
timbre
.
convert
.
BizVoiceTimbreConvert
.
entityToGetTimbreDto
;
@Component
public
class
BizVoiceTimbreRest
implements
cn
.
com
.
poc
.
timbre
.
rest
.
BizVoiceTimbreRest
{
@Resource
private
BizVoiceTimbreService
bizVoiceTimbreService
;
@Override
public
List
<
GetTimbreDto
>
getTimbreList
()
throws
Exception
{
Locale
currentLocale
=
Context
.
get
().
getMessageSource
().
getCurrentLocale
();
List
<
GetTimbreDto
>
result
=
new
ArrayList
<>();
List
<
BizVoiceTimbreEntity
>
entities
=
bizVoiceTimbreService
.
findByExample
(
new
BizVoiceTimbreEntity
(),
null
);
if
(
CollectionUtils
.
isNotEmpty
(
entities
))
{
result
=
BizVoiceTimbreConvert
.
entitiesToGetTimbreDtoList
(
entities
,
currentLocale
);
}
return
result
;
}
@Override
public
GetTimbreDto
getTimbreInfo
(
String
timbreId
)
{
Assert
.
notNull
(
timbreId
);
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
bizVoiceTimbreService
.
getByTimbreId
(
timbreId
);
if
(
bizVoiceTimbreEntity
==
null
)
{
return
null
;
}
return
entityToGetTimbreDto
(
bizVoiceTimbreEntity
,
Context
.
get
().
getMessageSource
().
getCurrentLocale
());
}
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/service/BizVoiceTimbreService.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
service
;
import
cn.com.yict.framemax.core.service.BaseService
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
java.util.Collection
;
import
java.util.List
;
public
interface
BizVoiceTimbreService
extends
BaseService
{
BizVoiceTimbreEntity
get
(
java
.
lang
.
Integer
id
)
throws
Exception
;
BizVoiceTimbreEntity
getByTimbreId
(
java
.
lang
.
String
timbreId
);
List
<
BizVoiceTimbreEntity
>
findByExample
(
BizVoiceTimbreEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
;
BizVoiceTimbreEntity
save
(
BizVoiceTimbreEntity
entity
)
throws
Exception
;
BizVoiceTimbreEntity
update
(
BizVoiceTimbreEntity
entity
)
throws
Exception
;
void
deletedById
(
java
.
lang
.
Integer
id
)
throws
Exception
;
}
\ No newline at end of file
src/main/java/cn/com/poc/timbre/service/impl/BizVoiceTimbreServiceImpl.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
service
.
impl
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.yict.framemax.core.service.impl.BaseServiceImpl
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.poc.timbre.model.BizVoiceTimbreModel
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.convert.BizVoiceTimbreConvert
;
import
cn.com.poc.timbre.repository.BizVoiceTimbreRepository
;
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
BizVoiceTimbreServiceImpl
extends
BaseServiceImpl
implements
BizVoiceTimbreService
{
@Resource
private
BizVoiceTimbreRepository
repository
;
public
BizVoiceTimbreEntity
get
(
java
.
lang
.
Integer
id
)
throws
Exception
{
Assert
.
notNull
(
id
);
BizVoiceTimbreModel
model
=
this
.
repository
.
get
(
id
);
if
(
model
==
null
)
{
return
null
;
}
if
(
"Y"
.
equals
(
model
.
getIsDeleted
()))
{
return
null
;
}
return
BizVoiceTimbreConvert
.
modelToEntity
(
model
);
}
@Override
public
BizVoiceTimbreEntity
getByTimbreId
(
String
timbreId
)
{
BizVoiceTimbreModel
bizVoiceTimbreModel
=
new
BizVoiceTimbreModel
();
bizVoiceTimbreModel
.
setTimbreId
(
timbreId
);
bizVoiceTimbreModel
.
setIsDeleted
(
CommonConstant
.
IsDeleted
.
N
);
List
<
BizVoiceTimbreModel
>
models
=
this
.
repository
.
findByExample
(
bizVoiceTimbreModel
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
return
BizVoiceTimbreConvert
.
modelToEntity
(
models
.
get
(
0
));
}
return
null
;
}
public
List
<
BizVoiceTimbreEntity
>
findByExample
(
BizVoiceTimbreEntity
example
,
PagingInfo
pagingInfo
)
throws
Exception
{
List
<
BizVoiceTimbreEntity
>
result
=
new
ArrayList
<
BizVoiceTimbreEntity
>();
BizVoiceTimbreModel
model
=
new
BizVoiceTimbreModel
();
if
(
example
!=
null
)
{
model
=
BizVoiceTimbreConvert
.
entityToModel
(
example
);
}
model
.
setIsDeleted
(
"N"
);
List
<
BizVoiceTimbreModel
>
models
=
this
.
repository
.
findByExample
(
model
,
pagingInfo
);
if
(
CollectionUtils
.
isNotEmpty
(
models
))
{
result
=
models
.
stream
().
map
(
BizVoiceTimbreConvert:
:
modelToEntity
).
collect
(
Collectors
.
toList
());
}
return
result
;
}
public
BizVoiceTimbreEntity
save
(
BizVoiceTimbreEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
entity
.
setId
(
null
);
entity
.
setIsDeleted
(
"N"
);
BizVoiceTimbreModel
model
=
BizVoiceTimbreConvert
.
entityToModel
(
entity
);
BizVoiceTimbreModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizVoiceTimbreConvert
.
modelToEntity
(
saveModel
);
}
public
BizVoiceTimbreEntity
update
(
BizVoiceTimbreEntity
entity
)
throws
Exception
{
Assert
.
notNull
(
entity
);
Assert
.
notNull
(
entity
.
getId
(),
"update pk can not be null"
);
BizVoiceTimbreModel
model
=
this
.
repository
.
get
(
entity
.
getId
());
if
(
entity
.
getTimbreId
()
!=
null
)
{
model
.
setTimbreId
(
entity
.
getTimbreId
());
}
if
(
entity
.
getLanguage
()
!=
null
)
{
model
.
setLanguage
(
entity
.
getLanguage
());
}
if
(
entity
.
getTimbreName
()
!=
null
)
{
model
.
setTimbreName
(
entity
.
getTimbreName
());
}
if
(
entity
.
getTimbreNameEn
()
!=
null
)
{
model
.
setTimbreNameEn
(
entity
.
getTimbreNameEn
());
}
if
(
entity
.
getTimbreNameTw
()
!=
null
)
{
model
.
setTimbreNameTw
(
entity
.
getTimbreNameTw
());
}
if
(
entity
.
getVoiceUrl
()
!=
null
)
{
model
.
setVoiceUrl
(
entity
.
getVoiceUrl
());
}
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
());
}
BizVoiceTimbreModel
saveModel
=
this
.
repository
.
save
(
model
);
return
BizVoiceTimbreConvert
.
modelToEntity
(
saveModel
);
}
public
void
deletedById
(
java
.
lang
.
Integer
id
)
throws
Exception
{
Assert
.
notNull
(
id
);
BizVoiceTimbreModel
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
src/test/java/cn/com/poc/expose/aggregate/AgentApplicationServiceTest.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
expose
.
aggregate
;
import
cn.com.poc.agent_application.query.MemberCollectQueryCondition
;
import
cn.com.poc.agent_application.query.MemberCollectQueryItem
;
import
cn.com.poc.agent_application.service.BizMemberAgentApplicationCollectService
;
import
cn.com.poc.common.constant.CommonConstant
;
import
cn.com.poc.expose.aggregate.impl.AgentApplicationServiceImpl
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
cn.com.yict.framemax.data.model.PagingInfo
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.InjectMocks
;
import
org.mockito.Mock
;
import
org.mockito.Mockito
;
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.util.ArrayList
;
import
java.util.List
;
import
static
org
.
junit
.
Assert
.
assertEquals
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@ContextConfiguration
(
initializers
=
SingleContextInitializer
.
class
)
@WebAppConfiguration
public
class
AgentApplicationServiceTest
{
private
BizMemberAgentApplicationCollectService
bizMemberAgentApplicationCollectService
;
@Resource
private
AgentApplicationServiceImpl
agentApplicationService
;
private
Long
memberId
;
private
PagingInfo
pagingInfo
;
private
MemberCollectQueryCondition
condition
;
private
List
<
MemberCollectQueryItem
>
memberCollectQueryItems
;
@Before
public
void
setUp
()
{
memberId
=
1L
;
pagingInfo
=
new
PagingInfo
();
condition
=
new
MemberCollectQueryCondition
();
condition
.
setMemberId
(
memberId
);
condition
.
setIsCollect
(
CommonConstant
.
YOrN
.
Y
);
memberCollectQueryItems
=
new
ArrayList
<>();
memberCollectQueryItems
.
add
(
new
MemberCollectQueryItem
());
bizMemberAgentApplicationCollectService
=
Mockito
.
mock
(
BizMemberAgentApplicationCollectService
.
class
);
}
@Test
public
void
testGetCollectedApplications
()
{
// Mock the behavior of bizMemberAgentApplicationCollectService
when
(
bizMemberAgentApplicationCollectService
.
queryMemberCollect
(
condition
,
pagingInfo
)).
thenReturn
(
memberCollectQueryItems
);
// Call the method to be tested
List
<
MemberCollectQueryItem
>
result
=
agentApplicationService
.
getCollectedApplications
(
memberId
,
pagingInfo
);
// Verify that the service method was called with the correct parameters
Mockito
.
verify
(
bizMemberAgentApplicationCollectService
).
queryMemberCollect
(
condition
,
pagingInfo
);
}
@Test
public
void
autoPlayByAgentId
()
{
Long
memberId
=
197L
;
String
agentId
=
"bde291ad70f340458e7c6d8ef572eb59"
;
System
.
out
.
println
(
agentApplicationService
.
autoPlayByAgentId
(
memberId
,
agentId
));
}
@Test
public
void
enableAutoPlay
()
{
Long
memberId
=
197L
;
String
agentId
=
"bde291ad70f340458e7c6d8ef572eb59"
;
String
autoPlay
=
CommonConstant
.
YOrN
.
Y
;
String
result
=
agentApplicationService
.
enableAutoPlay
(
memberId
,
agentId
,
autoPlay
);
System
.
out
.
println
(
result
);
}
}
src/test/java/cn/com/poc/timbre/rest/BizVoiceTimbreRestTest.java
0 → 100644
View file @
3e64b773
package
cn
.
com
.
poc
.
timbre
.
rest
;
import
cn.com.poc.timbre.dto.GetTimbreDto
;
import
cn.com.poc.timbre.entity.BizVoiceTimbreEntity
;
import
cn.com.poc.timbre.rest.impl.BizVoiceTimbreRest
;
import
cn.com.poc.timbre.service.BizVoiceTimbreService
;
import
cn.com.yict.framemax.core.context.Context
;
import
cn.com.yict.framemax.core.i18n.BundleMessageSourceImplementor
;
import
cn.com.yict.framemax.core.spring.SingleContextInitializer
;
import
org.junit.After
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.mockito.*
;
import
org.mockito.junit.MockitoJUnitRunner
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Locale
;
import
static
org
.
junit
.
Assert
.*;
import
static
org
.
mockito
.
ArgumentMatchers
.
any
;
import
static
org
.
mockito
.
ArgumentMatchers
.
isNull
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
when
;
@RunWith
(
MockitoJUnitRunner
.
class
)
public
class
BizVoiceTimbreRestTest
{
MockedStatic
<
Context
>
mockedContext
;
@Mock
private
BizVoiceTimbreService
bizVoiceTimbreService
;
@InjectMocks
private
BizVoiceTimbreRest
bizVoiceTimbreRest
;
@Before
public
void
setUp
()
throws
Exception
{
// // Given
List
<
BizVoiceTimbreEntity
>
entities
=
new
ArrayList
<>();
BizVoiceTimbreEntity
bizVoiceTimbreEntity
=
new
BizVoiceTimbreEntity
();
bizVoiceTimbreEntity
.
setId
(
0
);
bizVoiceTimbreEntity
.
setTimbreId
(
"12341423AA"
);
bizVoiceTimbreEntity
.
setLanguage
(
0
);
bizVoiceTimbreEntity
.
setTimbreName
(
"1"
);
bizVoiceTimbreEntity
.
setTimbreNameEn
(
"one"
);
bizVoiceTimbreEntity
.
setTimbreNameTw
(
"一"
);
bizVoiceTimbreEntity
.
setVoiceUrl
(
"http://"
);
bizVoiceTimbreEntity
.
setIsDeleted
(
"N"
);
bizVoiceTimbreEntity
.
setModifiedTime
(
new
Date
());
bizVoiceTimbreEntity
.
setSysVersion
(
0
);
entities
.
add
(
bizVoiceTimbreEntity
);
when
(
bizVoiceTimbreService
.
findByExample
(
any
(),
ArgumentMatchers
.
isNull
())).
thenReturn
(
entities
);
when
(
bizVoiceTimbreService
.
getByTimbreId
(
any
())).
thenReturn
(
bizVoiceTimbreEntity
);
mockedContext
=
Mockito
.
mockStatic
(
Context
.
class
);
Context
mockContext
=
mock
(
Context
.
class
);
BundleMessageSourceImplementor
bundleMessageSource
=
mock
(
BundleMessageSourceImplementor
.
class
);
mockedContext
.
when
(
Context:
:
get
).
thenReturn
(
mockContext
);
mockedContext
.
when
(
Context
.
get
()::
getMessageSource
).
thenReturn
(
bundleMessageSource
);
when
(
bundleMessageSource
.
getCurrentLocale
()).
thenReturn
(
Locale
.
ENGLISH
);
}
@Test
public
void
getTimbreListTest
()
throws
Exception
{
// When
List
<
GetTimbreDto
>
result
=
bizVoiceTimbreRest
.
getTimbreList
();
// Then
assertEquals
(
3
,
result
.
size
());
}
@Test
public
void
getTimbreInfo
()
{
GetTimbreDto
timbreInfo
=
bizVoiceTimbreRest
.
getTimbreInfo
(
"12341423AA"
);
assertNotNull
(
timbreInfo
);
when
(
bizVoiceTimbreService
.
getByTimbreId
(
any
())).
thenReturn
(
isNull
());
timbreInfo
=
bizVoiceTimbreRest
.
getTimbreInfo
(
"12341423AA"
);
assertNull
(
timbreInfo
);
}
@After
public
void
close
(){
mockedContext
.
close
();
}
}
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