Commit 78c0c4d4 by 周添尉

完成应用管理的查找,安装,卸载

parent 7cd27cde
...@@ -28,12 +28,9 @@ function init_index_nav(){ ...@@ -28,12 +28,9 @@ function init_index_nav(){
for(var i = 0;i<data.length;i++){ for(var i = 0;i<data.length;i++){
var text = $('<a></a>').text(data[i].NAME).data('uuid',data[i].UUID); var text = $('<a></a>').text(data[i].NAME).data('uuid',data[i].UUID);
if(i==0){ if(i==0){
text.attr('href','index.jsp');
text.addClass('layout_center_navClick'); text.addClass('layout_center_navClick');
} }
else{ text.attr('href',data[i].REMARK);
text.attr('href','index2.jsp');
}
container.append(text); container.append(text);
} }
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox.js?v=2.1.3"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox.js?v=2.1.3"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox-buttons.js?v=1.0.5"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox-buttons.js?v=1.0.5"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox-thumbs.js?v=1.0.7"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox-thumbs.js?v=1.0.7"></script>
<script type="text/javascript" src="${pageContext.request.contextPath}/lib/plug/fancyBox/js/jquery.fancybox-media.js?v=1.0.5"></script> <script type="text/javascript" src="${pageContext.request.contextPath}/1lib/plug/fancyBox/js/jquery.fancybox-media.js?v=1.0.5"></script>
<!-- xcConfirm的js --> <!-- xcConfirm的js -->
<script src="${pageContext.request.contextPath}/lib/plug/xcConfirm/js/xcConfirm.js"></script> <script src="${pageContext.request.contextPath}/lib/plug/xcConfirm/js/xcConfirm.js"></script>
<!-- 调用api时的js --> <!-- 调用api时的js -->
...@@ -153,13 +153,14 @@ a{ ...@@ -153,13 +153,14 @@ a{
height:100%; height:100%;
} }
.index_application_show_tabs_content_div>div:first-child{ .index_application_show_tabs_content_div>div:first-child{
border:1px solid #ccc; border-radius: 10px;
border-radius:10px; width: 60px;
width:60px; height: 60px;
height:60px; margin: 10px auto 5px;
margin:10px auto 5px; border-radius: 10px;
background:white; }
padding:10px; .index_application_show_tabs_content_div>div:first-child>img{
border-radius:13px;
} }
.index_application_show_tabs_content_text{ .index_application_show_tabs_content_text{
text-align:center; text-align:center;
...@@ -319,11 +320,12 @@ $(function(){ ...@@ -319,11 +320,12 @@ $(function(){
$(this).addClass('index_application_show_tabs_click'); $(this).addClass('index_application_show_tabs_click');
//apps的切换 //apps的切换
index_application_toggle(); index_application_toggle();
}) })
}) })
//安装获得卸载 //安装或者卸载
function index_application_isLoad(handler){ function index_application_isLoad(handler){
var txt; var txt;
var option; var option;
...@@ -341,8 +343,10 @@ function index_application_isLoad(handler){ ...@@ -341,8 +343,10 @@ function index_application_isLoad(handler){
//保存到数据库 //保存到数据库
jwAppAppsModel.jwAppsAppsActAction.insert_unInstallApp_byResourceId({ jwAppAppsModel.jwAppsAppsActAction.insert_unInstallApp_byResourceId({
RESOURCE_ID:$(handler).parent().parent().data('app').RESOURCE_ID APP_ID:$(handler).parent().parent().data('app').APP_ID
}); });
//绑定一个data来区别是否已经安装1为安装,0为未安装
$(handler).parent().parent().data('app').CUSTOM_INSTALL='0';
$('.fancybox-iframe',window.parent.document).parent().parent().parent().find('.fancybox-close').unbind().bind('click',function(event){ $('.fancybox-iframe',window.parent.document).parent().parent().parent().find('.fancybox-close').unbind().bind('click',function(event){
event.stopPropagation(); event.stopPropagation();
...@@ -369,6 +373,12 @@ function index_application_isLoad(handler){ ...@@ -369,6 +373,12 @@ function index_application_isLoad(handler){
$(handler).parent().parent().hide(); $(handler).parent().parent().hide();
} }
//保存到数据库
jwAppAppsModel.jwAppsAppsActAction.insert_installApp_byResourceId({
APP_ID:$(handler).parent().parent().data('app').APP_ID
});
//绑定一个data来区别是否已经安装1为安装,0为未安装
$(handler).parent().parent().data('app').CUSTOM_INSTALL='1';
$('.fancybox-iframe',window.parent.document).parent().parent().parent().find('.fancybox-close').unbind().bind('click',function(event){ $('.fancybox-iframe',window.parent.document).parent().parent().parent().find('.fancybox-close').unbind().bind('click',function(event){
event.stopPropagation(); event.stopPropagation();
...@@ -388,12 +398,19 @@ function index_application_isLoad(handler){ ...@@ -388,12 +398,19 @@ function index_application_isLoad(handler){
//关闭后重新渲染应用中心 //关闭后重新渲染应用中心
function index_application_close(){ function index_application_close(){
console.log('关闭') var app_data=[];
$('.index_application_show_tabs_content>div').each(function(index,elemet){
if($(elemet).find('.index_application_show_tabs_content_img>span').text()=='卸载'){
app_data.push($(elemet).data('app'));
}
})
//初始化应用,调用父元素的方法
parent.window.init_index_application(app_data);
} }
//初始化类别 //初始化类别
function init_index_categorys(){ function init_index_categorys(){
var list_category = list_allApps.types; var list_category = list_allApps.types.rowSet;
var index_application_show_tabs = $('.index_application_show_tabs'); var index_application_show_tabs = $('.index_application_show_tabs');
index_application_show_tabs.append('<span class="index_application_show_tabs_click">全部应用</span>'); index_application_show_tabs.append('<span class="index_application_show_tabs_click">全部应用</span>');
for(var i = 0 ; i<list_category.length;i++){ for(var i = 0 ; i<list_category.length;i++){
...@@ -419,7 +436,7 @@ function init_index_apps(){ ...@@ -419,7 +436,7 @@ function init_index_apps(){
appsContainer.append(createContainer); appsContainer.append(createContainer);
var index_application_show_tabs_content_div= $('<div class="index_application_show_tabs_content_div"></div>'); var index_application_show_tabs_content_div= $('<div class="index_application_show_tabs_content_div"></div>');
createContainer.append(index_application_show_tabs_content_div); createContainer.append(index_application_show_tabs_content_div);
var app_img = $('<div><img src="'+ctx+'/custom/images/index_application_img.png" width="40" height="40"/></div>'); var app_img = $('<div><img src="'+ctx+'/photo/photo.jsp?ls_photo='+ apps[i].IMG_ID_S +'" width="60" height="60"/></div>');
var app_text1=$('<div class="index_application_show_tabs_content_text"></div>').text(apps[i].NAME); var app_text1=$('<div class="index_application_show_tabs_content_text"></div>').text(apps[i].NAME);
var app_text2=$('<div class="index_application_show_tabs_content_text" style="margin-top:2px;"></div>'); var app_text2=$('<div class="index_application_show_tabs_content_text" style="margin-top:2px;"></div>');
//判断是用户安装的还是系统自带的 //判断是用户安装的还是系统自带的
...@@ -432,10 +449,16 @@ function init_index_apps(){ ...@@ -432,10 +449,16 @@ function init_index_apps(){
var app_isInstall = $('<div class="index_application_show_tabs_content_img" onclick="index_application_isLoad(this)"><img src="'+ ctx +'/custom/images/index_application_unLoad.png" width="16" height="16"/><span>卸载</span></div>'); var app_isInstall = $('<div class="index_application_show_tabs_content_img" onclick="index_application_isLoad(this)"><img src="'+ ctx +'/custom/images/index_application_unLoad.png" width="16" height="16"/><span>卸载</span></div>');
//判断是否卸载 //判断是否卸载
if(!apps[i].USERID){ if(!apps[i].USERID){
//先处理下数据,如果是安装的那就加一个属性CUSTOMINSTALL为1,否则为0
apps[i].CUSTOM_INSTALL='0';
app_isInstall.css('background','#1887f6'); app_isInstall.css('background','#1887f6');
app_isInstall.find('img').attr('src',ctx+'/custom/images/index_application_load.png'); app_isInstall.find('img').attr('src',ctx+'/custom/images/index_application_load.png');
app_isInstall.find('span').text('安装'); app_isInstall.find('span').text('安装');
} }
else{
//先处理下数据,如果是安装的那就加一个属性CUSTOMINSTALL为1,否则为0
apps[i].CUSTOM_INSTALL='1';
}
index_application_show_tabs_content_div.append(app_img).append(app_text1).append(app_text2).append(app_isInstall); index_application_show_tabs_content_div.append(app_img).append(app_text1).append(app_text2).append(app_isInstall);
} }
} }
...@@ -456,7 +479,7 @@ function index_application_toggle(){ ...@@ -456,7 +479,7 @@ function index_application_toggle(){
$('.index_application_show_tabs_content>div').each(function(index,element){ $('.index_application_show_tabs_content>div').each(function(index,element){
$(element).show(); $(element).show();
//隐藏已经安装的 //隐藏已经安装的
if($(element).data('app').USERID){ if($(element).data('app').CUSTOM_INSTALL=='1'){
$(element).hide(); $(element).hide();
} }
//再隐藏不符合tabs的 //再隐藏不符合tabs的
...@@ -471,7 +494,7 @@ function index_application_toggle(){ ...@@ -471,7 +494,7 @@ function index_application_toggle(){
$('.index_application_show_tabs_content>div').each(function(index,element){ $('.index_application_show_tabs_content>div').each(function(index,element){
$(element).show(); $(element).show();
//隐藏未安装的 //隐藏未安装的
if(!$(element).data('app').USERID){ if($(element).data('app').CUSTOM_INSTALL=='0'){
$(element).hide(); $(element).hide();
} }
//再隐藏不符合tabs的 //再隐藏不符合tabs的
......
...@@ -495,6 +495,7 @@ a{ ...@@ -495,6 +495,7 @@ a{
.index_container_application_text img{ .index_container_application_text img{
display:block; display:block;
margin:44px auto 15px; margin:44px auto 15px;
border-radius: 10px;
} }
.index_container_application>div{ .index_container_application>div{
margin-bottom:20px; margin-bottom:20px;
...@@ -744,6 +745,7 @@ a{ ...@@ -744,6 +745,7 @@ a{
height:25px; height:25px;
ontline:none; ontline:none;
width:120px; width:120px;
cursor: pointer;
} }
.index_module_insertBtn{ .index_module_insertBtn{
font-size: 18px; font-size: 18px;
...@@ -767,6 +769,17 @@ a{ ...@@ -767,6 +769,17 @@ a{
line-height: 20px; line-height: 20px;
margin-top: 10px; margin-top: 10px;
} }
.index_application_noApp{
margin-top:20px;
font-size:18px;
display:inline-block;
border-bottom:2px solid white;
cursor: pointer;
}
.index_application_noApp:hover{
color:#1887f6;
border-bottom:2px solid #1887f6;
}
/********************超过1200px的屏幕时******************/ /********************超过1200px的屏幕时******************/
@media screen and (min-width:1200px){ @media screen and (min-width:1200px){
.index_container_application_text>div{ .index_container_application_text>div{
......
...@@ -533,6 +533,12 @@ function index_update_module(handler){ ...@@ -533,6 +533,12 @@ function index_update_module(handler){
//2.存放到数据库 //2.存放到数据库
var portlets=[]; var portlets=[];
for(var i=0;i<newJson.length;i++){ for(var i=0;i<newJson.length;i++){
//如果是新增模块时
if(!newJson[i]){
$.fancybox.open('<div style="color: #1887f6;font-weight: bold;font-size:18px;line-height:30px;">还有资源没有选择...</div>');
setTimeout('$.fancybox.close();index_module_edit()',1000);
return;
}
var requestObj={}; var requestObj={};
requestObj.PORTLET_ID=newJson[i].PORTLET_ID; requestObj.PORTLET_ID=newJson[i].PORTLET_ID;
portlets.push(requestObj); portlets.push(requestObj);
...@@ -580,7 +586,7 @@ function index_cancel_module(handler){ ...@@ -580,7 +586,7 @@ function index_cancel_module(handler){
//放大功能 //放大功能
function index_changeBig_calendar(handler){ function index_changeBig_calendar(handler){
if($(handler).prevAll('select').css('display')=='inline-block'){ if($(handler).prevAll('select').css('display')=='inline-block'){
$.fancybox.open('<div style="color: #1887f6;font-weight: bold;font-size:18px;">正处于编辑状态,无法放大...</div>'); $.fancybox.open('<div style="color: #1887f6;font-weight: bold;font-size:18px;line-height:30px;">正处于编辑状态,无法放大...</div>');
setTimeout('$.fancybox.close()',1000); setTimeout('$.fancybox.close()',1000);
return; return;
} }
...@@ -891,18 +897,53 @@ function index_application(handler){ ...@@ -891,18 +897,53 @@ function index_application(handler){
} }
//初始化应用 //初始化应用
function init_index_application(){ function init_index_application(data){
var list_allApps = jwAppAppsModel.jwAppsAppsDataAction.list_allApps_by_user({FIELD_COLUMN_ID:$('.layout_center_navClick').data('uuid')}).apps.rowSet; var list_row = data;
var app_container = $('.index_container_application_text');
//清空容器
app_container.html('');
//把未安装的app过滤掉 //把未安装的app过滤掉
var list_insert = []; var list_insert = [];
for(var j=0;j<list_allApps.length;j++){ if(!data){
if(list_allApps[j].USERID){ list_row = jwAppAppsModel.jwAppsAppsDataAction.list_allApps_by_user({FIELD_COLUMN_ID:$('.layout_center_navClick').data('uuid')});
list_insert.push(list_allApps[j]);
var list_allApps = list_row.apps.rowSet;
//flag区分是否存在已经安装的
var flag = true;
for(var j=0;j<list_allApps.length;j++){
if(list_allApps[j].USERID){
list_insert.push(list_allApps[j]);
flag=false;
}
}
//如果没有应用时
if(flag==true){
app_container.append('<span onclick="index_application()" class="index_application_noApp">暂无安装的应用,请去添加...</span>');
return;
}
}
else{
list_insert = list_row;
if(list_insert.length==0){
app_container.append('<span onclick="index_application()" class="index_application_noApp">暂无安装的应用,请去添加...</span>');
return;
} }
} }
//形成模板
for(var i = 0;i<list_insert.length;i++){ for(var i = 0;i<list_insert.length;i++){
var app_container = $('.index_container_application_text'); var app_div = $('<div></div>').data('app',list_insert[i]);
var app_div = $('<div></div>'); app_div.bind('click',function(){
var data = $(this).data('app');
if(data.IS_POPUP=='1'){
//弹出框
alert('弹出框')
}
else{
//新页面
alert('新页面')
}
});
//每隔5个加个样式 //每隔5个加个样式
if((i+1)%5==0){ if((i+1)%5==0){
app_div.css('marginRight','0'); app_div.css('marginRight','0');
......
...@@ -2,14 +2,34 @@ ...@@ -2,14 +2,34 @@
.verticalAlign{ vertical-align:middle; display:inline-block; height:100%; margin-left:-1px;} .verticalAlign{ vertical-align:middle; display:inline-block; height:100%; margin-left:-1px;}
.xcConfirm .xc_layer{position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #666666; opacity: 0.5; z-index: 2147000000;} .xcConfirm .xc_layer{position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #666666; opacity: 0.5; z-index: 2147000000;}
.xcConfirm .popBox{position: fixed; left: 50%; top: 50%; background-color: #ffffff; z-index: 2147000001; width: 570px; height: 300px; margin-left: -285px; margin-top: -150px; border-radius: 5px; font-weight: bold; color: #535e66;} /* .xcConfirm .popBox{position: fixed; left: 50%; top: 50%; background-color: #ffffff; z-index: 2147000001; width: 570px; height: 300px; margin-left: -285px; margin-top: -150px; border-radius: 5px; font-weight: bold; color: #535e66;} */
.xcConfirm .popBox{
position: fixed;
left: 50%;
top: 50%;
background-color: #ffffff;
z-index: 2147000001;
width: 570px;
height: 250px;
margin-left: -285px;
margin-top: -125px;
border-radius: 5px;
font-weight: bold;
color: #535e66;
}
.xcConfirm .popBox .ttBox{height: 59px; line-height: 30px; padding: 14px 30px; border-bottom: solid 1px #eef0f1;} .xcConfirm .popBox .ttBox{height: 59px; line-height: 30px; padding: 14px 30px; border-bottom: solid 1px #eef0f1;}
.xcConfirm .popBox .ttBox .tt{font-size: 18px; display: block; float: left; height: 30px; position: relative;} .xcConfirm .popBox .ttBox .tt{font-size: 18px; display: block; float: left; height: 30px; position: relative;}
.xcConfirm .popBox .ttBox .clsBtn{display: block; cursor: pointer; width: 12px; height: 12px; position: absolute; top: 22px; right: 30px; background: url(../img/icons.png) -48px -96px no-repeat;} .xcConfirm .popBox .ttBox .clsBtn{display: block; cursor: pointer; width: 12px; height: 12px; position: absolute; top: 22px; right: 30px; background: url(../img/icons.png) -48px -96px no-repeat;}
/* .xcConfirm .popBox .ttBox .clsBtn:hover{ /* .xcConfirm .popBox .ttBox .clsBtn:hover{
} */ } */
.xcConfirm .popBox .txtBox{margin: 40px 100px; height: 100px; overflow: hidden;} /* .xcConfirm .popBox .txtBox{margin: 40px 100px; height: 100px; overflow: hidden;} */
.xcConfirm .popBox .txtBox{
margin: 30px 100px;
height: 57px;
overflow: hidden;
margin-top: 40px;
}
.xcConfirm .popBox .txtBox .bigIcon{float: left; margin-right: 20px; width: 48px; height: 48px; background-image: url(../img/icons.png); background-repeat: no-repeat; background-position: 48px 0;} .xcConfirm .popBox .txtBox .bigIcon{float: left; margin-right: 20px; width: 48px; height: 48px; background-image: url(../img/icons.png); background-repeat: no-repeat; background-position: 48px 0;}
.xcConfirm .popBox .txtBox p{ height: 84px; margin-top: 16px; line-height: 26px; overflow-x: hidden; overflow-y: auto;} .xcConfirm .popBox .txtBox p{ height: 84px; margin-top: 16px; line-height: 26px; overflow-x: hidden; overflow-y: auto;}
.xcConfirm .popBox .txtBox p input{width: 364px; height: 30px; border: solid 1px #eef0f1; font-size: 18px; margin-top: 6px;} .xcConfirm .popBox .txtBox p input{width: 364px; height: 30px; border: solid 1px #eef0f1; font-size: 18px; margin-top: 6px;}
......
...@@ -6,6 +6,7 @@ import com.gaowj.business.action.BasicAction; ...@@ -6,6 +6,7 @@ import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager; import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException; import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.RequestUtils; import com.gaowj.business.util.RequestUtils;
import com.gaowj.business.util.SessionUtil;
import com.jw.app.business.AppsBusiness; import com.jw.app.business.AppsBusiness;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
...@@ -38,8 +39,10 @@ public class actAction extends BasicAction{ ...@@ -38,8 +39,10 @@ public class actAction extends BasicAction{
.getBusiness(AppsBusiness.class); .getBusiness(AppsBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request, Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX); RequestUtils.UPDATEDATAFIELDPREFIX);
query.put("APP_ID", RequestUtils.getString(request, "RESOURCE_ID")); //设置当前登陆人
/*business.insert_installApp_byResourceId();*/ query.put("USER_ID", SessionUtil.getEmid());
query.put("APP_ID", RequestUtils.getString(request, "APP_ID"));
business.insert_installApp(query);
return "json"; return "json";
} }
...@@ -54,8 +57,10 @@ public class actAction extends BasicAction{ ...@@ -54,8 +57,10 @@ public class actAction extends BasicAction{
.getBusiness(AppsBusiness.class); .getBusiness(AppsBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request, Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX); RequestUtils.UPDATEDATAFIELDPREFIX);
query.put("RESOURCE_ID", RequestUtils.getString(request, "RESOURCE_ID")); //设置当前登陆人
/*business.insert_unInstallApp_byResourceId();*/ query.put("USER_ID", SessionUtil.getEmid());
query.put("APP_ID", RequestUtils.getString(request, "APP_ID"));
business.insert_unInstallApp(query);
return "json"; return "json";
} }
......
...@@ -2,12 +2,11 @@ package com.jw.app.apps.action; ...@@ -2,12 +2,11 @@ package com.jw.app.apps.action;
import java.sql.SQLException; import java.sql.SQLException;
import java.text.ParseException; import java.text.ParseException;
import java.util.ArrayList;
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 net.sf.json.JSONObject;
import com.gaowj.business.action.BasicAction; import com.gaowj.business.action.BasicAction;
import com.gaowj.business.comp.BusinessManager; import com.gaowj.business.comp.BusinessManager;
import com.gaowj.business.exception.BusinessException; import com.gaowj.business.exception.BusinessException;
...@@ -16,6 +15,8 @@ import com.gaowj.business.util.SessionUtil; ...@@ -16,6 +15,8 @@ import com.gaowj.business.util.SessionUtil;
import com.jw.app.business.AppsBusiness; import com.jw.app.business.AppsBusiness;
import com.jw.app.business.utils.QueryParamUtil; import com.jw.app.business.utils.QueryParamUtil;
import net.sf.json.JSONObject;
public class dataAction extends BasicAction{ public class dataAction extends BasicAction{
/** /**
...@@ -57,14 +58,6 @@ public class dataAction extends BasicAction{ ...@@ -57,14 +58,6 @@ public class dataAction extends BasicAction{
public String list_allApps_by_user() throws BusinessException{ public String list_allApps_by_user() throws BusinessException{
jsonObject=new JSONObject(); jsonObject=new JSONObject();
//1.根据用户id,获取 //1.根据用户id,获取
/*SELECT * FROM (
SELECT ai_in.* FROM app_install ai_in where ai_in.USERID='6666'
) ai
RIGHT JOIN apps_app apps ON ai.APP_ID=apps.APP_ID*/
/*PortletBusiness business = BusinessManager
.getBusiness(PortletBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);*/
AppsBusiness business = BusinessManager AppsBusiness business = BusinessManager
.getBusiness(AppsBusiness.class); .getBusiness(AppsBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request, Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
...@@ -75,32 +68,56 @@ public class dataAction extends BasicAction{ ...@@ -75,32 +68,56 @@ public class dataAction extends BasicAction{
query.put("USER_ID", SessionUtil.getEmid()); query.put("USER_ID", SessionUtil.getEmid());
List<Map<String, Object>> listData = business List<Map<String, Object>> listData = business
.list_allApps_by_user(query); .list_allApps_by_user(query);
//flag=true表示未安装
Boolean flag = true;
//查找所有的app类型
Map<String, Object> queryCategory = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
List<Map<String, Object>> listCategory = business
.list_allCategory(queryCategory);
private_putMapByKey("types",listCategory);
for (Map<String, Object> rm : listData) { for (Map<String, Object> rm : listData) {
if(rm.get("USERID")!=null){ if(rm.get("USERID")!=null){
Map<String, Object> data = new HashMap<String, Object>(); private_putMapByKey("apps",listData);
data.put("rowSet", QueryParamUtil.DateToString(listData)); flag=false;
data.put("pageNo", 1); /*System.out.println("正常");*/
data.put("pageSize", listData.size());
data.put("pageCount", listData.size());
data.put("rows", data.get("rowSet"));
data.put("total", listData.size());
jsonObject.put("apps",data);
//查找所有的应用所属的类型
Map<String, Object> queryCategory = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
List<Map<String, Object>> listCategory = business
.list_allCategory(queryCategory);
Map<String, Object> allCategory = new HashMap<String, Object>();
allCategory.put("rowSet", QueryParamUtil.DateToString(listCategory));
allCategory.put("pageNo", 1);
allCategory.put("pageSize", listCategory.size());
allCategory.put("pageCount", listCategory.size());
allCategory.put("rows", allCategory.get("rowSet"));
allCategory.put("total", listCategory.size());
jsonObject.put("types",listCategory);
break; break;
} }
} }
//2上述结果中的USERID全部为null,表示一个app都没安装
if(flag==true){
//3.根据用户id来验证apps_uninstall有没有数据
List<Map<String, Object>> listUninstallData = business
.list_allUninstallApps_by_user(query);
if(listUninstallData.size()!=0){
//要把所有的应用都返回出去
Map<String, Object> queryApp = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
List<Map<String, Object>> listAllApps = business
.list_AllApps(queryApp);
/*System.out.println("未安装表里有");*/
private_putMapByKey("apps",listAllApps);
}
else{
//4.如果也没有,表示这个用户是新建用户,需要初始化应用
//5.初始化应用
//6.把默认的app应用添加到install表中
//7.把不默认的app应用添加到uninstall表中
Map<String, Object> queryDefaultApp = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
business.init_defaultApps(queryDefaultApp);
//8.重新查询关联表获得数据
List<Map<String, Object>> defaultData = business
.list_allApps_by_user(query);
/*System.out.println("默认");*/
private_putMapByKey("apps",defaultData);
}
}
} catch (SQLException e) { } catch (SQLException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
...@@ -108,14 +125,18 @@ public class dataAction extends BasicAction{ ...@@ -108,14 +125,18 @@ public class dataAction extends BasicAction{
// TODO Auto-generated catch block // TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
//2上述结果中的USERID全部为null,表示一个app都没安装
//3.验证apps_uninstall有没有数据
//4.如果也没有,表示这个用户是新建用户,需要初始化应用
//5.初始化应用
return "json"; return "json";
} }
private void private_putMapByKey(String key,List<Map<String, Object>> list) throws SQLException {
Map<String, Object> listMap = new HashMap<String, Object>();
listMap.put("rowSet", QueryParamUtil.DateToString(list));
listMap.put("pageNo", 1);
listMap.put("pageSize", list.size());
listMap.put("pageCount", list.size());
listMap.put("rows", listMap.get("rowSet"));
listMap.put("total", list.size());
jsonObject.put(key,listMap);
}
} }
...@@ -24,5 +24,36 @@ public interface AppsBusiness { ...@@ -24,5 +24,36 @@ public interface AppsBusiness {
* @return * @return
*/ */
List<Map<String, Object>> list_allCategory(Map<String, Object> query) throws BusinessException ; List<Map<String, Object>> list_allCategory(Map<String, Object> query) throws BusinessException ;
/**卸载应用
*
* @param query
*/
void insert_unInstallApp(Map<String, Object> query) throws BusinessException ;
/**安装应用
*
* @param query
*/
void insert_installApp(Map<String, Object> query) throws BusinessException ;
/**根据用户id来查找apps_uninstall的数据
*
* @param query
* @return
*/
List<Map<String, Object>> list_allUninstallApps_by_user(Map<String, Object> query) throws BusinessException ;
/**查找所有的app应用
*
* @param queryApp
* @return
*/
List<Map<String, Object>> list_AllApps(Map<String, Object> query) throws BusinessException ;
/**把默认的app应用添加到install表中并把不默认的app应用添加到uninstall表中
*
* @param queryDefaultApp
*/
void init_defaultApps(Map<String, Object> query) throws BusinessException ;
} }
...@@ -2,8 +2,13 @@ package com.jw.app.business.apps; ...@@ -2,8 +2,13 @@ package com.jw.app.business.apps;
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.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;
...@@ -53,4 +58,114 @@ public class AppsBusinessImpl implements AppsBusiness { ...@@ -53,4 +58,114 @@ public class AppsBusinessImpl implements AppsBusiness {
return listData; return listData;
} }
@Override
public void insert_unInstallApp(Map<String, Object> query) {
//1.先删除安装表里面的数据
appsDAO.delete_installApp(query);
//2.添加未安装表的数据
private_insert_unInstallApp(query);
}
/**添加未安装的数据
*
* @param query
*/
private void private_insert_unInstallApp(Map<String, Object> query) {
Map<String, Object> insertQuery = new HashMap<String, Object>();
insertQuery.put("APP_ID", query.get("APP_ID"));
insertQuery.put("USERID", SessionUtil.getEmid());
insertQuery.put("RESOURCE_ID", UUID.randomUUID().toString());
appsDAO.insert_unInstallApp(mapToList(insertQuery));
}
@Override
public void insert_installApp(Map<String, Object> query) {
//1.先删除未安装表里面的数据
appsDAO.delete_unInstallApp(query);
//2.添加安装表的数据
private_insert_installApp(query);
}
/**添加安装的数据
*
* @param query
*/
private void private_insert_installApp(Map<String, Object> query) {
Map<String, Object> insertQuery = new HashMap<String, Object>();
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String now = formatter.format(new Date());
insertQuery.put("APP_ID", query.get("APP_ID"));
insertQuery.put("INSTALL_TIME", now);
insertQuery.put("USERID", SessionUtil.getEmid());
insertQuery.put("RESOURCE_ID", UUID.randomUUID().toString());
appsDAO.insert_installApp(mapToList(insertQuery));
}
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;
}
@Override
public List<Map<String, Object>> list_allUninstallApps_by_user(Map<String, Object> query) throws BusinessException {
List<Map<String, Object>> listData = null;
try {
listData = QueryParamUtil.ClobToString(appsDAO.list_allUninstallApps_by_user(query));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listData;
}
@Override
public List<Map<String, Object>> list_AllApps(Map<String, Object> query) throws BusinessException {
List<Map<String, Object>> listData = null;
try {
listData = QueryParamUtil.ClobToString(appsDAO.list_AllApps(query));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listData;
}
@Override
public void init_defaultApps(Map<String, Object> query) throws BusinessException {
try {
//1.先获得所有的apps应用
List<Map<String, Object>> listData = QueryParamUtil.ClobToString(appsDAO.list_AllApps(query));
for(Map<String, Object> data : listData){
Map<String, Object> defaultQuery = new HashMap<String, Object>();
defaultQuery.put("APP_ID",data.get("APP_ID"));
if("0".equals(data.get("IS_DEFAULT"))){
//2.遍历所有的app,如果是默认应用,则添加到install表中
private_insert_installApp(defaultQuery);
}
else{
//3.否则添加到uninstall表中
private_insert_unInstallApp(defaultQuery);
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} }
...@@ -11,5 +11,16 @@ public interface AppsDAO { ...@@ -11,5 +11,16 @@ public interface AppsDAO {
List<Map<String,Object>> list_allApps_by_user(Map<String,Object> query) throws BusinessException ; List<Map<String,Object>> list_allApps_by_user(Map<String,Object> query) throws BusinessException ;
List<Map<String,Object>> list_allCategory(Map<String,Object> query) throws BusinessException ; List<Map<String,Object>> list_allCategory(Map<String,Object> query) throws BusinessException ;
void delete_installApp(Map<String, Object> query) throws BusinessException;
void insert_installApp(List<Map<String,Object>> query) throws BusinessException;
void delete_unInstallApp(Map<String, Object> query) throws BusinessException;
void insert_unInstallApp(List<Map<String,Object>> query) throws BusinessException;
List<Map<String,Object>> list_allUninstallApps_by_user(Map<String,Object> query) throws BusinessException ;
List<Map<String,Object>> list_AllApps(Map<String,Object> query) throws BusinessException ;
} }
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
<mapper namespace="com.jw.app.business.apps.AppsDAO"> <mapper namespace="com.jw.app.business.apps.AppsDAO">
<select id="list_allApps_by_user" parameterType="map" <select id="list_allApps_by_user" parameterType="map"
resultType="upperCaseKeyMap"> resultType="upperCaseKeyMap">
SELECT * FROM ( SELECT apps.* , ai.RESOURCE_ID , ai.USERID FROM (
SELECT ai_in.* FROM app_install ai_in where ai_in.USERID=#{USER_ID} SELECT ai_in.* FROM app_install ai_in where ai_in.USERID=#{USER_ID}
) ai ) ai
RIGHT JOIN apps_app apps ON ai.APP_ID=apps.APP_ID RIGHT JOIN apps_app apps ON ai.APP_ID=apps.APP_ID
...@@ -14,11 +14,11 @@ ...@@ -14,11 +14,11 @@
SELECT * FROM apps_category SELECT * FROM apps_category
</select> </select>
<delete id="delete_installApp_byResourceId" parameterType="map"> <delete id="delete_installApp" parameterType="map">
delete from app_install where RESOURCE_ID=#{RESOURCE_ID} delete from app_install where APP_ID=#{APP_ID} and USERID=#{USER_ID}
</delete> </delete>
<insert id="insert_installApp_byResourceId" parameterType="java.util.List"> <insert id="insert_installApp" parameterType="java.util.List">
insert into app_install( insert into app_install(
<trim prefix="" suffixOverrides=","> <trim prefix="" suffixOverrides=",">
<foreach collection="list" item="field"> <foreach collection="list" item="field">
...@@ -34,11 +34,11 @@ ...@@ -34,11 +34,11 @@
<![CDATA[ ) ]]> <![CDATA[ ) ]]>
</insert> </insert>
<delete id="delete_unInstallApp_byResourceId" parameterType="map"> <delete id="delete_unInstallApp" parameterType="map">
delete from apps_uninstall where RESOURCE_ID=#{RESOURCE_ID} delete from apps_uninstall where APP_ID=#{APP_ID} and USERID=#{USER_ID}
</delete> </delete>
<insert id="insert_unInstallApp_byResourceId" parameterType="java.util.List"> <insert id="insert_unInstallApp" parameterType="java.util.List">
insert into apps_uninstall( insert into apps_uninstall(
<trim prefix="" suffixOverrides=","> <trim prefix="" suffixOverrides=",">
<foreach collection="list" item="field"> <foreach collection="list" item="field">
...@@ -54,4 +54,14 @@ ...@@ -54,4 +54,14 @@
<![CDATA[ ) ]]> <![CDATA[ ) ]]>
</insert> </insert>
<select id="list_allUninstallApps_by_user" parameterType="map"
resultType="upperCaseKeyMap">
SELECT * FROM apps_uninstall where USERID=#{USER_ID}
</select>
<select id="list_AllApps" parameterType="map"
resultType="upperCaseKeyMap">
SELECT * FROM apps_app
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -94,7 +94,7 @@ ...@@ -94,7 +94,7 @@
<select id="list_portlet_columns" parameterType="map" <select id="list_portlet_columns" parameterType="map"
resultType="upperCaseKeyMap"> resultType="upperCaseKeyMap">
<![CDATA[ <![CDATA[
select * from portlet_columns pc select * from portlet_columns pc WHERE parent_id !="0"
]]> ]]>
<!-- <trim prefix="WHERE" prefixOverrides="AND |OR"> <!-- <trim prefix="WHERE" prefixOverrides="AND |OR">
<if test="NAME != null and NAME != ''"> <if test="NAME != null and NAME != ''">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment