/***********************************************************************
* System : NLSOS
* Date : 2011-12-27
* Description :
************************************************************************/
package department;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import jp.co.ana.fmc.fis.fid.common.json.JSON;
import common.action.AbstractCommonAction;
import common.service.CommonService;
/**
*
*/
@SuppressWarnings("serial")
public class Action extends AbstractCommonAction {
/** Bean */
private Bean bean;
/** Service */
private Service service ;
//开始记录数
private int start ;
private int limit ;
/** Service */
private CommonService commonService = null;
Map<String, Object> jsonMap = new HashMap<String, Object>();
/**
* Action 处理执行.
*
* @return Action 处理执行结果.
*/
public String doAction() throws Exception {
// 日志
this.writeLog(this.getClass().getName(), ACTION_START);
// 日志
this.writeLog(this.getClass().getName(), ACTION_END);
return SUCCESS;
}
/**
* 获取一层(下级)的部门信息
*
* 通常为部门树做准备
*
* @return Json.
*/
public void getList() throws Exception{
// 实例化
bean = new Bean();
// 接收参数
bean.setPageStart(start);
bean.setPageSize(limit);
// 取数据
List<Bean> list = service.getList(bean);
// 记录总数
int totalCount = service.getTotalCount(bean).getTotalCount();
// 组织 Json
jsonMap.put("totalCount", totalCount + "" );
jsonMap.put("list", list );
// 响应
//getResponse().getWriter().write("["+JSON.serialize(jsonMap)+"]");
getResponse().getWriter().write(JSON.serialize(jsonMap));
}
/**
* 获取一层(下级)的部门信息
*
* 为部门树做准备
*
* @return Json.
*/
public void getChildren() throws Exception{
// bean = new Bean();
List<Bean> list = service.getChildren(bean);
// 暂时未用到。
// JSONArray jsonObject = JSONArray.fromObject(list);
//jsonMap.put("text", "事业局");
//jsonMap.put("cls", "folder");
//jsonMap.put("children", list );
//jsonMap.putAll( jsonMap);
//getResponse().getWriter().write("["+JSON.serialize(jsonMap)+"]");
getResponse().getWriter().write(JSON.serialize(list));
}
/**
* 增删改(含批量删).
*
* @return Json.
*/
public void modify() throws Exception{
if( bean.getAction().equalsIgnoreCase("Audit") ){
// 取登录用户ID
//bean.setAuditorId( ((UserBean)this.getSession().get("user")).getEmployee().getId() );
}
bean = service.modify( bean );
jsonMap.put("code", bean.getCode() );
jsonMap.put("message", bean.getMessage() );
// 为 Ext 返回参数。
if("0".equals( bean.getCode() )){
jsonMap.put("success", "true");
}
getResponse().getWriter().write(JSON.serialize(jsonMap));
this.writeLog(this.getClass().getName(), ACTION_END);
}
public void setBean(Bean bean) {
this.bean = bean;
}
public Bean getBean() {
return bean;
}
public void setCommonService(CommonService commonService) {
this.commonService = commonService;
}
public CommonService getCommonService() {
return commonService;
}
public Service getService() {
return service;
}
public void setService(Service service) {
this.service = service;
}
public int getStart() {
return start;
}
public void setStart(int start) {
this.start = start;
}
public int getLimit() {
return limit;
}
public void setLimit(int limit) {
this.limit = limit;
}
}