ssh 模板
2016-07-25 10:17
176 查看
pojo
<span style="font-size:14px;">import com.njbh.core.pojo.GenericModel; public class FanInfo implements java.io.Serializable,GenericModel{ private String id; private String fanDesc; private String fanState; private String catchTime; private Long period; private String moduleId; public String getId() { return id; } public void setId(String id) { this.id = id; } public String getFanDesc() { return fanDesc; } public void setFanDesc(String fanDesc) { this.fanDesc = fanDesc; } public String getFanState() { return fanState; } public void setFanState(String fanState) { this.fanState = fanState; } public String getCatchTime() { return catchTime; } public void setCatchTime(String catchTime) { this.catchTime = catchTime; } public Long getPeriod() { return period; } public void setPeriod(Long period) { this.period = period; } public String getModuleId() { return moduleId; } public void setModuleId(String moduleId) { this.moduleId = moduleId; } }</span>
service
<span style="font-size:14px;"><strong>import java.util.List;</span><span style="font-size:14px;"> import com.njbh.core.service.Service; import com.njbh.fault.inspection.pojo.cisco.FanInfo; public interface FanInfoService extends Service<FanInfo, String>{ /** * @author XJ * 根据设备id查找电源状态 * @param mouldeId * @return */ public List<FanInfo> queryFanInfoState(String mouldeId); }</strong></span>
serviceImpl
<span style="font-size:14px;"><strong>import java.util.List; import com.njbh.core.service.impl.GenericService; import com.njbh.fault.inspection.dao.ciso.FanInfoHome; import com.njbh.fault.inspection.pojo.cisco.FanInfo; import com.njbh.fault.inspection.service.ciso.FanInfoService; public class FanInfoServiceImpl extends GenericService<FanInfo, String> implements FanInfoService{ @Override public List<FanInfo> queryFanInfoState(String mouldeId) { FanInfoHome faninfohome = (FanInfoHome) home; return faninfohome.queryFanInfoState(mouldeId); } }</strong></span>
dao
<strong><span style="font-size:14px;">import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.hibernate.HibernateException; import org.hibernate.Query; import org.hibernate.transform.Transformers; import com.njbh.core.home.GenericHome; import com.njbh.fault.inspection.pojo.cisco.FanInfo; public class FanInfoHome extends GenericHome<FanInfo, String>{ private static final Log log = LogFactory.getLog(FanInfoHome.class); public FanInfoHome(Class<FanInfo> c) { super(c); // TODO Auto-generated constructor stub } public FanInfoHome(){ this(FanInfo.class); } public List<FanInfo> queryFanInfoState(String mouldeId){ log.debug("attaching FanInfoHome queryFanInfoState"); try { StringBuffer sql = new StringBuffer(); sql.append(" select FAN_STATE \"fanState\" from FANINFO "); sql.append(" where MODULEID=?"); sql.append(" and PERIOD=(select max(PERIOD) from FANINFO where MODULEID=?)"); Query query = sessionFactory.getCurrentSession().createSQLQuery(sql.toString()); query.setString(0, mouldeId); query.setString(1, mouldeId); Query transQuery = query.setResultTransformer(Transformers.aliasToBean(FanInfo.class)); log.debug("attaching queryFanInfoState successful"); return transQuery.list(); } catch (HibernateException e) { log.error("attaching queryFanInfoState failed", e); return null; } } } </span></strong>
action
<strong><span style="font-size:14px;">import java.util.List; import com.njbh.core.action.GenericAction; import com.njbh.fault.inspection.pojo.cisco.FanInfo; import com.njbh.fault.inspection.service.ciso.FanInfoService; public class FanInfoAction extends GenericAction<FanInfoService>{ private String mouldeId; public String getMouldeId() { return mouldeId; } public void setMouldeId(String mouldeId) { this.mouldeId = mouldeId; } public String queryFanInfoState(){ FanInfoService fanInfoService =(FanInfoService)service; List<FanInfo> list= fanInfoService.queryFanInfoState(mouldeId); this.setJsonStr(listToJoson(list)); return SUCCESS; } }</span></strong>
struts.xml
<strong><span style="font-size:14px;"> <action name="queryFanInfoState" class="FanInfoAction" method="queryFanInfoState"> <result name="SUCCESS">jsondata.jsp</result> </action></span></strong>
application.xml
<bean id="FanInfoAction" class="com.njbh.fault.inspection.action.cisco.FanInfoAction" scope="request"> <property name="service" ref="fanInfoService" /> </bean>
<pre name="code" class="html"> <strong><span style="font-size:14px;"><bean id="fanInfoService" class="com.njbh.fault.inspection.service.ciso.impl.FanInfoServiceImpl"> <property name="home" ref="fanInfoHome" /> </bean></span></strong>
<strong><span style="font-size:14px;"> <bean id="fanInfoHome" class="com.njbh.fault.inspection.dao.ciso.FanInfoHome"> <property name="sessionFactory" ref="sessionFactory" /> </bean></span></strong>
相关文章推荐
- qt获取内网IP、外网IP和Mac地址
- Leetcode 2. Add Two Numbers
- form表单提交中文乱码
- replace和update的区别是什么
- SQL中的case when then else end用法
- Swift基础(十八)UISegmentedControl
- Qt字符串编码处理
- Android 别人那里学习到的回调机制
- Windows下配置Apache运行C语言的CGI脚本
- 伸展树的python实现
- 手把手教你:让EF动态支持新增表、动态支持多数据库
- android小知识
- WebService 超简单入门教程(Java)
- NTSTATUS Code
- Linux分区
- unity3d magnitude的意义
- OSI模型和TCP/IP模型
- 【solr 基础篇一】介绍与安装
- Matlab批量预处理图片
- nyoj 15 括号匹配(二) 区间动规