Commit f070064d by 罗绍泽

interface:获取当前登陆人的资源列表

script:<script type="text/javascript" src="${ctx}/jwapp/pages/portlet/js/jwAppPortletModule.js" charset="utf-8"></script>
method:jwAppPortletModel.jwAppsPortletDataAction.listAllPTemplateByUser()
parent 98e6116d
...@@ -205,4 +205,5 @@ ...@@ -205,4 +205,5 @@
<import resource="business-system.xml"/> <import resource="business-system.xml"/>
<import resource="business-standard.xml"/> <import resource="business-standard.xml"/>
<import resource="business-test.xml"/> <import resource="business-test.xml"/>
<import resource="business-apps.xml"/>
</beans> </beans>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
<bean id="sqlSessionFactory-apps" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource-business" />
<property name="configLocation" value="/WEB-INF/conf/gaowj/bl/mybatis-config.xml" />
<property name="mapperLocations">
<list>
<value>classpath:com/jw/app/business/portlet/PortletDAO.xml</value>
</list>
</property>
</bean>
<!-- BusinessInterFace -->
<bean id="PortletBusiness"
class="com.jw.app.business.portlet.PortletBusinessImpl">
<property name="portletDAO" ref="portletDAO"/>
</bean>
<!-- DAO -->
<bean id="portletDAO" class="org.mybatis.spring.mapper.MapperFactoryBean">
<property name="mapperInterface" value="com.jw.app.business.portlet.PortletDAO"/>
<property name="sqlSessionFactory" ref="sqlSessionFactory-apps"/>
</bean>
</beans>
//此乃本模块与后台交互的方法接口部分
var jwAppPortletModel = function(format) {
this.module = "";
this.action = "";
this.format = format;
};
//定义数据交互
jwAppPortletModel.prototype = BusinessObject;
//获取当前登陆人的资源列表
jwAppPortletModel.prototype.listAllPTemplateByUser = function(){};
//创建一个数据操作对象,然后再后续使用
jwAppPortletModel.jwAppsPortletActAction = new jwAppPortletModel("json").delegate("jwAppsPortletAct");
//创建一个数据获取对象,然后再后续使用
jwAppPortletModel.jwAppsPortletDataAction = new jwAppPortletModel("json").delegate("jwAppsPortletData");
//说明: 1、所有方法里统一传递josn格式的参数,用于后台交互,如data.listTables(param) ,如没有参数则传'{}',如data.listTables({})
// 2、前后台数据获取传输协议 如:json[{'0':{pageCount':'2','pageNo':'1','pageSize':'20','rowSet':'[{0},{1}....]'}}]
// 3、前后台增删改的返回状态 如:json[{'0':{'rowSet':{'NAME':'-1','VALUE':'保存失败'}}}]
...@@ -4,5 +4,18 @@ ...@@ -4,5 +4,18 @@
"http://struts.apache.org/dtds/struts-2.3.dtd"> "http://struts.apache.org/dtds/struts-2.3.dtd">
<struts> <struts>
<package name="src_jwapp" extends="gaowj">
<action name="jwAppsPortletAct_*" class="com.jw.app.portlet.action.actAction"
method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
<action name="jwAppsPortletData_*" class="com.jw.app.portlet.action.dataAction"
method="{1}">
<result name="json" type="json">
<param name="root">jsonObject</param>
</result>
</action>
</package>
</struts> </struts>
package com.jw.app.business;
import java.util.List;
import java.util.Map;
import org.springframework.stereotype.Service;
import com.gaowj.business.exception.BusinessException;
@Service
public interface PortletBusiness {
List<Map<String,Object>> list_portlet_template_by_user(Map<String, Object> query) throws BusinessException ;
}
package com.jw.app.business.portlet;
import java.io.IOException;
import java.sql.SQLException;
import java.util.List;
import java.util.Map;
import com.gaowj.business.exception.BusinessException;
import com.gaowj.business.util.SessionUtil;
import com.jw.app.business.PortletBusiness;
import com.jw.app.business.utils.QueryParamUtil;
public class PortletBusinessImpl implements PortletBusiness {
private PortletDAO portletDAO;
public PortletDAO getPortletDAO() {
return portletDAO;
}
public void setPortletDAO(PortletDAO portletDAO) {
this.portletDAO = portletDAO;
}
@Override
public List<Map<String, Object>> list_portlet_template_by_user(Map<String, Object> query)
throws BusinessException {
List<Map<String, Object>> listData=null;
try {
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));
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return listData;
}
}
package com.jw.app.business.portlet;
import java.util.List;
import java.util.Map;
import org.apache.ibatis.session.RowBounds;
import com.gaowj.business.exception.BusinessException;
public interface PortletDAO {
List<Map<String,Object>> list_portlet_template_user(Map<String,Object> query) throws BusinessException ;
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.jw.app.business.portlet.PortletDAO">
<select id="list_portlet_template_user" parameterType="map"
resultType="upperCaseKeyMap">
<![CDATA[
select * from portlet_template_user ptu
left JOIN portlet_template pt ON ptu.portlet_id=pt.portlet_id
]]>
<trim prefix="WHERE" prefixOverrides="AND |OR">
<!-- 不得省略,用于剔除portlet_template中被删除的模块 -->
and pt.PORTLET_ID IS NOT NULL
<if test="PORTLET_ID != null and PORTLET_ID != ''">
and pt.PORTLET_ID = #{PORTLET_ID}
</if>
<if test="NAME != null and NAME != ''">
and pt.NAME like '%${NAME}%'
</if>
<if test="TITLE != null and TITLE != ''">
and pt.TITLE like '%${TITLE}%'
</if>
<if test="P_TYPE != null and P_TYPE != ''">
and pt.P_TYPE = #{P_TYPE}
</if>
<if test="CREATOR_ID != null and CREATOR_ID != ''">
and pt.CREATOR_ID = #{CREATOR_ID}
</if>
<if test="START_TIME != null and START_TIME != ''">
and pt.CREATE_TIME &gt;= #{START_TIME}
</if>
<if test="END_TIME != null and END_TIME != ''">
and pt.CREATE_TIME &lt;= #{END_TIME}
</if>
<if test="TASKTIMER != null and TASKTIMER != ''">
and pt.TASKTIMER = #{TASKTIMER}
</if>
<if test="list != null and list != ''">
and pt.PORTLET_ID in ( ${list} )
</if>
<if test="G_ID != null and G_ID != ''">
and pt.G_ID like '%${G_ID}%'
</if>
<if test="COLUMN_ID != null and COLUMN_ID != ''">
and pt.COLUMN_ID = #{COLUMN_ID}
</if>
<if test="USER_ID != null and USER_ID != ''">
and ptu.USER_ID = #{USER_ID}
</if>
</trim>
ORDER BY ptu.ORDER_NUM ASC
</select>
</mapper>
\ No newline at end of file
package com.jw.app.portlet.action;
import com.gaowj.business.action.BasicAction;
import net.sf.json.JSONObject;
public class actAction extends BasicAction {
/**
*
*/
private static final long serialVersionUID = -8065624929370521607L;
private JSONObject jsonObject = new JSONObject();
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
}
package com.jw.app.portlet.action;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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.gaowj.business.util.SessionUtil;
import com.jw.app.business.PortletBusiness;
import com.jw.app.business.utils.QueryParamUtil;
import net.sf.json.JSONObject;
public class dataAction extends BasicAction {
/**
*
*/
private static final long serialVersionUID = -7897314852467856687L;
private JSONObject jsonObject = new JSONObject();
private int rows = 20;// 每页显示的记录数
private int page = 1;// 当前第几页
public JSONObject getJsonObject() {
return jsonObject;
}
public void setJsonObject(JSONObject jsonObject) {
this.jsonObject = jsonObject;
}
public int getRows() {
rows = getPageSize();
return rows;
}
public void setRows(int rows) {
setPageSize(rows);
this.rows = getPageSize();
}
public int getPage() {
page = getPageNo();
return page;
}
public void setPage(int page) {
setPageNo(page);
this.page = getPageNo();
}
/**
* 获取用户的资源列表
* @return
* @throws BusinessException
*/
public String listAllPTemplateByUser() throws BusinessException {
PortletBusiness business = BusinessManager
.getBusiness(PortletBusiness.class);
Map<String, Object> query = RequestUtils.getUpdateFieldMap(request,
RequestUtils.UPDATEDATAFIELDPREFIX);
try {
System.out.println();
query = QueryParamUtil.StringToDate(query);
//设置当前登陆人
query.put("USER_ID", SessionUtil.getEmid());
List<Map<String, Object>> listData = business
.list_portlet_template_by_user(query);
for (Map<String, Object> rm : listData) {
if(rm.get("P_TYPE")==null||!rm.get("P_TYPE").equals("3"))
{
rm.remove("RSS_CONTENT");
rm.remove("TAKE_CONTENT");
}
}
Map<String, Object> data = new HashMap<String, Object>();
data.put("rowSet", QueryParamUtil.DateToString(listData));
data.put("pageNo", 1);
data.put("pageSize", listData.size());
data.put("pageCount", listData.size());
data.put("rows", data.get("rowSet"));
data.put("total", listData.size());
jsonObject = new JSONObject();
jsonObject.putAll(data);
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return "json";
}
}
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