1.删除数据(假删除)并修改时间
<!--根据id删除学生信息(多条)--> <update id="updateStuStatus" parameterType="map"> UPDATE student_t SET status = 0, modifiy_time = #{modifiyTime,jdbcType=TIMESTAMP} WHERE _id in( <foreach collection="list" item="id" separator=","> #{id, jdbcType=INTEGER} </foreach> ) </update>
传入的数据:
//Service Map<String,Object> map = new HashMap<String,Object>(); map.put("list",list); map.put("modifiyTime",date); int result = studentInfoEntityMapper.updateStuStatus(map);
2.根据学生id查找学生图片
<!--查询学生图片--> <select id="selectByStuList" resultMap="BaseResultMap"> SELECT img_src FROM img_t WHERE stu_id IN <foreach collection="list" item="item" open="(" separator="," close=")"> #{item.id,jdbcType=INTEGER} </foreach> and status = 1 ORDER BY create_time DESC </select> <!--传入的数据,dao层--> List<ImgInfoEntity> selectByStuList(List<StudentInfoEntity> list);
3.根据教师id查找学生信息,或者根据学生名字查找学生信息
<!--根據教師id,查询學生信息。或者,根據學生姓名,查詢學生信息--> <select id="selectStuAllByTeaId" parameterType="map" resultMap="BaseResultMap"> SELECT <include refid="Base_Column_List"/> FROM student_t <where> <if test="list != null"> AND tea_id IN <foreach collection="list" item="item" open="(" separator="," close=")"> #{item.id} </foreach> </if> <if test="name != null"> AND name LIKE '%${name}%' </if> AND status = 1 </where> ORDER BY create_time DESC </select>
<!--方式二:--> <select id="selectStuAllByTeaId" parameterType="java.util.Map" resultMap="BaseResultMap"> select <include refid="Base_Column_List" /> from student_t <where> <if test="_parameter.containsKey('list')"> AND tea_id IN <foreach collection="list" item="item" open="(" separator="," close=")"> #{item.id} </foreach> </if> <if test="_parameter.containsKey('name')"> AND name LIKE '%${name}%' </if> </where> order by create_time DESC </select>