package com.sa.ibiz.demo.demo.service.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sa.ibiz.demo.demo.mapper.WFStepActorMapper;
import com.sa.ibiz.demo.demo.domain.WFStepActor;
import com.sa.ibiz.demo.demo.service.WFStepActorService;
import com.sa.ibiz.demo.ibizutil.service.ServiceImplBase;
import com.sa.ibiz.demo.demo.service.dto.WFStepActorSearchFilter;
import org.springframework.util.DigestUtils;
import org.springframework.util.StringUtils;
import java.util.UUID;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.math.BigInteger;
import com.sa.ibiz.demo.ibizutil.annotation.PreField;
import java.lang.reflect.Field;

import com.sa.ibiz.demo.demo.service.WFStepService;
import com.sa.ibiz.demo.demo.service.WFUserService;

/**
 * 实体[WFStepActor] 服务对象接口实现
 */
@Service
public class WFStepActorServiceImpl extends ServiceImplBase<WFStepActorMapper, WFStepActor> implements WFStepActorService{

    @Autowired
    private WFStepService wfstepService;
    @Autowired
    private WFUserService originalwfuserService;

    @Resource
    private WFStepActorMapper wfstepactorMapper;


    @Override
    public boolean create(WFStepActor et) {
        this.beforeCreate(et);
        String primaryKey=et.getWfstepactorid();
        if(StringUtils.isEmpty(primaryKey))
        {
            primaryKey=(String)et.getDefaultPrimaryKey();
            et.setWfstepactorid(primaryKey);
         }
         return super.create(et);
    }
    @Override
	public WFStepActor get(WFStepActor et) {
        String primaryKey=et.getWfstepactorid();
         if(StringUtils.isEmpty(primaryKey))
         {
             primaryKey=(String)et.getDefaultPrimaryKey();
             et.setWfstepactorid(primaryKey);
          }
		      return super.get(et);
	}

    @Override
   	public boolean remove(WFStepActor et) {
        String primaryKey=et.getWfstepactorid();
         if(StringUtils.isEmpty(primaryKey))
         {
             primaryKey=(String)et.getDefaultPrimaryKey();
             et.setWfstepactorid(primaryKey);
          }
   		     return super.remove(et);
   	}

    @Override
    public boolean update(WFStepActor et){
        String primaryKey=et.getWfstepactorid();
         if(StringUtils.isEmpty(primaryKey))
         {
             primaryKey=(String)et.getDefaultPrimaryKey();
             et.setWfstepactorid(primaryKey);
          }
		     this.wfstepactorMapper.updateOne(et);
		     this.get(et);
             return true;
    }


    public Object getEntityKey(WFStepActor et){
		return et.getWfstepactorid();  
    }

    @Override
    public boolean getDraft(WFStepActor et)  {
    if((!StringUtils.isEmpty(et.getWfstepid())) && et.getWfstep() == null){
            try {
                et.setWfstep(wfstepService.getById(et.getWfstepid()));
            }catch (Exception ex){}
        }
    if((!StringUtils.isEmpty(et.getOriginalwfuserid())) && et.getOriginalwfuser() == null){
            try {
                et.setOriginalwfuser(originalwfuserService.getById(et.getOriginalwfuserid()));
            }catch (Exception ex){}
        }
            return true;
    }
    @Override
    public WFStepActor remindSave(WFStepActor et)  {
		return et;
    }

	public List<WFStepActor> listDefault(WFStepActorSearchFilter filter) {
		return wfstepactorMapper.searchDefault(filter,filter.getSelectCond());
	}

	public Page<WFStepActor> searchDefault(WFStepActorSearchFilter filter) {
		return wfstepactorMapper.searchDefault(filter.getPage(),filter,filter.getSelectCond());
	}

    public  List<Map<String,Object>> selectRow(String sql){
       return wfstepactorMapper.selectRow(sql);
    }

 }