Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jfV5portal
Overview
Overview
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
管理员
jfV5portal
Commits
84e9a1d3
Commit
84e9a1d3
authored
Apr 27, 2018
by
罗绍泽
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
增加portlet布局保存的方法
详见:
http://localhost:8080/jfV5portal/jwAppsPortletView_portletApi
parent
f2a8eefd
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
188 additions
and
14 deletions
+188
-14
jwAppPortletModule.js
WebContent/jwapp/pages/portlet/js/jwAppPortletModule.js
+2
-0
portletApi.jsp
WebContent/jwapp/pages/portlet/portletApi.jsp
+48
-13
PortletBusiness.java
src_jwapp/com/jw/app/business/PortletBusiness.java
+2
-0
PortletBusinessImpl.java
...wapp/com/jw/app/business/portlet/PortletBusinessImpl.java
+79
-1
PortletDAO.java
src_jwapp/com/jw/app/business/portlet/PortletDAO.java
+4
-0
PortletDAO.xml
src_jwapp/com/jw/app/business/portlet/PortletDAO.xml
+21
-0
actAction.java
src_jwapp/com/jw/app/portlet/action/actAction.java
+32
-0
No files found.
WebContent/jwapp/pages/portlet/js/jwAppPortletModule.js
View file @
84e9a1d3
...
@@ -14,6 +14,8 @@ jwAppPortletModel.prototype.listAllPTemplateByUser = function(){};
...
@@ -14,6 +14,8 @@ jwAppPortletModel.prototype.listAllPTemplateByUser = function(){};
jwAppPortletModel
.
prototype
.
listAllPortletColumns
=
function
(){};
jwAppPortletModel
.
prototype
.
listAllPortletColumns
=
function
(){};
//获取所有的资源列表
//获取所有的资源列表
jwAppPortletModel
.
prototype
.
listAllPTemplate
=
function
(){};
jwAppPortletModel
.
prototype
.
listAllPTemplate
=
function
(){};
//保存用户的资源列表
jwAppPortletModel
.
prototype
.
saveLayout
=
function
(){};
//创建一个数据操作对象,然后再后续使用
//创建一个数据操作对象,然后再后续使用
...
...
WebContent/jwapp/pages/portlet/portletApi.jsp
View file @
84e9a1d3
...
@@ -39,7 +39,7 @@ table {
...
@@ -39,7 +39,7 @@ table {
width
:
100%
;
width
:
100%
;
}
}
table
tr
td
pre
{
table
tr
td
.
pre
{
width
:
100%
;
width
:
100%
;
height
:
200px
;
height
:
200px
;
overflow
:
auto
;
overflow
:
auto
;
...
@@ -65,9 +65,9 @@ table tr td pre {
...
@@ -65,9 +65,9 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td>
调用
</td>
<td>
调用
</td>
<td>
jwAppPortletModel.jwAppsPortletDataAction.listAllPTemplateByUser({
<br
/>
<td>
<pre>
var result = jwAppPortletModel.jwAppsPortletDataAction.listAllPTemplateByUser({
FIELD_COLUMN_ID:'d6926714-c220-4a7e-9ec0-3a23caebb179'
<br
/>
FIELD_COLUMN_ID: 'd6926714-c220-4a7e-9ec0-3a23caebb179'
})
</td>
})
</pre>
</td>
</tr>
</tr>
<tr>
<tr>
<td>
参数备注
</td>
<td>
参数备注
</td>
...
@@ -75,7 +75,7 @@ table tr td pre {
...
@@ -75,7 +75,7 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><pre></pre></td>
<td><pre
class=
"pre"
></pre></td>
</tr>
</tr>
</table>
</table>
...
@@ -90,7 +90,7 @@ table tr td pre {
...
@@ -90,7 +90,7 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td>
调用
</td>
<td>
调用
</td>
<td>
jwAppPortletModel.jwAppsPortletDataAction.listAllPortletColumns()
</td>
<td>
<pre>
var result = jwAppPortletModel.jwAppsPortletDataAction.listAllPortletColumns()
</pre>
</td>
</tr>
</tr>
<tr>
<tr>
<td>
参数备注
</td>
<td>
参数备注
</td>
...
@@ -98,7 +98,7 @@ table tr td pre {
...
@@ -98,7 +98,7 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><pre></pre></td>
<td><pre
class=
"pre"
></pre></td>
</tr>
</tr>
</table>
</table>
...
@@ -113,9 +113,9 @@ table tr td pre {
...
@@ -113,9 +113,9 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td>
调用
</td>
<td>
调用
</td>
<td>
jwAppPortletModel.jwAppsPortletDataAction.listAllPTemplate({
<br
/>
<td>
<pre>
var result = jwAppPortletModel.jwAppsPortletDataAction.listAllPTemplate({
FIELD_COLUMN_ID:'d6926714-c220-4a7e-9ec0-3a23caebb179'
<br
/>
FIELD_COLUMN_ID: 'd6926714-c220-4a7e-9ec0-3a23caebb179'
})
</td>
})
</pre>
</td>
</tr>
</tr>
<tr>
<tr>
<td>
参数备注
</td>
<td>
参数备注
</td>
...
@@ -123,7 +123,42 @@ table tr td pre {
...
@@ -123,7 +123,42 @@ table tr td pre {
</tr>
</tr>
<tr>
<tr>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><pre></pre></td>
<td><pre
class=
"pre"
></pre></td>
</tr>
</table>
<table
id=
"tbl_004"
>
<tr>
<td>
编号
</td>
<td>
004
</td>
</tr>
<tr>
<td>
描述
</td>
<td>
保存用户的资源列表
</td>
</tr>
<tr>
<td>
调用
</td>
<td><pre>
var layout = {
columnsId: 'd6926714-c220-4a7e-9ec0-3a23caebb179',
portlets: [{
"PORTLET_ID": "a9a27fe8-8215-44a1-8e65-f93c74962240"
},
{
"PORTLET_ID": "8538986b-f177-4f70-a525-59f78d557c6b"
}]
};
layout = JSON.stringify(layout);
var result = jwAppPortletModel.jwAppsPortletActAction.saveLayout({
layout: layout
});
</pre></td>
</tr>
<tr>
<td>
参数备注
</td>
<td>
FIELD_COLUMN_ID:栏目id
</td>
</tr>
<tr>
<td><span
class=
"look"
>
结果查看
</span></td>
<td><pre
class=
"pre"
></pre></td>
</tr>
</tr>
</table>
</table>
</body>
</body>
...
@@ -133,8 +168,8 @@ table tr td pre {
...
@@ -133,8 +168,8 @@ table tr td pre {
var
$table
=
$
(
this
);
var
$table
=
$
(
this
);
var
tr4
=
$
(
this
).
find
(
'tr'
).
eq
(
4
);
var
tr4
=
$
(
this
).
find
(
'tr'
).
eq
(
4
);
tr4
.
find
(
'td'
).
eq
(
0
).
find
(
'span'
).
click
(
function
()
{
tr4
.
find
(
'td'
).
eq
(
0
).
find
(
'span'
).
click
(
function
()
{
var
click
=
$table
.
find
(
'tr'
).
eq
(
2
).
find
(
'td'
).
eq
(
1
).
text
();
var
click
=
$table
.
find
(
'tr'
).
eq
(
2
).
find
(
'td'
).
eq
(
1
).
find
(
'pre'
).
text
();
eval
(
'var result='
+
click
);
eval
(
click
);
tr4
.
find
(
'td'
).
eq
(
1
).
find
(
'pre'
).
html
(
syntaxHighlight
(
result
));
tr4
.
find
(
'td'
).
eq
(
1
).
find
(
'pre'
).
html
(
syntaxHighlight
(
result
));
});
});
});
});
...
...
src_jwapp/com/jw/app/business/PortletBusiness.java
View file @
84e9a1d3
...
@@ -15,4 +15,6 @@ public interface PortletBusiness {
...
@@ -15,4 +15,6 @@ public interface PortletBusiness {
List
<
Map
<
String
,
Object
>>
list_portlet_template
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_portlet_template
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_portlet_columns
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_portlet_columns
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
void
saveLayout
(
String
columnsId
,
List
<
Map
<
String
,
Object
>>
list
)
throws
BusinessException
;
}
}
src_jwapp/com/jw/app/business/portlet/PortletBusinessImpl.java
View file @
84e9a1d3
...
@@ -2,9 +2,13 @@ package com.jw.app.business.portlet;
...
@@ -2,9 +2,13 @@ package com.jw.app.business.portlet;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.sql.SQLException
;
import
java.sql.SQLException
;
import
java.text.SimpleDateFormat
;
import
java.util.ArrayList
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.UUID
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.SessionUtil
;
import
com.gaowj.business.util.SessionUtil
;
...
@@ -13,6 +17,11 @@ import com.jw.app.business.utils.QueryParamUtil;
...
@@ -13,6 +17,11 @@ import com.jw.app.business.utils.QueryParamUtil;
public
class
PortletBusinessImpl
implements
PortletBusiness
{
public
class
PortletBusinessImpl
implements
PortletBusiness
{
/**
* 默认模板的标识符
*/
private
static
final
String
DEFAULT
=
"default"
;
private
PortletDAO
portletDAO
;
private
PortletDAO
portletDAO
;
public
PortletDAO
getPortletDAO
()
{
public
PortletDAO
getPortletDAO
()
{
...
@@ -29,10 +38,11 @@ public class PortletBusinessImpl implements PortletBusiness {
...
@@ -29,10 +38,11 @@ public class PortletBusinessImpl implements PortletBusiness {
throws
BusinessException
{
throws
BusinessException
{
List
<
Map
<
String
,
Object
>>
listData
=
null
;
List
<
Map
<
String
,
Object
>>
listData
=
null
;
try
{
try
{
query
.
put
(
"USER_ID"
,
SessionUtil
.
getEmid
());
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
if
(
listData
.
size
()==
0
){
if
(
listData
.
size
()==
0
){
//如果当前登陆人还没有设置自定义的资源,则显示默认的资源
//如果当前登陆人还没有设置自定义的资源,则显示默认的资源
query
.
put
(
"USER_ID"
,
"default"
);
query
.
put
(
"USER_ID"
,
DEFAULT
);
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
}
}
for
(
Map
<
String
,
Object
>
map:
listData
){
for
(
Map
<
String
,
Object
>
map:
listData
){
...
@@ -94,4 +104,72 @@ public class PortletBusinessImpl implements PortletBusiness {
...
@@ -94,4 +104,72 @@ public class PortletBusinessImpl implements PortletBusiness {
return
listData
;
return
listData
;
}
}
@Override
public
void
saveLayout
(
String
columnsId
,
List
<
Map
<
String
,
Object
>>
list
)
throws
BusinessException
{
String
userId
=
SessionUtil
.
getEmid
();
List
<
Map
<
String
,
Object
>>
listData
=
null
;
try
{
Map
<
String
,
Object
>
query
=
new
HashMap
<
String
,
Object
>();
query
.
put
(
"USER_ID"
,
userId
);
query
.
put
(
"COLUMN_ID"
,
columnsId
);
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
if
(
listData
.
size
()==
0
){
//如果当前登陆人没有设置自己的模板布局,则查询默认的布局
query
.
put
(
"USER_ID"
,
DEFAULT
);
listData
=
QueryParamUtil
.
ClobToString
(
portletDAO
.
list_portlet_template_user
(
query
));
}
//验证用户传过来的布局和数据库中的布局是否一致,默认为一致
boolean
same
=
true
;
if
(
listData
.
size
()!=
list
.
size
()){
same
=
false
;
}
else
{
//长度一致的情况下,判断每一个索引所在位置的portletId是否一致
for
(
int
i
=
0
;
i
<
listData
.
size
();
i
++){
//只要有一个不满足,则设置same为false
if
(!
listData
.
get
(
i
).
get
(
"PORTLET_ID"
).
equals
(
list
.
get
(
i
).
get
(
"PORTLET_ID"
))){
same
=
false
;
break
;
}
}
}
if
(!
same
){
//如果不一致,则将用户的自定义模板布局删除,重新添加新布局进行保存
Map
<
String
,
Object
>
deleteQuery
=
new
HashMap
<
String
,
Object
>();
deleteQuery
.
put
(
"USER_ID"
,
userId
);
portletDAO
.
delete_portlet_template_user
(
deleteQuery
);
//重新添加
int
index
=
0
;
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd HH:mm:ss"
);
String
now
=
formatter
.
format
(
new
Date
());
for
(
Map
<
String
,
Object
>
map:
list
){
map
.
put
(
"ID"
,
UUID
.
randomUUID
().
toString
());
map
.
put
(
"USER_ID"
,
userId
);
map
.
put
(
"ORDER_NUM"
,
index
++);
map
.
put
(
"IS_DELETE"
,
0
);
map
.
put
(
"CREATE_USER"
,
userId
);
map
.
put
(
"CREATE_TIME"
,
now
);
portletDAO
.
insert_portlet_template_user
(
mapToList
(
map
));
}
}
}
catch
(
IOException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
catch
(
SQLException
e
)
{
// TODO Auto-generated catch block
e
.
printStackTrace
();
}
}
private
List
<
Map
<
String
,
Object
>>
mapToList
(
Map
<
String
,
Object
>
map
){
List
<
Map
<
String
,
Object
>>
entity
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
Map
<
String
,
Object
>
field
=
new
HashMap
<
String
,
Object
>();
field
.
put
(
"key"
,
entry
.
getKey
());
field
.
put
(
"value"
,
entry
.
getValue
());
entity
.
add
(
field
);
}
return
entity
;
}
}
}
src_jwapp/com/jw/app/business/portlet/PortletDAO.java
View file @
84e9a1d3
...
@@ -17,4 +17,8 @@ public interface PortletDAO {
...
@@ -17,4 +17,8 @@ public interface PortletDAO {
List
<
Map
<
String
,
Object
>>
list_portlet_content
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_portlet_content
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_app_acount
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
List
<
Map
<
String
,
Object
>>
list_app_acount
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
void
delete_portlet_template_user
(
Map
<
String
,
Object
>
query
)
throws
BusinessException
;
void
insert_portlet_template_user
(
List
<
Map
<
String
,
Object
>>
entity
)
throws
BusinessException
;
}
}
src_jwapp/com/jw/app/business/portlet/PortletDAO.xml
View file @
84e9a1d3
...
@@ -120,4 +120,24 @@
...
@@ -120,4 +120,24 @@
on btua.APP_ID=btumu.APP_ID
on btua.APP_ID=btumu.APP_ID
WHERE btumu.USER_ID=#{USER_ID} AND btua.APP_ID=#{APP_ID}
WHERE btumu.USER_ID=#{USER_ID} AND btua.APP_ID=#{APP_ID}
</select>
</select>
<delete
id=
"delete_portlet_template_user"
parameterType=
"map"
>
delete from portlet_template_user where user_id=#{USER_ID}
</delete>
<insert
id=
"insert_portlet_template_user"
parameterType=
"java.util.List"
>
insert into portlet_template_user(
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"list"
item=
"field"
>
${field.key},
</foreach>
</trim>
<![CDATA[ ) values( ]]>
<trim
prefix=
""
suffixOverrides=
","
>
<foreach
collection=
"list"
item=
"field"
>
#{field.value},
</foreach>
</trim>
<![CDATA[ ) ]]>
</insert>
</mapper>
</mapper>
\ No newline at end of file
src_jwapp/com/jw/app/portlet/action/actAction.java
View file @
84e9a1d3
package
com
.
jw
.
app
.
portlet
.
action
;
package
com
.
jw
.
app
.
portlet
.
action
;
import
java.util.ArrayList
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.Map
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.action.BasicAction
;
import
com.gaowj.business.comp.BusinessManager
;
import
com.gaowj.business.exception.BusinessException
;
import
com.gaowj.business.util.RequestUtils
;
import
com.jw.app.business.PortletBusiness
;
import
com.jw.app.business.utils.Status
;
import
net.sf.json.JSONArray
;
import
net.sf.json.JSONObject
;
import
net.sf.json.JSONObject
;
import
net.sf.json.util.JSONUtils
;
public
class
actAction
extends
BasicAction
{
public
class
actAction
extends
BasicAction
{
...
@@ -21,4 +33,24 @@ public class actAction extends BasicAction {
...
@@ -21,4 +33,24 @@ public class actAction extends BasicAction {
this
.
jsonObject
=
jsonObject
;
this
.
jsonObject
=
jsonObject
;
}
}
public
String
saveLayout
()
throws
BusinessException
{
String
layout
=
RequestUtils
.
getString
(
request
,
"layout"
);
//layout="{columnsId:'d6926714-c220-4a7e-9ec0-3a23caebb179',portlets:[{\"PORTLET_ID\":\"a9a27fe8-8215-44a1-8e65-f93c74962240\"},{\"PORTLET_ID\":\"8538986b-f177-4f70-a525-59f78d557c6b\"}]}";
JSONObject
json
=
JSONObject
.
fromObject
(
layout
);
//获取栏目id
String
columnsId
=
json
.
get
(
"columnsId"
).
toString
();
//解析protlets
JSONArray
array
=
JSONArray
.
fromObject
(
json
.
get
(
"portlets"
));
List
<
Map
<
String
,
Object
>>
list
=
new
ArrayList
<
Map
<
String
,
Object
>>();
for
(
Iterator
iter
=
array
.
iterator
();
iter
.
hasNext
();){
JSONObject
jsonObject
=
(
JSONObject
)
iter
.
next
();
list
.
add
((
Map
<
String
,
Object
>)
JSONObject
.
toBean
(
jsonObject
,
Map
.
class
));
}
PortletBusiness
business
=
BusinessManager
.
getBusiness
(
PortletBusiness
.
class
);
business
.
saveLayout
(
columnsId
,
list
);
jsonObject
.
putAll
(
Status
.
getStatus
(
Status
.
UPDATE_OK
));
return
"json"
;
}
}
}
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