shikeying
2024-04-07 52c8ee3120e4a44e48e217bced6f6c799ff7980c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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.jdbc.core.namedparam.MapSqlParameterSource;
import org.springframework.stereotype.Service;
 
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
@Service
public class EventServiceImpl extends BaseServiceImpl {
 
    private final EventVoMapper eventVoMapper = new EventVoMapper();
 
    /**
     * 根据工单id集合,返回这些工单对象(历史工单基本信息)
     * @param ids
     * @return
     * @date 2024-03-31
     */
    public List<EventVo> queryEventWhereIn(List<Long> ids){
        MapSqlParameterSource parameterSource = new MapSqlParameterSource();
        parameterSource.addValue("ids", ids);
        return this.sqlListObjectWhereIn("select * from event_history where id in (:ids)", eventVoMapper, parameterSource);
    }
 
    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;
        }
    }
}