<?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.yeejoin.amos.supervision.business.dao.mapper.RiskJudgmentItemMapper">

    <insert id="save" keyColumn="id" keyProperty="id"
            parameterType="com.yeejoin.amos.supervision.business.entity.mybatis.RiskJudgmentItemBo"
            useGeneratedKeys="true">
        insert into spc_risk_judgment_item
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="itemFlag != null">
                item_flag,
            </if>
            <if test="itemLevel != null">
                item_level,
            </if>
            <if test="itemType != null">
                item_type,
            </if>
            <if test="itemName != null">
                item_name,
            </if>
            <if test="itemParentId != null">
                item_parent_id,
            </if>
            <if test="itemCanCopy != null">
                item_can_copy,
            </if>
            <if test="selectName != null">
                select_name,
            </if>
            <if test="selectIsNeed != null">
                select_is_need,
            </if>
            <if test="selectIsRequired != null">
                select_is_required,
            </if>
            <if test="selectJson != null">
                select_json,
            </if>
            <if test="inputName != null">
                input_name,
            </if>
            <if test="inputType != null">
                input_type,
            </if>
            <if test="inputCanEdit != null">
                input_can_edit,
            </if>
            <if test="inputIsNeed != null">
                input_is_need,
            </if>
            <if test="inputIsRequired != null">
                input_is_required,
            </if>
            <if test="remarkIsNeed != null">
                remark_is_need,
            </if>
            <if test="remarkIsRequired != null">
                remark_is_required,
            </if>
            <if test="photoIsNeed != null">
                photo_is_need,
            </if>
            <if test="photoIsRequired != null">
                photo_is_required,
            </if>
            <if test="deleted != null">
                deleted,
            </if>
            <if test="createDate != null">
                create_date,
            </if>
            <if test="updateDate != null">
                update_date,
            </if>
            <if test="orgCode != null">
                org_code,
            </if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="itemFlag != null">
                #{itemFlag},
            </if>
            <if test="itemLevel != null">
                #{itemLevel},
            </if>
            <if test="itemType != null">
                #{itemType},
            </if>
            <if test="itemName != null">
                #{itemName},
            </if>
            <if test="itemParentId != null">
                #{itemParentId},
            </if>
            <if test="itemCanCopy != null">
                #{itemCanCopy},
            </if>
            <if test="selectName != null">
                #{selectName},
            </if>
            <if test="selectIsNeed != null">
                #{selectIsNeed},
            </if>
            <if test="selectIsRequired != null">
                #{selectIsRequired},
            </if>
            <if test="selectJson != null">
                #{selectJson},
            </if>
            <if test="inputName != null">
                #{inputName},
            </if>
            <if test="inputType != null">
                #{inputType},
            </if>
            <if test="inputCanEdit != null">
                #{inputCanEdit},
            </if>
            <if test="inputIsNeed != null">
                #{inputIsNeed},
            </if>
            <if test="inputIsRequired != null">
                #{inputIsRequired},
            </if>
            <if test="remarkIsNeed != null">
                #{remarkIsNeed},
            </if>
            <if test="remarkIsRequired != null">
                #{remarkIsRequired},
            </if>
            <if test="photoIsNeed != null">
                #{photoIsNeed},
            </if>
            <if test="photoIsRequired != null">
                #{photoIsRequired},
            </if>
            <if test="deleted != null">
                #{deleted},
            </if>
            <if test="createDate != null">
                #{createDate},
            </if>
            <if test="updateDate != null">
                #{updateDate},
            </if>
            <if test="orgCode != null">
                #{orgCode},
            </if>
        </trim>
    </insert>

    <update id="update" parameterType="com.yeejoin.amos.supervision.business.entity.mybatis.RiskJudgmentItemBo">
        update spc_risk_judgment_item
        <set>
            <if test="itemFlag != null">
                item_flag = #{itemFlag},
            </if>
            <if test="itemLevel != null">
                item_level = #{itemLevel},
            </if>
            <if test="itemType != null">
                item_type = #{itemType},
            </if>
            <if test="itemName != null">
                item_name = #{itemName},
            </if>
            <if test="itemParentId != null">
                item_parent_id = #{itemParentId},
            </if>
            <if test="itemCanCopy != null">
                item_can_copy = #{itemCanCopy},
            </if>
            <if test="selectName != null">
                select_name = #{selectName},
            </if>
            <if test="selectIsNeed != null">
                select_is_need = #{selectIsNeed},
            </if>
            <if test="selectIsRequired != null">
                select_is_required = #{selectIsRequired},
            </if>
            <if test="selectJson != null">
                select_json = #{selectJson},
            </if>
            <if test="inputName != null">
                input_name = #{inputName},
            </if>
            <if test="inputTye != null">
                input_type = #{inputTye},
            </if>
            <if test="inputCanEdit != null">
                input_can_edit = #{inputCanEdit},
            </if>
            <if test="inputIsNeed != null">
                input_is_need = #{inputIsNeed},
            </if>
            <if test="inputIsRequired != null">
                input_is_required = #{inputIsRequired},
            </if>
            <if test="remarkIsNeed != null">
                remark_is_need = #{remarkIsNeed},
            </if>
            <if test="remarkIsRequired != null">
                remark_is_required = #{remarkIsRequired},
            </if>
            <if test="photoIsNeed != null">
                photo_is_need = #{photoIsNeed},
            </if>
            <if test="photoIsRequired != null">
                photo_is_required = #{photoIsRequired},
            </if>
            <if test="deleted != null">
                deleted = #{deleted},
            </if>
            <if test="createDate != null">
                create_date = #{createDate},
            </if>
            <if test="updateDate != null">
                update_date = #{updateDate},
            </if>
            <if test="orgCode != null">
                org_code = #{orgCode},
            </if>
        </set>
        where id = #{id}
    </update>

    <select id="listAllItemByDepartmentCode" resultType="com.yeejoin.amos.supervision.business.entity.mybatis.RiskJudgmentItemBo">
        select
            *
        from
            spc_risk_judgment_item
        where
            deleted = 0
        and
            department_code = #{departmentCode}
    </select>
    <select id="findByItemId" resultType="com.yeejoin.amos.supervision.business.entity.mybatis.RiskJudgmentItemBo">
        select * from spc_risk_judgment_item where id = #{itemId}
    </select>

</mapper>