package com.imooc.mapper;

import com.imooc.my.mapper.MyMapper;
import com.imooc.pojo.Users;
import com.imooc.utils.PagedGridResult;
import com.imooc.vo.UsersVO;
import com.imooc.bo.UpdatedUserBO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;
import java.util.List;

@Mapper
public interface UsersMapper extends MyMapper<Users> {

    @Select("SELECT * FROM t_users WHERE nickname LIKE CONCAT('%', #{nickname}, '%')")
    List<UsersVO> searchByNickname(String nickname);
    @Update("UPDATE t_users SET nickname = #{nickname} WHERE id = #{id}")
    int updateNickname(UpdatedUserBO user);
    @Update("UPDATE t_users SET sex = #{sex} WHERE id = #{id}")
    int updateSex(UpdatedUserBO user);
    @Update("UPDATE t_users SET birthday = #{birthday} WHERE id = #{id}")
    int updateBirthday(UpdatedUserBO user);
    @Update("UPDATE t_users SET description = #{description} WHERE id = #{id}")
    int updateDescription(UpdatedUserBO user);
    @Update("UPDATE t_users SET province = #{province},city = #{city},district = #{district} WHERE id = #{id}")
    int updateLocation(UpdatedUserBO user);
    @Update("UPDATE t_users SET imooc_num = #{imoocNum},can_imooc_num_be_updated = 0 WHERE id = #{id}")
    int updateVnum(UpdatedUserBO user);
    @Select("SELECT * FROM t_users WHERE imooc_num = #{imoocNum}")
    List<UsersVO> selectByImoocNum(@Param("imoocNum") String imoocNum);
}