Skip to content

Commit

Permalink
[Feature][UDF]feature_add_udf_manage (#2476)
Browse files Browse the repository at this point in the history
* feature_add_udf_manage

* feature_add_udf_manage

* support udf register manage web

* feature_add_udf_manage

* feature_add_udf_manage

* feature_add_udf_manage

* feature_add_udf_manage

* feature_add_udf_manage

---------

Co-authored-by: zhu-mingye <[email protected]>
  • Loading branch information
zackyoungh and Zzm0809 authored Nov 3, 2023
1 parent 1cdfd5f commit 089efcd
Show file tree
Hide file tree
Showing 41 changed files with 1,258 additions and 212 deletions.
95 changes: 95 additions & 0 deletions dinky-admin/src/main/java/org/dinky/controller/UDFController.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.controller;

import org.dinky.data.dto.CommonDTO;
import org.dinky.data.model.Resources;
import org.dinky.data.model.UDFManage;
import org.dinky.data.result.Result;
import org.dinky.data.vo.UDFManageVO;
import org.dinky.service.UDFService;

import java.util.List;

import org.springframework.web.bind.annotation.GetMapping;
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 io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;

/**
* Flink udf controller
*/
@Slf4j
@Api(tags = "UDF Controller")
@RestController
@RequestMapping("/api/udf")
@RequiredArgsConstructor
public class UDFController {
private final UDFService udfService;

/**
* update udf name by id
*
* @return Result
*/
@GetMapping("/list")
public Result<List<UDFManageVO>> list() {
return Result.succeed(udfService.selectAll());
}

/**
* update udf
*
* @param udfManage udfManage
* @return Result
*/
@PostMapping("/update")
public Result<Void> update(@RequestBody UDFManage udfManage) {
udfService.update(udfManage);
return Result.succeed();
}

/**
* get udf resources list
*
* @return Result
*/
@GetMapping("/udfResourcesList")
public Result<List<Resources>> udfResourcesList() {
return Result.succeed(udfService.udfResourcesList());
}

/**
* add or update by resource id
*
* @param dto dto
* @return Result
*/
@PostMapping("/addOrUpdateByResourceId")
public Result<Void> saveOrUpdate(@RequestBody CommonDTO<List<Integer>> dto) {
udfService.addOrUpdateByResourceId(dto.getData());
return Result.succeed();
}
}
33 changes: 33 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/dto/CommonDTO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.data.dto;

import org.apache.poi.ss.formula.functions.T;

import lombok.Data;

/**
* When using post, the dto passed as a parameter(使用post时,一个参数传递的dto)
* @param <T> params
*/
@Data
public class CommonDTO<T> {
private T data;
}
51 changes: 51 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/model/UDFManage.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.data.model;

import org.dinky.mybatis.model.SuperEntity;

import com.baomidou.mybatisplus.annotation.TableName;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_udf_manage")
@ApiModel(value = "UDFTemplate", description = "User-Defined Function Template")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class UDFManage extends SuperEntity<UDFManage> {

@ApiModelProperty(value = "Class Name", dataType = "String", notes = "Class Name")
private String className;

@ApiModelProperty(value = "Task Id", dataType = "Integer", notes = "Task Id")
private Integer taskId;

@ApiModelProperty(value = "Resources Id", dataType = "Integer", notes = "Resources Id")
private Integer resourcesId;
}
44 changes: 44 additions & 0 deletions dinky-admin/src/main/java/org/dinky/data/vo/UDFManageVO.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.data.vo;

import java.io.Serializable;
import java.util.Date;

import lombok.Data;

@Data
public class UDFManageVO implements Serializable {
private Integer id;
private String name;
private Boolean enabled;
private String className;
private Integer taskId;
private Integer resourcesId;
/**
* develop or resources
*/
private String source;

private String dialect;
private String fileName;
private Date createTime;
private Date updateTime;
}
36 changes: 36 additions & 0 deletions dinky-admin/src/main/java/org/dinky/mapper/UDFManageMapper.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.mapper;

import org.dinky.data.model.UDFManage;
import org.dinky.data.vo.UDFManageVO;
import org.dinky.mybatis.mapper.SuperMapper;

import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
* UDFManageMapper
*/
@Mapper
public interface UDFManageMapper extends SuperMapper<UDFManage> {
List<UDFManageVO> selectAll();
}
38 changes: 37 additions & 1 deletion dinky-admin/src/main/java/org/dinky/service/UDFService.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,40 @@

package org.dinky.service;

public interface UDFService {}
import org.dinky.data.model.Resources;
import org.dinky.data.model.UDFManage;
import org.dinky.data.vo.UDFManageVO;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.baomidou.mybatisplus.extension.service.IService;

public interface UDFService extends IService<UDFManage> {
/**
* update udf name by id
* @param entity udf
* @return boolean
*/
boolean update(UDFManage entity);

/**
* get all udf
* @return List
*/
List<UDFManageVO> selectAll();

/**
* get udf by id
* @return UDFManage
*/
List<Resources> udfResourcesList();

/**
* add or update udf by resourceIds
* @param resourceIds resourceIds
*/
@Transactional(rollbackFor = Exception.class)
void addOrUpdateByResourceId(List<Integer> resourceIds);
}
Loading

0 comments on commit 089efcd

Please sign in to comment.