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.pswp.cn/news/37931.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/37931.shtml
英文地址,請注明出處:http://en.pswp.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…