SSM中接口+mapper文件(增删改查)

IActivateInfoDao接口

public interface IActivateInfoDao{//根据用户id和验证类型,判断认证是否已存在ActivateInfo selectByUserIdAndType(@Param("userId") String userId, @Param("type") String type);//插入int insert(ActivateInfo activateInfo);//更新int update(ActivateInfo activateInfo);//根据id删除int delete(String id);//根据传入的参数获取ActivateInfo selectByEmailAndCodeAndType(@Param("email") String email,@Param("code") String code,@Param("type") String type);
}

IActivateInfoDao映射文件mapper

<?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="cn.javaex.yaoqishan.dao.activate_info.IActivateInfoDAO"><!-- 建立sql查询结果接口与实体属性的映射关系 --><resultMap id="ActivateInfoMap" type="cn.javaex.yaoqishan.view.ActivateInfo"><result column="id" property="id"/><result column="user_id" property="userId"/><result column="type" property="type"/><result column="code" property="code"/><result column="create_time" property="createTime"/></resultMap><!-- 根据用户id和验证类型,判断认证是否已存在 --><select id="selectByUserIdAndType" resultMap="ActivateInfoMap">SELECT*FROMactivate_infoWHEREuser_id = #{userId}AND type = #{type}</select><!-- 插入 --><insert id="insert">INSERT INTO activate_info<trim prefix="(" suffix=")" suffixOverrides=","><if test="userId!=null and userId!=''">user_id,</if><if test="type!=null and type!=''">type,</if><if test="code!=null and code!=''">code,</if><if test="createTime!=null and createTime!=''">create_time,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="userId!=null and userId!=''">#{userId},</if><if test="type!=null and type!=''">#{type},</if><if test="code!=null and code!=''">#{code},</if><if test="createTime!=null and createTime!=''">#{createTime},</if></trim></insert><!-- 更新 --><update id="update">UPDATE activate_info<set><if test="userId!=null">user_id=#{userId},</if><if test="type!=null">type=#{type},</if><if test="code!=null">code=#{code},</if><if test="createTime!=null">create_time=#{createTime},</if></set>WHERE id = #{id}</update><!-- 删除验证记录 --><delete id="delete">DELETE FROM activate_info WHERE id = #{id}</delete><!-- 获取验证记录 --><select id="selectByEmailAndCodeAndType" resultMap="ActivateInfoMap">SELECTai.user_id,ai.create_timeFROMuser_info ui,activate_info aiWHEREui.id = ai.user_idAND ui.email = #{email}AND ai.code = #{code}AND ai.type = #{type}</select>
</mapper>

IApiInfoDAO 接口

public interface IApiInfoDAO {//查询指定类型的接口列表List<ApiInfo> listByType(String type);int insert(ApiInfo apiInfo);int update(ApiInfo apiInfo);//根据数组批量删除接口int delete(@Param("idArr") String[] idArr);Map<String, Object> selectById(String id);//用自定义SQL文更新int updateSQL(@Param("alterSql") String alterSql);//判断字段有没有被接口使用int countByField(@Param("field") String field);//向接口表中添加字段void alter(@Param("alterSql") String alterSql);int updateRankSet(ApiInfo apiInfo);}
<?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="cn.javaex.yaoqishan.dao.api_info.IApiInfoDAO"><!-- 建立sql查询结果接口与实体属性的映射关系 --><resultMap id="ApiInfoMap" type="cn.javaex.yaoqishan.view.ApiInfo"><result column="id" property="id"/><result column="name" property="name"/><result column="sort" property="sort"/><result column="type" property="type"/><result column="type_id" property="typeId"/><result column="rank_type" property="rankType"/><result column="select_video" property="selectVideo"/><result column="cache_time" property="cacheTime"/></resultMap><!-- 插入字段 --><insert id="alter">${alterSql}</insert><!-- 查询指定类型的接口列表 --><select id="listByType" resultMap="ApiInfoMap">SELECT*FROMapi_infoWHEREtype = #{type}ORDER BYsort</select><!-- 根据主键,获取接口设置条件 --><select id="selectById" resultType="hashmap">SELECT*FROMapi_infoWHEREid = #{id}</select><!-- 插入新的接口 --><insert id="insert">INSERT INTO api_info<trim prefix="(" suffix=")" suffixOverrides=","><if test="sort!=null and sort!=''">sort,</if><if test="name!=null and name!=''">name,</if><if test="type!=null and type!=''">type,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="sort!=null and sort!=''">#{sort},</if><if test="name!=null and name!=''">#{name},</if><if test="type!=null and type!=''">#{type},</if></trim></insert><!-- 更新接口 --><update id="update">UPDATE api_info<set><if test="sort!=null">sort=#{sort},</if><if test="name!=null">name=#{name},</if><if test="type!=null">type=#{type},</if></set>WHERE id = #{id}</update><!-- 删除接口 --><delete id="delete">DELETE FROM api_info WHERE id IN<foreach collection="idArr" index="index" item="item" open="(" separator="," close=")">#{item}</foreach></delete><!-- 更新一条接口 --><update id="updateSQL">${alterSql}</update><!-- 判断字段有没有被接口使用 --><select id="countByField" resultType="int">SELECTCOUNT(*)FROMapi_infoWHEREISNULL(${field}, '') != ''</select><!-- 更新接口 --><update id="updateRankSet">UPDATE api_info<set><if test="typeId!=null">type_id=#{typeId},</if><if test="rankType!=null">rank_type=#{rankType},</if><if test="num!=null">num=#{num},</if><if test="selectVideo!=null">select_video=#{selectVideo},</if><if test="cacheTime!=null">cache_time=#{cacheTime},</if></set>WHERE id = #{id}</update>
</mapper>

IChannelInfoDAO接口

public interface IChannelInfoDAO {/*** 查询频道栏目列表*/List<ChannelInfo> list();//插入传入的对象int insert(ChannelInfo channelInfo);//传入对象参数进行查询int update(ChannelInfo channelInfo);//根据id查询ChannelInfo selectById(String id);//根据id删除int delete(String id);}
<?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="cn.javaex.yaoqishan.dao.channel_info.IChannelInfoDAO"><!-- 建立sql查询结果字段与实体属性的映射关系 --><resultMap id="ChannelInfoMap" type="cn.javaex.yaoqishan.view.ChannelInfo"><result column="id" property="id"/><result column="name" property="name"/><result column="sort" property="sort"/><result column="template" property="template"/><result column="title" property="title"/><result column="keywords" property="keywords"/><result column="description" property="description"/></resultMap><!-- 查询频道列表 --><select id="list" resultMap="ChannelInfoMap">SELECT*FROMchannel_infoORDER BYsort</select><!-- 根据主键查询频道信息 --><select id="selectById" resultMap="ChannelInfoMap">SELECT*FROMchannel_infoWHEREid = #{id}</select><!-- 插入新的频道 --><insert id="insert">INSERT INTO channel_info<trim prefix="(" suffix=")" suffixOverrides=","><if test="name!=null and name!=''">name,</if><if test="sort!=null and sort!=''">sort,</if><if test="template!=null and template!=''">template,</if><if test="title!=null and title!=''">title,</if><if test="keywords!=null and keywords!=''">keywords,</if><if test="description!=null and description!=''">description,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="name!=null and name!=''">#{name},</if><if test="sort!=null and sort!=''">#{sort},</if><if test="template!=null and template!=''">#{template},</if><if test="title!=null and title!=''">#{title},</if><if test="keywords!=null and keywords!=''">#{keywords},</if><if test="description!=null and description!=''">#{description},</if></trim><selectKey keyProperty="id" order="AFTER" resultType="String"><!-- 得到刚insert到数据表中的记录的主键值,只适用于自增主键 -->SELECT IDENT_CURRENT('channel_info') AS id</selectKey></insert><!-- 更新频道 --><update id="update">UPDATE channel_info<set><if test="name!=null">name=#{name},</if><if test="sort!=null">sort=#{sort},</if><if test="template!=null">template=#{template},</if><if test="title!=null">title=#{title},</if><if test="keywords!=null">keywords=#{keywords},</if><if test="description!=null">description=#{description},</if></set>WHERE id = #{id}</update><!-- 删除频道 --><delete id="delete">DELETE FROM channel_info WHERE id = #{id}</delete>
</mapper>

ICollectionInfoDAO接口

public interface ICollectionInfoDAO {/*** 根据媒体id和用户id查看*/int countByMediaIdAndUserId(@Param("mediaId") String mediaId, @Param("userId") String userId);/**添加对象*/int insert(CollectionInfo collectionInfo);/*** 删除收藏的视频*/int delete(CollectionInfo collectionInfo);/*** 获取用户的id获取视频收藏列表*/List<Map<String, Object>> listCollection(String userId);/**根据数组批量删除*/int deleteByUserIdArr(@Param("userIdArr") String[] userIdArr);}
<?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="cn.javaex.yaoqishan.dao.collection_info.ICollectionInfoDAO"><!-- 建立sql查询结果字段与实体属性的映射关系 --><resultMap id="CollectionInfoMap" type="cn.javaex.yaoqishan.view.CollectionInfo"><result column="id" property="id"/><result column="media_id" property="mediaId"/><result column="user_id" property="userId"/></resultMap><!-- 判断该视频是否已被用户收藏过了 --><select id="countByMediaIdAndUserId" resultType="int">SELECTCOUNT(*)FROMcollection_infoWHEREmedia_id = #{mediaId}AND user_id = #{userId}</select><!-- 插入新的视频收藏 --><insert id="insert">INSERT INTO collection_info<trim prefix="(" suffix=")" suffixOverrides=","><if test="mediaId!=null and mediaId!=''">media_id,</if><if test="userId!=null and userId!=''">user_id,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="mediaId!=null and mediaId!=''">#{mediaId},</if><if test="userId!=null and userId!=''">#{userId},</if></trim></insert><!-- 删除收藏的视频 --><delete id="delete">DELETEFROMcollection_infoWHEREuser_id = #{userId}<if test="mediaId!=null and mediaId!=''">AND media_id = #{mediaId}</if></delete><!-- 获取用户的视频收藏列表 --><select id="listCollection" resultType="hashmap">SELECTmi.media_id,mi.biaoti,mi.fengmian,mi.zongjishu,mi.status,ti.name AS typeNameFROMcollection_info ci,media_info mi,type_info tiWHEREci.media_id = mi.media_idAND mi.type_id = ti.idAND ci.user_id = #{userId}ORDER BYci.id DESC</select><!-- 删除收藏表中的内容 --><delete id="deleteByUserIdArr">DELETE FROM collection_info WHERE user_id IN<foreach collection="userIdArr" index="index" item="item" open="(" separator="," close=")">#{item}</foreach></delete>
</mapper>

IFieldProfileInfoDAO接口

public interface IFieldProfileInfoDAO {//根据id查询列表List<FieldProfileInfo> listByFieldId(String fieldId);int insert(FieldProfileInfo fieldProfileInfo);int update(FieldProfileInfo fieldProfileInfo);int delete(@Param("idArr") String[] idArr);String selectById(String id);List<String> selectByIdArr(@Param("idArr") String[] idArr);
}
<?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="cn.javaex.yaoqishan.dao.field_profile_info.IFieldProfileInfoDAO"><!-- 建立sql查询结果字段与实体属性的映射关系 --><resultMap id="FieldProfileInfoMap" type="cn.javaex.yaoqishan.view.FieldProfileInfo"><result column="id" property="id"/><result column="field_id" property="fieldId"/><result column="name" property="name"/><result column="sort" property="sort"/></resultMap><!-- 根据字段主键查询字段详情列表 --><select id="listByFieldId" resultMap="FieldProfileInfoMap">SELECT*FROMfield_profile_infoWHEREfield_id = #{fieldId}ORDER BYsort</select><!-- 根据主键,查询对应的文本 --><select id="selectById" resultType="String">SELECTnameFROMfield_profile_infoWHEREid = #{id}</select><!-- 根据主键数组,查询对应的文本list --><select id="selectByIdArr" resultType="String">SELECTnameFROMfield_profile_infoWHERE id IN<foreach collection="idArr" index="index" item="item" open="(" separator="," close=")">#{item}</foreach></select><!-- 插入一条新数据 --><insert id="insert">INSERT INTO field_profile_info<trim prefix="(" suffix=")" suffixOverrides=","><if test="sort!=null and sort!=''">sort,</if><if test="name!=null and name!=''">name,</if><if test="fieldId!=null and fieldId!=''">field_id,</if></trim><trim prefix="values (" suffix=")" suffixOverrides=","><if test="sort!=null and sort!=''">#{sort},</if><if test="name!=null and name!=''">#{name},</if><if test="fieldId!=null and fieldId!=''">#{fieldId},</if></trim></insert><!-- 更新一条新数据 --><update id="update">UPDATE field_profile_info<set><if test="sort!=null">sort=#{sort},</if><if test="name!=null">name=#{name},</if></set>WHERE id = #{id}</update><!-- 删除字段详情内容 --><delete id="delete">DELETE FROM field_profile_info WHERE id IN<foreach collection="idArr" index="index" item="item" open="(" separator="," close=")">#{item}</foreach></delete>
</mapper>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/37931.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

一文读懂c++语言

一文读懂C语言 C的发展C的设计目标C的特性C的挑战 C的发展 C是一种通用的、高级的编程语言&#xff0c;它是C语言的扩展。C由Bjarne Stroustrup于1983年首次引入&#xff0c;并在之后的几十年中不断发展壮大。C被广泛应用于各种领域&#xff0c;包括系统开发、游戏开发、嵌入式…

pytest数据驱动(最简单)

目录 第一种&#xff1a;通过yaml文件获取数据&#xff08;一维列表&#xff09; 第二种&#xff1a;通过yaml文件获取数据&#xff08;二维列表&#xff09; 第三种&#xff1a;通过yaml文件获取数据&#xff08;pytest.fixture&#xff09; 资料获取方法 第一种&#xff…

国际腾讯云账号云核算概述!!

云核算概述 维基百科界说&#xff1a;云核算是一种依据互联网的新型核算方法&#xff0c;经过互联网上异构、自治的服务为个人和企业供给按需即取的核算。 云核算描绘的一起特征&#xff1a;云是一种按需运用的服务&#xff0c;运用者只重视服务本身。 云核算作为IT服务形式&am…

四、Linux中cd、pwd以及相对/绝对路径和特殊路径符

1、cd命令&#xff1a; cd命令可以切换当前工作目录&#xff0c;基础语法是&#xff1a; cd [linux路径] &#xff08;1&#xff09;、打开Linux的命令提示行&#xff0c;当前工作目录是home&#xff0c;输入“cd /”&#xff0c;可以切换到根目录下&#xff0c;在根目录下输…

6_AccessKeyId和AccessKeySecret的环境变量配置

系列文章目录 第1章 Linux安装Docker 第2章 Docker安装jdk1.8和MySql 第3章 Docker安装redis 第4章 Jar包部署Docker 第5章 Docker-compose多服务统一编排管理 第6章 AccessKeyId和AccessKeySecret的环境变量配置 文章目录 系列文章目录前言一、WIN系统配置二、LINUX系统配置三…

【go语言学习笔记】05 Go 语言实战

文章目录 一、 RESTful API 服务1. RESTful API 定义1.1 HTTP Method1.2 RESTful API 规范 2. RESTful API 风格示例3. RESTful JSON API4. Gin 框架4.1 导入 Gin 框架4.2 使用 Gin 框架4.2.1 获取特定的用户&#xff08;GET&#xff09;4.2.2 新增一个用户&#xff08;POST&am…

【前端 | CSS】align-items与align-content的区别

align-items 描述 CSS align-items 属性将所有直接子节点上的 align-self 值设置为一个组。align-self 属性设置项目在其包含块中在交叉轴方向上的对齐方式 align-items是针对每一个子项起作用&#xff0c;它的基本单位是每一个子项&#xff0c;在所有情况下都有效果&…

SpringBoot复习:(31)Controller中返回的对象是如何转换成json字符串给调用者的?

首先&#xff0c;SpringBoot自动装配了HttpMessageConvertersAutoConfiguration这个自动配置类 而这个自动配置类又通过Import注解导入了JacksonHttpMessageConvertersConfiguration类&#xff0c; 在这个类中配置了一个类型为MappingJackson2HttpMessageConverter类型的bean…

vant van-tabs van-pull-refresh van-list 标签栏+上拉加载+下拉刷新

<template><div class"huibj"><div class"listtab"><!--顶部导航--><div class"topdh"><topnav topname"余额明细"></topnav></div><!--Tab 标签--><van-tabs v-model"…

Python教程(9)——Python变量类型列表list的用法介绍

列表操作 创建列表访问列表更改列表元素增加列表元素修改列表元素删除列表元素 删除列表 在Python中&#xff0c;列表&#xff08;list&#xff09;是一种有序、可变的数据结构&#xff0c;用于存储多个元素。列表可以包含不同类型的元素&#xff0c;包括整数、浮点数、字符串等…

配置 yum/dnf 置您的系统以使用默认存储库

题目 给系统配置默认存储库&#xff0c;要求如下&#xff1a; YUM 的 两 个 存 储 库 的 地 址 分 别 是 &#xff1a; ftp://host.domain8.rhce.cc/dvd/BaseOS ftp://host.domain8.rhce.cc/dvd/AppStream vim /etc/yum.repos.d/redhat.repo [base] namebase baseurlftp:/…

C语言快速回顾(一)

前言 在Android音视频开发中&#xff0c;网上知识点过于零碎&#xff0c;自学起来难度非常大&#xff0c;不过音视频大牛Jhuster提出了《Android 音视频从入门到提高 - 任务列表》&#xff0c;结合我自己的工作学习经历&#xff0c;我准备写一个音视频系列blog。C/C是音视频必…

Rabbitmq延迟消息

目录 一、延迟消息1.基于死信实现延迟消息1.1 消息的TTL&#xff08;Time To Live&#xff09;1.2 死信交换机 Dead Letter Exchanges1.3 代码实现 2.基于延迟插件实现延迟消息2.1 插件安装2.2 代码实现 3.基于延迟插件封装消息 一、延迟消息 延迟消息有两种实现方案&#xff…

2016年,进了百度

昨在深圳出差&#xff0c;与微信里的朋友吃了个便饭&#xff0c;他是今年四月份加的我微信&#xff08;gaoyang677&#xff09;&#xff0c;他的经历很有意思&#xff0c;经他许可&#xff0c;分享给大家。 2012年时候&#xff0c;他大学毕业来到深圳&#xff0c;进了厂子&…

vue3 setup+Taro3 调用原生小程序自定义年月日时分多列选择器,NutUI改造

vue3 setupTaro3 调用原生小程序自定义年月日时分多列选择器&#xff0c;NutUI改造 NutUI 有日期时间选择器&#xff0c;但是滑动效果太差&#xff0c;卡顿明显。换成 原生小程序 很顺畅 上代码&#xff1a; <template><view><pickermode"multiSelector&…

2023牛客暑期多校训练营9-J Puzzle: Star Battle

2023牛客暑期多校训练营9-J Puzzle: Star Battle https://ac.nowcoder.com/acm/contest/57363/J 文章目录 2023牛客暑期多校训练营9-J Puzzle: Star Battle题意解题思路代码 题意 解题思路 出题人都说是诈骗题&#xff08;&#xff0c;可以发现满足每行每列恰好有 n n n个星…

python数据结构和算法

python数据结构和算法 参考 python图解算法 选择/快速排序 哈希表 广度优先搜索算法 迪杰斯特拉算法 贪婪算法 动态规划 K-邻近算法 计算机科学是解决问题的研究。计算机科学使用抽象作为表示过程和数据的工具。抽象的数据类型允许程序员通过隐藏数据的细节来管理问题领域的…

【解决】Kafka Exception thrown when sending a message with key=‘null‘ 异常

问题原因&#xff1a; 如下图&#xff0c;kafka 中配置的是监听域名的方式&#xff0c;但程序里使用的是 ip:port 的连接方式。 解决办法&#xff1a; kafka 中配置的是域名的方式&#xff0c;程序里也相应配置成 域名:port 的方式&#xff08;注意&#xff1a;本地h…

机器学习笔记之优化算法(十三)关于二次上界引理

机器学习笔记之优化算法——关于二次上界引理 引言回顾&#xff1a;利普希兹连续梯度下降法介绍 二次上界引理&#xff1a;介绍与作用二次上界与最优步长之间的关系二次上界引理证明过程 引言 本节将介绍二次上界的具体作用以及它的证明过程。 回顾&#xff1a; 利普希兹连续…

uniapp 微信小程序 订阅消息

第一步&#xff0c;需要先去小程序官方挑选一下订阅模板拿到模板id 订阅按钮在头部导航上&#xff0c;所以 <u-navbar :bgColor"bgColor"><view class"u-nav-slot" slot"left" click"goSubscribe"><image :src"g…