school_website/ruoyi-admin/src/main/resources/mapper/cms/HitCompetitionStudentInfoMapper.xml
2025-05-24 17:05:28 +08:00

177 lines
9.6 KiB
XML

<?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.ruoyi.cms.mapper.HitCompetitionStudentInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="com.ruoyi.cms.domain.HitCompetitionStudentInfo">
<id column="id" property="id" />
<result property="id" column="id" />
<result property="hitRegId" column="hit_reg_id" />
<result property="stuName" column="stu_name" />
<result property="schoolName" column="school_name" />
<result property="collegeName" column="college_name" />
<result property="major" column="major" />
<result property="division" column="division" />
<result property="phoneNumber" column="phone_number" />
<result property="email" column="email" />
<result property="userId" column="user_id" />
<result property="studentIdCard" column="student_id_card" />
<result property="trialsScore" column="trials_score" />
<result property="isPreliminary" column="is_preliminary" />
<result property="remark" column="remark" />
<result property="sex" column="sex" />
<result property="delFlag" column="del_flag" />
<result property="createTime" column="create_time" />
<result property="createBy" column="create_by" />
<result property="updateTime" column="update_time" />
<result property="updateBy" column="update_by" />
</resultMap>
<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id, hit_reg_id, stuName, schoolName, collegeName, major, division, phoneNumber, email, studentIdCard, trialsScore, isPreliminary, remark,sex, del_flag, create_time, create_by, update_time, update_by
</sql>
<select id="selectHitCompetitionStudentInfoList" parameterType="HitCompetitionStudentInfo"
resultType="com.ruoyi.cms.domain.HitCompetitionStudentInfo">
select *
from hit_competition_student_info
<where>
<if test="hitRegId != null and hitRegId != ''">and hit_reg_id = #{hitRegId}</if>
<if test="stuName != null and stuName != ''">and stu_name like concat('%', #{stuName}, '%')</if>
<if test="schoolName != null and schoolName != ''">and school_name = #{schoolName}</if>
<if test="collegeName != null and collegeName != ''">and college_name like concat('%', #{collegeName},
'%')
</if>
<if test="schoolName != null and schoolName != ''">and school_name like concat('%', #{schoolName}, '%')
</if>
<if test="major != null and major != ''">and major = #{major}</if>
<if test="division != null and division != ''">and division = #{division}</if>
<if test="phoneNumber != null and phoneNumber != ''">and phone_number = #{phoneNumber}</if>
<if test="email != null and email != ''">and email = #{email}</if>
<if test="studentIdCard != null and studentIdCard != ''">and student_id_card = #{studentIdCard}</if>
<if test="trialsScore != null ">and trials_score = #{trialsScore}</if>
<if test="isPreliminary != null ">and is_preliminary = #{isPreliminary}</if>
<if test="year != null ">and create_time like concat(#{year},'%')</if>
</where>
order by school_name desc
</select>
<select id="selectHitCompetitionStudentInfoById" parameterType="String"
resultType="com.ruoyi.cms.domain.HitCompetitionStudentInfo">
select * from hit_competition_student_info
where id = #{id}
</select>
<select id="selectHitCompetitionStudentInfoByUserId"
resultType="com.ruoyi.cms.domain.HitCompetitionStudentInfo" >
SELECT
hcsi.*,hu.virtual_score,hu.assay_score
FROM
hit_competition_student_info hcsi
LEFT JOIN hit_reg_info_user hu ON hu.user_id = hcsi.user_id
WHERE
hcsi.user_id = #{userId}
AND hcsi.create_time LIKE concat(#{year}, '%')
AND hu.create_time LIKE concat(#{year}, '%')
</select>
<insert id="insertHitCompetitionStudentInfo" parameterType="HitCompetitionStudentInfo" useGeneratedKeys="true" keyProperty="id">
insert into hit_competition_student_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="hitRegId != null">hit_reg_id,</if>
<if test="stuName != null and stuName != ''">stu_name,</if>
<if test="schoolName != null and schoolName != ''">school_name,</if>
<if test="collegeName != null and collegeName != ''">college_name,</if>
<if test="major != null and major != ''">major,</if>
<if test="division != null and division != ''">division,</if>
<if test="phoneNumber != null and phoneNumber != ''">phone_number,</if>
<if test="email != null">email,</if>
<if test="studentIdCard != null">student_id_card,</if>
<if test="trialsScore != null">trials_score,</if>
<if test="isPreliminary != null">is_preliminary,</if>
<if test="remark != null">remark,</if>
<if test="sex != null">sex,</if>
<if test="delFlag != null">del_flag,</if>
<if test="createTime != null">create_time,</if>
<if test="createBy != null">create_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="studentId != null">student_id,</if>
<if test="userId != null">user_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="hitRegId != null">#{hitRegId},</if>
<if test="stuName != null and stuName != ''">#{stuName},</if>
<if test="schoolName != null and schoolName != ''">#{schoolName},</if>
<if test="collegeName != null and collegeName != ''">#{collegeName},</if>
<if test="major != null and major != ''">#{major},</if>
<if test="division != null and division != ''">#{division},</if>
<if test="phoneNumber != null and phoneNumber != ''">#{phoneNumber},</if>
<if test="email != null">#{email},</if>
<if test="studentIdCard != null">#{studentIdCard},</if>
<if test="trialsScore != null">#{trialsScore},</if>
<if test="isPreliminary != null">#{isPreliminary},</if>
<if test="remark != null">#{remark},</if>
<if test="sex != null">#{sex},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createBy != null">#{createBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="studentId != null">#{studentId},</if>
<if test="userId != null">#{userId},</if>
</trim>
</insert>
<update id="updateHitCompetitionStudentInfo" parameterType="HitCompetitionStudentInfo">
update hit_competition_student_info
<trim prefix="SET" suffixOverrides=",">
<if test="hitRegId != null">hit_reg_id = #{hitRegId},</if>
<if test="studentId != null">student_id = #{studentId},</if>
<if test="stuName != null and stuName != ''">stu_name = #{stuName},</if>
<if test="schoolName != null and schoolName != ''">school_name = #{schoolName},</if>
<if test="collegeName != null and collegeName != ''">college_name = #{collegeName},</if>
<if test="major != null and major != ''">major = #{major},</if>
<if test="division != null and division != ''">division = #{division},</if>
<if test="phoneNumber != null and phoneNumber != ''">phone_number = #{phoneNumber},</if>
<if test="email != null">email = #{email},</if>
<if test="studentIdCard != null">student_id_card = #{studentIdCard},</if>
<if test="trialsScore != null">trials_score = #{trialsScore},</if>
<if test="isPreliminary != null">is_preliminary = #{isPreliminary},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="sex != null">sex = #{sex},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
</trim>
where id = #{id}
</update>
<update id="updateStudentByLessThan">
UPDATE hit_competition_student_info
SET is_preliminary = 1
WHERE school_name IN (
SELECT school_name
FROM (
SELECT school_name
FROM hit_competition_student_info
GROUP BY school_name
HAVING COUNT(*) &lt; 15
) AS temp
);
</update>
<delete id="deleteHitCompetitionStudentInfoById" parameterType="String">
delete from hit_competition_student_info where id = #{id}
</delete>
<delete id="deleteHitCompetitionStudentInfoByIds" parameterType="String">
delete from hit_competition_student_info where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>