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.WFUCPolicyMapper;
import com.sa.ibiz.demo.demo.domain.WFUCPolicy;
import com.sa.ibiz.demo.demo.service.WFUCPolicyService;
import com.sa.ibiz.demo.ibizutil.service.ServiceImplBase;
import com.sa.ibiz.demo.demo.service.dto.WFUCPolicySearchFilter;
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.WFUserService;
import com.sa.ibiz.demo.demo.service.WFUserService;

/**
 * 实体[WFUCPolicy] 服务对象接口实现
 */
@Service
public class WFUCPolicyServiceImpl extends ServiceImplBase<WFUCPolicyMapper, WFUCPolicy> implements WFUCPolicyService{

    @Autowired
    private WFUserService majorwfuserService;
    @Autowired
    private WFUserService minorwfuserService;

    @Resource
    private WFUCPolicyMapper wfucpolicyMapper;


    @Override
    public boolean create(WFUCPolicy et) {
        this.beforeCreate(et);
         return super.create(et);
    }
    @Override
    public boolean update(WFUCPolicy et){
        this.beforeUpdate(et);
		this.wfucpolicyMapper.updateOne(et);
		this.get(et);
		return true;
    }

    public Object getEntityKey(WFUCPolicy et){
		return et.getWfucpolicyid();  
    }

    @Override
    public boolean getDraft(WFUCPolicy et)  {
    if((!StringUtils.isEmpty(et.getMajorwfuserid())) && et.getMajorwfuser() == null){
            try {
                et.setMajorwfuser(majorwfuserService.getById(et.getMajorwfuserid()));
            }catch (Exception ex){}
        }
    if((!StringUtils.isEmpty(et.getMinorwfuserid())) && et.getMinorwfuser() == null){
            try {
                et.setMinorwfuser(minorwfuserService.getById(et.getMinorwfuserid()));
            }catch (Exception ex){}
        }
            return true;
    }
    @Override
    public WFUCPolicy enablePolicy(WFUCPolicy et)  {
		return et;
    }
    @Override
    public WFUCPolicy disablePolicy(WFUCPolicy et)  {
		return et;
    }

	public List<WFUCPolicy> listDefault(WFUCPolicySearchFilter filter) {
		return wfucpolicyMapper.searchDefault(filter,filter.getSelectCond());
	}

	public Page<WFUCPolicy> searchDefault(WFUCPolicySearchFilter filter) {
		return wfucpolicyMapper.searchDefault(filter.getPage(),filter,filter.getSelectCond());
	}

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

 }