<?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.generator.mapper.front.FrontProjectModuleMapper">

    <resultMap type="FrontProjectModule" id="FrontProjectModuleResult">
        <id property="id" column="id" />
        <result property="projectId" column="project_id" />
        <result property="moduleId" column="module_id" />
        <result property="status" column="status" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="remark" column="remark" />
    </resultMap>

    <resultMap type="SysProjectModule" id="SysProjectModuleResult">
        <id property="id" column="id" />
        <result property="projectId" column="project_id" />
        <result property="moduleId" column="module_id" />
        <result property="status" column="status" />
        <result property="createTime" column="create_time" />
        <result property="updateTime" column="update_time" />
        <result property="remark" column="remark" />
    </resultMap>

    <select id="selectModulesByProjectId" parameterType="Long" resultMap="FrontProjectModuleResult">
        select id, project_id, module_id, status, create_time, update_time, remark
        from front_project_module
        where project_id = #{projectId}
          and status = '0'
        order by id asc
    </select>

    <select id="selectSysProjectModulesByProjectId" parameterType="Long" resultMap="SysProjectModuleResult">
        select id, project_id, module_id, status, create_time, update_time, remark
        from front_project_module
        where project_id = #{projectId}
          and status = '0'
        order by id asc
    </select>

    <insert id="insertFrontProjectModule" parameterType="FrontProjectModule" useGeneratedKeys="true" keyProperty="id">
        insert into front_project_module
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="projectId != null">project_id,</if>
            <if test="moduleId != null">module_id,</if>
            <if test="status != null">status,</if>
            <if test="createTime != null">create_time,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="remark != null">remark,</if>
        </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="projectId != null">#{projectId},</if>
            <if test="moduleId != null">#{moduleId},</if>
            <if test="status != null">#{status},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="remark != null">#{remark},</if>
        </trim>
    </insert>

    <delete id="deleteModulesByProjectId" parameterType="Long">
        delete from front_project_module where project_id = #{projectId}
    </delete>
</mapper>
