package com.duowenlvshi.duowenlszp.model.work.Server;

import com.duowenlvshi.duowenlszp.model.work.entity.Work;
import com.duowenlvshi.duowenlszp.model.work.dao.WorkMapper;
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;
import java.util.Map;

/**
 * @author yang fang yu
 * @since 2019/8/20 17:40
 */
@Service
public class WorkServer {
    @Autowired(required = false)
    WorkMapper workMapper;

    /*通过律师id查询所有工作经历*/
    public List selectByLawyerId(String lawyerId){
        return workMapper.selectByLawyerId(lawyerId);
    }
    /*删除律师工作经历*/
    public int delete(String id){
        return workMapper.delete(id);
    }
    /*新增或修改工作经历*/
    public int save(Work work){
        int i =0;
        if("".equals(work.getWorkId())){
            //新增
            work.setWorkId(UUIDUtil.GetUUID());
            work.setCreatedate(new Date());
            work.setUpdatedate(new Date());
            work.setIsvalid("1");
            i =workMapper.insertSelective(work);
        }else{
            //修改
            work.setUpdatedate(new Date());
            i =workMapper.updateByPrimaryKeySelective(work);
        }
        return i;
    }
    /*迷糊查询学校*/
    public List<Map> selectSchoolVague(String name){

        return  workMapper.selectSchoolVague(name);
    }
    /*查询学校*/
    public List<Map> selectSchool(String name){

        return  workMapper.selectSchool(name);
    }
    public int deleteAll(Map map){

        return  workMapper.deleteAll(map);
    }

    public double selectYear(String id){
        return  workMapper.selectYear(id);
    }

}
