package com.yd.dal.service.customer.impl;

import com.yd.dal.entity.customer.AclFileUpload;
import com.yd.dal.entity.customer.CustomerFileUpload;
import com.yd.dal.mapper.customer.AclFileUploadMapper;
import com.yd.dal.service.customer.AclFileUploadDALService;
import com.yd.util.intercept.annotation.TargetDataSource;
import com.yd.util.intercept.commons.DataSourceKey;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service("aclFileUploadDALService")
public class AclFileUploadDALServiceImpl implements AclFileUploadDALService {

    @Resource
    private AclFileUploadMapper aclFileUploadMapper;

    @Override
    public CustomerFileUpload findFilePathInfo(Integer targetType, Integer targetUseFor, Long practitionerId) {
        CustomerFileUpload fileUpload = null;
        if(targetType != null && targetUseFor != null && practitionerId != null){
            fileUpload = aclFileUploadMapper.findByTargetTypeAndTargetUseForAndTargetId(targetType,targetUseFor,practitionerId);
        }
        return  fileUpload;
    }

    @Override
    @TargetDataSource(dataSourceKey = DataSourceKey.DB_MASTER)
    public List<AclFileUpload> findByAclFileUpload(AclFileUpload fileUpload) {
        return aclFileUploadMapper.findByAclFileUpload(fileUpload);
    }

    @Override
    public AclFileUpload findFileUploadById(Long fileId) {
        return aclFileUploadMapper.selectByPrimaryKey(fileId);
    }

    @Override
    public void updateFileUpload(AclFileUpload fileUpload) {
        aclFileUploadMapper.updateByPrimaryKeySelective(fileUpload);
    }

    @Override
    public void saveFileUpload(AclFileUpload aclFileUpload) {
        aclFileUploadMapper.insertSelective(aclFileUpload);
    }

    @Override
    public AclFileUpload findByTargetIdAndRemark(Integer type,Long targetId, String remark ) {
        return aclFileUploadMapper.findByTargetIdAndRemark(type,targetId,remark);
    }
}
