package io.hmit.modules.serviceOrder.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.modules.serviceOrder.dao.PensionServiceDocumentDao;
import io.hmit.modules.serviceOrder.dto.PensionServiceDocumentDTO;
import io.hmit.modules.serviceOrder.entity.PensionServiceDocumentEntity;
import io.hmit.modules.serviceOrder.service.PensionServiceDocumentService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 服务及相关图片附件关联表
 *
 * @author zsh 408538940@qq.com
 * @since 1.0.0 2021-01-26
 */
@Service
public class PensionServiceDocumentServiceImpl extends CrudServiceImpl<PensionServiceDocumentDao, PensionServiceDocumentEntity, PensionServiceDocumentDTO> implements PensionServiceDocumentService {

    @Autowired
    private PensionServiceDocumentDao pensionServiceDocumentDao;
    @Override
    public QueryWrapper<PensionServiceDocumentEntity> getWrapper(Map<String, Object> params){
        String id = (String)params.get("id");
        Long serviceId =(Long) params.get("serviceId");

        QueryWrapper<PensionServiceDocumentEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(StringUtils.isNotBlank(id), "id", id)
        .eq(serviceId != null, "service_id", serviceId);

        return wrapper;
    }


    @Override
    public void deletebyServiceId(Long id) {
        pensionServiceDocumentDao.deleteByServiceId(id);
    }
}
