您的位置:首页 > 其它

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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: