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

springboot查詢(xún)?nèi)坎块T(mén)流程分析

 更新時(shí)間:2024年10月14日 11:41:19   作者:golemon  
本文分析了在SpringBoot框架中前端如何請(qǐng)求DeptController的list()方法,并通過(guò)DeptService到DeptMapper接口查詢(xún)數(shù)據(jù)庫(kù)中的全部部門(mén)信息的流程,整個(gè)過(guò)程涉及前端到后端數(shù)據(jù)的獲取和返回,是SpringBoot應(yīng)用中常見(jiàn)的數(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;
/**
 * 部門(mén)管理Controller
 */
@Slf4j
@RestController
public class DeptController {
    @Autowired
    private DeptService deptService;
    //    @RequestMapping(value = "/depts", method = RequestMethod.GET) // 指定請(qǐng)求參數(shù)為 GET
    @GetMapping("/depts") // 等同于上面的寫(xiě)法
    public Result list() {
//        System.out.println("查詢(xún)?nèi)坎块T(mén)數(shù)據(jù)");
        log.info("查詢(xún)?nèi)坎块T(mén)數(shù)據(jù)");
        // 調(diào)用service查詢(xún)部門(mén)數(shù)據(jù)
        List<Dept> deptList = deptService.list();
        return Result.success(deptList);
    }
}

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

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

package com.intelligent_learning_aid_system.service;
import com.intelligent_learning_aid_system.pojo.Dept;
import java.util.List;
/**
 * 部門(mén)管理
 */
public interface DeptService {
    /**
     * 查詢(xún)?nèi)坎块T(mén)
     * @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;
    /**
     * 查詢(xún)?nèi)坎块T(mén)
     */
    public List<Dept> list() {
        return deptMapper.list();
    }
}

DeptMapper接口會(huì)往數(shù)據(jù)庫(kù)發(fā)送SQL語(yǔ)句,查詢(xún)?nèi)康牟块T(mén),并且把查詢(xún)的信息封裝到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;
/**
 * 部門(mén)管理
 */
@Mapper
public interface DeptMapper {
    /**
     * 查詢(xún)?nèi)坎块T(mén)
     * @return
     */
    @Select("select * from dept")
    List<Dept> list();
}

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

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

相關(guān)文章

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

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

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

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

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

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

    后端業(yè)務(wù)開(kāi)發(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在開(kāi)發(fā)中最好不要嵌套使用,容易導(dǎo)致死鎖,需要的朋友可以參考下
    2024-01-01
  • SpringBoot實(shí)現(xiàn)讀取YML,yaml,properties文件

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

    yml,yaml,properties三種文件都是用來(lái)存放配置的文件,一些靜態(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)用來(lái)說(shuō),重啟時(shí)間需要花費(fèi)大量的時(shí)間成本,本文就來(lái)詳解熱部署方案,需要的朋友可以參考下
    2023-05-05
  • Eclipse Debug模式的開(kāi)啟與關(guān)閉問(wèn)題簡(jiǎn)析

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

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

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

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

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

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

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

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

最新評(píng)論

南江县| 滦南县| 洪江市| 宣恩县| 商洛市| 紫阳县| 饶河县| 萍乡市| 霍城县| 榕江县| 永济市| 汉川市| 海城市| 昌图县| 从江县| 皋兰县| 华池县| 琼中| 稷山县| 呈贡县| 阳春市| 都匀市| 赣榆县| 云和县| 昌平区| 盐池县| 龙川县| 黑河市| 峨眉山市| 德州市| 新和县| 永善县| 昌平区| 双鸭山市| 松溪县| 连平县| 梅州市| 梁平县| 墨玉县| 安多县| 永川市|