| <?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.matrix.system.oa.dao.OaFixedAssetsDao"> | 
|     <!-- 定义OaFixedAssets 的复杂关联map --> | 
|     <resultMap type="com.matrix.system.oa.bean.OaFixedAssets" id="OaFixedAssetsMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="createBy" column="create_by" /> | 
|         <result property="createTime" column="create_time" /> | 
|         <result property="updateBy" column="update_by" /> | 
|         <result property="updateTime" column="update_time" /> | 
|             <result property="assetsType" column="assets_type" /> | 
|             <result property="name" column="name" /> | 
|             <result property="number" column="number" /> | 
|             <result property="model" column="model" /> | 
|             <result property="department" column="department" /> | 
|             <result property="price" column="price" /> | 
|             <result property="count" column="count" /> | 
|             <result property="supplier" column="supplier" /> | 
|             <result property="user" column="user" /> | 
|             <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|      | 
|     <!-- 定义OaFixedAssets 的简单map  ,本map不添加其他的关联属性 --> | 
|     <resultMap type="com.matrix.system.oa.bean.OaFixedAssets" id="OaFixedAssetsSimpleMap"> | 
|         <id property="id" column="id" /> | 
|         <result property="createBy" column="create_by" /> | 
|         <result property="createTime" column="create_time" /> | 
|         <result property="updateBy" column="update_by" /> | 
|         <result property="updateTime" column="update_time" /> | 
|             <result property="assetsType" column="assets_type" /> | 
|             <result property="name" column="name" /> | 
|             <result property="number" column="number" /> | 
|             <result property="model" column="model" /> | 
|             <result property="department" column="department" /> | 
|             <result property="price" column="price" /> | 
|             <result property="count" column="count" /> | 
|             <result property="supplier" column="supplier" /> | 
|             <result property="user" column="user" /> | 
|             <result property="companyId" column="company_id" /> | 
|     </resultMap> | 
|      | 
|     <!-- 字段sql --> | 
|     <sql id="columns"> | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|             id, | 
|             assets_type, | 
|             name, | 
|             number, | 
|             model, | 
|             department, | 
|             price, | 
|             count, | 
|             supplier, | 
|             user, | 
|             company_id | 
|     </sql> | 
|      | 
|     <!-- 属性sql --> | 
|     <sql id="propertys"> | 
|         #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.id}, | 
|             #{item.assetsType}, | 
|             #{item.name}, | 
|             #{item.number}, | 
|             #{item.model}, | 
|             #{item.department}, | 
|             #{item.price}, | 
|             #{item.count}, | 
|             #{item.supplier}, | 
|             #{item.user}, | 
|             #{item.companyId} | 
|     </sql> | 
|      | 
|     <!-- where sql --> | 
|     <sql id="where_sql"> | 
|           | 
|          <if test="record!=null"> | 
|             <if test="(record.id!=null and record.id!='') or  (record.id!='' and record.id==0)  "> | 
|                 and id  = #{record.id}  | 
|             </if> | 
|             <if test="(record.assetsType!=null and record.assetsType!='') or  (record.assetsType!='' and record.assetsType==0)  "> | 
|                 and assets_type  like concat('%',#{record.assetsType},'%') | 
|             </if> | 
|             <if test="(record.name!=null and record.name!='') or  (record.name!='' and record.name==0)  "> | 
|                 and name  like concat('%',#{record.name},'%') | 
|             </if> | 
|             <if test="(record.number!=null and record.number!='') or  (record.number!='' and record.number==0)  "> | 
|                 and number like concat('%',#{record.number},'%') | 
|             </if> | 
|             <if test="(record.model!=null and record.model!='') or  (record.model!='' and record.model==0)  "> | 
|                 and model like concat('%',#{record.model},'%') | 
|             </if> | 
|             <if test="(record.department!=null and record.department!='') or  (record.department!='' and record.department==0)  "> | 
|                 and department  like concat('%',#{record.department},'%') | 
|             </if> | 
|             <if test="(record.price!=null and record.price!='') or  (record.price!='' and record.price==0)  "> | 
|                 and price  = #{record.price}  | 
|             </if> | 
|             <if test="(record.count!=null and record.count!='') or  (record.count!='' and record.count==0)  "> | 
|                 and count  = #{record.count}  | 
|             </if> | 
|             <if test="(record.supplier!=null and record.supplier!='') or  (record.supplier!='' and record.supplier==0)  "> | 
|                 and supplier  = #{record.supplier}  | 
|             </if> | 
|             <if test="(record.user!=null and record.user!='') or  (record.user!='' and record.user==0)  "> | 
|                 and user  = #{record.user}  | 
|             </if> | 
|             <if test="(record.companyId!=null and record.companyId!='') or  (record.companyId!='' and record.companyId==0)  "> | 
|                 and company_id  = #{record.companyId} | 
|             </if> | 
|         </if> | 
|           | 
|     </sql> | 
|      | 
|     <!--  插入方法   --> | 
|     <insert id="insert" parameterType="com.matrix.system.oa.bean.OaFixedAssets" | 
|         useGeneratedKeys="true" keyProperty="item.id"> | 
|         INSERT INTO oa_fixed_assets ( | 
|         create_by, | 
|         create_time, | 
|         update_by, | 
|         update_time, | 
|   | 
|         assets_type, | 
|         name, | 
|         number, | 
|         model, | 
|         department, | 
|         price, | 
|         count, | 
|         supplier, | 
|         user, | 
|         company_id | 
|         ) | 
|     VALUES ( | 
|             #{item.createBy}, | 
|         now(), | 
|         #{item.updateBy}, | 
|         now(), | 
|             #{item.assetsType}, | 
|             #{item.name}, | 
|             #{item.number}, | 
|             #{item.model}, | 
|             #{item.department}, | 
|             #{item.price}, | 
|             #{item.count}, | 
|             #{item.supplier}, | 
|             #{item.user}, | 
|             #{item.companyId} | 
|     ) | 
|     </insert> | 
|      | 
|      | 
|      | 
|     <!--  批量插入   --> | 
|     <insert id="batchInsert" parameterType="java.util.List"> | 
|         INSERT INTO oa_fixed_assets ( | 
|         <include refid="columns"></include>     | 
|         ) | 
|     VALUES  | 
|     <foreach collection="list" item="item" index="index" separator=",">( | 
|         <include refid="propertys"></include>     | 
|     )</foreach> | 
|     </insert> | 
|      | 
|      | 
|      | 
|      | 
|      | 
|     <!--  根据Map更新 部分更新   --> | 
|     <update id="updateByMap" parameterType="java.util.HashMap" > | 
|         UPDATE oa_fixed_assets | 
|         <set> | 
|             <if test="_parameter.containsKey('assetsType')"> | 
|                     assets_type = #{assetsType}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('name')"> | 
|                     name = #{name}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('number')"> | 
|                     number = #{number}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('model')"> | 
|                     model = #{model}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('department')"> | 
|                     department = #{department}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('price')"> | 
|                     price = #{price}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('count')"> | 
|                     count = #{count}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('supplier')"> | 
|                     supplier = #{supplier}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('user')"> | 
|                     user = #{user}, | 
|                 </if>         | 
|             <if test="_parameter.containsKey('companyId')"> | 
|                     company_id = #{companyId}, | 
|                 </if>         | 
|         </set> | 
|         WHERE id=#{id}  | 
|     </update>  | 
|      | 
|      | 
|     <!--  根据对象更新 部分更新   --> | 
|     <update id="updateByModel" parameterType="String"> | 
|         UPDATE oa_fixed_assets | 
|         <set> | 
|             <if test="record.assetsType != null and record.assetsType != '' "> | 
|                 assets_type  = #{record.assetsType},  | 
|             </if> | 
|             <if test="record.name != null and record.name != '' "> | 
|                 name  = #{record.name},  | 
|             </if> | 
|             <if test="record.number != null and record.number != '' "> | 
|                 number  = #{record.number},  | 
|             </if> | 
|             <if test="record.model != null and record.model != '' "> | 
|                 model  = #{record.model},  | 
|             </if> | 
|             <if test="record.department != null and record.department != '' "> | 
|                 department  = #{record.department},  | 
|             </if> | 
|             <if test="record.price != null "> | 
|                 price  = #{record.price},  | 
|             </if> | 
|             <if test="record.count != null "> | 
|                 count  = #{record.count},  | 
|             </if> | 
|             <if test="record.supplier != null and record.supplier != '' "> | 
|                 supplier  = #{record.supplier},  | 
|             </if> | 
|             <if test="record.user != null and record.user != '' "> | 
|                 user  = #{record.user},  | 
|             </if> | 
|             <if test="record.companyId != null and record.companyId != '' "> | 
|                 company_id  = #{record.companyId}, | 
|             </if> | 
|         </set> | 
|         WHERE id=#{record.id}  | 
|     </update> | 
|      | 
|     <!-- 批量删除 --> | 
|     <delete id="deleteByIds" parameterType="java.util.List"> | 
|         delete from oa_fixed_assets where  id in | 
|         <foreach collection="list" index="index" item="item" open="(" | 
|             separator="," close=")"> | 
|             #{item} | 
|         </foreach> | 
|     </delete> | 
|          | 
|     <!-- 根据id删除--> | 
|     <delete id="deleteById" parameterType="String"> | 
|         DELETE FROM oa_fixed_assets | 
|         where  id=#{id}  | 
|     </delete> | 
|      | 
|     <!-- 根据对象删除--> | 
|     <delete id="deleteByModel" parameterType="com.matrix.system.oa.bean.OaFixedAssets"> | 
|         DELETE FROM oa_fixed_assets | 
|         <where> | 
|         <include refid="where_sql" ></include> | 
|         </where> | 
|     </delete> | 
|      | 
|      | 
|      | 
|     <!-- 分页查询 --> | 
|     <select id="selectInPage" resultMap="OaFixedAssetsMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from oa_fixed_assets | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|         <if test="pageVo !=null"><!-- 判断pageVo对象是否为空 --> | 
|             <if test="pageVo.sort !=null  and pageVo.order !=null"> | 
|                 order by | 
|                 ${pageVo.sort} ${pageVo.order} | 
|             </if> | 
|             <if test="pageVo.offset >=0  and pageVo.limit >0"> | 
|                 limit | 
|                 #{pageVo.offset},#{pageVo.limit} | 
|             </if> | 
|         </if> | 
|     </select> | 
|      | 
|     <!-- 查询总条数 --> | 
|     <select id="selectTotalRecord" parameterType="long"   resultType="java.lang.Integer"> | 
|     select count(*) | 
|     from oa_fixed_assets | 
|         <where> | 
|            <include refid="where_sql"></include> | 
|         </where> | 
|     </select> | 
|   | 
|     <!-- 根据id查询--> | 
|     <select id="selectById" resultMap="OaFixedAssetsMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from oa_fixed_assets | 
|         where  id=#{id}  | 
|     </select>     | 
|      | 
|      | 
|     <!-- 根据id 锁表查询--> | 
|     <select id="selectForUpdate" resultMap="OaFixedAssetsMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from oa_fixed_assets | 
|         where  id=#{id}  | 
|         for update | 
|     </select>     | 
|      | 
|      | 
|      | 
|     <!-- 根据对象查询--> | 
|     <select id="selectByModel" resultMap="OaFixedAssetsMap"> | 
|         select  | 
|         <include refid="columns" ></include> | 
|         from oa_fixed_assets | 
|         <where> | 
|           <include refid="where_sql"></include> | 
|          </where> | 
|     </select> | 
| </mapper> |