package com.duowenlvshi.duowenlszp.model.education.server;

import com.duowenlvshi.duowenlszp.model.education.entity.Education;
import com.duowenlvshi.duowenlszp.model.education.dao.EducationMapper;

import com.duowenlvshi.duowenlszp.app.util.UUIDUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * @author yang fang yu
 * @since 2019/8/20 09:35
 */
@Service
public class EducationServer {
    @Autowired(required = false)
    EducationMapper educationMapper;

    public int save(Education education){
        int i =0;
        if("".equals(education.getEducationId())){
            //新增
            education.setEducationId(UUIDUtil.GetUUID());
            education.setCreatedate(new Date());
            education.setUpdatedate(new Date());
            education.setIsvalid("1");
            i =educationMapper.insertSelective(education);
        }else{
            //修改
            education.setUpdatedate(new Date());
            i =educationMapper.updateByPrimaryKeySelective(education);
        }
      return i;
    }

    public int delete(String id){
        return educationMapper.delete(id);
    }

    public Education select(String id){
        return educationMapper.selectByPrimaryKey(id);
    }

    /*通过律师id查询使用教育记录*/
    public List selectByLawyerId(String lawyerId){
        return educationMapper.selectByLawyerId(lawyerId);
    }

}
