remark:
<resultMap type="me.gacl.domain.Classes" id="ClassResultMap">
<id property="id" column="c_id"/>
<result property="name" column="c_name"/>
<!-- 多对一,配置 property表示在类中定义的对象的属性名 -->
<association property="teacher" column="teacher_id" javaType="me.gacl.domain.Teacher">
<id property="id" column="t_id"/>
<result property="name" column="t_name"/>
</association>
/* 一对多 */
<!-- ofType指定students集合中的对象类型 -->
<collection property="students" ofType="me.gacl.domain.Student">
<id property="id" column="s_id"/>
<result property="name" column="s_name"/>
</collection>
</resultMap>
<?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.ruoyi.project.system.crmUser.mapper.CrmUserMapper">
<resultMap type="CrmUser" id="CrmUserResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="customerType" column="customer_type" />
<result property="customerName" column="customer_name" />
<result property="headPhoto" column="head_photo" />
<result property="nationality" column="nationality" />
<result property="vocation" column="vocation" />
<result property="linkman" column="linkman" />
<result property="tel" column="tel" />
<result property="fax" column="fax" />
<result property="mail" column="mail" />
<result property="linkAddress" column="link_address" />
<result property="addressProvince" column="address_province" />
<result property="addressCity" column="address_city" />
<result property="addressCounty" column="address_county" />
<result property="addressStreet" column="address_street" />
<result property="delFlag" column="del_flag" />
<result property="remarks" column="remarks" />
<result property="createDate" column="create_date" />
<result property="updateDate" column="update_date" />
<result property="optPerson" column="opt_person" />
<result property="customerStatus" column="customer_status" />
<result property="creditRating" column="credit_rating" />
<result property="tid" column="tid" />
</resultMap>
<!-- CrmDOResult resultMap -->
<resultMap type="CrmDO" id="CrmDOResult">
<result property="id" column="id" />
<result property="customerId" column="customer_id" />
<result property="customerType" column="customer_type" />
<result property="customerName" column="customer_name" />
<result property="headPhoto" column="head_photo" />
<result property="nationality" column="nationality" />
<result property="vocation" column="vocation" />
<result property="linkman" column="linkman" />
<result property="tel" column="tel" />
<result property="fax" column="fax" />
<result property="mail" column="mail" />
<result property="linkAddress" column="link_address" />
<result property="addressProvince" column="address_province" />
<result property="addressCity" column="address_city" />
<result property="addressCounty" column="address_county" />
<result property="addressStreet" column="address_street" />
<result property="delFlag" column="del_flag" />
<result property="remarks" column="remarks" />
<result property="inboundDateOne" column="create_date" />
<result property="inboundDateTwo" column="create_date" />
<result property="updateDate" column="update_date" />
<result property="optPerson" column="opt_person" />
<result property="customerStatus" column="customer_status" />
<result property="creditRating" column="credit_rating" />
</resultMap>
<sql id="selectCrmUserVo">
select id, customer_id, customer_type, customer_name, head_photo, nationality, vocation, linkman, tel, fax, mail, link_address, address_province, address_city, address_county, address_street, del_flag, remarks, create_date, update_date, opt_person, customer_status, credit_rating, tid from crm_user
</sql>
<select id="selectCrmUserList" parameterType="CrmUser" resultMap="CrmUserResult">
<include refid="selectCrmUserVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="customerId != null and customerId != '' "> and customer_id = #{customerId}</if>
<if test="customerType != null and customerType != '' "> and customer_type = #{customerType}</if>
<if test="customerName != null and customerName != '' "> and customer_name = #{customerName}</if>
<if test="headPhoto != null and headPhoto != '' "> and head_photo = #{headPhoto}</if>
<if test="nationality != null and nationality != '' "> and nationality = #{nationality}</if>
<if test="vocation != null and vocation != '' "> and vocation = #{vocation}</if>
<if test="linkman != null and linkman != '' "> and linkman = #{linkman}</if>
<if test="tel != null and tel != '' "> and tel = #{tel}</if>
<if test="fax != null and fax != '' "> and fax = #{fax}</if>
<if test="mail != null and mail != '' "> and mail = #{mail}</if>
<if test="linkAddress != null and linkAddress != '' "> and link_address = #{linkAddress}</if>
<if test="addressProvince != null and addressProvince != '' "> and address_province = #{addressProvince}</if>
<if test="addressCity != null and addressCity != '' "> and address_city = #{addressCity}</if>
<if test="addressCounty != null and addressCounty != '' "> and address_county = #{addressCounty}</if>
<if test="addressStreet != null and addressStreet != '' "> and address_street = #{addressStreet}</if>
<if test="delFlag != null and delFlag != '' "> and del_flag = #{delFlag}</if>
<if test="remarks != null and remarks != '' "> and remarks = #{remarks}</if>
<if test="createDate != null "> and create_date = #{createDate}</if>
<if test="updateDate != null "> and update_date = #{updateDate}</if>
<if test="optPerson != null and optPerson != '' "> and opt_person = #{optPerson}</if>
<if test="customerStatus != null and customerStatus != '' "> and customer_status = #{customerStatus}</if>
<if test="creditRating != null and creditRating != '' "> and credit_rating = #{creditRating}</if>
<if test="tid != null and tid != '' "> and tid = #{tid}</if>
</where>
</select>
<!-- todo 修改createDate条件查询 -->
<!-- explain select * from crm_user where create_date between DATE_FORMAT('2019-06-17', '%Y-%m-%d') and DATE_FORMAT('2019-06-19', '%Y-%m-%d'); -->
<!-- select * from crm_user where create_date between DATE_FORMAT('2019-06-17', '%Y-%m-%d') and DATE_FORMAT('2019-06-19', '%Y-%m-%d') and customer_id='ZS-KH-20191022-001' and vocation='信息'; -->
<select id="selectCrmUserListByCondition" parameterType="CrmDO" resultMap="CrmDOResult">
<include refid="selectCrmUserVo"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="customerId != null and customerId != '' "> and customer_id = #{customerId}</if>
<if test="customerType != null and customerType != '' "> and customer_type = #{customerType}</if>
<if test="customerName != null and customerName != '' "> and customer_name = #{customerName}</if>
<if test="headPhoto != null and headPhoto != '' "> and head_photo = #{headPhoto}</if>
<if test="nationality != null and nationality != '' "> and nationality = #{nationality}</if>
<if test="vocation != null and vocation != '' "> and vocation = #{vocation}</if>
<if test="linkman != null and linkman != '' "> and linkman = #{linkman}</if>
<if test="tel != null and tel != '' "> and tel = #{tel}</if>
<if test="fax != null and fax != '' "> and fax = #{fax}</if>
<if test="mail != null and mail != '' "> and mail = #{mail}</if>
<if test="linkAddress != null and linkAddress != '' "> and link_address = #{linkAddress}</if>
<if test="addressProvince != null and addressProvince != '' "> and address_province = #{addressProvince}</if>
<if test="addressCity != null and addressCity != '' "> and address_city = #{addressCity}</if>
<if test="addressCounty != null and addressCounty != '' "> and address_county = #{addressCounty}</if>
<if test="addressStreet != null and addressStreet != '' "> and address_street = #{addressStreet}</if>
<if test="delFlag != null and delFlag != '' "> and del_flag = #{delFlag}</if>
<if test="remarks != null and remarks != '' "> and remarks = #{remarks}</if>
<if test="inboundDateOne != null and inboundDateTwo != null "> and create_date between DATE_FORMAT(#{inboundDateOne}, '%Y-%m-%d') and DATE_FORMAT(#{inboundDateTwo}, '%Y-%m-%d')</if>
<if test="optPerson != null and optPerson != '' "> and opt_person = #{optPerson}</if>
<if test="customerStatus != null and customerStatus != '' "> and customer_status = #{customerStatus}</if>
<if test="creditRating != null and creditRating != '' "> and credit_rating = #{creditRating}</if>
<if test="tid != null and tid != '' "> and tid = #{tid}</if>
</where>
</select>
<!-- 三表连接 -->
<sql id="crmColumns">
a.id AS "id",
a.customer_id AS "customerId",
a.customer_type AS "customerType",
a.customer_name AS "customerName",
a.head_photo AS "headPhoto",
a.nationality AS "nationality",
a.vocation AS "vocation",
a.linkman AS "linkman",
a.tel AS "tel",
a.fax AS "fax",
a.mail AS "mail",
a.link_address AS "linkAddress",
a.address_province AS "addressProvince",
a.address_city AS "addressCity",
a.address_county AS "addressCounty",
a.address_street AS "addressStreet",
a.del_flag AS "delFlag",
a.remarks AS "remarks",
a.create_date AS "createDate",
a.update_date AS "updateDate",
a.opt_person AS "optPerson",
a.customer_status AS "customerStatus",
a.credit_rating AS "creditRating",
a.tid AS "tid",
a2.dict_code AS "dictData.dictCode",
a2.dict_label AS "dictData.dictLabel",
a3.name AS "nationData.name",
a3.code AS "nationData.code"
</sql>
<sql id="crmJoins">
left join sys_dict_data a2 on a.vocation = a2.dict_code
left join sys_nationality a3 on a.nationality = a3.`code`
</sql>
<!-- select a.*, b.*,c.* from crm_user a left join sys_dict_data b on a.vocation = b.dict_code left join sys_nationality c on a.nationality = c.`code` -->
<select id="getMorelist" resultType="CrmUser">
SELECT
<include refid="crmColumns"/>
FROM crm_user a
<include refid="crmJoins"/>
<where>
<if test="id != null "> and id = #{id}</if>
<if test="customerId != null and customerId != '' "> and a.customer_id = #{customerId}</if>
<if test="customerType != null and customerType != '' "> and a.customer_type = #{customerType}</if>
<if test="customerName != null and customerName != '' "> and a.customer_name = #{customerName}</if>
<if test="headPhoto != null and headPhoto != '' "> and a.head_photo = #{headPhoto}</if>
<if test="nationality != null and nationality != '' "> and a.nationality = #{nationality}</if>
<if test="vocation != null and vocation != '' "> and a.vocation = #{vocation}</if>
<if test="linkman != null and linkman != '' "> and a.linkman = #{linkman}</if>
<if test="tel != null and tel != '' "> and a.tel = #{tel}</if>
<if test="fax != null and fax != '' "> and a.fax = #{fax}</if>
<if test="mail != null and mail != '' "> and a.mail = #{mail}</if>
<if test="linkAddress != null and linkAddress != '' "> and a.link_address = #{linkAddress}</if>
<if test="addressProvince != null and addressProvince != '' "> and a.address_province = #{addressProvince}</if>
<if test="addressCity != null and addressCity != '' "> and a.address_city = #{addressCity}</if>
<if test="addressCounty != null and addressCounty != '' "> and a.address_county = #{addressCounty}</if>
<if test="addressStreet != null and addressStreet != '' "> and a.address_street = #{addressStreet}</if>
<if test="delFlag != null and delFlag != '' "> and a.del_flag = #{delFlag}</if>
<if test="remarks != null and remarks != '' "> and a.remarks = #{remarks}</if>
<if test="inboundDateOne != null and inboundDateTwo != null "> and a.create_date between DATE_FORMAT(#{inboundDateOne}, '%Y-%m-%d') and DATE_FORMAT(#{inboundDateTwo}, '%Y-%m-%d')</if>
<if test="optPerson != null and optPerson != '' "> and a.opt_person = #{optPerson}</if>
<if test="customerStatus != null and customerStatus != '' "> and a.customer_status = #{customerStatus}</if>
<if test="creditRating != null and creditRating != '' "> and a.credit_rating = #{creditRating}</if>
<if test="tid != null and tid != '' "> and a.tid = #{tid}</if>
</where>
</select>
<select id="selectCrmUserById" parameterType="Integer" resultMap="CrmUserResult">
<include refid="selectCrmUserVo"/>
where id = #{id}
</select>
<insert id="insertCrmUser" parameterType="CrmUser" useGeneratedKeys="true" keyProperty="id">
insert into crm_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="customerId != null and customerId != '' ">customer_id,</if>
<if test="customerType != null and customerType != '' ">customer_type,</if>
<if test="customerName != null and customerName != '' ">customer_name,</if>
<if test="headPhoto != null and headPhoto != '' ">head_photo,</if>
<if test="nationality != null and nationality != '' ">nationality,</if>
<if test="vocation != null and vocation != '' ">vocation,</if>
<if test="linkman != null and linkman != '' ">linkman,</if>
<if test="tel != null and tel != '' ">tel,</if>
<if test="fax != null and fax != '' ">fax,</if>
<if test="mail != null and mail != '' ">mail,</if>
<if test="linkAddress != null and linkAddress != '' ">link_address,</if>
<if test="addressProvince != null and addressProvince != '' ">address_province,</if>
<if test="addressCity != null and addressCity != '' ">address_city,</if>
<if test="addressCounty != null and addressCounty != '' ">address_county,</if>
<if test="addressStreet != null and addressStreet != '' ">address_street,</if>
<if test="delFlag != null and delFlag != '' ">del_flag,</if>
<if test="remarks != null and remarks != '' ">remarks,</if>
<if test="createDate != null ">create_date,</if>
<if test="updateDate != null ">update_date,</if>
<if test="optPerson != null and optPerson != '' ">opt_person,</if>
<if test="customerStatus != null and customerStatus != '' ">customer_status,</if>
<if test="creditRating != null and creditRating != '' ">credit_rating,</if>
<if test="tid != null and tid != '' ">tid,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="customerId != null and customerId != '' ">#{customerId},</if>
<if test="customerType != null and customerType != '' ">#{customerType},</if>
<if test="customerName != null and customerName != '' ">#{customerName},</if>
<if test="headPhoto != null and headPhoto != '' ">#{headPhoto},</if>
<if test="nationality != null and nationality != '' ">#{nationality},</if>
<if test="vocation != null and vocation != '' ">#{vocation},</if>
<if test="linkman != null and linkman != '' ">#{linkman},</if>
<if test="tel != null and tel != '' ">#{tel},</if>
<if test="fax != null and fax != '' ">#{fax},</if>
<if test="mail != null and mail != '' ">#{mail},</if>
<if test="linkAddress != null and linkAddress != '' ">#{linkAddress},</if>
<if test="addressProvince != null and addressProvince != '' ">#{addressProvince},</if>
<if test="addressCity != null and addressCity != '' ">#{addressCity},</if>
<if test="addressCounty != null and addressCounty != '' ">#{addressCounty},</if>
<if test="addressStreet != null and addressStreet != '' ">#{addressStreet},</if>
<if test="delFlag != null and delFlag != '' ">#{delFlag},</if>
<if test="remarks != null and remarks != '' ">#{remarks},</if>
<if test="createDate != null ">#{createDate},</if>
<if test="updateDate != null ">#{updateDate},</if>
<if test="optPerson != null and optPerson != '' ">#{optPerson},</if>
<if test="customerStatus != null and customerStatus != '' ">#{customerStatus},</if>
<if test="creditRating != null and creditRating != '' ">#{creditRating},</if>
<if test="tid != null and tid != '' ">#{tid},</if>
</trim>
</insert>
<update id="updateCrmUser" parameterType="CrmUser">
update crm_user
<trim prefix="SET" suffixOverrides=",">
<if test="customerId != null and customerId != '' ">customer_id = #{customerId},</if>
<if test="customerType != null and customerType != '' ">customer_type = #{customerType},</if>
<if test="customerName != null and customerName != '' ">customer_name = #{customerName},</if>
<if test="headPhoto != null and headPhoto != '' ">head_photo = #{headPhoto},</if>
<if test="nationality != null and nationality != '' ">nationality = #{nationality},</if>
<if test="vocation != null and vocation != '' ">vocation = #{vocation},</if>
<if test="linkman != null and linkman != '' ">linkman = #{linkman},</if>
<if test="tel != null and tel != '' ">tel = #{tel},</if>
<if test="fax != null and fax != '' ">fax = #{fax},</if>
<if test="mail != null and mail != '' ">mail = #{mail},</if>
<if test="linkAddress != null and linkAddress != '' ">link_address = #{linkAddress},</if>
<if test="addressProvince != null and addressProvince != '' ">address_province = #{addressProvince},</if>
<if test="addressCity != null and addressCity != '' ">address_city = #{addressCity},</if>
<if test="addressCounty != null and addressCounty != '' ">address_county = #{addressCounty},</if>
<if test="addressStreet != null and addressStreet != '' ">address_street = #{addressStreet},</if>
<if test="delFlag != null and delFlag != '' ">del_flag = #{delFlag},</if>
<if test="remarks != null and remarks != '' ">remarks = #{remarks},</if>
<if test="createDate != null ">create_date = #{createDate},</if>
<if test="updateDate != null ">update_date = #{updateDate},</if>
<if test="optPerson != null and optPerson != '' ">opt_person = #{optPerson},</if>
<if test="customerStatus != null and customerStatus != '' ">customer_status = #{customerStatus},</if>
<if test="creditRating != null and creditRating != '' ">credit_rating = #{creditRating},</if>
<if test="tid != null and tid != '' ">tid = #{tid},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteCrmUserById" parameterType="Integer">
delete from crm_user where id = #{id}
</delete>
<delete id="deleteCrmUserByIds" parameterType="String">
delete from crm_user where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>
<?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.jgxt.dao.takeover.DiscussMapper">
<!--添加消息 -->
<insert id="addDiscuss" parameterType="com.jgxt.bean.takeover.DiscussBean">
insert into t_discuss values(null,#{userId},#{content},#{createDate},#{repayDate},#{oneself},#{sendto})
</insert>
<!--history.jsp -->
<resultMap type="com.jgxt.bean.takeover.DiscussBean" id="resultMapId">
<id column="discussId" property="discussId"/>
<result column="discussId" property="discussId"/>
<result column="userId" property="userId"/>
<result column="content" property="content"/>
<result column="createDate" property="createDate"/>
<result column="replyDate" property="repayDate"/>
<result column="oneself" property="oneself"/>
<result column="sendto" property="sendto"/>
<!-- 多个讨论对一用户,配置 property表示在类中定义的对象的属性名 -->
<association property="userinfo" javaType="com.jgxt.bean.UserInfo" >
<id column="id" property="id" />
<result column="realname" property="realname" />
<result column="banktype_id" property="banktype_id" />
</association>
<!-- 多个讨论对一用户,配置 property表示在类中定义的对象的属性名 -->
<association property="banktype" javaType="com.jgxt.bean.Banktype" >
<id column="id" property="id" />
<result column="name" property="name" />
</association>
</resultMap>
<!-- 降序查询讨论区历史信息 -->
<select id="getDisList" parameterType="java.util.HashMap" resultMap="resultMapId">
select t1.discussId,t1.userId,t1.content,t1.createDate,t1.oneself,t1.sendto from t_discuss t1
<where>
<if test="starttime !='' and starttime !=undefined"> <!-- 日期:起始 -->
AND DATE_FORMAT(t1.createDate,'%Y-%m-%d') >=#{starttime}
</if>
<if test="endtime !='' and endtime !=undefined"> <!-- 截止-->
AND DATE_FORMAT(t1.createDate,'%Y-%m-%d') <=#{endtime}
</if>
<if test="context !='' and context != null"> <!-- 消息内容-->
AND t1.content like concat('%',#{context},'%')
</if>
<if test="isenterprise ==1"> <!-- 消息类型 -->
AND t1.oneself = #{isenterprise}
</if>
</where>
order by createDate desc
LIMIT #{start,jdbcType=INTEGER},#{count,jdbcType=INTEGER}
</select>
<!-- 查询讨论区历史信息 -->
<select id="getDisListForAll" parameterType="java.util.HashMap" resultMap="resultMapId">
select t1.discussId,t1.userId,t1.content,t1.createDate,t1.oneself,t1.sendto from t_discuss t1
</select>
<!-- 首页查看更多进行滚动查看 -->
<select id="selectNameAndContent" parameterType="java.util.HashMap" resultMap="resultMapId">
select t1.discussId,t1.userId,t1.createDate,t1.content from t_discuss t1
LIMIT #{start,jdbcType=INTEGER},#{count,jdbcType=INTEGER}
</select>
<!-- id查当天所有discuss的list -->
<!-- <select id="getDisList" resultMap="resultMapId">
select t1.discussId,t1.userId,t1.content,DATE_FORMAT(createDate,'%m-%d %H:%i:%s')createDate,t2.username
from (select * from t_discuss order by createDate desc limit 11) t1 inner join userinfo t2 on t1.userid=t2.id ORDER BY createDate
</select> -->
<!-- 查询discuss的count -->
<select id="getDisCount" resultType="java.lang.Integer" parameterType="java.util.HashMap">
SELECT COUNT(1) FROM t_discuss d
<where>
<if test="starttime !='' and starttime !=undefined"> <!-- 日期:起始 -->
AND DATE_FORMAT(d.createDate,'%Y-%m-%d') >=#{starttime}
</if>
<if test="endtime !='' and endtime !=undefined"> <!-- 截止-->
AND DATE_FORMAT(d.createDate,'%Y-%m-%d') <=#{endtime}
</if>
<if test="context !='' and context != null"> <!-- 消息内容-->
AND d.content like concat('%',#{context},'%')
</if>
<if test="isenterprise ==1"> <!-- 消息类型 -->
AND d.oneself = #{isenterprise}
</if>
</where>
</select>
<!-- 查询max -->
<select id="selectMax" resultType="java.lang.Integer">
select max(t.discussId) from t_discuss t
</select>
<!--根据id查整条讨论信息 -->
<resultMap type="com.jgxt.bean.takeover.DiscussBean" id="resultMapId2">
<id column="discussId" property="discussId"/>
<result column="discussId" property="discussId"/>
<result column="userId" property="userId"/>
<result column="content" property="content"/>
<result column="createDate" property="createDate"/>
<result column="replyDate" property="repayDate"/>
<result column="sendto" property="sendto"/>
</resultMap>
<select id="getListById" resultMap="resultMapId2">
select t1.* from t_discuss t1 where discussId=#{discussId}
</select>
</mapper>