【mapper @Select()注解开发,使用模板 if 和循环】壮心未与年俱老,死去犹能作鬼雄。这篇文章主要讲述mapper @Select()注解开发,使用模板 if 和循环相关的知识,希望能为你提供帮助。
if
@Select({"<
script>
",
"SELECT" +
"mu.id userId," +
"eui.id userInfoId," +
"mu.user_name userName," +
"com.company_id AS comId," +
"com.company_name comName," +
"eui.talent_type talentType," +
"eui.self_introduction selfIntroduction," +
"eui.working_years workingYears," +
"eui.education education," +
"mu.icon_url iconUrl" +
" FROM" +
"mky_user mu," +
"em_company c," +
"em_company_record com," +
"em_user_info eui," +
"em_aptitude_maintain_approve ea" +
" WHERE 1=1 ",
" <
when test=‘searchStr!=null‘>
",
"AND ( mu.user_name LIKE #{searchStr} OR com.company_name LIKE#{searchStr} ) ",
" <
/when>
",
" <
when test=‘firstId!=null‘>
",
" AND ea.first_id = #{firstId} ",
" <
/when>
"," <
when test=‘secondId!=null‘>
",
" AND ea.second_id = #{secondId} ",
" <
/when>
"," <
when test=‘threeId!=null‘>
",
" AND ea.three_id = #{threeId} ",
" <
/when>
",
" <
when test=‘startDate!=null‘>
",
"AND ea.end_date &
gt;
#{startDate}",
" <
/when>
",
" <
when test=‘endDate!=null‘>
",
"AND ea.end_date&
lt;
#{endDate}",
" <
/when>
",
"AND c.id = com.company_id" +
"AND mu.com_id = c.id" +
"AND mu.id = eui.user_id" +
"AND eui.page_display_flag = 1" +
"AND ea.user_info_id = eui.id" +
"AND ea.end_date &
gt;
DATE_FORMAT( now( ), ‘%Y-%m-%d‘ ) " +"AND mu.del_flag = 0" +
"AND ea.del_flag = 0" +
"AND eui.del_flag = 0" +
"AND c.del_flag = 0" +
"AND com.del_flag = 0" +"GROUP BYeui.id" +
"ORDER BY" +
"eui.update_date DESC" +" <
/script>
"})
List<
TalentsResultVo>
selectAllTalentsByParams(@Param("firstId") String firstId, @Param("secondId") String secondId, @Param("threeId") String threeId, @Param("startDate") String startDate, @Param("endDate") String endDate, @Param("searchStr") String searchStr);
循环
@Select({
" <
script>
",
" select ",
" id ,stream_id‘streamId‘ , project_id‘projectId‘ ,push_stream_addr ‘pushStreamAddr‘ , rtmp_play_addr‘rtmpPlayAddr‘ , flv_play_addr ‘flvPlayAddr‘ , hls_play_addr ‘hlsPlayAddr‘ ,monitor_state‘monitorState‘, monitor_name‘monitorName‘ , note, state_reason‘stateReason‘ , ip_addr ‘ipAddr‘",
" from bi_real_time_monitoring ",
"whereproject_id in ",
" <
foreach collection=‘projectIds‘ item=‘id‘ open=‘(‘ separator=‘,‘ close=‘)‘>
",
" #{id} ",
" <
/foreach>
",
" and delFlag =0and monitor_state != 2 ",
" <
/script>
"
})
List<
BiRealTimeMonitoring>
selectBiRealTimeMonitoringByProjectIds(@Param("projectIds") List<
String>
projectIds);
注意一个报错注意一个报错
推荐阅读
- xml-mapping xml 与 java 对象转换映射框架,像 XStream 一样优雅地读写xml
- elasticsearch之mappings的其他设置(indexcopy_to对象属性settings)
- 在application.yml的自动提示中显示出项目内部的属性配置项
- ZUK Z2 AospExtended-v6.7 Android 9.0可用的谷歌相机Mod.md
- vs code 怎么与手机连接进行调试app项目
- Android多线程断点续传下载原理及实现
- 安卓开发Webview简单使用
- [ubuntu]android SDK 与Gradle环境的安装与配置
- selenium与appium怎样联系