Skip to content

Commit

Permalink
[Feature][scaleph-ui-react] update scaleph-ui-react2 module (#686)
Browse files Browse the repository at this point in the history
* feature: add mybatis plus postgresql generator

* feature: add mybatis plus postgresql generator

* feature: add datasource icons

* feature: update user login

* feature: update scaleph-ui-react2

* feature: update scaleph-ui-react2

---------

Co-authored-by: wangqi <wangqi@xinxuan.net>
  • Loading branch information
kalencaya and wangqi authored Jan 30, 2024
1 parent db0e449 commit 5b1bed5
Show file tree
Hide file tree
Showing 40 changed files with 205 additions and 1,212 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,180 @@
/*
* 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.generator;

import cn.sliew.scaleph.dao.entity.BaseDO;
import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.*;
import com.baomidou.mybatisplus.generator.config.builder.Controller;
import com.baomidou.mybatisplus.generator.config.builder.Entity;
import com.baomidou.mybatisplus.generator.config.builder.Mapper;
import com.baomidou.mybatisplus.generator.config.builder.Service;
import com.baomidou.mybatisplus.generator.config.converts.PostgreSqlTypeConvert;
import com.baomidou.mybatisplus.generator.config.querys.PostgreSqlQuery;
import com.baomidou.mybatisplus.generator.config.rules.DateType;
import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
import com.baomidou.mybatisplus.generator.fill.Column;
import com.baomidou.mybatisplus.generator.fill.Property;
import com.baomidou.mybatisplus.generator.keywords.PostgreSqlKeyWordsHandler;
import lombok.extern.slf4j.Slf4j;

/**
* https://baomidou.com/pages/981406/#controller-%E7%AD%96%E7%95%A5%E9%85%8D%E7%BD%AE
*/
@Slf4j
public class MybatisPlusPostgreSQLGenerator {

private final static String AUTHOR = "wangqi";
private final static String URL = "jdbc:postgresql://localhost:5432/dw";
private final static String USERNAME = "root";
private final static String PASSWORD = "123456"; //NOSONAR
private static final String BASE_PACKAGE = "cn.sliew";
private static final String MODULE = "scaleph";
private static final String TABLE_PREFIX = "";

/**
* just add table names here and run the {@link #main(String[])} method.
*/
private static final String[] TABLES = {"dwd_ds_table_1"};

public static void main(String[] args) {
//自动生成配置
FastAutoGenerator generator = FastAutoGenerator.create(dataSourceConfig())
.globalConfig(MybatisPlusPostgreSQLGenerator::globalConfig)
.packageConfig(MybatisPlusPostgreSQLGenerator::packageConfig)
.templateConfig(MybatisPlusPostgreSQLGenerator::templateConfig)
.strategyConfig(MybatisPlusPostgreSQLGenerator::strategyConfig)
.injectionConfig(MybatisPlusPostgreSQLGenerator::injectionConfig);
generator.execute();
}

/**
* 数据源配置
*
* @return DataSourceConfig
*/
private static DataSourceConfig.Builder dataSourceConfig() {
return new DataSourceConfig.Builder(URL, USERNAME, PASSWORD)
.schema("dwd")
.dbQuery(new PostgreSqlQuery())
.typeConvert(new PostgreSqlTypeConvert())
.keyWordsHandler(new PostgreSqlKeyWordsHandler());
}

/**
* 全局配置
*
* @return GlobalConfig
*/
private static void globalConfig(GlobalConfig.Builder builder) {
builder.fileOverride()
.outputDir(System.getProperty("user.dir") +
"/scaleph-support/scaleph-generator/src/main/java/")
.author(AUTHOR)
.fileOverride()
.enableSpringdoc()
.dateType(DateType.ONLY_DATE)
.commentDate("yyyy-MM-dd");
}

/**
* 包配置
*
* @return PackageConfig
*/
private static void packageConfig(PackageConfig.Builder builder) {
builder.parent(BASE_PACKAGE)
.moduleName(MODULE)
.entity("dao.entity")
.service("service")
.serviceImpl("service.impl")
.mapper("dao.mapper")
.xml("dao.mapper")
.controller("api.controller");
// .pathInfo(Collections.singletonMap(OutputFile.mapperXml, "/Users/wangqi/Downloads/generator"));
}

private static void templateConfig(TemplateConfig.Builder builder) {
// 设置 null 避免对应的类生成
// 修改 entity 模板,使用自定义的
builder.controller(null)
.service(null)
.serviceImpl(null)
.entity("/custom-entity.java.vm");
}

/**
* 策略配置
*
* @return StrategyConfig
*/
private static void strategyConfig(StrategyConfig.Builder builder) {
builder.enableCapitalMode()
.enableSkipView()
.disableSqlFilter()
.addInclude(TABLES)
.addTablePrefix(TABLE_PREFIX);

Entity.Builder entityBuilder = builder.entityBuilder();
entityBuilder.superClass(BaseDO.class)
.enableLombok()
.enableTableFieldAnnotation()
.enableRemoveIsPrefix()
.naming(NamingStrategy.underline_to_camel)
.columnNaming(NamingStrategy.underline_to_camel)
.addSuperEntityColumns("id", "creator", "created_time", "editor", "update_time")
.idType(IdType.AUTO)
.addTableFills(new Column("create_time", FieldFill.INSERT))
.addTableFills(new Property("updateTime", FieldFill.INSERT_UPDATE))
.formatFileName("%s");

Mapper.Builder mapperBuilder = builder.mapperBuilder();
mapperBuilder.superClass(BaseMapper.class)
.enableMapperAnnotation()
.enableBaseResultMap()
.enableBaseColumnList()
.formatMapperFileName("%sMapper")
.formatXmlFileName("%sMapper");

Service.Builder serviceBuilder = builder.serviceBuilder();
serviceBuilder.formatServiceFileName("%sService")
.formatServiceImplFileName("%sServiceImp")
.build();


Controller.Builder controllerBuilder = builder.controllerBuilder();
controllerBuilder.enableHyphenStyle()
.enableRestStyle()
.formatFileName("%sController")
.build();

}

/**
* 自定义配置
*
* @return InjectionConfig
*/
private static void injectionConfig(InjectionConfig.Builder builder) {

}
}
17 changes: 0 additions & 17 deletions scaleph-ui-react2/config/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -375,23 +375,6 @@ export default [
},
],
},
{
name: 'xflow',
path: '/xflow',
icon: 'setting',
routes: [
{
path: '/xflow',
redirect: '/xflow/dag',
},
{
name: 'dag',
path: '/xflow/dag',
icon: 'apartment',
component: './XFlow/dag',
},
],
},
{
path: "/user/center",
component: "./User",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 1 addition & 3 deletions scaleph-ui-react2/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,10 @@ export async function getInitialState(): Promise<{
if (resp.success && resp.data) {
user = resp.data;
} else {
console.log('fetchUserInfo', resp)
history.push("/user/login");
}
});
} catch (error) {
console.log('fetchUserInfo', error)
history.push("/user/login");
}
return user;
Expand Down Expand Up @@ -102,7 +100,7 @@ export const layout: RunTimeLayoutConfig = ({initialState, setInitialState}) =>
return (<>{defaultDom}</>);
},
rightContentRender: () => <RightContent/>,
// menuDataRender: () => defaultMenus,
menuDataRender: () => defaultMenus,
menuItemRender: (menuItemProps: any, defaultDom: any) => {
return (
<Space align="end" size={5}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ const AvatarDropdown: React.FC<GlobalHeaderRightProps> = ({ menu }) => {
};
});

const onMenuClick = useCallback(
(event: MenuInfo) => {
const onMenuClick = useCallback((event: MenuInfo) => {
const { key } = event;
if (key === "logout") {
flushSync(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ const SeaTunnelConfModal: React.FC<ModalFormProps<WsDiJob>> = ({visible, onVisib
<Drawer
open={visible}
width={780}
bodyStyle={{overflowY: 'scroll'}}
styles={{
body: {overflowY: 'scroll'}
}}
destroyOnClose={true}
onClose={onCancel}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,5 +89,11 @@ body {
}
}
}

:global {
button {
color: #000;
}
}
}
}
1 change: 0 additions & 1 deletion scaleph-ui-react2/src/pages/Studio/DataBoard/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ const DataBoard: React.FC = () => {
fetchJob({ jobType: 'r' }).then((d) => setRealtimeJobCnt(d));
fetchProject();
fetchTopBatch100();
console.log(topBatch100)
}, []);
// 集群数量
const fetchCluster = useCallback(async () => {
Expand Down
25 changes: 14 additions & 11 deletions scaleph-ui-react2/src/pages/User/Login/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ const Login: React.FC = () => {
const {initialState, setInitialState} = useModel("@@initialState");

useEffect(() => {
localStorage.clear();
refreshAuthCode();
}, []);

const refreshAuthCode = async () => {
const data = await AuthService.refreshAuthImage();
setAuthCode(data);
AuthService.refreshAuthImage().then((data) => setAuthCode(data))
};

const handleSubmit = async () => {
Expand All @@ -54,15 +54,18 @@ const Login: React.FC = () => {
localStorage.setItem(USER_AUTH.token, resp.data);
message.success(intl.formatMessage({id: "pages.user.login.success"}));
UserService.getOnlineUserInfo(resp.data).then(async (response) => {
await flushSync(() => {
setInitialState((state) => ({
...state,
currentUser: response.data,
}));
});
setTimeout(() => {
navigate("/");
}, 500);
if (response.success && response.data) {
await flushSync(() => {
setInitialState((state) => ({
...state,
currentUser: response.data,
}));
});
AuthService.setSession(response.data)
setTimeout(() => {
navigate("/");
}, 500);
}
})
} else {
refreshAuthCode();
Expand Down
74 changes: 0 additions & 74 deletions scaleph-ui-react2/src/pages/XFlow/dag/config-drawer/index.tsx

This file was deleted.

13 changes: 0 additions & 13 deletions scaleph-ui-react2/src/pages/XFlow/dag/connect.tsx

This file was deleted.

Loading

0 comments on commit 5b1bed5

Please sign in to comment.