|
|
@@ -0,0 +1,125 @@
|
|
|
+<?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.siwei.apply.mapper.ProjectImmobileCodeMapper">
|
|
|
+
|
|
|
+ <!-- 结果映射 -->
|
|
|
+ <resultMap id="BaseResultMap" type="com.siwei.apply.domain.ProjectImmobileCode">
|
|
|
+ <id property="id" column="id"/>
|
|
|
+ <result property="projectId" column="project_id"/>
|
|
|
+ <result property="businessId" column="business_id"/>
|
|
|
+ <result property="code" column="code"/>
|
|
|
+ <result property="validFlag" column="valid_flag"/>
|
|
|
+ <result property="createdAt" column="created_at"/>
|
|
|
+ <result property="updatedAt" column="updated_at"/>
|
|
|
+ </resultMap>
|
|
|
+
|
|
|
+ <!-- 基础查询字段 -->
|
|
|
+ <sql id="Base_Column_List">
|
|
|
+ id, project_id, business_id, code, valid_flag, created_at, updated_at
|
|
|
+ </sql>
|
|
|
+
|
|
|
+ <!-- 根据ID查询 -->
|
|
|
+ <select id="selectById" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_immobile_code
|
|
|
+ WHERE id = #{id}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据项目ID查询(多条) -->
|
|
|
+ <select id="selectByProjectId" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_immobile_code
|
|
|
+ WHERE project_id = #{projectId}
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据业务ID查询(只返回一条) -->
|
|
|
+ <select id="selectByBusinessId" resultMap="BaseResultMap" parameterType="String">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_immobile_code
|
|
|
+ WHERE business_id = #{businessId}
|
|
|
+ LIMIT 1
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 根据业务ID列表查询 -->
|
|
|
+ <select id="selectByBusinessIdList" resultMap="BaseResultMap" parameterType="List">
|
|
|
+ SELECT
|
|
|
+ <include refid="Base_Column_List"/>
|
|
|
+ FROM t_project_immobile_code
|
|
|
+ <where>
|
|
|
+ <if test="businessIdList != null and businessIdList.size() > 0">
|
|
|
+ AND business_id IN
|
|
|
+ <foreach collection="businessIdList" item="id" open="(" separator="," close=")">
|
|
|
+ #{id}
|
|
|
+ </foreach>
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <!-- 插入记录 -->
|
|
|
+ <insert id="insert" parameterType="com.siwei.apply.domain.ProjectImmobileCode">
|
|
|
+ INSERT INTO t_project_immobile_code (
|
|
|
+ id,
|
|
|
+ project_id,
|
|
|
+ business_id,
|
|
|
+ code,
|
|
|
+ valid_flag,
|
|
|
+ created_at,
|
|
|
+ updated_at
|
|
|
+ ) VALUES (
|
|
|
+ #{id},
|
|
|
+ #{projectId},
|
|
|
+ #{businessId},
|
|
|
+ #{code},
|
|
|
+ #{validFlag},
|
|
|
+ #{createdAt},
|
|
|
+ #{updatedAt}
|
|
|
+ )
|
|
|
+ </insert>
|
|
|
+
|
|
|
+ <!-- 根据业务ID更新记录(更新 code, valid_flag, updated_at) -->
|
|
|
+ <update id="update" parameterType="com.siwei.apply.domain.ProjectImmobileCode">
|
|
|
+ UPDATE t_project_immobile_code
|
|
|
+ SET code = #{code},
|
|
|
+ valid_flag = #{validFlag},
|
|
|
+ updated_at = #{updatedAt}
|
|
|
+ WHERE business_id = #{businessId}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据ID更新记录(可选字段更新) -->
|
|
|
+ <update id="updateById" parameterType="com.siwei.apply.domain.ProjectImmobileCode">
|
|
|
+ UPDATE t_project_immobile_code
|
|
|
+ <set>
|
|
|
+ <if test="projectId != null">project_id = #{projectId},</if>
|
|
|
+ <if test="businessId != null">business_id = #{businessId},</if>
|
|
|
+ <if test="code != null">code = #{code},</if>
|
|
|
+ <if test="validFlag != null">valid_flag = #{validFlag},</if>
|
|
|
+ <if test="updatedAt != null">updated_at = #{updatedAt}</if>
|
|
|
+ </set>
|
|
|
+ WHERE id = #{id}
|
|
|
+ </update>
|
|
|
+
|
|
|
+ <!-- 根据项目ID删除 -->
|
|
|
+ <delete id="deleteByProjectId" parameterType="String">
|
|
|
+ DELETE FROM t_project_immobile_code WHERE project_id = #{projectId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 根据业务ID删除,且排除指定ID的记录 -->
|
|
|
+ <delete id="deleteByBusinessIdAndIdNotEqual" parameterType="map">
|
|
|
+ DELETE FROM t_project_immobile_code
|
|
|
+ WHERE business_id = #{businessId}
|
|
|
+ AND id != #{id}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+ <!-- 根据业务ID删除 -->
|
|
|
+ <delete id="deleteByBusinessId" parameterType="String">
|
|
|
+ DELETE FROM t_project_immobile_code WHERE business_id = #{businessId}
|
|
|
+ </delete>
|
|
|
+
|
|
|
+</mapper>
|
|
|
+
|