package com.ruoyi.project.activiti.service.impl;

import com.ruoyi.project.activiti.domain.ActIdUser;
import com.ruoyi.project.activiti.mapper.ActIdUserMapper;
import com.ruoyi.project.activiti.service.ActIdUserService;
import org.activiti.engine.IdentityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 流程用户Service业务层处理
 *
 * @author Xianlu Tech
 * @date 2019-10-02
 */
@Service
public class ActIdUserServiceImpl implements ActIdUserService {
    @Autowired
    private ActIdUserMapper actIdUserMapper;
    @Autowired
    private IdentityService identityService;

    @Override
    public void add(ActIdUser actIdUser) {
        actIdUserMapper.insertActIdUser(actIdUser);
        String[] groupIds = actIdUser.getGroupIds();
        if (null != groupIds) {
            for (String groupId : groupIds) {
                identityService.createMembership(actIdUser.getId(), groupId);
            }
        }

    }

    @Override
    public void delete(List<String> ids) {
        actIdUserMapper.deleteActIdUserByIds(ids);
    }
}
