通过创建companyInfo对象时判断nmSqbId是否为空 空值时创建序列 创建完插入数据库时是有nmSqbId 但是用view的话该如何再传到前台接受呢
/**
* 保存主体信息
* @param companyInfo
* @param session
* @return
*/
@At
public View saveCompanyInfo(@Param("::companyInfo.")QfgCompanyInfo companyInfo,@Param("nmSqbId")Integer nmSqbId, HttpSession session) throws Exception{
if(null == companyInfo.getNmCompanyId()){
if(companyInfo.getNmSqbId()==null){
Sql sql = Sqls.create("SELECT SEQ_QFG_PROJECT_INFO.nextval as nmSqbId FROM DUAL");
sql.setCallback(new SqlCallback() {
public Object invoke(Connection conn, ResultSet rs, Sql sql) throws SQLException {
Integer sqbId = null;
while (rs.next())
sqbId = (rs.getInt("nmSqbId"));
return sqbId;
}
});
dao.execute(sql);
int sqbId = sql.getInt();
companyInfo.setNmSqbId(sqbId);
}
try {
wondersDao.insert(companyInfo, session);
} catch (Exception e) {
e.printStackTrace();
}
}else{
//修改保存
QfgCompanyInfo companyInfoInDb = dao.fetch(QfgCompanyInfo.class, companyInfo.getNmCompanyId());
BeanUtils.copyProperties(companyInfoInDb, companyInfo);
wondersDao.update(companyInfoInDb,session);
}
return new ServerRedirectView("/designRequire/companyInfoList?nmSqbId=" + companyInfo.getNmSqbId());
}