最新一版6.0
parent
86303182f7
commit
4ce93b9f97
|
@ -73,6 +73,10 @@
|
||||||
<groupId>io.minio</groupId>
|
<groupId>io.minio</groupId>
|
||||||
<artifactId>minio</artifactId>
|
<artifactId>minio</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.quartz-scheduler</groupId>
|
||||||
|
<artifactId>quartz</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -3,17 +3,18 @@ package net.srt.controller;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.convert.MetadataCollectConvert;
|
||||||
|
import net.srt.entity.MetadataCollectEntity;
|
||||||
import net.srt.entity.MetadataCollectQuery;
|
import net.srt.entity.MetadataCollectQuery;
|
||||||
import net.srt.framework.common.page.PageResult;
|
import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.common.utils.Result;
|
import net.srt.framework.common.utils.Result;
|
||||||
import net.srt.service.MetadataCollectService;
|
import net.srt.service.MetadataCollectService;
|
||||||
import net.srt.vo.MetadataCollectVO;
|
import net.srt.vo.MetadataCollectVO;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.*;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("metadata-collect")
|
@RequestMapping("metadata-collect")
|
||||||
|
@ -24,8 +25,66 @@ public class MetadataCollectController {
|
||||||
|
|
||||||
@GetMapping("page")
|
@GetMapping("page")
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:page')")
|
||||||
public Result<PageResult<MetadataCollectVO>> page(@Valid MetadataCollectQuery query){
|
public Result<PageResult<MetadataCollectVO>> page(@Valid MetadataCollectQuery query){
|
||||||
PageResult<MetadataCollectVO> page = metadataCollectService.page(query);
|
PageResult<MetadataCollectVO> page = metadataCollectService.page(query);
|
||||||
return Result.ok(page);
|
return Result.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@Operation(summary = "信息")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:info')")
|
||||||
|
public Result<MetadataCollectVO> get(@PathVariable("id") Long id){
|
||||||
|
MetadataCollectEntity entity = metadataCollectService.getById(id);
|
||||||
|
return Result.ok(MetadataCollectConvert.INSTANCE.convert(entity));
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@Operation(summary = "保存")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:save')")
|
||||||
|
public Result<String> save(@RequestBody MetadataCollectVO vo){
|
||||||
|
metadataCollectService.save(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@Operation(summary = "修改")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:update')")
|
||||||
|
public Result<String> update(@RequestBody @Valid MetadataCollectVO vo){
|
||||||
|
metadataCollectService.update(vo);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/release/{id}")
|
||||||
|
@Operation(summary = "发布")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:release')")
|
||||||
|
public Result<String> release(@PathVariable Long id){
|
||||||
|
metadataCollectService.release(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping("/cancel/{id}")
|
||||||
|
@Operation(summary = "取消发布")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:cancel')")
|
||||||
|
public Result<String> cancel(@PathVariable Long id){
|
||||||
|
metadataCollectService.cancel(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping("hand-run/{id}")
|
||||||
|
@Operation(summary = "手动执行")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:hand-run')")
|
||||||
|
public Result<String> handRun(@PathVariable Long id){
|
||||||
|
metadataCollectService.handRun(id);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@Operation(summary = "删除")
|
||||||
|
@PreAuthorize("hasAuthority('data-governance:metadata-collect:delete')")
|
||||||
|
public Result<String> delete(@RequestBody List<Long> idList){
|
||||||
|
metadataCollectService.delete(idList);
|
||||||
|
return Result.ok();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,21 @@ import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.mybatis.service.BaseService;
|
import net.srt.framework.mybatis.service.BaseService;
|
||||||
import net.srt.vo.MetadataCollectVO;
|
import net.srt.vo.MetadataCollectVO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface MetadataCollectService extends BaseService<MetadataCollectEntity> {
|
public interface MetadataCollectService extends BaseService<MetadataCollectEntity> {
|
||||||
|
|
||||||
PageResult<MetadataCollectVO> page(MetadataCollectQuery query);
|
PageResult<MetadataCollectVO> page(MetadataCollectQuery query);
|
||||||
|
|
||||||
|
void save(MetadataCollectVO vo);
|
||||||
|
|
||||||
|
void update(MetadataCollectVO vo);
|
||||||
|
|
||||||
|
void cancel(Long id);
|
||||||
|
|
||||||
|
void release(Long id);
|
||||||
|
|
||||||
|
void handRun(Long id);
|
||||||
|
|
||||||
|
void delete(List<Long> idList);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,97 @@
|
||||||
package net.srt.service.impl;
|
package net.srt.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.cron.CronException;
|
||||||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
|
import net.srt.api.module.data.governance.constant.MetadataCollectType;
|
||||||
|
import net.srt.api.module.quartz.QuartzDataGovernanceMetadataCollectApi;
|
||||||
import net.srt.convert.MetadataCollectConvert;
|
import net.srt.convert.MetadataCollectConvert;
|
||||||
import net.srt.dao.MetadataCollectDao;
|
import net.srt.dao.MetadataCollectDao;
|
||||||
import net.srt.entity.MetadataCollectEntity;
|
import net.srt.entity.MetadataCollectEntity;
|
||||||
import net.srt.entity.MetadataCollectQuery;
|
import net.srt.entity.MetadataCollectQuery;
|
||||||
|
import net.srt.framework.common.exception.ServerException;
|
||||||
import net.srt.framework.common.page.PageResult;
|
import net.srt.framework.common.page.PageResult;
|
||||||
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
import net.srt.framework.mybatis.service.impl.BaseServiceImpl;
|
||||||
import net.srt.service.MetadataCollectService;
|
import net.srt.service.MetadataCollectService;
|
||||||
import net.srt.vo.MetadataCollectVO;
|
import net.srt.vo.MetadataCollectVO;
|
||||||
|
import org.quartz.CronExpression;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
import srt.cloud.framework.dbswitch.common.util.StringUtil;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class MetadataCollectServiceImpl extends BaseServiceImpl<MetadataCollectDao, MetadataCollectEntity> implements MetadataCollectService {
|
public class MetadataCollectServiceImpl extends BaseServiceImpl<MetadataCollectDao, MetadataCollectEntity> implements MetadataCollectService {
|
||||||
|
|
||||||
|
private final QuartzDataGovernanceMetadataCollectApi metadataCollectApi;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<MetadataCollectVO> page(MetadataCollectQuery query) {
|
public PageResult<MetadataCollectVO> page(MetadataCollectQuery query) {
|
||||||
IPage<MetadataCollectEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
IPage<MetadataCollectEntity> page = baseMapper.selectPage(getPage(query), getWrapper(query));
|
||||||
return new PageResult<>(MetadataCollectConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
return new PageResult<>(MetadataCollectConvert.INSTANCE.convertList(page.getRecords()), page.getTotal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void save(MetadataCollectVO vo) {
|
||||||
|
checkParam(vo);
|
||||||
|
MetadataCollectEntity entity = MetadataCollectConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
baseMapper.insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(MetadataCollectVO vo) {
|
||||||
|
checkParam(vo);
|
||||||
|
MetadataCollectEntity entity = MetadataCollectConvert.INSTANCE.convert(vo);
|
||||||
|
entity.setProjectId(getProjectId());
|
||||||
|
updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel(Long id) {
|
||||||
|
metadataCollectApi.cancel(id);
|
||||||
|
MetadataCollectEntity entity = baseMapper.selectById(id);
|
||||||
|
entity.setReleaseTime(null);
|
||||||
|
entity.setStatus(0);
|
||||||
|
baseMapper.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void release(Long id) {
|
||||||
|
metadataCollectApi.release(id);
|
||||||
|
MetadataCollectEntity entity = baseMapper.selectById(id);
|
||||||
|
entity.setReleaseTime(new Date());
|
||||||
|
entity.setStatus(1);
|
||||||
|
baseMapper.updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handRun(Long id) {
|
||||||
|
metadataCollectApi.handRun(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void delete(List<Long> idList) {
|
||||||
|
removeByIds(idList);
|
||||||
|
// for (Long id : idList) {
|
||||||
|
// LambdaQueryWrapper<MetadataCollectEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
|
//
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
private void checkParam(MetadataCollectVO vo){
|
||||||
|
if(MetadataCollectType.CRON.getValue().equals(vo.getTaskType())){
|
||||||
|
if(!CronExpression.isValidExpression(vo.getCron())){
|
||||||
|
throw new ServerException("cron表达式有误,请检查!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Wrapper<MetadataCollectEntity> getWrapper(MetadataCollectQuery query) {
|
private Wrapper<MetadataCollectEntity> getWrapper(MetadataCollectQuery query) {
|
||||||
LambdaQueryWrapper<MetadataCollectEntity> wrapper = Wrappers.lambdaQuery();
|
LambdaQueryWrapper<MetadataCollectEntity> wrapper = Wrappers.lambdaQuery();
|
||||||
wrapper.like(StringUtil.isNotBlank(query.getName()),MetadataCollectEntity::getName,query.getName())
|
wrapper.like(StringUtil.isNotBlank(query.getName()),MetadataCollectEntity::getName,query.getName())
|
||||||
|
@ -34,4 +101,6 @@ public class MetadataCollectServiceImpl extends BaseServiceImpl<MetadataCollectD
|
||||||
dataScopeWithOrgId(wrapper);
|
dataScopeWithOrgId(wrapper);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue