ustcyc
2025-01-07 de5d55508afd27fb2b47e6d4d6fd9984525c222c
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zhitan.model.mapper.IndexStorageMapper">
    <resultMap id="indexStorageMap" type="com.zhitan.model.domain.IndexStorage">
        <result property="id" column="id"/>
        <result property="indexId" column="index_id"/>
        <result property="timeType" column="time_type"/>
        <result property="calcType" column="calc_type"/>
        <result property="calcText" column="calc_text"/>
        <result property="updateTime" column="update_time"/>
        <result property="createTime" column="create_time"/>
        <result property="isPvCalc" column="is_pv_calc"/>
    </resultMap>
    <insert id="insertIndexStorage">
        insert into index_storage (id, index_id, time_type, calc_type, calc_text, create_time,
                               update_time,is_pv_calc)
    values (#{id}, #{indexId}, #{timeType}, #{calcType}, #{calcText}, now(), now(),#{isPvCalc});
  </insert>
  <insert id="saveParams">
    delete from storage_parameter where storage_id = #{storageId};
    <foreach collection="parameterIds" item="paramId" separator=";">
      insert into storage_parameter (storage_id, index_id)
      values (#{storageId}, #{paramId});
    </foreach>
  </insert>
  <update id="updateIndexStorage">
    update index_storage
    set index_id    = #{indexId},
        calc_type   = #{calcType},
        calc_text   = #{calcText},
        update_time = now(),
        is_pv_calc = #{isPvCalc}
    where id = #{id};
  </update>
  <select id="getIndexStorage" resultMap="indexStorageMap">
    select *
    from index_storage
    where index_id = #{indexId};
  </select>
  <select id="getAllCalcIndexStorage" resultMap="indexStorageMap">
    select *
    from index_storage
    where calc_type = #{calcType}
  </select>
    <select id="getAllParameter"
            resultType="com.zhitan.model.domain.IndexStorageParam">
        select storage_id as storageId, index_id as indexId
        from storage_parameter
    </select>
  <select id="getWithTimetype" resultMap="indexStorageMap">
    select *
    from index_storage
    where index_id = #{indexId}
      AND time_type = #{timeType};
  </select>
</mapper>