通用mapper配置
mapper配置与接口对应关系
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="com.example.Mapper.TeamMapper"> <select id="getById" parameterType="String" resultType="com.example.Entity.Team_event"> SELECT * FROM teamevent WHERE id=#{id} </select> </mapper>
package com.example.Mapper; import com.example.Entity.Team_event; import com.example.Entity.Team_hotwords; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Select; import java.util.List; @Mapper public interface TeamMapper { //查询所有热词的方法 @Select("SELECT word,wordfrequency FROM team_hotwords ORDER BY wordfrequency DESC LIMIT 10") List<Team_hotwords> sel(); //查询所有事件内容的方法 @Select("SELECT eventcontent,problem FROM teamevent where updatetime::TEXT like '2021-06%'") List<Team_event> selEvent(); @Select("SELECT eventcontent,problem FROM teamevent where id =#{id}") Team_event selEventById(String id); Team_event getById(String id);//这个对应上面的mapper,复杂语句搁里面 }
参考文档:https://www.cnblogs.com/kpsmile/p/11314093.html