2021-02-24 17:14:37 +08:00
|
|
|
package io.dataease.service.dataset;
|
|
|
|
|
|
|
|
import io.dataease.base.domain.DatasetTableField;
|
|
|
|
import io.dataease.base.domain.DatasetTableFieldExample;
|
|
|
|
import io.dataease.base.mapper.DatasetTableFieldMapper;
|
|
|
|
import org.apache.commons.lang3.ObjectUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
import java.util.List;
|
2021-02-25 12:28:55 +08:00
|
|
|
import java.util.UUID;
|
2021-02-24 17:14:37 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @Author gin
|
|
|
|
* @Date 2021/2/24 2:03 下午
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
public class DataSetTableFieldsService {
|
|
|
|
@Resource
|
|
|
|
private DatasetTableFieldMapper datasetTableFieldMapper;
|
|
|
|
|
|
|
|
public void batchEdit(List<DatasetTableField> list) {
|
|
|
|
for (DatasetTableField field : list) {
|
|
|
|
save(field);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DatasetTableField save(DatasetTableField datasetTableField) {
|
|
|
|
if (StringUtils.isEmpty(datasetTableField.getId())) {
|
2021-02-25 12:28:55 +08:00
|
|
|
datasetTableField.setId(UUID.randomUUID().toString());
|
2021-02-24 17:14:37 +08:00
|
|
|
datasetTableFieldMapper.insert(datasetTableField);
|
|
|
|
} else {
|
2021-03-25 18:18:44 +08:00
|
|
|
datasetTableFieldMapper.updateByPrimaryKeySelective(datasetTableField);
|
2021-02-24 17:14:37 +08:00
|
|
|
}
|
|
|
|
return datasetTableField;
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<DatasetTableField> list(DatasetTableField datasetTableField) {
|
|
|
|
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
|
|
|
DatasetTableFieldExample.Criteria criteria = datasetTableFieldExample.createCriteria();
|
|
|
|
if (StringUtils.isNotEmpty(datasetTableField.getTableId())) {
|
|
|
|
criteria.andTableIdEqualTo(datasetTableField.getTableId());
|
|
|
|
}
|
|
|
|
if (ObjectUtils.isNotEmpty(datasetTableField.getChecked())) {
|
|
|
|
criteria.andCheckedEqualTo(datasetTableField.getChecked());
|
|
|
|
}
|
|
|
|
datasetTableFieldExample.setOrderByClause("column_index asc");
|
|
|
|
return datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void deleteByTableId(String tableId) {
|
|
|
|
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
|
|
|
datasetTableFieldExample.createCriteria().andTableIdEqualTo(tableId);
|
|
|
|
datasetTableFieldMapper.deleteByExample(datasetTableFieldExample);
|
|
|
|
}
|
2021-03-01 18:03:11 +08:00
|
|
|
|
|
|
|
public List<DatasetTableField> getListByIds(List<String> ids) {
|
|
|
|
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
|
|
|
datasetTableFieldExample.createCriteria().andIdIn(ids);
|
|
|
|
return datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
|
|
|
}
|
2021-04-13 18:21:40 +08:00
|
|
|
|
|
|
|
public List<DatasetTableField> getFieldsByTableId(String id) {
|
|
|
|
DatasetTableFieldExample datasetTableFieldExample = new DatasetTableFieldExample();
|
|
|
|
datasetTableFieldExample.createCriteria().andTableIdEqualTo(id);
|
|
|
|
return datasetTableFieldMapper.selectByExample(datasetTableFieldExample);
|
|
|
|
}
|
2021-04-19 11:44:21 +08:00
|
|
|
|
|
|
|
public DatasetTableField get(String id) {
|
|
|
|
return datasetTableFieldMapper.selectByPrimaryKey(id);
|
|
|
|
}
|
2021-02-24 17:14:37 +08:00
|
|
|
}
|