yeg
2026-09-29 b78295e8da96c3e5e76befeef9582ce5273dbb74
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?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.battery.business.mapper.TTestTypeMapper">
 
    <resultMap type="TTestType" id="TTestTypeResult">
        <id property="testTypeId" column="test_type_id" />
        <result property="testTypeName" column="test_type_name" />
        <result property="status" column="status" />
        <result property="delFlag" column="del_flag" />
        <result property="createBy" column="create_by" />
        <result property="createTime" column="create_time" />
        <result property="updateBy" column="update_by" />
        <result property="updateTime" column="update_time" />
        <result property="remark" column="remark" />
    </resultMap>
 
    <sql id="selectTestTypeVo">
        select test_type_id, test_type_name, status, del_flag, create_by, create_time,
               update_by, update_time, remark
        from t_test_type
    </sql>
 
    <select id="selectTestTypeById" parameterType="Long" resultMap="TTestTypeResult">
        <include refid="selectTestTypeVo" />
        where test_type_id = #{testTypeId}
          and del_flag = '0'
    </select>
 
    <select id="selectTestTypeList" parameterType="TTestType" resultMap="TTestTypeResult">
        <include refid="selectTestTypeVo" />
        <where>
            del_flag = '0'
            <if test="testTypeId != null">
                and test_type_id = #{testTypeId}
            </if>
            <if test="testTypeName != null and testTypeName != ''">
                and test_type_name like concat('%', #{testTypeName}, '%')
            </if>
            <if test="beginCreateTime != null and beginCreateTime != ''">
                and create_time &gt;= #{beginCreateTime}
            </if>
            <if test="endCreateTime != null and endCreateTime != ''">
                and create_time &lt;= #{endCreateTime}
            </if>
            <if test="status != null and status != ''">
                and status = #{status}
            </if>
        </where>
        order by create_time desc, test_type_id desc
    </select>
 
    <select id="selectTestTypeByName" parameterType="String" resultMap="TTestTypeResult">
        <include refid="selectTestTypeVo" />
        where test_type_name = #{testTypeName}
          and del_flag = '0'
        limit 1
    </select>
 
    <insert id="insertTestType" parameterType="TTestType" useGeneratedKeys="true" keyProperty="testTypeId">
        insert into t_test_type
        (test_type_name, status, del_flag, create_by, create_time, remark)
        values
        (#{testTypeName}, #{status}, #{delFlag}, #{createBy}, #{createTime}, #{remark})
    </insert>
 
    <update id="updateTestType" parameterType="TTestType">
        update t_test_type
        set test_type_name = #{testTypeName},
            remark = #{remark},
            update_by = #{updateBy},
            update_time = #{updateTime}
        where test_type_id = #{testTypeId}
          and del_flag = '0'
    </update>
 
    <update id="updateTestTypeStatus" parameterType="TTestType">
        update t_test_type
        set status = #{status},
            update_by = #{updateBy},
            update_time = #{updateTime}
        where test_type_id = #{testTypeId}
          and del_flag = '0'
    </update>
 
    <select id="countTestReferencesByTestTypeId" parameterType="Long" resultType="int">
        select count(1)
        from t_test
        where test_type_id = #{testTypeId}
          and del_flag = '0'
    </select>
 
    <update id="deleteTestTypeById">
        update t_test_type
        set del_flag = cast(test_type_id as char),
            update_by = #{updateBy},
            update_time = sysdate()
        where test_type_id = #{testTypeId}
          and del_flag = '0'
    </update>
</mapper>