<?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.mbyte.easy.admin.mapper.QuestionQuestionWholeMapper">
<resultMap id="BaseResultMap" type="com.mbyte.easy.admin.entity.QuestionQuestionWhole">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="user_id" jdbcType="BIGINT" property="userId" />
<result column="category_id" jdbcType="BIGINT" property="categoryId" />
<result column="question_title" jdbcType="VARCHAR" property="questionTitle" />
<result column="question_content" jdbcType="VARCHAR" property="questionContent" />
<result column="question_check" jdbcType="INTEGER" property="questionCheck" />
<result column="question_reward" jdbcType="INTEGER" property="questionReward" />
<result column="question_top" jdbcType="INTEGER" property="questionTop" />
<result column="reply_number" jdbcType="INTEGER" property="replyNumber" />
<result column="scan_number" jdbcType="INTEGER" property="scanNumber" />
<result column="keep_number" jdbcType="INTEGER" property="keepNumber" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
<result column="nickname" jdbcType="VARCHAR" property="userNickName"/>
<collection property="categories" column="id" select="selectCatagoryByquestionId">
<id column="id" jdbcType="BIGINT" property="id" />
<result column="name" jdbcType="BIGINT" property="name" />
<result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime" />
</collection>
</resultMap>
<select id="selectCatagoryByquestionId" parameterType="java.lang.Long" resultType="com.mbyte.easy.admin.entity.QuestionSiteMenuSort">
select s.id as id,s.name as name,s.create_time as create_time,s.update_time as update_time
from t_question_menu_sort gs
left join t_question_site_menu_sort s on gs.menu_id = s.id
where gs.question_id=#{id,jdbcType=BIGINT}
</select>
<!-- 显示后台数据 开始-->
<select id="listPage" resultMap="BaseResultMap">
select <include refid="Base_Column_List"/>
from t_question_question_whole q
left join t_user_data u on u.id = q.user_id
where 1 = 1
<if test="questionQuestionWhole.userId!=null">
and q.user_id = #{questionQuestionWhole.userId,jdbcType=BIGINT}
</if>
<if test="questionQuestionWhole.userNickName!=null">
<bind name="nickname" value="'%' + questionQuestionWhole.userNickName + '%'" />
and u.nickname like #{nickname,jdbcType=VARCHAR}
</if>
<if test="questionQuestionWhole.questionTitle!=null">
<bind name="questionTitle" value="'%' + questionQuestionWhole.questionTitle + '%'" />
and q.question_title like #{questionTitle,jdbcType=VARCHAR}
</if>
</select>
StringBoot三表关联嵌套查询
最新推荐文章于 2023-10-17 11:03:31 发布