CompanyMapper.xml 2.74 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 id, code, parentId, type, name, address1, address2, city, province, country, postalCode, attentionTo, phoneNum, mobile, faxNum, email, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, userDef1, userDef2, userDef3
		FROM company
		<where>
			<if test="id != null">
				AND id = #{id}
			</if>
			<if test="code != null">
				AND code like #{code}
			</if>
			<if test="parentId != null">
				AND parentId = #{parentId}
			</if>
			<if test="type != null">
				AND type like #{type}
			</if>
			<if test="name != null">
				AND name like #{name}
			</if>
			<if test="address1 != null">
				AND address1 like #{address1}
			</if>
			<if test="address2 != null">
				AND address2 like #{address2}
			</if>
			<if test="city != null">
				AND city like #{city}
			</if>
			<if test="province != null">
				AND province like #{province}
			</if>
			<if test="country != null">
				AND country like #{country}
			</if>
			<if test="postalCode != null">
				AND postalCode like #{postalCode}
			</if>
			<if test="attentionTo != null">
				AND attentionTo like #{attentionTo}
			</if>
			<if test="phoneNum != null">
				AND phoneNum like #{phoneNum}
			</if>
			<if test="mobile != null">
				AND mobile like #{mobile}
			</if>
			<if test="faxNum != null">
				AND faxNum like #{faxNum}
			</if>
			<if test="email != null">
				AND email like #{email}
			</if>
			<if test="created != null">
				AND created = #{created}
			</if>
			<if test="createdBy != null">
				AND createdBy like #{createdBy}
			</if>
			<if test="lastUpdated != null">
				AND lastUpdated = #{lastUpdated}
			</if>
			<if test="lastUpdatedBy != null">
				AND lastUpdatedBy like #{lastUpdatedBy}
			</if>
			<if test="enable != null">
				AND enable = #{enable}
			</if>
			<if test="deleted != null">
				AND deleted = #{deleted}
			</if>
			<if test="userDef1 != null">
				AND userDef1 like #{userDef1}
			</if>
			<if test="userDef2 != null">
				AND userDef2 like #{userDef2}
			</if>
			<if test="userDef3 != null">
				AND userDef3 like #{userDef3}
			</if>
		</where>

	</select>

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

</mapper>