package com.springboot.cloud.sysadmin.organization.service.impl;

/*
 **********************************************
 *      DATE           PERSON       REASON
 *    2020-12-30          FXY        Created
 **********************************************
 */


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.springboot.cloud.sysadmin.organization.dao.UserMapper;
import com.springboot.cloud.sysadmin.organization.entity.po.User;
import com.springboot.cloud.sysadmin.organization.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {

    /**
     * username用户账户，唯一
     * mobile 用户手机号，唯一
     *
     * @param payload
     * @return
     */
    @Override
    public User getUserByUsernameOrMobile(String payload) {
        QueryWrapper<User> queryWrapper = new QueryWrapper<User>();
        queryWrapper.eq("username", payload).or().eq("mobile", payload);
        return getOne(queryWrapper);
    }
}
