package com.fs.company.mapper;

import com.fs.company.domain.CompanyUser;


import com.fs.company.vo.CompanyUserOptionRespVO;
import com.fs.doctor.domain.DoctorCompanyUser;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 理员信息Mapper接口
 *
 * @author fs
 * @date 2021-05-25
 */
public interface CompanyUserMapper
{
    /**
     * 查询理员信息
     *
     * @param userId 理员信息ID
     * @return 理员信息
     */
    public CompanyUser selectCompanyUserById(Long userId);

    public String selectCompanyUserNameById(@Param("userId") Long userId);

    /**
     * 查询理员信息列表
     *
     * @param companyUser 理员信息
     * @return 理员信息集合
     */
    public List<CompanyUser> selectCompanyUserList(CompanyUser companyUser);

    /**
     * 新增理员信息
     *
     * @param companyUser 理员信息
     * @return 结果
     */
    public int insertCompanyUser(CompanyUser companyUser);

    /**
     * 修改理员信息
     *
     * @param companyUser 理员信息
     * @return 结果
     */
    public int updateCompanyUser(CompanyUser companyUser);


    /**
     * 删除理员信息
     *
     * @param userId 理员信息ID
     * @return 结果
     */
    public int deleteCompanyUserById(Long userId);

    /**
     * 批量删除理员信息
     *
     * @param userIds 需要删除的数据ID
     * @return 结果
     */
    public int deleteCompanyUserByIds(Long[] userIds);

    int updateUserAvatar(@Param("userName")String username, @Param("avatar") String avatar);

    int resetUserPwd(@Param("userName")String userName,  @Param("password")String encryptPassword);


    CompanyUser selectUserByUserName(@Param("userName")String userName);
    @Select("select count(1) from company_user where user_name=#{userName}")
    int checkUserName(String userName);
    @Update("update company_user set password=#{password} where user_id=#{userId}")
    int resetUserPwdByUserId( @Param("userId")Long userId, @Param("password") String encryptPassword);


    @Select("select count(1) from company_user  where user_name=#{userName} and del_flag=0  ")
    Integer checkUserNameUnique(String userName);


    @Select("select u.* from company_user u   where u.company_id=#{companyId} and u.nick_name=#{nickName} limit 1 ")
    CompanyUser selectCompanyUserByCompanyIdAndNickName(@Param("companyId")long companyId,@Param("nickName") String nickName);

    @Select("select count(1) from company_user  where company_id=#{companyId} and del_flag=0  ")
    Integer selectCompanyUserCountByCompanyId(Long companyId);


    List<CompanyUserOptionRespVO> getUserOptionVOList(@Param("companyNickName") String companyNickName,@Param("companyId") Long companyId);

    @Select("select user_id,user_name from company_user where company_id=#{companyId} and del_flag=0 ")
    List<CompanyUser> queryAllCompanyUser(@Param("companyId") Long companyId);

    /**
     * 根据手机号查询用户
     *
     * @param phonenumber 手机号
     * @return 用户信息
     */
    CompanyUser selectUserByPhone(@Param("phonenumber") String phonenumber);

}
