package com.activiti6.service.activiti.impl;



import com.activiti6.domain.MyFormData;
import com.activiti6.domain.MyFormDataExample;
import com.activiti6.mapper.activiti.NewMyFormDataMapper;
import com.activiti6.service.activiti.MyFormDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

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

@Service
public class FormDataServiceImp implements MyFormDataService {

    @Autowired
    private NewMyFormDataMapper newMyFormDataMapper;

    @Override
    public void add(MyFormData myFormData,Long userId) {
        myFormData.setCreateBy(userId.toString());
        myFormData.setCreateTime(new Date());
        newMyFormDataMapper.insertSelective(myFormData);
    }

    @Override
    public List<MyFormData> list(MyFormData myFormData) {
        MyFormDataExample example = new MyFormDataExample();
        MyFormDataExample.Criteria criteria = example.createCriteria();
        List<MyFormData> list = newMyFormDataMapper.selectByExample(example);
        return list;
    }

    @Override
    public void update(MyFormData myFormData) {
        newMyFormDataMapper.updateByPrimaryKeySelective(myFormData);
    }

    @Override
    public MyFormData get(Long id) {
        return newMyFormDataMapper.selectByPrimaryKey(id);
    }

    @Override
    public void delete(List<Long> ids) {
        MyFormDataExample myFormDataExample=new MyFormDataExample();
        MyFormDataExample.Criteria criteria = myFormDataExample.createCriteria();
        criteria.andFIdIn(ids);
        newMyFormDataMapper.deleteByExample(myFormDataExample);
    }
}
