21 |
--------------------------------------------------------------------------------
/petstore/petstore-dist/bin/sqlshell.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | # Licensed to the Apache Software Foundation (ASF) under one or more
4 | # contributor license agreements. See the NOTICE file distributed with
5 | # this work for additional information regarding copyright ownership.
6 | # The ASF licenses this file to You under the Apache License, Version 2.0
7 | # (the "License"); you may not use this file except in compliance with
8 | # the License. You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 | # Initial Developer: zhh
19 |
20 | ./lealone.sh -client $@
21 |
--------------------------------------------------------------------------------
/petstore/petstore-dist/bin/sqlshell.bat:
--------------------------------------------------------------------------------
1 | @REM
2 | @REM Licensed to the Apache Software Foundation (ASF) under one or more
3 | @REM contributor license agreements. See the NOTICE file distributed with
4 | @REM this work for additional information regarding copyright ownership.
5 | @REM The ASF licenses this file to You under the Apache License, Version 2.0
6 | @REM (the "License"); you may not use this file except in compliance with
7 | @REM the License. You may obtain a copy of the License at
8 | @REM
9 | @REM http://www.apache.org/licenses/LICENSE-2.0
10 | @REM
11 | @REM Unless required by applicable law or agreed to in writing, software
12 | @REM distributed under the License is distributed on an "AS IS" BASIS,
13 | @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | @REM See the License for the specific language governing permissions and
15 | @REM limitations under the License.
16 | @REM
17 | @REM Initial Developer: zhh
18 |
19 | @echo off
20 | .\lealone.bat -client %*
21 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/common/js/plugins/README.md:
--------------------------------------------------------------------------------
1 | # Lealone-JS
2 |
3 | Lealone 前端动态化与智能化 RPC 客户端
4 |
5 | 不必学习 node.js、npm、webpack 等前端构建工具也能进行前端工程化组件化开发。
6 |
7 |
8 | ### lealone-rpc-5.0.0.js
9 |
10 | RPC 客户端,动态智能化绑定后端服务,可以使用 axios 或 sockjs 与后端通信。
11 |
12 |
13 | ### lealone-vue-5.0.0.js
14 |
15 | vue 框架扩展库,支持跨应用跨组件路由,把组件绑定到后端服务能极大降低应用的 js 代码量。
16 |
17 |
18 | ### vue-2.6.12.js
19 |
20 | vue 框架的定制版本,只修改了少量代码,增加了两个功能:
21 |
22 | 1. 允许在不挂载组件的情况下获取组件实例
23 |
24 | 2. 允许组件依赖的数据就绪后再执行组件渲染操作
25 |
26 |
27 | ### 用法
28 |
29 | 完整的例子可以从 [PetStore](https://github.com/lealone/Lealone-Examples/tree/main/petstore) 这个应用开始
30 |
31 | PetStore 是一个多页应用,分成三个子应用:
32 |
33 | [home](https://github.com/lealone/Lealone-Examples/blob/main/petstore/petstore-web/web/home/index.html) 主页与购物车
34 |
35 | [user](https://github.com/lealone/Lealone-Examples/blob/main/petstore/petstore-web/web/user/index.html) 用户管理
36 |
37 | [store](https://github.com/lealone/Lealone-Examples/blob/main/petstore/petstore-web/web/store/index.html) 库存管理
38 |
39 |
40 |
--------------------------------------------------------------------------------
/rpc-demo/web/hello.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
rpc client test
12 |
13 |
14 | say hello:
15 |
16 |
{{ message }}
17 |
18 |
19 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/rpc-demo/src/main/java/com/lealone/examples/rpc/HelloService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.rpc;
19 |
20 | public class HelloService {
21 | public String sayHello(String name) {
22 | return "Hello " + name;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/home/template/layout/tabs.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
宠物类目
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
搜索宠物
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/petstore/petstore-dist/bin/runSqlScript.bat:
--------------------------------------------------------------------------------
1 | @REM
2 | @REM Licensed to the Apache Software Foundation (ASF) under one or more
3 | @REM contributor license agreements. See the NOTICE file distributed with
4 | @REM this work for additional information regarding copyright ownership.
5 | @REM The ASF licenses this file to You under the Apache License, Version 2.0
6 | @REM (the "License"); you may not use this file except in compliance with
7 | @REM the License. You may obtain a copy of the License at
8 | @REM
9 | @REM http://www.apache.org/licenses/LICENSE-2.0
10 | @REM
11 | @REM Unless required by applicable law or agreed to in writing, software
12 | @REM distributed under the License is distributed on an "AS IS" BASIS,
13 | @REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | @REM See the License for the specific language governing permissions and
15 | @REM limitations under the License.
16 |
17 | @echo off
18 | java -cp ../lib/lealone-petstore-1.0.0.jar^
19 | com.lealone.examples.petstore.main.PetStoreSqlScript^
20 | -tableDir ../sql -serviceDir ../sql -srcDir ../src
21 |
--------------------------------------------------------------------------------
/polyglot-demo/src/main/java/com/lealone/examples/polyglot/TimeService.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.polyglot;
19 |
20 | public class TimeService {
21 | public String getCurrentTime() {
22 | return new java.util.Date().toString();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/js-demo/src/main/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | protocol_server_engines:
20 | - name: VERTX
21 | enabled: true
22 | parameters: {
23 | port: 9000,
24 | environment: dev,
25 | web_root: ./web,
26 | jdbc_url: "jdbc:lealone:embed:lealone?user=root"
27 | }
28 |
--------------------------------------------------------------------------------
/rpc-demo/src/main/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | protocol_server_engines:
20 | - name: VERTX
21 | enabled: true
22 | parameters: {
23 | port: 9000,
24 | environment: dev,
25 | web_root: ./web,
26 | jdbc_url: "jdbc:lealone:embed:lealone?user=root"
27 | }
28 |
--------------------------------------------------------------------------------
/fullstack-demo/src/main/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | protocol_server_engines:
20 | - name: VERTX
21 | enabled: true
22 | parameters: {
23 | port: 9000,
24 | environment: dev,
25 | web_root: ./web,
26 | jdbc_url: "jdbc:lealone:embed:test?user=root"
27 | }
28 |
--------------------------------------------------------------------------------
/polyglot-demo/src/main/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | protocol_server_engines:
20 | - name: VERTX
21 | enabled: true
22 | parameters: {
23 | port: 9000,
24 | environment: dev,
25 | web_root: ./web,
26 | jdbc_url: "jdbc:lealone:embed:lealone?user=root"
27 | }
28 |
--------------------------------------------------------------------------------
/python-demo/src/main/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | protocol_server_engines:
20 | - name: VERTX
21 | enabled: true
22 | parameters: {
23 | port: 9000,
24 | environment: dev,
25 | web_root: ./web,
26 | jdbc_url: "jdbc:lealone:embed:lealone?user=root"
27 | }
28 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/home/template/layout/footer.html:
--------------------------------------------------------------------------------
1 |
22 |
--------------------------------------------------------------------------------
/petstore/petstore-test/src/test/java/com/lealone/examples/petstore/test/PetStoreSqlScriptTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.petstore.test;
19 |
20 | import com.lealone.examples.petstore.main.PetStoreSqlScript;
21 |
22 | public class PetStoreSqlScriptTest {
23 |
24 | public static void main(String[] args) throws Exception {
25 | PetStoreSqlScript.main(args);
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/petstore/petstore-test/src/test/resources/lealone.yaml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing, software
12 | # distributed under the License is distributed on an "AS IS" BASIS,
13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | # See the License for the specific language governing permissions and
15 | # limitations under the License.
16 |
17 | base_dir: ./target/data
18 |
19 | listen_address: 127.0.0.1
20 |
21 | protocol_server_engines:
22 | - name: VERTX
23 | enabled: true
24 | parameters: {
25 | port: 9000,
26 | environment: dev,
27 | web_root: ../petstore-web/web,
28 | router: "com.lealone.examples.petstore.web.PetStoreRouter",
29 | jdbc_url: "jdbc:lealone:embed:petstore?user=root"
30 | }
31 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/user/js/hooks.js:
--------------------------------------------------------------------------------
1 | const userHooks = {
2 | getUser: {
3 | before() {
4 | if(!lealone.currentUser) {
5 | lealone.route('user', 'login');
6 | return false;
7 | }
8 | this.userId = lealone.currentUser;
9 | }
10 | },
11 | register: {
12 | before() {
13 | if(this.password != this.password2) {
14 | this.errorMessage = "密码验证 必须和 密码 相同";
15 | return false;
16 | }
17 | },
18 | after(response) {
19 | if(!lealone.currentUser) {
20 | lealone.currentUser = this.userId;
21 | localStorage.currentUser = this.userId;
22 | }
23 | location.href = "/";
24 | }
25 | },
26 | update: {
27 | before() { this.account.userId = lealone.currentUser },
28 | after() { lealone.route('user', 'account') }
29 | },
30 | login: {
31 | after(data) {
32 | lealone.currentUser = data.userId;
33 | localStorage.currentUser = data.userId;
34 | location.href = "/";
35 | },
36 | error(msg) { this.errorMessage = "用户名或密码不正确,请重新输入" }
37 | }
38 | }
39 |
40 | UserService.hooks = userHooks;
41 |
--------------------------------------------------------------------------------
/js-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/orm-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/rpc-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/polyglot-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/python-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/fullstack-demo/src/main/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/petstore/petstore-test/src/test/resources/log4j2.xml:
--------------------------------------------------------------------------------
1 |
2 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/store/template/category-list.html:
--------------------------------------------------------------------------------
1 |
44 |
--------------------------------------------------------------------------------
/spring-demo/src/main/java/com/lealone/examples/spring/SpringDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.spring;
19 |
20 | import org.springframework.boot.SpringApplication;
21 | import org.springframework.boot.autoconfigure.SpringBootApplication;
22 |
23 | @SpringBootApplication(scanBasePackages = {
24 | "com.lealone.plugins.spring",
25 | "com.lealone.examples.spring" })
26 | public class SpringDemo {
27 | public static void main(String[] args) {
28 | SpringApplication.run(SpringDemo.class, args);
29 | HelloService.create();
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/store/template/item-list.html:
--------------------------------------------------------------------------------
1 |
36 |
--------------------------------------------------------------------------------
/spring-demo/src/main/java/com/lealone/examples/spring/ServletInitializer.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.spring;
19 |
20 | import org.springframework.boot.builder.SpringApplicationBuilder;
21 | import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
22 |
23 | public class ServletInitializer extends SpringBootServletInitializer {
24 |
25 | @Override
26 | protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
27 | HelloService.create();
28 | return application.sources(SpringDemo.class);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/petstore/petstore-service/src/main/resources/services.sql:
--------------------------------------------------------------------------------
1 |
2 | -- 删除服务: user_service
3 | drop service if exists user_service;
4 |
5 | -- 创建服务: user_service
6 | create service if not exists user_service (
7 | login(user_id varchar, password varchar) user,
8 | logout(user_id varchar) varchar,
9 | register(user_id varchar, password varchar, password2 varchar) void,
10 | update(account Account) void,
11 | get_user(user_id varchar) varchar
12 | )
13 | implement by 'com.lealone.examples.petstore.service.UserService' -- user_service 的默认实现类
14 | ;
15 |
16 | -- 删除服务: store_service
17 | drop service if exists store_service;
18 |
19 | -- 创建服务: store_service
20 | create service if not exists store_service (
21 | add_product(product Product, logo varchar) varchar,
22 | get_all_categories() varchar,
23 | get_all_product_items(product_id varchar) varchar
24 | )
25 | implement by 'com.lealone.examples.petstore.service.StoreService' -- store_service 的默认实现类
26 | ;
27 |
28 | -- 删除服务: view_cart_service
29 | drop service if exists view_cart_service;
30 |
31 | -- 创建服务: view_cart_service
32 | create service if not exists view_cart_service (
33 | add_item(cart_id varchar, item_id varchar) void,
34 | remove_item(cart_id varchar, item_id varchar) void,
35 | update(cart_id varchar, item_id varchar, quantity int) void,
36 | get_items(cart_id varchar) varchar
37 | )
38 | implement by 'com.lealone.examples.petstore.service.ViewCartService' -- view_cart_service 的默认实现类
39 | ;
40 |
--------------------------------------------------------------------------------
/petstore/petstore-test/src/test/java/com/lealone/examples/petstore/test/PetStoreTemplateCompilerTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.petstore.test;
19 |
20 | import java.io.IOException;
21 |
22 | import com.lealone.examples.petstore.main.PetStore;
23 | import com.lealone.plugins.service.template.TemplateCompiler;
24 |
25 | public class PetStoreTemplateCompilerTest {
26 |
27 | public static void main(String[] args) throws IOException {
28 | String webRoot = PetStore.getAbsolutePath("petstore-web/web");
29 | args = new String[] { "-webRoot", webRoot };
30 | TemplateCompiler.main(args);
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/spring-demo/src/main/java/com/lealone/examples/spring/HelloController.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.spring;
19 |
20 | import org.springframework.web.bind.annotation.GetMapping;
21 | import org.springframework.web.bind.annotation.RequestParam;
22 | import org.springframework.web.bind.annotation.RestController;
23 |
24 | @RestController
25 | public class HelloController {
26 |
27 | // 用这样的url打开: http://localhost:8080/hello?name=zhh
28 | @GetMapping("/hello")
29 | public String hello(@RequestParam(value = "name", defaultValue = "World") String name) {
30 | return "Hello " + HelloService.getUser(name);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/petstore/petstore-test/src/test/java/com/lealone/examples/petstore/test/TemplateEngineTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.petstore.test;
19 |
20 | import com.lealone.examples.petstore.main.PetStore;
21 | import com.lealone.plugins.service.template.TemplateEngine;
22 |
23 | public class TemplateEngineTest {
24 |
25 | public static void main(String[] args) throws Exception {
26 | String webRoot = PetStore.getAbsolutePath("petstore-web/web");
27 | TemplateEngine te = new TemplateEngine(webRoot, "utf-8");
28 | String str = te.process("/home/index.html");
29 | System.out.println(str);
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/petstore/petstore-web/web/user/template/login.html:
--------------------------------------------------------------------------------
1 |
2 |
45 |
46 |
--------------------------------------------------------------------------------
/rpc-demo/src/main/java/com/lealone/examples/rpc/RpcDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.rpc;
19 |
20 | import com.lealone.main.Lealone;
21 |
22 | // 请在浏览器中打开下面的 URL 进行测试:
23 | // http://localhost:9000/service/hello_service/say_hello?name=zhh
24 | // http://localhost:9000/hello.html
25 | public class RpcDemo {
26 |
27 | public static void main(String[] args) {
28 | Lealone.main(args, () -> runScript());
29 | }
30 |
31 | public static void runScript() {
32 | String url = "jdbc:lealone:tcp://localhost:9210/lealone?user=root";
33 | // 执行 services.sql 脚本,创建服务
34 | Lealone.runScript(url, "./sql/services.sql");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/fullstack-demo/src/main/java/com/lealone/examples/fullstack/FullStackDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.fullstack;
19 |
20 | import com.lealone.main.Lealone;
21 |
22 | // 请在浏览器中打开下面的 URL 进行测试:
23 | // http://localhost:9000/fullStack.html
24 | public class FullStackDemo {
25 |
26 | public static void main(String[] args) {
27 | Lealone.main(args, () -> runScript());
28 | }
29 |
30 | public static void runScript() {
31 | String url = "jdbc:lealone:tcp://localhost:9210/test?user=root";
32 | // 执行建表脚本,同时自动生成对应的模型类的代码
33 | // 执行服务创建脚本,同时自动生成对应的服务接口代码
34 | Lealone.runScript(url, "./sql/tables.sql", "./sql/services.sql");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/petstore/petstore-dal/pom.xml:
--------------------------------------------------------------------------------
1 |
18 |
20 | 4.0.0
21 |
22 | com.lealone.examples.petstore
23 | petstore
24 | 1.0.0
25 | ../pom.xml
26 |
27 |
28 | petstore-dal
29 | jar
30 | 1.0.0
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/polyglot-demo/src/main/java/com/lealone/examples/polyglot/PolyglotDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.polyglot;
19 |
20 | import com.lealone.main.Lealone;
21 |
22 | // 请在浏览器中打开下面的 URL 进行测试:
23 | // http://localhost:9000/service/hello_service/hello?name=zhh
24 | // http://localhost:9000/service/time_service/get_current_time
25 | public class PolyglotDemo {
26 |
27 | public static void main(String[] args) {
28 | Lealone.main(args, () -> runScript());
29 | }
30 |
31 | public static void runScript() {
32 | String url = "jdbc:lealone:tcp://localhost:9210/lealone?user=root";
33 | // 执行服务创建脚本,同时自动生成对应的服务接口代码
34 | Lealone.runScript(url, "./sql/services.sql");
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Lealone-Examples
2 |
3 | 一些用于演示 Lealone 功能的例子
4 |
5 |
6 | ### rpc-demo
7 |
8 | 演示 Lealone RPC 框架最简单的用法,请继续阅读文档: [微服务框架快速入门](https://github.com/lealone/Lealone-Docs/blob/master/应用文档/微服务框架快速入门.md)
9 |
10 |
11 | ### orm-demo
12 |
13 | 演示 Lealone ORM 框架最常用的功能,请继续阅读文档: [Lealone ORM 框架快速入门](https://github.com/lealone/Lealone-Docs/blob/master/%E5%BA%94%E7%94%A8%E6%96%87%E6%A1%A3/Lealone%20ORM%E6%A1%86%E6%9E%B6%E5%BF%AB%E9%80%9F%E5%85%A5%E9%97%A8.md)
14 |
15 |
16 | ### fullstack-demo
17 |
18 | 综合应用 Lealone RPC 和 ORM 框架开发一个全栈微服务应用,
19 | 请继续阅读文档: [使用 Lealone RPC 和 ORM 框架开发一个全栈微服务应用](https://github.com/lealone/Lealone-Docs/blob/master/%E5%BA%94%E7%94%A8%E6%96%87%E6%A1%A3/%E4%BD%BF%E7%94%A8Lealone%20RPC%E5%92%8CORM%E6%A1%86%E6%9E%B6%E5%BC%80%E5%8F%91%E4%B8%80%E4%B8%AA%E5%85%A8%E6%A0%88%E5%BE%AE%E6%9C%8D%E5%8A%A1%E5%BA%94%E7%94%A8.md)
20 |
21 |
22 | ### js-demo
23 |
24 | 使用 JavaScript 开发一个全栈微服务应用,
25 | 请继续阅读文档: [基于 ORM 框架使用 JavaScript 开发一个全栈微服务应用](https://github.com/lealone/Lealone-Docs/blob/master/应用文档/基于ORM框架使用JavaScript开发一个全栈微服务应用.md)
26 |
27 |
28 | ### python-demo
29 |
30 | 使用 Python 开发一个全栈微服务应用,
31 | 请继续阅读文档: [基于 ORM 框架使用 Python 开发一个全栈微服务应用](https://github.com/lealone/Lealone-Docs/blob/master/应用文档/基于ORM框架使用Python开发一个全栈微服务应用.md)
32 |
33 |
34 | ### spring-demo
35 |
36 | 演示如何在 Spring 应用中集成 Lealone,
37 | 请继续阅读文档: [在 Spring 现有应用中使用 Lealone 微服务框架](https://github.com/lealone/Lealone-Docs/blob/master/应用文档/在Spring现有应用中使用Lealone微服务框架.md)
38 |
39 |
40 | ### petstore
41 |
42 | 基于 Vue + Lealone 开发的 [PetStore 应用](https://github.com/lealone/Lealone-Examples/blob/main/petstore/README.md)
43 |
44 |
--------------------------------------------------------------------------------
/petstore/petstore-dal/src/main/java/com/lealone/examples/petstore/dal/model/Sequence.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.petstore.dal.model;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PInteger;
8 | import com.lealone.plugins.orm.property.PString;
9 |
10 | /**
11 | * Model for table 'SEQUENCE'.
12 | *
13 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
14 | */
15 | public class Sequence extends Model {
16 |
17 | public static final Sequence dao = new Sequence(null, ROOT_DAO);
18 |
19 | public final PString name;
20 | public final PInteger nextid;
21 |
22 | public Sequence() {
23 | this(null, REGULAR_MODEL);
24 | }
25 |
26 | private Sequence(ModelTable t, short modelType) {
27 | super(t == null ? new ModelTable("PETSTORE", "PUBLIC", "SEQUENCE") : t, modelType);
28 | name = new PString<>("NAME", this);
29 | nextid = new PInteger<>("NEXTID", this);
30 | super.setModelProperties(new ModelProperty[] { name, nextid });
31 | }
32 |
33 | @Override
34 | protected Sequence newInstance(ModelTable t, short modelType) {
35 | return new Sequence(t, modelType);
36 | }
37 |
38 | public static Sequence decode(String str) {
39 | return decode(str, null);
40 | }
41 |
42 | public static Sequence decode(String str, JsonFormat format) {
43 | return new Sequence().decode0(str, format);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/petstore/petstore-dal/src/main/java/com/lealone/examples/petstore/dal/model/User.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.petstore.dal.model;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PString;
8 |
9 | /**
10 | * Model for table 'USER'.
11 | *
12 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
13 | */
14 | public class User extends Model {
15 |
16 | public static final User dao = new User(null, ROOT_DAO);
17 |
18 | public final PString userId;
19 | public final PString password;
20 | public final PString roles;
21 |
22 | public User() {
23 | this(null, REGULAR_MODEL);
24 | }
25 |
26 | private User(ModelTable t, short modelType) {
27 | super(t == null ? new ModelTable("PETSTORE", "PUBLIC", "USER") : t, modelType);
28 | userId = new PString<>("USER_ID", this);
29 | password = new PString<>("PASSWORD", this);
30 | roles = new PString<>("ROLES", this);
31 | super.setModelProperties(new ModelProperty[] { userId, password, roles });
32 | }
33 |
34 | @Override
35 | protected User newInstance(ModelTable t, short modelType) {
36 | return new User(t, modelType);
37 | }
38 |
39 | public static User decode(String str) {
40 | return decode(str, null);
41 | }
42 |
43 | public static User decode(String str, JsonFormat format) {
44 | return new User().decode0(str, format);
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/js-demo/src/main/java/com/lealone/examples/js/User.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.js;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PInteger;
8 | import com.lealone.plugins.orm.property.PLong;
9 | import com.lealone.plugins.orm.property.PString;
10 |
11 | /**
12 | * Model for table 'USER'.
13 | *
14 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
15 | */
16 | public class User extends Model {
17 |
18 | public static final User dao = new User(null, ROOT_DAO);
19 |
20 | public final PLong id;
21 | public final PString name;
22 | public final PInteger age;
23 |
24 | public User() {
25 | this(null, REGULAR_MODEL);
26 | }
27 |
28 | private User(ModelTable t, short modelType) {
29 | super(t == null ? new ModelTable("LEALONE", "PUBLIC", "USER") : t, modelType);
30 | id = new PLong<>("ID", this);
31 | name = new PString<>("NAME", this);
32 | age = new PInteger<>("AGE", this);
33 | super.setModelProperties(new ModelProperty[] { id, name, age });
34 | }
35 |
36 | @Override
37 | protected User newInstance(ModelTable t, short modelType) {
38 | return new User(t, modelType);
39 | }
40 |
41 | public static User decode(String str) {
42 | return decode(str, null);
43 | }
44 |
45 | public static User decode(String str, JsonFormat format) {
46 | return new User().decode0(str, format);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/petstore/petstore-dal/src/main/java/com/lealone/examples/petstore/dal/model/Inventory.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.petstore.dal.model;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PInteger;
8 | import com.lealone.plugins.orm.property.PString;
9 |
10 | /**
11 | * Model for table 'INVENTORY'.
12 | *
13 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
14 | */
15 | public class Inventory extends Model {
16 |
17 | public static final Inventory dao = new Inventory(null, ROOT_DAO);
18 |
19 | public final PString itemid;
20 | public final PInteger qty;
21 |
22 | public Inventory() {
23 | this(null, REGULAR_MODEL);
24 | }
25 |
26 | private Inventory(ModelTable t, short modelType) {
27 | super(t == null ? new ModelTable("PETSTORE", "PUBLIC", "INVENTORY") : t, modelType);
28 | itemid = new PString<>("ITEMID", this);
29 | qty = new PInteger<>("QTY", this);
30 | super.setModelProperties(new ModelProperty[] { itemid, qty });
31 | }
32 |
33 | @Override
34 | protected Inventory newInstance(ModelTable t, short modelType) {
35 | return new Inventory(t, modelType);
36 | }
37 |
38 | public static Inventory decode(String str) {
39 | return decode(str, null);
40 | }
41 |
42 | public static Inventory decode(String str, JsonFormat format) {
43 | return new Inventory().decode0(str, format);
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/js-demo/src/main/java/com/lealone/examples/js/JsDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.js;
19 |
20 | import com.lealone.main.Lealone;
21 |
22 | // 在前端调用 hello_service 服务,用以下 url:
23 | // http://localhost:9000/service/hello_service/hello?name=zhh
24 |
25 | // 在前端调用 user_service 服务,请在浏览器中打开下面这个 url 进行测试:
26 | // http://localhost:9000/fullStack.html
27 | public class JsDemo {
28 |
29 | public static void main(String[] args) {
30 | Lealone.main(args, () -> runScript());
31 | }
32 |
33 | public static void runScript() {
34 | String url = "jdbc:lealone:tcp://localhost:9210/lealone?user=root";
35 | // 执行建表脚本,同时自动生成对应的模型类的代码
36 | // 执行服务创建脚本,同时自动生成对应的服务接口代码
37 | Lealone.runScript(url, "./sql/tables.sql", "./sql/services.sql");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/petstore/petstore-dal/src/main/java/com/lealone/examples/petstore/dal/model/BannerData.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.petstore.dal.model;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PString;
8 |
9 | /**
10 | * Model for table 'BANNER_DATA'.
11 | *
12 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
13 | */
14 | public class BannerData extends Model {
15 |
16 | public static final BannerData dao = new BannerData(null, ROOT_DAO);
17 |
18 | public final PString favcategory;
19 | public final PString bannerName;
20 |
21 | public BannerData() {
22 | this(null, REGULAR_MODEL);
23 | }
24 |
25 | private BannerData(ModelTable t, short modelType) {
26 | super(t == null ? new ModelTable("PETSTORE", "PUBLIC", "BANNER_DATA") : t, modelType);
27 | favcategory = new PString<>("FAVCATEGORY", this);
28 | bannerName = new PString<>("BANNER_NAME", this);
29 | super.setModelProperties(new ModelProperty[] { favcategory, bannerName });
30 | }
31 |
32 | @Override
33 | protected BannerData newInstance(ModelTable t, short modelType) {
34 | return new BannerData(t, modelType);
35 | }
36 |
37 | public static BannerData decode(String str) {
38 | return decode(str, null);
39 | }
40 |
41 | public static BannerData decode(String str, JsonFormat format) {
42 | return new BannerData().decode0(str, format);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/python-demo/src/main/java/com/lealone/examples/python/User.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.python;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PInteger;
8 | import com.lealone.plugins.orm.property.PLong;
9 | import com.lealone.plugins.orm.property.PString;
10 |
11 | /**
12 | * Model for table 'USER'.
13 | *
14 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
15 | */
16 | public class User extends Model {
17 |
18 | public static final User dao = new User(null, ROOT_DAO);
19 |
20 | public final PLong id;
21 | public final PString name;
22 | public final PInteger age;
23 |
24 | public User() {
25 | this(null, REGULAR_MODEL);
26 | }
27 |
28 | private User(ModelTable t, short modelType) {
29 | super(t == null ? new ModelTable("LEALONE", "PUBLIC", "USER") : t, modelType);
30 | id = new PLong<>("ID", this);
31 | name = new PString<>("NAME", this);
32 | age = new PInteger<>("AGE", this);
33 | super.setModelProperties(new ModelProperty[] { id, name, age });
34 | }
35 |
36 | @Override
37 | protected User newInstance(ModelTable t, short modelType) {
38 | return new User(t, modelType);
39 | }
40 |
41 | public static User decode(String str) {
42 | return decode(str, null);
43 | }
44 |
45 | public static User decode(String str, JsonFormat format) {
46 | return new User().decode0(str, format);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/python-demo/src/main/java/com/lealone/examples/python/PythonDemo.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.python;
19 |
20 | import com.lealone.main.Lealone;
21 |
22 | // 在前端调用 hello_service 服务,用以下 url:
23 | // http://localhost:9000/service/hello_service/hello?name=zhh
24 |
25 | // 在前端调用 user_service 服务,请在浏览器中打开下面这个 url 进行测试:
26 | // http://localhost:9000/fullStack.html
27 | public class PythonDemo {
28 |
29 | public static void main(String[] args) {
30 | Lealone.main(args, () -> runScript());
31 | }
32 |
33 | public static void runScript() {
34 | String url = "jdbc:lealone:tcp://localhost:9210/lealone?user=root";
35 | // 执行建表脚本,同时自动生成对应的模型类的代码
36 | // 执行服务创建脚本,同时自动生成对应的服务接口代码
37 | Lealone.runScript(url, "./sql/tables.sql", "./sql/services.sql");
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/fullstack-demo/src/main/java/com/lealone/examples/fullstack/generated/model/User.java:
--------------------------------------------------------------------------------
1 | package com.lealone.examples.fullstack.generated.model;
2 |
3 | import com.lealone.plugins.orm.Model;
4 | import com.lealone.plugins.orm.ModelProperty;
5 | import com.lealone.plugins.orm.ModelTable;
6 | import com.lealone.plugins.orm.format.JsonFormat;
7 | import com.lealone.plugins.orm.property.PInteger;
8 | import com.lealone.plugins.orm.property.PLong;
9 | import com.lealone.plugins.orm.property.PString;
10 |
11 | /**
12 | * Model for table 'USER'.
13 | *
14 | * THIS IS A GENERATED OBJECT, DO NOT MODIFY THIS CLASS.
15 | */
16 | public class User extends Model {
17 |
18 | public static final User dao = new User(null, ROOT_DAO);
19 |
20 | public final PLong id;
21 | public final PString name;
22 | public final PInteger age;
23 |
24 | public User() {
25 | this(null, REGULAR_MODEL);
26 | }
27 |
28 | private User(ModelTable t, short modelType) {
29 | super(t == null ? new ModelTable("TEST", "PUBLIC", "USER") : t, modelType);
30 | id = new PLong<>("ID", this);
31 | name = new PString<>("NAME", this);
32 | age = new PInteger<>("AGE", this);
33 | super.setModelProperties(new ModelProperty[] { id, name, age });
34 | }
35 |
36 | @Override
37 | protected User newInstance(ModelTable t, short modelType) {
38 | return new User(t, modelType);
39 | }
40 |
41 | public static User decode(String str) {
42 | return decode(str, null);
43 | }
44 |
45 | public static User decode(String str, JsonFormat format) {
46 | return new User().decode0(str, format);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/fullstack-demo/src/main/java/com/lealone/examples/fullstack/UserServiceImpl.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing, software
13 | * distributed under the License is distributed on an "AS IS" BASIS,
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | * See the License for the specific language governing permissions and
16 | * limitations under the License.
17 | */
18 | package com.lealone.examples.fullstack;
19 |
20 | import com.lealone.examples.fullstack.generated.model.User;
21 | import com.lealone.examples.fullstack.generated.service.UserService;
22 |
23 | public class UserServiceImpl implements UserService {
24 | @Override
25 | public Long addUser(String name, Integer age) {
26 | // 如果 name = 'zhh', age = 18
27 | // 对应的sql是: insert into user(name, age) values('zhh', 18);
28 | return new User().name.set(name).age.set(age).insert(); // 链式调用,insert()返回新增记录的rowId
29 | }
30 |
31 | @Override
32 | public User findByName(String name) {
33 | // 如果 name = 'zhh'
34 | // 对应的sql是: select * from user where name = 'zhh' limit 1
35 | return User.dao.where().name.eq(name).findOne();
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/spring-demo/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 | 4.0.0
5 | com.lealone.examples
6 | lealone-spring-demo
7 | 1.0.0
8 | jar
9 |
10 |
11 |
12 | com.lealone.plugins
13 | lealone-spring
14 | 6.0.1
15 |
16 |
17 |
18 |
19 |
20 |
21 | org.apache.maven.plugins
22 | maven-compiler-plugin
23 | 2.3.2
24 |
25 | 1.8
26 | 1.8
27 | UTF-8
28 |
29 |
30 |
31 | org.springframework.boot
32 | spring-boot-maven-plugin
33 | 2.3.0.RELEASE
34 |
35 |
36 |
37 | repackage
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
--------------------------------------------------------------------------------
/petstore/petstore-main/pom.xml:
--------------------------------------------------------------------------------
1 |
18 |
20 | 4.0.0
21 |
22 | com.lealone.examples.petstore
23 | petstore
24 | 1.0.0
25 | ../pom.xml
26 |
27 |
28 | petstore-main
29 | jar
30 | 1.0.0
31 |
32 |
33 |
34 | com.lealone.examples.petstore
35 | petstore-web
36 | ${project.version}
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/petstore/petstore-test/pom.xml:
--------------------------------------------------------------------------------
1 |
18 |
20 | 4.0.0
21 |
22 | com.lealone.examples.petstore
23 | petstore
24 | 1.0.0
25 | ../pom.xml
26 |
27 |
28 | petstore-test
29 | jar
30 | 1.0.0
31 |
32 |
33 |
34 | com.lealone.examples.petstore
35 | petstore-main
36 | ${project.version}
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/petstore/petstore-web/pom.xml:
--------------------------------------------------------------------------------
1 |
18 |
20 | 4.0.0
21 |
22 | com.lealone.examples.petstore
23 | petstore
24 | 1.0.0
25 | ../pom.xml
26 |
27 |
28 | petstore-web
29 | jar
30 | 1.0.0
31 |
32 |
33 |
34 | com.lealone.examples.petstore
35 | petstore-service
36 | ${project.version}
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/petstore/petstore-service/pom.xml:
--------------------------------------------------------------------------------
1 |
18 |
20 | 4.0.0
21 |
22 | com.lealone.examples.petstore
23 | petstore
24 | 1.0.0
25 | ../pom.xml
26 |
27 |
28 | petstore-service
29 | jar
30 | 1.0.0
31 |
32 |
33 |
34 | com.lealone.examples.petstore
35 | petstore-dal
36 | ${project.version}
37 |
38 |
39 |
40 |
--------------------------------------------------------------------------------
/fullstack-demo/web/fullStack.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |