package com.iplatform.milvus.service;
|
|
import com.iplatform.milvus.EventVo;
|
import com.walker.jdbc.service.BaseServiceImpl;
|
import org.springframework.jdbc.core.RowMapper;
|
import org.springframework.stereotype.Service;
|
|
import java.sql.ResultSet;
|
import java.sql.SQLException;
|
import java.util.List;
|
|
@Service
|
public class EventServiceImpl extends BaseServiceImpl {
|
|
private final EventVoMapper eventVoMapper = new EventVoMapper();
|
|
public List<EventVo> queryEventAll(Long existId){
|
if(existId == null){
|
return this.select("select * from event_history order by id asc", new Object[]{}, this.eventVoMapper);
|
} else {
|
return this.select("select * from event_history where id > ? order by id asc", new Object[]{existId}, this.eventVoMapper);
|
}
|
}
|
|
private static class EventVoMapper implements RowMapper<EventVo> {
|
@Override
|
public EventVo mapRow(ResultSet rs, int rowNum) throws SQLException {
|
EventVo e = new EventVo();
|
e.setId(rs.getLong("id"));
|
e.setContent(rs.getString("content"));
|
String title = rs.getString("title");
|
if(title.length() > 200){
|
title = title.substring(0, 200);
|
}
|
e.setTitle(title);
|
if(rs.getObject("answer") != null){
|
String answer = rs.getString("answer");
|
if(answer.length() > 180){
|
answer = answer.substring(0,180);
|
}
|
e.setAnswer(answer);
|
}
|
return e;
|
}
|
}
|
}
|