<?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.yunniu.farming.webadmin.dao.DocCatalogDao" > <resultMap id="BaseResultMap" type="com.yunniu.farming.webadmin.model.DocCatalog" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="saccesstoken" property="saccesstoken" jdbcType="VARCHAR" /> <result column="sysadminid" property="sysadminid" jdbcType="INTEGER" /> <result column="mchid" property="mchid" jdbcType="INTEGER" /> <result column="productid" property="productid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sicon" property="sicon" jdbcType="VARCHAR" /> <result column="spath" property="spath" jdbcType="VARCHAR" /> <result column="sdesc" property="sdesc" jdbcType="LONGVARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="parentid" property="parentid" jdbcType="INTEGER" /> <result column="iablepubinfo" property="iablepubinfo" jdbcType="INTEGER" /> <result column="isshow" property="isshow" jdbcType="INTEGER" /> <result column="isortno" property="isortno" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="TIMESTAMP" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> </resultMap> <!-- 一对多 查询 一级下的二级分类 --> <select id="selectSubs" parameterType="String" resultType="com.yunniu.farming.webadmin.model.DocCatalog"> SELECT * FROM doc_catalog WHERE parentid = #{id} </select> <!-- 增加没有关联关联的查询,提高首页查询效率 --> <resultMap id="BaseResultMapWithoutSub" type="com.yunniu.farming.webadmin.model.DocCatalog" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="saccesstoken" property="saccesstoken" jdbcType="VARCHAR" /> <result column="sysadminid" property="sysadminid" jdbcType="INTEGER" /> <result column="mchid" property="mchid" jdbcType="INTEGER" /> <result column="productid" property="productid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sicon" property="sicon" jdbcType="VARCHAR" /> <result column="spath" property="spath" jdbcType="VARCHAR" /> <result column="sdesc" property="sdesc" jdbcType="LONGVARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="parentid" property="parentid" jdbcType="INTEGER" /> <result column="iablepubinfo" property="iablepubinfo" jdbcType="INTEGER" /> <result column="isshow" property="isshow" jdbcType="INTEGER" /> <result column="isortno" property="isortno" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="TIMESTAMP" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> </resultMap> <sql id="Base_Column_List" > id, saccesstoken, sysadminid, mchid, productid, itype, sname, sicon, spath, sdesc, ilevel, parentid, iablepubinfo, isshow, isortno,tcreatetime, sdef1, sdef2, sdef3, sdef4, sdef5, idef6, idef7, ddef8, ddef9, ddef10 </sql> <!-- 带参查询 Start --> <select id="selectByParam" resultMap="BaseResultMap" parameterType="com.yunniu.farming.webadmin.model.DocCatalog" > select <include refid="Base_Column_List" /> from doc_catalog <where> <if test="id != null" > AND id = #{id,jdbcType=INTEGER} </if> <if test="parentid != null" > AND parentid = #{parentid,jdbcType=INTEGER} </if> <if test="ilevel != null" > AND ilevel = #{ilevel,jdbcType=INTEGER} </if> <if test="mchid != null" > AND mchid = #{mchid,jdbcType=INTEGER} </if> <if test="sysadminid != null" > AND sysadminid = #{sysadminid,jdbcType=INTEGER} </if> <if test="itype != null" > AND itype = #{itype,jdbcType=INTEGER} </if> <if test="sname != null" > AND sname = #{sname,jdbcType=VARCHAR} </if> <if test="saccesstoken != null" > AND saccesstoken = #{saccesstoken,jdbcType=VARCHAR} </if> <if test="isshow != null" > AND isshow = #{isshow,jdbcType=INTEGER} </if> </where> ORDER BY doc_catalog.isortno DESC </select> <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" > select 'false' as QUERYID, <include refid="Base_Column_List" /> from doc_catalog where id = #{id,jdbcType=INTEGER} </select> <delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" > delete from doc_catalog where id = #{id,jdbcType=INTEGER} or parentid=#{id,jdbcType=INTEGER} </delete> <resultMap id="roleModel" type="com.yunniu.farming.webadmin.model.DocCatalog" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="saccesstoken" property="saccesstoken" jdbcType="VARCHAR" /> <result column="sysadminid" property="sysadminid" jdbcType="INTEGER" /> <result column="mchid" property="mchid" jdbcType="INTEGER" /> <result column="productid" property="productid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sicon" property="sicon" jdbcType="VARCHAR" /> <result column="spath" property="spath" jdbcType="VARCHAR" /> <result column="sdesc" property="sdesc" jdbcType="VARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="parentid" property="parentid" jdbcType="INTEGER" /> <result column="iablepubinfo" property="iablepubinfo" jdbcType="INTEGER" /> <result column="isshow" property="isshow" jdbcType="INTEGER" /> <result column="isortno" property="isortno" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="TIMESTAMP" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> <collection property="subs" ofType="com.yunniu.farming.webadmin.model.DocCatalog" javaType="java.util.ArrayList"> <id column="id" property="id" jdbcType="INTEGER" /> <result column="saccesstoken" property="saccesstoken" jdbcType="VARCHAR" /> <result column="sysadminid" property="sysadminid" jdbcType="INTEGER" /> <result column="mchid" property="mchid" jdbcType="INTEGER" /> <result column="productid" property="productid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sicon" property="sicon" jdbcType="VARCHAR" /> <result column="spath" property="spath" jdbcType="VARCHAR" /> <result column="sdesc" property="sdesc" jdbcType="LONGVARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="parentid" property="parentid" jdbcType="INTEGER" /> <result column="iablepubinfo" property="iablepubinfo" jdbcType="INTEGER" /> <result column="isshow" property="isshow" jdbcType="INTEGER" /> <result column="isortno" property="isortno" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="TIMESTAMP" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> </collection> </resultMap> <!-- 查询所有导航分类档案 优化后 --> <select id="getRoleInfo" resultMap="roleModel" parameterType="com.yunniu.farming.webadmin.model.DocCatalog" > select doc_catalog.*, ro.* from doc_catalog left join doc_catalog ro on doc_catalog.id=ro.parentid <where> <if test="id != null" > AND doc_catalog.id = #{id,jdbcType=INTEGER} </if> <if test="parentid != null" > AND doc_catalog.parentid = #{parentid,jdbcType=INTEGER} </if> <if test="ilevel != null" > AND doc_catalog.ilevel = #{ilevel,jdbcType=INTEGER} </if> <if test="sysadminid != null" > AND doc_catalog.sysadminid = #{sysadminid,jdbcType=INTEGER} </if> <if test="itype != null" > AND doc_catalog.itype = #{itype,jdbcType=INTEGER} </if> <if test="sname != null" > AND doc_catalog.sname = #{sname,jdbcType=VARCHAR} </if> <if test="isshow != null" > AND doc_catalog.isshow = #{isshow,jdbcType=INTEGER} </if> </where> ORDER BY doc_catalog.isortno DESC </select> <resultMap id="BaseResultMaps" type="com.yunniu.farming.webadmin.model.DocCatalog" > <id column="id" property="id" jdbcType="INTEGER" /> <result column="saccesstoken" property="saccesstoken" jdbcType="VARCHAR" /> <result column="sysadminid" property="sysadminid" jdbcType="INTEGER" /> <result column="mchid" property="mchid" jdbcType="INTEGER" /> <result column="productid" property="productid" jdbcType="INTEGER" /> <result column="itype" property="itype" jdbcType="INTEGER" /> <result column="sname" property="sname" jdbcType="VARCHAR" /> <result column="sicon" property="sicon" jdbcType="VARCHAR" /> <result column="spath" property="spath" jdbcType="VARCHAR" /> <result column="sdesc" property="sdesc" jdbcType="LONGVARCHAR" /> <result column="ilevel" property="ilevel" jdbcType="INTEGER" /> <result column="parentid" property="parentid" jdbcType="INTEGER" /> <result column="iablepubinfo" property="iablepubinfo" jdbcType="INTEGER" /> <result column="isshow" property="isshow" jdbcType="INTEGER" /> <result column="isortno" property="isortno" jdbcType="INTEGER" /> <result column="tcreatetime" property="tcreatetime" jdbcType="INTEGER" /> <result column="sdef1" property="sdef1" jdbcType="VARCHAR" /> <result column="sdef2" property="sdef2" jdbcType="VARCHAR" /> <result column="sdef3" property="sdef3" jdbcType="VARCHAR" /> <result column="sdef4" property="sdef4" jdbcType="VARCHAR" /> <result column="sdef5" property="sdef5" jdbcType="VARCHAR" /> <result column="idef6" property="idef6" jdbcType="INTEGER" /> <result column="idef7" property="idef7" jdbcType="INTEGER" /> <result column="ddef8" property="ddef8" jdbcType="DECIMAL" /> <result column="ddef9" property="ddef9" jdbcType="DECIMAL" /> <result column="ddef10" property="ddef10" jdbcType="TIMESTAMP" /> <!-- FRICE TODO 一对多 关联查询 --> <!-- 注意 此处一对多关联查询,SQL语句只执行一次,但是会查询出来关联1对N的集合,并且自动封装 --> <collection property="prosubs" column="catalogid" ofType="com.yunniu.farming.webadmin.model.Product"> <id column="sub_id" property="id" jdbcType="INTEGER" /> <result column="sub_catalogid" property="catalogid" jdbcType="INTEGER" /> <result column="sub_itype" property="itype" jdbcType="INTEGER" /> <result column="sub_sname" property="sname" jdbcType="VARCHAR" /> <result column="sub_sshortpic" property="sshortpic" jdbcType="VARCHAR" /> <result column="sub_doldprice" property="doldprice" jdbcType="DECIMAL" /> <result column="sub_dsaleprice" property="dsaleprice" jdbcType="DECIMAL" /> <result column="sub_isalenum" property="isalenum" jdbcType="INTEGER" /> </collection> </resultMap> <!-- FRICE TODO 带参数查询子对象 Start --> <sql id="Full_Column_List"> doc_catalog.id,doc_catalog.mchid,doc_catalog.saccesstoken,doc_catalog.itype, doc_catalog.sname,doc_catalog.sicon,doc_catalog.ilevel,doc_catalog.parentid,doc_catalog.isshow,doc_catalog.isortno,doc_catalog.tcreatetime, doc_catalog.spath,doc_catalog.sdesc, doc_catalog.sdef1, doc_catalog.sdef2,doc_catalog.sdef3,doc_catalog.sdef4,doc_catalog.sdef5,doc_catalog.idef6,doc_catalog.idef7,doc_catalog.ddef8, doc_catalog.ddef9,doc_catalog.ddef10 </sql> <!-- 自关联查询对象字段 --> <sql id="SubDc_Column_List" > sub.id AS sub_id ,sub.catalogid AS sub_catalogid, sub.itype AS sub_itype , sub.sname AS sub_sname , sub.sshortpic AS sub_sshortpic, sub.doldprice AS sub_doldprice , sub.dsaleprice AS sub_dsaleprice,sub.isalenum AS sub_isalenum </sql> <select id="selectProSubByParam" resultMap="BaseResultMaps" parameterType="com.yunniu.farming.webadmin.model.DocCatalog"> SELECT <include refid="Full_Column_List" /> , <include refid="SubDc_Column_List" /> FROM doc_catalog inner JOIN product sub ON doc_catalog.id = sub.catalogid <where> sub.istatus = 1 <if test="id != null"> AND doc_catalog.id = #{id,jdbcType=INTEGER} </if> <if test="sname != null"> AND doc_catalog.sname like '%${sname}%' </if> <if test="itype != null"> AND doc_catalog.itype = #{itype,jdbcType=INTEGER} </if> <if test="isshow != null"> AND doc_catalog.isshow = #{isshow,jdbcType=INTEGER} </if> <if test="mchid != null"> AND doc_catalog.mchid = #{mchid,jdbcType=INTEGER} </if> </where> ORDER BY doc_catalog.isortno DESC </select> </mapper>