<?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="cn.iocoder.yudao.module.jx.mapper.SopeNessMapper">

    <resultMap type="cn.iocoder.yudao.module.jx.domain.SopeNess" id="SopeNessResult">
        <result property="id"    column="id"    />
        <result property="deptId"    column="dept_id"    />
        <result property="createTime"    column="create_time"    />
        <result property="creator"    column="creator"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updater"    column="updater"    />
        <result property="businessType"    column="business_type"    />
        <result property="description"    column="description"    />
        <result property="licenseNumber"    column="license_number"    />
        <result property="licenseIssueDate"    column="license_issue_date"    />
        <result property="licenseExpiryDate"    column="license_expiry_date"    />
        <result property="price"    column="price"    />
        <result property="duration"    column="duration"    />
        <result property="notes"    column="notes"    />
        <result property="licenseCover"    column="license_cover"    />
    </resultMap>

    <sql id="selectSopeNessVo">
        select * from sope_ness
    </sql>

    <select id="selectSopeNessList" parameterType="cn.iocoder.yudao.module.jx.domain.SopeNess" resultMap="SopeNessResult">
        <include refid="selectSopeNessVo"/>
        <where>
            deleted = 0
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId} </if>
            <if test="entity.businessType != null  and entity.businessType != ''"> and business_type like concat('%', #{entity.businessType}, '%')</if>
            <if test="entity.description != null  and entity.description != ''"> and description = #{entity.description}</if>
            <if test="entity.licenseNumber != null  and licenseNumber != ''"> and license_number = #{entity.licenseNumber}</if>
            <if test="entity.licenseIssueDate != null "> and license_issue_date = #{entity.licenseIssueDate}</if>
            <if test="entity.licenseExpiryDate != null "> and license_expiry_date = #{entity.licenseExpiryDate}</if>
            <if test="entity.price != null "> and price = #{entity.price}</if>
            <if test="entity.duration != null  and entity.duration != ''"> and duration = #{entity.duration}</if>
            <if test="entity.notes != null  and entity.notes != ''"> and notes = #{notes}</if>
            <if test="entity.licenseCover != null  and entity.licenseCover != ''"> and license_cover = #{entity.licenseCover}</if>
            or deleted = 0 and dept_id = 100
            <if test="entity.deptId != null "> and dept_id = #{entity.deptId} </if>
            <if test="entity.businessType != null  and entity.businessType != ''"> and business_type like concat('%', #{entity.businessType}, '%')</if>
            <if test="entity.description != null  and entity.description != ''"> and description = #{entity.description}</if>
            <if test="entity.licenseNumber != null  and licenseNumber != ''"> and license_number = #{entity.licenseNumber}</if>
            <if test="entity.licenseIssueDate != null "> and license_issue_date = #{entity.licenseIssueDate}</if>
            <if test="entity.licenseExpiryDate != null "> and license_expiry_date = #{entity.licenseExpiryDate}</if>
            <if test="entity.price != null "> and price = #{entity.price}</if>
            <if test="entity.duration != null  and entity.duration != ''"> and duration = #{entity.duration}</if>
            <if test="entity.notes != null  and entity.notes != ''"> and notes = #{notes}</if>
            <if test="entity.licenseCover != null  and entity.licenseCover != ''"> and license_cover = #{entity.licenseCover}</if>
        </where>
    </select>

    <select id="selectSopeNessById" parameterType="Long" resultMap="SopeNessResult">
        <include refid="selectSopeNessVo"/>
        where id = #{id}
    </select>

    <insert id="insertSopeNess" parameterType="cn.iocoder.yudao.module.jx.domain.SopeNess" useGeneratedKeys="true" keyProperty="id">
        insert into sope_ness
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="deptId != null">dept_id,</if>
            <if test="createTime != null">create_time,</if>
            <if test="creator != null">creator,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updater != null">updater,</if>
            <if test="businessType != null and businessType != ''">business_type,</if>
            <if test="description != null">description,</if>
            <if test="licenseNumber != null">license_number,</if>
            <if test="licenseIssueDate != null">license_issue_date,</if>
            <if test="licenseExpiryDate != null">license_expiry_date,</if>
            <if test="price != null">price,</if>
            <if test="duration != null">duration,</if>
            <if test="notes != null">notes,</if>
            <if test="licenseCover != null">license_cover,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="deptId != null">#{deptId},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="creator != null">#{creator},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updater != null">#{updater},</if>
            <if test="businessType != null and businessType != ''">#{businessType},</if>
            <if test="description != null">#{description},</if>
            <if test="licenseNumber != null">#{licenseNumber},</if>
            <if test="licenseIssueDate != null">#{licenseIssueDate},</if>
            <if test="licenseExpiryDate != null">#{licenseExpiryDate},</if>
            <if test="price != null">#{price},</if>
            <if test="duration != null">#{duration},</if>
            <if test="notes != null">#{notes},</if>
            <if test="licenseCover != null">#{licenseCover},</if>
         </trim>
    </insert>

    <update id="updateSopeNess" parameterType="cn.iocoder.yudao.module.jx.domain.SopeNess">
        update sope_ness
        <trim prefix="SET" suffixOverrides=",">
            <if test="deptId != null">dept_id = #{deptId},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="creator != null">creator = #{creator},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updater != null">updater = #{updater},</if>
            <if test="businessType != null and businessType != ''">business_type = #{businessType},</if>
            <if test="description != null">description = #{description},</if>
            <if test="licenseNumber != null">license_number = #{licenseNumber},</if>
            <if test="licenseIssueDate != null">license_issue_date = #{licenseIssueDate},</if>
            <if test="licenseExpiryDate != null">license_expiry_date = #{licenseExpiryDate},</if>
            <if test="price != null">price = #{price},</if>
            <if test="duration != null">duration = #{duration},</if>
            <if test="notes != null">notes = #{notes},</if>
            <if test="licenseCover != null">license_cover = #{licenseCover},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteSopeNessById" parameterType="Long">
        delete from sope_ness where id = #{id}
    </delete>

    <delete id="deleteSopeNessByIds" parameterType="String">
        delete from sope_ness where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>
</mapper>
