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>