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.UserRoleDataDetailMapper;
import com.sa.ibiz.demo.demo.domain.UserRoleDataDetail;
import com.sa.ibiz.demo.demo.service.UserRoleDataDetailService;
import com.sa.ibiz.demo.ibizutil.service.ServiceImplBase;
import com.sa.ibiz.demo.demo.service.dto.UserRoleDataDetailSearchFilter;
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.QueryModelService;
import com.sa.ibiz.demo.demo.service.UserRoleDataService;

/**
 * 实体[UserRoleDataDetail] 服务对象接口实现
 */
@Service
public class UserRoleDataDetailServiceImpl extends ServiceImplBase<UserRoleDataDetailMapper, UserRoleDataDetail> implements UserRoleDataDetailService{

    @Autowired
    private QueryModelService querymodelService;
    @Autowired
    private UserRoleDataService userroledataService;

    @Resource
    private UserRoleDataDetailMapper userroledatadetailMapper;


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

    @Override
   	public boolean remove(UserRoleDataDetail et) {
        String primaryKey=et.getUserroledatadetailid();
         if(StringUtils.isEmpty(primaryKey))
         {
             primaryKey=(String)et.getDefaultPrimaryKey();
             et.setUserroledatadetailid(primaryKey);
          }
   		     return super.remove(et);
   	}

    @Override
    public boolean update(UserRoleDataDetail et){
        String primaryKey=et.getUserroledatadetailid();
         if(StringUtils.isEmpty(primaryKey))
         {
             primaryKey=(String)et.getDefaultPrimaryKey();
             et.setUserroledatadetailid(primaryKey);
          }
		     this.userroledatadetailMapper.updateOne(et);
		     this.get(et);
             return true;
    }


    public Object getEntityKey(UserRoleDataDetail et){
		return et.getUserroledatadetailid();  
    }

    @Override
    public boolean getDraft(UserRoleDataDetail et)  {
    if((!StringUtils.isEmpty(et.getQuerymodelid())) && et.getQuerymodel() == null){
            try {
                et.setQuerymodel(querymodelService.getById(et.getQuerymodelid()));
            }catch (Exception ex){}
        }
    if((!StringUtils.isEmpty(et.getUserroledataid())) && et.getUserroledata() == null){
            try {
                et.setUserroledata(userroledataService.getById(et.getUserroledataid()));
            }catch (Exception ex){}
        }
            return true;
    }

	public List<UserRoleDataDetail> listDefault(UserRoleDataDetailSearchFilter filter) {
		return userroledatadetailMapper.searchDefault(filter,filter.getSelectCond());
	}

	public Page<UserRoleDataDetail> searchDefault(UserRoleDataDetailSearchFilter filter) {
		return userroledatadetailMapper.searchDefault(filter.getPage(),filter,filter.getSelectCond());
	}

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

 }