cxf+mybaties+spring

来源:互联网 发布:过山车是谁发明的 知乎 编辑:程序博客网 时间:2024/06/05 13:31

刚到公司接触的一个新的项目,用的是spring进行管理,mybaties进行数据持久化,cxf发布接口整体dao-service-action;和web项目区别是这只写接口由前边c#传入数据,

具体记录一下

1.webservice暴露出来的方法

@WebService(endpointInterface="com.lgt.webservice.action.UniqueAction",targetNamespace="http://www.lgt.com")

private UniqueService uniqueService ;


public UniqueService getUniqueService() {
return uniqueService;
}


public void setUniqueService(UniqueService uniqueService) {
this.uniqueService = uniqueService;
}

public String method(String code,String data){
try {
logger.info("【执行"+code+"模块】-请求来自IP:"+ClientUtil.getRemoteAddr());
String str = this.uniqueService.execute(code, data);

//这里说一下前台传进来的总是字符串形式的两个参数,code为要执行的方法,data为封装类,写一个json工具类将对象,page全部转换为String

return str;
} catch (Exception e) {
// TODO: handle exception
return  JsonUtil.formatResult(code, MessageCode.CODE_500000,"访问接口出现错误!接口编码:"+code);
}finally{
logger.info("【执行"+code+"模块】-处理来自IP:"+ClientUtil.getLocalAddr());
}
2.service
所有Action私有并写set,get方法
public String execute(String code, String data){
// TODO Auto-generated method stub
//判断是否为空
if(StringUtils.isNotEmpty(this.getModuleType(code))){
////////////系统管理///////////////////
if(ModuleCode.CODE_LL.equalsIgnoreCase(this.getModuleType(code))){//登录模块
logger.debug("进入登录模块......");
return this.loginAction.execute(code, data).toString();
}else if(ModuleCode.CODE_QQ.equalsIgnoreCase(this.getModuleType(code))){//权限模块
logger.debug("进入权限模块......");
return this.authorityAction.execute(code, data).toString();
}else if(ModuleCode.CODE_AI.equalsIgnoreCase(this.getModuleType(code))){//日志模块
logger.debug("进入日志模块......");
return this.loggerAction.execute(code, data).toString();
}else if(ModuleCode.CODE_AK.equalsIgnoreCase(this.getModuleType(code))){//数据字典模块
logger.debug("进入数据字典管理 模块......");
return this.dictionaryAction.execute(code, data).toString();
}else if(ModuleCode.CODE_AM.equalsIgnoreCase(this.getModuleType(code))){//菜单模块管理
logger.debug("进入菜单模块管理模块....");
。。。
这里只是一部分,
ModuleCode.CODE这些都是已经写好的常量
this.getModuleType(code)截取字符串前两位的方法,进入到模块以后再根据具体code进入相应的方法,
具体转换方法我会写一个专门的文章