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.mzph.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…