package lingtao.net.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import lingtao.net.bean.SysUser;

public interface SysUserMapper {
	int deleteByPrimaryKey(Integer userId);

	int insertSelective(SysUser record);

	int updateByPrimaryKeySelective(SysUser record);

	@Select("select * from tbl_sys_user where username = #{username}")
	SysUser getUserByUsername(@Param("username") String username);

	List<SysUser> getUsers(SysUser user);

	int changeUserStatus(@Param("userId") Integer userId);

	public void addUserRoles(@Param("userId") Integer userId, @Param("roleIds") Integer[] roleIds);

	void deleteUserRoles(@Param("userId") Integer userId);

	int addBirthDay(SysUser user);

	int changeSysStatus(@Param("userId") Integer userId);

	int changeNeedIp();

	@Update("update tbl_sys_user set sysStatus = 1 where sysStatus = 0 and userId = #{userId}")
	int videoOverToChangeSysStatus(@Param("userId") Integer userId);

	@Update("update tbl_sys_user set sysStatus = 2 where userId = #{userId}")
	int examOverToChangeSysStatus(@Param("userId") Integer userId);

	@Update("update tbl_sys_user set readLogStatus = 1 where userId = #{userId}")
	int changeReadLogStatus(Integer userId);

	@Select("select * from tbl_sys_user where userId = #{userId}")
	SysUser getUserInfo(Integer userId);

	/**
	 * 如果当天生日，更改状态
	 * 
	 * @param isBirthDay
	 * @param userId
	 * @return
	 */
	@Update("update tbl_sys_user set isBirthDay = #{isBirthDay} where userId = #{userId}")
	int setIsBirthDay(@Param("isBirthDay") Integer isBirthDay, @Param("userId") Integer userId);

	/**
	 * 改变生日状态
	 * 
	 * @param userId
	 */
	@Update("update tbl_sys_user set isBirthDay = 0 where userId = #{userId}")
	void changeIsBirthDay(Integer userId);

	/**
	 * 客服数据 -- 根据搜索的店铺获取人员
	 * 
	 * @param shopname
	 */
	@Select("select * from tbl_sys_user where role like '%${shopname}%'")
	List<SysUser> getRealnamesByShopname(@Param("shopname") String shopname);

}