648540858
2022-02-24 a42dda2bd3cc1cf8c20cc61e7ad9211eadecbaf3
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
package com.genersoft.iot.vmp.storager.dao;
 
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
import com.genersoft.iot.vmp.storager.dao.dto.LogDto;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
 
import java.util.List;
 
/**
 * 用于存储设服务的日志
 */
@Mapper
@Repository
public interface LogMapper {
 
    @Insert("insert into log ( name, type, uri, address, result, timing, username, createTime) " +
            "values ('${name}', '${type}', '${uri}', '${address}', '${result}', ${timing}, '${username}', '${createTime}')")
    int add(LogDto logDto);
 
    @Select(value = {"<script>" +
            " SELECT * FROM log " +
            " WHERE 1=1 " +
            " <if test=\"query != null\"> AND (name LIKE '%${query}%')</if> " +
            " <if test=\"type != null\" >  AND type = '${type}'</if>" +
            " <if test=\"startTime != null\" >  AND createTime &gt;= '${startTime}' </if>" +
            " <if test=\"endTime != null\" >  AND createTime &lt;= '${endTime}' </if>" +
            " ORDER BY createTime DESC " +
            " </script>"})
    List<LogDto> query(String query, String type, String startTime, String endTime);
 
    @Delete("DELETE FROM log")
    int clear();
}