xxx组公共组件使用和说明
2015-08-05 02:00
302 查看
前端
所有的Controller 必须继承 BaseActionController 能使用基类的方法必须使用基类的方法,不需要自己再造轮子。
所有的Controller 与页面之间的交互 都封装成dto对象..后台校验都必须采用coe-boss-validate 提供的校验方法进行校验(特殊除外)--- 能抽象的校验一律在coe-boss-validate中实现
前后台传输请使用dto进行传输
所有的模块命名必须规范.如下:
com.bill99.boss.intra
com.bill99.boss.website
com.bill99.boss.应用.模块.controller
com.bill99.boss.应用.模块.dto
com.bill99.boss.应用.模块.service
公共的前端模块放到coe-boss-controller
公共插件和方法函数请使用 coe-boss-utils 里面提供的
配置文件请需要分模块例如:
[b]context/servlet/member/[b]context-init.xml[/b]
context/servlet/大模块/context-模块-XXX.xml
Controller内部函数规范
[/b]
public ModelAndView index(HttpServletRequest req, HttpServletResponse resp)
throws Exception {
ModelAndView m = new ModelAndView(this.viewName);
this.query(req, m);
return m;
}
private void query(HttpServletRequest req, ModelAndView m) throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("orderField", "serverName");
List<Server> dataList = this.serverService.queryServerByMap(map);
m.addObject("dataList", dataList);
}
后端
数据操作请采用标准的代码生成工具来生成coe-boss-codegenerator 来生成后端代码
公共组件的使用说明
前端Controller公共的函数
/**
* 登陆用户
* @param defaultValue
* @return
*/
public String getLoginUserName(HttpServletRequest request,String defaultValue);
/**
* sso信息,包括getUserName,getUserId ,getUserCode等信息
*
* @param request
* @return
*/
public SSOInfo getSSOInfo(HttpServletRequest request) ;
/**
* <b>功能:</b>输出JSON<br>
* <b>日期:</b> 2012-6-18 <br>
*
* @param t
* @param response
*/
public <T> void toJson(T t, HttpServletResponse response);
/**
* 字符串输出
*
* @param t
* @param response
*/
public void toWriter(String t, HttpServletResponse response);
/**
* x直接在浏览器显示图片
*
* @param filePath
* 文件在本地的路径
* @param response
* @throws Exception
* @return void 返回类型
*/
public void showImage(String filePath, HttpServletResponse response);
/**
* 在浏览器端弹出下载框 进行下载
*
* @param filePath
* 服务器文件的路径
* @param response
* @param fileName
* 弹出框显示的文件名
* @throws Exception
* @return void 返回类型
*/
public void downLoad(String filePath, HttpServletResponse response,
String fileName) throws Exception;
/**
* 校验参数对象---对象必须继承BaseDto类 其他特殊校验请在vilidator中添加
* 错误信息,目前只封装成了string返回.请直接在原对象中调用getErrorMsg 获取
* 后续可以扩展为错误信息key=value形式的返回 json
* @param dto 必须继承BaseDto类
* @return true|false
* @throws Exception
*/
public <T> boolean hasErrors(T dto) throws Exception;
/**
* 获取登录用户的IP地址
* @param request
* @return ip
*/
public String getIpAddr(HttpServletRequest request);
EXL操作
/**
* Exl文件导出到处理类,支持导出到本地和 浏览器
*
* @ClassName: ExcelUtil
* @Description: TODO
* @author xianglin.mo
* @date 2015-1-4 下午03:16:05
* @version [1.0, 2015-1-4]
* @since version 1.0
*/
public class ExcelUtil extends AbstractExcel
{
创建xls
public void createExl(String sheetName, List dataList, String filePath);
/**
* 导入Excel,解析 并支持 验证 和后续通知等操作 需要自己的实现是转换对象 必须继承ExcelMode 可以实现各自的拦截器
* 如果拦截器中将对象置为空,则不返回数据。
*
* @param <T>
* exl列转换的目标对象
* @param in
* @param model
* @param className 必须继承ExcelModel基类
* @return
* @throws Exception
* @return List<T> 返回类型
*/
public <T> List<T> importExcel(InputStream in, ExcelImpDto model,
Class<T> className) throws Exception;
/**
* 导入Excel,解析 并支持 验证 和后续通知等操作 需要自己的实现是转换对象 必须继承ExcelMode 可以实现各自的拦截器
* 如果拦截器中将对象置为空,则不返回数据。
*
* @param <T>
* exl列转换的目标对象
* @param in
* @param model
* @param className 必须继承ExcelModel基类
* @return
* @throws Exception
* @return List<T> 返回类型
*/
public <T> List<T> importExcel(HttpServletRequest request,
ExcelImpDto model, Class<T> className) throws Exception
}
业务逻辑规则处理-
SpringRuleEngine;
/**
* 规则引擎工厂,配置所有的流程和规则处理逻辑
*
* @ClassName: MultiRuleEngine
* @Description: TODO
* @author xianglin.mo
* @date 2014-11-26 上午09:15:33
* @version [1.0, 2014-11-26]
* @since version 1.0
*/
public class RuleEngineFactory;
进件系统流程配置和加载以及开发规范
t_flow 流程定义表 ----如果有新的流程 在此定义
t_node 流程节点处理逻辑表 ----如果开发了新的节点配置到这张表中—所有的节点必须继承AbstractLoopRule
t_workflow_rule 流程实例化表 (包括流程的流转)----所有流程的规则在这里配置---执行的流程也在此表配置----所有节点id都那个各自的处理单元()
t_node_role 流程节点的权限控制表
t_noderule_param 流程实例化中每个节点需要用到的参数配置表
t_boss_workitem 流程执行的过程记录 --(主要节点的记录)
开源的工具类使用
commons-codec 加解密常用
commons-beanutils bean直接的转换 map 还有对象与对象直接的转换 反射
commons-collections 集合类扩展处理
json相关处理
/**
* 官方已经明确过 ObjectMapper 是线程安全的,所以只要保证启动时,不并发即可 作为全局变量使用,可以提高性能
*
* @ClassName: JsonUtils
* @Description: TODO
* @author xianglin.mo
* @date 2014-11-26 下午02:31:54
* @version [1.0, 2014-11-26]
* @since version 1.0
*/
public class JsonUtils;
java-unrar 文件解压缩处理
所有的Controller 必须继承 BaseActionController 能使用基类的方法必须使用基类的方法,不需要自己再造轮子。
所有的Controller 与页面之间的交互 都封装成dto对象..后台校验都必须采用coe-boss-validate 提供的校验方法进行校验(特殊除外)--- 能抽象的校验一律在coe-boss-validate中实现
注解 | 适用的数据类型 | 说明 |
@AssertFalse | Boolean, boolean | 验证注解的元素值是false |
@AssertTrue | Boolean, boolean | 验证注解的元素值是true |
@DecimalMax(value=x) | BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. | 验证注解的元素值小于等于@ DecimalMax指定的value值 |
@DecimalMin(value=x) | BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. | 验证注解的元素值小于等于@ DecimalMin指定的value值 |
@Digits(integer=整数位数, fraction=小数位数) | BigDecimal, BigInteger, String, byte,short, int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of Number andCharSequence. | 验证注解的元素值的整数位数和小数位数上限 |
@Future | java.util.Date, java.util.Calendar; Additionally supported by HV, if theJoda Time date/time API is on the class path: any implementations ofReadablePartial andReadableInstant. | 验证注解的元素值(日期类型)比当前时间晚 |
@Max(value=x) | BigDecimal, BigInteger, byte, short,int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type ofCharSequence (the numeric value represented by the character sequence is evaluated), any sub-type of Number. | 验证注解的元素值小于等于@Max指定的value值 |
@Min(value=x) | BigDecimal, BigInteger, byte, short,int, long and the respective wrappers of the primitive types. Additionally supported by HV: any sub-type of CharSequence (the numeric value represented by the char sequence is evaluated), any sub-type of Number. | 验证注解的元素值大于等于@Min指定的value值 |
@NotNull | Any type | 验证注解的元素值不是null |
@Null | Any type | 验证注解的元素值是null |
@Past | java.util.Date, java.util.Calendar; Additionally supported by HV, if theJoda Time date/time API is on the class path: any implementations ofReadablePartial andReadableInstant. | 验证注解的元素值(日期类型)比当前时间早 |
@Pattern(regex=正则表达式, flag=) | String. Additionally supported by HV: any sub-type of CharSequence. | 验证注解的元素值与指定的正则表达式匹配 |
@Size(min=最小值, max=最大值) | String, Collection, Map and arrays. Additionally supported by HV: any sub-type of CharSequence. | 验证注解的元素值的在min和max(包含)指定区间之内,如字符长度、集合大小 |
@Valid | Any non-primitive type(引用类型) | 验证关联的对象,如账户对象里有一个订单对象,指定验证订单对象 |
@NotEmpty | CharSequence, Collection, Map and Arrays | 验证注解的元素值不为null且不为空(字符串长度不为0、集合大小不为0) |
@Range(min=最小值, max=最大值) | CharSequence, Collection, Map and Arrays,BigDecimal, BigInteger, CharSequence, byte, short, int, long and the respective wrappers of the primitive types | 验证注解的元素值在最小值和最大值之间 |
@NotBlank | CharSequence | 验证注解的元素值不为空(不为null、去除首位空格后长度为0),不同于@NotEmpty,@NotBlank只应用于字符串且在比较时会去除字符串的空格 |
@Length(min=下限, max=上限) | CharSequence | 验证注解的元素值长度在min和max区间内 |
@Email | CharSequence | 验证注解的元素值是Email,也可以通过正则表达式和flag指定自定义的email格式 |
所有的模块命名必须规范.如下:
com.bill99.boss.intra
com.bill99.boss.website
com.bill99.boss.应用.模块.controller
com.bill99.boss.应用.模块.dto
com.bill99.boss.应用.模块.service
公共的前端模块放到coe-boss-controller
公共插件和方法函数请使用 coe-boss-utils 里面提供的
配置文件请需要分模块例如:
[b]context/servlet/member/[b]context-init.xml[/b]
context/servlet/大模块/context-模块-XXX.xml
Controller内部函数规范
[/b]
public ModelAndView index(HttpServletRequest req, HttpServletResponse resp)
throws Exception {
ModelAndView m = new ModelAndView(this.viewName);
this.query(req, m);
return m;
}
private void query(HttpServletRequest req, ModelAndView m) throws Exception {
Map<String, String> map = new HashMap<String, String>();
map.put("orderField", "serverName");
List<Server> dataList = this.serverService.queryServerByMap(map);
m.addObject("dataList", dataList);
}
后端
数据操作请采用标准的代码生成工具来生成coe-boss-codegenerator 来生成后端代码
公共组件的使用说明
前端Controller公共的函数
/**
* 登陆用户
* @param defaultValue
* @return
*/
public String getLoginUserName(HttpServletRequest request,String defaultValue);
/**
* sso信息,包括getUserName,getUserId ,getUserCode等信息
*
* @param request
* @return
*/
public SSOInfo getSSOInfo(HttpServletRequest request) ;
/**
* <b>功能:</b>输出JSON<br>
* <b>日期:</b> 2012-6-18 <br>
*
* @param t
* @param response
*/
public <T> void toJson(T t, HttpServletResponse response);
/**
* 字符串输出
*
* @param t
* @param response
*/
public void toWriter(String t, HttpServletResponse response);
/**
* x直接在浏览器显示图片
*
* @param filePath
* 文件在本地的路径
* @param response
* @throws Exception
* @return void 返回类型
*/
public void showImage(String filePath, HttpServletResponse response);
/**
* 在浏览器端弹出下载框 进行下载
*
* @param filePath
* 服务器文件的路径
* @param response
* @param fileName
* 弹出框显示的文件名
* @throws Exception
* @return void 返回类型
*/
public void downLoad(String filePath, HttpServletResponse response,
String fileName) throws Exception;
/**
* 校验参数对象---对象必须继承BaseDto类 其他特殊校验请在vilidator中添加
* 错误信息,目前只封装成了string返回.请直接在原对象中调用getErrorMsg 获取
* 后续可以扩展为错误信息key=value形式的返回 json
* @param dto 必须继承BaseDto类
* @return true|false
* @throws Exception
*/
public <T> boolean hasErrors(T dto) throws Exception;
/**
* 获取登录用户的IP地址
* @param request
* @return ip
*/
public String getIpAddr(HttpServletRequest request);
EXL操作
/**
* Exl文件导出到处理类,支持导出到本地和 浏览器
*
* @ClassName: ExcelUtil
* @Description: TODO
* @author xianglin.mo
* @date 2015-1-4 下午03:16:05
* @version [1.0, 2015-1-4]
* @since version 1.0
*/
public class ExcelUtil extends AbstractExcel
{
创建xls
public void createExl(String sheetName, List dataList, String filePath);
/**
* 导入Excel,解析 并支持 验证 和后续通知等操作 需要自己的实现是转换对象 必须继承ExcelMode 可以实现各自的拦截器
* 如果拦截器中将对象置为空,则不返回数据。
*
* @param <T>
* exl列转换的目标对象
* @param in
* @param model
* @param className 必须继承ExcelModel基类
* @return
* @throws Exception
* @return List<T> 返回类型
*/
public <T> List<T> importExcel(InputStream in, ExcelImpDto model,
Class<T> className) throws Exception;
/**
* 导入Excel,解析 并支持 验证 和后续通知等操作 需要自己的实现是转换对象 必须继承ExcelMode 可以实现各自的拦截器
* 如果拦截器中将对象置为空,则不返回数据。
*
* @param <T>
* exl列转换的目标对象
* @param in
* @param model
* @param className 必须继承ExcelModel基类
* @return
* @throws Exception
* @return List<T> 返回类型
*/
public <T> List<T> importExcel(HttpServletRequest request,
ExcelImpDto model, Class<T> className) throws Exception
}
业务逻辑规则处理-
SpringRuleEngine;
/**
* 规则引擎工厂,配置所有的流程和规则处理逻辑
*
* @ClassName: MultiRuleEngine
* @Description: TODO
* @author xianglin.mo
* @date 2014-11-26 上午09:15:33
* @version [1.0, 2014-11-26]
* @since version 1.0
*/
public class RuleEngineFactory;
进件系统流程配置和加载以及开发规范
t_flow 流程定义表 ----如果有新的流程 在此定义
t_node 流程节点处理逻辑表 ----如果开发了新的节点配置到这张表中—所有的节点必须继承AbstractLoopRule
t_workflow_rule 流程实例化表 (包括流程的流转)----所有流程的规则在这里配置---执行的流程也在此表配置----所有节点id都那个各自的处理单元()
t_node_role 流程节点的权限控制表
t_noderule_param 流程实例化中每个节点需要用到的参数配置表
t_boss_workitem 流程执行的过程记录 --(主要节点的记录)
开源的工具类使用
commons-codec 加解密常用
commons-beanutils bean直接的转换 map 还有对象与对象直接的转换 反射
commons-collections 集合类扩展处理
json相关处理
/**
* 官方已经明确过 ObjectMapper 是线程安全的,所以只要保证启动时,不并发即可 作为全局变量使用,可以提高性能
*
* @ClassName: JsonUtils
* @Description: TODO
* @author xianglin.mo
* @date 2014-11-26 下午02:31:54
* @version [1.0, 2014-11-26]
* @since version 1.0
*/
public class JsonUtils;
java-unrar 文件解压缩处理
相关文章推荐
- Linux下网卡开机自动加载
- 合服测试(二)
- 使用Jenkins配置自动化构建
- 合服测试(一)
- MZL's endless loop(欧拉回路,欧拉路径)
- hadoop删除节点和添加节点
- 无法启动soapUI 提示:the jvm could not be started. the main method may have thrown an exception
- app游戏测试在外网搭建账号及sdk
- 黑马程序员---结构体及指针
- myeclipse和eclipse的区别和联系,以及版本间的对应关系
- H - The Child and Toy-CodeForces 437C-水题
- Android QQ空间说说回复功能简介
- RESTful API 设计最佳实践
- G - The Child and Set-CodeForces 437B-水题
- [Leetcode 221, Medium] Maximal square
- 杭电 刘春英 老师 写给计算机软件专业的大学生 .
- B - Pasha Maximizes -水题-CodeForces 435B
- jsp当参数为空的时候默认显示值
- BootStrap分页和标签
- 第一步水题100道结束