91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

如何進行Mapper多表關聯查詢

發布時間:2021-11-25 16:56:46 來源:億速云 閱讀:823 作者:柒染 欄目:編程語言

這期內容當中小編將會給大家帶來有關如何進行Mapper多表關聯查詢,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。

1、首先寫sql語句

select p.id, p.create_time, p.update_time, p.create_user, p.update_user, p.project_name, p.test_user, 
    p.dev_user, p.simple_desc, p.other_desc, p.project_code, p.belong_env_id, p.status_id,u.status_name,u.description from projectinfo_temp p LEFT JOIN usestatus u on p.status_id = u.id

2、關聯pojo

@ToString
public class ProjectinfoTemp {

    private Integer id;

    private Date createTime;

    private Date updateTime;

    private String createUser;

    private String updateUser;

    private String projectName;

    private String testUser;

    private String devUser;

    private String simpleDesc;

    private String otherDesc;

    private String projectCode;

    private Integer belongEnvId;

    private Integer statusId;
    /**
     *  關聯狀態表 激活狀態
     */
    private Usestatus usestatus;

狀態表

/**
 *
 * @author liwen406
 * @date 2019-04-21 09:12
 */
@ToString
public class Usestatus {
    private Integer id;

    private String statusName;

    private String description;

3編寫關聯sql語句

模仿寫法

<sql id="WithBase_Column_List" >
p.id, p.create_time, p.update_time, p.create_user, p.update_user, p.project_name, p.test_user,
p.dev_user, p.simple_desc, p.other_desc, p.project_code, p.belong_env_id, p.status_id,u.status_name,u.description
</sql>
<select id="selectByExample" resultMap="BaseResultMap" parameterType="com.apitest.pojo.ProjectinfoTempExample" >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="Base_Column_List" />
    from projectinfo_temp
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>

  <select id="selectByExamplestart" resultMap="WithBaseResultMap"  >
    select
    <if test="distinct" >
      distinct
    </if>
    <include refid="WithBase_Column_List" />
    from projectinfo_temp p LEFT JOIN usestatus u on p.status_id = u.id
    <if test="_parameter != null" >
      <include refid="Example_Where_Clause" />
    </if>
    <if test="orderByClause != null" >
      order by ${orderByClause}
    </if>
  </select>

4前端調用寫法

<div class="x_content">
                                <table id="datatable" class="table table-striped table-bordered">
                                    <thead>
                                    <tr>
                                        <th class="table-title">應用編號</th>
                                        <th class="table-title">應用名稱</th>
                                        <th class="table-title">測試負責人</th>
                                        <th class="table-title">開發負責人</th>
                                        <th class="table-title">模塊/接口/用例</th>
                                        <th class="table-title">狀態</th>
                                        <th class="table-title">操作</th>
                                    </tr>
                                    </thead>
                                    <tbody>
                                    <tr th:each="pagefo:${pageInfo.list}">
                                        <td th:text="${pagefo.projectCode}"></td>
                                        <td th:text="${pagefo.projectName}"></td>
                                        <td th:text="${pagefo.testUser}"></td>
                                        <td th:text="${pagefo.devUser}"></td>
                                        <td th:text="${pagefo.belongEnvId}"></td>
                                        <td th:text="${pagefo.usestatus.statusName}"></td>
                                        <td>
                                            <a type="button" class="fa fa-bug btn  btn-round btn-success"
                                               th:href="@{/run/}+${pagefo.projectCode}">運行</a>
                                            <a type="button" class="fa fa-edit btn btn-round btn-info"
                                               th:href="@{/cache/editProjectInf/}+${pagefo.projectCode}">編輯</a>
                                            <a type="button" class="fa fa-trash-o btn  btn-round btn-danger"
                                               th:href="@{/deleteProjectinfoTemp/}+${pagefo.projectCode}">刪除</a>
                                        </td>
                                    </tr>
                                    </tbody>
                                </table>
                                <div class="box-footer">
                                    <div class="pull-left">
                                        <div class="form-group form-inline">
                                            <span th:text="'共'+${pageInfo.getPages()}+'頁'"></span>,
                                            <span th:text="'當前為'+${pageInfo.getPageNum()}+'頁'"></span>
                                            <span th:text="'總'+${pageInfo.getTotal()}+'條記錄'"></span>
                                        </div>
                                    </div>

                                    <div class="box-tools pull-right">
                                        <ul class="pagination">
                                            <li><a th:href="@{/cache/project_list_cache(start=0)}"
                                                   aria-label="Previous">[首 頁]</a></li>
                                            <li><a th:href="@{/cache/project_list_cache(start=${pageInfo.pageNum-1})}">[上一頁]</a>
                                            </li>
                                            <li><a th:href="@{/cache/project_list_cache(start=${pageInfo.pageNum+1})}">[下一頁]</a>
                                            </li>
                                            <li><a th:href="@{/cache/project_list_cache(start=${pageInfo.pages})}"
                                                   aria-label="Next">[尾 頁]</a></li>
                                        </ul>
                                    </div>
                                </div>
                            </div>

5、訪問結果顯示

如何進行Mapper多表關聯查詢

上述就是小編為大家分享的如何進行Mapper多表關聯查詢了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

武宣县| 石泉县| 松桃| 峨边| 微博| 合水县| 平乐县| 昆山市| 库车县| 资兴市| 莱州市| 工布江达县| 舞钢市| 芦山县| 体育| 清新县| 科尔| 阿荣旗| 安陆市| 宁远县| 陆河县| 淄博市| 泰安市| 炎陵县| 潜江市| 乐安县| 青田县| 高清| 芒康县| 静宁县| 兴山县| 嘉祥县| 新密市| 开鲁县| 区。| 连江县| 屏东市| 偃师市| 收藏| 庆安县| 武宣县|