package cn.iselab.mooctest.user.mapper;

import cn.iselab.mooctest.user.model.Medal;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * @Author ROKG
 * @Description
 * @Date: Created in 下午9:22 2018/2/12
 * @Modified By:
 */
@Mapper
public interface MedalMapper {

    @Select("select * from medal where id=#{id}")
    Medal findById(long id);

    @Insert("insert into medal(name,description,img_url,type,is_deleted,create_time) values(#{name},#{description},#{imgUrl},#{type},#{isDeleted},#{createTime})")
    void save(Medal medal);

    @Update("update medal set name=#{name},description=#{description},is_deleted=#{isDeleted} where id=#{id}")
    void update(Medal medal);

    @Select("select * from medal where name like concat('%',#{keyword},'%') and is_deleted=0")
    List<Medal> findAll(String keyword);
}
