package com.winsun.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.winsun.bean.Partner;

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

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

@Mapper
@Component
public interface PartnerMapper extends BaseMapper<Partner> {

    @Update("update sys_user set phone = #{phone} ,name = #{name} ,account = #{account} ,sex = #{sex}, password = #{password}, roleid= #{roleId}  where id=#{id}")
    int updateSysUser(@Param("phone") String phone,@Param("name") String name,@Param("account") String account,@Param("sex") String sex,
    		@Param("password") String password,@Param("roleId") String roleId,@Param("id") String id);

    @Update("update hhr_user set ysm = #{ysm} ,grade = #{grade} ,id_card = #{idCard},position = #{position} ,parent_id = #{parentId} ,parent_ids = #{parentIds}  where id=#{id}")
    int updateHhUser(@Param("ysm") String ysm,@Param("grade") String grade,@Param("idCard") String idCard,@Param("position") String position,@Param("parentId") String parentId,@Param("parentIds") String parentIds,@Param("id") String id);
    
    @Update("update hhr_user_school set school_id = #{schoolId}  where user_id=#{userId}")
    int updateSchoolRef(@Param("schoolId") String schoolId,@Param("userId") String userId);
    
    @Select("select *  from `sys_user` where account = #{account} order by createtime desc")
    List<Map<String, Object>> selectSysUser(String account);
    
    @Insert(" replace into hhr_user_school(user_id,school_id) VALUES(#{userId},#{schoolId})")
    int saveSchoolRef(@Param("userId") String userId,@Param("schoolId") String schoolId);
    
    @Select(" select id,name from  sys_role ")
    List<Map<String, Object>> roleList();
}
