CompanyMapper.xml 4.17 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.general.company.mapper.CompanyMapper">

	<select id="selectCompanyByUserId" parameterType="Integer" resultType="com.huaheng.pc.general.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}
	</select>

	<select id="selectCompanyList" resultType="com.huaheng.pc.general.company.domain.Company">
        SELECT c.id, c.code, c.name, c.enable
        FROM company c
        INNER JOIN  warehouse_company wc ON c.id = wc.warehouseId
        <where>
            <if test="id != null">
                AND c.id = #{id}
            </if>
            <if test="code != null">
                AND c.code = #{code}
            </if>
            <if test="parentId != null">
                AND c.parentId = #{parentId}
            </if>
            <if test="type != null">
                AND c.type = #{type}
            </if>
            <if test="name != null">
                AND c.name = #{name}
            </if>
            <if test="address1 != null">
                AND c.address1 = #{address1}
            </if>
            <if test="address2 != null">
                AND c.address2 = #{address2}
            </if>
            <if test="city != null">
                AND c.city = #{city}
            </if>
            <if test="province != null">
                AND c.province = #{province}
            </if>
            <if test="country != null">
                AND c.country = #{country}
            </if>
            <if test="postalCode != null">
                AND c.postalCode = #{postalCode}
            </if>
            <if test="attentionTo != null">
                AND c.attentionTo = #{attentionTo}
            </if>
            <if test="phoneNum != null">
                AND c.phoneNum = #{phoneNum}
            </if>
            <if test="mobile != null">
                AND c.mobile = #{mobile}
            </if>
            <if test="faxNum != null">
                AND c.faxNum = #{faxNum}
            </if>
            <if test="email != null">
                AND c.email = #{email}
            </if>
            <if test="created != null">
                AND c.created = #{created}
            </if>
            <if test="createdBy != null">
                AND c.createdBy = #{createdBy}
            </if>
            <if test="lastUpdated != null">
                AND c.lastUpdated = #{lastUpdated}
            </if>
            <if test="lastUpdatedBy != null">
                AND c.lastUpdatedBy = #{lastUpdatedBy}
            </if>
            <if test="enable != null">
                AND c.enable = #{enable}
            </if>
            <if test="deleted != null">
                AND c.deleted = #{deleted}
            </if>
            <if test="userDef1 != null">
                AND c.userDef1 = #{userDef1}
            </if>
            <if test="userDef2 != null">
                AND c.userDef2 = #{userDef2}
            </if>
            <if test="userDef3 != null">
                AND c.userDef3 = #{userDef3}
            </if>
            <if test="warehouseId != null">
                AND wc.warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null">
                AND wc.warehouseCode = #{warehouseCode}
            </if>
		</where>
	</select>

    <select id="CompanyParent" resultType="java.util.Map">
        SELECT c.id, c.code, c.name, c.enable
        FROM company c
        INNER JOIN warehouse_company wc ON c.id = wc.warehouseId
        <if test="enable != null and enable != ''">
            AND c.enable = #{enable}
        </if>
        <if test="deleted != null and deleted != ''">
            AND c.deleted = #{deleted}
        </if>
        <if test="type != null">
            AND c.type = #{type}
        </if>
        <if test="warehouseId != null">
            AND wc.warehouseId = #{warehouseId}
        </if>
    </select>

    <delete id="deleteCompanyByIds" parameterType="Integer">
 		update  company  set deleted=true where id in (#{ids})
 	</delete>

</mapper>