123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188 |
- <?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.liang.dao.PrjContractDao">
- <resultMap type="com.liang.entity.PrjContract" id="PrjContractMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="htmc" column="HTMC" jdbcType="VARCHAR"/>
- <result property="wj" column="WJ" jdbcType="VARCHAR"/>
- <result property="htje" column="HTJE" jdbcType="NUMERIC"/>
- <result property="cjr" column="CJR" jdbcType="INTEGER"/>
- <result property="cjsj" column="CJSJ" jdbcType="TIMESTAMP"/>
- <result property="rws" column="RWS" jdbcType="INTEGER"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="PrjContractMap">
- select c.*, x.ZWMC as RWSMC, u.name as CJRXM
- from prj_Contract c
- left join prj_Project x on x.ID = c.RWS
- left join sys_user_info u on u.user_id = c.CJR
- where c.ID = #{id}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="PrjContractMap">
- select
- ID, HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL
- from prj_Contract
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="htmc != null and htmc != ''">
- and HTMC = #{htmc}
- </if>
- <if test="wj != null and wj != ''">
- and WJ = #{wj}
- </if>
- <if test="htje != null">
- and HTJE = #{htje}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="cjsj != null">
- and CJSJ = #{cjsj}
- </if>
- <if test="rws != null">
- and RWS = #{rws}
- </if>
- <if test="zbpc != null">
- and ZBPC = #{zbpc}
- </if>
- <if test="zxdw != null">
- and ZXDW = #{zxdw}
- </if>
- <if test="yszl != null and yszl != ''">
- and YSZL = #{yszl}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from prj_Contract
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="htmc != null and htmc != ''">
- and HTMC = #{htmc}
- </if>
- <if test="wj != null and wj != ''">
- and WJ = #{wj}
- </if>
- <if test="htje != null">
- and HTJE = #{htje}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="cjsj != null">
- and CJSJ = #{cjsj}
- </if>
- <if test="rws != null">
- and RWS = #{rws}
- </if>
- <if test="zbpc != null">
- and ZBPC = #{zbpc}
- </if>
- <if test="zxdw != null">
- and ZXDW = #{zxdw}
- </if>
- <if test="yszl != null and yszl != ''">
- and YSZL = #{yszl}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
- values (#{htmc}, #{wj}, #{htje}, #{cjr}, GETDATE(), #{rws},#{zbpc},#{zxdw},#{yszl})
- </insert>
- <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
- insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.htmc}, #{entity.wj}, #{entity.htje}, #{entity.cjr}, #{entity.cjsj}, #{entity.rws},#{entity.zbpc},#{entity.zxdw},#{entity.yszl})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into prj_Contract(HTMC, WJ, HTJE, CJR, CJSJ, RWS,ZBPC,ZXDW,YSZL)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.htmc}, #{entity.wj}, #{entity.htje}, #{entity.cjr}, #{entity.cjsj}, #{entity.rws},#{entity.zbpc},#{entity.zxdw},#{entity.yszl})
- </foreach>
- on duplicate key update
- HTMC = values(HTMC),
- WJ = values(WJ),
- HTJE = values(HTJE),
- CJR = values(CJR),
- CJSJ = values(CJSJ),
- RWS = values(RWS),
- ZBPC = values(ZBPC),
- ZXDW = values(ZXDW),
- YSZL = values(YSZL)
- </insert>
- <!--通过主键修改数据-->
- <update id="update">
- update prj_Contract
- set HTMC = #{htmc},
- WJ = #{wj},
- HTJE = #{htje},
- RWS = #{rws},
- YSZL = #{yszl},
- ZBPC = #{zbpc},
- ZXDW = #{zxdw}
- where ID = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete from prj_Contract where ID = #{id}
- </delete>
- <!--批量删除合同-->
- <delete id="batchDelete" parameterType="java.util.ArrayList">
- delete from prj_Contract
- where ID in
- <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
- #{item}
- </foreach>
- </delete>
- <!--合同列表-->
- <select id="getContractList" resultMap="PrjContractMap" parameterType="map">
- select c.*, x.ZWMC as RWSMC, u.name as CJRXM
- from prj_Contract c
- left join prj_Project x on x.ID = c.RWS
- left join sys_user_info u on u.user_id = c.CJR
- where 1 = 1
- <if test="htmc != null and htmc != ''">
- and c.HTMC like '%'+#{htmc}+'%'
- </if>
- <if test="rws != null and rws != ''">
- and c.RWS = #{rws}
- </if>
- <if test="rwsmc != null and rwsmc != ''">
- and x.ZWMC like '%'+#{rwsmc}+'%'
- </if>
- <choose>
- <when test="sortName != null and sortName != '' and sortOrder != null and sortOrder != ''">
- order by ${sortName} ${sortOrder}
- </when>
- <otherwise>
- order by c.ID asc
- </otherwise>
- </choose>
- </select>
- </mapper>
|