<?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="cn.wisenergy.mapper.CustomerServiceMapper"> <resultMap id="bankMap" type="cn.wisenergy.model.app.CustomerService"> <id column="id" property="id"/> <result column="wechat_id" property="wechatId"/> <result column="wechat_img_url" property="wechatImgUrl"/> <result column="create_time" property="createTime"/> <result column="update_time" property="updateTime"/> </resultMap> <sql id="table"> customer_service </sql> <sql id="cols_all"> id, <include refid="cols_exclude_id"/> </sql> <sql id="cols_exclude_id"> wechat_id,wechat_img_url,create_time,update_time </sql> <sql id="vals"> #{wechatId},#{wechatImgUrl},now(),now() </sql> <sql id="updateCondition"> <if test="wechatId != null">service_id = #{wechatId},</if> <if test="wechatImgUrl != null">wechat_img_url = #{wechatImgUrl},</if> update_time =now() </sql> <sql id="criteria"> <if test="id != null">id = #{id}</if> <if test="wechatId != null">and service_id = #{wechatId}</if> <if test="wechatImgUrl != null">and wechat_img_url = #{wechatImgUrl}</if> <if test="createTime != null">and create_time >= #{createTime}</if> <if test="updateTime != null">and #{updateTime} >= update_time</if> </sql> <select id="randService" resultType="cn.wisenergy.model.app.CustomerService"> select <include refid="cols_all"/> from <include refid="table"/> order by rand() limit 1 </select> </mapper>