code
stringlengths
1
2.01M
repo_name
stringlengths
3
62
path
stringlengths
1
267
language
stringclasses
231 values
license
stringclasses
13 values
size
int64
1
2.01M
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-23 上午11:48:21 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-23 Initailized */ package com.zz.bsp.web.tag; import javax.servlet.jsp.JspException; import org.apache.commons.lang.StringUtils; /** * 根据分页输出排序标签 * */ public class OrderRenderTag extends BaseHandlerTag { private static final long serialVersionUID = 1190150273786407740L; // 目标排序字段 protected String realField = null; // 排序字段 protected String curField = null; // 排序方式 protected String direction = null; public int doStartTag() throws JspException { log.debug("start render..."); if(StringUtils.isNotBlank(curField)){ StringBuilder sb = new StringBuilder(" orderField=\"" + curField + "\" "); if (curField.equals(realField)) { sb.append("class=\"" + direction + "\""); } write(sb.toString()); } return super.doStartTag(); } @Override public void release() { realField = null; curField = null; direction = null; } public String getRealField() { return realField; } public void setRealField(String realField) { this.realField = realField; } public String getCurField() { return curField; } public void setCurField(String curField) { this.curField = curField; } public String getDirection() { return direction; } public void setDirection(String direction) { this.direction = direction; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/web/tag/OrderRenderTag.java
Java
asf20
1,988
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-18 上午09:42:37 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-18 Initailized */ package com.zz.bsp.web.tag; import java.lang.annotation.Annotation; import java.util.Locale; import javax.servlet.jsp.JspException; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.BodyTagSupport; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 所有TAG的基类 * */ public abstract class BaseHandlerTag extends BodyTagSupport { protected Log log = LogFactory.getLog(getClass()); private static final long serialVersionUID = -6449382767144312974L; /** * The default Locale for our server. */ protected static final Locale defaultLocale = Locale.getDefault(); /** Access key character. */ protected String accesskey = null; /** Tab index value. */ protected String tabindex = null; /** * Whether to created indexed names for fields */ protected boolean indexed = false; /** Mouse click event. */ private String onclick = null; /** Mouse double click event. */ private String ondblclick = null; /** Mouse over component event. */ private String onmouseover = null; /** Mouse exit component event. */ private String onmouseout = null; /** Mouse moved over component event. */ private String onmousemove = null; /** Mouse pressed on component event. */ private String onmousedown = null; /** Mouse released on component event. */ private String onmouseup = null; /** Key down in component event. */ private String onkeydown = null; /** Key released in component event. */ private String onkeyup = null; /** Key down and up together in component event. */ private String onkeypress = null; /** Text selected in component event. */ private String onselect = null; /** Content changed after component lost focus event. */ private String onchange = null; /** Component lost focus event. */ private String onblur = null; /** Component has received focus event. */ private String onfocus = null; /** Component is disabled. */ private boolean disabled = false; /** Component is readonly. */ private boolean readonly = false; /** Style attribute associated with component. */ private String style = null; /** Named Style class associated with component. */ private String styleClass = null; /** Identifier associated with component. */ private String styleId = null; /** The alternate text of this element. */ private String alt = null; /** The name of the message resources bundle for message lookups. */ private String bundle = null; /** The name of the session attribute key for our locale. */ private String locale = null; /** The advisory title of this element. */ private String title = null; //验证的对象 private Object chkObject; //验证的class名称 private String chkClazz; //验证的字段 private String chkField; /** Sets the accessKey character. */ public void setAccesskey(String accessKey) { this.accesskey = accessKey; } /** Returns the accessKey character. */ public String getAccesskey() { return (this.accesskey); } /** Sets the tabIndex value. */ public void setTabindex(String tabIndex) { this.tabindex = tabIndex; } /** Returns the tabIndex value. */ public String getTabindex() { return (this.tabindex); } // Indexing ability for Iterate /** * Sets the indexed value. */ public void setIndexed(boolean indexed) { this.indexed = indexed; } /** * Returns the indexed value. */ public boolean getIndexed() { return (this.indexed); } // Mouse Events /** Sets the onClick event handler. */ public void setOnclick(String onClick) { this.onclick = onClick; } /** Returns the onClick event handler. */ public String getOnclick() { return onclick; } /** Sets the onDblClick event handler. */ public void setOndblclick(String onDblClick) { this.ondblclick = onDblClick; } /** Returns the onDblClick event handler. */ public String getOndblclick() { return ondblclick; } /** Sets the onMouseDown event handler. */ public void setOnmousedown(String onMouseDown) { this.onmousedown = onMouseDown; } /** Returns the onMouseDown event handler. */ public String getOnmousedown() { return onmousedown; } /** Sets the onMouseUp event handler. */ public void setOnmouseup(String onMouseUp) { this.onmouseup = onMouseUp; } /** Returns the onMouseUp event handler. */ public String getOnmouseup() { return onmouseup; } /** Sets the onMouseMove event handler. */ public void setOnmousemove(String onMouseMove) { this.onmousemove = onMouseMove; } /** Returns the onMouseMove event handler. */ public String getOnmousemove() { return onmousemove; } /** Sets the onMouseOver event handler. */ public void setOnmouseover(String onMouseOver) { this.onmouseover = onMouseOver; } /** Returns the onMouseOver event handler. */ public String getOnmouseover() { return onmouseover; } /** Sets the onMouseOut event handler. */ public void setOnmouseout(String onMouseOut) { this.onmouseout = onMouseOut; } /** Returns the onMouseOut event handler. */ public String getOnmouseout() { return onmouseout; } // Keyboard Events /** Sets the onKeyDown event handler. */ public void setOnkeydown(String onKeyDown) { this.onkeydown = onKeyDown; } /** Returns the onKeyDown event handler. */ public String getOnkeydown() { return onkeydown; } /** Sets the onKeyUp event handler. */ public void setOnkeyup(String onKeyUp) { this.onkeyup = onKeyUp; } /** Returns the onKeyUp event handler. */ public String getOnkeyup() { return onkeyup; } /** Sets the onKeyPress event handler. */ public void setOnkeypress(String onKeyPress) { this.onkeypress = onKeyPress; } /** Returns the onKeyPress event handler. */ public String getOnkeypress() { return onkeypress; } // Text Events /** Sets the onChange event handler. */ public void setOnchange(String onChange) { this.onchange = onChange; } /** Returns the onChange event handler. */ public String getOnchange() { return onchange; } /** Sets the onSelect event handler. */ public void setOnselect(String onSelect) { this.onselect = onSelect; } /** Returns the onSelect event handler. */ public String getOnselect() { return onselect; } // Focus Events and States /** Sets the onBlur event handler. */ public void setOnblur(String onBlur) { this.onblur = onBlur; } /** Returns the onBlur event handler. */ public String getOnblur() { return onblur; } /** Sets the onFocus event handler. */ public void setOnfocus(String onFocus) { this.onfocus = onFocus; } /** Returns the onFocus event handler. */ public String getOnfocus() { return onfocus; } /** Sets the disabled event handler. */ public void setDisabled(boolean disabled) { this.disabled = disabled; } /** Returns the disabled event handler. */ public boolean getDisabled() { return disabled; } /** Sets the readonly event handler. */ public void setReadonly(boolean readonly) { this.readonly = readonly; } /** Returns the readonly event handler. */ public boolean getReadonly() { return readonly; } // CSS Style Support /** Sets the style attribute. */ public void setStyle(String style) { this.style = style; } /** Returns the style attribute. */ public String getStyle() { return style; } /** Sets the style class attribute. */ public void setStyleClass(String styleClass) { this.styleClass = styleClass; } /** Returns the style class attribute. */ public String getStyleClass() { return renderStyleClass(); } /** Sets the style id attribute. */ public void setStyleId(String styleId) { this.styleId = styleId; } /** Returns the style id attribute. */ public String getStyleId() { return styleId; } // Other Common Elements /** Returns the alternate text attribute. */ public String getAlt() { return alt; } /** Sets the alternate text attribute. */ public void setAlt(String alt) { this.alt = alt; } /** Returns the name of the message resources bundle to use. */ public String getBundle() { return bundle; } /** Sets the name of the message resources bundle to use. */ public void setBundle(String bundle) { this.bundle = bundle; } /** Returns the name of the session attribute for our locale. */ public String getLocale() { return locale; } /** Sets the name of the session attribute for our locale. */ public void setLocale(String locale) { this.locale = locale; } /** Returns the advisory title attribute. */ public String getTitle() { return title; } /** Sets the advisory title attribute. */ public void setTitle(String title) { this.title = title; } /** * Property accessor of chkObject * @return the chkObject */ public Object getChkObject() { return chkObject; } /** * @param chkObject the chkObject to set */ public void setChkObject(Object chkObject) { this.chkObject = chkObject; } /** * Property accessor of chkClazz * @return the chkClazz */ public String getChkClazz() { return chkClazz; } /** * @param chkClazz the chkClazz to set */ public void setChkClazz(String chkClazz) { this.chkClazz = chkClazz; } /** * Property accessor of chkField * @return the chkField */ public String getChkField() { return chkField; } /** * @param chkField the chkField to set */ public void setChkField(String chkField) { this.chkField = chkField; } /** * Release any acquired resources. */ public void release() { super.release(); accesskey = null; alt = null; bundle = null; indexed = false; locale = null; onclick = null; ondblclick = null; onmouseover = null; onmouseout = null; onmousemove = null; onmousedown = null; onmouseup = null; onkeydown = null; onkeyup = null; onkeypress = null; onselect = null; onchange = null; onblur = null; onfocus = null; disabled = false; readonly = false; style = null; styleClass = null; styleId = null; tabindex = null; title = null; chkObject = null; chkClazz = null; chkField = null; } // --------------------------------------------------------- Public Methods /** * Prepares the style attributes for inclusion in the component's HTML tag. * * @return The prepared String for inclusion in the HTML tag. * @exception JspException * if invalid attributes are specified */ protected String prepareStyles(){ String value = null; StringBuffer styles = new StringBuffer(); if (style != null) { styles.append(" style=\""); styles.append(getStyle()); styles.append("\""); } if (getStyleClass() != null) { styles.append(" class=\""); styles.append(getStyleClass()); styles.append("\""); } if (styleId != null) { styles.append(" id=\""); styles.append(getStyleId()); styles.append("\""); } value = title; if (value != null) { styles.append(" title=\""); styles.append(value); styles.append("\""); } value = alt; if (value != null) { styles.append(" alt=\""); styles.append(value); styles.append("\""); } return styles.toString(); } /** * Prepares the event handlers for inclusion in the component's HTML tag. * * @return The prepared String for inclusion in the HTML tag. */ protected String prepareEventHandlers() { StringBuffer handlers = new StringBuffer(); prepareMouseEvents(handlers); prepareKeyEvents(handlers); prepareTextEvents(handlers); prepareFocusEvents(handlers); return handlers.toString(); } /** * Prepares the mouse event handlers, appending them to the the given * StringBuffer. * * @param handlers * The StringBuffer that output will be appended to. */ protected void prepareMouseEvents(StringBuffer handlers) { if (onclick != null) { handlers.append(" onclick=\""); handlers.append(getOnclick()); handlers.append("\""); } if (ondblclick != null) { handlers.append(" ondblclick=\""); handlers.append(getOndblclick()); handlers.append("\""); } if (onmouseover != null) { handlers.append(" onmouseover=\""); handlers.append(getOnmouseover()); handlers.append("\""); } if (onmouseout != null) { handlers.append(" onmouseout=\""); handlers.append(getOnmouseout()); handlers.append("\""); } if (onmousemove != null) { handlers.append(" onmousemove=\""); handlers.append(getOnmousemove()); handlers.append("\""); } if (onmousedown != null) { handlers.append(" onmousedown=\""); handlers.append(getOnmousedown()); handlers.append("\""); } if (onmouseup != null) { handlers.append(" onmouseup=\""); handlers.append(getOnmouseup()); handlers.append("\""); } } /** * Prepares the keyboard event handlers, appending them to the the given * StringBuffer. * * @param handlers * The StringBuffer that output will be appended to. */ protected void prepareKeyEvents(StringBuffer handlers) { if (onkeydown != null) { handlers.append(" onkeydown=\""); handlers.append(getOnkeydown()); handlers.append("\""); } if (onkeyup != null) { handlers.append(" onkeyup=\""); handlers.append(getOnkeyup()); handlers.append("\""); } if (onkeypress != null) { handlers.append(" onkeypress=\""); handlers.append(getOnkeypress()); handlers.append("\""); } } /** * Prepares the text event handlers, appending them to the the given * StringBuffer. * * @param handlers * The StringBuffer that output will be appended to. */ protected void prepareTextEvents(StringBuffer handlers) { if (onselect != null) { handlers.append(" onselect=\""); handlers.append(getOnselect()); handlers.append("\""); } if (onchange != null) { handlers.append(" onchange=\""); handlers.append(getOnchange()); handlers.append("\""); } } /** * Prepares the focus event handlers, appending them to the the given * StringBuffer. * * @param handlers * The StringBuffer that output will be appended to. */ protected void prepareFocusEvents(StringBuffer handlers) { if (onblur != null) { handlers.append(" onblur=\""); handlers.append(getOnblur()); handlers.append("\""); } if (onfocus != null) { handlers.append(" onfocus=\""); handlers.append(getOnfocus()); handlers.append("\""); } if (disabled) { handlers.append(" disabled=\"disabled\""); } if (readonly) { handlers.append(" readonly=\"readonly\""); } } protected String renderStyleClass(){ //如果需要验证 if(StringUtils.isNotBlank(getChkField()) && (getChkObject() != null || StringUtils.isNotBlank(getChkClazz()))){ StringBuilder styleSb = new StringBuilder(); if(StringUtils.isNotBlank(styleClass)){ styleSb.append(styleClass); } //输出class return styleSb.toString(); } else{ return styleClass; } } //遍历所有的validate annotation protected boolean renderStyle(Annotation annotation){ return false; } protected void write(String text) { JspWriter writer = pageContext.getOut(); try { if (text!=null) writer.print(text); } catch (Exception e) { log.error("ERROR",e); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/web/tag/BaseHandlerTag.java
Java
asf20
19,302
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-11-24 下午1:58:16 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-11-24 Initailized */ package com.zz.bsp.web.filter; import java.io.IOException; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.zz.bsp.constants.Constants; /** * 重复提交过滤器 * */ public class TokenCheckFilter implements Filter { protected final Log log = LogFactory.getLog(getClass()); public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; String formToken = request.getParameter(Constants.OECS_TOKEN_CHECK_NAME); if (StringUtils.isBlank(formToken)) { chain.doFilter(request, response); return; } Object tokenObj = request.getSession().getAttribute(Constants.OECS_TOKEN_CHECK_NAME_IN_SESSION); if (tokenObj != null && StringUtils.isNotEmpty(formToken) && tokenObj.equals(formToken)) { log.debug("check token ok !!!"); request.getSession().removeAttribute(Constants.OECS_TOKEN_CHECK_NAME_IN_SESSION); chain.doFilter(request, response); return; } else { log.debug("check token fail !!!"); String errBackUrl = request.getParameter(Constants.OECS_TOKEN_ERR_BACK_URL_NAME); response.sendRedirect(StringUtils.isBlank(errBackUrl) ? request.getHeader("Referer") : errBackUrl); return; } } public void init(FilterConfig arg0) throws ServletException { log.debug("init ...."); } public void destroy() { log.debug("destory !!!"); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/web/filter/TokenCheckFilter.java
Java
asf20
2,480
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午02:22:03 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.web.action; import java.beans.PropertyEditorSupport; import java.math.BigDecimal; import java.math.BigInteger; import java.util.Date; import java.util.Locale; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.propertyeditors.CustomNumberEditor; import org.springframework.validation.BindException; import org.springframework.web.bind.WebDataBinder; import org.springframework.web.bind.annotation.InitBinder; import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.mvc.multiaction.MultiActionController; import com.zz.bsp.constants.Constants; import com.zz.bsp.util.DateTimeUtils; /** * * Action的基类 * * 在spring mvc的框架里,最终负责处理请求的是MultiActionController中的invokeNamedMethod,它负责 * 封装参数转换成对象以及调用Action的具体方法 * */ public class BaseMultiActionController extends MultiActionController { protected final Log log = LogFactory.getLog(getClass()); protected static final String MODEL_ID = "id"; protected static final String MODEL_IDS = "ids"; protected static final String ERRORS_NAME = "errors"; protected static final String APP_ID = "appId"; protected static final String RESPONSE_STATUS_CODE = "statusCode"; protected static final String RESPONSE_MESSAGE = "message"; protected static final String STATUS_CODE_OK = "200"; protected static final String STATUS_CODE_ERR = "300"; protected String getModelId(HttpServletRequest request) { return request.getParameter(MODEL_ID); } protected String getMutilModelId(HttpServletRequest request) { return request.getParameter(MODEL_IDS); } protected String getAppId(HttpServletRequest request) { return request.getParameter(APP_ID); } protected String getText(String msgKey) { Object[] args = null; return getText(msgKey, args); } protected String getText(String msgKey, String arg) { return getText(msgKey, new Object[] { arg }); } protected String getText(String msgKey, Object[] args) { Locale locale = null; return getMessageSourceAccessor().getMessage(msgKey, args, locale); } /* @Override protected void bind(HttpServletRequest request, Object command) throws Exception { logger.debug("Binding request parameters onto MultiActionController command"); setValidator(); ServletRequestDataBinder binder = createBinder(request, command); BindException errors = new BindException(binder.getBindingResult()); binder.bind(request); if (this.getValidators() != null) { for (int i = 0; i < this.getValidators().length; i++) { if (this.getValidators()[i].supports(command.getClass())) { ValidationUtils.invokeValidator(this.getValidators()[i],command, errors); } } } request.setAttribute(ERRORS_NAME, errors); } @Override protected ServletRequestDataBinder createBinder(HttpServletRequest request,Object command) throws Exception { String commandName = command.getClass().getSimpleName(); commandName = commandName.substring(0,1).toLowerCase()+commandName.substring(1); ServletRequestDataBinder binder = new ServletRequestDataBinder(command,commandName); initBinder(request, binder); return binder; }*/ /*@Override @InitBinder protected void initBinder(HttpServletRequest request, ServletRequestDataBinder binder) throws Exception { log.debug("initBinder(HttpServletRequest request, ServletRequestDataBinder binder) begin ..."); binder.registerCustomEditor(Integer.class, null, new CustomNumberEditor(Integer.class, null, true)); binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(byte[].class, new ByteArrayMultipartFileEditor()); SimpleDateFormat dateShortFormat = new SimpleDateFormat(AbdfConstants.DEFUALT_SHOT_TIME_FORMAT); dateShortFormat.setLenient(false); binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateShortFormat, true)); SimpleDateFormat dateLongFormat = new SimpleDateFormat(AbdfConstants.DEFUALT_LONG_TIME_FORMAT); dateLongFormat.setLenient(false); binder.registerCustomEditor(Date.class, null, new CustomDateEditor(dateLongFormat, true)); }*/ @InitBinder //http://sillycat.javaeye.com/blog/563979 public void initBinder(WebDataBinder binder) { //日期转化的,包括长时间和短时间格式的 binder.registerCustomEditor(Date.class, new PropertyEditorSupport(true){ private final boolean allowEmpty = true; @Override public void setAsText(String text) throws IllegalArgumentException { if (this.allowEmpty && StringUtils.isBlank(text)) { setValue(null); return; } else if (StringUtils.isBlank(text)) { throw new IllegalArgumentException("Could not parse date: it is null"); } //不带横线的日期 if(text.indexOf(Constants.LINE_SIGN_SPLIT_NAME) == -1 && text.length() == 8){ setValue(DateTimeUtils.stringFormatToDate(text, Constants.NO_SPLIT_SHOT_TIME_FORMAT)); return; } //常日期 if(text.length() > 10){ setValue(DateTimeUtils.stringFormatToDate(text, Constants.DEFUALT_LONG_TIME_FORMAT)); return; } //正常日期 else{ setValue(DateTimeUtils.stringFormatToDate(text, Constants.DEFUALT_SHOT_TIME_FORMAT)); } } /** * Format the Date as String, using the specified DateFormat. */ @Override public String getAsText() { Date value = (Date) getValue(); String ret =DateTimeUtils.dateToStringFormat(value, Constants.DEFUALT_LONG_TIME_FORMAT); if(ret != null && ret.endsWith("00:00:00")){ ret =DateTimeUtils.dateToStringFormat(value, Constants.DEFUALT_SHOT_TIME_FORMAT); } return ret; } }); binder.registerCustomEditor(BigDecimal.class, new CustomNumberEditor(BigDecimal.class, true)); binder.registerCustomEditor(Integer.class, null,new CustomNumberEditor(Integer.class, null, true)); binder.registerCustomEditor(int.class, null, new CustomNumberEditor(Integer.class, null , true)); binder.registerCustomEditor(Long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(long.class, null, new CustomNumberEditor(Long.class, null, true)); binder.registerCustomEditor(Float.class, new CustomNumberEditor(Float.class, true)); binder.registerCustomEditor(Double.class, new CustomNumberEditor(Double.class, true)); binder.registerCustomEditor(BigInteger.class, new CustomNumberEditor(BigInteger.class, true)); } public BindException handleErrors(HttpServletRequest request,HttpServletResponse response) throws Exception { BindException errors = (BindException) request.getAttribute(ERRORS_NAME); if (errors.hasErrors()) { log.debug("handleErrors hasErrors!!!"); return errors; } else { return null; } } //包装异常信息 protected void wrapModelAndView(ModelAndView view,Exception e){ if(e != null){ log.warn("WARN", e); view.addObject(RESPONSE_STATUS_CODE, STATUS_CODE_ERR); view.addObject(RESPONSE_MESSAGE, e.getMessage()); } } //得到术语的转义输出 public String getTermValue(String code, String defaultValue, String param, String split){ log.debug("begin get term value..."); if(StringUtils.isBlank(defaultValue)){ defaultValue = code; } log.debug("code :" + code + ", value : " + defaultValue); return defaultValue; } public String getTermValue(String code, String defaultValue, String param){ return getTermValue(code, defaultValue, param, null); } public String getTermValue(String code, String defaultValue){ return getTermValue(code, defaultValue, null, null); } public String getTermValue(String code){ return getTermValue(code, code, null, null); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/web/action/BaseMultiActionController.java
Java
asf20
9,625
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午03:52:49 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.constants; /** * 常量定义 * */ public interface Constants { /** * ? 符号 */ public static final String QUESTION_SIGN_SPLIT_NAME = "?"; /** * @ 符号 */ public static final String AT_SIGN_SPLIT_NAME = "@"; /** * , 符号 */ public static final String COMMA_SIGN_SPLIT_NAME = ","; /** * - 符号 */ public static final String LINE_SIGN_SPLIT_NAME = "-"; /** * 下划线 */ public static final String UNDERLINE_SIGN_SPLIT_NAME = "_"; /** * DOT */ public static final String DOT_SIGN_SPLIT_NAME = "."; /** * semicolon */ public static final String SEMICOLON_SIGN_SPLIT_NAME = ";"; /** * COLON */ public static final String COLON_SIGN_SPLIT_NAME = ":"; /** * Long -1 */ public static final long GLOBAL_SYSTEM_OPER_ID = -1; /** * 全局数据最长长度:int 1000 */ public static final int GLOBAL_DATA_MAX_LENGTH = 1000; /** * 默认编码 */ public static final String DEFAULT_CHARSET_NAME = "UTF-8"; /** * 默认报文接口编码 */ public static final String DEFAULT_PROTOCOL_CHARSET_NAME = "GBK"; /** * 报文接口类型--WEBSERVICE */ public static final String MSG_INTERFACE_TYPE_WEBSERVICE = "WEBSERVICE"; /** * 报文接口类型--socket */ public static final String MSG_INTERFACE_TYPE_SOCKET = "SOCKET"; /** * 报文接口类型--hessian */ public static final String MSG_INTERFACE_TYPE_HESSIAN = "HESSIAN"; /** * 默认的时间格式 */ public static final String DEFUALT_SHOT_TIME_FORMAT = "yyyy-MM-dd"; public static final String DEFUALT_LONG_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String ORACLE_LONG_TIME_FORMAT = "yyyy-MM-dd hh24:mi:ss"; public static final String NO_SPLIT_SHOT_TIME_FORMAT = "yyyyMMdd"; public static final String STAMP_TIME_FORMAT = "yyyyMMddHHmmss"; public static final String MONTH_TIME_FORMAT = "yyyyMM"; /** * xml文件结尾 */ public static final String XML_CONF_NAME_EXT = ".xml"; /** * 配置名称 */ public static final String EXCLUDE_CONFIG_NAME = "exclude"; /** * 系统属性文件名 */ public static final String SYSTEM_PROPERTY_FILENAME = "system.properties"; /** * 系统代号属性KEY */ public static final String SYSTEM_PROPERTY_APPCODE_KEY = "sys.app.code"; /** * cache管理器bean名称 */ public static final String CACHE_MANAGER_BEAN_NAME = "oecsCacheManageService"; /** * AccessDecisionManager */ public static final String ACCESS_DECISION_BEAN_NAME = "accessDecisionService"; /** * AccessDecisionManager */ public static final String AUDIT_LOG_BEAN_NAME = "auditLogService"; /** * AccessDecisionManager */ public static final String DICT_CACHE_SERVICE_BEAN_NAME = "oecsDictCacheService"; /** * TerminologyCacheService */ public static final String TERM_CACHE_SERVICE_BEAN_NAME = "terminologyCacheService"; /** * DictConvertCacheService */ public static final String DICT_CONVERT_CACHE_SERVICE_BEAN_NAME ="dictConvertCacheService"; /** * PAGEINFO_IN_REQUEST */ public static final String PAGEINFO_IN_REQUEST = "pageinfo_in_request"; /** * 默认页数 20 */ public static final int DEFAULT_PAGE_SIZE = 20; /** * 全局数据字典 :有效 */ public final String DICT_GLOBAL_STATUS_VALIDATE = "V"; /** * 全局数据字典 :无效 */ public final String DICT_GLOBAL_STATUS_INVALIDATE = "I"; /** * 全局数据字典:是 */ public final String DICT_GLOBAL_YESNO_YES = "Y"; /** * 全局数据字典:否 */ public final String DICT_GLOBAL_YESNO_NO = "N"; /** * 全局处理状态P 处理中 */ public final String DICT_GLOBAL_RESULT_PROCESSING = "P"; /** * 全局处理状态F 失败 */ public final String DICT_GLOBAL_RESULT_FAIL = "F"; /** * 全局处理状态S 成功 */ public final String DICT_GLOBAL_RESULT_SUCCESS = "S"; /** * 全局处理状态U 不能处理 */ public final String DICT_GLOBAL_RESULT_UNPROCESS = "U"; /** * 随机数 */ public static final String SPRING_SECURITY_RANDS_IN_SESSION = "KAPTCHA_SESSION_KEY"; //"j_spring_rands_in_session"; public static final String SPRING_SECURITY_FORM_VCODE_KEY = "j_validatecode"; public static final String SPRING_SECURITY_CHECK_NAME = "j_spring_security_check"; /** * token */ public static final String OECS_TOKEN_CHECK_NAME_IN_SESSION = "oecs_token_check_in_session"; public static final String OECS_TOKEN_CHECK_NAME = "o_token_check"; public static final String OECS_TOKEN_ERR_BACK_URL_NAME = "o_token_err_url"; /** * 首页是否已经做过初始化 */ public static final String ACTION_INDEX_INIT_IN_SESSION = "index_init_in_session"; /** * 当前登录用户 */ public static final String CUR_USER_DETAIL_IN_SESSION = "cur_user_detail_in_session"; /** * 当前登录用户该系统下的菜单树信息 */ public static final String CUR_USER_ALL_MENU_IN_SESSION = "cur_user_all_menu_in_session"; /** * 用户快捷菜单 */ public static final String CUR_USER_SHORTCUT_IN_SESSION = "cur_user_shortcut_in_session"; /** * 当前应用信息信息 */ public static final String CUR_APP_INFO_IN_REQUEST = "cur_app_info_in_request"; /** * 当前用户应用信息 */ public static final String CUR_USER_APPS_IN_REQUEST = "cur_user_apps_in_request"; /** * 当前系统菜单信息 */ public static final String CUR_APP_MENUS_IN_REQUEST = "cur_app_menus_in_request"; /** * 当前菜单树 */ public static final String CUR_MENU_TREE_IN_REQUEST = "cur_menu_tree_in_request"; /** * 用户菜单树FOR RENDER */ public static final String MENU_TREE_FOR_RENDER_IN_REQUEST = "menu_tree_for_render_in_request"; /** * 是否重新初始化首页参数 */ public static final String REINIT_INDEX_PARAMETER_NAME = "reInit"; /** * 是否重新初始化首页参数 */ public static final String FAVORITE_PARAMETER_NAME = "favorite"; /** * hessian客户端调用者信息in hessian context */ public static final String HESSIAN_CLIENT_INFO_IN_HESSIAN = "hessian_client_info_in_hessian"; /** * 资源类型 SET_AP_RESOURCE_TYPE 应用 */ public static final String SET_AP_RESOURCE_TYPE_APP = "APP"; /** * 资源类型 菜单 */ public static final String SET_AP_RESOURCE_TYPE_MEU = "MEU"; /** * 资源类型 菜单树 */ public static final String SET_AP_RESOURCE_TYPE_MET = "MET"; /** * 资源类型 按钮 */ public static final String SET_AP_RESOURCE_TYPE_BTN = "BTN"; /** * 资源类型 URL */ public static final String SET_AP_RESOURCE_TYPE_URL = "URL"; /** * 资源类型 片段 */ public static final String SET_AP_RESOURCE_TYPE_FRG = "FRG"; /** * 授权目标类型 操作员 */ public static final String SET_AP_PERMISSION_TARGET_TYPE_OPER = "OPER"; /** * 授权目标类型 角色 */ public static final String SET_AP_PERMISSION_TARGET_TYPE_ROLE = "ROLE"; /** * 授权资源类型 资源 */ public static final String SET_AP_PERMISSION_RES_TYPE_RES = "RES"; /** * 授权资源类型 资源组 */ public static final String SET_AP_PERMISSION_RES_TYPE_REG = "REG"; /** * 服务器状态 正常 */ public static final String SVR_STATE_NORMAL = "NORM"; /** * 服务器状态 停止 */ public static final String SVR_STATE_STOP = "STOP"; /** * 服务器状态 准备停止 */ public static final String SVR_STATE_PRE_STOO = "PSTP"; /** * 服务器状态 日切中 */ public static final String SVR_STATE_DAUT = "DAUT"; /** * 没有可用的接口池 */ public static final String SWITCH_NO_ACTIVE_POOL = "switch.no.active.pool"; /** * 默认异常代号信息 */ public static final String DEFAULT_ERR_MSG = "sys.unkown.err.msg"; /** * 默认四位的异常代码 */ public static final String DEFAULT_ERR_CODE = "9999"; /** * 超时异常代码 */ public static final String TIMOUT_ERR_CODE = "9998"; /** * 默认2位的异常代号 */ public static final String DEFAULT_THIRD_PART_ERR_CODE = "99"; /** * 默认2位的返回代号 */ public static final String DEFAULT_RESPONSE_CODE = "00"; /** * 默认的字段描述 */ public static final String DEFAULT_DB_COLUMN_VALUE = "N/A"; /** * 刷新cache和数据库配置的key参数 */ public static final String SYSTEM_REFRESH_PARAM_KEY = "sys.refresh.param.key"; /** * 后台管理系统缓存刷新列表代号 */ public static final String SERVERS_CACHE_LIST_CODE = "servers.cache.list"; /** * 全局执行状态 发布 */ public final String SET_GC_EXECUTE_STATUS_PUB = "PUB"; /** * 全局执行状态 草稿 */ public final String SET_GC_EXECUTE_STATUS_DRA = "DRA"; /** * 全局执行状态 作废 */ public final String SET_GC_EXECUTE_STATUS_DIS = "DIS"; /** * 帐单应答错误 */ public static final String BILLING_RESPONSE_ERROR = "billing.ocn.response.msg.err"; /** * 第三方超时异常码 */ public static final String TIMEOUT_EXCEPTION_CODE = "0010"; /** * 单点登录,判断重复登录缓存KEY */ public static final String SSO_CA_USER_LOGINED_CACHE = "sso_ca_user_logined_"; /** * 单点登录,缓存服务器地址 */ public static final String SSO_CA_MEMCACHE_SERVERS_ADDRESS = "sso.memcache.servers"; }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/constants/Constants.java
Java
asf20
11,902
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-17 下午4:03:53 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-17 Initailized */ package com.zz.bsp.service; import java.io.Serializable; import java.util.Date; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ibatis.session.RowBounds; import org.springframework.transaction.annotation.Transactional; import com.zz.bsp.constants.Constants; import com.zz.bsp.core.Model; import com.zz.bsp.dao.Dao; import com.zz.bsp.orm.query.OecsCriterion; import com.zz.bsp.orm.query.Order; import com.zz.bsp.orm.query.Page; import com.zz.bsp.orm.query.PropertyFilter; import com.zz.bsp.util.DateTimeUtils; import com.zz.bsp.util.ModelUpdInfoUtils; import com.zz.bsp.util.OecsCriterionUtils; /** * 领域对象的业务管理类基类. * * 提供了领域对象的简单CRUD方法. * * @param <T> 领域对象类型 * @param <PK> 领域对象的主键类型 * */ @Transactional public abstract class DefaultEntityService <T extends Model, PK extends Serializable>{ protected Log log = LogFactory.getLog(getClass()); /** * 在子类实现的回调函数,为EntityManager提供默认CRUD操作所需的DAO. */ protected abstract Dao<T, PK> getDao(); // CRUD函数 // @Transactional(readOnly = true,timeout=30) public T get(PK id) { return getDao().get(id); } @Transactional(timeout=30) public void save(T entity) { getDao().save(entity); } @Transactional(timeout=30) public void update(T entity) { update(entity, false); } @Transactional(timeout=30) @SuppressWarnings("unchecked") //是否以秒为精度,否则以毫秒为精度,默认以毫秒为精度 public void update(T entity, boolean secondPrecision) { Serializable pks = entity.getPK(); if(pks != null){ try{ T dbEntity = getDao().get((PK)pks); if(dbEntity != null){ Date dbDate = ModelUpdInfoUtils.getModelUpdateTime(dbEntity); log.debug("dbDate :" + dbDate.getTime()); Date date = ModelUpdInfoUtils.getModelUpdateTime(entity); log.debug("modelDate :" + date.getTime()); if(dbDate != null){ //如果不相符,则为脏数据 if(!dbDate.equals(date)){ if(!secondPrecision){ log.warn("the date (not secondPrecision) is dirty :" + entity); throw new IllegalStateException("the date is dirty"); } else{ //以秒为精度 long diff = DateTimeUtils.diffTwoDateWithTime(date, dbDate); if(diff/1000 != 0){ log.warn("the date (secondPrecision) is dirty :" + entity); throw new IllegalStateException("the date is dirty"); } } } } } } catch(Exception e){ log.info(e.getMessage(), e); if(e instanceof IllegalStateException){ throw ((IllegalStateException)e); } } } //设置更新时间 ModelUpdInfoUtils.updateModelUpdateTime(entity); getDao().update(entity); } @Transactional(timeout=30) public void delete(PK id) { getDao().delete(id); } /** * 按id逻辑删除对象. */ @Transactional(timeout=30) public void logicDel(final PK id){ T t =get(id); ModelUpdInfoUtils.setModelInvalidStatus(t); getDao().update(t); } @Transactional(timeout=30) public void delete(List<PK> ids) { if(ids != null && ids.size() > 0){ Dao<T, PK> dao = getDao(); for(PK id : ids){ dao.delete(id); } } } @Transactional(readOnly = true,timeout=30) public List<T> getAll() { OecsCriterion criterion = new OecsCriterion(); return getDao().find(criterion, null); } @Transactional(readOnly = true,timeout=30) public Page<T> getAll(Page<T> page) { return search(page, null); } @Transactional(readOnly = true) public Page<T> search(Page<T> page, List<PropertyFilter> filters) { OecsCriterion criterion = OecsCriterionUtils.createOecsCriterion(page, filters); RowBounds rowBounds = OecsCriterionUtils.createRowBounds(page); //开始查询 List<T> result = getDao().find(criterion, rowBounds); page.setResult(result); //处理是否需要统计记录数 if(page.isAutoCount()){ page.setTotalCount(getDao().count(criterion)); } return page; } @Transactional(readOnly = true) public List<T> search(List<PropertyFilter> filters) { return search(filters, null); } @Transactional(readOnly = true) public List<T> search(List<PropertyFilter> filters ,List<Order> orders) { OecsCriterion criterion = new OecsCriterion(filters); if(orders != null){ StringBuilder orderBySb = new StringBuilder(); StringBuilder orderSb = new StringBuilder(); int i = 0; for(Order order : orders){ if(i != 0){ orderBySb.append(Constants.COMMA_SIGN_SPLIT_NAME); orderSb.append(Constants.COMMA_SIGN_SPLIT_NAME); } i++; orderBySb.append(order.getOrderBy()); orderSb.append(order.getOrder()); } criterion.setOrderBy(orderBySb.toString()); criterion.setOrder(orderSb.toString()); } return getDao().find(criterion, null); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/service/DefaultEntityService.java
Java
asf20
6,513
package com.zz.bsp.service; import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.shiro.authc.AuthenticationException; import org.apache.shiro.authc.AuthenticationInfo; import org.apache.shiro.authc.AuthenticationToken; import org.apache.shiro.authc.SimpleAuthenticationInfo; import org.apache.shiro.authc.UsernamePasswordToken; import org.apache.shiro.authz.AuthorizationInfo; import org.apache.shiro.realm.AuthorizingRealm; import org.apache.shiro.subject.PrincipalCollection; import org.springframework.beans.factory.annotation.Autowired; import com.zz.bsp.orm.query.PropertyFilter; import com.zz.test.model.user.UserModel; import com.zz.test.service.user.UserService; public class ZzMsShiroRealm extends AuthorizingRealm { protected Log log = LogFactory.getLog(getClass()); @Autowired UserService userService; /** * 授权 */ protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection arg0) { log.debug("get auth info --》" + arg0); return null; } /** * 认证 */ protected AuthenticationInfo doGetAuthenticationInfo(AuthenticationToken authcToken) throws AuthenticationException { log.debug("begin to auth -->" + authcToken); UsernamePasswordToken token = (UsernamePasswordToken)authcToken; String userName = token.getUsername(); String password = String.valueOf(token.getPassword()); PropertyFilter filter = new PropertyFilter("EQS_USER_NAME", userName); List<PropertyFilter> filterList = new ArrayList<PropertyFilter>(1); filterList.add(filter); List<UserModel> userList = userService.search(filterList); if(userList != null && userList.size() > 0) { log.info("find user :" + userName); UserModel dbUser = userList.get(0); if(password.equalsIgnoreCase(dbUser.getUserPwd())) { log.debug("login ok ~~~~"); return new SimpleAuthenticationInfo(userName,password, getName()); } else { log.debug("login fail req pwd ->" + password); return null; } } return null; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/service/ZzMsShiroRealm.java
Java
asf20
2,252
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-framework * $Id$ * $Revision$ * Last Changed by gaowm at 2012-4-6 下午7:46:16 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * gaowm 2012-4-6 Initailized */ package com.zz.bsp.dao; /** * dao扫描接口 * */ public @interface OecsMapper { }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/dao/OecsMapper.java
Java
asf20
451
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-9-6 下午04:26:39 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-9-6 Initailized */ package com.zz.bsp.dao; import java.io.Serializable; import java.util.List; import org.apache.ibatis.session.RowBounds; import com.zz.bsp.orm.query.OecsCriterion; /** * DAO的基接口 * 其他基类都可以实现该或者基础该接口 */ public interface Dao<T, PK extends Serializable>{ /** * 保存新增的对象. */ public void save(final T entity); /** * 保存修改的对象. */ public void update(final T entity); /** * 按id删除对象. */ public void delete(final PK id); /** * 按id获取对象. */ public T get(final PK id); /** * 根据分页获取数据, rowBounds如果为空,则没有分页 */ List<T> find(OecsCriterion criterion, RowBounds rowBounds); /** * 计算总记录数 * @param criterion * @return */ public long count(OecsCriterion criterion); }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/dao/Dao.java
Java
asf20
1,356
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午02:40:45 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.dialect; /** * MYSQL本地语言 * */ public class MySQLDialect extends Dialect { public boolean supportsLimitOffset() { return true; } public boolean supportsLimit() { return true; } public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { if (offset > 0) { return sql + " limit " + offsetPlaceholder + "," + limitPlaceholder; } return sql + " limit " + limitPlaceholder; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/dialect/MySQLDialect.java
Java
asf20
1,091
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午02:40:04 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.dialect; /** * oracle本地语言 * */ public class OracleDialect extends Dialect { public boolean supportsLimit() { return true; } public boolean supportsLimitOffset() { return true; } public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { sql = sql.trim(); boolean isForUpdate = false; if (sql.toLowerCase().endsWith(" for update")) { sql = sql.substring(0, sql.length() - 11); isForUpdate = true; } StringBuffer pagingSelect = new StringBuffer(sql.length() + 100); if (offset > 0) pagingSelect.append("select * from ( select row_.*, rownum rownum_ from ( "); else { pagingSelect.append("select * from ( "); } pagingSelect.append(sql); if (offset > 0) { String endString = offsetPlaceholder + "+" + limitPlaceholder; pagingSelect.append(" ) row_ ) where rownum_ <= " + endString + " and rownum_ > " + offsetPlaceholder); } else { pagingSelect.append(" ) where rownum <= " + limitPlaceholder); } if (isForUpdate) { pagingSelect.append(" for update"); } return pagingSelect.toString(); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/dialect/OracleDialect.java
Java
asf20
1,968
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午02:34:31 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.dialect; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * 本地数据库语言 * */ public class Dialect { public boolean supportsLimit() { return false; } public boolean supportsLimitOffset() { return supportsLimit(); } public String getLimitString(String sql, int offset, int limit) { return getLimitString(sql, offset, Integer.toString(offset), limit, Integer.toString(limit)); } public String getLimitString(String sql, int offset, String offsetPlaceholder, int limit, String limitPlaceholder) { throw new UnsupportedOperationException("paged queries not supported"); } public String getCountSQL(String sql) { String countQueryString = null; if (isWarp(sql)) countQueryString = "select count(*) from (" + removeOrders(sql) + ") _COUNT_FOR_SQL_"; else { countQueryString = " select count(*) " + removeSelect(removeOrders(sql)); } return countQueryString; } private static String removeOrders(String hql) { Pattern p = Pattern.compile("order\\s*by[\\w|\\W|\\s|\\S]*", 2); Matcher m = p.matcher(hql); StringBuffer sb = new StringBuffer(); while (m.find()) { m.appendReplacement(sb, ""); } m.appendTail(sb); return sb.toString(); } private static boolean isWarp(String hql) { Pattern p = Pattern.compile("(group\\s*by[\\w|\\W|\\s|\\S]*|union)+", 2); Matcher m = p.matcher(hql); return m.find(); } private static String removeSelect(String hql) { int beginPos = hql.toLowerCase().indexOf("from"); return hql.substring(beginPos); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/dialect/Dialect.java
Java
asf20
2,549
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-9-16 下午04:31:57 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-9-16 Initailized */ package com.zz.bsp.orm.query; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.zz.bsp.constants.Constants; /** * 东方亿付查询查询共用类 * */ public class OecsCriterion implements Serializable { private static final long serialVersionUID = -7164611833406678484L; protected Log log = LogFactory.getLog(getClass()); public static final String ACS = "ACS"; public static final String DESC = "DESC"; private String order = DESC; private String orderBy; @SuppressWarnings("unchecked") private List<PropertyFilter> criteria = Collections.EMPTY_LIST; private String customSql; //嵌套的扩展查询条件 @SuppressWarnings("unchecked") private List<PropertyFilter> extraCriteria = Collections.EMPTY_LIST; public OecsCriterion(){ } public OecsCriterion(List<PropertyFilter> criteria){ this.criteria = criteria; } public OecsCriterion(List<PropertyFilter> criteria, String orderBy){ this.criteria = criteria; this.orderBy = orderBy; } public OecsCriterion(List<PropertyFilter> criteria, String orderBy, String order){ this.criteria = criteria; this.orderBy = orderBy; this.order = order; } /** * Property accessor of order * * @return the order */ public String getOrder() { return order; } /** * @param order * the order to set */ public void setOrder(String order) { this.order = order; } /** * Property accessor of orderBy * * @return the orderBy */ public String getOrderBy() { return orderBy; } /** * @param orderBy * the orderBy to set */ public void setOrderBy(String orderBy) { this.orderBy = orderBy; } /** * Property accessor of criteria * * @return the criteria */ public List<PropertyFilter> getCriteria() { return criteria; } /** * @param criteria * the criteria to set */ public void setCriteria(List<PropertyFilter> criteria) { this.criteria = criteria; } public String getWhereSqlString(){ return constructSqlString(criteria); } public void setCustomCriteria(String sql) { this.customSql = sql; } public String getCustomSqlString(){ return customSql; } public String getExtraWhereSqlString(){ return constructSqlString(extraCriteria); } public String getOrderBySqlString(){ if(StringUtils.isNotBlank(orderBy)){ //拼装order条件 StringBuilder sb = new StringBuilder(" ORDER BY "); String[] orderBys = StringUtils.split(orderBy, ','); if(StringUtils.isBlank(order)){ order = DESC; } String [] orders = StringUtils.split(order, ','); int i = 0; for (String orderBy : orderBys) { if(i != 0){ sb.append(" " + Constants.COMMA_SIGN_SPLIT_NAME + " "); } sb.append(orderBy); String curOrder = DESC; if(orders.length == 1){ curOrder = orders[0]; } else{ if((i + 1) > orders.length){ curOrder = DESC; } else{ curOrder = orders[i]; } } sb.append(" " + curOrder); i++; } log.debug("getOrderBySqlString :" + sb.toString()); return sb.toString(); } return ""; } public List<PropertyFilter> getExtraCriteria() { return extraCriteria; } public void setExtraCriteria(List<PropertyFilter> extraCriteria) { this.extraCriteria = extraCriteria; } protected String constructSqlString(List<PropertyFilter> in){ //查询参数 if(in != null && in.size() > 0){ StringBuilder sb = new StringBuilder(); for(PropertyFilter filter : in){ sb.append("and" + filter.getSqlString()); } log.debug("getWhereSqlString :" + sb.toString()); return sb.toString(); } return ""; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/OecsCriterion.java
Java
asf20
5,140
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午02:33:47 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.query; import java.io.Serializable; /** * 分页行数设定对象 * */ public class RowBounds implements Serializable { private static final long serialVersionUID = 154393093419524432L; // 默认分页长度 public final static int NO_ROW_OFFSET = 0; // 默认最到行数 public final static int NO_ROW_LIMIT = Integer.MAX_VALUE; // 默认对象 public final static RowBounds DEFAULT = new RowBounds(); private int offset; private int limit; private String countSQL; // 是否统计总数 private boolean isCountRowNum = false; public RowBounds() { this.offset = NO_ROW_OFFSET; this.limit = NO_ROW_LIMIT; this.isCountRowNum = false; } public RowBounds(int offset, int limit) { this.offset = offset; this.limit = limit; this.isCountRowNum = true; } public RowBounds(int offset, int limit, boolean isCountRowNum) { this.offset = offset; this.limit = limit; this.isCountRowNum = isCountRowNum; } public int getOffset() { return offset; } public int getLimit() { return limit; } public void setDefault() { this.limit = DEFAULT.limit; this.offset = DEFAULT.offset; } public boolean isCountRowNum() { return isCountRowNum; } public void setCountRowNum(boolean isCountRowNum) { this.isCountRowNum = isCountRowNum; } public String getCountSQL() { return countSQL; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/RowBounds.java
Java
asf20
2,043
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-9-16 下午03:29:53 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-9-16 Initailized */ package com.zz.bsp.orm.query; /** * 属性比较类型. 目前IN 只支持字符串的类型 * */ public enum MatchType { NEQ, EQ, LIKE, LT, GT, LE,GE, NULL, NOTNULL, IN ,LLIKE, RLIKE; public String express(){ if("LIKE".equals(this.name()) || "LLIKE".equals(this.name()) || "RLIKE".equals(this.name()) ){ return "LIKE"; } if("LT".equals(this.name())){ return "<"; } if("GT".equals(this.name())){ return ">"; } if("LE".equals(this.name())){ return "<="; } if("GE".equals(this.name())){ return ">="; } if("NULL".equals(this.name())){ return "is null"; } if("NOTNULL".equals(this.name())){ return "is not null"; } if("IN".equals(this.name())){ return "in"; } if("NEQ".equals(this.name())){ return "<>"; } return "="; } public String expressStart(){ if("LIKE".equals(this.name()) || "LLIKE".equals(this.name())){ return "%"; } if("IN".equals(this.name())){ return "("; } return ""; } public String expressEnd(){ if("LIKE".equals(this.name()) || "RLIKE".equals(this.name()) ){ return "%"; } if("IN".equals(this.name())){ return ")"; } return ""; } public boolean outputValue(){ if("NULL".equals(this.name()) || "NOTNULL".equals(this.name())){ return false; } return true; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/MatchType.java
Java
asf20
2,101
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-16 上午11:56:00 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-16 Initailized */ package com.zz.bsp.orm.query; import org.apache.commons.lang.StringUtils; import com.zz.bsp.util.AssertUtils; import com.zz.bsp.util.PropertyFilterUtils; import com.zz.bsp.util.ReflectionUtils; /** * 与具体ORM实现无关的属性过滤条件封装类. * * PropertyFilter主要记录页面中简单的搜索过滤条件,比Hibernate的Criterion要简单. * * */ public class PropertyFilter { /** 多个属性间OR关系的分隔符. */ public static final String OR_SEPARATOR = "_OR_"; private String[] propertyNames = null; private Class<?> propertyType = null; private Object propertyValue = null; private MatchType matchType = null; private String propertyTypeCode = null; public PropertyFilter() { } public PropertyFilter(MatchType matchType, PropertyType propertyType,String fieldName, String value){ this((matchType.name() + propertyType.name() + "_" + fieldName), value); } /** * @param filterName 比较属性字符串,含待比较的比较类型、属性值类型及属性列表. * eg. LIKES_NAME_OR_LOGIN_NAME * @param value 待比较的值. */ public PropertyFilter(final String filterName, final String value) { String matchTypeStr = StringUtils.substringBefore(filterName, "_"); String matchTypeCode = StringUtils.substring(matchTypeStr, 0, matchTypeStr.length() - 1); this.propertyTypeCode = StringUtils.substring(matchTypeStr, matchTypeStr.length() - 1, matchTypeStr.length()); try { matchType = Enum.valueOf(MatchType.class, matchTypeCode); } catch (RuntimeException e) { throw new IllegalArgumentException("filter type of " + filterName + " is illegal", e); } try { propertyType = Enum.valueOf(PropertyType.class, propertyTypeCode).getValue(); } catch (RuntimeException e) { throw new IllegalArgumentException("filter property type of " + filterName + " is illegal", e); } String propertyNameStr = StringUtils.substringAfter(filterName, "_"); propertyNames = StringUtils.splitByWholeSeparator(propertyNameStr, PropertyFilter.OR_SEPARATOR); AssertUtils.isTrue(propertyNames.length > 0, "filter name of " + filterName + "is illegal"); //按entity property中的类型将字符串转化为实际类型. this.propertyValue = ReflectionUtils.convertStringToObject(value, propertyType); } /** * 是否比较多个属性. */ public boolean isMultiProperty() { return (propertyNames.length > 1); } /** * 获取比较值的类型. */ public PropertyType getPropertyType(){ return PropertyType.valueOf(propertyTypeCode); } /** * 获取比较属性名称列表. */ public String[] getPropertyNames() { return propertyNames; } /** * 获取唯一的比较属性名称. */ public String getPropertyName() { if (propertyNames.length > 1) { throw new IllegalArgumentException("There are not only one property"); } return propertyNames[0]; } /** * 获取比较值. */ public Object getPropertyValue() { return propertyValue; } /** * 获取比较方式类型. */ public MatchType getMatchType() { return matchType; } /** * 获取Filter的Sql语句 * @return */ public String getSqlString(){ String sql = PropertyFilterUtils.propertyFilter2SqlString(this); return sql; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/PropertyFilter.java
Java
asf20
4,154
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-17 下午5:15:39 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-17 Initailized */ package com.zz.bsp.orm.query; import org.apache.commons.lang.StringUtils; /** * SQL 排序对象 * */ public class Order { //排序字段 private String orderBy; //排序方式 private String order; public Order(){ } public Order(String orderBy, String order){ this.orderBy = orderBy; setOrder(order); } public String getOrderBy() { return orderBy; } public void setOrderBy(String orderBy) { this.orderBy = orderBy; } public String getOrder() { return order; } public void setOrder(String order) { if(StringUtils.isBlank(order)){ this.order = Page.DESC; return; } if(Page.ASC.equalsIgnoreCase(order)){ this.order = Page.ASC; return; } this.order = Page.DESC; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/Order.java
Java
asf20
1,294
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-9-16 下午03:30:43 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-9-16 Initailized * Zhouxushun 2011-11-14 add array property type */ package com.zz.bsp.orm.query; import java.util.Date; import com.zz.bsp.constants.Constants; /** * 属性数据类型. * */ public enum PropertyType { S(String.class), I(Integer.class), L(Long.class), N(Double.class), D(Date.class), B(Boolean.class), A(String.class); private Class<?> clazz; PropertyType(Class<?> clazz) { this.clazz = clazz; } public Class<?> getValue() { return clazz; } public String expressStart(){ if("S".equals(this.name())){ return "'"; } if("D".equals(this.name())){ return "to_date('"; } return ""; } public String expressEnd(){ if("S".equals(this.name())){ return "'"; } if("D".equals(this.name())){ return "','" + Constants.ORACLE_LONG_TIME_FORMAT + "')"; } return ""; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/PropertyType.java
Java
asf20
1,397
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-17 下午3:41:36 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-17 Initailized * zhouxushun 2012-5-3 考虑电视分页的特殊性,MIN_PAGESIZE 大小由原来的5改成4 * */ package com.zz.bsp.orm.query; import java.io.Serializable; import java.util.Collections; import java.util.List; import org.apache.commons.lang.StringUtils; /** * 与具体ORM实现无关的分页参数及查询结果封装. * 注意所有序号从1开始. * * @param <T> Page中记录的类型. */ public class Page<T> implements Serializable{ private static final long serialVersionUID = -8126702682606137927L; public static final int MIN_PAGESIZE = 4; public static final int DEFAULT_PAGESIZE = 20; public static final int MAX_PAGESIZE = 1000; public static final int DEFAULT_PAGENUMSHOWN = 10; // 公共变量 public static final String ASC = "asc"; public static final String DESC = "desc"; //分页参数 protected int pageNum = 1; protected int numPerPage = DEFAULT_PAGESIZE; protected String orderField = null; protected String orderDirection = ASC; protected boolean autoCount = true; protected boolean autoPage = true; protected int pageNumShown = DEFAULT_PAGENUMSHOWN; //返回结果 protected List<T> result = null; protected long totalCount = -1; //扩展记录 protected Object extraObj = null; // 构造函数 public Page() { super(); } public Page(final int pageSize) { setNumPerPage(pageSize); } public Page(final int pageSize, final boolean autoCount) { setNumPerPage(pageSize); this.autoCount = autoCount; } /** * 获得当前页的页号,序号从1开始,默认为1. */ public int getPageNum() { return pageNum; } /** * 设置当前页的页号,序号从1开始,低于1时自动调整为1. */ public void setPageNum(int pageNum) { this.pageNum = pageNum; if (pageNum < 1) { this.pageNum = 1; } } /** * 获得每页的记录数量,默认为20. */ public int getNumPerPage() { return numPerPage; } /** * 设置每页的记录数量,超出MIN_PAGESIZE与MAX_PAGESIZE范围时会自动调整. */ public void setNumPerPage(final int numPerPage) { this.numPerPage = numPerPage; if (numPerPage < MIN_PAGESIZE) { this.numPerPage = MIN_PAGESIZE; } if (numPerPage > MAX_PAGESIZE) { this.numPerPage = MAX_PAGESIZE; } } /** * 根据pageNo和pageSize计算当前页第一条记录在总结果集中的位置,序号从0开始. */ public int getFirst() { return ((pageNum - 1) * numPerPage); } /** * 获得排序字段,无默认值.多个排序字段时用','分隔,仅在Criterion查询时有效. */ public String getOrderField() { return orderField; } /** * 设置排序字段.多个排序字段时用','分隔.仅在Criterion查询时有效. */ public void setOrderField(final String orderField) { this.orderField = orderField; } /** * 是否已设置排序字段,仅在Criterion查询时有效. */ public boolean isOrderBySetted() { return StringUtils.isNotBlank(orderField); } /** * 获得排序方向,默认为asc,仅在Criterion查询时有效. * * @param order 可选值为desc或asc,多个排序字段时用','分隔. */ public String getOrderDirection() { return orderDirection; } /** * 设置排序方式向,仅在Criterion查询时有效. * * @param order 可选值为desc或asc,多个排序字段时用','分隔. */ public void setOrderDirection(final String orderDirection) { //检查order字符串的合法值 String[] orders = StringUtils.split(orderDirection, ','); for (String orderStr : orders) { if (!StringUtils.equalsIgnoreCase(DESC, orderStr) && !StringUtils.equalsIgnoreCase(ASC, orderStr)) throw new IllegalArgumentException("排序方向" + orderStr + "不是合法值"); } this.orderDirection = orderDirection.toLowerCase(); } /** * 取得分页参数的组合字符串. * 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order. */ public String getPageRequest() { return getPageNum() + "|" + StringUtils.defaultString(getOrderField()) + "|" + getOrderDirection(); } /** * 设置分页参数的组合字符串. * 将多个分页参数组合成一个字符串方便在页面上的传递,格式为pageNo|orderBy|order. */ public void setPageRequest(final String pageRequest) { if (StringUtils.isBlank(pageRequest)) return; String[] params = StringUtils.splitPreserveAllTokens(pageRequest, '|'); if (StringUtils.isNumeric(params[0])) { setPageNum(Integer.valueOf(params[0])); } if (StringUtils.isNotBlank(params[1])) { setOrderField(params[1]); } if (StringUtils.isNotBlank(params[2])) { setOrderDirection(params[2]); } } /** * 查询对象时是否自动另外执行count查询获取总记录数,默认为false,仅在Criterion查询时有效. */ public boolean isAutoCount() { return autoCount; } /** * 查询对象时是否自动另外执行count查询获取总记录数,仅在Criterion查询时有效. */ public void setAutoCount(final boolean autoCount) { this.autoCount = autoCount; } // 查询结果函数 /** * 取得页内的记录列表. */ public List<T> getResult() { if (result == null) return Collections.emptyList(); return result; } public void setResult(final List<T> result) { this.result = result; } /** * 取得总记录数,默认值为-1. */ public long getTotalCount() { return totalCount; } public void setTotalCount(final long totalCount) { this.totalCount = totalCount; } /** * 根据pageSize与totalCount计算总页数,默认值为-1. */ public long getTotalPages() { if (totalCount < 0) return -1; long count = totalCount / numPerPage; if (totalCount % numPerPage > 0) { count++; } return count; } /** * 是否还有下一页. */ public boolean isHasNext() { return (pageNum + 1 <= getTotalPages()); } /** * 取得下页的页号,序号从1开始. */ public int getNextPage() { if (isHasNext()) return pageNum + 1; else return pageNum; } /** * 是否还有上一页. */ public boolean isHasPre() { return (pageNum - 1 >= 1); } /** * 取得上页的页号,序号从1开始. */ public int getPrePage() { if (isHasPre()) return pageNum - 1; else return pageNum; } /** * 取得反转的排序方向. * 如果有以','分隔的多个排序方向,逐一进行反转. */ public String getInverseOrder() { String[] orders = StringUtils.split(orderDirection, ','); for (int i = 0; i < orders.length; i++) { if (DESC.equals(orders[i])) { orders[i] = ASC; } else { orders[i] = DESC; } } return StringUtils.join(orders); } public boolean isAutoPage() { return autoPage; } public void setAutoPage(boolean autoPage) { this.autoPage = autoPage; } public Object getExtraObj() { return extraObj; } public void setExtraObj(Object extraObj) { this.extraObj = extraObj; } public int getPageNumShown() { return pageNumShown; } public void setPageNumShown(int pageNumShown) { this.pageNumShown = pageNumShown; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/query/Page.java
Java
asf20
8,868
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午02:43:08 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.mybatis; import org.mybatis.spring.SqlSessionFactoryBean; import com.zz.bsp.orm.dialect.Dialect; import com.zz.bsp.orm.dialect.OracleDialect; /** * OECS的SqlSessionFactoryBean * * 添加了分页查询和行数总计 */ public class OecsSqlSessionFactoryBean extends SqlSessionFactoryBean { // 需要被注入的值 private String dialectClass = "com.orientpay.oecs.framework.orm.dialect.OracleDialect"; private Dialect dialect = new OracleDialect(); /** * @param dialectValue * the dialectValue to set */ public void setDialectClass(String dialectClass) { this.dialectClass = dialectClass; try { dialect = (Dialect) Class.forName(dialectClass).newInstance(); } catch (Exception e) { throw new IllegalArgumentException(dialectClass +" : can not init!"); } } public String getDialectClass(){ return dialectClass; } public Dialect getDialect(){ return dialect; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/mybatis/OecsSqlSessionFactoryBean.java
Java
asf20
1,496
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-26 下午03:13:16 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-26 Initailized */ package com.zz.bsp.orm.mybatis; import java.util.Properties; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.ibatis.executor.Executor; import org.apache.ibatis.mapping.BoundSql; import org.apache.ibatis.mapping.MappedStatement; import org.apache.ibatis.mapping.MappedStatement.Builder; import org.apache.ibatis.mapping.SqlSource; import org.apache.ibatis.plugin.Interceptor; import org.apache.ibatis.plugin.Intercepts; import org.apache.ibatis.plugin.Invocation; import org.apache.ibatis.plugin.Plugin; import org.apache.ibatis.plugin.Signature; import org.apache.ibatis.session.ResultHandler; import org.apache.ibatis.session.RowBounds; import com.zz.bsp.orm.dialect.Dialect; /** * mybatis分页拦截器 * */ @Intercepts({@Signature(type=Executor.class,method = "query", args = {MappedStatement.class, Object.class, RowBounds.class, ResultHandler.class})}) public class PaginationInterceptor implements Interceptor{ public static final Log log = LogFactory.getLog(PaginationInterceptor.class); private final static int MAPPED_STATEMENT_INDEX = 0; private final static int PARAMETER_INDEX = 1; private final static int ROWBOUNDS_INDEX = 2; private final static int MAX_VALUE_CONDITION = RowBounds.NO_ROW_LIMIT; private Dialect dialect; public Object intercept(Invocation invocation) throws Throwable { final Object[] queryArgs = invocation.getArgs(); if(queryArgs[ROWBOUNDS_INDEX] != null){ final RowBounds rowBounds = (RowBounds)queryArgs[ROWBOUNDS_INDEX]; if(rowBounds.getLimit() < MAX_VALUE_CONDITION){ processIntercept(invocation.getArgs()); } } queryArgs[ROWBOUNDS_INDEX] = org.apache.ibatis.session.RowBounds.DEFAULT; return invocation.proceed(); } private void processIntercept(final Object[] queryArgs) { MappedStatement ms = (MappedStatement)queryArgs[MAPPED_STATEMENT_INDEX]; Object parameter = queryArgs[PARAMETER_INDEX]; final RowBounds rowBounds = (RowBounds)queryArgs[ROWBOUNDS_INDEX]; if (rowBounds != null) { int offset = rowBounds.getOffset(); int limit = rowBounds.getLimit(); if (dialect.supportsLimit() && (offset != RowBounds.NO_ROW_OFFSET || limit != RowBounds.NO_ROW_LIMIT)) { log.debug("Pagination query prepare ..."); BoundSql boundSql = ms.getBoundSql(parameter); String sql = boundSql.getSql().trim(); if (dialect.supportsLimitOffset()) { sql = dialect.getLimitString(sql, offset, limit); offset = RowBounds.NO_ROW_OFFSET; } else { sql = dialect.getLimitString(sql, 0, limit); } BoundSql newBoundSql = new BoundSql(ms.getConfiguration(),sql, boundSql.getParameterMappings(), boundSql.getParameterObject()); log.debug("Mybatis Page Search:"+ sql.replaceAll("\n", "")); MappedStatement newMs = copyFromMappedStatement(ms, new BoundSqlSqlSource(newBoundSql)); queryArgs[MAPPED_STATEMENT_INDEX] = newMs; } } queryArgs[ROWBOUNDS_INDEX]= RowBounds.DEFAULT; } private MappedStatement copyFromMappedStatement(MappedStatement ms,SqlSource newSqlSource) { Builder builder = new MappedStatement.Builder(ms.getConfiguration(),ms.getId(),newSqlSource,ms.getSqlCommandType()); builder.resource(ms.getResource()); builder.fetchSize(ms.getFetchSize()); builder.statementType(ms.getStatementType()); builder.keyGenerator(ms.getKeyGenerator()); if(ms.getKeyProperties() != null && ms.getKeyProperties().length > 0) { builder.keyProperty(ms.getKeyProperties()[0]); } builder.timeout(ms.getTimeout()); builder.parameterMap(ms.getParameterMap()); builder.resultMaps(ms.getResultMaps()); builder.resultSetType(ms.getResultSetType()); builder.cache(ms.getCache()); builder.flushCacheRequired(ms.isFlushCacheRequired()); builder.statementType(ms.getStatementType()); MappedStatement newMs = builder.build(); return newMs; } public Object plugin(Object target) { return Plugin.wrap(target, this); } public static class BoundSqlSqlSource implements SqlSource { BoundSql boundSql; public BoundSqlSqlSource(BoundSql boundSql) { this.boundSql = boundSql; } public BoundSql getBoundSql(Object parameterObject) { return boundSql; } } public void setProperties(Properties props) { String dialectClass = props.getProperty("dialect"); try { dialect = (Dialect) Class.forName(dialectClass).newInstance(); } catch (Exception e) { throw new IllegalArgumentException(dialectClass +" : can not init!"); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/orm/mybatis/PaginationInterceptor.java
Java
asf20
5,751
package com.zz.bsp.core; import java.util.ArrayList; import java.util.List; /** * 前端UI菜单 * @author Administrator * */ public class UiMenu { private String id; //上级ID private String pid; private String name; private String iconCls; private String url; private List<UiMenu> child = new ArrayList<UiMenu>(5); public String getId() { return id; } public void setId(String id) { this.id = id; } public String getPid() { return pid; } public void setPid(String pid) { this.pid = pid; } public String getName() { return name; } public void setName(String name) { this.name = name; } public String getIconCls() { return iconCls; } public void setIconCls(String iconCls) { this.iconCls = iconCls; } public String getUrl() { return url; } public void setUrl(String url) { this.url = url; } public List<UiMenu> getChild() { return child; } public void setChild(List<UiMenu> child) { this.child = child; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/UiMenu.java
Java
asf20
1,050
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-15 上午11:39:51 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-15 Initailized */ package com.zz.bsp.core; import java.io.Serializable; /** * SpringSecurity UserDetails impl * */ public class OecsUserDetailsImpl implements Serializable { private static final long serialVersionUID = 4779719257045848137L; // 用户唯一的ID private String userId; // 用户名 private String username; // 用户真实姓名 private String realname; // 登录方式,目前支持口令和动态密码 private String loginType; // 密码 private String password; // 默认的系统appCode private String defautAppCode; // 扩展信息 private Object extraInfo; // 是否已经初始化权限信息 private boolean initAuthInfoFlag; // 用户部门信息 private String userOrgName; public void setUsername(String username) { this.username = username; } public void setPassword(String password) { this.password = password; } public String getPassword() { return password; } public String getUsername() { return username; } public boolean isAccountNonExpired() { return true; } public boolean isAccountNonLocked() { return true; } public boolean isCredentialsNonExpired() { return true; } public boolean isEnabled() { return true; } public Object getExtraInfo() { return extraInfo; } public void setExtraInfo(Object extraInfo) { this.extraInfo = extraInfo; } public boolean isInitAuthInfoFlag() { return initAuthInfoFlag; } public void setInitAuthInfoFlag(boolean initAuthInfoFlag) { this.initAuthInfoFlag = initAuthInfoFlag; } public String getUserId() { return userId; } public void setUserId(String userId) { this.userId = userId; } /** * Property accessor of realname * * @return the realname */ public String getRealname() { return realname; } /** * @param realname * the realname to set */ public void setRealname(String realname) { this.realname = realname; } /** * Property accessor of loginType * * @return the loginType */ public String getLoginType() { return loginType; } /** * @param loginType * the loginType to set */ public void setLoginType(String loginType) { this.loginType = loginType; } /** * Property accessor of defautAppCode * * @return the defautAppCode */ public String getDefautAppCode() { return defautAppCode; } /** * @param defautAppCode * the defautAppCode to set */ public void setDefautAppCode(String defautAppCode) { this.defautAppCode = defautAppCode; } public String getUserOrgName() { return userOrgName; } public void setUserOrgName(String userOrgName) { this.userOrgName = userOrgName; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/OecsUserDetailsImpl.java
Java
asf20
3,186
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午04:53:49 * $URL$ * * Change Log * Author Change Date Comments * ------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.core; import java.util.HashMap; /** * ThreadLocal上下文 * 用于存储一些需要在一个线程里面用到的变量 * 比如remoteIp, username, password */ public class ThreadLocalContext { private static final ThreadLocal<ThreadLocalContext> localContext = new ThreadLocal<ThreadLocalContext>(); private int count; private final HashMap<String, Object> values = new HashMap<String, Object>(); private ThreadLocalContext() { } /** * Sets the request serviceContext. * * */ public static synchronized ThreadLocalContext begin() { ThreadLocalContext context = localContext.get(); if (context == null) { context = new ThreadLocalContext(); localContext.set(context); } context.count++; return context; } /** * Returns the service request. */ public static ThreadLocalContext getContext() { return localContext.get(); } /** * Add a object. */ public void addValue(String key, Object value) { values.put(key, value); } /** * Gets a object. */ public Object getValue(String key) { return values.get(key); } /** * Gets a header from the context. */ public static Object getContextValue(String header) { ThreadLocalContext context = localContext.get(); if (context != null) { return context.getValue(header); } return null; } /** * Cleanup at the end of a request. */ public static synchronized void end() { ThreadLocalContext context = localContext.get(); if (context != null && --context.count == 0) { context.values.clear(); localContext.remove(); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/ThreadLocalContext.java
Java
asf20
2,269
package com.zz.bsp.core; import java.util.ArrayList; import java.util.List; public class GridViewDto<T> { private List<T> rows = new ArrayList<T>(20); private Long total = 0L; public List<T> getRows() { return rows; } public void setRows(List<T> rows) { this.rows = rows; } public Long getTotal() { return total; } public void setTotal(Long total) { this.total = total; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/GridViewDto.java
Java
asf20
425
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2012-5-25 上午9:29:04 * $URL$ * * Change Log * Author Change Date Comments * ------------------------------------------------------------- * jason 2012-5-25 Initailized */ package com.zz.bsp.core; import java.util.Iterator; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import org.springframework.beans.BeanUtils; import org.springframework.beans.TypeConverter; import org.springframework.beans.factory.config.AbstractFactoryBean; import org.springframework.core.GenericCollectionTypeResolver; /** * 多个map设置 * */ public class MutilMapFactoryBean extends AbstractFactoryBean<Map<?, ?>> { private List<Map<?, ?>> sourceList; private Class<?> targetMapClass; public void setSourceList(List<Map<?, ?>> sourceList) { this.sourceList = sourceList; } public void setTargetMapClass(Class<?> targetMapClass) { if (targetMapClass == null) { throw new IllegalArgumentException("'targetMapClass' must not be null"); } if (!(Map.class.isAssignableFrom(targetMapClass))){ throw new IllegalArgumentException("'targetMapClass' must implement [java.util.Map]"); } this.targetMapClass = targetMapClass; } @SuppressWarnings("rawtypes") public Class<Map> getObjectType() { return Map.class; } @SuppressWarnings({ "unchecked", "rawtypes" }) protected Map<?, ?> createInstance() { if (this.sourceList == null) throw new IllegalArgumentException("'sourceList' is required"); Map<Object, Object> result = null; if (this.targetMapClass != null) { result = (Map<Object, Object>) BeanUtils.instantiateClass(this.targetMapClass); } else{ result = new LinkedHashMap<Object, Object>(); } Class<?> keyType = null; Class<?> valueType = null; if (this.targetMapClass != null) { keyType = GenericCollectionTypeResolver.getMapKeyType((Class<? extends Map>) this.targetMapClass); valueType = GenericCollectionTypeResolver.getMapValueType((Class<? extends Map>) this.targetMapClass); } if ((keyType != null) || (valueType != null)) { TypeConverter converter = getBeanTypeConverter(); for(Map<?, ?> map : sourceList){ for (Iterator localIterator = map.entrySet().iterator(); localIterator.hasNext();) { Map.Entry entry = (Map.Entry) localIterator.next(); Object convertedKey = converter.convertIfNecessary(entry.getKey(), keyType); Object convertedValue = converter.convertIfNecessary(entry.getValue(), valueType); result.put(convertedKey, convertedValue); } } } else { for(Map<?, ?> map : sourceList){ result.putAll(map); } } return result; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/MutilMapFactoryBean.java
Java
asf20
3,251
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午03:54:13 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.core; import java.io.Serializable; import java.util.HashMap; import java.util.Map; /** * 所有Model的基类 * */ public abstract class Model implements Serializable{ private static final long serialVersionUID = -7346901881796052757L; //用来保存修改的字段 protected Map<String, Object> entityMap = new HashMap<String, Object>(); public Map<String, Object> getEntityMap() { return entityMap; } public abstract Serializable getPK(); }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/core/Model.java
Java
asf20
875
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-utility-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-13 下午5:19:43 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-13 Initailized */ package com.zz.bsp.util; import java.io.IOException; import java.util.Properties; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 系统属性配置文件工具类 * */ public class SystemPropsUtils { protected static final Log log = LogFactory.getLog(SystemPropsUtils.class); protected static final String SYSTEM_PROPERTY_FILENAME = "system.properties"; private static Properties prop; private SystemPropsUtils(){ } public static String getString(String aKey){ return getString(aKey,""); } public static String getString(String aKey,String defaultValue){ String value = (String)prop.get(aKey); if(StringUtils.isBlank(value)){ log.debug("the property is null"); value = defaultValue; } log.debug("the property is ->" + value); return value; } static{ try { prop = ResourcesUtils.getResourceAsProperties(SYSTEM_PROPERTY_FILENAME); } catch (IOException e) { log.error("ERROR", e); throw new RuntimeException("Could not find : " + SYSTEM_PROPERTY_FILENAME,e); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/SystemPropsUtils.java
Java
asf20
1,660
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-8 上午11:41:33 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-8 Initailized */ package com.zz.bsp.util; import java.io.File; import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.net.URLConnection; import java.util.Properties; /** * 资源工具类 * */ public class ResourcesUtils { private ResourcesUtils(){ } public static URL getResourceURL(String resource) throws IOException { return getResourceURL(ClassLoaderUtils.getDefaultClassLoader(), resource); } public static URL getResourceURL(ClassLoader loader, String resource) throws IOException { URL url = null; if (loader != null){ url = loader.getResource(resource); } if (url == null){ url = ClassLoader.getSystemResource(resource); } if (url == null){ throw new IOException("Could not find resource " + resource); } return url; } public static InputStream getResourceAsStream(String resource) throws IOException { return getResourceAsStream(ClassLoaderUtils.getDefaultClassLoader(), resource); } public static InputStream getResourceAsStream(ClassLoader loader, String resource) throws IOException { InputStream in = null; if (loader != null){ in = loader.getResourceAsStream(resource); } if (in == null){ in = ClassLoader.getSystemResourceAsStream(resource); } if(in == null){ in = new FileInputStream(new File(resource)); } return in; } public static Properties getResourceAsProperties(String resource) throws IOException { Properties props = new Properties(); InputStream in = null; String propfile = resource; in = getResourceAsStream(propfile); props.load(in); in.close(); return props; } public static Properties getResourceAsProperties(ClassLoader loader, String resource) throws IOException { Properties props = new Properties(); InputStream in = null; String propfile = resource; in = getResourceAsStream(loader, propfile); props.load(in); in.close(); return props; } public static Reader getResourceAsReader(String resource) throws IOException { return new InputStreamReader(getResourceAsStream(resource)); } public static Reader getResourceAsReader(ClassLoader loader, String resource) throws IOException { return new InputStreamReader(getResourceAsStream(loader, resource)); } public static File getResourceAsFile(String resource) throws IOException { return new File(getResourceURL(resource).getFile()); } public static File getResourceAsFile(ClassLoader loader, String resource) throws IOException { return new File(getResourceURL(loader, resource).getFile()); } public static InputStream getUrlAsStream(String urlString) throws IOException { URL url = new URL(urlString); URLConnection conn = url.openConnection(); return conn.getInputStream(); } public static Reader getUrlAsReader(String urlString) throws IOException { return new InputStreamReader(getUrlAsStream(urlString)); } public static Properties getUrlAsProperties(String urlString) throws IOException { Properties props = new Properties(); InputStream in = null; String propfile = urlString; in = getUrlAsStream(propfile); props.load(in); in.close(); return props; } public static Class<?> classForName(String className) throws ClassNotFoundException { Class<?> clazz = null; try { clazz = ClassLoaderUtils.getDefaultClassLoader().loadClass(className); } catch (Exception e) { } if (clazz == null) { clazz = Class.forName(className); } return clazz; } public static Object instantiate(String className) throws ClassNotFoundException, InstantiationException, IllegalAccessException { return instantiate(classForName(className)); } public static Object instantiate(Class<?> clazz) throws InstantiationException, IllegalAccessException { return clazz.newInstance(); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ResourcesUtils.java
Java
asf20
5,007
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-3 下午05:14:07 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-3 Initailized */ package com.zz.bsp.util; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import org.apache.commons.beanutils.ConvertUtils; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.beanutils.converters.DateConverter; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 反射工具类 * */ public class ReflectionUtils { private static Log log = LogFactory.getLog(ReflectionUtils.class); static { DateConverter dc = new DateConverter(); dc.setUseLocaleFormat(true); dc.setPatterns(new String[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyyMMdd" }); ConvertUtils.register(dc, Date.class); } /** * 调用Getter方法. */ public static Object invokeGetterMethod(Object target, String propertyName) { String getterMethodName = "get" + StringUtils.capitalize(propertyName); return invokeMethod(target, getterMethodName, new Class[] {}, new Object[] {}); } /** * 调用Setter方法.使用value的Class来查找Setter方法. */ public static void invokeSetterMethod(Object target, String propertyName, Object value) { invokeSetterMethod(target, propertyName, value, null); } /** * 调用Setter方法. * * @param propertyType * 用于查找Setter方法,为空时使用value的Class替代. */ public static void invokeSetterMethod(Object target, String propertyName, Object value, Class<?> propertyType) { Class<?> type = propertyType != null ? propertyType : value.getClass(); String setterMethodName = "set" + StringUtils.capitalize(propertyName); invokeMethod(target, setterMethodName, new Class[] { type }, new Object[] { value }); } /** * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. */ public static Object getFieldValue(final Object object, final String fieldName) { Field field = getDeclaredField(object, fieldName); if (field == null) { throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + object + "]"); } makeAccessible(field); Object result = null; try { result = field.get(object); } catch (IllegalAccessException e) { log.error("ERROR", e); } return result; } /** * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. */ public static void setFieldValue(final Object object, final String fieldName, final Object value) { Field field = getDeclaredField(object, fieldName); if (field == null) { throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + object + "]"); } makeAccessible(field); try { field.set(object, value); } catch (IllegalAccessException e) { log.error("ERROR", e);; } } /** * 直接调用对象方法, 无视private/protected修饰符. */ public static Object invokeMethod(final Object object, final String methodName, final Class<?>[] parameterTypes, final Object[] parameters) { Method method = getDeclaredMethod(object, methodName, parameterTypes); if (method == null) { throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + object + "]"); } method.setAccessible(true); try { return method.invoke(object, parameters); } catch (Exception e) { throw convertReflectionExceptionToUnchecked(e); } } /** * 循环向上转型, 获取对象的DeclaredField. * * 如向上转型到Object仍无法找到, 返回null. */ public static Field getDeclaredField(final Object object, final String fieldName) { if (object == null) { log.debug("object is null"); return null; } if (StringUtils.isBlank(fieldName)) { log.debug("fieldName is null"); return null; } for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { return superClass.getDeclaredField(fieldName); } catch (NoSuchFieldException e) { // NOSONAR ,Field不在当前类定义,继续向上转型 } } return null; } /** * 强行设置Field可访问. */ protected static void makeAccessible(final Field field) { if (!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers())) { field.setAccessible(true); } } /** * 循环向上转型, 获取对象的DeclaredMethod. * * 如向上转型到Object仍无法找到, 返回null. */ protected static Method getDeclaredMethod(Object object, String methodName, Class<?>[] parameterTypes) { if (object == null) { log.debug("object is null"); return null; } for (Class<?> superClass = object.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { try { return superClass.getDeclaredMethod(methodName, parameterTypes); } catch (NoSuchMethodException e) { // NOSONAR, Method不在当前类定义,继续向上转型 } } return null; } /** * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. 如无法找到, 返回Object.class. eg. public UserDao * extends HibernateDao<User> * * @param clazz * The class to introspect * @return the first generic declaration, or Object.class if cannot be * determined */ @SuppressWarnings("unchecked") public static <T> Class<T> getSuperClassGenricType(final Class<?> clazz) { return (Class<T>) getSuperClassGenricType(clazz, 0); } /** * 通过反射, 获得定义Class时声明的父类的泛型参数的类型. 如无法找到, 返回Object.class. * * 如public UserDao extends HibernateDao<User,Long> * * @param clazz * clazz The class to introspect * @param index * the Index of the generic ddeclaration,start from 0. * @return the index generic declaration, or Object.class if cannot be * determined */ public static Class<?> getSuperClassGenricType(final Class<?> clazz, final int index) { Type genType = clazz.getGenericSuperclass(); if (!(genType instanceof ParameterizedType)) { log.warn(clazz.getSimpleName() + "'s superclass not ParameterizedType"); return Object.class; } Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if (index >= params.length || index < 0) { log.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " + params.length); return Object.class; } if (!(params[index] instanceof Class)) { log.warn(clazz.getSimpleName() + " not set the actual class on superclass generic parameter"); return Object.class; } return (Class<?>) params[index]; } /** * 提取集合中的对象的属性(通过getter函数), 组合成List. * * @param collection * 来源集合. * @param propertyName * 要提取的属性名. */ public static List<?> convertElementPropertyToList(final Collection<?> collection, final String propertyName) { List<Object> list = new ArrayList<Object>(); try { for (Object obj : collection) { list.add(PropertyUtils.getProperty(obj, propertyName)); } } catch (Exception e) { throw convertReflectionExceptionToUnchecked(e); } return list; } /** * 提取集合中的对象的属性(通过getter函数), 组合成由分割符分隔的字符串. * * @param collection * 来源集合. * @param propertyName * 要提取的属性名. * @param separator * 分隔符. */ public static String convertElementPropertyToString(final Collection<?> collection, final String propertyName, final String separator) { List<?> list = convertElementPropertyToList(collection, propertyName); return StringUtils.join(list, separator); } /** * 转换字符串到相应类型. * * @param value * 待转换的字符串 * @param toType * 转换目标类型 */ public static Object convertStringToObject(String value, Class<?> toType) { try { return ConvertUtils.convert(value, toType); } catch (Exception e) { throw convertReflectionExceptionToUnchecked(e); } } /** * 将反射时的checked exception转换为unchecked exception. */ public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) { if (e instanceof IllegalAccessException || e instanceof IllegalArgumentException || e instanceof NoSuchMethodException) { return new IllegalArgumentException("Reflection Exception.", e); } else if (e instanceof InvocationTargetException) { return new RuntimeException("Reflection Exception.", ((InvocationTargetException) e).getTargetException()); } else if (e instanceof RuntimeException) { return (RuntimeException) e; } return new RuntimeException("Unexpected Checked Exception.", e); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ReflectionUtils.java
Java
asf20
12,545
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-5 下午05:48:35 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-5 Initailized */ package com.zz.bsp.util; import java.util.Collection; import java.util.Map; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; /** * 断言类 用于检查参数,抛出运行时异常 * */ public class AssertUtils { private AssertUtils() { } public static void isTrue(boolean expression, String message) { if (!(expression)){ throw new IllegalArgumentException(message); } } public static void isTrue(boolean expression) { isTrue(expression, "[Assertion failed] - this expression must be true"); } public static void isNull(Object object, String message) { if (object != null){ throw new IllegalArgumentException(message); } } public static void isNull(Object object) { isNull(object, "[Assertion failed] - the object argument must be null"); } public static void notNull(Object object, String message) { if (object == null){ throw new IllegalArgumentException(message); } } public static void notNull(Object object) { notNull(object, "[Assertion failed] - this argument is required; it must not be null"); } public static void hasLength(String text, String message) { if (StringUtils.isBlank(text)){ throw new IllegalArgumentException(message); } } public static void hasLength(String text) { hasLength(text, "[Assertion failed] - this String argument must have length; it must not be null or empty"); } public static void hasText(String text, String message) { if (StringUtils.isBlank(text)){ throw new IllegalArgumentException(message); } } public static void hasText(String text) { hasText(text, "[Assertion failed] - this String argument must have text; it must not be null, empty, or blank"); } public static void doesNotContain(String textToSearch, String substring, String message) { if ((StringUtils.isBlank(textToSearch)) || (StringUtils.isBlank(substring)) || (textToSearch.indexOf(substring) == -1)){ return; } throw new IllegalArgumentException(message); } public static void doesNotContain(String textToSearch, String substring) { doesNotContain(textToSearch, substring, "[Assertion failed] - this String argument must not contain the substring [" + substring + "]"); } public static void notEmpty(Object[] array, String message) { if (array == null || array.length == 0){ throw new IllegalArgumentException(message); } } public static void notEmpty(Object[] array) { notEmpty(array, "[Assertion failed] - this array must not be empty: it must contain at least 1 element"); } public static void noNullElements(Object[] array, String message) { if (array != null){ for (int i = 0; i < array.length; ++i){ if (array[i] == null){ throw new IllegalArgumentException(message); } } } } public static void noNullElements(Object[] array) { noNullElements(array, "[Assertion failed] - this array must not contain any null elements"); } public static void notEmpty(Collection<?> collection, String message) { if (CollectionUtils.isEmpty(collection)){ throw new IllegalArgumentException(message); } } public static void notEmpty(Collection<?> collection) { notEmpty(collection, "[Assertion failed] - this collection must not be empty: it must contain at least 1 element"); } public static void notEmpty(Map<?,?> map, String message) { if (map == null || map.size() == 0){ throw new IllegalArgumentException(message); } } public static void notEmpty(Map<?,?> map) { notEmpty(map, "[Assertion failed] - this map must not be empty; it must contain at least one entry"); } public static void isInstanceOf(Class<?> clazz, Object obj) { isInstanceOf(clazz, obj, ""); } public static void isInstanceOf(Class<?> type, Object obj, String message) { notNull(type, "Type to check against must not be null"); if (!(type.isInstance(obj))) throw new IllegalArgumentException(message + "Object of class [" + ((obj != null) ? obj.getClass().getName() : "null") + "] must be an instance of " + type); } public static void isAssignable(Class<?> superType, Class<?> subType) { isAssignable(superType, subType, ""); } public static void isAssignable(Class<?> superType, Class<?> subType, String message) { notNull(superType, "Type to check against must not be null"); if ((subType == null) || (!(superType.isAssignableFrom(subType)))) throw new IllegalArgumentException(message + subType + " is not assignable to " + superType); } public static void state(boolean expression, String message) { if (!(expression)) throw new IllegalStateException(message); } public static void state(boolean expression) { state(expression, "[Assertion failed] - this state invariant must be true"); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/AssertUtils.java
Java
asf20
6,515
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-16 下午12:43:02 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-16 Initailized */ package com.zz.bsp.util; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.Iterator; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.lang.StringUtils; import com.zz.bsp.constants.Constants; import com.zz.bsp.orm.query.MatchType; import com.zz.bsp.orm.query.PropertyFilter; import com.zz.bsp.orm.query.PropertyType; /** * TODO Add class descriptions * */ public class PropertyFilterUtils { /** * 根据对象ID集合,整理合并集合. * * 默认对象主键的名称名为"id". * * @see #mergeByCheckedIds(Collection, Collection, Class, String) */ public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds,final Class<T> clazz) { mergeByCheckedIds(srcObjects, checkedIds, clazz, "id"); } /** * 根据对象ID集合,整理合并集合. * * 页面发送变更后的子对象id列表时,删除原来的子对象集合再根据页面id列表创建一个全新的集合这种看似最简单的做法是不行的. * 因此采用如此的整合算法:在源集合中删除id不在目标集合中的对象,根据目标集合中的id创建对象并添加到源集合中. * 因为新建对象只有ID被赋值, 因此本函数不适合于cascade-save-or-update自动持久化子对象的设置. * * @param srcObjects 源集合,元素为对象. * @param checkedIds 目标集合,元素为ID. * @param clazz 集合中对象的类型 * @param idName 对象主键的名称 */ public static <T, ID> void mergeByCheckedIds(final Collection<T> srcObjects, final Collection<ID> checkedIds, final Class<T> clazz, final String idName) { //参数校验 AssertUtils.notNull(srcObjects, "scrObjects can not be null"); AssertUtils.hasText(idName, "idName can not be null"); AssertUtils.notNull(clazz, "clazz can not be null"); //目标集合为空, 删除源集合中所有对象后直接返回. if (checkedIds == null) { srcObjects.clear(); return; } //遍历源集合,如果其id不在目标ID集合中的对象,进行删除. //同时,在目标集合中删除已在源集合中的id,使得目标集合中剩下的id均为源集合中没有的id. Iterator<T> srcIterator = srcObjects.iterator(); try { while (srcIterator.hasNext()) { T element = srcIterator.next(); Object id; id = PropertyUtils.getProperty(element, idName); if (!checkedIds.contains(id)) { srcIterator.remove(); } else { checkedIds.remove(id); } } //ID集合目前剩余的id均不在源集合中,创建对象,为id属性赋值并添加到源集合中. for (ID id : checkedIds) { T obj = clazz.newInstance(); PropertyUtils.setProperty(obj, idName, id); srcObjects.add(obj); } } catch (Exception e) { throw ReflectionUtils.convertReflectionExceptionToUnchecked(e); } } /** * 根据按PropertyFilter命名规则的Request参数,创建PropertyFilter列表. * 默认Filter属性名前缀为filter_. * * @see #buildPropertyFilters(HttpServletRequest, String) */ public static List<PropertyFilter> buildPropertyFilters(final HttpServletRequest request) { return buildPropertyFilters(request, "filter_"); } //目前不支持and 和 or 的方式 public static List<PropertyFilter> buildMutilPropertyFilters(final HttpServletRequest request) { String columnsNames = request.getParameter("searchColumnNames"); if(StringUtils.isNotBlank(columnsNames)) { String [] columnsNameArr = columnsNames.split(Constants.COMMA_SIGN_SPLIT_NAME); String [] searchConditionArr = request.getParameter("searchConditions").split(Constants.COMMA_SIGN_SPLIT_NAME); String [] searchValsArr = request.getParameter("searchVals").split(Constants.COMMA_SIGN_SPLIT_NAME); int len = columnsNameArr.length; List<PropertyFilter> filterList = new ArrayList<PropertyFilter>(len); for(int i= 0; i < len; i++) { filterList.add(new PropertyFilter(searchConditionArr[i] + columnsNameArr[i], searchValsArr[i])); } return filterList; } else { return buildPropertyFilters(request, "filter_"); } } /** * 根据按PropertyFilter命名规则的Request参数,创建PropertyFilter列表. * PropertyFilter命名规则为Filter属性前缀_比较类型属性类型_属性名. * * eg. * filter_EQS_name * filter_LIKES_name_OR_email */ public static List<PropertyFilter> buildPropertyFilters(final HttpServletRequest request, final String filterPrefix) { List<PropertyFilter> filterList = new ArrayList<PropertyFilter>(); //从request中获取含属性前缀名的参数,构造去除前缀名后的参数Map. Map<String, Object> filterParamMap = ServletUtils.getParametersStartingWith(request, filterPrefix); //分析参数Map,构造PropertyFilter列表 for (Map.Entry<String, Object> entry : filterParamMap.entrySet()) { String filterName = entry.getKey(); Object valueObj = entry.getValue(); String value = null; if(valueObj instanceof String){ value = (String)valueObj; } //如果value值为空,则忽略此filter. if (StringUtils.isNotBlank(value)) { PropertyFilter filter = new PropertyFilter(filterName, value); filterList.add(filter); } } return filterList; } public static String propertyFilter2SqlString(PropertyFilter filter){ String[] propertyNames = filter.getPropertyNames(); StringBuilder sb = new StringBuilder(); if(filter.isMultiProperty()){ sb.append(" ("); } boolean isFirst = true; for(String propertyName : propertyNames){ if(StringUtils.isNotBlank(propertyName)){ if(isFirst){ isFirst = false; } else{ sb.append("OR"); } sb.append(propertyFilter2SqlString(propertyName, filter)); } } if(filter.isMultiProperty()){ sb.append(") "); } return sb.toString(); } protected static String propertyFilter2SqlString(String propertyName, PropertyFilter filter){ PropertyType propertyType = filter.getPropertyType(); Object propertyValue = filter.getPropertyValue(); MatchType matchType = filter.getMatchType(); StringBuilder sb = new StringBuilder(" " + propertyName); sb.append(" " + matchType.express() + " "); if(matchType.outputValue()){ sb.append(propertyType.expressStart()); sb.append(matchType.expressStart()); if(propertyValue != null && propertyValue instanceof Date){ Date date = (Date)propertyValue; sb.append(DateTimeUtils.dateToStringFormat(date, Constants.DEFUALT_LONG_TIME_FORMAT)); } else{ sb.append(propertyValue); } sb.append(matchType.expressEnd()); sb.append(propertyType.expressEnd() + " "); } return sb.toString(); } public static void main(String [] args){ PropertyType propertyType = PropertyType.D; MatchType matchType = MatchType.LLIKE; System.out.println(propertyType.name()); System.out.println(matchType.name()); String query1 = "LIKES_NAME_OR_LOGIN_NAME"; PropertyFilter f1 = new PropertyFilter(query1, "admin"); System.out.println(propertyFilter2SqlString(f1)); String query2 = "LLIKES_NAME_OR_LOGIN_NAME"; PropertyFilter f2 = new PropertyFilter(query2, "admin"); System.out.println(propertyFilter2SqlString(f2)); String query3 = "RLIKES_NAME_OR_LOGIN_NAME"; PropertyFilter f3 = new PropertyFilter(query3, "admin"); System.out.println(propertyFilter2SqlString(f3)); String query4 = "EQS_NAME"; PropertyFilter f4 = new PropertyFilter(query4, "admin"); System.out.println(propertyFilter2SqlString(f4)); String query5 = "GEI_NAME"; PropertyFilter f5 = new PropertyFilter(query5, "1"); System.out.println(propertyFilter2SqlString(f5)); String query6 = "GTI_NAME"; PropertyFilter f6 = new PropertyFilter(query6, "1"); System.out.println(propertyFilter2SqlString(f6)); String query7 = "EQD_NAME"; PropertyFilter f7 = new PropertyFilter(query7, "2011-02-03"); System.out.println(propertyFilter2SqlString(f7)); String query8 = "EQN_NAME"; PropertyFilter f8 = new PropertyFilter(query8, "1"); System.out.println(propertyFilter2SqlString(f8)); String query9 = "EQS_NAME"; PropertyFilter f9 = new PropertyFilter(query9, "admin"); System.out.println(propertyFilter2SqlString(f9)); String query10 = "GTD_CREATE_OR_LASTUPD"; PropertyFilter f10 = new PropertyFilter(query10, "2011-02-03 12:12:01"); System.out.println(propertyFilter2SqlString(f10)); String query11 = "INA_STATUS"; PropertyFilter f11 = new PropertyFilter(query11, "'A','B','C','D'"); System.out.println(propertyFilter2SqlString(f11)); String query12 = "NULLS_STATUS"; PropertyFilter f12 = new PropertyFilter(query12,null); System.out.println(propertyFilter2SqlString(f12)); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/PropertyFilterUtils.java
Java
asf20
10,941
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-18 下午7:05:51 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-18 Initailized */ package com.zz.bsp.util; import java.io.Serializable; import java.util.Date; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.math.NumberUtils; import com.zz.bsp.constants.Constants; import com.zz.bsp.core.OecsUserDetailsImpl; /** * model更新的辅助类,用于修改实体对象里面各个字段的信息 * */ public class ModelUpdInfoUtils { //创建和修改信息 public static final String CREATE_TIME = "createTime"; public static final String CREATE_OPER_ID = "createOperId"; public static final String CREATE_OPER_NAME = "createOperName"; public static final String LAST_MOD_TIME = "updateTime"; public static final String LAST_MOD_OPER_ID = "updateOperId"; public static final String LAST_MOD_OPER_NAME = "updateOperName"; public static final String STATUS = "status"; //主键信息 public static final String ID = "id"; public static final String CODE = "code"; public static final String APP_CODE = "appCode"; private ModelUpdInfoUtils(){ } /** * 更新实体对象的最后修改时间 * @param object 实体对象并且实现了Serializable接口的类 */ public static void updateModelUpdateTime(Object object){ if(object == null){ return; } if(ReflectionUtils.getDeclaredField(object,LAST_MOD_TIME) != null){ ReflectionUtils.invokeSetterMethod(object, LAST_MOD_TIME, new Date()); } } /** * 得到实体对象的最后修改时间 * @param object 实体对象并且实现了Serializable接口的类 */ public static Date getModelUpdateTime(Object object){ if(object == null){ return null; } try{ if(ReflectionUtils.getDeclaredField(object,LAST_MOD_TIME) != null){ Object dateObj = ReflectionUtils.invokeGetterMethod(object, LAST_MOD_TIME); if(dateObj instanceof Date){ return (Date)dateObj; } } } catch(Exception e){ } return null; } /** * 修改实体对象里面的创建时间,操作员ID,操作员姓名 * @param object 实体类并且实现了Serializable接口的类 * @param user 用户实体类 */ public static void updateModelInfo(Serializable object, OecsUserDetailsImpl user){ if(object == null || user == null){ return; } if(ReflectionUtils.getDeclaredField(object,LAST_MOD_OPER_ID) != null){ if(StringUtils.isNotBlank(user.getUserId())){ Long operId = NumberUtils.toLong(user.getUserId()); ReflectionUtils.invokeSetterMethod(object, LAST_MOD_OPER_ID, operId); } } if(ReflectionUtils.getDeclaredField(object,LAST_MOD_OPER_NAME) != null){ ReflectionUtils.invokeSetterMethod(object, LAST_MOD_OPER_NAME, user.getRealname()); } // 如果实体类存在主键 id,先设定实体对象主键值为null if(ReflectionUtils.getDeclaredField(object,ID) != null){ Object idValue = ReflectionUtils.getFieldValue(object, ID); if(idValue == null || "".equals(idValue)){ // 一定要设置为空,要不然无法插入数据库 ReflectionUtils.setFieldValue(object, ID, null); // 修改实体对象里面的创建时间,操作员ID,操作员姓名 updateModelCreateInfo(object,user); updateModelUpdateTime(object); } } else if(ReflectionUtils.getDeclaredField(object,CODE) != null || ReflectionUtils.getDeclaredField(object,APP_CODE) != null){ Object createTime = ReflectionUtils.getFieldValue(object, CREATE_TIME); if(createTime == null){ // 修改实体对象里面的创建时间,操作员ID,操作员姓名 updateModelCreateInfo(object,user); updateModelUpdateTime(object); } } // 修改实体对象里面的创建时间,操作员ID,操作员姓名 } /** * 修改实体对象里面的创建时间,操作员ID,操作员姓名 * @param object 实体类并且实现了Serializable接口的类 * @param user 用户实体类 */ protected static void updateModelCreateInfo(Serializable object, OecsUserDetailsImpl user){ if(ReflectionUtils.getDeclaredField(object,CREATE_TIME) != null){ ReflectionUtils.invokeSetterMethod(object, CREATE_TIME, DateTimeUtils.getCurrentDate()); } if(ReflectionUtils.getDeclaredField(object,CREATE_OPER_ID) != null){ if(StringUtils.isNotBlank(user.getUserId())){ Long operId = NumberUtils.toLong(user.getUserId()); ReflectionUtils.invokeSetterMethod(object, CREATE_OPER_ID, operId); } } if(ReflectionUtils.getDeclaredField(object,CREATE_OPER_NAME) != null){ ReflectionUtils.invokeSetterMethod(object, CREATE_OPER_NAME, user.getRealname()); } } /** * 修改实体对象里面的创建时间,操作员ID,操作员姓名和最后修改时间 * @param object 实体类并且实现了Serializable接口的类 * @param transCode 操作员姓名 */ public static void createModelInfoBySys(Serializable object, String transCode){ if(ReflectionUtils.getDeclaredField(object,CREATE_TIME) != null){ ReflectionUtils.invokeSetterMethod(object, CREATE_TIME, DateTimeUtils.getCurrentDate()); } if(ReflectionUtils.getDeclaredField(object,CREATE_OPER_ID) != null){ ReflectionUtils.invokeSetterMethod(object, CREATE_OPER_ID, Constants.GLOBAL_SYSTEM_OPER_ID); } if(ReflectionUtils.getDeclaredField(object,CREATE_OPER_NAME) != null){ ReflectionUtils.invokeSetterMethod(object, CREATE_OPER_NAME, transCode); } if(ReflectionUtils.getDeclaredField(object,LAST_MOD_TIME) != null){ ReflectionUtils.invokeSetterMethod(object, LAST_MOD_TIME, DateTimeUtils.getCurrentDate()); } updateModelInfoBySys(object, transCode); } /** * 修改实体对象里面的操作员ID、操作员姓名,表明这个订单现在是系统在操作 * @param object 实体类并且实现了Serializable接口的类 * @param transCode 操作员姓名 */ public static void updateModelInfoBySys(Serializable object, String transCode){ if(ReflectionUtils.getDeclaredField(object,LAST_MOD_OPER_ID) != null){ ReflectionUtils.invokeSetterMethod(object, LAST_MOD_OPER_ID, Constants.GLOBAL_SYSTEM_OPER_ID); } if(ReflectionUtils.getDeclaredField(object,LAST_MOD_OPER_NAME) != null){ ReflectionUtils.invokeSetterMethod(object, LAST_MOD_OPER_NAME, transCode); } } /** * 修改实体对象里面的状态为Invalidate,表明这个订单现在无效 * @param object 实体类并且实现了Serializable接口的类 */ public static void setModelInvalidStatus(Serializable object){ if(ReflectionUtils.getDeclaredField(object,STATUS) != null){ ReflectionUtils.invokeSetterMethod(object, STATUS, Constants.DICT_GLOBAL_STATUS_INVALIDATE); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ModelUpdInfoUtils.java
Java
asf20
8,096
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-8 上午11:46:29 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-8 Initailized */ package com.zz.bsp.util; import java.io.PrintStream; import java.text.MessageFormat; import java.util.Enumeration; import java.util.Iterator; import java.util.Properties; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.zz.bsp.constants.Constants; /** * request 工具类 * */ public class RequestUtils { private static final Log log = LogFactory.getLog(RequestUtils.class); private static Properties headerMap; private static String defaultMobile; static { /* * InputStream in = RequestUtils.class.getResourceAsStream( * "/cn/com/eaglenetworks/abdf/view/util/mobile_match.properties"); * headerMap = new Properties(); try{ headerMap.load(in); defaultMobile * = headerMap.getProperty("empty"); } catch(IOException e){ * log.error("ERROR",e); } */ headerMap = new Properties(); headerMap.put("x-up-calling-line-id", "{0}"); headerMap.put("x-up-subno", "86{0}_gateway"); headerMap.put("X-Imsi", "{0}"); headerMap.put("X-WAP-ClientID", "{0}"); headerMap.put("X-Network-info", "{2},{0},{1}"); } public static boolean isMultipart(HttpServletRequest req) { return ((req.getContentType() != null) && (req.getContentType() .toLowerCase().startsWith("multipart"))); } public static Cookie getCookie(HttpServletRequest request, String name) { Cookie[] cookies = request.getCookies(); if (cookies == null) { return null; } for (int i = 0; i < cookies.length; i++) { if (name.equals(cookies[i].getName())) { return cookies[i]; } } return null; } public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int maxAge) { Cookie cookie = new Cookie(name, value); cookie.setMaxAge(maxAge); String serverName = request.getServerName(); String domain = getDomainOfServerName(serverName); if (domain != null && domain.indexOf('.') != -1) { cookie.setDomain('.' + domain); } cookie.setPath("/"); response.addCookie(cookie); } public static String getDomainOfServerName(String host) { if (isIPAddr(host)) { return null; } String[] names = StringUtils.split(host, '.'); int len = names.length; if (len >= 2) { return names[len - 2] + '.' + names[len - 1]; } return host; } public static String getHeader(HttpServletRequest req, String name) { String value = req.getHeader(name); if (value != null) return value; Enumeration<?> names = req.getHeaderNames(); while (names.hasMoreElements()) { String n = (String) names.nextElement(); if (n.equalsIgnoreCase(name)) { return req.getHeader(n); } } return null; } public static String getUrlPrefix(HttpServletRequest req) { StringBuffer url = new StringBuffer(req.getScheme()); url.append("://"); url.append(req.getServerName()); int port = req.getServerPort(); if (port != 80) { url.append(":"); url.append(port); } return url.toString(); } public static String getRequestURL(HttpServletRequest req) { StringBuffer url = new StringBuffer(req.getRequestURI()); String param = req.getQueryString(); if (param != null) { url.append('?'); url.append(param); } String path = url.toString(); return path.substring(req.getContextPath().length()); } public static void dumpHeaders(PrintStream out, HttpServletRequest req) { Enumeration<?> names = req.getHeaderNames(); while (names.hasMoreElements()) { String name = (String) names.nextElement(); out.println(name + "=" + req.getHeader(name)); } } /** * 用于支持WAP * * @param req * @return */ public static String getRequestMobile(HttpServletRequest req) { String mobile = defaultMobile; Iterator<?> keys = headerMap.keySet().iterator(); while (keys.hasNext()) { String header = (String) keys.next(); String value = getHeader(req, header); if (value != null) { String pattern = (String) headerMap.get(header); MessageFormat mf = new MessageFormat(pattern); try { Object[] vs = mf.parse(value); mobile = (String) vs[0]; if (mobile.startsWith("86")) { mobile = mobile.substring(2); } break; } catch (Exception e) { log.warn("error", e); dumpHeaders(req, System.err); continue; } } } return mobile; } public static void dumpHeaders(HttpServletRequest req, PrintStream out) { Enumeration<?> hds = req.getHeaderNames(); while (hds.hasMoreElements()) { String name = (String) hds.nextElement(); out.println(name + "=" + req.getHeader(name)); } } public static boolean support(HttpServletRequest req, String contentType) { String accept = getHeader(req, "accept"); if (accept != null) { accept = accept.toLowerCase(); return accept.indexOf(contentType.toLowerCase()) != -1; } return false; } public static boolean isMozillaCompatible(HttpServletRequest req) { String user_agent = req.getHeader("user-agent"); return user_agent == null || user_agent.indexOf("Mozilla") != -1; } public static int getParam(HttpServletRequest req, String param, int defaultValue) { try { String value = req.getParameter(param); if (value == null) { return defaultValue; } int idx = value.indexOf('#'); if (idx != -1) { value = value.substring(0, idx); } return Integer.parseInt(value); } catch (Exception e) { log.error("error ", e); } return defaultValue; } public static String getParam(HttpServletRequest req, String param, String defaultValue) { String value = req.getParameter(param); return (StringUtils.isEmpty(value)) ? defaultValue : value; } public static boolean isIPAddr(String addr) { if (StringUtils.isEmpty(addr)) { return false; } String[] ips = StringUtils.split(addr, '.'); if (ips.length != 4) { return false; } try { int ipa = Integer.parseInt(ips[0]); int ipb = Integer.parseInt(ips[1]); int ipc = Integer.parseInt(ips[2]); int ipd = Integer.parseInt(ips[3]); return ipa >= 0 && ipa <= 255 && ipb >= 0 && ipb <= 255 && ipc >= 0 && ipc <= 255 && ipd >= 0 && ipd <= 255; } catch (Exception e) { } return false; } public static String convert2UTF8(String src){ if(StringUtils.isBlank(src)){ return src; } String ret = ""; try{ ret = new String(src.getBytes("ISO-8859-1"),Constants.DEFAULT_CHARSET_NAME); } catch(Exception e){ log.debug("warn : cannot convert :" + src); ret = src; } return ret; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/RequestUtils.java
Java
asf20
9,150
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-1 下午06:56:10 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-1 Initailized */ package com.zz.bsp.util; /** * Hex 处理工具类 * */ public class HexUtils { // 16进制 public static final char[] hex = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; private HexUtils(){ } /** * 把用十六进制字符串描述的数据转成byte类型 * @param b * @return */ public static final byte[] fromHex(String b) { char[] data = b.toCharArray(); int l = data.length; byte[] out = new byte[l >> 1]; int i = 0; for (int j = 0; j < l;) { int f = Character.digit(data[(j++)], 16) << 4; f |= Character.digit(data[(j++)], 16); out[i] = (byte) (f & 0xFF); ++i; } return out; } /** * 把byte类型转成用十六进制字符串描述的字符串 * @param b * @return */ public static final String toHex(byte[] b) { char[] buf = new char[b.length * 2]; int j; int i = j = 0; for (; i < b.length; ++i) { int k = b[i]; buf[(j++)] = hex[(k >>> 4 & 0xF)]; buf[(j++)] = hex[(k & 0xF)]; } return new String(buf); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/HexUtils.java
Java
asf20
1,709
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-framework-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午03:44:12 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.util; import java.io.UnsupportedEncodingException; import java.util.Enumeration; import java.util.Map; import java.util.StringTokenizer; import java.util.TreeMap; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Http与Servlet工具类. * */ public class ServletUtils { //-- Content Type 定义 --// public static final String TEXT_TYPE = "text/plain"; public static final String JSON_TYPE = "application/json"; public static final String XML_TYPE = "text/xml"; public static final String HTML_TYPE = "text/html"; public static final String JS_TYPE = "text/javascript"; public static final String EXCEL_TYPE = "application/vnd.ms-excel"; //-- Header 定义 --// public static final String AUTHENTICATION_HEADER = "Authorization"; //-- 常用数值定义 --// public static final long ONE_YEAR_SECONDS = 60 * 60 * 24 * 365; /** * 设置客户端缓存过期时间 Header. */ public static void setExpiresHeader(HttpServletResponse response, long expiresSeconds) { //Http 1.0 header response.setDateHeader("Expires", System.currentTimeMillis() + expiresSeconds * 1000); //Http 1.1 header response.setHeader("Cache-Control", "private, max-age=" + expiresSeconds); } /** * 设置客户端无缓存Header. */ public static void setNoCacheHeader(HttpServletResponse response) { //Http 1.0 header response.setDateHeader("Expires", 0); response.addHeader("Pragma", "no-cache"); //Http 1.1 header response.setHeader("Cache-Control", "no-cache"); } /** * 设置LastModified Header. */ public static void setLastModifiedHeader(HttpServletResponse response, long lastModifiedDate) { response.setDateHeader("Last-Modified", lastModifiedDate); } /** * 设置Etag Header. */ public static void setEtag(HttpServletResponse response, String etag) { response.setHeader("ETag", etag); } /** * 根据浏览器If-Modified-Since Header, 计算文件是否已被修改. * * 如果无修改, checkIfModify返回false ,设置304 not modify status. * * @param lastModified 内容的最后修改时间. */ public static boolean checkIfModifiedSince(HttpServletRequest request, HttpServletResponse response, long lastModified) { long ifModifiedSince = request.getDateHeader("If-Modified-Since"); if ((ifModifiedSince != -1) && (lastModified < ifModifiedSince + 1000)) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); return false; } return true; } /** * 根据浏览器 If-None-Match Header, 计算Etag是否已无效. * * 如果Etag有效, checkIfNoneMatch返回false, 设置304 not modify status. * * @param etag 内容的ETag. */ public static boolean checkIfNoneMatchEtag(HttpServletRequest request, HttpServletResponse response, String etag) { String headerValue = request.getHeader("If-None-Match"); if (headerValue != null) { boolean conditionSatisfied = false; if (!"*".equals(headerValue)) { StringTokenizer commaTokenizer = new StringTokenizer(headerValue, ","); while (!conditionSatisfied && commaTokenizer.hasMoreTokens()) { String currentToken = commaTokenizer.nextToken(); if (currentToken.trim().equals(etag)) { conditionSatisfied = true; } } } else { conditionSatisfied = true; } if (conditionSatisfied) { response.setStatus(HttpServletResponse.SC_NOT_MODIFIED); response.setHeader("ETag", etag); return false; } } return true; } /** * 设置让浏览器弹出下载对话框的Header. * * @param fileName 下载后的文件名. */ public static void setFileDownloadHeader(HttpServletResponse response, String fileName) { try { //中文文件名支持 String encodedfileName = new String(fileName.getBytes(), "ISO8859-1"); response.setHeader("Content-Disposition", "attachment; filename=\"" + encodedfileName + "\""); } catch (UnsupportedEncodingException e) { } } /** * 取得带相同前缀的Request Parameters. * * 返回的结果Parameter名已去除前缀. */ @SuppressWarnings("unchecked") public static Map<String, Object> getParametersStartingWith(HttpServletRequest request, String prefix) { Enumeration<String> paramNames = (Enumeration<String>)request.getParameterNames(); Map<String, Object> params = new TreeMap<String, Object>(); if (prefix == null) { prefix = ""; } while (paramNames != null && paramNames.hasMoreElements()) { String paramName = (String) paramNames.nextElement(); if ("".equals(prefix) || paramName.startsWith(prefix)) { String unprefixed = paramName.substring(prefix.length()); String[] values = request.getParameterValues(paramName); if (values == null || values.length == 0) { //NOSONAR, Do nothing, no values found at all. } else if (values.length > 1) { params.put(unprefixed, values); } else { params.put(unprefixed, values[0]); } } } return params; } /** * 对Http Basic验证的 Header进行编码. */ public static String encodeHttpBasic(String userName, String password) { String encode = userName + ":" + password; return "Basic " + EncodeUtils.base64Encode(encode.getBytes()); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ServletUtils.java
Java
asf20
6,616
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-utility-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-11-1 上午11:04:12 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-11-1 Initailized */ package com.zz.bsp.util; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; import java.util.Iterator; import java.util.Map; import org.apache.commons.beanutils.PropertyUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 对象操作工具类 * */ public class ObjectUtils { private static final Log log = LogFactory.getLog(ObjectUtils.class); private ObjectUtils(){ } /** * 得到方法的值 * @param property * @param object * @return */ public static Object getMethodValue(String property, Object object) { /*Field[] fields = object.getClass().getDeclaredFields(); Object valueObject = null; for (int j = 0; j < fields.length; j++) { if (fields[j].getName().equals(property)) { String firstChar = fields[j].getName().substring(0, 1); String leaveChar = fields[j].getName().substring(1); String methodName = firstChar.toUpperCase() + leaveChar; try { Method meth = object.getClass().getMethod("get" + methodName, null); valueObject = meth.invoke(object, null); } catch (Exception ex) { ex.printStackTrace(); } break; } } return valueObject;*/ //add by zhouxushun 2011-11-22 to support map if(object instanceof Map){ Map<?, ?> objMap = (Map<?, ?>)object; return objMap.get(property); } //end String firstChar = property.substring(0, 1); String leaveChar = property.substring(1); String methodName = firstChar.toUpperCase() + leaveChar; Object ret = null; try { Method method = getAllMethod("get" + methodName, object.getClass()); if(method != null){ //ret = method.invoke(object, null); ret = method.invoke(object, new Object[]{}); } } catch(Exception e){ log.warn(e.getMessage(), e); } return ret; } /** * 递归获取对象的值 * @param property * @param object * @return */ public static Object getMethodValueForRecursion(String property, Object object) { if (property == null || object == null) { return null; } if (property.indexOf(".") == -1) { return getMethodValue(property, object); } else { String theFirstProperty = property.substring(0, property.indexOf(".")); String theSecondProperty = property.substring(property.indexOf(".") + 1); Object firstObj = getMethodValue(theFirstProperty, object); return getMethodValueForRecursion(theSecondProperty, firstObj); } } /** * 对象复制 * @param srcObject * @param targetClassName * @return */ @SuppressWarnings("unchecked") public static Object objectCopy(Object srcObject, String targetClassName) { Object targetObject = null; if ((srcObject == null) || (targetClassName == null)) { return null; } if (srcObject instanceof Collection) { Iterator<Object> iter = ((Collection<Object>) srcObject).iterator(); Collection<Object> coll = new ArrayList<Object>(); Object item = null; Object targetItem = null; while (iter.hasNext()) { item = iter.next(); targetItem = deepObjectCopy(item, targetClassName); coll.add(targetItem); } targetObject = coll; } else { targetObject = deepObjectCopy(srcObject, targetClassName); } return targetObject; } /** * * @param srcObject * @param targetClassName * @return */ private static Object deepObjectCopy(Object srcObject, String targetClassName) { Class<?> targetClass = null; Object targetObject = null; try { targetClass = Class.forName(targetClassName); targetObject = targetClass.newInstance(); PropertyUtils.copyProperties(targetObject, srcObject); } catch (Exception e) { log.warn(e.getMessage(), e); } return targetObject; } /** * 需要重构,简单的基本类型进行拷贝 * @param srcObject * @param targetClassName * @return */ public static Object objectPrimitiveCopy(Object srcObject, String targetClassName){ try { Object targetObject = Class.forName(targetClassName).newInstance(); return objectPrimitiveCopy(srcObject,targetObject,false); } catch (Exception e) { log.warn(e.getMessage(), e); return null; } } /** * 需要重构,简单的基本类型进行拷贝 * @param srcObject * @param targetClassName * @return */ public static Object objectPrimitiveCopy(Object srcObject, Object targetObject, boolean valueFromSrc){ Class<?> valueClass = null; if(valueFromSrc){ valueClass = srcObject.getClass(); } else{ valueClass = targetObject.getClass(); } try { Field[] fields = valueClass.getDeclaredFields(); for(Field field : fields){ Class<?> fieldType = field.getType(); //如果是基本类型,字符串,boolean、integer、long、double类型 if(fieldType.isPrimitive() || fieldType.getName().equals(String.class.getName()) || fieldType.getName().equals(Boolean.class.getName()) || fieldType.getName().equals(Integer.class.getName()) || fieldType.getName().equals(Long.class.getName()) || fieldType.getName().equals(Double.class.getName()) ){ String property = field.getName(); Object value = getMethodValue(property,srcObject); setMethodValue(property,targetObject,value); } } } catch (Exception e) { log.warn(e.getMessage(), e); } return targetObject; } public static String strArroStringSQL(String[] strArr) { if (strArr == null || strArr.length == 0) return ""; StringBuffer sb = new StringBuffer(); for (int i = 0; i < strArr.length; i++) { sb.append("'" + strArr[i] + "',"); } String returnValue = sb.toString(); returnValue = returnValue.substring(0, returnValue.length() - 1); return returnValue; } public static boolean isHaveProperty(String property, Class<?> objClass) { Field[] fields = objClass.getDeclaredFields(); boolean flag = false; for (int j = 0; j < fields.length; j++) { if (fields[j].getName().equals(property)) { flag = true; break; } } return flag; } @SuppressWarnings("unchecked") public static void setMethodValue(String property, Object object, Object propertyValue) { String firstChar = property.substring(0, 1); String leaveChar = property.substring(1); String methodName = firstChar.toUpperCase() + leaveChar; //add by zhouxushun 2011-11-22 to support map if(object instanceof Map){ Map<String, Object> objMap = (Map<String, Object>)object; objMap.put(property, propertyValue); return; } //end try { Method meth = null; Class<?> fieldType = null; //Method method = object.getClass().getDeclaredMethod("get" + methodName,null); Method method = getAllMethod("get" + methodName, object.getClass()); if(method != null){ fieldType = method.getReturnType(); } else{ fieldType = object.getClass().getDeclaredField(property).getType(); } if(fieldType != null){ if(propertyValue == null){ return; } //如果为基本类型 if(fieldType.isPrimitive()){ if(propertyValue instanceof Boolean){ meth = object.getClass().getMethod("set" + methodName, Boolean.TYPE); } else if(propertyValue instanceof Integer){ meth = object.getClass().getMethod("set" + methodName, Integer.TYPE); } else if(propertyValue instanceof Long){ meth = object.getClass().getMethod("set" + methodName, Long.TYPE); } else if(propertyValue instanceof Double){ meth = object.getClass().getMethod("set" + methodName, Double.TYPE); } } else{ meth = object.getClass().getMethod("set" + methodName, propertyValue.getClass()); } if(meth != null){ meth.invoke(object, propertyValue); } } } catch (Exception ex) { ex.printStackTrace(); } } public static void setMethodValueForRecursion(String property, Object object, Object value) { if (property == null || object == null) { return; } if (property.indexOf(".") == -1) { setMethodValue(property, object,value); } else { String theFirstProperty = property.substring(0, property.indexOf(".")); String theSecondProperty = property.substring(property.indexOf(".") + 1); Object firstObj = getMethodValue(theFirstProperty, object); setMethodValueForRecursion(theSecondProperty, firstObj, value); } } protected static Method getAllMethod(String methodName, Class<?> clazz){ if(clazz==null){ return null; } try{ //Method method = object.getClass().getDeclaredMethod("get" + methodName, Null.class); Method method = clazz.getDeclaredMethod(methodName, new Class[]{}); return method; } catch(Exception e){ return getAllMethod(methodName, clazz.getSuperclass()); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ObjectUtils.java
Java
asf20
11,619
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午03:24:25 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.util; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.net.URLEncoder; import org.apache.commons.codec.DecoderException; import org.apache.commons.codec.binary.Base64; import org.apache.commons.codec.binary.Hex; import org.apache.commons.lang.StringEscapeUtils; /** * 各种格式的编码加码工具类. * * 集成Commons-Codec,Commons-Lang及JDK提供的编解码方法. * */ public class EncodeUtils { public static final String DEFAULT_CHARSET_NAME = "UTF-8"; public static final String GBK_CHARSET_NAME = "GBK"; /** * Hex编码. */ public static String hexEncode(byte[] input) { return Hex.encodeHexString(input); } /** * Hex解码. */ public static byte[] hexDecode(String input) { try { return Hex.decodeHex(input.toCharArray()); } catch (DecoderException e) { throw new IllegalStateException("Hex Decoder exception", e); } } /** * Base64编码. */ public static String base64Encode(byte[] input) { return new String(Base64.encodeBase64(input)); } /** * Base64编码, URL安全(将Base64中的URL非法字符如+,/=转为其他字符, 见RFC3548). */ public static String base64UrlSafeEncode(byte[] input) { return Base64.encodeBase64URLSafeString(input); } /** * Base64解码. */ public static byte[] base64Decode(String input) { return Base64.decodeBase64(input); } /** * URL 编码, Encode默认为UTF-8. */ public static String urlEncode(String input) { return urlEncode(input, DEFAULT_CHARSET_NAME); } /** * URL 编码. */ public static String urlEncode(String input, String encoding) { try { return URLEncoder.encode(input, encoding); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("Unsupported Encoding Exception", e); } } /** * URL 解码, Encode默认为UTF-8. */ public static String urlDecode(String input) { return urlDecode(input, DEFAULT_CHARSET_NAME); } /** * URL 解码. */ public static String urlDecode(String input, String encoding) { try { return URLDecoder.decode(input, encoding); } catch (UnsupportedEncodingException e) { throw new IllegalArgumentException("Unsupported Encoding Exception", e); } } /** * Html 转码. */ public static String htmlEscape(String html) { return StringEscapeUtils.escapeHtml(html); } /** * Html 解码. */ public static String htmlUnescape(String htmlEscaped) { return StringEscapeUtils.unescapeHtml(htmlEscaped); } /** * Xml 转码. */ public static String xmlEscape(String xml) { return StringEscapeUtils.escapeXml(xml); } /** * Xml 解码. */ public static String xmlUnescape(String xmlEscaped) { return StringEscapeUtils.unescapeXml(xmlEscaped); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/EncodeUtils.java
Java
asf20
3,677
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-10-25 下午7:47:19 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-10-25 Initailized */ package com.zz.bsp.util; import com.zz.bsp.constants.Constants; /** * StringUtils的扩展工具类 * */ public class StringExUtils { /** * 字符串填充 * @param src * @param fix * @param finalSize * @return */ public static String postfixStrWith(String src, String fix, int finalSize) { src = (src == null) ? "" : src; StringBuffer result = produceFix(src, fix, finalSize); return src + result.toString(); } /** * 空白填充 * @param src * @param finalSize * @return */ public static String postfixStrWithBlank(String src, int finalSize) { return postfixStrWith(src, " ", finalSize); } /** * 前缀填充 * @param src 源字符串 * @param fix 填充时加入的字符 * @param finalSize 字符最终长度 * @return String 填充后的字符 */ public static String prefixStrWith(String src, String fix, int finalSize) { src = (src == null) ? "" : src; StringBuffer result = produceFix(src, fix, finalSize); return result.toString() + src; } public static String varLenWithValue(String val, int len, String charset){ StringBuilder sb = new StringBuilder(); int valLen = 0; if(val == null){ val = ""; } try{ valLen = val.getBytes(charset).length; } catch(Exception e){ valLen = val.getBytes().length; } String valLenStr = String.valueOf(valLen); int valLenStrLen = valLenStr.getBytes().length; int diff = len - valLenStrLen; for(int i = 0; i < diff; i++){ sb.append("0"); } sb.append(valLenStr); sb.append(val); return sb.toString(); } public static String stringToCertCharset(String str, String charset){ try{ return new String(str.getBytes(), charset); } catch(Exception e){ return str; } } public static String byteToCertCharset(byte [] bytes, String charset){ try{ return new String(bytes, charset); } catch(Exception e){ return new String(); } } /** * 前缀填充 * @param src 源字符串 * @param fix 填充时加入的字符 * @param finalSize 字符最终长度 * @return String 填充后的字符 */ private static StringBuffer produceFix(String src, String fix, int finalSize) { try{ AssertUtils.isTrue(src.getBytes(Constants.DEFAULT_PROTOCOL_CHARSET_NAME).length <= finalSize, "src.length() should <= finalSize, but not!"); StringBuffer result = new StringBuffer(); for (int i = 0; i < finalSize - src.getBytes(Constants.DEFAULT_PROTOCOL_CHARSET_NAME).length; i++) { result.append(fix); } return result; } catch(Exception e){ throw new IllegalArgumentException(e); } } public static void main(String [] arg){ System.out.println(varLenWithValue("你好",2,Constants.DEFAULT_PROTOCOL_CHARSET_NAME)); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/StringExUtils.java
Java
asf20
3,572
package com.zz.bsp.util; import java.beans.BeanInfo; import java.beans.Introspector; import java.beans.PropertyDescriptor; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import net.sf.json.JSONArray; import net.sf.json.JSONObject; import net.sf.json.JsonConfig; import net.sf.json.processors.JsonValueProcessor; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Json工具类 * */ public class JsonUtils { public static final Log log = LogFactory.getLog(JsonUtils.class); public static List<?> jsonToList(String json, Class<?> clazz) { JSONArray jsonArray = JSONArray.fromObject(json); List<Object> list = new ArrayList<Object>(); int iSize = jsonArray.size(); for (int i = 0; i < iSize; i++) { JSONObject jsonObj = jsonArray.getJSONObject(i); Object obj = JSONObject.toBean(jsonObj, clazz); list.add(obj); } return list; } public static Object jsonToObject(String json, Class<?> clazz) { JSONObject jsonObject = JSONObject.fromObject(json); return JSONObject.toBean(jsonObject, clazz); } public static String objectToJson(Object object) { String jsonString = null; // 日期值处理器 JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Date.class, new JsonValueProcessor() { private final String format = "yyyy-MM-dd HH:mm:ss"; public Object processArrayValue(Object value, JsonConfig jsonConfig) { return process(value, jsonConfig); } public Object processObjectValue(String key, Object value, JsonConfig jsonConfig) { return process(value, jsonConfig); } private Object process(Object value, JsonConfig jsonConfig) { if (value instanceof Date) { String str = new SimpleDateFormat(format).format((Date) value); return str; } return value == null ? null : value.toString(); } }); if (object != null) { if (object instanceof Collection<?> || object instanceof Object[]) { jsonString = JSONArray.fromObject(object, jsonConfig).toString(); } else { jsonString = JSONObject.fromObject(object, jsonConfig).toString(); } } return jsonString == null ? "{}" : jsonString; } /** * 将Map转为bean对象 * * @param obj * @param map * @return * @throws Exception */ @SuppressWarnings("rawtypes") public static Object mapToBean(Class clazz, Map<String, String> map) { try { BeanInfo beanInfo = Introspector.getBeanInfo(clazz); // 获取类属性 Object obj = clazz.newInstance(); // 创建 JavaBean 对象 // 给 JavaBean 对象的属性赋值 PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); for (int i = 0; i < propertyDescriptors.length; i++) { PropertyDescriptor descriptor = propertyDescriptors[i]; String propertyName = descriptor.getName(); if (map.containsKey(propertyName)) { // 下面一句可以 try 起来,这样当一个属性赋值失败的时候就不会影响其他属性赋值。 Object value = map.get(propertyName); Object[] args = new Object[1]; args[0] = value; descriptor.getWriteMethod().invoke(obj, args); } } return obj; } catch (Exception e) { log.debug("map trans to bean error", e); } return null; } @SuppressWarnings("unchecked") public static Map<String, String> toMap(JSONObject jsonObject) { Map<String, String> result = new HashMap<String, String>(); Iterator<String> iterator = jsonObject.keys(); String key = null; String value = null; while (iterator.hasNext()) { key = iterator.next(); value = jsonObject.getString(key); result.put(key, value); } return result; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/JsonUtils.java
Java
asf20
4,874
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-22 下午10:19:23 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-22 Initailized */ package com.zz.bsp.util; import java.util.List; import org.apache.ibatis.session.RowBounds; import com.zz.bsp.orm.query.OecsCriterion; import com.zz.bsp.orm.query.Page; import com.zz.bsp.orm.query.PropertyFilter; /** * OecsCriterion 工具类 * */ public class OecsCriterionUtils { private OecsCriterionUtils(){ } public static OecsCriterion createOecsCriterion(Page<?> page, List<PropertyFilter> filters){ OecsCriterion criterion = new OecsCriterion(); //设置排序参数 if(page.isOrderBySetted()){ criterion.setOrderBy(page.getOrderField()); criterion.setOrder(page.getOrderDirection()); } //设置查询参数 if(filters != null && filters.size() > 0){ criterion.setCriteria(filters); } return criterion; } public static OecsCriterion createOecsCriterion(Page<?> page, String sql){ OecsCriterion criterion = new OecsCriterion(); //设置排序参数 if(page.isOrderBySetted()){ criterion.setOrderBy(page.getOrderField()); criterion.setOrder(page.getOrderDirection()); } //设置查询参数 if(sql != null && sql !=""){ criterion.setCustomCriteria(sql); } return criterion; } public static RowBounds createRowBounds(Page<?> page){ RowBounds rowBounds = null; //设置分页参数 if(page.isAutoPage()){ int limit = (page.getPageNum() - 1) * page.getNumPerPage(); rowBounds = new RowBounds(limit, page.getNumPerPage()); } return rowBounds; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/OecsCriterionUtils.java
Java
asf20
2,087
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-utility-trunk * $Id$ * $Revision$ * Last Changed by jason at 2011-9-13 下午4:53:38 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2011-9-13 Initailized */ package com.zz.bsp.util; import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContextAware; /** * 以静态变量保存Spring ApplicationContext, * 可在任何代码任何地方任何时候中取出ApplicaitonContext. * */ public class SpringContextUtils implements ApplicationContextAware { private static ApplicationContext applicationContext; /** * 实现ApplicationContextAware接口的context注入函数, 将其存入静态变量. */ public void setApplicationContext(ApplicationContext applicationContext) { SpringContextUtils.applicationContext = applicationContext; //NOSONAR } public static void init(ApplicationContext applicationContext){ SpringContextUtils.applicationContext = applicationContext; } /** * 取得存储在静态变量中的ApplicationContext. */ public static ApplicationContext getApplicationContext() { checkApplicationContext(); return applicationContext; } /** * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型. */ @SuppressWarnings("unchecked") public static <T> T getBean(String name) { checkApplicationContext(); return (T) applicationContext.getBean(name); } /** * 从静态变量ApplicationContext中取得Bean, 自动转型为所赋值对象的类型. * 如果有多个Bean符合Class, 取出第一个. */ public static <T> T getBean(Class<T> requiredType) { checkApplicationContext(); return applicationContext.getBean(requiredType); } /** * 清除applicationContext静态变量. */ public static void cleanApplicationContext() { applicationContext = null; } private static void checkApplicationContext() { if (applicationContext == null) { throw new IllegalStateException("applicaitonContext is not init!"); } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/SpringContextUtils.java
Java
asf20
2,425
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-framework-trunk * $Id$ * $Revision$ * Last Changed by jason at 2012-4-18 下午1:04:13 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * jason 2012-4-18 Initailized */ package com.zz.bsp.util; import java.lang.reflect.AccessibleObject; import java.lang.reflect.Field; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import com.zz.bsp.web.annotation.ReqMapping; /** * 请求对象转换工具类 * */ public class ReqMappingUtils { protected static final Log log = LogFactory.getLog(ReqMappingUtils.class); private ReqMappingUtils(){ } public static void paramToObject(Object obj, HttpServletRequest request){ if(obj == null || request == null){ log.debug("obj or request is null"); return; } try{ List<?> fields = getRelativeFields(obj.getClass()); for (Object o : fields) { Field field = (Field) o; log.debug("field ->" + field.getName()); ReqMapping annotation = field.getAnnotation(ReqMapping.class); String paramName = annotation.paramName(); if(StringUtils.isBlank(paramName)){ paramName = field.getName(); } log.debug("paramName ->" + paramName); if(annotation.mutilFlag()){ String [] values = request.getParameterValues(paramName); log.debug("mutil values ->" + values); field.set(obj, values); } else{ String value = request.getParameter(paramName); log.debug("value ->" + value); field.set(obj, value); } } } catch(Exception e){ log.warn(e.getMessage(), e); } } public static Object paramToObject(Class<?> clazz, HttpServletRequest request){ Object targetObject = null; try { targetObject = clazz.newInstance(); paramToObject(targetObject, request); } catch (Exception e) { log.warn(e.getMessage(), e); } return targetObject; } public static String objectToParam(Object obj){ if(obj == null){ log.debug("obj or request is null"); return ""; } StringBuilder sb = new StringBuilder(); try{ List<?> fields = getRelativeFields(obj.getClass()); for (Object o : fields) { Field field = (Field) o; log.debug("field ->" + field.getName()); ReqMapping annotation = field.getAnnotation(ReqMapping.class); String paramName = annotation.paramName(); if(StringUtils.isBlank(paramName)){ paramName = field.getName(); } log.debug("paramName ->" + paramName); if(annotation.mutilFlag()){ String [] values = (String [])field.get(obj); log.debug("mutil values ->" + values); for(String value : values){ if(sb.length() > 0){ sb.append("&"); } sb.append(paramName + "=" + value); } } else{ String value = (String)field.get(obj); log.debug("value ->" + value); if(sb.length() > 0){ sb.append("&"); } sb.append(paramName + "=" + value); } } } catch(Exception e){ log.warn(e.getMessage(), e); } return sb.toString(); } protected static List<?> getRelativeFields(Class<?> clazz) { Field[] fields = clazz.getDeclaredFields(); List<Field> result = new ArrayList<Field>(); for (Field field : fields) { if (field.isAnnotationPresent(ReqMapping.class)) { ((AccessibleObject) field).setAccessible(true); result.add(field); } } return result; } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ReqMappingUtils.java
Java
asf20
4,836
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-3 下午05:17:28 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * ZhouXushun 2011-8-3 Initailized */ package com.zz.bsp.util; import java.lang.reflect.Method; import java.net.URL; import java.net.URLClassLoader; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 类加载器的帮助类 * */ public class ClassLoaderUtils { protected static Log log = LogFactory.getLog(ClassLoaderUtils.class); private ClassLoaderUtils() { } public static void addURL(String url, ClassLoader classLoader) { log.debug("addURL(),url->" + url); if (StringUtils.isBlank(url)) { return; } ClassLoader threadContextClassLoader = classLoader; if (threadContextClassLoader == null) { threadContextClassLoader = Thread.currentThread().getContextClassLoader(); } boolean is = threadContextClassLoader instanceof URLClassLoader; if (is) { try { URL realUrl = new URL(url); URLClassLoader curr = (URLClassLoader) threadContextClassLoader; Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class }); add.setAccessible(true); add.invoke(curr, new Object[] { realUrl }); } catch (Exception e) { log.warn("WARN", e); throw new IllegalArgumentException(e); } } else { log.warn("the classloader is not a URLClassLoader type!"); throw new IllegalArgumentException("the classloader is not a URLClassLoader type!"); } } public static ClassLoader getDefaultClassLoader() { ClassLoader cl = null; try { cl = Thread.currentThread().getContextClassLoader(); } catch (Throwable e) { log.info("INFO", e); } if (cl == null) { cl = ClassLoaderUtils.class.getClassLoader(); } return cl; } public static void removeURL(String url, ClassLoader classLoader){ //TODO 等待实现,从classloader中删除某个url } public static void removeURL(String [] urls, ClassLoader classLoader){ if(urls != null && urls.length > 0 && classLoader != null){ for(String url : urls){ removeURL(url, classLoader); } } } public static void removeURL(List<String> urlList, ClassLoader classLoader){ if(urlList != null && urlList.size() > 0 && classLoader != null){ for(String url : urlList){ removeURL(url, classLoader); } } } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/ClassLoaderUtils.java
Java
asf20
3,143
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-common-utility-trunk * $Id$ * $Revision$ * Last Changed by ZhouXushun at 2011-8-4 下午02:56:15 * $URL$ * * Change Log * Author Change Date Comments * ------------------------------------------------------------- * ZhouXushun 2011-8-4 Initailized */ package com.zz.bsp.util; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * 日期时间帮助类 * */ public class DateTimeUtils { private static final Log log = LogFactory.getLog(DateTimeUtils.class); // 默认的时间格式 public static final String DEFUALT_SHOT_TIME_FORMAT = "yyyy-MM-dd"; public static final String SHOT_DATE_FORMAT = "yyyyMMdd"; public static final String DEFUALT_LONG_TIME_FORMAT = "yyyy-MM-dd HH:mm:ss"; public static final String LONG_TIME_FORMAT = "HH:mm:ss"; public static final String SHOT_TIME_FORMAT = "HHmmss"; private DateTimeUtils() { } /** * 清除小时分钟和秒 */ public static Date clearHourMiniteSecond(Date date) { if (date == null) { return null; } Calendar gc = GregorianCalendar.getInstance(); gc.clear(); gc.setTime(date); gc.set(Calendar.HOUR_OF_DAY, 0); gc.set(Calendar.MINUTE, 0); gc.set(Calendar.SECOND, 0); gc.set(Calendar.MILLISECOND, 0); return gc.getTime(); } /** * 按照指定格式返回当前时间,如果格式为空,则默认为yyyy-MM-dd * * @param dateFormat * @return */ public static String getCurrentDateToString(String dateFormat) { if (StringUtils.isBlank(dateFormat)) { dateFormat = DEFUALT_SHOT_TIME_FORMAT; } SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(getCurrentDate()); } /** * 按照指定格式返回当前时间,如果格式为空,则默认为yyyy-MM-dd * * @param dateFormat * @return */ public static Date stringFormatToDate(String date, String dateFormat) { if (date == null) { return null; } if (StringUtils.isBlank(dateFormat)) { if (date.length() > 10) { dateFormat = DEFUALT_LONG_TIME_FORMAT; } else { dateFormat = DEFUALT_SHOT_TIME_FORMAT; } } try { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.parse(date); } catch (Exception e) { log.info("INFO", e); return null; } } /** * 格式化日期输出,如果格式为空,则默认为yyyy-MM-dd * * @param date * @param dateFormat * @return */ public static String dateToStringFormat(Date date, String dateFormat) { if (date == null) { return ""; } if (StringUtils.isBlank(dateFormat)) { dateFormat = DEFUALT_SHOT_TIME_FORMAT; } try { SimpleDateFormat sdf = new SimpleDateFormat(dateFormat); return sdf.format(date); } catch (Exception e) { log.info("INFO", e); return null; } } /** * 得到当前时间 * * @return */ public static Date getCurrentDate() { return new Date(); } /** * 比较两个时间的间隔,单位为毫秒 * * @param endDate * @param startDate * @return */ public static int diffTwoDateWithTime(Date endDate, Date startDate) { if (startDate == null || endDate == null) { return -1; } int diff = (int) (endDate.getTime() - startDate.getTime()); return diff; } /** * 比较两个时间的间隔,单位为小时 * * @param startDate * @param endDate * @return */ public static int diffTwoDateWithHour(Date startDate, Date endDate) { return (int) ((endDate.getTime() - startDate.getTime()) / (60 * 60 * 1000) + 1); } /** * 时间增加一天Calendar的使用 * @param s * @param n * @return */ public static String addDate(String s, int n) { try { SimpleDateFormat sdf = new SimpleDateFormat(SHOT_DATE_FORMAT); Calendar cd = Calendar.getInstance(); cd.setTime(sdf.parse(s)); cd.add(Calendar.DATE, n);// 增加一天 // cd.add(Calendar.MONTH, n);//增加一个月 return sdf.format(cd.getTime()); } catch (Exception e) { log.info("INFO", e); return null; } } /** * 日期处理 * @param srcDate 原日期 * @param days 增加的天数 * @param minutes 增加的分钟数 * @param seconds 增加的秒数 * @return */ public static Date addDate(Date srcDate, int days, int minutes, int seconds){ Calendar c = Calendar.getInstance(); c.setTime(srcDate); if(days != 0){ c.add(Calendar.DATE, days); } if(minutes != 0){ c.add(Calendar.MINUTE, minutes); } if(seconds != 0){ c.add(Calendar.SECOND, seconds); } return c.getTime(); } public static void main(String[] args) { System.out.println(DateTimeUtils.stringFormatToDate("20131121100521", "yyyyMMddHHmmss")); Date srcDate = new Date(); System.out.println(DateTimeUtils.dateToStringFormat(srcDate, DEFUALT_LONG_TIME_FORMAT)); System.out.println(DateTimeUtils.dateToStringFormat(DateTimeUtils.addDate(srcDate, 1, 0, 0), DEFUALT_LONG_TIME_FORMAT)); System.out.println(DateTimeUtils.dateToStringFormat(DateTimeUtils.addDate(srcDate, 1, 1, 0), DEFUALT_LONG_TIME_FORMAT)); System.out.println(DateTimeUtils.dateToStringFormat(DateTimeUtils.addDate(srcDate, 1, 1, 1), DEFUALT_LONG_TIME_FORMAT)); System.out.println(DateTimeUtils.dateToStringFormat(srcDate, DEFUALT_LONG_TIME_FORMAT)); System.out.println(DateTimeUtils.dateToStringFormat(DateTimeUtils.addDate(srcDate, 0, 1440, 0), DEFUALT_LONG_TIME_FORMAT)); } }
zz-ms
trunk/zz-ms-v2.0/src/main/java/com/zz/bsp/util/DateTimeUtils.java
Java
asf20
6,852
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-uams-admin-trunk * $Id$ * $Revision$ * Last Changed by shitz at 2011-9-13 上午11:00:03 * $URL$ * * Change Log * Author Change Date Comments * ------------------------------------------------------------- * shitz 2011-9-13 Initailized */ package com.zz.test.web.action.user; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.zz.bsp.core.GridViewDto; import com.zz.bsp.orm.query.Page; import com.zz.bsp.orm.query.PropertyFilter; import com.zz.bsp.util.JsonUtils; import com.zz.bsp.util.PropertyFilterUtils; import com.zz.bsp.web.action.BaseMultiActionController; import com.zz.test.model.user.UserModel; import com.zz.test.service.user.UserService; /** * 备付金账户余额勾兑Controller * */ @Controller @RequestMapping("/user") public class UserController extends BaseMultiActionController { @Autowired UserService userService; /** * 分页查询资金划拨 * * @param request * @param response * @param page * @return */ @RequestMapping("/page.html") public ModelAndView page(HttpServletRequest request, HttpServletResponse response) { log.debug("page method begin..."); return new ModelAndView("user/page"); } /** * 分页查询资金划拨 * * @param request * @param response * @param page * @return */ @RequestMapping("/list.html") public ModelAndView list(HttpServletRequest request, HttpServletResponse response, Page<UserModel> page) { log.debug("list method begin..."); System.out.println("-----" + request.getParameterMap()); List<PropertyFilter> filters = PropertyFilterUtils.buildMutilPropertyFilters(request); System.out.println("-----" + filters); page = userService.search(page, filters); log.debug("list method end."); GridViewDto<UserModel> dto = new GridViewDto<UserModel>(); dto.setRows(page.getResult()); dto.setTotal(page.getTotalCount()); ModelAndView mv = new ModelAndView("user/list", "dto", JsonUtils.objectToJson(dto)); return mv; } /** * 显示资金划拨详细信息 * * @param request * @param response * @param model * @return */ @RequestMapping("/view.html") public ModelAndView view(HttpServletRequest request, HttpServletResponse response) { ModelAndView mv = new ModelAndView("user/view"); Long id = Long.parseLong(request.getParameter("id")); UserModel model = userService.get(id); mv.addObject("model", model); return mv; } /** * 资金划拨勾兑 (权限判断) * * @param request * @param response * @param model * @return */ @RequestMapping("/edit.html") public ModelAndView edit(HttpServletRequest request, HttpServletResponse response, UserModel model) { log.debug("edit method begin, id->" + model.getId()); String id = request.getParameter("id"); ModelAndView mv = new ModelAndView("user/edit"); if (id != null) { model = userService.get(new Long(id)); mv.addObject("model", model); } else { mv.addObject("model", new UserModel()); } return mv; } /** * 保存或更新 * * @param request * @param response * @param model * 资金划拨 * @return */ @RequestMapping("/save.html") public ModelAndView save(HttpServletRequest request, HttpServletResponse response, UserModel model) { log.debug("save method begin..."); ModelAndView mv = new ModelAndView("user/save", "result", true); String id = request.getParameter("id"); log.debug("model --->" + model); if(StringUtils.isBlank(id) || "0".equals(id)) { userService.save(model); } else { userService.update(model); } log.debug("saveOrUpdate method end."); return mv; } /** * 根据操作员id或ids取消备付金账户信息 * * @param request * @param response * @return */ @RequestMapping("/del.html") public ModelAndView del(HttpServletRequest request, HttpServletResponse response) { log.debug("del method begin..."); String id = getModelId(request); ModelAndView mv = new ModelAndView("user/result", "result", true); if(StringUtils.isNotBlank(id)) { userService.delete(Long.parseLong(id)); } log.debug("del method end."); return mv; } /** * 分页查询资金划拨 * * @param request * @param response * @param page * @return */ @RequestMapping("/search.html") public ModelAndView search(HttpServletRequest request, HttpServletResponse response) { log.debug("page method begin..."); return new ModelAndView("user/search"); } }
zz-ms
trunk/zz-ms-v2.0/src/test/java/com/zz/test/web/action/user/UserController.java
Java
asf20
5,660
package com.zz.test.web.action; import java.util.ArrayList; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.servlet.ModelAndView; import com.zz.bsp.core.UiMenu; import com.zz.bsp.orm.query.PropertyFilter; import com.zz.bsp.util.JsonUtils; import com.zz.bsp.web.action.BaseMultiActionController; import com.zz.test.model.user.UserModel; import com.zz.test.service.user.UserService; @Controller public class IndexController extends BaseMultiActionController{ @Autowired UserService userService; @RequestMapping("/index.html") public ModelAndView index(HttpServletRequest request, HttpServletResponse response){ log.debug("index begin..."); ModelAndView mv = new ModelAndView("index"); return mv; } @RequestMapping("/login.html") public ModelAndView login(HttpServletRequest request, HttpServletResponse response, UserModel userModel){ log.debug("login begin..."); boolean isOk = false; PropertyFilter filter = new PropertyFilter("EQS_USER_NAME", userModel.getUserName()); List<PropertyFilter> filterList = new ArrayList<PropertyFilter>(1); filterList.add(filter); List<UserModel> userList = userService.search(filterList); if(userList != null && userList.size() > 0) { log.info("find user :" + userModel.getUserName()); UserModel dbUser = userList.get(0); if(userModel.getUserPwd().equalsIgnoreCase(dbUser.getUserPwd())) { log.debug("login ok ~~~~"); isOk = true; } else { log.debug("login fail req pwd ->" + userModel.getUserPwd()); } } return new ModelAndView("login", "result", isOk); } //获取菜单 @RequestMapping("/menu.html") public ModelAndView menu(HttpServletRequest request, HttpServletResponse response, String menuCode){ log.debug("menu begin, menu code : " +menuCode); List<UiMenu> menuList = new ArrayList<UiMenu>(1); UiMenu uiMenu = new UiMenu(); uiMenu.setIconCls("icon-sys"); uiMenu.setId("1"); uiMenu.setName("我的菜单"); uiMenu.setPid("0"); uiMenu.setUrl("javascript:void(0);"); menuList.add(uiMenu); UiMenu uiMenu2 = new UiMenu(); uiMenu2.setIconCls("icon-sys"); uiMenu2.setId("2"); uiMenu2.setName("空菜单"); uiMenu2.setPid("0"); uiMenu2.setUrl("javascript:void(0);"); menuList.add(uiMenu2); List<UiMenu> subList = new ArrayList<UiMenu>(1); UiMenu subUiMenu = new UiMenu(); subUiMenu.setIconCls("icon-adds"); subUiMenu.setId("11"); subUiMenu.setName("用户管理"); subUiMenu.setPid("1"); subUiMenu.setUrl(request.getContextPath() + "/user/page.html"); subList.add(subUiMenu); uiMenu.setChild(subList); ModelAndView mv = new ModelAndView("menu", "uiMenu", JsonUtils.objectToJson(menuList)); return mv; } }
zz-ms
trunk/zz-ms-v2.0/src/test/java/com/zz/test/web/action/IndexController.java
Java
asf20
3,453
/** * Copyright : http://www.orientpay.com , 2007-2012 * Project : oecs-g2-component-trunk * $Id$ * $Revision$ * Last Changed by qinxiang at 2011-9-18 下午6:58:27 * $URL$ * * Change Log * Author Change Date Comments *------------------------------------------------------------- * qinxiang 2011-9-18 Initailized */ package com.zz.test.service.user; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.zz.bsp.dao.Dao; import com.zz.bsp.service.DefaultEntityService; import com.zz.test.dao.user.UserDao; import com.zz.test.model.user.UserModel; /** * 登帐记录Service * */ @Service("userService") @Transactional(timeout=10) public class UserService extends DefaultEntityService<UserModel, Long>{ @Autowired UserDao userDao; protected Dao<UserModel, Long> getDao() { return userDao; } }
zz-ms
trunk/zz-ms-v2.0/src/test/java/com/zz/test/service/user/UserService.java
Java
asf20
1,031
package com.zz.test.dao.user; import com.zz.bsp.dao.Dao; import com.zz.bsp.dao.OecsMapper; import com.zz.test.model.user.UserModel; @OecsMapper public interface UserDao extends Dao<UserModel, Long>{ }
zz-ms
trunk/zz-ms-v2.0/src/test/java/com/zz/test/dao/user/UserDao.java
Java
asf20
216
package com.zz.test.model.user; import java.io.Serializable; import com.zz.bsp.core.Model; public class UserModel extends Model { private static final long serialVersionUID = -826093286526668144L; private Long id; private String userName; private String userPwd; @Override public Serializable getPK() { return id; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getUserName() { return userName; } public void setUserName(String userName) { entityMap.put("userName", userName); this.userName = userName; } public String getUserPwd() { return userPwd; } public void setUserPwd(String userPwd) { entityMap.put("userPwd", userPwd); this.userPwd = userPwd; } @Override public String toString() { return "UserModel [id=" + id + ", userName=" + userName + ", userPwd=" + userPwd + "]"; } }
zz-ms
trunk/zz-ms-v2.0/src/test/java/com/zz/test/model/user/UserModel.java
Java
asf20
941
package com.jzzms.bsp.service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.OperatorMapper; import com.jzzms.bsp.model.Operator; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; /** * 操作员Service * */ @Service @Transactional public class OperatorService extends DefaultEntityService<Operator, Long>{ @Autowired OperatorMapper operatorMapper; protected Dao<Operator, Long> getDao() { return operatorMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/OperatorService.java
Java
asf20
682
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.EmployeeOrgMapper; import com.jzzms.bsp.model.urss.EmployeeOrg; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class EmployeeOrgService extends DefaultEntityService<EmployeeOrg, Integer> { @Autowired EmployeeOrgMapper employeeOrgMapper; @Override protected Dao<EmployeeOrg, Integer> getDao() { return employeeOrgMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/EmployeeOrgService.java
Java
asf20
682
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.EmployeeMapper; import com.jzzms.bsp.model.urss.Employee; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class EmployeeService extends DefaultEntityService<Employee, Integer> { @Autowired EmployeeMapper employeeMapper; @Override protected Dao<Employee, Integer> getDao() { return employeeMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/EmployeeService.java
Java
asf20
655
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.RoleMapper; import com.jzzms.bsp.model.urss.Role; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class RoleService extends DefaultEntityService<Role, Integer>{ @Autowired RoleMapper roleMapper; @Override protected Dao<Role, Integer> getDao() { return roleMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/RoleService.java
Java
asf20
655
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.ResourceMapper; import com.jzzms.bsp.model.urss.Resource; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class ResourceService extends DefaultEntityService<Resource, Integer> { @Autowired ResourceMapper resourceMapper; @Override protected Dao<Resource, Integer> getDao() { return resourceMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/ResourceService.java
Java
asf20
655
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.FunctionMapper; import com.jzzms.bsp.model.urss.Function; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class FunctionService extends DefaultEntityService<Function, Integer> { @Autowired FunctionMapper functionMapper; @Override protected Dao<Function, Integer> getDao() { return functionMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/FunctionService.java
Java
asf20
655
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.OrgDetailMapper; import com.jzzms.bsp.model.urss.OrgDetail; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class OrgDetailService extends DefaultEntityService<OrgDetail, Integer> { @Autowired OrgDetailMapper orgDetailMapper; @Override protected Dao<OrgDetail, Integer> getDao() { return orgDetailMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/OrgDetailService.java
Java
asf20
663
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.OrgTreeMapper; import com.jzzms.bsp.model.urss.OrgTree; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class OrgTreeService extends DefaultEntityService<OrgTree, Integer> { @Autowired OrgTreeMapper orgTreeMapper; @Override protected Dao<OrgTree, Integer> getDao() { return orgTreeMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/OrgTreeService.java
Java
asf20
647
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.UserRoleMapper; import com.jzzms.bsp.model.urss.UserRole; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class UserRoleService extends DefaultEntityService<UserRole, Integer> { @Autowired UserRoleMapper userRoleMapper; @Override protected Dao<UserRole, Integer> getDao() { return userRoleMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/UserRoleService.java
Java
asf20
655
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.ConfigMapper; import com.jzzms.bsp.model.urss.Config; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class ConfigService extends DefaultEntityService<Config, String> { @Autowired ConfigMapper configMapper; @Override protected Dao<Config, String> getDao() { return configMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/ConfigService.java
Java
asf20
637
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.PermissionMapper; import com.jzzms.bsp.model.urss.Permission; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class PermissionService extends DefaultEntityService<Permission, Integer> { @Autowired PermissionMapper permissionMapper; @Override protected Dao<Permission, Integer> getDao() { return permissionMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/PermissionService.java
Java
asf20
674
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.OrgTypeMapper; import com.jzzms.bsp.model.urss.OrgType; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class OrgTypeService extends DefaultEntityService<OrgType, Integer> { @Autowired OrgTypeMapper orgTypeMapper; @Override protected Dao<OrgType, Integer> getDao() { return orgTypeMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/OrgTypeService.java
Java
asf20
647
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.CompanyMapper; import com.jzzms.bsp.model.urss.Company; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class CompanyService extends DefaultEntityService<Company, Integer> { @Autowired CompanyMapper companyMapper; @Override protected Dao<Company, Integer> getDao() { return companyMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/CompanyService.java
Java
asf20
647
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.AppMapper; import com.jzzms.bsp.model.urss.App; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class AppService extends DefaultEntityService<App, Integer> { @Autowired AppMapper appMapper; @Override protected Dao<App, Integer> getDao() { return appMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/AppService.java
Java
asf20
615
package com.jzzms.bsp.service.urss; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.jzzms.bsp.dao.urss.UserMapper; import com.jzzms.bsp.model.urss.User; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.service.DefaultEntityService; @Service @Transactional public class UserService extends DefaultEntityService<User, Integer> { @Autowired UserMapper userMapper; @Override protected Dao<User, Integer> getDao() { return userMapper; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/urss/UserService.java
Java
asf20
623
package com.jzzms.bsp.service; import java.util.ArrayList; import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DataAccessException; import org.springframework.security.core.GrantedAuthority; import org.springframework.security.core.userdetails.UserDetails; import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.core.userdetails.UsernameNotFoundException; import com.jzzms.bsp.model.Operator; import com.jzzms.framework.core.UserDetailsImpl; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.service.security.GrantedAuthorityImpl; public class ZzUserDetailsSvr implements UserDetailsService { protected Log log = LogFactory.getLog(getClass()); @Autowired OperatorService operatorService; public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException { log.debug("loadUserByUsername username: " + username); List<PropertyFilter> filters = new ArrayList<PropertyFilter>(2); filters.add(new PropertyFilter("EQS_LOGIN_NAME", username)); filters.add(new PropertyFilter("EQS_STATUS", "V")); List<Operator> list = operatorService.search(filters); if(list == null || list.size() == 0){ log.warn("can not find [" + username + "]"); throw new UsernameNotFoundException("can not find [" + username + "]"); } log.debug("get a user for username :" + username); Operator oper = list.get(0); UserDetailsImpl userDetail = new UserDetailsImpl(); userDetail.setUsername(username); userDetail.setPassword(oper.getLoginPwd()); List<GrantedAuthority> grantedAuthorities = new ArrayList<GrantedAuthority>(); grantedAuthorities.add(new GrantedAuthorityImpl("ROLE_")); userDetail.setAuthorities(grantedAuthorities); return userDetail; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/service/ZzUserDetailsSvr.java
Java
asf20
2,164
package com.jzzms.bsp.view.action; import org.apache.struts2.convention.annotation.Namespace; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/bsp") public class IndexAction extends SimpleActionSupport { private static final long serialVersionUID = 4292294870924885076L; @Override public String execute() throws Exception { log.debug("execute ..."); return null; } public String menu() throws Exception { log.debug("getMenu ..."); String appCode = String.valueOf(request.get("request")); String moduleId = String.valueOf(request.get("moduleId")); log.debug("appCode : " + appCode + ", moduleId: " + moduleId); return SUCCESS; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/IndexAction.java
Java
asf20
711
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.OrgType; import com.jzzms.bsp.service.urss.OrgTypeService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "OrgType.action", type = "redirect") }) public class OrgTypeAction extends CrudActionSupport<OrgType> { private static final long serialVersionUID = 1339148106109L; @Autowired(required=false) private OrgTypeService orgTypeService; // 基本属性 private OrgType entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = orgTypeService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ orgTypeService.save(entity); } else{ orgTypeService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ orgTypeService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = orgTypeService.get(NumberUtils.StringToInteger(pk)); } else { entity = new OrgType(); } } public OrgType getModel() { return entity; } public OrgType getEntity() { return entity; } public void setEntity(OrgType entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/OrgTypeAction.java
Java
asf20
2,404
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.EmployeeOrg; import com.jzzms.bsp.service.urss.EmployeeOrgService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "employeeOrg.action", type = "redirect") }) public class EmployeeOrgAction extends CrudActionSupport<EmployeeOrg> { private static final long serialVersionUID = 1339148105921L; @Autowired(required=false) private EmployeeOrgService employeeOrgService; // 基本属性 private EmployeeOrg entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = employeeOrgService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ employeeOrgService.save(entity); } else{ employeeOrgService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ employeeOrgService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = employeeOrgService.get(NumberUtils.StringToInteger(pk)); } else { entity = new EmployeeOrg(); } } public EmployeeOrg getModel() { return entity; } public EmployeeOrg getEntity() { return entity; } public void setEntity(EmployeeOrg entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/EmployeeOrgAction.java
Java
asf20
2,472
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Permission; import com.jzzms.bsp.service.urss.PermissionService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Permission.action", type = "redirect") }) public class PermissionAction extends CrudActionSupport<Permission> { private static final long serialVersionUID = 1339148106140L; @Autowired(required=false) private PermissionService permissionService; // 基本属性 private Permission entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = permissionService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ permissionService.save(entity); } else{ permissionService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ permissionService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = permissionService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Permission(); } } public Permission getModel() { return entity; } public Permission getEntity() { return entity; } public void setEntity(Permission entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/PermissionAction.java
Java
asf20
2,457
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Config; import com.jzzms.bsp.service.urss.ConfigService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Config.action", type = "redirect") }) public class ConfigAction extends CrudActionSupport<Config> { private static final long serialVersionUID = 1339148105812L; @Autowired(required=false) private ConfigService configService; // 基本属性 private Config entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = configService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ configService.save(entity); } else{ configService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); if(StringUtils.isNotBlank(pk)){ configService.delete(pk); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = configService.get(pk); } else { entity = new Config(); } } public Config getModel() { return entity; } public Config getEntity() { return entity; } public void setEntity(Config entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/ConfigAction.java
Java
asf20
2,183
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.User; import com.jzzms.bsp.service.urss.UserService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "User.action", type = "redirect") }) public class UserAction extends CrudActionSupport<User> { private static final long serialVersionUID = 1339148106250L; @Autowired(required=false) private UserService userService; // 基本属性 private User entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = userService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ userService.save(entity); } else{ userService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ userService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = userService.get(NumberUtils.StringToInteger(pk)); } else { entity = new User(); } } public User getModel() { return entity; } public User getEntity() { return entity; } public void setEntity(User entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/UserAction.java
Java
asf20
2,354
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Function; import com.jzzms.bsp.service.urss.FunctionService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Function.action", type = "redirect") }) public class FunctionAction extends CrudActionSupport<Function> { private static final long serialVersionUID = 1339148105984L; @Autowired(required=false) private FunctionService functionService; // 基本属性 private Function entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = functionService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ functionService.save(entity); } else{ functionService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ functionService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = functionService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Function(); } } public Function getModel() { return entity; } public Function getEntity() { return entity; } public void setEntity(Function entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/FunctionAction.java
Java
asf20
2,421
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Resource; import com.jzzms.bsp.service.urss.ResourceService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Resource.action", type = "redirect") }) public class ResourceAction extends CrudActionSupport<Resource> { private static final long serialVersionUID = 1339148106187L; @Autowired(required=false) private ResourceService resourceService; // 基本属性 private Resource entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = resourceService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ resourceService.save(entity); } else{ resourceService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ resourceService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = resourceService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Resource(); } } public Resource getModel() { return entity; } public Resource getEntity() { return entity; } public void setEntity(Resource entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/ResourceAction.java
Java
asf20
2,421
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.OrgTree; import com.jzzms.bsp.service.urss.OrgTreeService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "OrgTree.action", type = "redirect") }) public class OrgTreeAction extends CrudActionSupport<OrgTree> { private static final long serialVersionUID = 1339148106062L; @Autowired(required=false) private OrgTreeService orgTreeService; // 基本属性 private OrgTree entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = orgTreeService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ orgTreeService.save(entity); } else{ orgTreeService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ orgTreeService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = orgTreeService.get(NumberUtils.StringToInteger(pk)); } else { entity = new OrgTree(); } } public OrgTree getModel() { return entity; } public OrgTree getEntity() { return entity; } public void setEntity(OrgTree entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/OrgTreeAction.java
Java
asf20
2,403
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Company; import com.jzzms.bsp.service.urss.CompanyService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Company.action", type = "redirect") }) public class CompanyAction extends CrudActionSupport<Company> { private static final long serialVersionUID = 1339148105750L; @Autowired(required=false) private CompanyService companyService; // 基本属性 private Company entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = companyService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); if(StringUtils.isBlank(pk)){ companyService.save(entity); } else{ companyService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); if(StringUtils.isNotBlank(pk)){ companyService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = companyService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Company(); } } public Company getModel() { return entity; } public Company getEntity() { return entity; } public void setEntity(Company entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/CompanyAction.java
Java
asf20
2,212
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.OrgDetail; import com.jzzms.bsp.service.urss.OrgDetailService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "OrgDetail.action", type = "redirect") }) public class OrgDetailAction extends CrudActionSupport<OrgDetail> { private static final long serialVersionUID = 1339148106015L; @Autowired(required=false) private OrgDetailService orgDetailService; // 基本属性 private OrgDetail entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = orgDetailService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ orgDetailService.save(entity); } else{ orgDetailService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ orgDetailService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = orgDetailService.get(NumberUtils.StringToInteger(pk)); } else { entity = new OrgDetail(); } } public OrgDetail getModel() { return entity; } public OrgDetail getEntity() { return entity; } public void setEntity(OrgDetail entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/OrgDetailAction.java
Java
asf20
2,437
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Role; import com.jzzms.bsp.service.urss.RoleService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Role.action", type = "redirect") }) public class RoleAction extends CrudActionSupport<Role> { private static final long serialVersionUID = 1339148106218L; @Autowired(required=false) private RoleService roleService; // 基本属性 private Role entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = roleService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ roleService.save(entity); } else{ roleService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ roleService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = roleService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Role(); } } public Role getModel() { return entity; } public Role getEntity() { return entity; } public void setEntity(Role entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/RoleAction.java
Java
asf20
2,355
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.Employee; import com.jzzms.bsp.service.urss.EmployeeService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "Employee.action", type = "redirect") }) public class EmployeeAction extends CrudActionSupport<Employee> { private static final long serialVersionUID = 1339148105875L; @Autowired(required=false) private EmployeeService employeeService; // 基本属性 private Employee entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = employeeService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ employeeService.save(entity); } else{ employeeService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ employeeService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = employeeService.get(NumberUtils.StringToInteger(pk)); } else { entity = new Employee(); } } public Employee getModel() { return entity; } public Employee getEntity() { return entity; } public void setEntity(Employee entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/EmployeeAction.java
Java
asf20
2,422
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.App; import com.jzzms.bsp.service.urss.AppService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/bsp/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "app.action", type = "redirect") }) public class AppAction extends CrudActionSupport<App> { private static final long serialVersionUID = 1339148105687L; @Autowired private AppService appService; // 基本属性 private App entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = appService.search(getPage(), filters); return LIST; } public String save() throws Exception { log.debug("save-------------"); if(StringUtils.isBlank(pk)){ appService.save(entity); } else{ appService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); if(StringUtils.isNotBlank(pk)){ appService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = appService.get(NumberUtils.StringToInteger(pk)); } else { entity = new App(); } } public App getModel() { return entity; } public App getEntity() { return entity; } public void setEntity(App entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/AppAction.java
Java
asf20
2,127
package com.jzzms.bsp.view.action.urss; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.struts2.convention.annotation.Namespace; import org.apache.struts2.convention.annotation.Result; import org.apache.struts2.convention.annotation.Results; import org.springframework.beans.factory.annotation.Autowired; import com.jzzms.bsp.model.urss.UserRole; import com.jzzms.bsp.service.urss.UserRoleService; import com.jzzms.framework.orm.query.PropertyFilter; import com.jzzms.framework.util.common.PropertyFilterUtils; import com.jzzms.framework.util.lang.NumberUtils; import com.jzzms.framework.view.action.CrudActionSupport; import com.jzzms.framework.view.action.SimpleActionSupport; @Namespace("/urss") @Results( { @Result(name = SimpleActionSupport.RELOAD, location = "UserRole.action", type = "redirect") }) public class UserRoleAction extends CrudActionSupport<UserRole> { private static final long serialVersionUID = 1339148106281L; @Autowired(required=false) private UserRoleService userRoleService; // 基本属性 private UserRole entity; public String list() throws Exception { log.debug("list-------------"); List<PropertyFilter> filters = PropertyFilterUtils.buildPropertyFilters(request); page = userRoleService.search(getPage(), filters); return SUCCESS; } public String save() throws Exception { log.debug("save-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isBlank(pk)){ userRoleService.save(entity); } else{ userRoleService.update(entity); } return SUCCESS; } public String delete() throws Exception { log.debug("delete, pk :" + pk + "-------------"); //UserDetailsImpl oper = (UserDetailsImpl)session.get(Constants.CUR_USER_DETAIL_IN_SESSION); if(StringUtils.isNotBlank(pk)){ userRoleService.delete(NumberUtils.StringToInteger(pk)); } return SUCCESS; } protected void prepareModel() throws Exception { if (StringUtils.isNotBlank(pk)) { entity = userRoleService.get(NumberUtils.StringToInteger(pk)); } else { entity = new UserRole(); } } public UserRole getModel() { return entity; } public UserRole getEntity() { return entity; } public void setEntity(UserRole entity) { this.entity = entity; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/view/action/urss/UserRoleAction.java
Java
asf20
2,422
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Company; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface CompanyMapper extends Dao<Company, Integer>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/CompanyMapper.java
Java
asf20
245
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.User; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface UserMapper extends Dao<User, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/UserMapper.java
Java
asf20
233
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.EmployeeOrg; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface EmployeeOrgMapper extends Dao<EmployeeOrg, Integer>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/EmployeeOrgMapper.java
Java
asf20
257
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.UserRole; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface UserRoleMapper extends Dao<UserRole, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/UserRoleMapper.java
Java
asf20
245
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.OrgTree; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface OrgTreeMapper extends Dao<OrgTree, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/OrgTreeMapper.java
Java
asf20
242
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.OrgType; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface OrgTypeMapper extends Dao<OrgType, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/OrgTypeMapper.java
Java
asf20
242
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Resource; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface ResourceMapper extends Dao<Resource, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/ResourceMapper.java
Java
asf20
245
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.OrgDetail; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface OrgDetailMapper extends Dao<OrgDetail, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/OrgDetailMapper.java
Java
asf20
248
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Config; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface ConfigMapper extends Dao<Config, String>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/ConfigMapper.java
Java
asf20
241
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Function; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface FunctionMapper extends Dao<Function, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/FunctionMapper.java
Java
asf20
245
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Employee; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface EmployeeMapper extends Dao<Employee, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/EmployeeMapper.java
Java
asf20
245
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.App; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface AppMapper extends Dao<App, Integer>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/AppMapper.java
Java
asf20
233
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Permission; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface PermissionMapper extends Dao<Permission, Integer> { }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/PermissionMapper.java
Java
asf20
251
package com.jzzms.bsp.dao.urss; import com.jzzms.bsp.model.urss.Role; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface RoleMapper extends Dao<Role, Integer>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/urss/RoleMapper.java
Java
asf20
238
package com.jzzms.bsp.dao; import com.jzzms.bsp.model.Operator; import com.jzzms.framework.dao.Dao; import com.jzzms.framework.dao.ZzMsMapper; @ZzMsMapper public interface OperatorMapper extends Dao<Operator, Long>{ }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/dao/OperatorMapper.java
Java
asf20
231
package com.jzzms.bsp.model; import java.io.Serializable; import java.util.Date; import com.jzzms.framework.core.Model; public class Operator extends Model{ private static final long serialVersionUID = 2329473050715789906L; private Long id; private Long orgId; private String realName; private String loginName; private String loginPwd; private Long successTimes; private Long failTimes; private Date lastLoginTime; private Date lastLoginFailTime; private Date curLoginTime; private String lastLoginAddr; private String curLoginAddr; private String miscDesc; private String status; private Date createTime; private Long createOperId; private String createOperName; private Date updateTime; private Long updateOperId; private String updateOperName; public Long getId() { return id; } public void setId(Long id) { this.id = id; } public Long getOrgId() { return orgId; } public void setOrgId(Long orgId) { entityMap.put("orgId", orgId); this.orgId = orgId; } public String getRealName() { return realName; } public void setRealName(String realName) { entityMap.put("realName", realName); this.realName = realName; } public String getLoginName() { return loginName; } public void setLoginName(String loginName) { entityMap.put("loginName", loginName); this.loginName = loginName; } public String getLoginPwd() { return loginPwd; } public void setLoginPwd(String loginPwd) { entityMap.put("loginPwd", loginPwd); this.loginPwd = loginPwd; } public Long getSuccessTimes() { return successTimes; } public void setSuccessTimes(Long successTimes) { entityMap.put("successTimes", successTimes); this.successTimes = successTimes; } public Long getFailTimes() { return failTimes; } public void setFailTimes(Long failTimes) { entityMap.put("failTimes", failTimes); this.failTimes = failTimes; } public Date getLastLoginTime() { return lastLoginTime; } public void setLastLoginTime(Date lastLoginTime) { entityMap.put("lastLoginTime", lastLoginTime); this.lastLoginTime = lastLoginTime; } public Date getLastLoginFailTime() { return lastLoginFailTime; } public void setLastLoginFailTime(Date lastLoginFailTime) { entityMap.put("lastLoginFailTime", lastLoginFailTime); this.lastLoginFailTime = lastLoginFailTime; } public Date getCurLoginTime() { return curLoginTime; } public void setCurLoginTime(Date curLoginTime) { entityMap.put("curLoginTime", curLoginTime); this.curLoginTime = curLoginTime; } public String getLastLoginAddr() { return lastLoginAddr; } public void setLastLoginAddr(String lastLoginAddr) { entityMap.put("lastLoginAddr", lastLoginAddr); this.lastLoginAddr = lastLoginAddr; } public String getCurLoginAddr() { return curLoginAddr; } public void setCurLoginAddr(String curLoginAddr) { entityMap.put("curLoginAddr", curLoginAddr); this.curLoginAddr = curLoginAddr; } public String getMiscDesc() { return miscDesc; } public void setMiscDesc(String miscDesc) { entityMap.put("miscDesc", miscDesc); this.miscDesc = miscDesc; } public String getStatus() { return status; } public void setStatus(String status) { entityMap.put("status", status); this.status = status; } public Date getCreateTime() { return createTime; } public void setCreateTime(Date createTime) { entityMap.put("createTime", createTime); this.createTime = createTime; } public Long getCreateOperId() { return createOperId; } public void setCreateOperId(Long createOperId) { entityMap.put("createOperId", createOperId); this.createOperId = createOperId; } public String getCreateOperName() { return createOperName; } public void setCreateOperName(String createOperName) { entityMap.put("createOperName", createOperName); this.createOperName = createOperName; } public Date getUpdateTime() { return updateTime; } public void setUpdateTime(Date updateTime) { entityMap.put("updateTime", updateTime); this.updateTime = updateTime; } public Long getUpdateOperId() { return updateOperId; } public void setUpdateOperId(Long updateOperId) { entityMap.put("updateOperId", updateOperId); this.updateOperId = updateOperId; } public String getUpdateOperName() { return updateOperName; } public void setUpdateOperName(String updateOperName) { entityMap.put("updateOperName", updateOperName); this.updateOperName = updateOperName; } @Override public String toString() { return "Operator [id=" + id + ", orgId=" + orgId + ", realName=" + realName + ", loginName=" + loginName + ", loginPwd=" + loginPwd + ", successTimes=" + successTimes + ", failTimes=" + failTimes + ", lastLoginTime=" + lastLoginTime + ", lastLoginFailTime=" + lastLoginFailTime + ", curLoginTime=" + curLoginTime + ", lastLoginAddr=" + lastLoginAddr + ", curLoginAddr=" + curLoginAddr + ", miscDesc=" + miscDesc + ", status=" + status + ", createTime=" + createTime + ", createOperId=" + createOperId + ", createOperName=" + createOperName + ", updateTime=" + updateTime + ", updateOperId=" + updateOperId + ", updateOperName=" + updateOperName + "]"; } public Serializable getPK() { return id; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/model/Operator.java
Java
asf20
6,282
package com.jzzms.bsp.model.urss; import java.io.Serializable; import com.jzzms.framework.core.Model; public class Config extends Model { private static final long serialVersionUID = 1339081058531L; private String code; private String value; private String status; public String getCode() { return code; } public void setCode(String code) { entityMap.put("code", code); this.code = code; } public String getValue() { return value; } public void setValue(String value) { entityMap.put("value", value); this.value = value; } public String getStatus() { return status; } public void setStatus(String status) { entityMap.put("status", status); this.status = status; } @Override public Serializable getPK() { return code; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/model/urss/Config.java
Java
asf20
814
package com.jzzms.bsp.model.urss; import java.io.Serializable; import com.jzzms.framework.core.Model; public class OrgTree extends Model { private static final long serialVersionUID = 1339081058734L; private Integer id; private String name; private Integer parentId; private Integer orgTypeId; private Integer comId; public Integer getId() { return id; } public void setId(Integer id) { entityMap.put("id", id); this.id = id; } public String getName() { return name; } public void setName(String name) { entityMap.put("name", name); this.name = name; } public Integer getParentId() { return parentId; } public void setParentId(Integer parentId) { entityMap.put("parentId", parentId); this.parentId = parentId; } public Integer getOrgTypeId() { return orgTypeId; } public void setOrgTypeId(Integer orgTypeId) { entityMap.put("orgTypeId", orgTypeId); this.orgTypeId = orgTypeId; } public Integer getComId() { return comId; } public void setComId(Integer comId) { entityMap.put("comId", comId); this.comId = comId; } @Override public Serializable getPK() { return id; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/model/urss/OrgTree.java
Java
asf20
1,208
package com.jzzms.bsp.model.urss; import java.io.Serializable; import com.jzzms.framework.core.Model; public class Resource extends Model { private static final long serialVersionUID = 1339081058843L; private Integer id; private Integer funId; private String name; private String code; private String isButton; private String buttonId; private String implJs; private String implUrl; private String groupName; private String isOrg; private String isLinkAssign; private String linkAssignValue; private String buttonStyle; private Integer orderIndex; private Integer appId; public Integer getId() { return id; } public void setId(Integer id) { entityMap.put("id", id); this.id = id; } public Integer getFunId() { return funId; } public void setFunId(Integer funId) { entityMap.put("funId", funId); this.funId = funId; } public String getName() { return name; } public void setName(String name) { entityMap.put("name", name); this.name = name; } public String getCode() { return code; } public void setCode(String code) { entityMap.put("code", code); this.code = code; } public String getIsButton() { return isButton; } public void setIsButton(String isButton) { entityMap.put("isButton", isButton); this.isButton = isButton; } public String getButtonId() { return buttonId; } public void setButtonId(String buttonId) { entityMap.put("buttonId", buttonId); this.buttonId = buttonId; } public String getImplJs() { return implJs; } public void setImplJs(String implJs) { entityMap.put("implJs", implJs); this.implJs = implJs; } public String getImplUrl() { return implUrl; } public void setImplUrl(String implUrl) { entityMap.put("implUrl", implUrl); this.implUrl = implUrl; } public String getGroupName() { return groupName; } public void setGroupName(String groupName) { entityMap.put("groupName", groupName); this.groupName = groupName; } public String getIsOrg() { return isOrg; } public void setIsOrg(String isOrg) { entityMap.put("isOrg", isOrg); this.isOrg = isOrg; } public String getIsLinkAssign() { return isLinkAssign; } public void setIsLinkAssign(String isLinkAssign) { entityMap.put("isLinkAssign", isLinkAssign); this.isLinkAssign = isLinkAssign; } public String getLinkAssignValue() { return linkAssignValue; } public void setLinkAssignValue(String linkAssignValue) { entityMap.put("linkAssignValue", linkAssignValue); this.linkAssignValue = linkAssignValue; } public String getButtonStyle() { return buttonStyle; } public void setButtonStyle(String buttonStyle) { entityMap.put("buttonStyle", buttonStyle); this.buttonStyle = buttonStyle; } public Integer getOrderIndex() { return orderIndex; } public void setOrderIndex(Integer orderIndex) { entityMap.put("orderIndex", orderIndex); this.orderIndex = orderIndex; } public Integer getAppId() { return appId; } public void setAppId(Integer appId) { entityMap.put("appId", appId); this.appId = appId; } @Override public Serializable getPK() { return id; } }
zz-ms
trunk/zz-ms-v1.0/sourcecode/bsp/src/com/jzzms/bsp/model/urss/Resource.java
Java
asf20
3,286