Unverified Commit 25e65271 authored by cainiao-cnj's avatar cainiao-cnj Committed by GitHub

refactor admin's bean define (#2445)

parent fd3dea14
......@@ -23,6 +23,7 @@ import org.dinky.alert.AlertPool;
import org.dinky.alert.AlertResult;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.AlertInstanceDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.model.AlertInstance;
......@@ -186,21 +187,21 @@ public class AlertInstanceController {
/**
* send test alert message
*
* @param alertInstance {@link AlertInstance}
* @param alertInstanceDTO {@link AlertInstanceDTO}
* @return {@link Result} of {@link Void}
*/
@PostMapping("/sendTest")
@Log(title = "Test Send To AlertInstance", businessType = BusinessType.TEST)
@ApiOperation("Test Send To AlertInstance")
@ApiImplicitParam(
name = "alertInstance",
value = "AlertInstance",
dataType = "AlertInstance",
name = "alertInstanceDTO",
value = "AlertInstanceDTO",
dataType = "AlertInstanceDTO",
paramType = "body",
required = true,
dataTypeClass = AlertInstance.class)
public Result<Void> sendAlertMsgTest(@RequestBody AlertInstance alertInstance) {
AlertResult alertResult = alertInstanceService.testAlert(alertInstance);
dataTypeClass = AlertInstanceDTO.class)
public Result<Void> sendAlertMsgTest(@RequestBody AlertInstanceDTO alertInstanceDTO) {
AlertResult alertResult = alertInstanceService.testAlert(alertInstanceDTO);
if (alertResult.getSuccess()) {
return Result.succeed(Status.SEND_TEST_SUCCESS);
} else {
......
......@@ -21,6 +21,7 @@ package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.ClusterInstanceDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.model.ClusterInstance;
......@@ -63,7 +64,7 @@ public class ClusterInstanceController {
/**
* added or updated cluster instance
*
* @param clusterInstance {@link ClusterInstance} cluster instance
* @param clusterInstanceDTO {@link ClusterInstanceDTO} cluster instance
* @return {@link Result}<{@link Void}>
* @throws Exception exception
*/
......@@ -71,21 +72,22 @@ public class ClusterInstanceController {
@Log(title = "Insert Or Update Cluster Instance", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update Cluster Instance")
@ApiImplicitParam(
name = "clusterInstance",
value = "ClusterInstance Instance",
dataType = "ClusterInstance",
name = "clusterInstanceDTO",
value = "ClusterInstanceDTO Instance",
dataType = "ClusterInstanceDTO",
paramType = "body",
required = true,
dataTypeClass = ClusterInstance.class)
dataTypeClass = ClusterInstanceDTO.class)
@SaCheckPermission(
value = {
PermissionConstants.REGISTRATION_CLUSTER_INSTANCE_EDIT,
PermissionConstants.REGISTRATION_CLUSTER_INSTANCE_ADD
},
mode = SaMode.OR)
public Result<Void> saveOrUpdateClusterInstance(@RequestBody ClusterInstance clusterInstance) throws Exception {
clusterInstance.setAutoRegisters(false);
clusterInstanceService.registersCluster(clusterInstance);
public Result<Void> saveOrUpdateClusterInstance(@RequestBody ClusterInstanceDTO clusterInstanceDTO)
throws Exception {
clusterInstanceDTO.setAutoRegisters(false);
clusterInstanceService.registersCluster(clusterInstanceDTO);
return Result.succeed(Status.SAVE_SUCCESS);
}
......
......@@ -23,6 +23,7 @@ import org.dinky.assertion.Asserts;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.CommonConstant;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.DataBaseDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
import org.dinky.data.model.Column;
......@@ -77,26 +78,26 @@ public class DataBaseController {
/**
* save or update database
*
* @param database {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Result}< {@link Void}>
*/
@PutMapping
@Log(title = "Insert Or Update DataBase", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update DataBase")
@ApiImplicitParam(
name = "database",
value = "DataBase",
name = "databaseDTO",
value = "DataBaseDTO",
required = true,
dataType = "DataBase",
dataType = "DataBaseDTO",
paramType = "body",
dataTypeClass = DataBase.class)
dataTypeClass = DataBaseDTO.class)
@SaCheckPermission(
value = {PermissionConstants.REGISTRATION_DATA_SOURCE_ADD, PermissionConstants.REGISTRATION_DATA_SOURCE_EDIT
},
mode = SaMode.OR)
public Result<Void> saveOrUpdateDataBase(@RequestBody DataBase database) {
if (databaseService.saveOrUpdateDataBase(database)) {
DriverPool.remove(database.getName());
public Result<Void> saveOrUpdateDataBase(@RequestBody DataBaseDTO dataBaseDTO) {
if (databaseService.saveOrUpdateDataBase(dataBaseDTO)) {
DriverPool.remove(dataBaseDTO.getName());
return Result.succeed(Status.SAVE_SUCCESS);
} else {
return Result.failed(Status.SAVE_FAILED);
......@@ -192,21 +193,21 @@ public class DataBaseController {
/**
* test connect database
*
* @param database {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Result}< {@link Void}>
*/
@PostMapping("/testConnect")
@Log(title = "DataBase Test Connect", businessType = BusinessType.TEST)
@ApiOperation("DataBase Test Connect")
@ApiImplicitParam(
name = "database",
value = "DataBase",
name = "dataBaseDTO",
value = "DataBaseDTO",
required = true,
dataType = "DataBase",
dataType = "DataBaseDTO",
paramType = "body",
dataTypeClass = DataBase.class)
public Result<Void> testConnect(@RequestBody DataBase database) {
String msg = databaseService.testConnect(database);
dataTypeClass = DataBaseDTO.class)
public Result<Void> testConnect(@RequestBody DataBaseDTO dataBaseDTO) {
String msg = databaseService.testConnect(dataBaseDTO);
boolean isHealthy = Asserts.isEquals(CommonConstant.HEALTHY, msg);
if (isHealthy) {
return Result.succeed(Status.DATASOURCE_CONNECT_SUCCESS);
......@@ -428,15 +429,15 @@ public class DataBaseController {
/**
* copy database
*
* @param database {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Result}< {@link Void}>
*/
@PostMapping("/copyDatabase")
@Log(title = "Copy Database", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Copy Database")
@SaCheckPermission(PermissionConstants.REGISTRATION_DATA_SOURCE_COPY)
public Result<Void> copyDatabase(@RequestBody DataBase database) {
if (databaseService.copyDatabase(database)) {
public Result<Void> copyDatabase(@RequestBody DataBaseDTO dataBaseDTO) {
if (databaseService.copyDatabase(dataBaseDTO)) {
return Result.succeed(Status.COPY_SUCCESS);
} else {
return Result.failed(Status.COPY_FAILED);
......
......@@ -21,7 +21,8 @@ package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.RoleMenuDto;
import org.dinky.data.dto.MenuDTO;
import org.dinky.data.dto.RoleMenuDTO;
import org.dinky.data.dto.TreeNodeDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.enums.Status;
......@@ -59,16 +60,16 @@ public class MenuController {
/**
* save or update menu
*
* @param menu {@link Menu}
* @param menuDTO {@link MenuDTO}
* @return {@link Result} with {@link Void}
*/
@PutMapping("addOrUpdate")
@Log(title = "Insert Or Update Menu ", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiOperation("Insert Or Update Menu")
@ApiImplicitParam(
name = "menu",
value = "Menu",
dataType = "Menu",
name = "menuDTO",
value = "MenuDTO",
dataType = "MenuDTO",
paramType = "body",
required = true,
dataTypeClass = Menu.class)
......@@ -79,8 +80,8 @@ public class MenuController {
PermissionConstants.AUTH_MENU_ADD_SUB
},
mode = SaMode.OR)
public Result<Void> saveOrUpdateMenu(@RequestBody Menu menu) {
if (menuService.saveOrUpdateMenu(menu)) {
public Result<Void> saveOrUpdateMenu(@RequestBody MenuDTO menuDTO) {
if (menuService.saveOrUpdateMenu(menuDTO)) {
return Result.succeed(Status.SAVE_SUCCESS);
} else {
return Result.failed(Status.SAVE_FAILED);
......@@ -118,14 +119,14 @@ public class MenuController {
* load role menu tree
*
* @param roleId role id
* @return {@link RoleMenuDto}
* @return {@link RoleMenuDTO}
*/
@GetMapping(value = "/roleMenus")
@ApiOperation("Load Role Menu")
@ApiImplicitParam(name = "roleId", value = "Role Id", dataType = "Integer", paramType = "query", required = true)
public Result<RoleMenuDto> roleMenuTreeSelect(@RequestParam("id") Integer roleId) {
public Result<RoleMenuDTO> roleMenuTreeSelect(@RequestParam("id") Integer roleId) {
List<Menu> menus = menuService.buildMenuTree(menuService.list());
RoleMenuDto menuVO = RoleMenuDto.builder()
RoleMenuDTO menuVO = RoleMenuDTO.builder()
.roleId(roleId)
.selectedMenuIds(menuService.selectMenuListByRoleId(roleId))
.menus(menus)
......
......@@ -21,6 +21,7 @@ package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.RoleDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.model.Role;
import org.dinky.data.model.User;
......@@ -66,24 +67,24 @@ public class RoleController {
/**
* create or update role
*
* @param role {@link Role}
* @param roleDTO {@link Role}
* @return {@link Role} of {@link Void}
*/
@PutMapping("/addedOrUpdateRole")
@ApiOperation("Insert Or Update Role")
@Log(title = "Insert Or Update Role", businessType = BusinessType.INSERT_OR_UPDATE)
@ApiImplicitParam(
name = "role",
value = "role",
name = "roleDTO",
value = "RoleDTO",
required = true,
dataType = "Role",
dataType = "RoleDTO",
paramType = "body",
dataTypeClass = Role.class)
@SaCheckPermission(
value = {PermissionConstants.AUTH_ROLE_ADD, PermissionConstants.AUTH_ROLE_EDIT},
mode = SaMode.OR)
public Result<Void> addedOrUpdateRole(@RequestBody Role role) {
return roleService.addedOrUpdateRole(role);
public Result<Void> addedOrUpdateRole(@RequestBody RoleDTO roleDTO) {
return roleService.addedOrUpdateRole(roleDTO);
}
/**
......
......@@ -21,7 +21,7 @@ package org.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.PermissionConstants;
import org.dinky.data.dto.AssignMenuToRoleDto;
import org.dinky.data.dto.AssignMenuToRoleDTO;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.result.Result;
import org.dinky.service.RoleMenuService;
......@@ -50,7 +50,7 @@ public class RoleMenuController {
/**
* assign menus to role
*
* @param assignMenuToRoleDto
* @param assignMenuToRoleDTO
* @return {@link Result} with {@link Void}
*/
@PostMapping("assignMenuToRole")
......@@ -63,7 +63,7 @@ public class RoleMenuController {
dataType = "AssignMenuToRoleDto",
paramType = "body")
@SaCheckPermission(PermissionConstants.AUTH_ROLE_ASSIGN_MENU)
public Result<Void> assignMenuToRole(@RequestBody AssignMenuToRoleDto assignMenuToRoleDto) {
return roleMenuService.assignMenuToRole(assignMenuToRoleDto);
public Result<Void> assignMenuToRole(@RequestBody AssignMenuToRoleDTO assignMenuToRoleDTO) {
return roleMenuService.assignMenuToRole(assignMenuToRoleDTO);
}
}
/*
*
* 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.dinky.mybatis.annotation.Save;
import javax.validation.constraints.NotNull;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.Extension;
import io.swagger.annotations.ExtensionProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* AlertInstanceDTO
*
* @since 2023/10/20 16:36
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "AlertInstanceDTO", description = "API Alert Instance Data Transfer Object")
public class AlertInstanceDTO {
@NotNull(
message = "Name cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Name", required = true, dataType = "String", example = "Name")
private String name;
@ApiModelProperty(value = "Tenant ID", required = true, dataType = "Integer", example = "1")
private Integer tenantId;
@ApiModelProperty(
value = "Alert Instance Type",
required = true,
dataType = "String",
example = "DingTalk",
extensions = {
@Extension(
name = "alertType-enum",
properties = {@ExtensionProperty(name = "values", value = "DingTalk,WeChat,Email,FeiShu,Sms")})
})
private String type;
@ApiModelProperty(
value = "Alert Instance Params",
required = true,
dataType = "String",
example = "{\"webhook\":\"https://oapi.dingtalk.com/robot/send?access_token=xxxxxx\"}")
private String params;
}
......@@ -31,7 +31,7 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "AssignMenuToRoleDto", description = "DTO for assigning menus to a role")
public class AssignMenuToRoleDto {
public class AssignMenuToRoleDTO {
@ApiModelProperty(value = "Role ID", dataType = "Integer", example = "1", notes = "The ID of the role")
private Integer roleId;
......
/*
*
* 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.dinky.data.model.ClusterInstance;
import org.dinky.mybatis.annotation.Save;
import javax.validation.constraints.NotNull;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* ClusterInstanceDTO
*
* @since 2023/10/23 10:18
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "ClusterInstanceDTO", description = "API Cluster Instance Data Transfer Object")
public class ClusterInstanceDTO {
@ApiModelProperty(value = "Name", required = true, dataType = "String", example = "Name")
private String name;
@ApiModelProperty(
value = "alias",
required = true,
dataType = "String",
example = "test",
notes = "cluster alias, if this is auto register, it will be has value, and can not modify it")
private String alias;
@ApiModelProperty(
value = "type",
required = true,
dataType = "String",
example = "test",
notes = "cluster type, such as: standalone ,yarn-session")
private String type;
@ApiModelProperty(value = "hosts", required = true, dataType = "String", example = "test", notes = "cluster hosts")
private String hosts;
@ApiModelProperty(
value = "jobManagerHost",
required = true,
dataType = "String",
example = "test",
notes = "job manager host")
private String jobManagerHost;
@ApiModelProperty(
value = "autoRegisters",
required = true,
dataType = "Boolean",
example = "test",
notes = "is auto registers, if this record from projob/application mode , it will be true")
private Boolean autoRegisters;
@ApiModelProperty(
value = "clusterConfigurationId",
required = true,
dataType = "Integer",
example = "test",
notes = "cluster configuration id")
private Integer clusterConfigurationId;
@ApiModelProperty(value = "taskId", required = true, dataType = "Integer", example = "test", notes = "task id")
private Integer taskId;
@NotNull(
message = "Enabled cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Enabled", required = true, dataType = "Boolean", example = "true")
private Boolean enabled;
public ClusterInstance toBean() {
ClusterInstance clusterInstance = new ClusterInstance();
BeanUtil.copyProperties(this, clusterInstance);
return clusterInstance;
}
public static ClusterInstanceDTO autoRegistersClusterDTO(
String hosts, String name, String alias, String type, Integer clusterConfigurationId, Integer taskId) {
ClusterInstanceDTO clusterInstanceDTO = new ClusterInstanceDTO();
clusterInstanceDTO.setName(name);
clusterInstanceDTO.setAlias(alias);
clusterInstanceDTO.setHosts(hosts);
clusterInstanceDTO.setType(type);
clusterInstanceDTO.setClusterConfigurationId(clusterConfigurationId);
clusterInstanceDTO.setTaskId(taskId);
clusterInstanceDTO.setAutoRegisters(true);
clusterInstanceDTO.setEnabled(true);
return clusterInstanceDTO;
}
}
/*
*
* 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.dinky.data.model.DataBase;
import org.dinky.mybatis.crypto.CryptoTypeHandler;
import org.dinky.mybatis.model.SuperEntity;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
/**
* DataBaseDTO
*
* @since 2023/10/23 10:59
**/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "DataBaseDTO", description = "API Database Data Transfer Object")
public class DataBaseDTO extends SuperEntity {
@ApiModelProperty(value = "tenantId", required = true, dataType = "Integer", example = "1")
private Integer tenantId;
@ApiModelProperty(value = "groupName", required = true, dataType = "String", example = "source")
private String groupName;
@ApiModelProperty(value = "type", required = true, dataType = "String", example = "MySQL")
private String type;
@ApiModelProperty(value = "url", required = true, dataType = "String", example = "jdbc:mysql://localhost:3306/test")
private String url;
@ApiModelProperty(value = "username", required = true, dataType = "String", example = "root")
private String username;
@TableField(typeHandler = CryptoTypeHandler.class)
@ApiModelProperty(value = "password", required = true, dataType = "String", example = "123456")
private String password;
@ApiModelProperty(value = "note", dataType = "String", example = "note")
private String note;
@ApiModelProperty(value = "flinkConfig", dataType = "String", example = "flinkConfig")
private String flinkConfig;
@ApiModelProperty(value = "flinkTemplate", dataType = "String", example = "flinkTemplate")
private String flinkTemplate;
@ApiModelProperty(value = "dbVersion", dataType = "String", example = "dbVersion")
private String dbVersion;
@ApiModelProperty(value = "status", dataType = "Boolean", example = "true")
private Boolean status;
@ApiModelProperty(value = "healthTime", dataType = "LocalDateTime", example = "2021-07-20 20:53:00")
private LocalDateTime healthTime;
@ApiModelProperty(value = "heartbeatTime", dataType = "LocalDateTime", example = "2021-07-20 20:53:00")
private LocalDateTime heartbeatTime;
public DataBase toBean() {
DataBase dataBase = new DataBase();
BeanUtil.copyProperties(this, dataBase);
return dataBase;
}
}
/*
*
* 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.dinky.data.model.Menu;
import org.dinky.mybatis.annotation.Save;
import java.util.ArrayList;
import java.util.List;
import javax.validation.constraints.NotNull;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* MenuDTO
*
* @since 2023/10/23 15:23
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "MenuDTO", description = "API Menu Data Transfer Object")
public class MenuDTO {
@ApiModelProperty(value = "Parent ID", dataType = "Integer", example = "0", notes = "ID of the parent menu")
private Integer parentId;
@NotNull(
message = "Name cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Name", dataType = "String", example = "Home", notes = "Name of the menu")
private String name;
@NotNull(
message = "Path cannot be null",
groups = {Save.class})
@ApiModelProperty(value = "Path", dataType = "String", example = "/home", notes = "Path associated with the menu")
private String path;
@NotNull(
message = "Component cannot be null",
groups = {Save.class})
@ApiModelProperty(
value = "Component",
dataType = "String",
example = "HomeComponent",
notes = "Component associated with the menu")
private String component;
@NotNull(
message = "Permissions cannot be null",
groups = {Save.class})
@ApiModelProperty(
value = "Permissions",
dataType = "String",
example = "menu:home:view",
notes = "Permissions required to access the menu")
private String perms;
@ApiModelProperty(value = "Icon", dataType = "String", notes = "Icon associated with the menu")
private String icon;
@ApiModelProperty(value = "Type", dataType = "String", notes = "Type of the menu")
private String type;
@ApiModelProperty(
value = "Order Number",
dataType = "Double",
example = "1.0",
notes = "Order number for menu positioning")
private Double orderNum;
@ApiModelProperty(value = "Display", dataType = "Boolean", notes = "Flag indicating if the menu is displayed")
private boolean display;
@ApiModelProperty(value = "Note", dataType = "String", notes = "Additional notes or details about the menu")
private String note;
@ApiModelProperty(value = "Children", dataType = "List<Menu>", notes = "List of child menus")
private List<Menu> children = new ArrayList<>();
@ApiModelProperty(value = "Root Menu", dataType = "Boolean", notes = "Flag indicating if the menu is a root menu")
private boolean rootMenu;
public Menu toBean() {
Menu menu = new Menu();
BeanUtil.copyProperties(this, menu);
return menu;
}
}
/*
*
* 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.dinky.data.model.Role;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* RoleDTO
*
* @since 2023/10/23 15:34
**/
@Data
@NoArgsConstructor
@AllArgsConstructor
@ApiModel(value = "RoleDTO", description = "API Role Data Transfer Object")
public class RoleDTO {
@ApiModelProperty(value = "ID", dataType = "Integer", example = "1", notes = "Unique identifier for the role")
private Integer id;
@ApiModelProperty(
value = "Tenant ID",
dataType = "Integer",
example = "1001",
notes = "ID of the tenant associated with the role")
private Integer tenantId;
@ApiModelProperty(
value = "Role Code",
dataType = "String",
example = "ROLE_ADMIN",
notes = "Code representing the role")
private String roleCode;
@ApiModelProperty(value = "Role Name", dataType = "String", example = "Administrator", notes = "Name of the role")
private String roleName;
@ApiModelProperty(
value = "Is Delete",
dataType = "Boolean",
notes = "Flag indicating if the role is marked as deleted")
private Boolean isDelete;
@ApiModelProperty(value = "Note", dataType = "String", notes = "Additional notes or details about the role")
private String note;
public Role toBean() {
Role role = new Role();
BeanUtil.copyProperties(this, role);
return role;
}
}
......@@ -36,7 +36,7 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor
@Builder
@ApiModel(value = "RoleMenuDto", description = "DTO for assigning menus to a role")
public class RoleMenuDto implements Serializable {
public class RoleMenuDTO implements Serializable {
@ApiModelProperty(
value = "Role ID",
......
......@@ -23,6 +23,7 @@ import org.dinky.assertion.Asserts;
import org.dinky.context.SpringContextUtils;
import org.dinky.daemon.task.DaemonFactory;
import org.dinky.daemon.task.DaemonTaskConfig;
import org.dinky.data.dto.ClusterInstanceDTO;
import org.dinky.data.enums.JobStatus;
import org.dinky.data.model.ClusterInstance;
import org.dinky.data.model.History;
......@@ -133,7 +134,7 @@ public class Job2MysqlHandler implements JobHandler {
ClusterInstance clusterInstance;
final Integer clusterConfigurationId = job.getJobConfig().getClusterConfigurationId();
if (job.isUseGateway()) {
clusterInstance = clusterInstanceService.registersCluster(ClusterInstance.autoRegistersCluster(
clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO(
job.getJobManagerAddress(),
job.getJobId(),
job.getJobConfig().getJobName() + "_" + LocalDateTime.now(),
......@@ -145,7 +146,7 @@ public class Job2MysqlHandler implements JobHandler {
}
} else if (GatewayType.LOCAL.equalsValue(job.getJobConfig().getType())
&& Asserts.isNotNullString(job.getJobManagerAddress())) {
clusterInstance = clusterInstanceService.registersCluster(ClusterInstance.autoRegistersCluster(
clusterInstance = clusterInstanceService.registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO(
job.getJobManagerAddress(),
job.getJobId(),
job.getJobConfig().getJobName() + "_" + LocalDateTime.now(),
......
......@@ -20,6 +20,7 @@
package org.dinky.service;
import org.dinky.alert.AlertResult;
import org.dinky.data.dto.AlertInstanceDTO;
import org.dinky.data.model.AlertInstance;
import org.dinky.data.result.Result;
import org.dinky.mybatis.service.ISuperService;
......@@ -39,10 +40,10 @@ public interface AlertInstanceService extends ISuperService<AlertInstance> {
/**
* test one alert instance
*
* @param alertInstance {@link AlertInstance}
* @param alertInstanceDTO {@link AlertInstanceDTO}
* @return {@link AlertResult}
*/
AlertResult testAlert(AlertInstance alertInstance);
AlertResult testAlert(AlertInstanceDTO alertInstanceDTO);
/**
* delete alert instance
......
......@@ -20,6 +20,7 @@
package org.dinky.service;
import org.dinky.cluster.FlinkClusterInfo;
import org.dinky.data.dto.ClusterInstanceDTO;
import org.dinky.data.model.ClusterInstance;
import org.dinky.mybatis.service.ISuperService;
......@@ -93,7 +94,15 @@ public interface ClusterInstanceService extends ISuperService<ClusterInstance> {
/**
* register clusterInstance instance
*
* @param clusterInstance {@link ClusterInstance} clusterInstance instance
* @param clusterInstanceDTO {@link ClusterInstanceDTO} clusterInstanceDTO instance
* @return {@link ClusterInstance}
*/
ClusterInstance registersCluster(ClusterInstanceDTO clusterInstanceDTO);
/**
* register clusterInstance instance
*
* @param clusterInstance {@link ClusterInstance} clusterInstanceDTO instance
* @return {@link ClusterInstance}
*/
ClusterInstance registersCluster(ClusterInstance clusterInstance);
......
......@@ -19,6 +19,7 @@
package org.dinky.service;
import org.dinky.data.dto.DataBaseDTO;
import org.dinky.data.dto.SqlDTO;
import org.dinky.data.dto.TaskDTO;
import org.dinky.data.model.Column;
......@@ -43,10 +44,10 @@ public interface DataBaseService extends ISuperService<DataBase> {
/**
* test connect database
*
* @param dataBase {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link String}
*/
String testConnect(DataBase dataBase);
String testConnect(DataBaseDTO dataBaseDTO);
/**
* check heart beat
......@@ -59,10 +60,10 @@ public interface DataBaseService extends ISuperService<DataBase> {
/**
* save or update database
*
* @param dataBase {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Boolean}
*/
Boolean saveOrUpdateDataBase(DataBase dataBase);
Boolean saveOrUpdateDataBase(DataBaseDTO dataBaseDTO);
/**
* enable or disable database
......@@ -173,10 +174,10 @@ public interface DataBaseService extends ISuperService<DataBase> {
/**
* copy database
*
* @param database {@link DataBase}
* @param dataBaseDTO {@link DataBaseDTO}
* @return {@link Boolean}
*/
Boolean copyDatabase(DataBase database);
Boolean copyDatabase(DataBaseDTO dataBaseDTO);
/**
* Explain common SQL statements for the given task.
......
......@@ -19,6 +19,7 @@
package org.dinky.service;
import org.dinky.data.dto.MenuDTO;
import org.dinky.data.model.Menu;
import org.dinky.data.model.User;
import org.dinky.data.result.Result;
......@@ -133,8 +134,8 @@ public interface MenuService extends ISuperService<Menu> {
/**
* save or update menu
* @param menu
* @param menuDTO
* @return
*/
boolean saveOrUpdateMenu(Menu menu);
boolean saveOrUpdateMenu(MenuDTO menuDTO);
}
......@@ -19,7 +19,7 @@
package org.dinky.service;
import org.dinky.data.dto.AssignMenuToRoleDto;
import org.dinky.data.dto.AssignMenuToRoleDTO;
import org.dinky.data.model.RoleMenu;
import org.dinky.data.result.Result;
import org.dinky.mybatis.service.ISuperService;
......@@ -32,5 +32,5 @@ public interface RoleMenuService extends ISuperService<RoleMenu> {
* @param assignMenuToRoleDto
* @return
*/
Result<Void> assignMenuToRole(AssignMenuToRoleDto assignMenuToRoleDto);
Result<Void> assignMenuToRole(AssignMenuToRoleDTO assignMenuToRoleDto);
}
......@@ -19,6 +19,7 @@
package org.dinky.service;
import org.dinky.data.dto.RoleDTO;
import org.dinky.data.model.Role;
import org.dinky.data.model.User;
import org.dinky.data.result.ProTableResult;
......@@ -35,10 +36,10 @@ public interface RoleService extends ISuperService<Role> {
/**
* create or update role
*
* @param role {@link Role}
* @param roleDTO {@link RoleDTO}
* @return {@link Result} of {@link Void}
*/
Result<Void> addedOrUpdateRole(Role role);
Result<Void> addedOrUpdateRole(RoleDTO roleDTO);
@Override
ProTableResult<Role> selectForProTable(JsonNode para);
......
......@@ -22,6 +22,7 @@ package org.dinky.service.impl;
import org.dinky.alert.Alert;
import org.dinky.alert.AlertConfig;
import org.dinky.alert.AlertResult;
import org.dinky.data.dto.AlertInstanceDTO;
import org.dinky.data.model.AlertGroup;
import org.dinky.data.model.AlertInstance;
import org.dinky.data.result.Result;
......@@ -66,9 +67,9 @@ public class AlertInstanceServiceImpl extends SuperServiceImpl<AlertInstanceMapp
}
@Override
public AlertResult testAlert(AlertInstance alertInstance) {
public AlertResult testAlert(AlertInstanceDTO alertInstanceDTO) {
AlertConfig alertConfig = AlertConfig.build(
alertInstance.getName(), alertInstance.getType(), JsonUtils.toMap(alertInstance.getParams()));
alertInstanceDTO.getName(), alertInstanceDTO.getType(), JsonUtils.toMap(alertInstanceDTO.getParams()));
Alert alert = Alert.buildTest(alertConfig);
String msg = "\n- **Job Name :** <font color='gray'>Test Job</font>\n"
......
......@@ -24,6 +24,7 @@ import org.dinky.assertion.Asserts;
import org.dinky.cluster.FlinkCluster;
import org.dinky.cluster.FlinkClusterInfo;
import org.dinky.constant.FlinkConstant;
import org.dinky.data.dto.ClusterInstanceDTO;
import org.dinky.data.model.ClusterConfiguration;
import org.dinky.data.model.ClusterInstance;
import org.dinky.gateway.config.GatewayConfig;
......@@ -126,6 +127,14 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
return list(new QueryWrapper<ClusterInstance>().eq("enabled", 1).eq("auto_registers", 1));
}
@Override
@Transactional(rollbackFor = Exception.class)
public ClusterInstance registersCluster(ClusterInstanceDTO clusterInstanceDTO) {
ClusterInstance clusterInstance = clusterInstanceDTO.toBean();
return this.registersCluster(clusterInstance);
}
@Override
@Transactional(rollbackFor = Exception.class)
public ClusterInstance registersCluster(ClusterInstance clusterInstance) {
......@@ -189,7 +198,7 @@ public class ClusterInstanceServiceImpl extends SuperServiceImpl<ClusterInstance
GatewayConfig gatewayConfig =
GatewayConfig.build(FlinkClusterConfig.create(clusterCfg.getType(), clusterCfg.getConfigJson()));
GatewayResult gatewayResult = JobManager.deploySessionCluster(gatewayConfig);
return registersCluster(ClusterInstance.autoRegistersCluster(
return registersCluster(ClusterInstanceDTO.autoRegistersClusterDTO(
gatewayResult.getWebURL().replace("http://", ""),
gatewayResult.getId(),
clusterCfg.getName() + "_" + LocalDateTime.now(),
......
......@@ -22,6 +22,7 @@ package org.dinky.service.impl;
import org.dinky.assertion.Asserts;
import org.dinky.data.annotations.ProcessStep;
import org.dinky.data.constant.CommonConstant;
import org.dinky.data.dto.DataBaseDTO;
import org.dinky.data.dto.SqlDTO;
import org.dinky.data.dto.TaskDTO;
import org.dinky.data.enums.ProcessStepType;
......@@ -61,8 +62,8 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBase> implements DataBaseService {
@Override
public String testConnect(DataBase dataBase) {
return Driver.buildUnconnected(dataBase.getDriverConfig()).test();
public String testConnect(DataBaseDTO dataBaseDTO) {
return Driver.buildUnconnected(dataBaseDTO.toBean().getDriverConfig()).test();
}
@Override
......@@ -86,7 +87,9 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
@Override
public Boolean saveOrUpdateDataBase(DataBase dataBase) {
public Boolean saveOrUpdateDataBase(DataBaseDTO dataBaseDTO) {
DataBase dataBase = dataBaseDTO.toBean();
if (Asserts.isNull(dataBase)) {
return false;
}
......@@ -238,7 +241,9 @@ public class DataBaseServiceImpl extends SuperServiceImpl<DataBaseMapper, DataBa
}
@Override
public Boolean copyDatabase(DataBase database) {
public Boolean copyDatabase(DataBaseDTO dataBaseDTO) {
DataBase database = dataBaseDTO.toBean();
String name = UUID.randomUUID().toString().replaceAll("-", "").substring(0, 10);
database.setId(null);
database.setName((database.getName().length() > 10 ? database.getName().substring(0, 10) : database.getName())
......
......@@ -20,6 +20,7 @@
package org.dinky.service.impl;
import org.dinky.data.constant.BaseConstant;
import org.dinky.data.dto.MenuDTO;
import org.dinky.data.enums.Status;
import org.dinky.data.model.Menu;
import org.dinky.data.model.RoleMenu;
......@@ -289,12 +290,14 @@ public class MenuServiceImpl extends SuperServiceImpl<MenuMapper, Menu> implemen
/**
* save or update menu
*
* @param menu
* @param menuDTO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean saveOrUpdateMenu(Menu menu) {
public boolean saveOrUpdateMenu(MenuDTO menuDTO) {
Menu menu = menuDTO.toBean();
if (StrUtil.isNotEmpty(menu.getPath())) {
// replace first / and replace other / to : for router
String replacedPerms = menu.getPath().replaceFirst("/", "").replaceAll("/", ":");
......
......@@ -19,7 +19,7 @@
package org.dinky.service.impl;
import org.dinky.data.dto.AssignMenuToRoleDto;
import org.dinky.data.dto.AssignMenuToRoleDTO;
import org.dinky.data.enums.Status;
import org.dinky.data.model.RoleMenu;
import org.dinky.data.result.Result;
......@@ -38,7 +38,7 @@ import cn.hutool.core.collection.CollUtil;
@Service
public class RoleMenuServiceImpl extends SuperServiceImpl<RoleMenuMapper, RoleMenu> implements RoleMenuService {
@Override
public Result<Void> assignMenuToRole(AssignMenuToRoleDto assignMenuToRoleDto) {
public Result<Void> assignMenuToRole(AssignMenuToRoleDTO assignMenuToRoleDto) {
if (CollUtil.isEmpty(assignMenuToRoleDto.getMenuIds())) {
return Result.failed(Status.SELECT_MENU);
......
......@@ -20,6 +20,7 @@
package org.dinky.service.impl;
import org.dinky.assertion.Asserts;
import org.dinky.data.dto.RoleDTO;
import org.dinky.data.enums.Status;
import org.dinky.data.model.Role;
import org.dinky.data.model.RowPermissions;
......@@ -77,7 +78,9 @@ public class RoleServiceImpl extends SuperServiceImpl<RoleMapper, Role> implemen
@Override
@Transactional(rollbackFor = Exception.class)
public Result<Void> addedOrUpdateRole(Role role) {
public Result<Void> addedOrUpdateRole(RoleDTO roleDTO) {
Role role = roleDTO.toBean();
if (Asserts.isNull(role.getId())) {
Role roleCode =
roleService.getOne(new LambdaQueryWrapper<Role>().eq(Role::getRoleCode, role.getRoleCode()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment