xiangpei
2024-03-28 0f431b52e0936456bd165d9553761bfd8a5a0517
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<?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.mindskip.xzs.repository.KnowledgePointMapper">
  <resultMap id="BaseResultMap" type="com.mindskip.xzs.domain.KnowledgePoint">
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="level" jdbcType="INTEGER" property="level" />
    <result column="subject_id" jdbcType="INTEGER" property="subjectId" />
    <result column="item_order" jdbcType="INTEGER" property="itemOrder" />
    <result column="deleted" jdbcType="BIT" property="deleted" />
    <result column="parent_id" jdbcType="INTEGER" property="parentId" />
  </resultMap>
  <sql id="Base_Column_List">
    id, name, level, subject_id, item_order, deleted, parent_id
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Integer" resultMap="BaseResultMap">
    select 
    <include refid="Base_Column_List" />
    from t_knowledge_point
    where id = #{id,jdbcType=INTEGER}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer">
    delete from t_knowledge_point
    where id = #{id,jdbcType=INTEGER}
  </delete>
  <insert id="insert" parameterType="com.mindskip.xzs.domain.KnowledgePoint" useGeneratedKeys="true" keyProperty="id" >
    insert into t_knowledge_point (id, name, level, 
      subject_id, item_order, deleted, 
      parent_id)
    values (#{id,jdbcType=INTEGER}, #{name,jdbcType=VARCHAR}, #{level,jdbcType=INTEGER}, 
      #{subjectId,jdbcType=INTEGER}, #{itemOrder,jdbcType=INTEGER}, #{deleted,jdbcType=BIT}, 
      #{parentId,jdbcType=INTEGER})
  </insert>
  <insert id="insertSelective" parameterType="com.mindskip.xzs.domain.KnowledgePoint" useGeneratedKeys="true" keyProperty="id" >
    insert into t_knowledge_point
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="level != null">
        level,
      </if>
      <if test="subjectId != null">
        subject_id,
      </if>
      <if test="itemOrder != null">
        item_order,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
      <if test="parentId != null">
        parent_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=INTEGER},
      </if>
      <if test="name != null">
        #{name,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        #{level,jdbcType=INTEGER},
      </if>
      <if test="subjectId != null">
        #{subjectId,jdbcType=INTEGER},
      </if>
      <if test="itemOrder != null">
        #{itemOrder,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        #{deleted,jdbcType=BIT},
      </if>
      <if test="parentId != null">
        #{parentId,jdbcType=INTEGER},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.mindskip.xzs.domain.KnowledgePoint">
    update t_knowledge_point
    <set>
      <if test="name != null">
        name = #{name,jdbcType=VARCHAR},
      </if>
      <if test="level != null">
        level = #{level,jdbcType=INTEGER},
      </if>
      <if test="subjectId != null">
        subject_id = #{subjectId,jdbcType=INTEGER},
      </if>
      <if test="itemOrder != null">
        item_order = #{itemOrder,jdbcType=INTEGER},
      </if>
      <if test="deleted != null">
        deleted = #{deleted,jdbcType=BIT},
      </if>
      <if test="parentId != null">
        parent_id = #{parentId,jdbcType=INTEGER},
      </if>
    </set>
    where id = #{id,jdbcType=INTEGER}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.mindskip.xzs.domain.KnowledgePoint">
    update t_knowledge_point
    set name = #{name,jdbcType=VARCHAR},
      level = #{level,jdbcType=INTEGER},
      subject_id = #{subjectId,jdbcType=INTEGER},
      item_order = #{itemOrder,jdbcType=INTEGER},
      deleted = #{deleted,jdbcType=BIT},
      parent_id = #{parentId,jdbcType=INTEGER}
    where id = #{id,jdbcType=INTEGER}
  </update>
 
 
  <select id="getKnowledgePointBySubjectId" resultMap="BaseResultMap" >
    SELECT
    <include refid="Base_Column_List"/>
    FROM t_knowledge_point
    where deleted=0 and parent_id is null and subject_id = #{id}
  </select>
 
 
 
  <select id="getKnowledgePointByParentId" resultMap="BaseResultMap" >
    SELECT
    <include refid="Base_Column_List"/>
    FROM t_knowledge_point
    where deleted=0 and parent_id = #{id}
  </select>
 
 
  <select id="page" resultType="com.mindskip.xzs.domain.other.KnowledgePointPage" parameterType="com.mindskip.xzs.viewmodel.admin.knowledge.KnowledgePageRequestVM">
    select level ,subject_id as subjectId,count(*) as count from t_knowledge_point
    where parent_id is null and deleted=0
    <if test="level != null">
      and  level = #{level}
    </if>
    GROUP BY  level ,subject_id
  </select>
 
 
  <select id="getKnowledgePoint" resultMap="BaseResultMap" >
    SELECT
    <include refid="Base_Column_List"/>
    FROM t_knowledge_point
    where deleted=0 and  name = #{name}
    and subject_id = #{subjectId} and level = #{levelId}
    limit 1
  </select>
 
</mapper>