Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
842947d7
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
842947d7
编写于
4月 28, 2022
作者:
O
o2sword
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
新版应用市场开发1
上级
730d0c49
变更
14
展开全部
隐藏空白更改
内联
并排
Showing
14 changed file
with
833 addition
and
508 deletion
+833
-508
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Collect.java
...src/main/java/com/x/base/core/project/config/Collect.java
+1
-1
o2server/x_program_center/src/main/java/com/x/program/center/Business.java
...m_center/src/main/java/com/x/program/center/Business.java
+21
-15
o2server/x_program_center/src/main/java/com/x/program/center/ThisApplication.java
...r/src/main/java/com/x/program/center/ThisApplication.java
+8
-29
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/collect/ActionRegist.java
...java/com/x/program/center/jaxrs/collect/ActionRegist.java
+2
-5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/collect/ActionValidateDirect.java
.../x/program/center/jaxrs/collect/ActionValidateDirect.java
+2
-5
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionGet.java
...ain/java/com/x/program/center/jaxrs/market/ActionGet.java
+59
-34
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java
.../x/program/center/jaxrs/market/ActionInstallOrUpdate.java
+276
-271
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionIsVip.java
...n/java/com/x/program/center/jaxrs/market/ActionIsVip.java
+43
-0
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListCategory.java
...com/x/program/center/jaxrs/market/ActionListCategory.java
+41
-27
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListPaging.java
...a/com/x/program/center/jaxrs/market/ActionListPaging.java
+56
-76
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionSync.java
...in/java/com/x/program/center/jaxrs/market/ActionSync.java
+0
-23
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java
...in/java/com/x/program/center/jaxrs/market/BaseAction.java
+302
-2
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/MarketAction.java
.../java/com/x/program/center/jaxrs/market/MarketAction.java
+18
-18
o2server/x_program_center/src/main/java/com/x/program/center/schedule/CollectMarket.java
...ain/java/com/x/program/center/schedule/CollectMarket.java
+4
-2
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Collect.java
浏览文件 @
842947d7
...
...
@@ -36,7 +36,7 @@ public class Collect extends ConfigObject {
public
static
String
ADDRESS_COLLECT_VALIDATE_CODE
=
"/o2_collect_assemble/jaxrs/unit/validate/codeanswer"
;
public
static
String
ADDRESS_COLLECT_APPLICATION_LIST
=
"/o2_collect_assemble/jaxrs/application/list"
;
public
static
String
ADDRESS_COLLECT_MARKET
=
"/market"
;
public
static
String
ADDRESS_COLLECT_APPLICATION_DOWN
=
"/o2_collect_assemble/jaxrs/application/download"
;
public
static
String
ADDRESS_COLLECT_APPLICATION_DOWN
=
"/o2_collect_assemble/jaxrs/application
2
/download"
;
public
static
String
COLLECT_TOKEN
=
"c-token"
;
public
static
String
ADDRESS_APPPACK_AUTH
=
"/auth/collect"
;
public
static
String
ADDRESS_APPPACK_SAVE
=
"/pack/info/save"
;
...
...
o2server/x_program_center/src/main/java/com/x/program/center/Business.java
浏览文件 @
842947d7
...
...
@@ -4,11 +4,10 @@ import java.io.ByteArrayInputStream;
import
java.io.DataInputStream
;
import
java.io.DataOutputStream
;
import
java.net.Socket
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
com.x.base.core.project.tools.DateTools
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.container.EntityManagerContainer
;
...
...
@@ -34,6 +33,8 @@ public class Business {
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
Business
.
class
);
private
static
Map
<
String
,
String
>
tokenMap
=
new
HashMap
();
private
EntityManagerContainer
emc
;
public
Business
(
EntityManagerContainer
emc
)
throws
Exception
{
...
...
@@ -88,18 +89,23 @@ public class Business {
return
resp
.
getData
(
WoValidateCollect
.
class
).
getValue
();
}
public
String
loginCollect
()
throws
Exception
{
String
url
=
Config
.
collect
().
url
(
Collect
.
ADDRESS_COLLECT_LOGIN
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"credential"
,
Config
.
collect
().
getName
());
map
.
put
(
"password"
,
Config
.
collect
().
getPassword
());
ActionResponse
resp
=
ConnectionAction
.
post
(
url
,
null
,
map
);
LoginWo
loginWo
=
resp
.
getData
(
LoginWo
.
class
);
if
(
loginWo
!=
null
)
{
return
loginWo
.
getToken
();
}
else
{
return
null
;
public
static
String
loginCollect
()
throws
Exception
{
String
date
=
DateTools
.
compactDate
(
new
Date
());
if
(
tokenMap
.
get
(
date
)!=
null
){
return
tokenMap
.
get
(
date
);
}
else
if
(
BooleanUtils
.
isTrue
(
Config
.
collect
().
getEnable
()))
{
String
url
=
Config
.
collect
().
url
(
Collect
.
ADDRESS_COLLECT_LOGIN
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
"credential"
,
Config
.
collect
().
getName
());
map
.
put
(
"password"
,
Config
.
collect
().
getPassword
());
ActionResponse
resp
=
ConnectionAction
.
post
(
url
,
null
,
map
);
LoginWo
loginWo
=
resp
.
getData
(
LoginWo
.
class
);
if
(
loginWo
!=
null
)
{
tokenMap
.
put
(
date
,
loginWo
.
getToken
());
return
loginWo
.
getToken
();
}
}
return
null
;
}
public
String
getUnitName
()
throws
Exception
{
...
...
o2server/x_program_center/src/main/java/com/x/program/center/ThisApplication.java
浏览文件 @
842947d7
package
com.x.program.center
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.ArrayBlockingQueue
;
import
java.util.concurrent.ExecutorService
;
import
java.util.concurrent.ThreadFactory
;
import
java.util.concurrent.ThreadPoolExecutor
;
import
java.util.concurrent.TimeUnit
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Config
;
import
com.x.program.center.schedule.Area
;
import
com.x.program.center.schedule.Cleanup
;
import
com.x.program.center.schedule.CleanupCode
;
import
com.x.program.center.schedule.CollectLog
;
import
com.x.program.center.schedule.CollectMarket
;
import
com.x.program.center.schedule.CollectPerson
;
import
com.x.program.center.schedule.DingdingSyncOrganization
;
import
com.x.program.center.schedule.DingdingSyncOrganizationTrigger
;
import
com.x.program.center.schedule.FireSchedule
;
import
com.x.program.center.schedule.QiyeweixinSyncOrganization
;
import
com.x.program.center.schedule.QiyeweixinSyncOrganizationTrigger
;
import
com.x.program.center.schedule.TriggerAgent
;
import
com.x.program.center.schedule.WeLinkSyncOrganization
;
import
com.x.program.center.schedule.WeLinkSyncOrganizationTrigger
;
import
com.x.program.center.schedule.ZhengwuDingdingSyncOrganization
;
import
com.x.program.center.schedule.ZhengwuDingdingSyncOrganizationTrigger
;
import
com.x.program.center.schedule.*
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.concurrent.*
;
public
class
ThisApplication
{
...
...
@@ -115,7 +95,6 @@ public class ThisApplication {
context
().
scheduleLocal
(
CleanupCode
.
class
,
10
,
60
*
30
);
context
().
scheduleLocal
(
Cleanup
.
class
,
10
,
60
*
30
);
context
().
scheduleLocal
(
CollectPerson
.
class
,
10
,
60
*
30
);
context
().
scheduleLocal
(
CollectMarket
.
class
,
10
,
60
*
60
*
10
);
context
().
scheduleLocal
(
CollectLog
.
class
,
10
,
60
*
30
);
// 运行间隔由60秒缩减到30秒
context
().
scheduleLocal
(
TriggerAgent
.
class
,
150
,
30
);
...
...
@@ -134,4 +113,4 @@ public class ThisApplication {
}
}
}
\ No newline at end of file
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/collect/ActionRegist.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.collect
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
...
...
@@ -15,8 +12,9 @@ import com.x.base.core.project.http.EffectivePerson;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.program.center.ThisApplication
;
import
com.x.program.center.schedule.CollectMarket
;
import
com.x.program.center.schedule.CollectPerson
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
class
ActionRegist
extends
BaseAction
{
...
...
@@ -62,7 +60,6 @@ class ActionRegist extends BaseAction {
this
.
configFlush
(
effectivePerson
);
// 人员和应用市场同步
ThisApplication
.
context
().
scheduleLocal
(
CollectPerson
.
class
);
ThisApplication
.
context
().
scheduleLocal
(
CollectMarket
.
class
);
}
result
.
setData
(
wo
);
return
result
;
...
...
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/collect/ActionValidateDirect.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.collect
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.program.center.ThisApplication
;
import
com.x.program.center.schedule.CollectMarket
;
import
com.x.program.center.schedule.CollectPerson
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
class
ActionValidateDirect
extends
BaseAction
{
...
...
@@ -44,7 +42,6 @@ class ActionValidateDirect extends BaseAction {
Config
.
flush
();
/* 人员和应用市场同步 */
ThisApplication
.
context
().
scheduleLocal
(
CollectPerson
.
class
);
ThisApplication
.
context
().
scheduleLocal
(
CollectMarket
.
class
);
}
result
.
setData
(
wo
);
return
result
;
...
...
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionGet.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.market
;
import
java.util.ArrayList
;
import
java.util.List
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.enums.CommonStatus
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.exception.ExceptionEntityNotExist
;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.program.center.core.entity.Application
;
import
com.x.program.center.core.entity.Attachment
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.program.center.Business
;
import
com.x.program.center.core.entity.InstallLog
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionGet
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionGet
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
,
String
id
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Application
app
=
emc
.
find
(
id
,
Application
.
class
);
if
(
null
==
app
)
{
throw
new
ExceptionEntityNotExist
(
id
,
Application
.
class
);
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
effectivePerson
.
getDistinguishedName
());
}
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
Cache
.
CacheKey
cacheKey
=
new
Cache
.
CacheKey
(
ActionGet
.
class
,
id
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
wo
=
(
Wo
)
optional
.
get
();
}
else
{
String
token
=
Business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
ActionResponse
response
=
ConnectionAction
.
get
(
Config
.
collect
().
url
(
COLLECT_MARKET_INFO
+
id
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
wo
=
response
.
getData
(
Wo
.
class
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"get market info form o2cloud error: {}."
,
e
.
getMessage
());
}
}
Wo
wo
=
Wo
.
copier
.
copy
(
app
);
wo
.
setAttList
(
emc
.
listEqual
(
Attachment
.
class
,
Attachment
.
application_FIELDNAME
,
wo
.
getId
()));
InstallLog
installLog
=
emc
.
find
(
id
,
InstallLog
.
class
);
if
(
installLog
!=
null
&&
CommonStatus
.
VALID
.
getValue
().
equals
(
installLog
.
getStatus
())){
wo
.
setInstalledVersion
(
installLog
.
getVersion
());
}
else
{
wo
.
setInstalledVersion
(
""
);
if
(
StringUtils
.
isNotBlank
(
wo
.
getId
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
InstallLog
installLog
=
emc
.
find
(
wo
.
getId
(),
InstallLog
.
class
);
if
(
installLog
!=
null
&&
CommonStatus
.
VALID
.
getValue
().
equals
(
installLog
.
getStatus
()))
{
wo
.
setInstalledVersion
(
installLog
.
getVersion
());
}
else
{
wo
.
setInstalledVersion
(
""
);
}
result
.
setData
(
wo
);
}
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
}
result
.
setData
(
wo
);
return
result
;
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wo
extends
Application
{
private
static
final
long
serialVersionUID
=
-
4000191514240350631L
;
static
WrapCopier
<
Application
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
Application
.
class
,
Wo
.
class
,
null
,
Wo
.
FieldsInvisible
);
public
static
class
Wo
extends
Application2
{
@FieldDescribe
(
"
图片列表
"
)
private
List
<
Attachment
>
att
List
=
new
ArrayList
<>();
@FieldDescribe
(
"
展示图片url列表.
"
)
private
List
<
String
>
pic
List
=
new
ArrayList
<>();
@FieldDescribe
(
"已安装的版本,空表示未安装"
)
private
String
installedVersion
;
public
List
<
Attachment
>
getAtt
List
()
{
return
att
List
;
public
List
<
String
>
getPic
List
()
{
return
pic
List
;
}
public
void
set
AttList
(
List
<
Attachment
>
att
List
)
{
this
.
attList
=
att
List
;
public
void
set
PicList
(
List
<
String
>
pic
List
)
{
this
.
picList
=
pic
List
;
}
public
String
getInstalledVersion
()
{
...
...
@@ -66,4 +91,4 @@ class ActionGet extends BaseAction {
this
.
installedVersion
=
installedVersion
;
}
}
}
\ No newline at end of file
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionInstallOrUpdate.java
浏览文件 @
842947d7
此差异已折叠。
点击以展开。
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionIsVip.java
0 → 100644
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.market
;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.program.center.Business
;
import
org.apache.commons.lang3.StringUtils
;
class
ActionIsVip
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionIsVip
.
class
);
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
wo
.
setValue
(
false
);
String
token
=
Business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
ActionResponse
response
=
ConnectionAction
.
get
(
Config
.
collect
().
url
(
COLLECT_UNIT_IS_VIP
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
wo
=
response
.
getData
(
Wo
.
class
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"check unit is vip form o2cloud error: {}."
,
e
.
getMessage
());
}
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wo
extends
WrapBoolean
{
}
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListCategory.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.market
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
javax.persistence.EntityManager
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Root
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapStringList
;
import
com.x.program.center.core.entity.Application
;
import
com.x.program.center.core.entity.Application_
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.program.center.Business
;
import
org.apache.commons.lang3.StringUtils
;
class
ActionListCategory
extends
BaseAction
{
import
java.util.Optional
;
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
class
ActionListCategory
extends
BaseAction
{
EntityManager
em
=
emc
.
get
(
Application
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Application
>
root
=
cq
.
from
(
Application
.
class
);
cq
.
select
(
root
.
get
(
Application_
.
category
));
List
<
String
>
categoryList
=
em
.
createQuery
(
cq
).
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionListCategory
.
class
);
Wo
wo
=
new
Wo
();
wo
.
setValueList
(
categoryList
);
result
.
setData
(
wo
);
return
result
;
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
if
(
logger
.
isDebugEnabled
())
{
logger
.
debug
(
effectivePerson
.
getDistinguishedName
());
}
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
Cache
.
CacheKey
cacheKey
=
new
Cache
.
CacheKey
(
ActionListCategory
.
class
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
wo
=
(
Wo
)
optional
.
get
();
}
else
{
String
token
=
Business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
ActionResponse
response
=
ConnectionAction
.
get
(
Config
.
collect
().
url
(
COLLECT_MARKET_CATEGORY
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)));
wo
=
response
.
getData
(
Wo
.
class
);
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wo
);
}
catch
(
Exception
e
)
{
logger
.
warn
(
"get market Category form o2cloud error: {}."
,
e
.
getMessage
());
}
}
}
result
.
setData
(
wo
);
return
result
;
}
public
static
class
Wo
extends
WrapStringList
{
}
}
\ No newline at end of file
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionListPaging.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.market
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
javax.persistence.EntityManager
;
import
javax.persistence.Tuple
;
import
javax.persistence.criteria.CriteriaBuilder
;
import
javax.persistence.criteria.CriteriaQuery
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.google.gson.JsonElement
;
import
com.google.gson.JsonObject
;
import
com.x.base.core.container.EntityManagerContainer
;
import
com.x.base.core.container.factory.EntityManagerContainerFactory
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.enums.CommonStatus
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.bean.WrapCopier
;
import
com.x.base.core.project.bean.WrapCopierFactory
;
import
com.x.base.core.project.bean.NameValuePair
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Collect
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.connection.ActionResponse
;
import
com.x.base.core.project.connection.ConnectionAction
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.tools.DateTools
;
import
com.x.base.core.project.tools.StringTools
;
import
com.x.base.core.project.logger.Logger
;
import
com.x.base.core.project.logger.LoggerFactory
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.MD5Tool
;
import
com.x.program.center.Business
;
import
com.x.program.center.core.entity.Application
;
import
com.x.program.center.core.entity.Application_
;
import
com.x.program.center.core.entity.InstallLog
;
import
org.apache.commons.lang3.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
class
ActionListPaging
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
ActionListPaging
.
class
);
ActionResult
<
List
<
Wo
>>
execute
(
EffectivePerson
effectivePerson
,
Integer
page
,
Integer
size
,
JsonElement
jsonElement
)
throws
Exception
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>(
);
Wi
wi
=
this
.
convertToWrapIn
(
jsonElement
,
Wi
.
class
);
Predicate
p
=
this
.
toFilterPredicate
(
effectivePerson
,
business
,
wi
);
String
orderBy
=
Application
.
createTime_FIELDNAME
;
if
(
StringUtils
.
isNotEmpty
(
wi
.
getOrderBy
()))
{
orderBy
=
wi
.
getOrderBy
();
}
List
<
Wo
>
wos
=
new
ArrayList
<>();
if
(
BooleanUtils
.
isTrue
(
wi
.
getAsc
())){
wos
=
emc
.
fetchAscPaging
(
Application
.
class
,
Wo
.
copier
,
p
,
page
,
size
,
orderBy
);
}
else
{
wos
=
emc
.
fetchDescPaging
(
Application
.
class
,
Wo
.
copier
,
p
,
page
,
size
,
orderBy
);
}
for
(
Wo
wo
:
wos
){
InstallLog
installLog
=
emc
.
find
(
wo
.
getId
(),
InstallLog
.
class
);
if
(
installLog
!=
null
&&
CommonStatus
.
VALID
.
getValue
().
equals
(
installLog
.
getStatus
())){
wo
.
setInstalledVersion
(
installLog
.
getVersion
());
}
else
{
wo
.
setInstalledVersion
(
""
);
ActionResult
<
List
<
Wo
>>
result
=
new
ActionResult
<>(
);
List
<
Wo
>
wos
=
new
ArrayList
<>();
Cache
.
CacheKey
cacheKey
=
new
Cache
.
CacheKey
(
ActionListPaging
.
class
,
page
,
size
,
MD5Tool
.
getMD5Str
(
gson
.
toJson
(
jsonElement
))
);
Optional
<?>
optional
=
CacheManager
.
get
(
cacheCategory
,
cacheKey
);
if
(
optional
.
isPresent
())
{
wos
=
(
List
<
Wo
>)
optional
.
get
()
;
}
else
{
String
token
=
Business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
try
{
JsonObject
jsonObject
=
jsonElement
.
getAsJsonObject
();
jsonObject
.
addProperty
(
"status"
,
"publish"
);
String
url
=
StringUtils
.
replaceEach
(
COLLECT_MARKET_LIST_INFO
,
new
String
[]{
"{page}"
,
"{size}"
},
new
String
[]{
String
.
valueOf
(
page
),
String
.
valueOf
(
size
)}
);
ActionResponse
response
=
ConnectionAction
.
post
(
Config
.
collect
().
url
(
url
),
ListTools
.
toList
(
new
NameValuePair
(
Collect
.
COLLECT_TOKEN
,
token
)),
jsonObject
);
wos
=
response
.
getDataAsList
(
Wo
.
class
);
result
.
setCount
(
response
.
getCount
());
}
catch
(
Exception
e
)
{
logger
.
warn
(
"list market form o2cloud error: {}."
,
e
.
getMessage
()
);
}
}
result
.
setData
(
wos
);
result
.
setCount
(
emc
.
count
(
Application
.
class
,
p
));
return
result
;
}
}
private
Predicate
toFilterPredicate
(
EffectivePerson
effectivePerson
,
Business
business
,
Wi
wi
)
throws
Exception
{
EntityManager
em
=
business
.
entityManagerContainer
().
get
(
Application
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Tuple
>
cq
=
cb
.
createQuery
(
Tuple
.
class
);
Root
<
Application
>
root
=
cq
.
from
(
Application
.
class
);
Predicate
p
=
cb
.
conjunction
();
if
(
StringUtils
.
isNotEmpty
(
wi
.
getName
())){
String
key
=
StringTools
.
escapeSqlLikeKey
(
wi
.
getName
());
if
(
StringUtils
.
isNotEmpty
(
key
))
{
p
=
cb
.
and
(
p
,
cb
.
like
(
root
.
get
(
Application_
.
name
),
"%"
+
key
+
"%"
,
StringTools
.
SQL_ESCAPE_CHAR
));
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
for
(
Wo
wo
:
wos
)
{
InstallLog
installLog
=
emc
.
find
(
wo
.
getId
(),
InstallLog
.
class
);
if
(
installLog
!=
null
&&
CommonStatus
.
VALID
.
getValue
().
equals
(
installLog
.
getStatus
()))
{
wo
.
setInstalledVersion
(
installLog
.
getVersion
());
}
else
{
wo
.
setInstalledVersion
(
""
);
}
}
}
}
if
(
StringUtils
.
isNotEmpty
(
wi
.
getCategory
())){
p
=
cb
.
and
(
p
,
cb
.
equal
(
root
.
get
(
Application_
.
category
),
wi
.
getCategory
()));
}
if
(
DateTools
.
isDateTimeOrDate
(
wi
.
getStartTime
()))
{
p
=
cb
.
and
(
p
,
cb
.
greaterThan
(
root
.
get
(
Application_
.
createTime
),
DateTools
.
parse
(
wi
.
getStartTime
())));
}
if
(
DateTools
.
isDateTimeOrDate
(
wi
.
getEndTime
()))
{
p
=
cb
.
and
(
p
,
cb
.
lessThan
(
root
.
get
(
Application_
.
createTime
),
DateTools
.
parse
(
wi
.
getEndTime
())));
if
(
ListTools
.
isNotEmpty
(
wos
)){
CacheManager
.
put
(
cacheCategory
,
cacheKey
,
wos
);
}
}
return
p
;
result
.
setData
(
wos
);
return
result
;
}
public
class
Wi
extends
GsonPropertyObject
{
...
...
@@ -162,12 +147,7 @@ class ActionListPaging extends BaseAction {
}
}
public
static
class
Wo
extends
Application
{
private
static
final
long
serialVersionUID
=
9206739553467260926L
;
static
WrapCopier
<
Application
,
Wo
>
copier
=
WrapCopierFactory
.
wo
(
Application
.
class
,
Wo
.
class
,
JpaObject
.
singularAttributeField
(
Application
.
class
,
true
,
false
),
Arrays
.
asList
(
"abort"
,
"installSteps"
,
"describe"
));
public
static
class
Wo
extends
Application2
{
@FieldDescribe
(
"已安装的版本,空表示未安装"
)
private
String
installedVersion
;
...
...
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/ActionSync.java
已删除
100644 → 0
浏览文件 @
730d0c49
package
com.x.program.center.jaxrs.market
;
import
com.x.base.core.project.http.ActionResult
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.WrapBoolean
;
import
com.x.program.center.ThisApplication
;
import
com.x.program.center.schedule.CollectMarket
;
class
ActionSync
extends
BaseAction
{
ActionResult
<
Wo
>
execute
(
EffectivePerson
effectivePerson
)
throws
Exception
{
ActionResult
<
Wo
>
result
=
new
ActionResult
<>();
Wo
wo
=
new
Wo
();
wo
.
setValue
(
true
);
result
.
setData
(
wo
);
ThisApplication
.
context
().
scheduleLocal
(
CollectMarket
.
class
);
return
result
;
}
public
static
class
Wo
extends
WrapBoolean
{
}
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/BaseAction.java
浏览文件 @
842947d7
package
com.x.program.center.jaxrs.market
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.cache.Cache
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
import
com.x.base.core.project.http.EffectivePerson
;
import
com.x.base.core.project.jaxrs.StandardJaxrsAction
;
import
com.x.program.center.WrapModule
;
import
java.util.Date
;
abstract
class
BaseAction
extends
StandardJaxrsAction
{
protected
static
String
COLLECT_MARKET_CATEGORY
=
"/o2_collect_assemble/jaxrs/application2/list/category"
;
protected
static
String
COLLECT_MARKET_LIST_INFO
=
"/o2_collect_assemble/jaxrs/application2/list/paging/{page}/size/{size}"
;
protected
static
String
COLLECT_MARKET_INFO
=
"/o2_collect_assemble/jaxrs/application2/"
;
protected
static
String
COLLECT_UNIT_IS_VIP
=
"/o2_collect_assemble/jaxrs/unit/is/vip"
;
protected
Cache
.
CacheCategory
cacheCategory
=
new
Cache
.
CacheCategory
(
InstallData
.
class
);
public
boolean
hasAuth
(
EffectivePerson
effectivePerson
,
String
person
){
if
(
effectivePerson
.
isManager
()){
return
true
;
...
...
@@ -24,11 +35,11 @@ abstract class BaseAction extends StandardJaxrsAction {
private
String
customApp
;
public
com
.
x
.
program
.
center
.
WrapModule
getWrapModule
()
{
public
WrapModule
getWrapModule
()
{
return
WrapModule
;
}
public
void
setWrapModule
(
com
.
x
.
program
.
center
.
WrapModule
wrapModule
)
{
public
void
setWrapModule
(
WrapModule
wrapModule
)
{
WrapModule
=
wrapModule
;
}
...
...
@@ -49,4 +60,293 @@ abstract class BaseAction extends StandardJaxrsAction {
}
}
public
static
class
Application2
extends
GsonPropertyObject
{
@FieldDescribe
(
"主键."
)
private
String
id
;
@FieldDescribe
(
"名称.必填"
)
private
String
name
;
@FieldDescribe
(
"分类.必填"
)
private
String
category
;
@FieldDescribe
(
"子分类."
)
private
String
subCategory
;
@FieldDescribe
(
"版本.必填"
)
private
String
version
;
@FieldDescribe
(
"价格."
)
private
Double
price
;
@FieldDescribe
(
"状态:draft|audit|publish|invalid."
)
private
String
status
;
@FieldDescribe
(
"宣传图片url链接."
)
private
String
broadcastPic
;
@FieldDescribe
(
"封面图片url链接."
)
private
String
indexPic
;
@FieldDescribe
(
"视频url链接."
)
private
String
video
;
@FieldDescribe
(
"依赖中间件(如:onlyOffice)"
)
private
String
middleware
;
@FieldDescribe
(
"适配O2的版本(向上兼容)"
)
private
String
o2Version
;
@FieldDescribe
(
"配置文件配置地址(web端)"
)
private
String
configPath
;
@FieldDescribe
(
"描述.必填"
)
private
String
describe
;
@FieldDescribe
(
"应用简介.必填"
)
private
String
abort
;
@FieldDescribe
(
"应用安装步骤.必填"
)
private
String
installSteps
;
@FieldDescribe
(
"发布者."
)
private
String
publisher
;
@FieldDescribe
(
"发布时间"
)
private
Date
publishTime
;
@FieldDescribe
(
"排序号,升序排列,为空在最后"
)
private
Integer
orderNumber
;
@FieldDescribe
(
"推荐指数"
)
private
Integer
recommend
;
@FieldDescribe
(
"下载次数"
)
private
Integer
downloadCount
;
@FieldDescribe
(
"最后更新时间"
)
private
Date
lastUpdateTime
;
@FieldDescribe
(
"安装后是否需要重启"
)
private
Boolean
restart
=
false
;
@FieldDescribe
(
"是否是VIP应用"
)
private
Boolean
vipApp
=
false
;
@FieldDescribe
(
"创建时间."
)
private
Date
createTime
;
@FieldDescribe
(
"修改时间."
)
private
Date
updateTime
;
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getCategory
()
{
return
category
;
}
public
void
setCategory
(
String
category
)
{
this
.
category
=
category
;
}
public
String
getSubCategory
()
{
return
subCategory
;
}
public
void
setSubCategory
(
String
subCategory
)
{
this
.
subCategory
=
subCategory
;
}
public
String
getVersion
()
{
return
version
;
}
public
void
setVersion
(
String
version
)
{
this
.
version
=
version
;
}
public
Double
getPrice
()
{
return
price
;
}
public
void
setPrice
(
Double
price
)
{
this
.
price
=
price
;
}
public
String
getStatus
()
{
return
status
;
}
public
void
setStatus
(
String
status
)
{
this
.
status
=
status
;
}
public
String
getBroadcastPic
()
{
return
broadcastPic
;
}
public
void
setBroadcastPic
(
String
broadcastPic
)
{
this
.
broadcastPic
=
broadcastPic
;
}
public
String
getIndexPic
()
{
return
indexPic
;
}
public
void
setIndexPic
(
String
indexPic
)
{
this
.
indexPic
=
indexPic
;
}
public
String
getVideo
()
{
return
video
;
}
public
void
setVideo
(
String
video
)
{
this
.
video
=
video
;
}
public
String
getMiddleware
()
{
return
middleware
;
}
public
void
setMiddleware
(
String
middleware
)
{
this
.
middleware
=
middleware
;
}
public
String
getO2Version
()
{
return
o2Version
;
}
public
void
setO2Version
(
String
o2Version
)
{
this
.
o2Version
=
o2Version
;
}
public
String
getConfigPath
()
{
return
configPath
;
}
public
void
setConfigPath
(
String
configPath
)
{
this
.
configPath
=
configPath
;
}
public
String
getDescribe
()
{
return
describe
;
}
public
void
setDescribe
(
String
describe
)
{
this
.
describe
=
describe
;
}
public
String
getAbort
()
{
return
abort
;
}
public
void
setAbort
(
String
abort
)
{
this
.
abort
=
abort
;
}
public
String
getInstallSteps
()
{
return
installSteps
;
}
public
void
setInstallSteps
(
String
installSteps
)
{
this
.
installSteps
=
installSteps
;
}
public
String
getPublisher
()
{
return
publisher
;
}
public
void
setPublisher
(
String
publisher
)
{
this
.
publisher
=
publisher
;
}
public
Date
getPublishTime
()
{
return
publishTime
;
}
public
void
setPublishTime
(
Date
publishTime
)
{
this
.
publishTime
=
publishTime
;
}
public
Integer
getOrderNumber
()
{
return
orderNumber
;
}
public
void
setOrderNumber
(
Integer
orderNumber
)
{
this
.
orderNumber
=
orderNumber
;
}
public
Integer
getRecommend
()
{
return
recommend
;
}
public
void
setRecommend
(
Integer
recommend
)
{
this
.
recommend
=
recommend
;
}
public
Integer
getDownloadCount
()
{
return
downloadCount
;
}
public
void
setDownloadCount
(
Integer
downloadCount
)
{
this
.
downloadCount
=
downloadCount
;
}
public
Date
getLastUpdateTime
()
{
return
lastUpdateTime
;
}
public
void
setLastUpdateTime
(
Date
lastUpdateTime
)
{
this
.
lastUpdateTime
=
lastUpdateTime
;
}
public
Boolean
getRestart
()
{
return
restart
;
}
public
void
setRestart
(
Boolean
restart
)
{
this
.
restart
=
restart
;
}
public
Boolean
getVipApp
()
{
return
vipApp
;
}
public
void
setVipApp
(
Boolean
vipApp
)
{
this
.
vipApp
=
vipApp
;
}
public
Date
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
Date
createTime
)
{
this
.
createTime
=
createTime
;
}
public
Date
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
Date
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
}
o2server/x_program_center/src/main/java/com/x/program/center/jaxrs/market/MarketAction.java
浏览文件 @
842947d7
...
...
@@ -87,23 +87,6 @@ public class MarketAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"同步数据."
,
action
=
ActionSync
.
class
)
@GET
@Path
(
"sync"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
sync
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
)
{
ActionResult
<
ActionSync
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionSync
().
execute
(
effectivePerson
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
@JaxrsMethodDescribe
(
value
=
"安装或更新应用."
,
action
=
ActionInstallOrUpdate
.
class
)
@GET
@Path
(
"{flag}/install/or/update"
)
...
...
@@ -212,4 +195,21 @@ public class MarketAction extends StandardJaxrsAction {
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
\ No newline at end of file
@JaxrsMethodDescribe
(
value
=
"判断注册在O2云用户是否是VIP用户."
,
action
=
ActionIsVip
.
class
)
@GET
@Path
(
"cloud/unit/is/vip"
)
@Produces
(
HttpMediaType
.
APPLICATION_JSON_UTF_8
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
public
void
cloudUnitIsVip
(
@Suspended
final
AsyncResponse
asyncResponse
,
@Context
HttpServletRequest
request
)
{
ActionResult
<
ActionIsVip
.
Wo
>
result
=
new
ActionResult
<>();
EffectivePerson
effectivePerson
=
this
.
effectivePerson
(
request
);
try
{
result
=
new
ActionIsVip
().
execute
(
effectivePerson
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
,
effectivePerson
,
request
,
null
);
result
.
error
(
e
);
}
asyncResponse
.
resume
(
ResponseFactory
.
getEntityTagActionResultResponse
(
request
,
result
));
}
}
o2server/x_program_center/src/main/java/com/x/program/center/schedule/CollectMarket.java
浏览文件 @
842947d7
...
...
@@ -29,6 +29,9 @@ import com.x.program.center.Business;
import
com.x.program.center.core.entity.Application
;
import
com.x.program.center.core.entity.Attachment
;
/**
* @author sword
*/
public
class
CollectMarket
extends
BaseAction
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
CollectMarket
.
class
);
...
...
@@ -41,8 +44,7 @@ public class CollectMarket extends BaseAction {
try
{
if
(
pirmaryCenter
()
&&
BooleanUtils
.
isTrue
(
Config
.
collect
().
getEnable
()))
{
try
(
EntityManagerContainer
emc
=
EntityManagerContainerFactory
.
instance
().
create
())
{
Business
business
=
new
Business
(
emc
);
String
token
=
business
.
loginCollect
();
String
token
=
Business
.
loginCollect
();
if
(
StringUtils
.
isNotEmpty
(
token
))
{
logger
.
info
(
"start sync market data."
);
List
<
Wi
>
wiList
=
null
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录