CompanyMapper.xml 11.7 KB
<?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.huaheng.pc.config.company.mapper.CompanyMapper">
  <resultMap id="BaseResultMap" type="com.huaheng.pc.config.company.domain.Company">
    <!--@mbg.generated-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="code" jdbcType="VARCHAR" property="code" />
    <result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" />
    <result column="name" jdbcType="VARCHAR" property="name" />
    <result column="attentionTo" jdbcType="VARCHAR" property="attentionTo" />
    <result column="address1" jdbcType="VARCHAR" property="address1" />
    <result column="address2" jdbcType="VARCHAR" property="address2" />
    <result column="district" jdbcType="VARCHAR" property="district" />
    <result column="city" jdbcType="VARCHAR" property="city" />
    <result column="province" jdbcType="VARCHAR" property="province" />
    <result column="country" jdbcType="VARCHAR" property="country" />
    <result column="postalCode" jdbcType="VARCHAR" property="postalCode" />
    <result column="phoneNum" jdbcType="VARCHAR" property="phoneNum" />
    <result column="mobile" jdbcType="VARCHAR" property="mobile" />
    <result column="email" jdbcType="VARCHAR" property="email" />
    <result column="shipmentPrefix" jdbcType="VARCHAR" property="shipmentPrefix" />
    <result column="receiptPrefix" jdbcType="VARCHAR" property="receiptPrefix" />
    <result column="nameEn" jdbcType="VARCHAR" property="nameEn" />
    <result column="printDocAtChecked" jdbcType="INTEGER" property="printDocAtChecked" />
    <result column="hostInterfaceType" jdbcType="VARCHAR" property="hostInterfaceType" />
    <result column="created" jdbcType="TIMESTAMP" property="created" />
    <result column="createdBy" jdbcType="VARCHAR" property="createdBy" />
    <result column="lastUpdated" jdbcType="TIMESTAMP" property="lastUpdated" />
    <result column="lastUpdatedBy" jdbcType="VARCHAR" property="lastUpdatedBy" />
    <result column="version" jdbcType="INTEGER" property="version" />
    <result column="userDef1" jdbcType="VARCHAR" property="userDef1" />
    <result column="userDef2" jdbcType="VARCHAR" property="userDef2" />
    <result column="userDef3" jdbcType="VARCHAR" property="userDef3" />
    <result column="userDef4" jdbcType="VARCHAR" property="userDef4" />
    <result column="userDef5" jdbcType="VARCHAR" property="userDef5" />
    <result column="userDef6" jdbcType="VARCHAR" property="userDef6" />
    <result column="userDef7" jdbcType="VARCHAR" property="userDef7" />
    <result column="userDef8" jdbcType="VARCHAR" property="userDef8" />
    <result column="processStamp" jdbcType="VARCHAR" property="processStamp" />
    <result column="deleted" jdbcType="BIT" property="deleted" />
  </resultMap>

  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, code, warehouseCode, `name`, attentionTo, address1, address2, district, city, 
    province, country, postalCode, phoneNum, mobile, email, shipmentPrefix, receiptPrefix, 
    nameEn, printDocAtChecked, hostInterfaceType, created, createdBy, lastUpdated, lastUpdatedBy, 
    version, userDef1, userDef2, userDef3, userDef4, userDef5, userDef6, userDef7, userDef8, 
    processStamp,deleted
  </sql>

  <select id="loginGetCompany" resultType="com.huaheng.pc.config.company.domain.Company">
		SELECT c.id, c.name, c.code
		FROM sys_user_company suc
		INNER JOIN company c ON  suc.companyId = c.id AND suc.userId = #{userId}
		INNER JOIN warehouse_company wc ON wc.companyId=c.id AND wc.warehouseCode = #{warehouseCode}
  </select>

  <select id="selectCompanyByUserId" resultType="com.huaheng.pc.config.company.domain.Company">
		SELECT c.id, c.name, c.code
		FROM sys_user_company suc
		INNER JOIN company c ON  suc.companyId = c.id AND suc.userId = #{userId}
		INNER JOIN warehouse_company wc ON wc.companyId=c.id AND wc.warehouseCode = #{warehouseCode}
  </select>

    <select id="selectByWarehouseCode" resultType="com.huaheng.pc.config.company.domain.Company">
        select c.id , c.code, c.name, c.warehouseCode, c.deleted
        from company c
        INNER JOIN warehouse_company wc ON c.id = wc.companyId
        where c.warehouseCode = #{warehouseCode}
  </select>

  <select id="selectListEntityByEqual" resultType="com.huaheng.pc.config.company.domain.Company">
    SELECT id, code, warehouseCode, `name`, attentionTo, address1, address2, district, city,
    province, country, postalCode, phoneNum, mobile, email, created, createdBy, lastUpdated, lastUpdatedBy,
    version, userDef1, userDef2, userDef3, processStamp
    FROM company
    <where>
      <if test="id != null">
        AND id = #{id}
      </if>
      <if test="code != null">
        AND code = #{code}
      </if>
      <if test="name != null">
        AND name = #{name}
      </if>
      <if test="address1 != null">
        AND address1 = #{address1}
      </if>
      <if test="address2 != null">
        AND address2 = #{address2}
      </if>
      <if test="city != null">
        AND city = #{city}
      </if>
      <if test="province != null">
        AND province = #{province}
      </if>
      <if test="country != null">
        AND country = #{country}
      </if>
      <if test="postalCode != null">
        AND postalCode = #{postalCode}
      </if>
      <if test="attentionTo != null">
        AND attentionTo = #{attentionTo}
      </if>
      <if test="phoneNum != null">
        AND phoneNum = #{phoneNum}
      </if>
      <if test="mobile != null">
        AND mobile = #{mobile}
      </if>
      <if test="email != null">
        AND email = #{email}
      </if>
      <if test="created != null">
        AND created = #{created}
      </if>
      <if test="createdBy != null">
        AND createdBy = #{createdBy}
      </if>
      <if test="lastUpdated != null">
        AND lastUpdated = #{lastUpdated}
      </if>
      <if test="lastUpdatedBy != null">
        AND lastUpdatedBy = #{lastUpdatedBy}
      </if>
      <if test="deleted != null">
        AND deleted = #{deleted}
      </if>
      <if test="userDef1 != null">
        AND userDef1 = #{userDef1}
      </if>
      <if test="userDef2 != null">
        AND userDef2 = #{userDef2}
      </if>
      <if test="userDef3 != null">
        AND userDef3 = #{userDef3}
      </if>
    </where>
  </select>

  <insert id="insertReturnId" parameterType="com.huaheng.pc.config.company.domain.Company" keyProperty="id" useGeneratedKeys="true" >
    INSERT INTO company
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="code != null">
        code,
      </if>
      <if test="warehouseCode != null">
        warehouseCode,
      </if>
      <if test="name != null">
        name,
      </if>
      <if test="attentionTo != null">
        attentionTo,
      </if>
      <if test="address1 != null">
        address1,
      </if>
      <if test="address2 != null">
        address2,
      </if>
      <if test="district != null">
        district,
      </if>
      <if test="city != null">
        city,
      </if>
      <if test="province != null">
        province,
      </if>
      <if test="country != null">
        country,
      </if>
      <if test="postalCode != null">
        postalCode,
      </if>
      <if test="phoneNum != null">
        phoneNum,
      </if>
      <if test="mobile != null">
        mobile,
      </if>
      <if test="email != null">
        email,
      </if>
      <if test="shipmentPrefix != null">
        shipmentPrefix,
      </if>
      <if test="receiptPrefix != null">
        receiptPrefix,
      </if>
      <if test="nameEn != null">
        nameEn,
      </if>
      <if test="printDocAtChecked != null">
        printDocAtChecked,
      </if>
      <if test="hostInterfaceType != null">
        hostInterfaceType,
      </if>
      <if test="created != null">
        created,
      </if>
      <if test="createdBy != null">
        createdBy,
      </if>
      <if test="lastUpdated != null">
        lastUpdated,
      </if>
      <if test="lastUpdatedBy != null">
        lastUpdatedBy,
      </if>
      <if test="version != null">
        version,
      </if>
      <if test="userDef1 != null">
        userDef1,
      </if>
      <if test="userDef2 != null">
        userDef2,
      </if>
      <if test="userDef3 != null">
        userDef3,
      </if>
      <if test="userDef4 != null">
        userDef4,
      </if>
      <if test="userDef5 != null">
        userDef5,
      </if>
      <if test="userDef6 != null">
        userDef6,
      </if>
      <if test="userDef7 != null">
        userDef7,
      </if>
      <if test="userDef8 != null">
        userDef8,
      </if>
      <if test="processStamp != null">
        processStamp,
      </if>
      <if test="deleted != null">
        deleted,
      </if>
    </trim>
    <trim prefix=" values (" suffix=")" suffixOverrides=",">
      <if test="code != null">
        #{code, jdbcType=VARCHAR},
      </if>
      <if test="warehouseCode != null">
        #{warehouseCode, jdbcType=VARCHAR},
      </if>
      <if test="name != null">
        #{name, jdbcType=VARCHAR},
      </if>
      <if test="attentionTo != null">
        #{attentionTo, jdbcType=VARCHAR},
      </if>
      <if test="address1 != null">
        #{address1, jdbcType=VARCHAR},
      </if>
      <if test="address2 != null">
        #{address2, jdbcType=VARCHAR},
      </if>
      <if test="district != null">
        #{district, jdbcType=VARCHAR},
      </if>
      <if test="city != null">
        #{city, jdbcType=VARCHAR},
      </if>
      <if test="province != null">
        #{province, jdbcType=VARCHAR},
      </if>
      <if test="country != null">
        #{country, jdbcType=VARCHAR},
      </if>
      <if test="postalCode != null">
        #{postalCode, jdbcType=VARCHAR},
      </if>
      <if test="phoneNum != null">
        #{phoneNum, jdbcType=VARCHAR},
      </if>
      <if test="mobile != null">
        #{mobile, jdbcType=VARCHAR},
      </if>
      <if test="email != null">
        #{email, jdbcType=VARCHAR},
      </if>
      <if test="shipmentPrefix != null">
        #{shipmentPrefix, jdbcType=VARCHAR},
      </if>
      <if test="receiptPrefix != null">
        #{receiptPrefix, jdbcType=VARCHAR},
      </if>
      <if test="nameEn != null">
        #{nameEn, jdbcType=VARCHAR},
      </if>
      <if test="printDocAtChecked != null">
        #{printDocAtChecked, jdbcType=INTEGER},
      </if>
      <if test="hostInterfaceType != null">
        #{hostInterfaceType, jdbcType=VARCHAR},
      </if>
      <if test="created != null">
        #{created, jdbcType=TIMESTAMP},
      </if>
      <if test="createdBy != null">
        #{createdBy, jdbcType=VARCHAR},
      </if>
      <if test="lastUpdated != null">
        #{lastUpdated, jdbcType=TIMESTAMP},
      </if>
      <if test="lastUpdatedBy != null">
        #{lastUpdatedBy, jdbcType=VARCHAR},
      </if>
      <if test="version != null">
        #{version, jdbcType=INTEGER},
      </if>
      <if test="userDef1 != null">
        #{userDef1, jdbcType=VARCHAR},
      </if>
      <if test="userDef2 != null">
        #{userDef2, jdbcType=VARCHAR},
      </if>
      <if test="userDef3 != null">
        #{userDef3, jdbcType=VARCHAR},
      </if>
      <if test="userDef4 != null">
        #{userDef4, jdbcType=VARCHAR},
      </if>
      <if test="userDef5 != null">
        #{userDef5, jdbcType=VARCHAR},
      </if>
      <if test="userDef6 != null">
        #{userDef6, jdbcType=VARCHAR},
      </if>
      <if test="userDef7 != null">
        #{userDef7, jdbcType=VARCHAR},
      </if>
      <if test="userDef8 != null">
        #{userDef8, jdbcType=VARCHAR},
      </if>
      <if test="processStamp != null">
        #{processStamp, jdbcType=VARCHAR},
      </if>
      <if test="deleted != null">
        #{deleted, jdbcType=BIT},
      </if>
    </trim>
  </insert>



</mapper>