最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

springboot查詢?nèi)坎块T流程分析

 更新時(shí)間:2024年10月14日 11:41:19   作者:golemon  
本文分析了在SpringBoot框架中前端如何請(qǐng)求DeptController的list()方法,并通過DeptService到DeptMapper接口查詢數(shù)據(jù)庫(kù)中的全部部門信息的流程,整個(gè)過程涉及前端到后端數(shù)據(jù)的獲取和返回,是SpringBoot應(yīng)用中常見的數(shù)據(jù)處理模式

前端發(fā)送請(qǐng)求后,會(huì)請(qǐng)求DeptController的方法list()。

package com.intelligent_learning_aid_system.controller;
import com.intelligent_learning_aid_system.pojo.Dept;
import com.intelligent_learning_aid_system.pojo.Result;
import com.intelligent_learning_aid_system.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
 * 部門管理Controller
 */
@Slf4j
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;
    //    @RequestMapping(value = "/depts", method = RequestMethod.GET) // 指定請(qǐng)求參數(shù)為 GET
    @GetMapping("/depts") // 等同于上面的寫法
    public Result list() {
//        System.out.println("查詢?nèi)坎块T數(shù)據(jù)");
        log.info("查詢?nèi)坎块T數(shù)據(jù)");
        // 調(diào)用service查詢部門數(shù)據(jù)
        List<Dept> deptList = deptService.list();
        return Result.success(deptList);
    }
}

list()中調(diào)用DeptService獲取數(shù)據(jù)。

DeptService中調(diào)用DeptMapper接口中的方法來查詢?nèi)康牟块T信息。

package com.intelligent_learning_aid_system.service;
import com.intelligent_learning_aid_system.pojo.Dept;
import java.util.List;
/**
 * 部門管理
 */
public interface DeptService {
    /**
     * 查詢?nèi)坎块T
     * @return
     */
    List<Dept> list();
}
package com.intelligent_learning_aid_system.service.impl;
import com.intelligent_learning_aid_system.mapper.DeptMapper;
import com.intelligent_learning_aid_system.pojo.Dept;
import com.intelligent_learning_aid_system.service.DeptService;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Select;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
@Slf4j
@Service
public class DeptServiceImpl implements DeptService {
    @Autowired
    private DeptMapper deptMapper;
    /**
     * 查詢?nèi)坎块T
     */
    public List<Dept> list() {
        return deptMapper.list();
    }
}

DeptMapper接口會(huì)往數(shù)據(jù)庫(kù)發(fā)送SQL語(yǔ)句,查詢?nèi)康牟块T,并且把查詢的信息封裝到List<Dept>集合中。

package com.intelligent_learning_aid_system.mapper;
import com.intelligent_learning_aid_system.pojo.Dept;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.web.bind.annotation.GetMapping;
import java.util.List;
/**
 * 部門管理
 */
@Mapper
public interface DeptMapper {
    /**
     * 查詢?nèi)坎块T
     * @return
     */
    @Select("select * from dept")
    List<Dept> list();
}

最終將集合數(shù)據(jù)返回給DeptService,DeptService又返回給DeptController。DeptController拿到數(shù)據(jù)再返回給前端。

到此這篇關(guān)于springboot查詢?nèi)坎块T流程的文章就介紹到這了,更多相關(guān)springboot查詢?nèi)坎块T內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • Spring 處理 HTTP 請(qǐng)求參數(shù)注解的操作方法

    Spring 處理 HTTP 請(qǐng)求參數(shù)注解的操作方法

    這篇文章主要介紹了Spring 處理 HTTP 請(qǐng)求參數(shù)注解的操作方法,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),感興趣的朋友參考下吧
    2024-04-04
  • Java實(shí)現(xiàn)在word中指定位置插入圖片

    Java實(shí)現(xiàn)在word中指定位置插入圖片

    Poi-tl?是基于?Apache?POI?的?Java?開源文檔處理庫(kù),專注于高效操作?Word?文檔,本文小編就來和大家詳細(xì)講講Java如何使用Poi-tl實(shí)現(xiàn)在word中指定位置插入圖片吧
    2025-06-06
  • SpringBoot快速整合通用Mapper的示例代碼

    SpringBoot快速整合通用Mapper的示例代碼

    后端業(yè)務(wù)開發(fā),每個(gè)表都要用到單表的?增刪改查?等通用方法,而配置了通用Mapper可以極大的方便使用Mybatis單表的增刪改查操作,這篇文章主要介紹了SpringBoot快速整合通用Mapper,需要的朋友可以參考下
    2022-07-07
  • Java死鎖代碼實(shí)例及產(chǎn)生死鎖必備的四個(gè)條件

    Java死鎖代碼實(shí)例及產(chǎn)生死鎖必備的四個(gè)條件

    這篇文章主要介紹了Java死鎖代碼實(shí)例及產(chǎn)生死鎖必備的四個(gè)條件,Java 發(fā)生死鎖的根本原因是,在申請(qǐng)鎖時(shí)發(fā)生了交叉閉環(huán)申請(qǐng),synchronized在開發(fā)中最好不要嵌套使用,容易導(dǎo)致死鎖,需要的朋友可以參考下
    2024-01-01
  • SpringBoot實(shí)現(xiàn)讀取YML,yaml,properties文件

    SpringBoot實(shí)現(xiàn)讀取YML,yaml,properties文件

    yml,yaml,properties三種文件都是用來存放配置的文件,一些靜態(tài)數(shù)據(jù),配置的數(shù)據(jù)都會(huì)存放到里邊。本文主要為大家整理了SpringBoot實(shí)現(xiàn)讀取YML,yaml,properties文件的方法,需要的可以參考一下
    2023-04-04
  • 關(guān)于SpringBoot的熱部署方案

    關(guān)于SpringBoot的熱部署方案

    這篇文章主要介紹了關(guān)于SpringBoot的熱部署方案,每次修改代碼就得將項(xiàng)目重啟,重新部署,對(duì)于一些大型應(yīng)用來說,重啟時(shí)間需要花費(fèi)大量的時(shí)間成本,本文就來詳解熱部署方案,需要的朋友可以參考下
    2023-05-05
  • Eclipse Debug模式的開啟與關(guān)閉問題簡(jiǎn)析

    Eclipse Debug模式的開啟與關(guān)閉問題簡(jiǎn)析

    這篇文章主要介紹了Eclipse Debug模式的開啟與關(guān)閉問題簡(jiǎn)析,同時(shí)向大家介紹了一個(gè)簡(jiǎn)單的debug模式啟動(dòng)不起來的解決方法,希望對(duì)大家有所幫助。
    2017-10-10
  • Java反射機(jī)制如何解決數(shù)據(jù)傳值為空的問題

    Java反射機(jī)制如何解決數(shù)據(jù)傳值為空的問題

    這篇文章主要介紹了Java反射機(jī)制如何解決數(shù)據(jù)傳值為空的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-03-03
  • 從Myeclipse 導(dǎo)入到eclipse中無法識(shí)別為 web項(xiàng)目 問題的解決步驟

    從Myeclipse 導(dǎo)入到eclipse中無法識(shí)別為 web項(xiàng)目 問題的解決步驟

    這篇文章主要介紹了從Myeclipse 導(dǎo)入到eclipse中無法識(shí)別為 web項(xiàng)目 問題的解決步驟,需要的朋友可以參考下
    2018-05-05
  • SprigBoot整合rocketmq-v5-client-spring-boot的示例詳解

    SprigBoot整合rocketmq-v5-client-spring-boot的示例詳解

    這篇文章主要介紹了SprigBoot整合rocketmq-v5-client-spring-boot的詳細(xì)過程,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧
    2010-07-07

最新評(píng)論

武乡县| 响水县| 扎赉特旗| 江油市| 翁源县| 岗巴县| 普陀区| 淮阳县| 兴安县| 阆中市| 康乐县| 福鼎市| 铅山县| 长垣县| 宁都县| 武平县| 苏尼特右旗| 达孜县| 博野县| 当涂县| 嵊州市| 涞源县| 曲周县| 攀枝花市| 庄浪县| 长治市| 泸西县| 蕉岭县| 宜城市| 兴和县| 武胜县| 白朗县| 兰溪市| 伽师县| 贺兰县| 称多县| 托克逊县| 长白| 麻阳| 余江县| 余庆县|