feat: 数据集

This commit is contained in:
junjie
2021-02-20 22:07:42 +08:00
parent 8ba0f91e7a
commit 2b909be521
7 changed files with 136 additions and 10 deletions

View File

@@ -0,0 +1,27 @@
package io.dataease.controller.dataset;
import io.dataease.base.domain.DatasetGroup;
import io.dataease.dto.dataset.DataSetGroupDTO;
import io.dataease.service.dataset.DataSetGroupService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Author gin
* @Date 2021/2/20 8:29 下午
*/
@RestController
@RequestMapping("dataset/group")
public class DataSetGroupController {
@Resource
private DataSetGroupService dataSetGroupService;
@PostMapping("/save")
public DataSetGroupDTO save(@RequestBody DatasetGroup datasetGroup) {
return dataSetGroupService.save(datasetGroup);
}
}

View File

@@ -0,0 +1,13 @@
package io.dataease.dto.dataset;
import io.dataease.base.domain.DatasetGroup;
import lombok.Data;
/**
* @Author gin
* @Date 2021/2/20 8:17 下午
*/
@Data
public class DataSetGroupDTO extends DatasetGroup {
private String label;
}

View File

@@ -0,0 +1,35 @@
package io.dataease.service.dataset;
import com.alibaba.nacos.common.util.UuidUtils;
import io.dataease.base.domain.DatasetGroup;
import io.dataease.base.mapper.DatasetGroupMapper;
import io.dataease.commons.utils.BeanUtils;
import io.dataease.dto.dataset.DataSetGroupDTO;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
/**
* @Author gin
* @Date 2021/2/20 8:10 下午
*/
@Service
public class DataSetGroupService {
@Resource
private DatasetGroupMapper datasetGroupMapper;
public DataSetGroupDTO save(DatasetGroup datasetGroup) {
if (StringUtils.isEmpty(datasetGroup.getId())) {
datasetGroup.setId(UuidUtils.generateUuid());
datasetGroup.setCreateTime(System.currentTimeMillis());
datasetGroupMapper.insert(datasetGroup);
} else {
datasetGroupMapper.updateByPrimaryKey(datasetGroup);
}
DataSetGroupDTO dataSetGroupDTO = new DataSetGroupDTO();
BeanUtils.copyBean(dataSetGroupDTO, datasetGroup);
dataSetGroupDTO.setLabel(dataSetGroupDTO.getName());
return dataSetGroupDTO;
}
}