package com.dingtalk.h5app.quickstart.mapper;

import com.dingtalk.h5app.quickstart.entity.CiKu;
import com.dingtalk.h5app.quickstart.entity.Grade;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * @author Eric
 */
@Mapper
public interface CiKuMapper {

    @Select("SELECT * FROM `ciku` ORDER BY RAND() LIMIT 50")
    List<CiKu> findByRandom();

    @Insert("INSERT INTO `grade`(username,grade)VALUE(#{name},#{grade})")
    int insertGrade(String name,String grade);


    @Select("SELECT username,grade,`date` from `grade` where username = #{name} order by `date` DESC LIMIT 5")
    List<Grade> getGrade(String name);
}
