一、常用SQL

1. 批量添加

  1. /**
  2. * 批量保存 关系
  3. * @param addList
  4. */
  5. void batchAdd(List<ObjectCommissionOfficeRelationship> addList);
  1. <insert id="batchAdd" useGeneratedKeys="true" keyProperty="id" parameterType="java.util.List">
  2. INSERT INTO tb_object_commission_office_relationship (id,commissionOfficeId, objectId, createUserId, createTime) VALUES
  3. <foreach collection="list" index="index" item="item" separator=",">
  4. (#{item.id},#{item.commissionOfficeId},#{item.objectId},#{item.createUserId},#{item.createTime})
  5. </foreach>
  6. </insert>

2. 根据ID集合查询数据

  1. /**
  2. * 根据id集合查询对象信息
  3. *
  4. * @param commissionOfficeIds
  5. * @return
  6. */
  7. List<ObjectCommissionOfficeRelationship> getObjectsByCommissionOfficeIds(List<String> commissionOfficeIds);
  1. <select id="getObjectsByCommissionOfficeIds" parameterType="java.util.List" resultType="net.longjin.objectlibrary.entitys.objectLibrary.ObjectCommissionOfficeRelationship">
  2. SELECT * FROM tb_object_commission_office_relationship WHERE commissionOfficeId IN
  3. <foreach collection="list" item="coId" open="(" close=")" separator=",">
  4. #{coId}
  5. </foreach>
  6. </select>