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

import com.duowenlvshi.duowenlszp.model.Brief.entity.Brief;
import com.duowenlvshi.duowenlszp.app.util.UUIDUtil;
import com.duowenlvshi.duowenlszp.model.Brief.dao.BriefMapper;
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/30 14:31
 */
@Service
public class BriefServer {
    @Autowired(required = false)
    BriefMapper briefMapper;

    public int save(Brief brief){
        int i =0;
        if("".equals(brief.getBriefId())){
            //新增
            brief.setBriefId(UUIDUtil.GetUUID());
            brief.setCreatedate(new Date());
            brief.setUpdatedate(new Date());
            brief.setIsvalid("1");
            i =briefMapper.insertSelective(brief);
        }else{
            //修改
            brief.setUpdatedate(new Date());
            i =briefMapper.updateByPrimaryKeySelective(brief);
        }
        return i;
    }
    public List selectByLawyerId(String lawyerId){
        return briefMapper.selectByLawyerId(lawyerId);
    }
}
