package com.bonus.boot.manager.manager.dao;

import java.util.List;
import java.util.Map;

import com.bonus.boot.manager.manager.entity.UnifyBean;
import com.bonus.boot.manager.manager.model.Permission;
import com.bonus.boot.manager.manager.model.SysUser;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserDao {

	@Options(useGeneratedKeys = true, keyProperty = "id")
	@Insert("insert into sys_user(username, password, nickname, headImgUrl, phone, telephone, email, birthday, sex, status, createTime, updateTime) values(#{username}, #{password}, #{nickname}, #{headImgUrl}, #{phone}, #{telephone}, #{email}, #{birthday}, #{sex}, #{status}, now(), now())")
	int save(SysUser user);

	@Select("select * from sys_user t where t.id = #{id}")
	SysUser getById(Long id);

	//@Select("select id,password,username,phone,role,sex,status,id_card as idCard,department,age, hospital_id as hospitalId from sys_user t where t.username = #{username}")
	@Select("select id,password,username,phone,role,role as roleId,sex,status,id_card as idCard,department,age, hospital_id as hospitalId from sys_user t where t.phone = #{username} and t.is_active = 1")
	SysUser getUser(String username);

	@Update("update sys_user t set t.password = #{password} where t.id = #{id}")
	int changePassword(@Param("id") Long id, @Param("password") String password);

	Integer count(@Param("params") Map<String, Object> params);

	List<SysUser> list(@Param("params") Map<String, Object> params, @Param("offset") Integer offset,
			@Param("limit") Integer limit);

	@Delete("delete from sys_role_user where userId = #{userId}")
	int deleteUserRole(Long userId);

	@Update("update sys_user t set t.PASSWORD = #{password} where t.ID = #{userId}")
	int resetUserPwd(String password,String userId);//重置密码

	int saveUserRoles(@Param("userId") Long userId, @Param("roleIds") List<Long> roleIds);

	int update(SysUser user);

	List<SysUser> getMsgList(SysUser o);

	int delById(SysUser bean);

	int resetPassword(SysUser bean);

	int addInfo(SysUser bean);

	int updateInfo(SysUser bean);

	SysUser getListById(String id);

	int insertroleUser(SysUser bean);

	int resetPasswordForOne(SysUser bean);

	void updateUnify(Long id);

	SysUser getEyId(Long aLong);

	List<UnifyBean> getLogininfor(String string);

	List<UnifyBean> getLogs(String string);

	int updateRoleUser(SysUser bean);

	List<UnifyBean> getPhysicalExamination();

	int updateUserPushStatus(@Param("list") List<UnifyBean> list);

	String getPermissionQuery(UnifyBean userVo);

	List<UnifyBean> getPushByBackOfficePersonnel();

	int updateUserBackstagePushStatus(List<UnifyBean> list);

	String getPermissionQuerys(UnifyBean userVo);

	//统一权限新增


}
