123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305 |
- <?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.BaseCompanyDao">
- <resultMap type="com.liang.entity.BaseCompany" id="BaseCompanyMap">
- <result property="id" column="ID" jdbcType="INTEGER"/>
- <result property="mc" column="MC" jdbcType="VARCHAR"/>
- <result property="szd" column="SZD" jdbcType="VARCHAR"/>
- <result property="txdz" column="TXDZ" jdbcType="VARCHAR"/>
- <result property="yzbm" column="YZBM" jdbcType="VARCHAR"/>
- <result property="dwxz" column="DWXZ" jdbcType="VARCHAR"/>
- <result property="lxr" column="LXR" jdbcType="INTEGER"/>
- <result property="xm" column="XM" jdbcType="VARCHAR"/>
- <result property="gddh" column="GDDH" jdbcType="VARCHAR"/>
- <result property="dzyj" column="DZYJ" jdbcType="VARCHAR"/>
- <result property="yddh" column="YDDH" jdbcType="VARCHAR"/>
- <result property="cz" column="CZ" jdbcType="VARCHAR"/>
- <result property="lxrxq" column="LXRXQ" jdbcType="VARCHAR"/>
- <result property="bm" column="BM" jdbcType="VARCHAR"/>
- <result property="fbm" column="FBM" jdbcType="VARCHAR"/>
- <result property="spx" column="SPX" jdbcType="VARCHAR"/>
- <result property="lx" column="LX" jdbcType="INTEGER"/>
- <result property="dwqc" column="DWQC" jdbcType="VARCHAR"/>
- <result property="sfkybg" column="SFKYBG" jdbcType="VARCHAR"/>
- <result property="xtdw" column="XTDW" jdbcType="INTEGER"/>
- <result property="cjr" column="CJR" jdbcType="INTEGER"/>
- <result property="px" column="PX" jdbcType="VARCHAR"/>
- </resultMap>
- <!--查询单个-->
- <select id="queryById" resultMap="BaseCompanyMap">
- select c.*, t.name as dwxzmc, p.xm as lxrxm
- from base_Company c
- left join base_CompanyType t on t.id = c.DWXZ
- left join base_Person p on p.id = c.lxr
- where c.ID = #{id}
- </select>
- <!--查询指定行数据-->
- <select id="queryAllByLimit" resultMap="BaseCompanyMap">
- select
- ID, MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX, DWQC, SFKYBG, XTDW, CJR,
- PX
- from base_Company
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="mc != null and mc != ''">
- and MC = #{mc}
- </if>
- <if test="szd != null and szd != ''">
- and SZD = #{szd}
- </if>
- <if test="txdz != null and txdz != ''">
- and TXDZ = #{txdz}
- </if>
- <if test="yzbm != null and yzbm != ''">
- and YZBM = #{yzbm}
- </if>
- <if test="dwxz != null and dwxz != ''">
- and DWXZ = #{dwxz}
- </if>
- <if test="lxr != null">
- and LXR = #{lxr}
- </if>
- <if test="xm != null and xm != ''">
- and XM = #{xm}
- </if>
- <if test="gddh != null and gddh != ''">
- and GDDH = #{gddh}
- </if>
- <if test="dzyj != null and dzyj != ''">
- and DZYJ = #{dzyj}
- </if>
- <if test="yddh != null and yddh != ''">
- and YDDH = #{yddh}
- </if>
- <if test="cz != null and cz != ''">
- and CZ = #{cz}
- </if>
- <if test="lxrxq != null">
- and LXRXQ = #{lxrxq}
- </if>
- <if test="bm != null and bm != ''">
- and BM = #{bm}
- </if>
- <if test="fbm != null and fbm != ''">
- and FBM = #{fbm}
- </if>
- <if test="spx != null and spx != ''">
- and SPX = #{spx}
- </if>
- <if test="lx != null">
- and LX = #{lx}
- </if>
- <if test="dwqc != null and dwqc != ''">
- and DWQC = #{dwqc}
- </if>
- <if test="sfkybg != null">
- and SFKYBG = #{sfkybg}
- </if>
- <if test="xtdw != null">
- and XTDW = #{xtdw}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="px != null and px != ''">
- and PX = #{px}
- </if>
- </where>
- limit #{pageable.offset}, #{pageable.pageSize}
- </select>
- <!--统计总行数-->
- <select id="count" resultType="java.lang.Long">
- select count(1)
- from base_Company
- <where>
- <if test="id != null">
- and ID = #{id}
- </if>
- <if test="mc != null and mc != ''">
- and MC = #{mc}
- </if>
- <if test="szd != null and szd != ''">
- and SZD = #{szd}
- </if>
- <if test="txdz != null and txdz != ''">
- and TXDZ = #{txdz}
- </if>
- <if test="yzbm != null and yzbm != ''">
- and YZBM = #{yzbm}
- </if>
- <if test="dwxz != null and dwxz != ''">
- and DWXZ = #{dwxz}
- </if>
- <if test="lxr != null">
- and LXR = #{lxr}
- </if>
- <if test="xm != null and xm != ''">
- and XM = #{xm}
- </if>
- <if test="gddh != null and gddh != ''">
- and GDDH = #{gddh}
- </if>
- <if test="dzyj != null and dzyj != ''">
- and DZYJ = #{dzyj}
- </if>
- <if test="yddh != null and yddh != ''">
- and YDDH = #{yddh}
- </if>
- <if test="cz != null and cz != ''">
- and CZ = #{cz}
- </if>
- <if test="lxrxq != null">
- and LXRXQ = #{lxrxq}
- </if>
- <if test="bm != null and bm != ''">
- and BM = #{bm}
- </if>
- <if test="fbm != null and fbm != ''">
- and FBM = #{fbm}
- </if>
- <if test="spx != null and spx != ''">
- and SPX = #{spx}
- </if>
- <if test="lx != null">
- and LX = #{lx}
- </if>
- <if test="dwqc != null and dwqc != ''">
- and DWQC = #{dwqc}
- </if>
- <if test="sfkybg != null">
- and SFKYBG = #{sfkybg}
- </if>
- <if test="xtdw != null">
- and XTDW = #{xtdw}
- </if>
- <if test="cjr != null">
- and CJR = #{cjr}
- </if>
- <if test="px != null and px != ''">
- and PX = #{px}
- </if>
- </where>
- </select>
- <!--新增所有列-->
- <insert id="insert" keyProperty="id" useGeneratedKeys="true">
- if not exists (select * from base_Company where dwqc = #{dwqc})
- insert into base_Company (MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX, DWQC, SFKYBG, XTDW, CJR, PX)
- values (#{mc}, #{szd}, #{txdz}, #{yzbm}, #{dwxz}, #{lxr}, #{xm},#{gddh}, #{dzyj}, #{yddh}, #{cz}, #{lxrxq}, #{bm}, #{fbm},
- #{spx}, #{lx}, #{dwqc}, #{sfkybg}, #{xtdw}, #{cjr}, #{px})
- </insert>
- <insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_Company(MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX,
- DWQC, SFKYBG, XTDW, CJR, PX)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mc}, #{entity.szd}, #{entity.txdz}, #{entity.yzbm}, #{entity.dwxz}, #{entity.lxr}, #{entity.xm},
- #{entity.gddh}, #{entity.dzyj}, #{entity.yddh}, #{entity.cz}, #{entity.lxrxq}, #{entity.bm}, #{entity.fbm},
- #{entity.spx}, #{entity.lx}, #{entity.dwqc}, #{entity.sfkybg}, #{entity.xtdw}, #{entity.cjr}, #{entity.px})
- </foreach>
- </insert>
- <insert id="insertOrUpdateBatch" keyProperty="id" useGeneratedKeys="true">
- insert into base_Company(MC, SZD, TXDZ, YZBM, DWXZ, LXR, XM, GDDH, DZYJ, YDDH, CZ, LXRXQ, BM, FBM, SPX, LX,
- DWQC, SFKYBG, XTDW, CJR, PX)
- values
- <foreach collection="entities" item="entity" separator=",">
- (#{entity.mc}, #{entity.szd}, #{entity.txdz}, #{entity.yzbm}, #{entity.dwxz}, #{entity.lxr}, #{entity.xm},
- #{entity.gddh}, #{entity.dzyj}, #{entity.yddh}, #{entity.cz}, #{entity.lxrxq}, #{entity.bm}, #{entity.fbm},
- #{entity.spx}, #{entity.lx}, #{entity.dwqc}, #{entity.sfkybg}, #{entity.xtdw}, #{entity.cjr}, #{entity.px})
- </foreach>
- on duplicate key update
- MC = values(MC),
- SZD = values(SZD),
- TXDZ = values(TXDZ),
- YZBM = values(YZBM),
- DWXZ = values(DWXZ),
- LXR = values(LXR),
- XM = values(XM),
- GDDH = values(GDDH),
- DZYJ = values(DZYJ),
- YDDH = values(YDDH),
- CZ = values(CZ),
- LXRXQ = values(LXRXQ),
- BM = values(BM),
- FBM = values(FBM),
- SPX = values(SPX),
- LX = values(LX),
- DWQC = values(DWQC),
- SFKYBG = values(SFKYBG),
- XTDW = values(XTDW),
- CJR = values(CJR),
- PX = values(PX)
- </insert>
- <!--通过主键修改数据-->
- <update id="update" parameterType="com.liang.entity.BaseCompany">
- update base_Company
- set BM = #{bm},
- MC = #{mc},
- DWQC = #{dwqc},
- LX = #{lx},
- SZD = #{szd},
- TXDZ = #{txdz},
- YZBM = #{yzbm},
- DWXZ = #{dwxz},
- LXR = #{lxr},
- XM = #{xm},
- GDDH = #{gddh},
- DZYJ = #{dzyj},
- YDDH = #{yddh},
- CZ = #{cz},
- PX = #{px}
- where ID = #{id}
- </update>
- <!--通过主键删除-->
- <delete id="deleteById">
- delete
- from base_Company
- where ID = #{id}
- </delete>
- <!--分页查询-->
- <select id="getBaseCompanyList" resultMap="BaseCompanyMap" parameterType="map">
- select c.ID, c.MC, c.DWQC,c.SZD, p.XM as LXRXM,
- case LX when '1' then '内部单位' when '2' then '外部单位' else '' end as LXMC
- from base_Company c
- left join base_Person p on p.ID = c.LXR
- where 1=1
- <if test="mc != null and mc != ''">
- and c.MC like '%'+#{mc}+'%'
- </if>
- <if test="dwqc != null and dwqc != ''">
- and c.DWQC like '%'+#{dwqc}+'%'
- </if>
- order by c.ID asc
- </select>
- <select id="list" resultMap="BaseCompanyMap">
- select * from base_Company
- </select>
- <!--校验单位全称是否唯一-->
- <select id="checkCompanyUnique" resultType="java.lang.Integer" parameterType="java.lang.String">
- select count(*) from base_Company where DWQC = #{DWQC}
- </select>
- <!--批量删除单位-->
- <delete id="batchDelete" parameterType="java.util.ArrayList">
- delete from base_Company
- where ID in
- <foreach item="item" index="index" collection="idList" open = "(" separator = "," close = ")">
- #{item}
- </foreach>
- </delete>
- </mapper>
|