Mysql mybatis 語法示例

?service

package com.ruoyi.goods.service;import java.util.List;
import com.ruoyi.goods.domain.GoodsProducts;/*** 商品Service接口* * @author ruoyi* @date 2023-08-27*/
public interface IGoodsProductsService 
{/*** 查詢商品* * @param ProductID 商品主鍵* @return 商品*/public GoodsProducts selectGoodsProductsByProductID(Long ProductID);/*** 查詢商品列表* * @param goodsProducts 商品* @return 商品集合*/public List<GoodsProducts> selectGoodsProductsList(GoodsProducts goodsProducts);/*** 新增商品* * @param goodsProducts 商品* @return 結果*/public int insertGoodsProducts(GoodsProducts goodsProducts);/*** 修改商品* * @param goodsProducts 商品* @return 結果*/public int updateGoodsProducts(GoodsProducts goodsProducts);/*** 批量刪除商品* * @param ProductIDs 需要刪除的商品主鍵集合* @return 結果*/public int deleteGoodsProductsByProductIDs(Long[] ProductIDs);/*** 刪除商品信息* * @param ProductID 商品主鍵* @return 結果*/public int deleteGoodsProductsByProductID(Long ProductID);
}

?xml

<?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.ruoyi.goods.mapper.GoodsProductsMapper"><resultMap type="GoodsProducts" id="GoodsProductsResult"><result property="ProductID"    column="ProductID"    /><result property="Name"    column="Name"    /><result property="Price"    column="Price"    /><result property="Description"    column="Description"    /><result property="Category"    column="Category"    /><result property="StockQuantity"    column="StockQuantity"    /></resultMap><sql id="selectGoodsProductsVo">select ProductID, Name, Price, Description, Category, StockQuantity from goods_products</sql><select id="selectGoodsProductsList" parameterType="GoodsProducts" resultMap="GoodsProductsResult"><include refid="selectGoodsProductsVo"/><where><if test="Name != null  and Name != ''"> and Name like concat('%', #{Name}, '%')</if><if test="Price != null "> and Price = #{Price}</if><if test="Description != null  and Description != ''"> and Description = #{Description}</if><if test="Category != null  and Category != ''"> and Category = #{Category}</if><if test="StockQuantity != null "> and StockQuantity = #{StockQuantity}</if></where></select><select id="selectGoodsProductsByProductID" parameterType="Long" resultMap="GoodsProductsResult"><include refid="selectGoodsProductsVo"/>where ProductID = #{ProductID}</select><insert id="insertGoodsProducts" parameterType="GoodsProducts" useGeneratedKeys="true" keyProperty="ProductID">insert into goods_products<trim prefix="(" suffix=")" suffixOverrides=","><if test="Name != null and Name != ''">Name,</if><if test="Price != null">Price,</if><if test="Description != null">Description,</if><if test="Category != null">Category,</if><if test="StockQuantity != null">StockQuantity,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="Name != null and Name != ''">#{Name},</if><if test="Price != null">#{Price},</if><if test="Description != null">#{Description},</if><if test="Category != null">#{Category},</if><if test="StockQuantity != null">#{StockQuantity},</if></trim></insert><update id="updateGoodsProducts" parameterType="GoodsProducts">update goods_products<trim prefix="SET" suffixOverrides=","><if test="Name != null and Name != ''">Name = #{Name},</if><if test="Price != null">Price = #{Price},</if><if test="Description != null">Description = #{Description},</if><if test="Category != null">Category = #{Category},</if><if test="StockQuantity != null">StockQuantity = #{StockQuantity},</if></trim>where ProductID = #{ProductID}</update><delete id="deleteGoodsProductsByProductID" parameterType="Long">delete from goods_products where ProductID = #{ProductID}</delete><delete id="deleteGoodsProductsByProductIDs" parameterType="String">delete from goods_products where ProductID in <foreach item="ProductID" collection="array" open="(" separator="," close=")">#{ProductID}</foreach></delete>
</mapper>

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/215054.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/215054.shtml
英文地址,請注明出處:http://en.pswp.cn/news/215054.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

基于OpenCV+CNN+IOT+微信小程序智能果實采摘指導系統——深度學習算法應用(含python、JS工程源碼)+數據集+模型(三)

目錄 前言總體設計系統整體結構圖系統流程圖 運行環境Python環境TensorFlow 環境Jupyter Notebook環境Pycharm 環境微信開發者工具OneNET云平臺 模塊實現1. 數據預處理1&#xff09;爬取功能2&#xff09;下載功能 2. 創建模型并編譯1&#xff09;定義模型結構2&#xff09;優化…

Docker與K8s的區別

Docker 和 K8s&#xff08;Kubernetes&#xff09;是兩個不同的技術&#xff0c;它們在容器化應用程序的管理和部署方面有著不同的角色和功能。 Docker 是一種容器化平臺&#xff0c;它允許您將應用程序及其所有依賴項打包到一個獨立的、可移植的容器中。Docker 提供了一種輕量…

《PySpark大數據分析實戰》-03.了解Hive

&#x1f4cb; 博主簡介 &#x1f496; 作者簡介&#xff1a;大家好&#xff0c;我是wux_labs。&#x1f61c; 熱衷于各種主流技術&#xff0c;熱愛數據科學、機器學習、云計算、人工智能。 通過了TiDB數據庫專員&#xff08;PCTA&#xff09;、TiDB數據庫專家&#xff08;PCTP…

恢復Django 項目

隨筆記錄 目錄 1. 重建Mysql DB 2. 啟動Django 項目 2.1 確保你的系統上已安裝pip工具。你可以使用以下命令來檢查pip是否已安裝 2.2 安裝Packages 2.2.1 安裝Django 2.2.2 安裝pymysql 2.2.3 安裝 kafka 2.2.4 安裝 requests 2.2.5 安裝simplepro 2.2.6 安裝libjp…

持續集成交付CICD:GitLabCI上傳Nexus制品

目錄 一、實驗 1.GitLabCI上傳Nexus制品 2.優化GitLabCI&#xff08;引用系統變量&#xff09; 3.添加if條件判斷項目類型 4.優化GitLabCI&#xff08;模板類&#xff09; 二、問題 1.GitLabCI獲取jar文件失敗 2. GitLabCI獲取流水線項目命名空間失敗 3.GItLab Packag…

.NET 8 編寫 LiteDB vs SQLite 數據庫 CRUD 接口性能測試(準備篇)

WebAppDbTest 項目準備 項目準備1、.net cli 創建項目2、nuget 包引用和項目結構2.1、項目添加相關 nuget 包2.2、WebAppDbTest 項目結構 3、項目代碼說明3.1、CSharp/C# 類文件說明3.2、json 配置文件說明 4、項目運行預覽 數據庫 .db 文件準備1、創建 SQLite 數據庫1.1、在 W…

c#讀取CSV文件跟Excel導入成DataTble

1.讀取CSV文件 /// <summary>/// 讀取CSV文件/// </summary>/// <param name"fileName">文件路徑</param>public static DataTable ReadCSV(string fileName){DataTable dt new DataTable();FileStream fs new FileStream(fileName, FileM…

Python---綜合案例

一、系統需求分析 1、需求分析 使用面向對象編程思想完成學員管理系統的開發&#xff0c;具體如下&#xff1a; ① 系統要求&#xff1a;學員數據存儲在文件中 ② 系統功能&#xff1a;添加學員、刪除學員、修改學員信息、查詢學員信息、顯示所有學員信息、保存學員信息及退…

56.windows docker 安裝ES、Go操作ES

文章目錄 一、環境準備1、 docker安裝ES2、啟動容器3、圖像化客戶端工具ElasticSearch-Head 二、Go ES連接與認證1、 連接ES2、配置ES認證 三、索引的增刪改查四、文檔的增刪改創建單個文檔根據文檔id刪除文檔批量刪除文檔批量創建文檔 五、文檔查詢列表查詢精確匹配模糊匹配嵌…

ubuntu18.04配置cuda+cudnn+tensorrt+anconda+pytorch-gpu+pycharm

一、顯卡驅動安裝 執行nvidia-smi查看安裝情況 二、cuda安裝 cuda官網下載cuda_11.6.2_510.47.03_linux.run&#xff0c;安裝執行 sudo sh cuda_11.6.2_510.47.03_linux.run提升安裝項&#xff0c;驅動不用安裝&#xff0c;即第一項&#xff08;Driver&#xff09;&#xff…

如何使用Java在Excel中添加動態數組公式?

本文由葡萄城技術團隊發布。轉載請注明出處&#xff1a;葡萄城官網&#xff0c;葡萄城為開發者提供專業的開發工具、解決方案和服務&#xff0c;賦能開發者。 前言 動態數組公式是 Excel 引入的一項重要功能&#xff0c;它將 Excel 分為兩種風格&#xff1a;Excel 365 和傳統 …

虹科技術 | IO-Link Wireless如何賦能工廠車間邁向無線自動化?

大規模定制、卓越運營和商業智能正在從根本上改變制造業&#xff0c;為了在競爭中立于不敗之地&#xff0c;制造商需要更加靈活、通用、可擴展和具有成本效益的機器和生產線。隨著制造商向工業 4.0 邁進&#xff0c;更好的適應性、更高的吞吐量和更短的停機時間是他們的共同要求…

打包CSS

接上一個打包HTML繼續進行CSS的打包 1.在之前的文件夾里的src文件夾創建一個css文件 2.在瀏覽器打開webpack——>中文文檔——>指南——>管理資源——>加載CSS 3.復制第一句代碼到終端 4.復制下圖代碼到webpack.config.js腳本的plugins&#xff1a;[.....]內容下…

【docker】Hello World

搜索hello-world鏡像 docker search hello-world拉去鏡像 docker pull hello-world查看本地鏡像 docker images 運行鏡像 docker run hello-world查看所有的容器 docker ps -a查詢start狀態容器 docker ps 輸出介紹 CONTAINER ID: 容器 ID。IMAGE: 使用的鏡像。COMMAN…

面試經典150題(14)

leetcode 150道題 計劃花兩個月時候刷完&#xff0c;今天&#xff08;第五天&#xff09;完成了1道(14)150&#xff1a; 14. &#xff08;134. 加油站&#xff09;題目描述&#xff1a; 在一條環路上有 n 個加油站&#xff0c;其中第 i 個加油站有汽油 gas[i] 升。 你有一輛油…

<JavaEE> 鎖進階 -- synchronized 的鎖優化

目錄 一、如何形容 synchronized 鎖 二、鎖升級 2.1 偏向鎖 2.2 輕量級鎖 2.3 重量級鎖 三、鎖消除 四、鎖粗化 一、如何形容 synchronized 鎖 synchronized 鎖是一個內部優化非常好的鎖&#xff0c;大部分情況下這個鎖都是適用的。在初始階段 synchronized 是一個樂觀…

分布式搜索引擎02

分布式搜索引擎02 在昨天的學習中&#xff0c;我們已經導入了大量數據到elasticsearch中&#xff0c;實現了elasticsearch的數據存儲功能。但elasticsearch最擅長的還是搜索和數據分析。 所以今天&#xff0c;我們研究下elasticsearch的數據搜索功能。我們會分別使用DSL和Res…

react面試總結2

redux中sages和thunk中間件的區別&#xff0c;優缺點 Redux 中的 redux-saga 和 redux-thunk 都是中間件&#xff0c;用于處理異步操作&#xff0c;但它們有一些區別。 Redux Thunk&#xff1a; 簡單易用&#xff1a;redux-thunk 是比較簡單直觀的中間件&#xff0c;它允許 …

手撕分布式緩存---HTTP Server搭建

經過了前兩個章節的學習&#xff0c;分布式緩存的存儲與新增我們已經實現了&#xff0c;并且對其做了高可用處理。本章節我們剝離和緩存強相關的邏輯&#xff0c;開始搭建一個HTTP服務器&#xff0c;畢竟緩存數據庫搭建完之后別人沒法訪問也是沒有用處的。這一章節我們重點學習…

ElasticSearch應用場景以及技術選型[ES系列] - 第496篇

歷史文章&#xff08;文章累計490&#xff09; 《國內最全的Spring Boot系列之一》 《國內最全的Spring Boot系列之二》 《國內最全的Spring Boot系列之三》 《國內最全的Spring Boot系列之四》 《國內最全的Spring Boot系列之五》 《國內最全的Spring Boot系列之六》 M…