package com.iailab.module.model.mpk.service.impl;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.iailab.framework.common.service.impl.BaseServiceImpl;
|
import com.iailab.framework.common.service.impl.CrudServiceImpl;
|
import com.iailab.framework.common.util.object.ConvertUtils;
|
import com.iailab.module.model.mpk.dao.ProjectModelDao;
|
import com.iailab.module.model.mpk.dto.MpkFileDTO;
|
import com.iailab.module.model.mpk.dto.ProjectModelDTO;
|
import com.iailab.module.model.mpk.entity.ProjectModelEntity;
|
import com.iailab.module.model.mpk.service.ProjectModelService;
|
import org.apache.commons.lang3.StringUtils;
|
import org.springframework.stereotype.Service;
|
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.UUID;
|
|
/**
|
* @description:
|
* @author: dzd
|
* @date: 2024/8/22 14:41
|
**/
|
@Service
|
public class ProjectModelServiceImpl extends BaseServiceImpl<ProjectModelDao, ProjectModelEntity> implements ProjectModelService {
|
@Override
|
public List<ProjectModelDTO> list(Map<String, Object> params) {
|
List<ProjectModelEntity> entityList = baseDao.selectList(getWrapper(params));
|
|
return ConvertUtils.sourceToTarget(entityList, ProjectModelDTO.class);
|
}
|
|
@Override
|
public void deleteByMap(Map<String,Object> map) {
|
baseDao.delete(getWrapper(map));
|
}
|
|
@Override
|
public void create(List<MpkFileDTO> models, String projectId) {
|
List<ProjectModelEntity> list = new ArrayList<>(models.size());
|
for (MpkFileDTO model : models) {
|
ProjectModelEntity projectModel = new ProjectModelEntity();
|
projectModel.setId(UUID.randomUUID().toString());
|
projectModel.setProjectId(projectId);
|
projectModel.setModelId(model.getId());
|
list.add(projectModel);
|
}
|
baseDao.insert(list);
|
}
|
|
public QueryWrapper<ProjectModelEntity> getWrapper(Map<String, Object> params){
|
String id = (String)params.get("id");
|
String projectId = (String)params.get("projectId");
|
String modelId = (String)params.get("modelId");
|
|
QueryWrapper<ProjectModelEntity> wrapper = new QueryWrapper<>();
|
wrapper.eq(StringUtils.isNotBlank(id), "id", id)
|
.eq(StringUtils.isNotBlank(projectId), "project_id", projectId)
|
.eq(StringUtils.isNotBlank(modelId),"model_id",modelId);
|
|
return wrapper;
|
}
|
|
|
}
|