zoukankan      html  css  js  c++  java
  • 在Mybatis中使用注解@多个參数查询

        @Select("SELECT * FROM wc_homework WHERE organization_id=#{classId} ORDER BY createtime DESC LIMIT #{start},#{count}")
        @Results({
                @Result(column = "course_id", property = "course_id"),
                @Result(column = "homework_id", property = "homework_id"),
                @Result(column = "organization_id", property = "organization_id"),
                @Result(property = "course", column = "course_id", one = @One(select = "selectCourse")),
                @Result(property = "viewTotalNum", column = "organization_id", one = @One(select = "SelectStudentCount")),
                @Result(property = "attachments", javaType = List.class, column = "homework_id", many = @Many(select = "selectAttachments")),
                @Result(property = "viewNum",column = "{homework_id = homework_id,organization_id = organization_id}",one = @One(select = "selectViewCounts")),
                @Result(property = "feedbackNum",column = "{homework_id = homework_id,organization_id = organization_id}",one = @One(select = "selectFeedbackCounts"))
        })

        List<HomeworkExt> selectByClassId(@Param("classId") Long classId, @Param("start") int start, @Param("count") int count);

    上面的 @Result(property = "feedbackNum",column = "{homework_id = homework_id,organization_id = organization_id}",one = @One(select = "selectFeedbackCounts"))

    最后一行,通过传入两个參数查询:相应以下的Map键值对。

     @Select("SELECT COUNT(DISTINCT f.user_id)  FROM wc_homework_log_see ws INNER JOIN " +
                "(SELECT wu.user_id, wf.`family_user_id` FROM wc_organization_user wu INNER JOIN wc_family wf ON wu.`user_id` = wf.`student_id` " +
                "WHERE wu.`organization_id` = #{organization_id} AND wu.`role_id` = 4) f ON f.family_user_id = ws.`user_id` " +
                "WHERE ws.`homework_id` = #{homework_id}")
        int selectViewCounts(Map<String,Object> map);

  • 相关阅读:
    第一章 教育观
    教资时间及考试分布情况
    第二章 信号量及条件变量(三)——> 重点
    Apache ftpServer 配置用户
    下载谷歌拼音输入法离线包
    springboot 启动脚本优化
    Json序列化和反序列化注意点-无参构造器
    Springboot2使用redis提示无法注入redisTemplate
    【转】iOS 保持界面流畅的技巧
    Java文件操作相关
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/4242554.html
Copyright © 2011-2022 走看看