package cn.com.ty.lift.system.user.service.impl;

import cn.com.ty.lift.system.user.dao.entity.UserAccount;
import cn.com.ty.lift.system.user.dao.mapper.UserAccountMapper;
import cn.com.ty.lift.system.user.service.IUserAccountService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * @author huangyuan
 * @date 2019-11-29
 * @description 用户账户
 */
@Service
public class UserAccountService extends ServiceImpl<UserAccountMapper, UserAccount> implements IUserAccountService {

    @Override
    public UserAccount getByMobile(String mobile) {
        return this.getOne(new QueryWrapper<UserAccount>()
        .eq("mobile", mobile)
        );
    }

    @Override
    public UserAccount getByUserId(Long userId) {
        return this.getById(userId);
    }

    @Override
    public boolean updateUserAccount(UserAccount userAccount) {
        return this.update(userAccount, new UpdateWrapper<UserAccount>()
        .eq("user_id", userAccount.getUserId())
        );
    }
}
