package com.community.huiju.service;

import com.baomidou.mybatisplus.extension.service.IService;
import com.community.commom.utils.AccountValidatorUtil;
import com.community.huiju.common.base.ResponseBean;
import com.community.huiju.enums.ResponseErrorsMessages;
import com.community.huiju.exception.WisdomException;
import com.community.huiju.model.TaUser;
import lombok.extern.slf4j.Slf4j;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * <p>
 * 住户app端用户表 服务类
 * </p>
 *
 * @author jobob
 * @since 2019-05-15
 */
public interface ITaUserService extends IService<TaUser> {

    Logger log = LoggerFactory.getLogger(ITaUserService.class);

    /**
     * 检验手机号
     * @param phone
     */
    default void checkPhone(String phone) {
        log.info("{} 手机号校验结果: {}",phone, AccountValidatorUtil.isPhone(phone));
        if (!AccountValidatorUtil.isPhone(phone)){
            throw new WisdomException(ResponseErrorsMessages.NOT_PHONE.getCode(), ResponseErrorsMessages.NOT_PHONE.getMsg());
        }
    }


    /**
     * 添加用户
     * @param userName
     * @param idCard
     * @param gender
     * @return
     */
    ResponseBean addTaUser(String userName, String idCard, String gender, String phone);

    /**
     * 修改用户
     * @param userName
     * @param idCard
     * @param gender
     * @return
     */
    ResponseBean updateTaUser(Integer userId, String userName, String idCard, String gender, String phone);

    /**
     * 查询用户
     * @param userId
     * @return
     */
    ResponseBean getTaUser(Integer userId);

    /**
     * 查询用户
     * @param phone
     * @return
     */
    ResponseBean getTaUserByPhone(String phone);
}
