package com.huimv.face.service.impl;

import com.huimv.face.domain.FaceUser;
import com.huimv.face.repo.FaceUserRepository;
import com.huimv.face.result.Result;
import com.huimv.face.service.FaceUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
import javax.persistence.criteria.Root;
import java.util.ArrayList;
import java.util.List;

/**
 * @Project : huimv.shiwan
 * @Package : com.huimv.face.service.impl
 * @Description : TODO
 * @Author : yuxuexuan
 * @Create : 2020/12/29 0029 10:17
 **/
@Service
public class FaceUserServiceImpl implements FaceUserService {

    @Autowired
    private FaceUserRepository faceUserRepository;


    @Override
    public FaceUser findAllByUserId(String userid) {
        return faceUserRepository.findAllByUSERID(userid);
    }

    @Override
    public Result findFaceUserByName(String userName) {
        try {
            FaceUser faceUser = faceUserRepository.findAllByUserName(userName);
            if (faceUser!=null){
                List list = new ArrayList();
                list.add(faceUser);
                return new Result(10000,"查询成功",list);
            }else {
                return new Result(10002,"用户不存在",null);
            }
        }catch (Exception e){
            return new Result(10003,"查询失败",null);
        }
    }
}