123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213 |
- <?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.zhyc.xps.sys.mapper.CustomerMapper">
- <!-- 通用查询映射结果 -->
- <resultMap id="CustomerResultMap" type="com.zhyc.xps.sys.dto.CustomerDto">
- <result column="oc_id" property="ocId" jdbcType="BIGINT" />
- <result column="customer_id" property="customerId" jdbcType="BIGINT" />
- <result column="customer_name" property="customerName" jdbcType="VARCHAR" />
- <result column="customer_code" property="customerCode" jdbcType="VARCHAR" />
- <result column="customer_card_no" property="customerCardNo" jdbcType="VARCHAR" />
- <result column="customer_phone" property="customerPhone" jdbcType="VARCHAR" />
- <result column="customer_remark" property="customerRemark" jdbcType="VARCHAR" />
- <result column="wx_id" property="wxId" jdbcType="VARCHAR" />
- </resultMap>
- <!-- 通用查询结果列 -->
- <sql id="CustomerDto_Cols">
- A.oc_id,
- A.customer_id,
- A.customer_name,
- A.customer_code,
- A.customer_card_no,
- A.wx_id,
- A.customer_remark
- </sql>
- <!--基于ID查询-->
- <select id="getById" resultMap="CustomerResultMap">
- SELECT
- <include refid="CustomerDto_Cols"/>
- FROM customer AS A
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND A.customer_id = #{customerId ,jdbcType=BIGINT}
- </select>
- <!--基于WxID查询-->
- <select id="getByWxId" resultMap="CustomerResultMap">
- SELECT
- <include refid="CustomerDto_Cols"/>
- FROM customer AS A
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND A.wx_id = #{wxId ,jdbcType=VARCHAR}
- </select>
- <!--基于Phone查询-->
- <select id="getByPhone" resultMap="CustomerResultMap">
- SELECT
- <include refid="CustomerDto_Cols"/>
- FROM customer AS A
- WHERE A.deleted_flag = 0
- AND A.oc_id = #{ocId ,jdbcType=BIGINT}
- AND A.customer_phone = #{customerPhone ,jdbcType=VARCHAR}
- </select>
- <!--分页查询-->
- <select id="getByPage" parameterType="java.util.Map" resultMap="CustomerResultMap" >
- SELECT
- <include refid="CustomerDto_Cols"/>
- FROM customer AS A
- WHERE A.deleted_flag = 0
- <if test="keywords != null and keywords != ''">
- AND A.customer_name like "%"#{keywords}"%"
- </if>
- ORDER BY A.oc_id, A.customer_id
- </select>
- <!--列表查询-->
- <select id="getByList" parameterType="java.util.Map" resultMap="CustomerResultMap">
- SELECT
- <include refid="CustomerDto_Cols"/>
- FROM customer AS A
- WHERE A.deleted_flag = 0
- <if test="keywords != null and keywords != ''">
- AND A.customer_name like "%"#{keywords}"%"
- </if>
- ORDER BY A.oc_id, A.customer_id
- </select>
- <insert id="create" parameterType="com.zhyc.xps.sys.entity.Customer">
- INSERT INTO customer
- <trim prefix="(" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- oc_id,
- </if>
- <if test="customerId != null">
- customer_id,
- </if>
- <if test="customerName != null and customerName != ''">
- customer_name,
- </if>
- <if test="customerCode != null and customerCode != ''">
- customer_code,
- </if>
- <if test="customerCardNo != null and customerCardNo != ''">
- customer_card_no,
- </if>
- <if test="customerPhone != null and customerPhone != ''">
- customer_phone,
- </if>
- <if test="customerRemark != null and customerRemark != ''">
- customer_remark,
- </if>
- <if test="wxId != null and wxId != ''">
- wx_id,
- </if>
- <if test="createdBy != null">
- created_by,
- </if>
- <if test="createdAt != null">
- created_at,
- </if>
- </trim>
- <trim prefix="values (" suffix=")" suffixOverrides=",">
- <if test="ocId != null">
- #{ocId,jdbcType=BIGINT},
- </if>
- <if test="customerId != null">
- #{customerId ,jdbcType=BIGINT},
- </if>
- <if test="customerName != null and customerName != ''">
- #{customerName ,jdbcType=VARCHAR},
- </if>
- <if test="customerCode != null and customerCode != ''">
- #{customerCode ,jdbcType=VARCHAR},
- </if>
- <if test="customerCardNo != null and customerCardNo != ''">
- #{customerCardNo ,jdbcType=VARCHAR},
- </if>
- <if test="customerPhone != null and customerPhone != ''">
- #{customerPhone ,jdbcType=VARCHAR},
- </if>
- <if test="customerRemark != null and customerRemark != ''">
- #{customerRemark ,jdbcType=VARCHAR},
- </if>
- <if test="wxId != null and wxId != ''">
- #{wxId ,jdbcType=VARCHAR},
- </if>
- <if test="createdBy != null">
- #{createdBy ,jdbcType=BIGINT},
- </if>
- <if test="createdAt != null">
- #{createdAt ,jdbcType=TIMESTAMP},
- </if>
- </trim>
- </insert>
- <!--更新-->
- <update id="update" parameterType="com.zhyc.xps.sys.entity.Customer">
- UPDATE customer
- <trim suffixOverrides=",">
- <set>
- <if test="customerName != null and customerName != ''">
- customer_name = #{customerName, jdbcType=VARCHAR},
- </if>
- <if test="customerCode != null and customerCode != ''">
- customer_code = #{customerCode ,jdbcType=VARCHAR},
- </if>
- <if test="customerCardNo != null">
- customer_card_no = #{customerCardNo ,jdbcType=VARCHAR},
- </if>
- <if test="customerPhone != null">
- customer_phone = #{customerPhone ,jdbcType=VARCHAR},
- </if>
- <if test="customerRemark != null">
- customer_remark = #{customerRemark, jdbcType=VARCHAR},
- </if>
- <if test="wxId != null">
- wx_id = #{wxId ,jdbcType=VARCHAR},
- </if>
- <if test="updatedBy != null ">
- updated_by = #{updatedBy ,jdbcType=BIGINT},
- </if>
- <if test="updatedAt != null">
- updated_at = #{updatedAt ,jdbcType=TIMESTAMP},
- </if>
- </set>
- </trim>
- WHERE oc_id = #{ocId ,jdbcType=BIGINT}
- AND customer_id = #{customerId ,jdbcType=BIGINT}
- </update>
- <!--删除-->
- <update id="delete" parameterType="java.util.Map">
- UPDATE customer
- <trim suffixOverrides=",">
- <set>
- <if test="deletedFlag != null">
- deleted_flag = #{deletedFlag,jdbcType=BIGINT},
- </if>
- <if test="deletedTime != null">
- deleted_time = #{deletedTime,jdbcType=TIMESTAMP},
- </if>
- <if test="deletedBy != null">
- deleted_by = #{deletedBy,jdbcType=BIGINT},
- </if>
- </set>
- </trim>
- WHERE 1 = 1
- <if test="ocId != null">
- AND oc_id = #{ocId,jdbcType=BIGINT}
- </if>
- <if test="customerId != null">
- AND customer_id = #{customerId ,jdbcType=BIGINT}
- </if>
- </update>
- </mapper>
|