Skip to content

Commit

Permalink
[Feature][scaleph-ui-react] add doris template web under project (#648)
Browse files Browse the repository at this point in the history
* feature: add doris template mapper

* feature: add doris template service

* feature: add doris template service

* feature: add doris template web route

* feature: add doris template web
  • Loading branch information
kalencaya authored Nov 21, 2023
1 parent ef04387 commit a9569b6
Show file tree
Hide file tree
Showing 24 changed files with 1,159 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/*
* 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 cn.sliew.scaleph.api.controller.ws;

import cn.sliew.scaleph.api.annotation.Logging;
import cn.sliew.scaleph.engine.doris.service.WsDorisTemplateService;
import cn.sliew.scaleph.engine.doris.service.dto.WsDorisTemplateDTO;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateAddParam;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateListParam;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateUpdateParam;
import cn.sliew.scaleph.system.model.ResponseVO;
import cn.sliew.scaleph.system.snowflake.exception.UidGenerateException;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

@Tag(name = "Doris管理-模板管理")
@RestController
@RequestMapping(path = "/api/doris/template")
public class WsDorisTemplateController {

@Autowired
private WsDorisTemplateService wsDorisTemplateService;

@Logging
@GetMapping
@Operation(summary = "查询模板列表", description = "分页查询模板列表")
public ResponseEntity<Page<WsDorisTemplateDTO>> list(@Valid WsDorisTemplateListParam param) {
Page<WsDorisTemplateDTO> page = wsDorisTemplateService.list(param);
return new ResponseEntity<>(page, HttpStatus.OK);
}

@Logging
@GetMapping("/{id}")
@Operation(summary = "查询模板信息", description = "查询模板信息")
public ResponseEntity<ResponseVO<WsDorisTemplateDTO>> selectOne(@PathVariable("id") Long id) {
WsDorisTemplateDTO dto = wsDorisTemplateService.selectOne(id);
return new ResponseEntity(ResponseVO.success(dto), HttpStatus.OK);
}

@Logging
@PutMapping
@Operation(summary = "新增模板", description = "新增模板")
public ResponseEntity<ResponseVO> insert(@Valid @RequestBody WsDorisTemplateAddParam param) throws UidGenerateException {
wsDorisTemplateService.insert(param);
return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK);
}

@Logging
@PostMapping
@Operation(summary = "修改模板", description = "修改模板")
public ResponseEntity<ResponseVO> update(@Valid @RequestBody WsDorisTemplateUpdateParam param) {
wsDorisTemplateService.update(param);
return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK);
}

@Logging
@DeleteMapping("/{id}")
@Operation(summary = "删除模板", description = "删除模板")
public ResponseEntity<ResponseVO> delete(@PathVariable("id") Long id) {
wsDorisTemplateService.deleteById(id);
return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK);
}

@Logging
@DeleteMapping("/batch")
@Operation(summary = "批量删除模板", description = "批量删除模板")
public ResponseEntity<ResponseVO> deleteBatch(@RequestBody List<Long> ids) {
wsDorisTemplateService.deleteBatch(ids);
return new ResponseEntity<>(ResponseVO.success(), HttpStatus.OK);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* 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 cn.sliew.scaleph.dao.entity.master.ws;

import cn.sliew.scaleph.dao.entity.BaseDO;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

/**
* doris template
*/
@Data
@TableName("ws_doris_template")
@Schema(name = "WsDorisTemplate对象", description = "doris template")
public class WsDorisTemplate extends BaseDO {

private static final long serialVersionUID = 1L;

@Schema(description = "项目id")
@TableField("project_id")
private Long projectId;

@TableField("`name`")
private String name;

@TableField("template_id")
private String templateId;

@TableField("namespace")
private String namespace;

@Schema(description = "session handler")
@TableField("`admin`")
private String admin;

@Schema(description = "fe spec")
@TableField("fe_spec")
private String feSpec;

@Schema(description = "be spec")
@TableField("be_spec")
private String beSpec;

@Schema(description = "cn spec")
@TableField("cn_spec")
private String cnSpec;

@Schema(description = "broker spec")
@TableField("broker_spec")
private String brokerSpec;

@TableField("remark")
private String remark;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 cn.sliew.scaleph.dao.mapper.master.ws;

import cn.sliew.scaleph.dao.entity.master.ws.WsDorisTemplate;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springframework.stereotype.Repository;

/**
* doris template Mapper 接口
*/
@Repository
public interface WsDorisTemplateMapper extends BaseMapper<WsDorisTemplate> {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ 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.
-->

<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.sliew.scaleph.dao.mapper.master.ws.WsDorisTemplateMapper">

<!-- 通用查询映射结果 -->
<resultMap id="BaseResultMap" type="cn.sliew.scaleph.dao.entity.master.ws.WsDorisTemplate">
<result column="id" property="id" />
<result column="creator" property="creator" />
<result column="create_time" property="createTime" />
<result column="editor" property="editor" />
<result column="update_time" property="updateTime" />
<result column="project_id" property="projectId" />
<result column="name" property="name" />
<result column="template_id" property="templateId" />
<result column="namespace" property="namespace" />
<result column="admin" property="admin" />
<result column="fe_spec" property="feSpec" />
<result column="be_spec" property="beSpec" />
<result column="cn_spec" property="cnSpec" />
<result column="broker_spec" property="brokerSpec" />
<result column="remark" property="remark" />
</resultMap>

<!-- 通用查询结果列 -->
<sql id="Base_Column_List">
id,
creator,
create_time,
editor,
update_time,
project_id, `name`, template_id, namespace, `admin`, fe_spec, be_spec, cn_spec, broker_spec, remark
</sql>

</mapper>
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,13 @@

package cn.sliew.scaleph.engine.doris.operator.spec;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.fabric8.kubernetes.api.model.*;
import lombok.Data;

import javax.annotation.Nullable;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -71,10 +74,13 @@ public class BaseSpec {
private Integer replicas;

/**
* fixme 错误
* (Members of ResourceRequirements are embedded into this type.)
*/
private ResourceRequirements ResourceRequirements;
@JsonProperty("limits")
private Map<String, Quantity> limits = new LinkedHashMap();

@JsonProperty("requests")
private Map<String, Quantity> requests = new LinkedHashMap();

/**
* (Optional) Tolerations for scheduling pods onto some dedicated nodes
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* 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 cn.sliew.scaleph.engine.doris.service;

import cn.sliew.scaleph.engine.doris.service.dto.WsDorisTemplateDTO;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateAddParam;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateListParam;
import cn.sliew.scaleph.engine.doris.service.param.WsDorisTemplateUpdateParam;
import cn.sliew.scaleph.engine.doris.service.resource.DorisTemplate;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.util.List;

public interface WsDorisTemplateService {

Page<WsDorisTemplateDTO> list(WsDorisTemplateListParam param);

WsDorisTemplateDTO selectOne(Long id);

DorisTemplate asYaml(Long id);

int insert(WsDorisTemplateAddParam param);

int update(WsDorisTemplateUpdateParam param);

int deleteById(Long id);

int deleteBatch(List<Long> ids);
}
Loading

0 comments on commit a9569b6

Please sign in to comment.