<?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.sincere.wechatbusiness.mapper.AttentionMapper"> <resultMap id="AttentionMap" type="com.sincere.wechatbusiness.model.Attention"> <id column="id" jdbcType="INTEGER" property="id" /> <result column="channelId" jdbcType="INTEGER" property="channelId" /> <result column="logo" jdbcType="VARCHAR" property="logo" /> <result column="name" jdbcType="VARCHAR" property="name" /> <result column="content" jdbcType="VARCHAR" property="content" /> <result column="img_url" jdbcType="VARCHAR" property="imgUrl" /> <result column="state" jdbcType="INTEGER" property="state"/> <result column="create_time" jdbcType="TIMESTAMP" property="createTime" /> </resultMap> <select id="getDetail" parameterType="java.lang.Integer" resultMap="AttentionMap"> select * from attention where channelId=#{id} and state=1 </select> <insert id="insert" parameterType="com.sincere.wechatbusiness.model.Attention"> insert into attention (channelId, logo,name,content,img_url) values (#{channelId,jdbcType=INTEGER}, #{logo,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, #{content,jdbcType=VARCHAR}, #{imgUrl,jdbcType=VARCHAR}) </insert> <update id="update" parameterType="com.sincere.wechatbusiness.model.Attention"> update attention <trim prefix="set" suffixOverrides=","> <if test="logo!=null and logo!=''"> logo=#{logo}, </if> <if test="name!=null and name!=''"> name=#{name}, </if> <if test="content!=null and content!=''"> content=#{content}, </if> <if test="imgUrl!=null and imgUrl!=''"> img_url=#{imgUrl}, </if> </trim> where id = #{id} </update> </mapper>