Files
pengchen-exam-java/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/specialty/ExamSpecialtyMapper.xml

202 lines
7.7 KiB
XML
Raw Normal View History

<?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="pc.exam.pp.module.exam.dal.mysql.specialty.ExamSpecialtyMapper">
<resultMap type="ExamSpecialty" id="ExamSpecialtyResult">
<result property="spId" column="sp_id"/>
<result property="parentId" column="parent_id"/>
<result property="ancestors" column="ancestors"/>
<result property="spName" column="sp_name"/>
<result property="orderNum" column="order_num"/>
<result property="status" column="status"/>
<result property="unite" column="unite"/>
<result property="treeNum" column="tree_num"/>
<result property="roles" column="roles"/>
</resultMap>
<resultMap type="ExamKnowledgePoints" id="KnowledgePointsResult">
<result property="spId" column="sp_id"/>
<result property="parentId" column="parent_id"/>
<result property="ancestors" column="ancestors"/>
<result property="spName" column="sp_name"/>
<result property="orderNum" column="order_num"/>
<result property="status" column="status"/>
<result property="treeNum" column="tree_num"/>
</resultMap>
<sql id="selectExamSpecialtyVo">
select sp_id,
parent_id,
ancestors,
sp_name,
order_num,
status,
creator,
create_time,
updater,
update_time,
unite,
tree_num,
roles,
tenant_id
from exam_specialty
</sql>
<select id="selectExamSpecialtyListVo"
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
select sp_id as id, sp_name as name, parent_id, status, create_time,roles from exam_specialty
<where>
<if test="name != null and name != ''">and sp_name like concat('%', #{name}, '%')</if>
<if test="status != null and status != ''">and status = #{status}</if>
and deleted = 0
</where>
</select>
<select id="selectExamSpecialtyAll"
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
select sp_id as id, sp_name as name, parent_id, status, create_time
from exam_specialty
where deleted = 0
and status = 0
</select>
<select id="selectExamSpecialtyByids"
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
SELECT sp_id AS id, sp_name AS name, ancestors, parent_id, status, create_time from exam_specialty
WHERE sp_id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
AND deleted = 0 and status = 0
</select>
<select id="selectExamSpecialtyPart"
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
select sp_id as id, sp_name as name, parent_id, status, create_time
FROM exam_specialty
WHERE (
LENGTH(ancestors) - LENGTH(REPLACE(ancestors, ',', ''))
) + 1 &lt;= 2
and status = 0
and deleted = 0
</select>
<select id="selectExamSpecialtyList" resultType="ExamSpecialty">
<include refid="selectExamSpecialtyVo"/>
<where>
<if test="name != null and name != ''">and sp_name like concat('%', #{name}, '%')</if>
<if test="status != null and status != ''">and status = #{status}</if>
and deleted = 0
</where>
</select>
<select id="selectSpIds" parameterType="ExamSpecialty" resultMap="ExamSpecialtyResult">
<include refid="selectExamSpecialtyVo"/>
<!-- <where>-->
<!-- <if test="spId != null "> and sp_id = #{spId}</if>-->
<!-- </where>-->
where sp_id in
<foreach item="spId" collection="array" open="(" separator="," close=")">
#{spId}
</foreach>
</select>
<update id="updateExamSpecialty" parameterType="ExamSpecialty">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
<if test="parentId != null">parent_id = #{parentId},</if>
<if test="ancestors != null">ancestors = #{ancestors},</if>
<if test="spName != null">sp_name = #{spName},</if>
<if test="orderNum != null">order_num = #{orderNum},</if>
<if test="status != null">status = #{status},</if>
<if test="unite != null">unite = #{unite},</if>
<if test="treeNum != null">tree_num = #{treeNum},</if>
</trim>
where sp_id = #{spId}
</update>
<select id="selectExamSpecialtyBySpId" parameterType="Long" resultMap="ExamSpecialtyResult">
<include refid="selectExamSpecialtyVo"/>
where sp_id = #{spId}
</select>
<select id="selectExamSpecialtyBySpName" parameterType="String" resultType="pc.exam.pp.module.exam.dal.dataobject.specialty.ExamSpecialty">
SELECT *
from exam_specialty
where sp_name = #{spName}
</select>
<select id="selectExamSpecialtyByParentId"
resultType="pc.exam.pp.module.exam.controller.admin.specialty.vo.SpecialtyQueryVo">
SELECT sp_id AS id, sp_name AS name, ancestors, parent_id, status, create_time
from exam_specialty
where parent_id = #{parentId}
</select>
<select id="getRoleById" resultType="java.lang.String">
select roles
from exam_specialty
where sp_id = #{id};
</select>
<select id="selectBySpecCourseSub" resultMap="ExamSpecialtyResult">
SELECT q3.*
FROM exam_specialty q1
JOIN exam_specialty q2 ON q2.parent_id = q1.sp_id
JOIN exam_specialty q3 ON q3.parent_id = q2.sp_id
WHERE q1.sp_name = #{specialtyName}
AND q2.sp_name = #{courseName}
AND q3.sp_name = #{subjectName}
AND q1.deleted = '0'
AND q2.deleted = '0'
AND q3.deleted = '0' LIMIT 1;
</select>
<select id="selectByPointsSub" resultMap="KnowledgePointsResult">
SELECT q3.*
FROM exam_knowledge_points q1
JOIN exam_knowledge_points q2 ON q2.parent_id = q1.sp_id
JOIN exam_knowledge_points q3 ON q3.parent_id = q2.sp_id
WHERE q1.sp_name = #{specialtyName}
AND q2.sp_name = #{chapteridDictText}
AND q3.sp_name = #{pointNames}
AND q1.deleted = '0'
AND q2.deleted = '0'
AND q3.deleted = '0' LIMIT 1;
</select>
<select id="selectAllSpecialtyRelations"
resultType="pc.exam.pp.module.exam.service.monitor.vo.SpecialtyRelation">
SELECT sp_id AS spId, parent_id AS parentId
FROM exam_specialty
</select>
<select id="selectAllIdToParent" resultType="pc.exam.pp.module.exam.service.monitor.vo.IdParentPair">
SELECT sp_id AS spId, parent_id AS parentId
FROM exam_specialty
WHERE deleted = '0'
and status = '0'
and tenant_id = #{loginTenantId}
</select>
<update id="deleteExamSpecialtyBySpId" parameterType="Long">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id = #{spId}
</update>
<update id="deleteExamSpecialtyBySpIds" parameterType="String">
update exam_specialty
<trim prefix="SET" suffixOverrides=",">
deleted = 1
</trim>
where sp_id in
<foreach item="spId" collection="array" open="(" separator="," close=")">
#{spId}
</foreach>
</update>
</mapper>