<?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.gkhy.exam.system.mapper.ExCourseMapper">
|
<resultMap type="com.gkhy.exam.system.domain.ExCourse" id="ExCourseResult">
|
<result property="id" column="id" />
|
<result property="name" column="name" />
|
<result property="categoryId" column="category_id" />
|
<result property="status" column="status" />
|
<result property="sort" column="sort" />
|
<result property="logo" column="logo" />
|
<result property="introduce" column="introduce" />
|
<result property="state" column="state" />
|
<result property="delFlag" column="del_flag" />
|
<result property="companyId" column="company_id" />
|
<result property="privatize" column="privatize" />
|
<result property="message" column="message" />
|
<result property="version" column="version" />
|
<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" />
|
<result property="companyName" column="company_name" />
|
<result property="categoryName" column="category_name" />
|
<association property="period" javaType="java.lang.Long" select="getCoursePeriod" column="{courseId=id}"/>
|
</resultMap>
|
|
<sql id="selectCourseVo">
|
select a.id, a.name, a.category_id, a.status, a.logo,a.sort,a.introduce,a.state,a.company_id,a.message,
|
a.privatize,a.version, a.create_by, a.create_time, a.update_by, a.update_time, a.remark,b.name as company_name,c.name as category_name
|
from ex_course a
|
left join sys_company b on b.id=a.company_id
|
left join sys_category c on c.id=a.category_id
|
</sql>
|
|
<update id="deleteByCourseId">
|
update ex_course set del_flag=1 where id=#{courseId}
|
</update>
|
|
<select id="selectCourseList" resultMap="ExCourseResult">
|
<include refid="selectCourseVo"/>
|
<where>
|
and a.del_flag=0
|
<if test="name != null and name != ''">
|
AND a.name like concat('%', #{name}, '%')
|
</if>
|
<if test="categoryId != null ">
|
AND a.categoryId =#{categoryId}
|
</if>
|
<if test="status != null ">
|
AND a.status =#{status}
|
</if>
|
<if test="state != null ">
|
AND a.state =#{state}
|
</if>
|
<if test="privatize != null ">
|
AND a.privatize =#{privatize}
|
</if>
|
<if test="companyId != null ">
|
AND (a.company_id =#{companyId} or a.privatize=1)
|
</if>
|
</where>
|
order by a.id desc
|
</select>
|
|
<select id="selectCourseById" resultMap="ExCourseResult">
|
<include refid="selectCourseVo"/>
|
where a.id=#{courseId}
|
</select>
|
|
<select id="checkNameUnique" resultType="com.gkhy.exam.system.domain.ExCourse">
|
select id,name from ex_course where name=#{name} and del_flag=0
|
<if test="companyId!=null">
|
and company_id=#{companyId}
|
</if>
|
limit 1
|
</select>
|
|
<select id="selectCourseState" resultType="java.lang.Integer">
|
select state from ex_course where id=#{courseId}
|
</select>
|
|
<select id="selectCountByCategoryId" resultType="java.lang.Integer">
|
select count(1) from ex_course where category_id=#{categoryId} and del_flag=0
|
</select>
|
|
<select id="getCoursePeriod" resultType="java.lang.Long">
|
select sum(b.resource_length) from ex_course_chapter_period a
|
inner join ex_resource b on a.resource_id=b.id
|
where a.course_id=#{courseId}
|
</select>
|
</mapper>
|