初始化项目
This commit is contained in:
1 parent
45a1702948
commit
934b8aad40
155 files changed
+2649
-68
No files matched your search
@@ -0,0 +1,119 @@
|
||||
<?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.bycrm.mapper.CustomerMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.bycrm.entity.Customer">
|
||||
<id column="id" property="id"/>
|
||||
<result column="name" property="name"/>
|
||||
<result column="phone" property="phone"/>
|
||||
<result column="address" property="address"/>
|
||||
<result column="industry" property="industry"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="created_at" property="createdAt"/>
|
||||
<result column="updated_at" property="updatedAt"/>
|
||||
</resultMap>
|
||||
|
||||
<resultMap id="CustomerVOResultMap" type="com.bycrm.vo.CustomerVO" extends="BaseResultMap">
|
||||
<result column="status_desc" property="statusDesc"/>
|
||||
<result column="current_dealer_id" property="currentDealerId"/>
|
||||
<result column="current_dealer_name" property="currentDealerName"/>
|
||||
<result column="protect_end_date" property="protectEndDate"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectById" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer WHERE id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectByNameLike" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer
|
||||
WHERE name LIKE CONCAT('%', #{name}, '%')
|
||||
LIMIT 10
|
||||
</select>
|
||||
|
||||
<select id="selectPage" resultMap="BaseResultMap">
|
||||
SELECT * FROM crm_customer
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY created_at DESC
|
||||
LIMIT #{query.size} OFFSET #{query.offset}
|
||||
</select>
|
||||
|
||||
<select id="countPage" resultType="java.lang.Long">
|
||||
SELECT COUNT(*) FROM crm_customer
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<insert id="insert" parameterType="com.bycrm.entity.Customer" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO crm_customer (name, phone, address, industry, status)
|
||||
VALUES (#{name}, #{phone}, #{address}, #{industry}, #{status})
|
||||
</insert>
|
||||
|
||||
<update id="update" parameterType="com.bycrm.entity.Customer">
|
||||
UPDATE crm_customer
|
||||
<set>
|
||||
<if test="name != null and name != ''">name = #{name},</if>
|
||||
<if test="phone != null">phone = #{phone},</if>
|
||||
<if test="address != null">address = #{address},</if>
|
||||
<if test="industry != null">industry = #{industry},</if>
|
||||
<if test="status != null">status = #{status},</if>
|
||||
</set>
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<delete id="deleteById">
|
||||
DELETE FROM crm_customer WHERE id = #{id}
|
||||
</delete>
|
||||
|
||||
<select id="selectPageWithDealer" resultMap="CustomerVOResultMap">
|
||||
SELECT
|
||||
c.*,
|
||||
CASE c.status
|
||||
WHEN 0 THEN '可报备'
|
||||
WHEN 1 THEN '保护中'
|
||||
WHEN 2 THEN '已失效'
|
||||
ELSE '未知'
|
||||
END AS status_desc,
|
||||
r.dealer_id AS current_dealer_id,
|
||||
d.name AS current_dealer_name,
|
||||
r.protect_end_date
|
||||
FROM crm_customer c
|
||||
LEFT JOIN crm_report r ON c.id = r.customer_id
|
||||
AND r.status = 1
|
||||
AND r.protect_end_date > NOW()
|
||||
LEFT JOIN crm_dealer d ON r.dealer_id = d.id
|
||||
<where>
|
||||
<if test="name != null and name != ''">
|
||||
AND c.name LIKE CONCAT('%', #{name}, '%')
|
||||
</if>
|
||||
<if test="industry != null and industry != ''">
|
||||
AND c.industry = #{industry}
|
||||
</if>
|
||||
<if test="status != null">
|
||||
AND c.status = #{status}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY c.created_at DESC
|
||||
LIMIT #{query.size} OFFSET #{query.offset}
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user