├── 整洁架构.png ├── .gitignore ├── coder-po ├── bin │ ├── example-front-coder-all.sh │ ├── example-java-coder-all.sh │ ├── sparrow-java-coder.sh │ ├── sparrow-front-coder.sh │ └── ddl │ │ └── sparrow_example.sql ├── .gitignore ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── sparrowzoo │ └── coder │ └── po │ ├── ProjectConfig.java │ └── UserExample.java ├── coder-domain ├── src │ ├── main │ │ ├── java │ │ │ └── com │ │ │ │ └── sparrowzoo │ │ │ │ └── coder │ │ │ │ ├── domain │ │ │ │ ├── bo │ │ │ │ │ ├── validate │ │ │ │ │ │ ├── Cloneable.java │ │ │ │ │ │ ├── Validator.java │ │ │ │ │ │ ├── NoneValidator.java │ │ │ │ │ │ ├── RegexValidator.java │ │ │ │ │ │ ├── StringValidator.java │ │ │ │ │ │ └── DigitalValidator.java │ │ │ │ │ ├── CoderTriple.java │ │ │ │ │ ├── ProjectBO.java │ │ │ │ │ ├── ProjectArchsBO.java │ │ │ │ │ ├── UserExampleBO.java │ │ │ │ │ ├── ProjectConfigBO.java │ │ │ │ │ └── TableConfigBO.java │ │ │ │ ├── service │ │ │ │ │ ├── frontend │ │ │ │ │ │ ├── FrontendPlaceholderGenerator.java │ │ │ │ │ │ ├── FrontendGenerator.java │ │ │ │ │ │ ├── placeholder │ │ │ │ │ │ │ └── extension │ │ │ │ │ │ │ │ ├── dependency │ │ │ │ │ │ │ │ └── I18nExtension.java │ │ │ │ │ │ │ │ ├── TSClassPlaceholderExtension.java │ │ │ │ │ │ │ │ └── PathPlaceholderExtension.java │ │ │ │ │ │ ├── generator │ │ │ │ │ │ │ └── column │ │ │ │ │ │ │ │ ├── ColumnGenerator.java │ │ │ │ │ │ │ │ └── AbstractColumnGenerator.java │ │ │ │ │ │ ├── validate │ │ │ │ │ │ │ └── react │ │ │ │ │ │ │ │ ├── MobileValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── TelValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── ChineseCharactersValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── IdCardValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── StringValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── NullableValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── RegexValidatorMessageGenerator.java │ │ │ │ │ │ │ │ ├── DigitalValidatorMessageGenerator.java │ │ │ │ │ │ │ │ └── EmailValidatorMessageGenerator.java │ │ │ │ │ │ ├── architecture │ │ │ │ │ │ │ └── ReactArchitectureGenerator.java │ │ │ │ │ │ └── DefaultFrontendPlaceholder.java │ │ │ │ │ ├── PlaceholderExtension.java │ │ │ │ │ ├── TemplateEngineer.java │ │ │ │ │ ├── ValidatorMessageGenerator.java │ │ │ │ │ ├── backend │ │ │ │ │ │ ├── ClassPlaceholderGenerator.java │ │ │ │ │ │ ├── ClassGenerator.java │ │ │ │ │ │ ├── placeholder │ │ │ │ │ │ │ └── extension │ │ │ │ │ │ │ │ └── ProjectPlaceholderExtension.java │ │ │ │ │ │ └── architecture │ │ │ │ │ │ │ ├── MySqlArchitectureGenerator.java │ │ │ │ │ │ │ └── ClearArchitectureGenerator.java │ │ │ │ │ ├── EnvConfig.java │ │ │ │ │ ├── ArchitectureGenerator.java │ │ │ │ │ ├── CodeGenerator.java │ │ │ │ │ ├── AbstractArchitectureGenerator.java │ │ │ │ │ ├── AbstractPlaceholderExtension.java │ │ │ │ │ ├── registry │ │ │ │ │ │ ├── ColumnGeneratorRegistry.java │ │ │ │ │ │ ├── ArchitectureRegistry.java │ │ │ │ │ │ ├── TableConfigRegistry.java │ │ │ │ │ │ └── ValidatorRegistry.java │ │ │ │ │ └── template │ │ │ │ │ │ ├── DefaultTemplateEngineer.java │ │ │ │ │ │ └── TemplateEngineerProvider.java │ │ │ │ └── CoderDomainRegistry.java │ │ │ │ ├── constant │ │ │ │ ├── ArchitectureNames.java │ │ │ │ ├── DefaultSpecialColumnIndex.java │ │ │ │ ├── Config.java │ │ │ │ └── EnumNames.java │ │ │ │ ├── utils │ │ │ │ ├── JavaTsTypeConverter.java │ │ │ │ └── ConfigUtils.java │ │ │ │ ├── enums │ │ │ │ ├── DigitalCategory.java │ │ │ │ ├── CodeSource.java │ │ │ │ ├── ColumnType.java │ │ │ │ ├── FrontendKey.java │ │ │ │ ├── ArchitectureCategory.java │ │ │ │ ├── SearchType.java │ │ │ │ ├── ClassKey.java │ │ │ │ ├── CellType.java │ │ │ │ ├── HeaderType.java │ │ │ │ ├── ControlType.java │ │ │ │ └── JavaTypeController.java │ │ │ │ └── repository │ │ │ │ ├── TableConfigRepository.java │ │ │ │ ├── UserExampleRepository.java │ │ │ │ └── ProjectConfigRepository.java │ │ └── resources │ │ │ ├── clear │ │ │ ├── query.txt │ │ │ ├── bo.txt │ │ │ ├── dto.txt │ │ │ ├── param.txt │ │ │ ├── pagerQuery.txt │ │ │ ├── dao.txt │ │ │ ├── repository.txt │ │ │ ├── daoImpl.txt │ │ │ └── assemble.txt │ │ │ ├── react │ │ │ ├── columns.txt │ │ │ ├── schema.txt │ │ │ └── search.txt │ │ │ ├── Licensed.txt │ │ │ └── config.properties │ └── test │ │ ├── java │ │ └── com │ │ │ └── sparrowzoo │ │ │ └── coder │ │ │ ├── TestBootstrap.java │ │ │ ├── spel │ │ │ ├── SpringELTest.java │ │ │ └── CodeGenerator.java │ │ │ ├── ValidatorTest.java │ │ │ └── moke │ │ │ └── beans │ │ │ ├── EnvConfigImpl.java │ │ │ └── MockProjectConfigRepository.java │ │ └── resources │ │ └── application.properties ├── .gitignore └── pom.xml ├── coder-protocol ├── src │ └── main │ │ └── java │ │ └── com │ │ └── sparrowzoo │ │ └── coder │ │ └── protocol │ │ ├── param │ │ ├── LocalClassParam.java │ │ ├── SourceCodeParam.java │ │ ├── UserExampleParam.java │ │ ├── ProjectConfigParam.java │ │ └── TableConfigParam.java │ │ ├── query │ │ ├── ProjectTablesQuery.java │ │ ├── UserExampleQuery.java │ │ ├── TableConfigQuery.java │ │ └── ProjectConfigQuery.java │ │ ├── enums │ │ ├── CoderModule.java │ │ └── CoderError.java │ │ └── dto │ │ ├── UserExampleDTO.java │ │ ├── ProjectConfigDTO.java │ │ └── TableConfigDTO.java └── pom.xml ├── coder-spring-starter └── src │ ├── main │ ├── java │ │ └── com │ │ │ └── sparrowzoo │ │ │ └── coder │ │ │ └── boot │ │ │ └── config │ │ │ ├── EnableCoderApp.java │ │ │ ├── ControllerAdvice.java │ │ │ ├── CoderConfig.java │ │ │ ├── WebMvcAutoConfiguration.java │ │ │ ├── DefaultEnvConfig.java │ │ │ └── CoderKnife4jConfiguration.java │ └── resources │ │ └── rsa │ │ ├── public.pub │ │ └── private │ └── test │ └── java │ └── com │ └── sparrow │ └── spring │ ├── TestWithOutBoostrap.java │ ├── TestWithBoostrap.java │ └── labmda │ ├── LambdaMeta.java │ ├── ShadowLambdaMeta.java │ ├── Test.java │ └── StringPool.java ├── README.md ├── coder-main-spring-boot ├── src │ ├── main │ │ ├── resources │ │ │ └── rsa │ │ │ │ ├── public.pub │ │ │ │ └── private │ │ ├── configs │ │ │ ├── dev.properties │ │ │ └── prod.properties │ │ └── java │ │ │ └── com │ │ │ └── sparrowzoo │ │ │ └── coder │ │ │ └── boot │ │ │ └── Application.java │ └── test │ │ └── java │ │ └── com │ │ └── sparrow │ │ └── spring │ │ ├── TestWithOutBoostrap.java │ │ ├── TestWithBoostrap.java │ │ └── labmda │ │ ├── LambdaMeta.java │ │ ├── ShadowLambdaMeta.java │ │ ├── Test.java │ │ └── StringPool.java └── pom.xml ├── init.sh ├── bom └── .gitignore ├── coder-dao-api ├── pom.xml └── src │ └── main │ └── java │ └── com │ └── sparrowzoo │ └── coder │ └── dao │ ├── query │ ├── UserExampleDBPagerQuery.java │ ├── TableConfigDBPagerQuery.java │ └── ProjectConfigDBPagerQuery.java │ ├── TableConfigDAO.java │ ├── UserExampleDAO.java │ └── ProjectConfigDAO.java ├── pom.xml ├── coder-infrastructure └── pom.xml ├── coder-dao-mybatis ├── pom.xml └── src │ └── main │ └── resources │ └── mybatis-config.xml ├── coder-dao-sparrow └── pom.xml ├── ddl ├── t_user_example.sql ├── user_example.sql ├── t_project_config.sql └── t_table_config.sql └── coder-adapter └── pom.xml /整洁架构.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sparrowzoo/sparrow-coder/HEAD/整洁架构.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | target 3 | .idea 4 | lib 5 | classes 6 | logs 7 | *.jar 8 | -------------------------------------------------------------------------------- /coder-po/bin/example-front-coder-all.sh: -------------------------------------------------------------------------------- 1 | config_path=$(pwd)/config.properties 2 | echo $config_path 3 | sh ./sparrow-front-coder.sh -all com.sparrow.coding.config.ExampleFront -config=$config_path 4 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/Cloneable.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | public interface Cloneable { 4 | T create(); 5 | } 6 | -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/TestBootstrap.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder; 2 | 3 | import com.sparrow.spring.starter.test.TestWithoutBootstrap; 4 | 5 | @TestWithoutBootstrap(scanBasePackages = "com.sparrowzoo.*") 6 | public class TestBootstrap { 7 | 8 | } 9 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/param/LocalClassParam.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.protocol.param; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class LocalClassParam { 7 | private Long projectId; 8 | private String fullClassName; 9 | } 10 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/query/ProjectTablesQuery.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.protocol.query; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class ProjectTablesQuery { 7 | private Long projectId; 8 | private String[] tableNames; 9 | } 10 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/query.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_query; 3 | 4 | import com.sparrow.protocol.pager.SimplePager; 5 | import java.util.Date; 6 | import lombok.Data; 7 | @Data 8 | public class $persistence_class_nameQuery extends SimplePager { 9 | $search_fields 10 | } 11 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/FrontendPlaceholderGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend; 2 | 3 | import com.sparrowzoo.coder.enums.FrontendKey; 4 | 5 | public interface FrontendPlaceholderGenerator { 6 | String getPath(FrontendKey key); 7 | } 8 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/bo.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_bo; 3 | 4 | import com.sparrow.protocol.enums.StatusRecord; 5 | import com.sparrow.protocol.*; 6 | import java.time.*; 7 | import lombok.Data; 8 | @Data 9 | public class $persistence_class_nameBO implements BO 10 | $get_sets 11 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/constant/ArchitectureNames.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.constant; 2 | 3 | public class ArchitectureNames { 4 | public static final String CLEAR = "clear"; 5 | public static final String MYSQL = "mysql"; 6 | public static final String REACT = "react"; 7 | } 8 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/constant/DefaultSpecialColumnIndex.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.constant; 2 | 3 | public class DefaultSpecialColumnIndex { 4 | public static final int CHECK = 0; 5 | public static final int COLUMN_FILTER = 999; 6 | public static final int ROW_MENU = 998; 7 | } 8 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/dto.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_dto; 3 | import lombok.Data; 4 | import com.sparrow.protocol.enums.StatusRecord; 5 | import com.sparrow.protocol.*; 6 | import java.time.*; 7 | 8 | @Data 9 | public class $persistence_class_nameDTO implements DTO 10 | $get_sets_dto 11 | 12 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/react/columns.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | import {ColumnDef, filterFns} from "@tanstack/react-table"; 3 | import * as React from "react"; 4 | import {BasicData, ColumnOperationProps} from "@/common/lib/table/DataTableProperty"; 5 | $frontend_column_import 6 | 7 | $frontend_class 8 | $frontend_column_defs 9 | -------------------------------------------------------------------------------- /coder-po/bin/example-java-coder-all.sh: -------------------------------------------------------------------------------- 1 | config_path=$(pwd)/config.properties 2 | echo $config_path 3 | 4 | if pwd | grep -q -E 'bin$'; then 5 | echo "true" 6 | else 7 | echo "请cd到bin目录下运行" 8 | exit 1 9 | fi 10 | 11 | 12 | sh ./sparrow-java-coder.sh -ct com.sparrow.example.po.TableDef -config=$config_path 13 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/param/SourceCodeParam.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.protocol.param; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class SourceCodeParam { 7 | private Long projectId; 8 | private String fullClassName; 9 | private String sourceCode; 10 | } 11 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/param.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_param; 3 | 4 | import com.sparrow.protocol.Param; 5 | import com.sparrow.protocol.enums.StatusRecord; 6 | import lombok.Data; 7 | import java.time.*; 8 | 9 | 10 | 11 | @Data 12 | public class $persistence_class_nameParam implements Param { 13 | $get_sets_params 14 | } 15 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/PlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrowzoo.coder.domain.bo.TableContext; 4 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 5 | 6 | public interface PlaceholderExtension { 7 | void extend(TableContext tableContext, TableConfigRegistry registry); 8 | } 9 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/TemplateEngineer.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrowzoo.coder.domain.bo.TableContext; 4 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 5 | 6 | public interface TemplateEngineer { 7 | String generate(String template, TableContext context, TableConfigRegistry registry); 8 | } 9 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/EnableCoderApp.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.boot.config; 2 | 3 | import org.springframework.context.annotation.Import; 4 | 5 | import java.lang.annotation.*; 6 | 7 | @Retention(RetentionPolicy.RUNTIME) 8 | @Target({ElementType.TYPE}) 9 | @Documented 10 | @Import(CoderConfig.class) 11 | public @interface EnableCoderApp { 12 | } 13 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/ValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrowzoo.coder.domain.bo.validate.Validator; 4 | 5 | public interface ValidatorMessageGenerator { 6 | String generateConfig(String propertyName, 7 | T validator); 8 | 9 | T defaultValidator(); 10 | } 11 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/backend/ClassPlaceholderGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.backend; 2 | 3 | import com.sparrowzoo.coder.enums.ClassKey; 4 | 5 | public interface ClassPlaceholderGenerator { 6 | String getModule(ClassKey classKey); 7 | 8 | String getPackage(ClassKey classKey); 9 | 10 | String getClassName(ClassKey classKey); 11 | } 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sparrow-coder 2 | 代码生成器示例脚手架 3 | 4 | git clone https://github.com/sparrowzoo/sparrow-shell.git 5 | git clone https://github.com/sparrowzoo/sparrow-bom.git 6 | git clone https://github.com/sparrow-os/sparrow-starter.git 7 | 8 | cd sparrow-bom 9 | mvn clean install 10 | cd ../sparrow-shell 11 | mvn clean install -Dmaven.test.skip 12 | cd ../sparrow-starter 13 | mvn clean install -Dmaven.test.skip 14 | 15 | remove 16 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/react/schema.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | import * as v from "valibot"; 3 | function createSchema(translate:(key:string)=>string) { 4 | const InnerFormSchema = v.object({ 5 | $frontend_schema 6 | }); 7 | //扩展提示 8 | const FormSchema = InnerFormSchema; 9 | //type FormData = v.InferOutput; 10 | return FormSchema 11 | } 12 | export default createSchema; 13 | 14 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/ControllerAdvice.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.boot.config; 2 | 3 | import com.sparrow.spring.starter.advice.ControllerResponseAdvice; 4 | import org.springframework.web.bind.annotation.RestControllerAdvice; 5 | 6 | @RestControllerAdvice(basePackages = {"com.sparrowzoo.coder.adapter.controller"}) 7 | public class ControllerAdvice extends ControllerResponseAdvice { 8 | } -------------------------------------------------------------------------------- /coder-main-spring-boot/src/main/resources/rsa/public.pub: -------------------------------------------------------------------------------- 1 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmHhBdf2hAjD536Xn8K+r1UhU+xX5JyPWlC6t68daamogtR85RxywSTKrp8M0xgIzqJ7fSRl/3O6cDtG1QAJOB9UDxHw6nvpcW92yDUMRBuzKiOA2KUPXye/+AXiKZejt/ZUtSVhe5W/4RqXHYhXrUs75KfoXJ0BC05mf2rwP6KF1k5SJb0Cn685g3gvW9u44MXzxpnGiGAQ0XXyk9BPVMP9amn3y08K8kPRhmxZ6Qvi+lGV1mJROt+tg7dB5ZEYNs5gW4UMXXlMWZkDJmBPZnOwr6Y5eeqpqNDKcEgrXoSPr7eVGvYkFIJwtwvbgikZj0qze+2JASEUOR09XRrPOzwIDAQAB 2 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/resources/rsa/public.pub: -------------------------------------------------------------------------------- 1 | MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmHhBdf2hAjD536Xn8K+r1UhU+xX5JyPWlC6t68daamogtR85RxywSTKrp8M0xgIzqJ7fSRl/3O6cDtG1QAJOB9UDxHw6nvpcW92yDUMRBuzKiOA2KUPXye/+AXiKZejt/ZUtSVhe5W/4RqXHYhXrUs75KfoXJ0BC05mf2rwP6KF1k5SJb0Cn685g3gvW9u44MXzxpnGiGAQ0XXyk9BPVMP9amn3y08K8kPRhmxZ6Qvi+lGV1mJROt+tg7dB5ZEYNs5gW4UMXXlMWZkDJmBPZnOwr6Y5eeqpqNDKcEgrXoSPr7eVGvYkFIJwtwvbgikZj0qze+2JASEUOR09XRrPOzwIDAQAB 2 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/pagerQuery.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_pager_query; 3 | 4 | import com.sparrow.protocol.enums.StatusRecord; 5 | import com.sparrow.protocol.dao.DatabasePagerQuery; 6 | import java.util.Date; 7 | import lombok.Data; 8 | @Data 9 | 10 | public class $persistence_class_nameDBPagerQuery extends DatabasePagerQuery { 11 | $search_fields 12 | public $persistence_class_nameDBPagerQuery() {} 13 | } 14 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/EnvConfig.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | public interface EnvConfig { 4 | public String getWorkspace(); 5 | 6 | public String getProjectRoot(); 7 | 8 | public String getFrontendProjectRoot(); 9 | 10 | public Boolean getMultiUser(); 11 | 12 | public String getHome(Long userId); 13 | 14 | public Boolean overwrite(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/utils/JavaTsTypeConverter.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.utils; 2 | 3 | public class JavaTsTypeConverter { 4 | public static String toTsType(Class clazz) { 5 | if (Number.class.isAssignableFrom(clazz)) { 6 | return "number"; 7 | } 8 | if (Boolean.class.isAssignableFrom(clazz)) { 9 | return "boolean"; 10 | } 11 | return "string"; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/constant/Config.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.constant; 2 | 3 | public class Config { 4 | 5 | /** 6 | * maven module 的配置前缀 7 | */ 8 | public static String MODULE_PREFIX = "module."; 9 | /** 10 | * java package 的配置前缀 11 | */ 12 | public static String PACKAGE_PREFIX = "package."; 13 | /** 14 | * java 类文件的生成前缀 15 | */ 16 | public static String CLASS_PREFIX = "class."; 17 | } 18 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/Validator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | import java.util.Map; 4 | 5 | public interface Validator{ 6 | void setI18n(Boolean i18n); 7 | Boolean getI18n(); 8 | 9 | Boolean getAllowEmpty(); 10 | 11 | String getEmptyMessage(); 12 | 13 | //国际化message.tsx 文件内容 14 | Map getI18nConfig(); 15 | 16 | void setI18nConfig(Map i18nConfig); 17 | } 18 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/enums/CoderModule.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.protocol.enums; 2 | 3 | import com.sparrow.protocol.ModuleSupport; 4 | 5 | public class CoderModule { 6 | public static final ModuleSupport Coder = new ModuleSupport() { 7 | @Override 8 | public String code() { 9 | return "99"; 10 | } 11 | 12 | @Override 13 | public String name() { 14 | return "Coder"; 15 | } 16 | }; 17 | } 18 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/ArchitectureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 4 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 5 | 6 | import java.io.IOException; 7 | 8 | public interface ArchitectureGenerator { 9 | void generate(TableConfigRegistry registry, String tableName) throws IOException; 10 | 11 | ArchitectureCategory getCategory(); 12 | 13 | String getName(); 14 | } 15 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/CodeGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrow.protocol.BusinessException; 4 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 5 | 6 | import java.io.IOException; 7 | 8 | public interface CodeGenerator { 9 | void generate(String tableName) throws IOException, BusinessException; 10 | 11 | void initScaffold(); 12 | 13 | void clear(); 14 | 15 | TableConfigRegistry getRegistry(); 16 | 17 | } 18 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/FrontendGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend; 2 | 3 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 4 | import com.sparrowzoo.coder.enums.FrontendKey; 5 | 6 | import java.io.IOException; 7 | 8 | public interface FrontendGenerator { 9 | String getTargetPhysicalPath(FrontendKey key); 10 | String readTemplateContent(FrontendKey frontendKey); 11 | void generate(FrontendKey key, TableConfigRegistry registry) throws IOException; 12 | } 13 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/backend/ClassGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.backend; 2 | 3 | 4 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 5 | import com.sparrowzoo.coder.enums.ClassKey; 6 | 7 | import java.io.IOException; 8 | 9 | public interface ClassGenerator { 10 | String getClassPhysicalPath(ClassKey classKey); 11 | 12 | String readTemplateContent(ClassKey classKey); 13 | 14 | void generate(ClassKey classKey, TableConfigRegistry registry) throws IOException; 15 | } 16 | -------------------------------------------------------------------------------- /init.sh: -------------------------------------------------------------------------------- 1 | rm -rf/coder-adapter/src 2 | rm -rf/coder-dao-api/src 3 | rm -rf/coder-dao-sparrow/src 4 | rm -rf/coder-domain/src 5 | rm -rf/coder-infrastructure/src 6 | rm -rf/coder-protocol/src 7 | 8 | rm -rf/coder-adapter/target 9 | rm -rf/coder-dao-api/target 10 | rm -rf/coder-dao-sparrow/target 11 | rm -rf/coder-dao-mybatis/target 12 | rm -rf/coder-dao-mybatis/src/main/resources/mapper/Sparrow* 13 | 14 | 15 | rm -rf/coder-domain/target 16 | rm -rf/coder-infrastructure/target 17 | rm -rf/coder-protocol/target 18 | rm -rf/coder-main-spring-boot/src/main/resources 19 | rm -rf */*.iml 20 | rm -rf */bin 21 | rm -rf */target 22 | rm -rf */*/target -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/dao.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_dao; 3 | 4 | import com.sparrow.protocol.dao.DaoSupport; 5 | import $package_po.$persistence_class_name; 6 | import $package_pager_query.$persistence_class_nameDBPagerQuery; 7 | import java.util.List; 8 | 9 | public interface $persistence_class_nameDAO extends DaoSupport<$persistence_class_name, Long> { 10 | List<$persistence_class_name> query$persistence_class_names($persistence_class_nameDBPagerQuery $persistence_object_namePagerQuery); 11 | 12 | Long count$persistence_class_name($persistence_class_nameDBPagerQuery $persistence_object_namePagerQuery); 13 | } 14 | -------------------------------------------------------------------------------- /bom/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /coder-po/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /coder-domain/.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | !.mvn/wrapper/maven-wrapper.jar 3 | !**/src/main/**/target/ 4 | !**/src/test/**/target/ 5 | 6 | ### IntelliJ IDEA ### 7 | .idea/modules.xml 8 | .idea/jarRepositories.xml 9 | .idea/compiler.xml 10 | .idea/libraries/ 11 | *.iws 12 | *.iml 13 | *.ipr 14 | 15 | ### Eclipse ### 16 | .apt_generated 17 | .classpath 18 | .factorypath 19 | .project 20 | .settings 21 | .springBeans 22 | .sts4-cache 23 | 24 | ### NetBeans ### 25 | /nbproject/private/ 26 | /nbbuild/ 27 | /dist/ 28 | /nbdist/ 29 | /.nb-gradle/ 30 | build/ 31 | !**/src/main/**/build/ 32 | !**/src/test/**/build/ 33 | 34 | ### VS Code ### 35 | .vscode/ 36 | 37 | ### Mac OS ### 38 | .DS_Store -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/TestWithOutBoostrap.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring; 2 | 3 | import com.sparrow.spring.starter.config.SparrowConfig; 4 | import com.sparrow.spring.starter.test.TestWithoutBootstrap; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | @TestWithoutBootstrap(scanBasePackages = "com.sparrow.*") 9 | public class TestWithOutBoostrap { 10 | 11 | @Autowired 12 | private SparrowConfig sparrowConfig; 13 | 14 | @Test 15 | public void testSpring() { 16 | System.out.println(sparrowConfig.toString()); 17 | System.out.println("hello sparrows"); 18 | } 19 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/constant/EnumNames.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.constant; 2 | 3 | public class EnumNames { 4 | public static final String CELL_TYPE = "cellType"; 5 | 6 | public static final String COLUMN_TYPE = "columnType"; 7 | 8 | public static final String CONTROL_TYPE = "controlType"; 9 | 10 | public static final String HEADER_TYPE = "headerType"; 11 | 12 | public static final String DATASOURCE_TYPE = "datasourceType"; 13 | 14 | public static final String SEARCH_TYPE = "searchType"; 15 | 16 | public static final String STATUS_RECORD = "status"; 17 | 18 | public static final String CODE_SOURCE="source"; 19 | 20 | } 21 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/TestWithOutBoostrap.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring; 2 | 3 | import com.sparrow.spring.starter.config.SparrowConfig; 4 | import com.sparrow.spring.starter.test.TestWithoutBootstrap; 5 | import org.junit.jupiter.api.Test; 6 | import org.springframework.beans.factory.annotation.Autowired; 7 | 8 | @TestWithoutBootstrap(scanBasePackages = "com.sparrow.*") 9 | public class TestWithOutBoostrap { 10 | 11 | @Autowired 12 | private SparrowConfig sparrowConfig; 13 | 14 | @Test 15 | public void testSpring() { 16 | System.out.println(sparrowConfig.toString()); 17 | System.out.println("hello sparrows"); 18 | } 19 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/CoderDomainRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain; 2 | 3 | import com.sparrowzoo.coder.repository.ProjectConfigRepository; 4 | import com.sparrowzoo.coder.repository.TableConfigRepository; 5 | import lombok.Getter; 6 | import lombok.extern.slf4j.Slf4j; 7 | 8 | import javax.inject.Inject; 9 | import javax.inject.Named; 10 | 11 | @Named 12 | @Getter 13 | @Slf4j 14 | public class CoderDomainRegistry { 15 | public CoderDomainRegistry() { 16 | log.info("CoderDomainRegistry init"); 17 | } 18 | 19 | @Inject 20 | private TableConfigRepository tableConfigRepository; 21 | 22 | @Inject 23 | private ProjectConfigRepository projectConfigRepository; 24 | } 25 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/CoderConfig.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.boot.config; 2 | 3 | 4 | import com.sparrow.authenticator.session.dao.EmptySessionDao; 5 | import lombok.extern.slf4j.Slf4j; 6 | import org.springframework.context.annotation.Bean; 7 | import org.springframework.context.annotation.ComponentScan; 8 | import org.springframework.context.annotation.Configuration; 9 | 10 | @Configuration 11 | @ComponentScan("com.sparrowzoo.coder") 12 | @Slf4j 13 | public class CoderConfig { 14 | public CoderConfig() { 15 | log.info("CoderConfig init"); 16 | } 17 | 18 | @Bean 19 | public EmptySessionDao sessionDao() { 20 | return new EmptySessionDao(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /coder-po/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | coder-po 13 | 1.0.0-SNAPSHOT 14 | 15 | 16 | com.sparrowzoo 17 | sparrow-protocol-dao 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /coder-dao-api/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | coder-dao-api 13 | 1.0.0-SNAPSHOT 14 | 15 | 16 | com.sparrowzoo.coder 17 | coder-po 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /coder-protocol/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 12 | 4.0.0 13 | 1.0.0-SNAPSHOT 14 | coder-protocol 15 | 16 | 17 | com.sparrowzoo 18 | sparrow-protocol 19 | 20 | 21 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/DigitalCategory.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum DigitalCategory implements EnumIdentityAccessor { 8 | INTEGER("/^\\d+$/", "parseInt(input,10)", 1), 9 | SIGNED_INTEGER("/^-?\\d+$/", "parseInt(input,10)", 2), 10 | FLOAT("/^-?\\d+\\.\\d+$/", "parseFloat(input)", 3); 11 | private final String regex; 12 | private final String converter; 13 | private final Integer id; 14 | 15 | DigitalCategory(String regex, String converter, Integer id) { 16 | this.regex = regex; 17 | this.converter = converter; 18 | this.id = id; 19 | } 20 | 21 | @Override 22 | public Integer getIdentity() { 23 | return this.id; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/Licensed.txt: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | */ -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/placeholder/extension/dependency/I18nExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.placeholder.extension.dependency; 2 | 3 | import com.sparrow.core.spi.JsonFactory; 4 | import com.sparrowzoo.coder.domain.bo.TableContext; 5 | import com.sparrowzoo.coder.domain.service.AbstractPlaceholderExtension; 6 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 7 | import com.sparrowzoo.coder.enums.PlaceholderKey; 8 | 9 | import javax.inject.Named; 10 | 11 | @Named 12 | public class I18nExtension extends AbstractPlaceholderExtension { 13 | @Override 14 | public void extend(TableContext tableContext, TableConfigRegistry registry) { 15 | tableContext.getPlaceHolder().put(PlaceholderKey.$frontend_i18n_message.name(), JsonFactory.getProvider().toString(tableContext.getI18nMap())); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/generator/column/ColumnGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.generator.column; 2 | 3 | import com.sparrowzoo.coder.domain.bo.ColumnDef; 4 | import com.sparrowzoo.coder.domain.bo.ProjectBO; 5 | import com.sparrowzoo.coder.enums.CellType; 6 | import com.sparrowzoo.coder.enums.HeaderType; 7 | 8 | import java.util.List; 9 | 10 | public interface ColumnGenerator { 11 | String column(ColumnDef columnDef,ProjectBO project); 12 | 13 | String importEdit(ColumnDef columnDef,ProjectBO project); 14 | 15 | String edit(ColumnDef columnDef,ProjectBO project,Boolean add); 16 | 17 | String importHeader(HeaderType headerType,ProjectBO project); 18 | 19 | String importCell(CellType cellType,ProjectBO project); 20 | 21 | String getName(); 22 | 23 | String columnDefs(String className, List columns); 24 | } 25 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/utils/ConfigUtils.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.utils; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import lombok.extern.slf4j.Slf4j; 5 | 6 | import java.io.IOException; 7 | import java.io.InputStream; 8 | import java.io.StringReader; 9 | import java.util.Properties; 10 | 11 | @Slf4j 12 | public class ConfigUtils { 13 | public static Properties initPropertyConfig(String configContent) throws IOException { 14 | Properties config = new Properties(); 15 | if (!StringUtility.isNullOrEmpty(configContent)) { 16 | log.info("load config from file: " + configContent); 17 | config.load(new StringReader(configContent)); 18 | return config; 19 | } 20 | InputStream configStream = ConfigUtils.class.getResourceAsStream("/config.properties"); 21 | config.load(configStream); 22 | return config; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/CodeSource.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | 7 | @EnumUniqueName(name = EnumNames.CODE_SOURCE) 8 | public enum CodeSource implements EnumIdentityAccessor { 9 | INNER(1), 10 | SOURCE_CODE(2); 11 | 12 | private final int identity; 13 | 14 | private CodeSource(Integer identity) { 15 | this.identity = identity; 16 | } 17 | 18 | public Integer getIdentity() { 19 | return identity; 20 | } 21 | 22 | public static CodeSource getEnum(Integer identity) { 23 | for (CodeSource codeSource : CodeSource.values()) { 24 | if (codeSource.getIdentity().equals(identity)) { 25 | return codeSource; 26 | } 27 | } 28 | return null; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /coder-po/bin/sparrow-java-coder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | source /etc/profile 3 | 4 | [ -z "$SPARROW_CODER_HOME" ] && echo "please config environment variable SPARROW_CODER_HOME" && exit 0 5 | sparrow_coder_name=sparrow-coder-all.jar 6 | class_path=$(cd ../target/classes;pwd) 7 | if [ $1 == '--help' ]; then 8 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.JavaMain --help 9 | fi 10 | 11 | if [ $1 == '--example' ]; then 12 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.JavaMain --example 13 | fi 14 | 15 | options=$1 16 | if [ $1 == '-all' ]; then 17 | options='-b,-p,-q,-v,-cv,-pq,-cq,-bop,-d,-di,-mi,-r,-ri,-s,-c,-a,-ct' 18 | fi 19 | #将,替换为空格 20 | options_array=(${options//,/ }) 21 | for option in ${options_array[@]} 22 | do 23 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.JavaMain $option $2 $3 24 | done 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/AbstractArchitectureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrow.container.Container; 4 | import com.sparrow.container.ContainerAware; 5 | import com.sparrowzoo.coder.domain.service.registry.ArchitectureRegistry; 6 | import lombok.extern.slf4j.Slf4j; 7 | import org.springframework.beans.factory.InitializingBean; 8 | 9 | @Slf4j 10 | public abstract class AbstractArchitectureGenerator implements ArchitectureGenerator, InitializingBean, ContainerAware { 11 | protected ArchitectureRegistry architectureRegistry = ArchitectureRegistry.getInstance(); 12 | 13 | @Override 14 | public void afterPropertiesSet() { 15 | this.architectureRegistry.register(this.getName(), this); 16 | } 17 | 18 | @Override 19 | public void aware(Container container, String s) { 20 | this.architectureRegistry.register(this.getName(), this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | sparrow-coder 6 | com.sparrowzoo.coder 7 | 1.0.0-SNAPSHOT 8 | pom 9 | 4.0.0 10 | 11 | coder-adapter 12 | coder-dao-api 13 | coder-domain 14 | coder-infrastructure 15 | coder-main-spring-boot 16 | coder-protocol 17 | coder-dao-sparrow 18 | coder-dao-mybatis 19 | coder-po 20 | coder-spring-starter 21 | 22 | 23 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/generator/column/AbstractColumnGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.generator.column; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.service.registry.ColumnGeneratorRegistry; 5 | import org.springframework.beans.factory.InitializingBean; 6 | 7 | import javax.inject.Inject; 8 | 9 | 10 | public abstract class AbstractColumnGenerator implements ColumnGenerator, InitializingBean { 11 | private final ColumnGeneratorRegistry columnGeneratorRegistry = ColumnGeneratorRegistry.getInstance(); 12 | 13 | protected String generate(String id, String defaultId, String format) { 14 | String componentId = StringUtility.isNullOrEmpty(id) ? defaultId : id; 15 | return String.format(format, componentId); 16 | } 17 | 18 | @Override 19 | public void afterPropertiesSet() { 20 | this.columnGeneratorRegistry.pubObject(this.getName(), this); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /coder-infrastructure/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | 1.0.0-SNAPSHOT 13 | coder-infrastructure 14 | 15 | 16 | com.sparrowzoo.coder 17 | coder-dao-api 18 | 19 | 20 | com.sparrowzoo.coder 21 | coder-domain 22 | 23 | 24 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/NoneValidator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | import java.util.Collections; 7 | import java.util.Map; 8 | 9 | @Data 10 | @AllArgsConstructor 11 | public class NoneValidator implements Validator { 12 | 13 | private String clazz; 14 | 15 | @Override 16 | public void setI18n(Boolean i18n) { 17 | 18 | } 19 | 20 | @Override 21 | public Boolean getI18n() { 22 | return null; 23 | } 24 | 25 | @Override 26 | public Boolean getAllowEmpty() { 27 | return true; 28 | } 29 | 30 | @Override 31 | public String getEmptyMessage() { 32 | return ""; 33 | } 34 | 35 | @Override 36 | public Map getI18nConfig() { 37 | return Collections.emptyMap(); 38 | } 39 | 40 | @Override 41 | public void setI18nConfig(Map i18nConfig) { 42 | 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/repository.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_repository; 3 | import $package_bo.$persistence_class_nameBO; 4 | import $package_param.$persistence_class_nameParam; 5 | import $package_query.$persistence_class_nameQuery; 6 | import java.util.List; 7 | import java.util.Set; 8 | 9 | 10 | 11 | 12 | public interface $persistence_class_nameRepository { 13 | Long save($persistence_class_nameParam $persistence_object_nameParam); 14 | 15 | Integer delete(Set $persistence_object_nameIds); 16 | 17 | Integer disable(Set $persistence_object_nameIds); 18 | 19 | Integer enable(Set $persistence_object_nameIds); 20 | 21 | $persistence_class_nameBO get$persistence_class_name(Long $persistence_object_nameId); 22 | 23 | List<$persistence_class_nameBO> query$persistence_class_names($persistence_class_nameQuery $persistence_object_nameQuery); 24 | 25 | Long get$persistence_class_nameCount($persistence_class_nameQuery $persistence_object_nameQuery); 26 | 27 | } 28 | -------------------------------------------------------------------------------- /coder-dao-mybatis/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | 13 | 1.0.0-SNAPSHOT 14 | coder-dao-mybatis 15 | 16 | 17 | 18 | com.sparrowzoo.coder 19 | coder-dao-api 20 | 21 | 22 | org.mybatis.spring.boot 23 | mybatis-spring-boot-starter 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/CoderTriple.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo; 2 | 3 | import lombok.Data; 4 | import lombok.Getter; 5 | 6 | import java.util.LinkedHashSet; 7 | import java.util.Set; 8 | 9 | @Getter 10 | public class CoderTriple { 11 | private final Set imports=new LinkedHashSet<>(); 12 | private final Set injects=new LinkedHashSet<>(); 13 | private final Set codes=new LinkedHashSet<>(); 14 | 15 | public void addImport(String importPackage) { 16 | this.imports.add(importPackage); 17 | } 18 | 19 | public void inject(String inject) { 20 | this.injects.add(inject); 21 | } 22 | 23 | public void code(String code) { 24 | this.codes.add(code); 25 | } 26 | public String joinCode(){ 27 | return String.join("\n",this.codes); 28 | } 29 | public String joinInjects(){ 30 | return String.join("\n",this.injects); 31 | } 32 | public String joinImports(){ 33 | return String.join("\n",this.imports); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /coder-po/bin/sparrow-front-coder.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | source /etc/profile 3 | 4 | [ -z "$SPARROW_CODER_HOME" ] && echo "please config environment variable SPARROW_CODER_HOME" && exit 0 5 | sparrow_coder_name=sparrow-coder-all.jar 6 | class_path=$(cd ../target/classes;pwd) 7 | if [ $1 == '--help' ]; then 8 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.FrontMain --help 9 | exit 10 | fi 11 | 12 | if [ $1 == '--example' ]; then 13 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.FrontMain --example 14 | exit 15 | fi 16 | 17 | options=$1 18 | if [ $1 == '-all' ]; then 19 | options='-mp,-cp,-cj,-lj,-mj' 20 | fi 21 | #将,替换为空格 22 | options_array=(${options//,/ }) 23 | for option in ${options_array[@]} 24 | do 25 | echo java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.FrontMain $option $2 26 | 27 | java -classpath $SPARROW_CODER_HOME/$sparrow_coder_name:$class_path com.sparrow.coding.FrontMain $option $2 28 | done 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/MobileValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class MobileValidatorMessageGenerator extends RegexValidatorMessageGenerator { 10 | @Override 11 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 12 | validator.setRegex("/^1\\d{10}$/"); 13 | if(StringUtility.isNullOrEmpty(validator.getFormatMessage())){ 14 | validator.setFormatMessage("请输入正确的手机号码"); 15 | } 16 | return super.outerGenerateMessage(propertyName, validator); 17 | } 18 | 19 | @Override 20 | public RegexValidator defaultValidator() { 21 | RegexValidator validator=RegexValidator.REGEX_VALIDATOR.create(); 22 | validator.setFormatMessage("请输入正确的手机号码"); 23 | return validator; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/TelValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class TelValidatorMessageGenerator extends RegexValidatorMessageGenerator { 10 | 11 | @Override 12 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 13 | if(StringUtility.isNullOrEmpty(validator.getFormatMessage())){ 14 | validator.setFormatMessage(this.defaultValidator.getFormatMessage()); 15 | } 16 | validator.setRegex("/^(\\d{4}-|\\d{3}-)?(\\d{8}|\\d{7})$/"); 17 | return super.outerGenerateMessage(propertyName, validator); 18 | } 19 | 20 | @Override 21 | public RegexValidator defaultValidator() { 22 | RegexValidator validator=RegexValidator.REGEX_VALIDATOR.create(); 23 | validator.setFormatMessage("请输入正确的电话号码"); 24 | return validator; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/ColumnType.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | @EnumUniqueName(name = EnumNames.COLUMN_TYPE) 10 | public enum ColumnType implements EnumIdentityAccessor { 11 | NORMAL(1, "标准"), 12 | ACTION(2, "菜单"), 13 | CHECK(3, "选择"), 14 | FILTER(4, "过滤列"), 15 | TREE(5, "树型") 16 | ; 17 | 18 | private String description; 19 | 20 | private Integer id; 21 | 22 | ColumnType(Integer id, String description) { 23 | this.id = id; 24 | this.description = description; 25 | } 26 | 27 | @Override 28 | public Integer getIdentity() { 29 | return this.id; 30 | } 31 | 32 | public static ColumnType getById(Integer id) { 33 | for (ColumnType type : ColumnType.values()) { 34 | if (type.getId().equals(id)) { 35 | return type; 36 | } 37 | } 38 | return null; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/ChineseCharactersValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class ChineseCharactersValidatorMessageGenerator extends RegexValidatorMessageGenerator { 10 | 11 | @Override 12 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 13 | validator.setRegex("/^[\\u4e00-\\u9fa5]+$/"); 14 | if(StringUtility.isNullOrEmpty(validator.getFormatMessage())){ 15 | validator.setFormatMessage(this.defaultValidator.getFormatMessage()); 16 | } 17 | return super.outerGenerateMessage(propertyName, validator); 18 | } 19 | 20 | @Override 21 | public RegexValidator defaultValidator() { 22 | RegexValidator validator=RegexValidator.REGEX_VALIDATOR.create(); 23 | validator.setFormatMessage("请输入中文字符"); 24 | return validator; 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/IdCardValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class IdCardValidatorMessageGenerator extends RegexValidatorMessageGenerator { 10 | 11 | //https://www.66zan.cn/regexdso/ 12 | @Override 13 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 14 | validator.setRegex("/^(\\d{15}|\\d{17}[\\dXx])$/"); 15 | if(StringUtility.isNullOrEmpty(validator.getFormatMessage())){ 16 | validator.setFormatMessage("请输入正确的身份证号码"); 17 | } 18 | return super.outerGenerateMessage(propertyName, validator); 19 | } 20 | 21 | @Override 22 | public RegexValidator defaultValidator() { 23 | RegexValidator validator=RegexValidator.REGEX_VALIDATOR.create(); 24 | validator.setFormatMessage("请输入正确的身份证号码"); 25 | return validator; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coder-dao-sparrow/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | 13 | 1.0.0-SNAPSHOT 14 | coder-dao-sparrow 15 | 16 | 17 | com.sparrowzoo 18 | sparrow-orm 19 | 20 | 21 | com.sparrowzoo 22 | sparrow-loader 23 | 24 | 25 | com.sparrowzoo.coder 26 | coder-dao-api 27 | 28 | 29 | -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/spel/SpringELTest.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.spel; 2 | 3 | import org.springframework.expression.EvaluationContext; 4 | import org.springframework.expression.Expression; 5 | import org.springframework.expression.ExpressionParser; 6 | import org.springframework.expression.ParserContext; 7 | import org.springframework.expression.common.TemplateParserContext; 8 | import org.springframework.expression.spel.standard.SpelExpressionParser; 9 | import org.springframework.expression.spel.support.StandardEvaluationContext; 10 | 11 | public class SpringELTest { 12 | public static void main(String[] args) { 13 | ExpressionParser parser = new SpelExpressionParser(); 14 | StandardEvaluationContext context = new StandardEvaluationContext(); 15 | context.setVariable("name", "Alice"); 16 | context.setVariable("age", 25); 17 | 18 | 19 | System.out.println(parser.parseExpression("'hello:' + #name").getValue(context)); 20 | String falseString = parser.parseExpression( 21 | "(#age > 20) ? #name :'Unknown'").getValue(String.class); 22 | System.out.println(falseString); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/enums/CoderError.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.protocol.enums; 2 | 3 | import com.sparrow.protocol.ErrorSupport; 4 | import com.sparrow.protocol.ModuleSupport; 5 | import lombok.Getter; 6 | 7 | @Getter 8 | public enum CoderError implements ErrorSupport { 9 | NOT_SELF_PROJECT(false, CoderModule.Coder, "03", "can't generate other's project"), 10 | SYSTEM_TABLE(false, CoderModule.Coder, "02", "system table can't be modified"), 11 | CLASS_NOT_FOUND(false, CoderModule.Coder, "01", "class not found"); 12 | 13 | private boolean system; 14 | private ModuleSupport module; 15 | private String code; 16 | private String message; 17 | 18 | CoderError(boolean system, ModuleSupport module, String code, String message) { 19 | this.system = system; 20 | this.message = message; 21 | this.module = module; 22 | this.code = (system ? 0 : 1) + module.code() + code; 23 | } 24 | 25 | @Override 26 | public boolean system() { 27 | return this.system; 28 | } 29 | 30 | @Override 31 | public ModuleSupport module() { 32 | return this.module; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/TestWithBoostrap.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring; 2 | 3 | import com.sparrowzoo.coder.boot.Application; 4 | import com.sparrow.spring.starter.config.SparrowConfig; 5 | import com.sparrow.spring.starter.test.SparrowTestExecutionListener; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.TestExecutionListeners; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest(classes = {Application.class}) 15 | @TestExecutionListeners(listeners = {SparrowTestExecutionListener.class, DependencyInjectionTestExecutionListener.class}) 16 | public class TestWithBoostrap { 17 | 18 | @Autowired 19 | private SparrowConfig sparrowConfig; 20 | 21 | @Test 22 | public void testSpring() { 23 | System.out.println(sparrowConfig.toString()); 24 | System.out.println("hello sparrows"); 25 | } 26 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/AbstractPlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service; 2 | 3 | import com.sparrow.container.Container; 4 | import com.sparrow.container.ContainerAware; 5 | import com.sparrow.utility.ClassUtility; 6 | import com.sparrowzoo.coder.domain.service.registry.ArchitectureRegistry; 7 | import com.sparrowzoo.coder.domain.service.registry.PlaceholderExtensionRegistry; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.beans.factory.InitializingBean; 10 | 11 | @Slf4j 12 | public abstract class AbstractPlaceholderExtension implements PlaceholderExtension, InitializingBean, ContainerAware { 13 | protected PlaceholderExtensionRegistry placeholderExtensionRegistry = PlaceholderExtensionRegistry.getInstance(); 14 | 15 | @Override 16 | public void afterPropertiesSet() { 17 | String beanName = ClassUtility.getBeanNameByClass(this.getClass(), PlaceholderExtension.class); 18 | this.placeholderExtensionRegistry.pubObject(beanName, this); 19 | } 20 | 21 | @Override 22 | public void aware(Container container, String s) { 23 | this.afterPropertiesSet(); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/StringValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrowzoo.coder.domain.bo.validate.StringValidator; 4 | 5 | import javax.inject.Named; 6 | 7 | @Named 8 | public class StringValidatorMessageGenerator extends AbstractValidatorMessageGenerator { 9 | 10 | @Override 11 | public String outerGenerateMessage(String propertyName, StringValidator validator) { 12 | StringBuilder pipeline = new StringBuilder(); 13 | pipeline.append(this.pipeline()); 14 | pipeline.append(this.nonEmpty(propertyName,validator)); 15 | pipeline.append(this.minLength(propertyName,validator)); 16 | pipeline.append(this.maxLength(propertyName,validator)); 17 | this.finish(pipeline); 18 | if (validator.getAllowEmpty()) { 19 | return this.allowEmpty(pipeline.toString()); 20 | } 21 | return pipeline.toString(); 22 | } 23 | 24 | @Override 25 | public StringValidator defaultValidator() { 26 | return StringValidator.STRING_VALIDATOR; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/FrontendKey.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import lombok.Getter; 5 | 6 | /** 7 | * 前端组件模板枚举 8 | */ 9 | @Getter 10 | public enum FrontendKey implements EnumIdentityAccessor { 11 | PAGE("page.txt", 1), 12 | API("api.txt", 2), 13 | ADD("add.txt", 3), 14 | EDIT("edit.txt", 4), 15 | SEARCH("search.txt", 5), 16 | OPERATION("operation.txt", 6), 17 | COLUMNS("columns.txt", 7), 18 | MESSAGE("", 8), 19 | MESSAGE_FILE_LIST("", 9), 20 | SCHEMA("schema.txt", 10); 21 | 22 | private String template; 23 | private Integer id; 24 | 25 | FrontendKey(String template, Integer id) { 26 | this.id = id; 27 | this.template = template; 28 | } 29 | 30 | @Override 31 | public Integer getIdentity() { 32 | return this.id; 33 | } 34 | 35 | public static FrontendKey getEnum(Integer id) { 36 | for (FrontendKey key : FrontendKey.values()) { 37 | if (key.getIdentity().equals(id)) { 38 | return key; 39 | } 40 | } 41 | return null; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/TestWithBoostrap.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring; 2 | 3 | import com.sparrowzoo.coder.boot.Application; 4 | import com.sparrow.spring.starter.config.SparrowConfig; 5 | import com.sparrow.spring.starter.test.SparrowTestExecutionListener; 6 | import org.junit.Test; 7 | import org.junit.runner.RunWith; 8 | import org.springframework.beans.factory.annotation.Autowired; 9 | import org.springframework.boot.test.context.SpringBootTest; 10 | import org.springframework.test.context.TestExecutionListeners; 11 | import org.springframework.test.context.junit4.SpringRunner; 12 | import org.springframework.test.context.support.DependencyInjectionTestExecutionListener; 13 | @RunWith(SpringRunner.class) 14 | @SpringBootTest(classes = {Application.class}) 15 | @TestExecutionListeners(listeners = {SparrowTestExecutionListener.class, DependencyInjectionTestExecutionListener.class}) 16 | public class TestWithBoostrap { 17 | 18 | @Autowired 19 | private SparrowConfig sparrowConfig; 20 | 21 | @Test 22 | public void testSpring() { 23 | System.out.println(sparrowConfig.toString()); 24 | System.out.println("hello sparrows"); 25 | } 26 | } -------------------------------------------------------------------------------- /coder-main-spring-boot/src/main/configs/dev.properties: -------------------------------------------------------------------------------- 1 | driverClassName=com.mysql.cj.jdbc.Driver 2 | username=root 3 | password=11111111 4 | jdbc_url=jdbc\:mysql\://127.0.0.1/sparrow?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf-8 5 | poolSize=1 6 | 7 | mock_login_user=false 8 | resource=http://r.sparrowzoo.net 9 | passport=http://localhost:3000 10 | physical_resource={your_home_path}/workspace/sparrow/sparrow-js/source 11 | 12 | root_path=http://localhost:8888 13 | 14 | sparrow.profile=dev 15 | logback.dir=./logs 16 | 17 | 18 | redis_url=127.0.0.1:6379 19 | redis.pool.maxActive=5 20 | redis.pool.maxIdle=2 21 | 22 | 23 | upload=http://u.sparrowzoo.net 24 | physical_upload={your_home_path}/upload 25 | 26 | swagger.enable=true 27 | swagger.production=false 28 | authenticator.encrypt_key=123456 29 | authenticator.validate_device_id=false 30 | authenticator.validate_status=false 31 | authenticator.mock-login-user=false 32 | authenticator.login-token-available-days=0.001 33 | authenticator.remember-me-days=15 34 | allowed_origins=http://www.sparrowzoo.com,http://passport.sparrowzoo.com,http://localhost:3000,http://localhost:3001,http://192.168.1.14:3000,http://192.168.1.14:3001 -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/ArchitectureCategory.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import lombok.Getter; 5 | 6 | @Getter 7 | public enum ArchitectureCategory implements EnumIdentityAccessor { 8 | BACKEND(1, "后端","clear"), 9 | FRONTEND(2, "前端","react"), 10 | MOBILE(3, "移动端","mobile"), 11 | DESKTOP(4, "桌面","pc"), 12 | MINI_PROGRAM(5, "小程序","mini-program"), 13 | DATABASE(6, "数据库","mysql"); 14 | 15 | private final String name; 16 | private final Integer id; 17 | private final String defaultArch; 18 | 19 | ArchitectureCategory(Integer id, String name,String defaultArch) { 20 | this.id = id; 21 | this.name = name; 22 | this.defaultArch = defaultArch; 23 | } 24 | 25 | @Override 26 | public Integer getIdentity() { 27 | return this.id; 28 | } 29 | 30 | public static ArchitectureCategory getById(Integer id) { 31 | for (ArchitectureCategory category : values()) { 32 | if (category.getId().equals(id)) { 33 | return category; 34 | } 35 | } 36 | return null; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/main/configs/prod.properties: -------------------------------------------------------------------------------- 1 | driverClassName=com.mysql.cj.jdbc.Driver 2 | username=root 3 | password=11111111 4 | jdbc_url=jdbc\:mysql\://127.0.0.1/sparrow?autoReconnect=true&failOverReadOnly=false&useUnicode=true&characterEncoding=utf-8 5 | poolSize=1 6 | 7 | mock_login_user=false 8 | resource=http://r.sparrowzoo.net 9 | passport=http://localhost:3000 10 | physical_resource={your_home_path}/workspace/sparrow/sparrow-js/source 11 | 12 | root_path=http://localhost:8888 13 | 14 | sparrow.profile=dev 15 | logback.dir=./logs 16 | 17 | 18 | redis_url=127.0.0.1:6379 19 | redis.pool.maxActive=5 20 | redis.pool.maxIdle=2 21 | 22 | 23 | upload=http://u.sparrowzoo.net 24 | physical_upload={your_home_path}/upload 25 | 26 | swagger.enable=true 27 | swagger.production=false 28 | authenticator.encrypt_key=123456 29 | authenticator.validate_device_id=false 30 | authenticator.validate_status=false 31 | authenticator.mock-login-user=true 32 | authenticator.login-token-available-days=0.001 33 | authenticator.remember-me-days=15 34 | 35 | allowed_origins=http://www.sparrowzoo.com,http://passport.sparrowzoo.com,http://localhost:3000,http://localhost:3001,http://192.168.1.14:3000,http://192.168.1.14:3001 -------------------------------------------------------------------------------- /coder-po/bin/ddl/sparrow_example.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `sparrow_example`; 2 | CREATE TABLE `sparrow_example` ( 3 | `id` int(11) NOT NULL AUTO_INCREMENT, 4 | `avatar` varchar(256) DEFAULT '' COMMENT '头象' , 5 | `user_name` varchar(32) DEFAULT '' COMMENT '用户名' , 6 | `password` varchar(32) DEFAULT '' COMMENT '密码' , 7 | `age` int(10) UNSIGNED DEFAULT 0 COMMENT '年龄' , 8 | `confirm_password` varchar(32) DEFAULT '' COMMENT '确认密码' , 9 | `email` varchar(256) DEFAULT '' COMMENT 'email' , 10 | `id_card` varchar(32) DEFAULT '' COMMENT '身份证' , 11 | `mobile` varchar(16) DEFAULT '' COMMENT '手机号' , 12 | `tel` varchar(16) DEFAULT '' COMMENT '联系电话' , 13 | `name` varchar(16) DEFAULT '' COMMENT '用户姓名' , 14 | `create_user_id` int(11) UNSIGNED DEFAULT 0 COMMENT '创建人ID' NOT NULL, 15 | `gmt_create` bigint(11) DEFAULT 0 COMMENT '创建时间' NOT NULL, 16 | `modified_user_id` int(11) unsigned DEFAULT 0 COMMENT '更新人ID' NOT NULL, 17 | `gmt_modified` bigint(11) DEFAULT 0 COMMENT '更新时间' NOT NULL, 18 | `create_user_name` varchar(64) DEFAULT '' COMMENT '创建人' NOT NULL, 19 | `modified_user_name` varchar(64) DEFAULT '' COMMENT '更新人' NOT NULL, 20 | PRIMARY KEY (`id`) 21 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='sparrow_example'; 22 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/query/UserExampleQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.query; 19 | 20 | import com.sparrow.protocol.pager.SimplePager; 21 | import java.util.Date; 22 | import lombok.Data; 23 | @Data 24 | public class UserExampleQuery extends SimplePager { 25 | private String userName; 26 | private String chineseName; 27 | private Integer status; 28 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/query/TableConfigQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.query; 19 | 20 | import com.sparrow.protocol.pager.SimplePager; 21 | import java.util.Date; 22 | import lombok.Data; 23 | @Data 24 | public class TableConfigQuery extends SimplePager { 25 | private String tableName; 26 | private String className; 27 | private Integer status; 28 | private Long projectId; 29 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/query/ProjectConfigQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.query; 19 | 20 | import com.sparrow.protocol.pager.SimplePager; 21 | import java.util.Date; 22 | import lombok.Data; 23 | @Data 24 | public class ProjectConfigQuery extends SimplePager { 25 | private String name; 26 | private String frontendName; 27 | private String chineseName; 28 | private Integer status; 29 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/ProjectBO.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo; 2 | 3 | import com.sparrowzoo.coder.domain.service.ArchitectureGenerator; 4 | import com.sparrowzoo.coder.domain.service.EnvConfig; 5 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 6 | import lombok.Data; 7 | 8 | import java.util.ArrayList; 9 | import java.util.List; 10 | import java.util.Properties; 11 | 12 | @Data 13 | public class ProjectBO { 14 | 15 | public ProjectBO(ProjectConfigBO projectConfig, Properties scaffoldConfig, EnvConfig envConfig) { 16 | this.projectConfig = projectConfig; 17 | this.scaffoldConfig = scaffoldConfig; 18 | this.envConfig = envConfig; 19 | this.architectures=new ProjectArchsBO(this.projectConfig.getArchitectures()); 20 | } 21 | 22 | private ProjectConfigBO projectConfig; 23 | private Properties scaffoldConfig; 24 | private EnvConfig envConfig; 25 | private List i18nList=new ArrayList<>(); 26 | private ProjectArchsBO architectures; 27 | 28 | public ArchitectureGenerator getArchitecture(ArchitectureCategory architectureCategory){ 29 | return this.architectures.getArch(architectureCategory); 30 | } 31 | 32 | public void addI18n(String i18n){ 33 | this.i18nList.add(i18n); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/ValidatorTest.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder; 2 | 3 | import com.alibaba.fastjson.JSON; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | import com.sparrowzoo.coder.domain.service.ValidatorMessageGenerator; 6 | import com.sparrowzoo.coder.domain.service.registry.ValidatorRegistry; 7 | import org.junit.jupiter.api.Test; 8 | import org.springframework.boot.test.context.SpringBootTest; 9 | 10 | @SpringBootTest 11 | public class ValidatorTest { 12 | @Test 13 | public void test() { 14 | ValidatorMessageGenerator messageGenerator = ValidatorRegistry.getInstance().getValidatorMessageGenerator("react", 15 | "email"); 16 | 17 | RegexValidator validator = new RegexValidator(); 18 | validator.setAllowEmpty(true); 19 | validator.setI18n(false); 20 | validator.setEmptyMessage("用户名不能为空"); 21 | validator.setMinLength(5); 22 | validator.setMaxLength(30); 23 | validator.setFormatMessage("请输入正确的邮箱格式"); 24 | validator.setMinLengthMessage("用户名长度必须在5到30之间"); 25 | 26 | String validateMessage = messageGenerator.generateConfig("email", validator); 27 | System.out.println(validateMessage); 28 | System.out.println(JSON.toJSONString(messageGenerator.defaultValidator())); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/SearchType.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | import lombok.Getter; 7 | 8 | @EnumUniqueName(name = EnumNames.SEARCH_TYPE) 9 | @Getter 10 | public enum SearchType implements EnumIdentityAccessor { 11 | EQUAL(1,"equal"), 12 | PREFIX_LIKE(2,"startWith"), 13 | SUFFIX_LIKE(3,"endWith"), 14 | LIKE(4,"contains"), 15 | DATE_RANGE(5,""), 16 | LESS(6,"lessThan"), 17 | LESS_EQUAL(7,"lessThanEqual"), 18 | GREATER(8,"greaterThan"), 19 | GREATER_EQUAL(9,"greaterThanEqual"), 20 | BETWEEN(10,"between"), 21 | NOT_EQUAL(11,"notEqual"); 22 | 23 | private Integer id; 24 | private String condition; 25 | 26 | SearchType(Integer id,String condition) { 27 | this.id = id; 28 | this.condition = condition; 29 | } 30 | 31 | @Override 32 | public Integer getIdentity() { 33 | return this.id; 34 | } 35 | 36 | public static SearchType getById(Integer id) { 37 | for (SearchType type : SearchType.values()) { 38 | if (type.getIdentity().equals(id)) { 39 | return type; 40 | } 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/NullableValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrowzoo.coder.domain.bo.validate.NoneValidator; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class NullableValidatorMessageGenerator extends AbstractValidatorMessageGenerator { 10 | 11 | //https://www.66zan.cn/regexdso/ 12 | @Override 13 | public String outerGenerateMessage(String propertyName, NoneValidator validator) { 14 | if (validator.getClazz().equals(Boolean.class.getName())) { 15 | return "v.boolean()"; 16 | } 17 | if (validator.getClazz().equals(String.class.getName())) { 18 | return "v.string()"; 19 | } 20 | if (validator.getClazz().equals(Integer.class.getName()) || validator.getClazz().equals(Long.class.getName()) || validator.getClazz().equals(Double.class.getName()) || validator.getClazz().equals(Float.class.getName())) { 21 | return "v.number()"; 22 | } 23 | return "v.any()"; 24 | } 25 | 26 | @Override 27 | public NoneValidator defaultValidator() { 28 | return new NoneValidator(String.class.getName()); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/query/UserExampleDBPagerQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao.query; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.dao.DatabasePagerQuery; 22 | import java.util.Date; 23 | import lombok.Data; 24 | @Data 25 | 26 | public class UserExampleDBPagerQuery extends DatabasePagerQuery { 27 | private String userName; 28 | private String chineseName; 29 | private Integer status; 30 | public UserExampleDBPagerQuery() {} 31 | } -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/labmda/LambdaMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022, baomidou (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sparrow.spring.labmda; 17 | 18 | import org.apache.ibatis.reflection.property.PropertyNamer; 19 | 20 | /** 21 | * Lambda 信息 22 | *

23 | * Created by hcl at 2021/5/14 24 | */ 25 | public interface LambdaMeta { 26 | 27 | default String getName() { 28 | return PropertyNamer.methodToProperty(getImplMethodName()); 29 | } 30 | 31 | /** 32 | * 获取 lambda 表达式实现方法的名称 33 | * 34 | * @return lambda 表达式对应的实现方法名称 35 | */ 36 | String getImplMethodName(); 37 | 38 | /** 39 | * 实例化该方法的类 40 | * 41 | * @return 返回对应的类名称 42 | */ 43 | String getInstantiatedClass(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/labmda/LambdaMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022, baomidou (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sparrow.spring.labmda; 17 | 18 | import org.apache.ibatis.reflection.property.PropertyNamer; 19 | 20 | /** 21 | * Lambda 信息 22 | *

23 | * Created by hcl at 2021/5/14 24 | */ 25 | public interface LambdaMeta { 26 | 27 | default String getName() { 28 | return PropertyNamer.methodToProperty(getImplMethodName()); 29 | } 30 | 31 | /** 32 | * 获取 lambda 表达式实现方法的名称 33 | * 34 | * @return lambda 表达式对应的实现方法名称 35 | */ 36 | String getImplMethodName(); 37 | 38 | /** 39 | * 实例化该方法的类 40 | * 41 | * @return 返回对应的类名称 42 | */ 43 | String getInstantiatedClass(); 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ddl/t_user_example.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `t_user_example`; 2 | CREATE TABLE `t_user_example` ( 3 | `id` int COMMENT 'ID' NOT NULL AUTO_INCREMENT, 4 | `user_name` varchar(32) COMMENT '用户名' NOT NULL, 5 | `chinese_name` varchar(32) default '' comment '中文名' NOT NULL, 6 | `birthday` date null comment '出生日期' NOT NULL, 7 | `email` varchar(128) default '' comment 'Email' NOT NULL, 8 | `mobile` varchar(128) default '' comment '手机号' NOT NULL, 9 | `tel` varchar(128) default '' comment '电话号码' NOT NULL, 10 | `id_card` varchar(128) default '' comment '身份证' NOT NULL, 11 | `gender` int not null default 999 comment '性别' NOT NULL, 12 | `age` int not null default 0 comment '年龄' NOT NULL, 13 | `project_id` int comment '项目' NOT NULL, 14 | `create_user_name` varchar(64) DEFAULT '' COMMENT '创建人' NOT NULL, 15 | `create_user_id` int(11) UNSIGNED DEFAULT 0 COMMENT '创建人ID' NOT NULL, 16 | `modified_user_id` int(11) unsigned DEFAULT 0 COMMENT '更新人ID' NOT NULL, 17 | `modified_user_name` varchar(64) DEFAULT '' COMMENT '更新人' NOT NULL, 18 | `gmt_create` bigint(11) DEFAULT 0 COMMENT '创建时间' NOT NULL, 19 | `gmt_modified` bigint(11) DEFAULT 0 COMMENT '更新时间' NOT NULL, 20 | `deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除' NOT NULL, 21 | `status` tinyint(3) UNSIGNED DEFAULT 0 COMMENT '状态' NOT NULL, 22 | PRIMARY KEY (`id`) 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='t_user_example'; 24 | -------------------------------------------------------------------------------- /ddl/user_example.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `t_user_example`; 2 | CREATE TABLE `t_user_example` ( 3 | `id` int COMMENT 'ID' NOT NULL AUTO_INCREMENT, 4 | `user_name` varchar(32) COMMENT '用户名' NOT NULL, 5 | `chinese_name` varchar(32) default '' comment '中文名' NOT NULL, 6 | `birthday` date null comment '出生日期' NOT NULL, 7 | `email` varchar(128) default '' comment 'Email' NOT NULL, 8 | `mobile` varchar(128) default '' comment '手机号' NOT NULL, 9 | `tel` varchar(128) default '' comment '电话号码' NOT NULL, 10 | `id_card` varchar(128) default '' comment '身份证' NOT NULL, 11 | `gender` int not null default 999 comment '性别' NOT NULL, 12 | `age` int not null default 0 comment '年龄' NOT NULL, 13 | `project_id` int comment '项目' NOT NULL, 14 | `create_user_name` varchar(64) DEFAULT '' COMMENT '创建人' NOT NULL, 15 | `create_user_id` int(11) UNSIGNED DEFAULT 0 COMMENT '创建人ID' NOT NULL, 16 | `modified_user_id` int(11) unsigned DEFAULT 0 COMMENT '更新人ID' NOT NULL, 17 | `modified_user_name` varchar(64) DEFAULT '' COMMENT '更新人' NOT NULL, 18 | `gmt_create` bigint(11) DEFAULT 0 COMMENT '创建时间' NOT NULL, 19 | `gmt_modified` bigint(11) DEFAULT 0 COMMENT '更新时间' NOT NULL, 20 | `deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除' NOT NULL, 21 | `status` tinyint(3) UNSIGNED DEFAULT 0 COMMENT '状态' NOT NULL, 22 | PRIMARY KEY (`id`) 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='t_user_example'; 24 | -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/query/TableConfigDBPagerQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao.query; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.dao.DatabasePagerQuery; 22 | import java.util.Date; 23 | import lombok.Data; 24 | @Data 25 | 26 | public class TableConfigDBPagerQuery extends DatabasePagerQuery { 27 | private String tableName; 28 | private String className; 29 | private Integer status; 30 | private Long projectId; 31 | public TableConfigDBPagerQuery() {} 32 | } -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/query/ProjectConfigDBPagerQuery.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao.query; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.dao.DatabasePagerQuery; 22 | import java.util.Date; 23 | import lombok.Data; 24 | @Data 25 | 26 | public class ProjectConfigDBPagerQuery extends DatabasePagerQuery { 27 | private String name; 28 | private String frontendName; 29 | private String chineseName; 30 | private Integer status; 31 | public ProjectConfigDBPagerQuery() {} 32 | } -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/TableConfigDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao; 19 | 20 | import com.sparrow.protocol.dao.DaoSupport; 21 | import com.sparrowzoo.coder.po.TableConfig; 22 | import com.sparrowzoo.coder.dao.query.TableConfigDBPagerQuery; 23 | import java.util.List; 24 | 25 | public interface TableConfigDAO extends DaoSupport { 26 | List queryTableConfigs(TableConfigDBPagerQuery tableConfigPagerQuery); 27 | 28 | Long countTableConfig(TableConfigDBPagerQuery tableConfigPagerQuery); 29 | } -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/UserExampleDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao; 19 | 20 | import com.sparrow.protocol.dao.DaoSupport; 21 | import com.sparrowzoo.coder.po.UserExample; 22 | import com.sparrowzoo.coder.dao.query.UserExampleDBPagerQuery; 23 | import java.util.List; 24 | 25 | public interface UserExampleDAO extends DaoSupport { 26 | List queryUserExamples(UserExampleDBPagerQuery userExamplePagerQuery); 27 | 28 | Long countUserExample(UserExampleDBPagerQuery userExamplePagerQuery); 29 | } -------------------------------------------------------------------------------- /ddl/t_project_config.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `t_project_config`; 2 | CREATE TABLE `t_project_config` ( 3 | `id` int comment 'ID' NOT NULL AUTO_INCREMENT, 4 | `name` varchar(50) default '' comment '项目名称' NOT NULL, 5 | `frontend_name` varchar(50) default '' comment '前端项目名称' NOT NULL, 6 | `chinese_name` varchar(50) default '' comment '项目中文名称' NOT NULL, 7 | `i18n` tinyint(1) default 0 comment '是否支持国际化' , 8 | `description` text default '' comment '项目描述' , 9 | `module_prefix` varchar(50) default '' comment '模块前缀' NOT NULL, 10 | `architectures` varchar(50) default '' comment '代码架构' , 11 | `config` varchar(512) default '' comment '脚手架配置' , 12 | `wrap_with_parent` tinyint(1) default 0 comment '是否使用父module' , 13 | `scaffold` varchar(50) default '' comment '脚手架' , 14 | `create_user_name` varchar(64) DEFAULT '' COMMENT '创建人' NOT NULL, 15 | `create_user_id` int(11) UNSIGNED DEFAULT 0 COMMENT '创建人ID' NOT NULL, 16 | `modified_user_id` int(11) unsigned DEFAULT 0 COMMENT '更新人ID' NOT NULL, 17 | `modified_user_name` varchar(64) DEFAULT '' COMMENT '更新人' NOT NULL, 18 | `gmt_create` bigint(11) DEFAULT 0 COMMENT '创建时间' NOT NULL, 19 | `gmt_modified` bigint(11) DEFAULT 0 COMMENT '更新时间' NOT NULL, 20 | `deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除' NOT NULL, 21 | `status` tinyint(3) UNSIGNED DEFAULT 0 COMMENT '状态' NOT NULL, 22 | PRIMARY KEY (`id`) 23 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='t_project_config'; 24 | -------------------------------------------------------------------------------- /coder-dao-api/src/main/java/com/sparrowzoo/coder/dao/ProjectConfigDAO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.dao; 19 | 20 | import com.sparrow.protocol.dao.DaoSupport; 21 | import com.sparrowzoo.coder.po.ProjectConfig; 22 | import com.sparrowzoo.coder.dao.query.ProjectConfigDBPagerQuery; 23 | import java.util.List; 24 | 25 | public interface ProjectConfigDAO extends DaoSupport { 26 | List queryProjectConfigs(ProjectConfigDBPagerQuery projectConfigPagerQuery); 27 | 28 | Long countProjectConfig(ProjectConfigDBPagerQuery projectConfigPagerQuery); 29 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/RegexValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class RegexValidatorMessageGenerator extends AbstractValidatorMessageGenerator { 10 | 11 | //https://www.66zan.cn/regexdso/ 12 | @Override 13 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 14 | StringBuilder pipeline = new StringBuilder(); 15 | pipeline.append(this.pipeline()); 16 | pipeline.append(this.nonEmpty(propertyName,validator)); 17 | if (StringUtility.isNullOrEmpty(validator.getFormatMessage())) { 18 | validator.setFormatMessage(this.defaultValidator.getFormatMessage() + validator.getRegex()); 19 | } 20 | pipeline.append(this.check(propertyName,validator, validator.getRegex(), validator.getFormatMessage())); 21 | this.finish(pipeline); 22 | if (validator.getAllowEmpty()) { 23 | return this.allowEmpty(pipeline.toString()); 24 | } 25 | return pipeline.toString(); 26 | } 27 | 28 | @Override 29 | public RegexValidator defaultValidator() { 30 | return RegexValidator.REGEX_VALIDATOR; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/backend/placeholder/extension/ProjectPlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.backend.placeholder.extension; 2 | 3 | import com.sparrow.utility.DateTimeUtility; 4 | import com.sparrowzoo.coder.domain.bo.ProjectConfigBO; 5 | import com.sparrowzoo.coder.domain.bo.TableContext; 6 | import com.sparrowzoo.coder.domain.service.AbstractPlaceholderExtension; 7 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 8 | import com.sparrowzoo.coder.enums.PlaceholderKey; 9 | 10 | import javax.inject.Named; 11 | import java.util.Map; 12 | 13 | @Named 14 | public class ProjectPlaceholderExtension extends AbstractPlaceholderExtension { 15 | @Override 16 | public void extend(TableContext tableContext, TableConfigRegistry registry) { 17 | ProjectConfigBO project = tableContext.getProject().getProjectConfig(); 18 | Map placeHolder = tableContext.getPlaceHolder(); 19 | if (placeHolder.containsKey(PlaceholderKey.$project_i18n.name())) { 20 | return; 21 | } 22 | String modulePrefix = project.getModulePrefix(); 23 | placeHolder.put(PlaceholderKey.$project_i18n.name(), project.getI18n().toString()); 24 | placeHolder.put(PlaceholderKey.$date.name(), DateTimeUtility.getFormatCurrentTime("yyyy-MM-dd HH:mm:ss")); 25 | placeHolder.put(PlaceholderKey.$module_prefix.name(), modulePrefix); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/ClassKey.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | /** 4 | * 生成类的key 5 | *

6 | * 通过 class.{name}找到类名 通过 package.{name}找到包名 通过 module.{module} 找到模块名 7 | *

8 | * 通过该key 的配置找到对应的子模块名,包名及类名 9 | *

10 | * 具体的配置见config.properties 11 | */ 12 | public enum ClassKey { 13 | PO("", "persistence"), 14 | BO("bo.txt", "domain"), 15 | PARAM("param.txt", "protocol"), 16 | QUERY("query.txt", "protocol"), 17 | DTO("dto.txt", "protocol"), 18 | CONTROLLER("controller.txt", "adapter"), 19 | VO("vo.txt", "adapter"), 20 | DAO("dao.txt", "dao.api"), 21 | DAO_MYBATIS("", "dao.mybatis"), 22 | DAO_IMPL("daoImpl.txt", "dao.sparrow"), 23 | SERVICE("service.txt", "domain"), 24 | ASSEMBLE("assemble.txt", "adapter"), 25 | REPOSITORY("repository.txt", "domain"), 26 | REPOSITORY_IMPL("repositoryImpl.txt", "infrastructure"), 27 | DATA_CONVERTER("dataConverter.txt", "infrastructure"), 28 | PAGER_QUERY("pagerQuery.txt", "dao.api"), 29 | BATCH_OPERATE_PARAM("batchOperateParam.txt", "protocol"); 30 | 31 | private String template; 32 | private String module; 33 | 34 | public String getTemplate() { 35 | return template; 36 | } 37 | 38 | ClassKey(String template, String module) { 39 | this.template = template; 40 | this.module = module; 41 | } 42 | 43 | public String getModule() { 44 | return module; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/CellType.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | @EnumUniqueName(name = EnumNames.CELL_TYPE) 10 | public enum CellType implements EnumIdentityAccessor { 11 | NORMAL("NormalCell", "normal", "标准", 1), 12 | UNIX_TIMESTAMP("UnixTimestampCell", "unix-timestamp", "时间戮", 6), 13 | TREE("TreeCell", "tree", "树形", 2), 14 | OPERATION("OperationCell", "operation", "命令操作", 3), 15 | CHECK_BOX("CheckBoxCell", "check-box", "选择", 4), 16 | CURRENCY("CurrencyCell", "currency", "货币", 5); 17 | 18 | private String componentName; 19 | private String fileName; 20 | private String description; 21 | private Integer id; 22 | 23 | 24 | CellType(String componentName, String fileName, String description, Integer id) { 25 | this.componentName = componentName; 26 | this.fileName = fileName; 27 | this.description = description; 28 | this.id = id; 29 | } 30 | 31 | @Override 32 | public Integer getIdentity() { 33 | return id; 34 | } 35 | 36 | public static CellType getById(Integer id) { 37 | for (CellType cellType : CellType.values()) { 38 | if (cellType.getId().equals(id)) { 39 | return cellType; 40 | } 41 | } 42 | return null; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/WebMvcAutoConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.boot.config; 19 | 20 | import lombok.extern.slf4j.Slf4j; 21 | import org.springframework.context.annotation.Configuration; 22 | import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; 23 | 24 | /** 25 | * 验试加载顺序 优先级 26 | */ 27 | @Configuration 28 | //@AutoConfigureAfter({AuthcAutoConfiguration.class, BasicAutoConfiguration.class}) 29 | @Slf4j 30 | public class WebMvcAutoConfiguration implements WebMvcConfigurer { 31 | public WebMvcAutoConfiguration() { 32 | log.info("WebMvcAutoConfiguration is loaded"); 33 | } 34 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/param/UserExampleParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.param; 19 | 20 | import com.sparrow.protocol.Param; 21 | import com.sparrow.protocol.enums.StatusRecord; 22 | import lombok.Data; 23 | import java.time.*; 24 | 25 | 26 | 27 | @Data 28 | public class UserExampleParam implements Param { 29 | private Long id; 30 | private String userName; 31 | private String chineseName; 32 | private LocalDate birthday; 33 | private String email; 34 | private String mobile; 35 | private String tel; 36 | private String idCard; 37 | private Integer gender; 38 | private Integer age; 39 | private Long projectId; 40 | 41 | } -------------------------------------------------------------------------------- /coder-adapter/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | coder-bom 8 | 1.0.0-SNAPSHOT 9 | com.sparrowzoo.coder 10 | 11 | 12 | coder-adapter 13 | 14 | 15 | com.github.xiaoymin 16 | knife4j-spring-boot-starter 17 | true 18 | 19 | 20 | com.sparrowzoo.coder 21 | coder-domain 22 | 23 | 24 | com.sparrowzoo 25 | sparrow-starter 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-web 30 | true 31 | 32 | 33 | com.sparrowzoo 34 | sparrow-loader 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/param/ProjectConfigParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.param; 19 | 20 | import com.sparrow.protocol.Param; 21 | import com.sparrow.protocol.enums.StatusRecord; 22 | import lombok.Data; 23 | import java.time.*; 24 | 25 | 26 | 27 | @Data 28 | public class ProjectConfigParam implements Param { 29 | private Long id; 30 | private String name; 31 | private String frontendName; 32 | private String chineseName; 33 | private Boolean i18n; 34 | private String description; 35 | private String modulePrefix; 36 | private String architectures; 37 | private String config; 38 | private Boolean wrapWithParent; 39 | private String scaffold; 40 | 41 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/registry/ColumnGeneratorRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.registry; 2 | 3 | import com.sparrow.container.FactoryBean; 4 | import com.sparrowzoo.coder.domain.service.frontend.generator.column.ColumnGenerator; 5 | 6 | import java.util.HashMap; 7 | import java.util.Iterator; 8 | import java.util.Map; 9 | 10 | public class ColumnGeneratorRegistry implements FactoryBean { 11 | private Map container = new HashMap<>(); 12 | 13 | private ColumnGeneratorRegistry() { 14 | } 15 | 16 | @Override 17 | public void pubObject(String s, ColumnGenerator columnGenerator) { 18 | this.container.put(s, columnGenerator); 19 | } 20 | 21 | @Override 22 | public ColumnGenerator getObject(String s) { 23 | return this.container.get(s); 24 | } 25 | 26 | @Override 27 | public Class getObjectType() { 28 | return ColumnGenerator.class; 29 | } 30 | 31 | @Override 32 | public void removeObject(String s) { 33 | this.container.remove(s); 34 | } 35 | 36 | @Override 37 | public Iterator keyIterator() { 38 | return this.container.keySet().iterator(); 39 | } 40 | 41 | 42 | static class Inner { 43 | private static final ColumnGeneratorRegistry columnGeneratorRegistry = new ColumnGeneratorRegistry(); 44 | } 45 | 46 | public static ColumnGeneratorRegistry getInstance() { 47 | return Inner.columnGeneratorRegistry; 48 | } 49 | 50 | 51 | } 52 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/ProjectArchsBO.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo; 2 | 3 | import com.sparrow.core.spi.JsonFactory; 4 | import com.sparrow.protocol.BO; 5 | import com.sparrow.utility.StringUtility; 6 | import com.sparrowzoo.coder.domain.service.ArchitectureGenerator; 7 | import com.sparrowzoo.coder.domain.service.registry.ArchitectureRegistry; 8 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 9 | import lombok.Getter; 10 | 11 | import java.util.HashMap; 12 | import java.util.Map; 13 | 14 | @Getter 15 | public class ProjectArchsBO implements BO { 16 | public ProjectArchsBO(String configs) { 17 | this.archs = JsonFactory.getProvider().parse(configs, Map.class); 18 | if (this.archs == null || this.archs.isEmpty()) { 19 | this.archs = new HashMap<>(); 20 | for (ArchitectureCategory category : ArchitectureCategory.values()) { 21 | this.archs.put(category.name(), category.getDefaultArch()); 22 | } 23 | } 24 | } 25 | 26 | public ArchitectureGenerator getArch(ArchitectureCategory category) { 27 | String arch = this.archs.get(category.name()); 28 | if (StringUtility.isNullOrEmpty(arch)) { 29 | arch = category.getDefaultArch(); 30 | } 31 | return ArchitectureRegistry.getInstance().getGenerator(category, arch); 32 | } 33 | 34 | public ArchitectureGenerator getArch(String category) { 35 | return this.getArch(ArchitectureCategory.valueOf(category)); 36 | } 37 | 38 | private Map archs; 39 | } 40 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/DigitalValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.DigitalValidator; 5 | 6 | import javax.inject.Named; 7 | 8 | @Named 9 | public class DigitalValidatorMessageGenerator extends AbstractValidatorMessageGenerator { 10 | @Override 11 | public String outerGenerateMessage(String propertyName, DigitalValidator validator) { 12 | if(StringUtility.isNullOrEmpty(validator.getDigitalMessage())){ 13 | validator.setDigitalMessage(this.defaultValidator.getDigitalMessage()); 14 | } 15 | StringBuilder pipeline = new StringBuilder(); 16 | pipeline.append(this.pipeline()); 17 | pipeline.append(this.nonEmpty(propertyName,validator)); 18 | pipeline.append(this.check(propertyName,validator, validator.getCategory().getRegex(), validator.getDigitalMessage())); 19 | pipeline.append(this.transform(validator.getCategory())); 20 | pipeline.append(this.minValue(propertyName,validator)); 21 | pipeline.append(this.maxValue(propertyName,validator)); 22 | this.finish(pipeline); 23 | if (validator.getAllowEmpty()) { 24 | return this.allowEmpty(pipeline.toString()); 25 | } 26 | return pipeline.toString(); 27 | } 28 | 29 | 30 | @Override 31 | public DigitalValidator defaultValidator() { 32 | return DigitalValidator.DIGITAL_VALIDATOR; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/main/resources/rsa/private: -------------------------------------------------------------------------------- 1 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCYeEF1/aECMPnfpefwr6vVSFT7FfknI9aULq3rx1pqaiC1HzlHHLBJMqunwzTGAjOont9JGX/c7pwO0bVAAk4H1QPEfDqe+lxb3bINQxEG7MqI4DYpQ9fJ7/4BeIpl6O39lS1JWF7lb/hGpcdiFetSzvkp+hcnQELTmZ/avA/ooXWTlIlvQKfrzmDeC9b27jgxfPGmcaIYBDRdfKT0E9Uw/1qaffLTwryQ9GGbFnpC+L6UZXWYlE6362Dt0HlkRg2zmBbhQxdeUxZmQMmYE9mc7Cvpjl56qmo0MpwSCtehI+vt5Ua9iQUgnC3C9uCKRmPSrN77YkBIRQ5HT1dGs87PAgMBAAECggEBAJeRxJGFJxBEm8JG7YIJQOrv0vsgZuUP7Xq1xNPFBA8RnZ4wggI9dMnvg1Fs7wOAoNYZyaKjpMZ+tcjNlD8ji2qhyfMEBEqSXEo+44fnif+2WckkCvOOq+/lkj7oE70nh581MyXcocm4O7oPh1vsqllRw8SFB4tPiJ9N8unBVpdMhnghpK80qK1AJkAKNMoHu540xEhKsW5Cr2NbTss+Ezv8HpcyZ9/7hJvkxiMxvMP58af/0oE+LzCJVhUrHxuQWuqgYoOc+IVKCxaXfnPn7F41nfzPGB85onO62ed4DRoSYw/2MR5EoEHla74OvAFkc+a68vQGJn5RhBdlg4MCIFECgYEA+6VRQX7QTzbkZQepCLJ+rRKw/ilXfBPOEK7Kqn+ROVzaHksUPRPVf+J2sOe5CqWrm5gvTYJRmQY/KSS5xfcniKdk7V54481Vg7htdxmEAzYEG5fdew3pcPz6YYNAUnpgXgXqfYhmGrMnEfV7TyJ5/Nc4O15yBSJoV/T3uSfR5R0CgYEAmxuhk0045znlq9WRHUNPUuQTBio0LYqaqZqU9IsLuBayOlMaRuho4ock+ulK36qKY7Xcmo3KP6DucwfqOhd772ubuAWsD/0V/yC19y98Oo/Lu2c6R6eP44cnc6CFTDTHMkNzdBJOp9qN7ZZR6ooRng1OtLvHoWmW0of23VOp29sCgYEA4pJ7cav7ZIc45toZ0JHdynjc0Upp0XaHf6/RG+gV2n8GiGXzB/cWsLk3QpqwmayGsWY5mODwFQZx0dqWRW79smV9UtdPo1PaXems7aIUoUt+MVXv/X6OI8Qyr5+cR2aV47IR6groW7vYPqw25Q5WpVcl8xZbNNJA/oi6joQS0OUCgYEAk0sC/dnYTqQJeUte+bYArwuNEU6krBayVptIFo2wPEm5SG/ARVPQvkVuFaPTCWFu988sxcweIpxVtADxKedBNxQuFOu2AJzq9ZL/mdOLGiWRZ85YZtE1b/DZwxDNZJe+DfpFuhTkgrumCde0xJAGuNuUQUcNBTg7FIQvJvCbHf8CgYABkBrRdC+L8h6HkaolgVvR7f3upMvJ0j32UI/e7bpX8cmeK23OfMkRIu8jrlUtBP9Y/BkSsLkS6SPFh31CURkwgcBNSX/CaAiZqV58H6aljrndwWSMMVfcErIANz+oCpP3wRhDwBNRxqvl5NbL3wb8NB0x0icyBGDeM5afzSHMhA== 2 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/resources/rsa/private: -------------------------------------------------------------------------------- 1 | MIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQCYeEF1/aECMPnfpefwr6vVSFT7FfknI9aULq3rx1pqaiC1HzlHHLBJMqunwzTGAjOont9JGX/c7pwO0bVAAk4H1QPEfDqe+lxb3bINQxEG7MqI4DYpQ9fJ7/4BeIpl6O39lS1JWF7lb/hGpcdiFetSzvkp+hcnQELTmZ/avA/ooXWTlIlvQKfrzmDeC9b27jgxfPGmcaIYBDRdfKT0E9Uw/1qaffLTwryQ9GGbFnpC+L6UZXWYlE6362Dt0HlkRg2zmBbhQxdeUxZmQMmYE9mc7Cvpjl56qmo0MpwSCtehI+vt5Ua9iQUgnC3C9uCKRmPSrN77YkBIRQ5HT1dGs87PAgMBAAECggEBAJeRxJGFJxBEm8JG7YIJQOrv0vsgZuUP7Xq1xNPFBA8RnZ4wggI9dMnvg1Fs7wOAoNYZyaKjpMZ+tcjNlD8ji2qhyfMEBEqSXEo+44fnif+2WckkCvOOq+/lkj7oE70nh581MyXcocm4O7oPh1vsqllRw8SFB4tPiJ9N8unBVpdMhnghpK80qK1AJkAKNMoHu540xEhKsW5Cr2NbTss+Ezv8HpcyZ9/7hJvkxiMxvMP58af/0oE+LzCJVhUrHxuQWuqgYoOc+IVKCxaXfnPn7F41nfzPGB85onO62ed4DRoSYw/2MR5EoEHla74OvAFkc+a68vQGJn5RhBdlg4MCIFECgYEA+6VRQX7QTzbkZQepCLJ+rRKw/ilXfBPOEK7Kqn+ROVzaHksUPRPVf+J2sOe5CqWrm5gvTYJRmQY/KSS5xfcniKdk7V54481Vg7htdxmEAzYEG5fdew3pcPz6YYNAUnpgXgXqfYhmGrMnEfV7TyJ5/Nc4O15yBSJoV/T3uSfR5R0CgYEAmxuhk0045znlq9WRHUNPUuQTBio0LYqaqZqU9IsLuBayOlMaRuho4ock+ulK36qKY7Xcmo3KP6DucwfqOhd772ubuAWsD/0V/yC19y98Oo/Lu2c6R6eP44cnc6CFTDTHMkNzdBJOp9qN7ZZR6ooRng1OtLvHoWmW0of23VOp29sCgYEA4pJ7cav7ZIc45toZ0JHdynjc0Upp0XaHf6/RG+gV2n8GiGXzB/cWsLk3QpqwmayGsWY5mODwFQZx0dqWRW79smV9UtdPo1PaXems7aIUoUt+MVXv/X6OI8Qyr5+cR2aV47IR6groW7vYPqw25Q5WpVcl8xZbNNJA/oi6joQS0OUCgYEAk0sC/dnYTqQJeUte+bYArwuNEU6krBayVptIFo2wPEm5SG/ARVPQvkVuFaPTCWFu988sxcweIpxVtADxKedBNxQuFOu2AJzq9ZL/mdOLGiWRZ85YZtE1b/DZwxDNZJe+DfpFuhTkgrumCde0xJAGuNuUQUcNBTg7FIQvJvCbHf8CgYABkBrRdC+L8h6HkaolgVvR7f3upMvJ0j32UI/e7bpX8cmeK23OfMkRIu8jrlUtBP9Y/BkSsLkS6SPFh31CURkwgcBNSX/CaAiZqV58H6aljrndwWSMMVfcErIANz+oCpP3wRhDwBNRxqvl5NbL3wb8NB0x0icyBGDeM5afzSHMhA== 2 | -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/labmda/ShadowLambdaMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022, baomidou (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sparrow.spring.labmda; 17 | 18 | 19 | import java.lang.invoke.SerializedLambda; 20 | 21 | /** 22 | * 基于 {@link com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda} 创建的元信息 23 | *

24 | * Create by hcl at 2021/7/7 25 | */ 26 | public class ShadowLambdaMeta implements LambdaMeta { 27 | private final SerializedLambda lambda; 28 | 29 | public ShadowLambdaMeta(SerializedLambda lambda) { 30 | this.lambda = lambda; 31 | } 32 | 33 | @Override 34 | public String getImplMethodName() { 35 | return lambda.getImplMethodName(); 36 | } 37 | 38 | @Override 39 | public String getInstantiatedClass() { 40 | String instantiatedMethodType = lambda.getInstantiatedMethodType(); 41 | return instantiatedMethodType.substring(2, instantiatedMethodType.indexOf(StringPool.SEMICOLON)).replace(StringPool.SLASH, StringPool.DOT); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/labmda/ShadowLambdaMeta.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2011-2022, baomidou (jobob@qq.com). 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.sparrow.spring.labmda; 17 | 18 | 19 | import java.lang.invoke.SerializedLambda; 20 | 21 | /** 22 | * 基于 {@link com.baomidou.mybatisplus.core.toolkit.support.SerializedLambda} 创建的元信息 23 | *

24 | * Create by hcl at 2021/7/7 25 | */ 26 | public class ShadowLambdaMeta implements LambdaMeta { 27 | private final SerializedLambda lambda; 28 | 29 | public ShadowLambdaMeta(SerializedLambda lambda) { 30 | this.lambda = lambda; 31 | } 32 | 33 | @Override 34 | public String getImplMethodName() { 35 | return lambda.getImplMethodName(); 36 | } 37 | 38 | @Override 39 | public String getInstantiatedClass() { 40 | String instantiatedMethodType = lambda.getInstantiatedMethodType(); 41 | return instantiatedMethodType.substring(2, instantiatedMethodType.indexOf(StringPool.SEMICOLON)).replace(StringPool.SLASH, StringPool.DOT); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/registry/ArchitectureRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.registry; 2 | 3 | import com.sparrowzoo.coder.domain.service.ArchitectureGenerator; 4 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class ArchitectureRegistry { 10 | private Map> registry; 11 | 12 | public void register(String name, ArchitectureGenerator generator) { 13 | registry.putIfAbsent(generator.getCategory(), new HashMap<>()); 14 | registry.get(generator.getCategory()).put(name, generator); 15 | } 16 | 17 | public Map> getRegistry() { 18 | return registry; 19 | } 20 | 21 | public ArchitectureGenerator getGenerator(ArchitectureCategory category, String name) { 22 | Map architectureMap = registry.get(category); 23 | if (architectureMap == null) { 24 | return null; 25 | } 26 | if (architectureMap.containsKey(name)) { 27 | return architectureMap.get(name); 28 | } 29 | return architectureMap.values().iterator().next(); 30 | } 31 | 32 | private ArchitectureRegistry() { 33 | registry = new HashMap<>(); 34 | } 35 | 36 | 37 | static class Inner { 38 | private static final ArchitectureRegistry architectureRegistry = new ArchitectureRegistry(); 39 | } 40 | 41 | public static ArchitectureRegistry getInstance() { 42 | return ArchitectureRegistry.Inner.architectureRegistry; 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /ddl/t_table_config.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS `t_table_config`; 2 | CREATE TABLE `t_table_config` ( 3 | `id` int COMMENT 'ID' NOT NULL AUTO_INCREMENT, 4 | `project_id` int comment '项目' NOT NULL, 5 | `primary_key` varchar(32) default '' comment '主键' NOT NULL, 6 | `table_name` varchar(128) default '' comment '表名' NOT NULL, 7 | `class_name` varchar(128) default '' comment '类名' NOT NULL, 8 | `description` varchar(255) default '' comment '描述' NOT NULL, 9 | `locked` tinyint(1) default 0 comment '是否锁定' NOT NULL, 10 | `checkable` int default 0 comment '选择' NOT NULL, 11 | `row_menu` int default 0 comment '行菜单' NOT NULL, 12 | `column_filter` int default 0 comment '列过滤器' NOT NULL, 13 | `status_command` tinyint(1) default 0 comment '是否显示状态命令' NOT NULL, 14 | `column_configs` text null comment '列配置' , 15 | `source` int default 0 not null comment '类来源' NOT NULL, 16 | `source_code` text null comment '源代码' , 17 | `page_size` int default 0 not null comment '分页大小' NOT NULL, 18 | `only_access_self` tinyint(2) default 0 not null comment '只看自己' NOT NULL, 19 | `create_user_name` varchar(64) DEFAULT '' COMMENT '创建人' NOT NULL, 20 | `create_user_id` int(11) UNSIGNED DEFAULT 0 COMMENT '创建人ID' NOT NULL, 21 | `modified_user_id` int(11) unsigned DEFAULT 0 COMMENT '更新人ID' NOT NULL, 22 | `modified_user_name` varchar(64) DEFAULT '' COMMENT '更新人' NOT NULL, 23 | `gmt_create` bigint(11) DEFAULT 0 COMMENT '创建时间' NOT NULL, 24 | `gmt_modified` bigint(11) DEFAULT 0 COMMENT '更新时间' NOT NULL, 25 | `deleted` tinyint(1) DEFAULT 0 COMMENT '是否删除' NOT NULL, 26 | `status` tinyint(3) UNSIGNED DEFAULT 0 COMMENT '状态' NOT NULL, 27 | PRIMARY KEY (`id`) 28 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='t_table_config'; 29 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/daoImpl.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_dao_impl; 3 | 4 | import com.sparrow.orm.query.*; 5 | import com.sparrow.orm.template.impl.ORMStrategy; 6 | import $package_dao.$persistence_class_nameDAO; 7 | import $package_pager_query.$persistence_class_nameDBPagerQuery; 8 | import $package_po.$persistence_class_name; 9 | import java.util.List; 10 | import javax.inject.Named; 11 | import com.sparrow.protocol.*; 12 | import com.sparrow.context.SessionContext; 13 | import com.sparrow.protocol.enums.StatusRecord; 14 | 15 | 16 | @Named 17 | public class $persistence_class_nameDaoImpl extends ORMStrategy<$persistence_class_name, Long> implements $persistence_class_nameDAO { 18 | @Override public List<$persistence_class_name> query$persistence_class_names($persistence_class_nameDBPagerQuery pager$persistence_class_nameQuery) { 19 | SearchCriteria searchCriteria = new SearchCriteria(pager$persistence_class_nameQuery); 20 | searchCriteria.setWhere(this.generateCriteria(pager$persistence_class_nameQuery)); 21 | searchCriteria.setOrderCriteria(OrderCriteria.desc($persistence_class_name::getId)); 22 | return this.getList(searchCriteria); 23 | } 24 | 25 | private BooleanCriteria generateCriteria($persistence_class_nameDBPagerQuery $persistence_object_nameQuery) { 26 | $search_dao_condition 27 | } 28 | 29 | @Override public Long count$persistence_class_name($persistence_class_nameDBPagerQuery $persistence_object_namePagerQuery) { 30 | SearchCriteria searchCriteria = new SearchCriteria(); 31 | searchCriteria.setWhere(this.generateCriteria($persistence_object_namePagerQuery)); 32 | return this.getCount(searchCriteria); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/param/TableConfigParam.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.param; 19 | 20 | import com.sparrow.protocol.Param; 21 | import com.sparrow.protocol.enums.StatusRecord; 22 | import lombok.Data; 23 | import java.time.*; 24 | 25 | 26 | 27 | @Data 28 | public class TableConfigParam implements Param { 29 | private Long id; 30 | private Long projectId; 31 | private String primaryKey; 32 | private String tableName; 33 | private String className; 34 | private String description; 35 | private Boolean locked; 36 | private Integer checkable; 37 | private Integer rowMenu; 38 | private Integer columnFilter; 39 | private Boolean statusCommand; 40 | private String columnConfigs; 41 | private Integer source; 42 | private String sourceCode; 43 | private Integer pageSize; 44 | private Boolean onlyAccessSelf; 45 | 46 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/repository/TableConfigRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.repository; 19 | import com.sparrowzoo.coder.domain.bo.TableConfigBO; 20 | import com.sparrowzoo.coder.protocol.param.TableConfigParam; 21 | import com.sparrowzoo.coder.protocol.query.TableConfigQuery; 22 | import java.util.List; 23 | import java.util.Set; 24 | 25 | 26 | 27 | 28 | public interface TableConfigRepository { 29 | Long save(TableConfigParam tableConfigParam); 30 | 31 | Integer delete(Set tableConfigIds); 32 | 33 | Integer disable(Set tableConfigIds); 34 | 35 | Integer enable(Set tableConfigIds); 36 | 37 | TableConfigBO getTableConfig(Long tableConfigId); 38 | 39 | List queryTableConfigs(TableConfigQuery tableConfigQuery); 40 | 41 | Long getTableConfigCount(TableConfigQuery tableConfigQuery); 42 | 43 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/repository/UserExampleRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.repository; 19 | import com.sparrowzoo.coder.domain.bo.UserExampleBO; 20 | import com.sparrowzoo.coder.protocol.param.UserExampleParam; 21 | import com.sparrowzoo.coder.protocol.query.UserExampleQuery; 22 | import java.util.List; 23 | import java.util.Set; 24 | 25 | 26 | 27 | 28 | public interface UserExampleRepository { 29 | Long save(UserExampleParam userExampleParam); 30 | 31 | Integer delete(Set userExampleIds); 32 | 33 | Integer disable(Set userExampleIds); 34 | 35 | Integer enable(Set userExampleIds); 36 | 37 | UserExampleBO getUserExample(Long userExampleId); 38 | 39 | List queryUserExamples(UserExampleQuery userExampleQuery); 40 | 41 | Long getUserExampleCount(UserExampleQuery userExampleQuery); 42 | 43 | } -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/moke/beans/EnvConfigImpl.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.moke.beans; 2 | 3 | import com.sparrowzoo.coder.domain.service.EnvConfig; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | 7 | import javax.inject.Named; 8 | import java.io.File; 9 | 10 | @Named 11 | @Slf4j 12 | public class EnvConfigImpl implements EnvConfig { 13 | EnvConfigImpl() { 14 | log.info("env config impl"); 15 | } 16 | 17 | @Value("${workspace}") 18 | private String workspace; 19 | 20 | @Value("${project_root}") 21 | private String projectRoot; 22 | 23 | @Value("${frontend_project_root}") 24 | private String frontendProjectRoot; 25 | 26 | @Value("${multi_user}") 27 | private Boolean multiUser; 28 | 29 | @Value("${overwrite}") 30 | private Boolean overwrite; 31 | 32 | 33 | @Override 34 | public String getWorkspace() { 35 | return this.workspace.replace("/", File.separator); 36 | } 37 | 38 | @Override 39 | public String getProjectRoot() { 40 | return this.projectRoot.replace("/", File.separator); 41 | } 42 | 43 | @Override 44 | public String getFrontendProjectRoot() { 45 | return frontendProjectRoot.replace("/", File.separator); 46 | } 47 | 48 | @Override 49 | public Boolean getMultiUser() { 50 | return this.multiUser; 51 | } 52 | 53 | @Override 54 | public String getHome(Long userId) { 55 | if (this.multiUser) { 56 | return userId + ""; 57 | } 58 | return ""; 59 | } 60 | 61 | @Override 62 | public Boolean overwrite() { 63 | return this.overwrite; 64 | } 65 | 66 | 67 | } 68 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/DefaultEnvConfig.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.boot.config; 2 | 3 | import com.sparrowzoo.coder.domain.service.EnvConfig; 4 | import lombok.extern.slf4j.Slf4j; 5 | import org.springframework.beans.factory.annotation.Value; 6 | 7 | import javax.inject.Named; 8 | import java.io.File; 9 | 10 | @Named 11 | @Slf4j 12 | public class DefaultEnvConfig implements EnvConfig { 13 | DefaultEnvConfig() { 14 | log.info("env config impl"); 15 | } 16 | 17 | @Value("${workspace}") 18 | private String workspace; 19 | 20 | @Value("${project_root}") 21 | private String projectRoot; 22 | 23 | @Value("${frontend_project_root}") 24 | private String frontendProjectRoot; 25 | 26 | @Value("${multi_user}") 27 | private Boolean multiUser; 28 | 29 | @Value("${overwrite}") 30 | private Boolean overwrite; 31 | 32 | 33 | @Override 34 | public String getWorkspace() { 35 | return this.workspace.replace("/", File.separator); 36 | } 37 | 38 | @Override 39 | public String getProjectRoot() { 40 | return this.projectRoot.replace("/", File.separator); 41 | } 42 | 43 | @Override 44 | public String getFrontendProjectRoot() { 45 | return frontendProjectRoot.replace("/", File.separator); 46 | } 47 | 48 | @Override 49 | public Boolean getMultiUser() { 50 | return this.multiUser; 51 | } 52 | 53 | @Override 54 | public String getHome(Long userId) { 55 | if (this.multiUser) { 56 | return userId + ""; 57 | } 58 | return ""; 59 | } 60 | 61 | @Override 62 | public Boolean overwrite() { 63 | return this.overwrite; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/UserExampleBO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.domain.bo; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | import lombok.Data; 24 | @Data 25 | public class UserExampleBO implements BO 26 | {private Long id; 27 | private String userName; 28 | private String chineseName; 29 | private LocalDate birthday; 30 | private String email; 31 | private String mobile; 32 | private String tel; 33 | private String idCard; 34 | private Integer gender; 35 | private Integer age; 36 | private Long projectId; 37 | private String createUserName; 38 | private Long createUserId; 39 | private Long modifiedUserId; 40 | private String modifiedUserName; 41 | private Long gmtCreate; 42 | private Long gmtModified; 43 | private Boolean deleted; 44 | private StatusRecord status; 45 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/dto/UserExampleDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.dto; 19 | import lombok.Data; 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | 24 | @Data 25 | public class UserExampleDTO implements DTO 26 | {private Long id; 27 | private String userName; 28 | private String chineseName; 29 | private LocalDate birthday; 30 | private String email; 31 | private String mobile; 32 | private String tel; 33 | private String idCard; 34 | private Integer gender; 35 | private Integer age; 36 | private Long projectId; 37 | private String createUserName; 38 | private Long createUserId; 39 | private Long modifiedUserId; 40 | private String modifiedUserName; 41 | private Long gmtCreate; 42 | private Long gmtModified; 43 | private Boolean deleted; 44 | private Integer status; 45 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/repository/ProjectConfigRepository.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.repository; 19 | import com.sparrowzoo.coder.domain.bo.ProjectConfigBO; 20 | import com.sparrowzoo.coder.protocol.param.ProjectConfigParam; 21 | import com.sparrowzoo.coder.protocol.query.ProjectConfigQuery; 22 | import java.util.List; 23 | import java.util.Set; 24 | 25 | 26 | 27 | 28 | public interface ProjectConfigRepository { 29 | Long save(ProjectConfigParam projectConfigParam); 30 | 31 | Integer delete(Set projectConfigIds); 32 | 33 | Integer disable(Set projectConfigIds); 34 | 35 | Integer enable(Set projectConfigIds); 36 | 37 | ProjectConfigBO getProjectConfig(Long projectConfigId); 38 | 39 | List queryProjectConfigs(ProjectConfigQuery projectConfigQuery); 40 | 41 | Long getProjectConfigCount(ProjectConfigQuery projectConfigQuery); 42 | 43 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/placeholder/extension/TSClassPlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.placeholder.extension; 2 | 3 | import com.sparrow.orm.Field; 4 | import com.sparrowzoo.coder.domain.bo.TableContext; 5 | import com.sparrowzoo.coder.domain.service.AbstractPlaceholderExtension; 6 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 7 | import com.sparrowzoo.coder.enums.PlaceholderKey; 8 | import com.sparrowzoo.coder.utils.JavaTsTypeConverter; 9 | 10 | import javax.inject.Named; 11 | import java.util.Map; 12 | 13 | @Named 14 | public class TSClassPlaceholderExtension extends AbstractPlaceholderExtension { 15 | @Override 16 | public void extend(TableContext tableContext, TableConfigRegistry registry) { 17 | Map placeholder = tableContext.getPlaceHolder(); 18 | placeholder.put(PlaceholderKey.$frontend_class.name(), this.generateClass(tableContext)); 19 | } 20 | 21 | private String generateClass(TableContext tableContext) { 22 | Map fields = tableContext.getEntityManager().getPropertyFieldMap(); 23 | StringBuilder fieldBuild = new StringBuilder(); 24 | for (Field field : fields.values()) { 25 | Class fieldClazz = field.getType(); 26 | String property = String.format("%s:%s; \n", field.getPropertyName(), JavaTsTypeConverter.toTsType(fieldClazz)); 27 | fieldBuild.append(property); 28 | } 29 | String className = tableContext.getTableConfig().getClassName(); 30 | className = className.substring(className.lastIndexOf(".") + 1); 31 | 32 | return String.format("export interface %1$s extends BasicData<%1$s> \n{\n %2$s\n}", className, fieldBuild); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/ProjectConfigBO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.domain.bo; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | import lombok.Data; 24 | @Data 25 | public class ProjectConfigBO implements BO 26 | ,DisplayTextAccessor{private Long id; 27 | private String name; 28 | private String frontendName; 29 | private String chineseName; 30 | private Boolean i18n; 31 | private String description; 32 | private String modulePrefix; 33 | private String architectures; 34 | private String config; 35 | private Boolean wrapWithParent; 36 | private String scaffold; 37 | private String createUserName; 38 | private Long createUserId; 39 | private Long modifiedUserId; 40 | private String modifiedUserName; 41 | private Long gmtCreate; 42 | private Long gmtModified; 43 | private Boolean deleted; 44 | private StatusRecord status; 45 | private String displayText; 46 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/dto/ProjectConfigDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.dto; 19 | import lombok.Data; 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | 24 | @Data 25 | public class ProjectConfigDTO implements DTO 26 | ,DisplayTextAccessor{private Long id; 27 | private String name; 28 | private String frontendName; 29 | private String chineseName; 30 | private Boolean i18n; 31 | private String description; 32 | private String modulePrefix; 33 | private String architectures; 34 | private String config; 35 | private Boolean wrapWithParent; 36 | private String scaffold; 37 | private String createUserName; 38 | private Long createUserId; 39 | private Long modifiedUserId; 40 | private String modifiedUserName; 41 | private Long gmtCreate; 42 | private Long gmtModified; 43 | private Boolean deleted; 44 | private Integer status; 45 | private String displayText; 46 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/validate/react/EmailValidatorMessageGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.validate.react; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.validate.RegexValidator; 5 | import com.sparrowzoo.coder.domain.bo.validate.StringValidator; 6 | 7 | import javax.inject.Named; 8 | 9 | @Named 10 | public class EmailValidatorMessageGenerator extends AbstractValidatorMessageGenerator { 11 | 12 | @Override 13 | public String outerGenerateMessage(String propertyName, RegexValidator validator) { 14 | StringBuilder pipeline = new StringBuilder(); 15 | pipeline.append(this.pipeline()); 16 | pipeline.append(this.nonEmpty(propertyName,validator)); 17 | pipeline.append(this.minLength(propertyName,validator)); 18 | pipeline.append(this.maxLength(propertyName,validator)); 19 | pipeline.append(this.email(propertyName,validator)); 20 | this.finish(pipeline); 21 | if (validator.getAllowEmpty()) { 22 | return this.allowEmpty(pipeline.toString()); 23 | } 24 | return pipeline.toString(); 25 | } 26 | 27 | private String email(String propertyName, RegexValidator validator) { 28 | String message = validator.getFormatMessage(); 29 | if (StringUtility.isNullOrEmpty(message)) { 30 | message = this.defaultValidator.getFormatMessage(); 31 | } 32 | return String.format(",\nv.email(%s)", this.getMessage(propertyName,validator, "email-message", message)); 33 | } 34 | 35 | @Override 36 | public RegexValidator defaultValidator() { 37 | RegexValidator validator=RegexValidator.REGEX_VALIDATOR.create(); 38 | validator.setFormatMessage("请输入有效的邮箱地址"); 39 | return validator; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/RegexValidator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | import lombok.Data; 4 | 5 | @Data 6 | public class RegexValidator extends StringValidator implements Validator { 7 | public static RegexValidator REGEX_VALIDATOR=new RegexValidator(); 8 | static { 9 | StringValidator stringValidator=StringValidator.STRING_VALIDATOR.create(); 10 | REGEX_VALIDATOR.setI18n(stringValidator.i18n); 11 | REGEX_VALIDATOR.setEmptyMessage(stringValidator.emptyMessage); 12 | REGEX_VALIDATOR.setAllowEmpty(stringValidator.allowEmpty); 13 | REGEX_VALIDATOR.setMinLength(stringValidator.minLength); 14 | REGEX_VALIDATOR.setMaxLength(stringValidator.maxLength); 15 | REGEX_VALIDATOR.setMinLengthMessage(stringValidator.minLengthMessage); 16 | REGEX_VALIDATOR.setMaxLengthMessage(stringValidator.maxLengthMessage); 17 | REGEX_VALIDATOR.setI18nConfig(stringValidator.i18nConfig); 18 | REGEX_VALIDATOR.setFormatMessage("请输入正确格式的:%s"); 19 | } 20 | private String formatMessage; 21 | private String regex; 22 | 23 | public RegexValidator create() { 24 | RegexValidator validator=new RegexValidator(); 25 | validator.setFormatMessage(REGEX_VALIDATOR.formatMessage); 26 | validator.setRegex(REGEX_VALIDATOR.regex); 27 | validator.setI18n(REGEX_VALIDATOR.i18n); 28 | validator.setEmptyMessage(REGEX_VALIDATOR.emptyMessage); 29 | validator.setAllowEmpty(REGEX_VALIDATOR.allowEmpty); 30 | validator.setMinLength(REGEX_VALIDATOR.minLength); 31 | validator.setMaxLength(REGEX_VALIDATOR.maxLength); 32 | validator.setMinLengthMessage(REGEX_VALIDATOR.minLengthMessage); 33 | validator.setMaxLengthMessage(REGEX_VALIDATOR.maxLengthMessage); 34 | validator.setI18nConfig(REGEX_VALIDATOR.i18nConfig); 35 | return validator; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/TableConfigBO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.domain.bo; 19 | 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | import lombok.Data; 24 | @Data 25 | public class TableConfigBO implements BO 26 | {private Long id; 27 | private Long projectId; 28 | private String primaryKey; 29 | private String tableName; 30 | private String className; 31 | private String description; 32 | private Boolean locked; 33 | private Integer checkable; 34 | private Integer rowMenu; 35 | private Integer columnFilter; 36 | private Boolean statusCommand; 37 | private String columnConfigs; 38 | private Integer source; 39 | private String sourceCode; 40 | private Integer pageSize; 41 | private Boolean onlyAccessSelf; 42 | private String createUserName; 43 | private Long createUserId; 44 | private Long modifiedUserId; 45 | private String modifiedUserName; 46 | private Long gmtCreate; 47 | private Long gmtModified; 48 | private Boolean deleted; 49 | private StatusRecord status; 50 | } -------------------------------------------------------------------------------- /coder-protocol/src/main/java/com/sparrowzoo/coder/protocol/dto/TableConfigDTO.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.protocol.dto; 19 | import lombok.Data; 20 | import com.sparrow.protocol.enums.StatusRecord; 21 | import com.sparrow.protocol.*; 22 | import java.time.*; 23 | 24 | @Data 25 | public class TableConfigDTO implements DTO 26 | {private Long id; 27 | private Long projectId; 28 | private String primaryKey; 29 | private String tableName; 30 | private String className; 31 | private String description; 32 | private Boolean locked; 33 | private Integer checkable; 34 | private Integer rowMenu; 35 | private Integer columnFilter; 36 | private Boolean statusCommand; 37 | private String columnConfigs; 38 | private Integer source; 39 | private String sourceCode; 40 | private Integer pageSize; 41 | private Boolean onlyAccessSelf; 42 | private String createUserName; 43 | private Long createUserId; 44 | private Long modifiedUserId; 45 | private String modifiedUserName; 46 | private Long gmtCreate; 47 | private Long gmtModified; 48 | private Boolean deleted; 49 | private Integer status; 50 | } -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/HeaderType.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | @EnumUniqueName(name = EnumNames.HEADER_TYPE) 10 | public enum HeaderType implements EnumIdentityAccessor { 11 | NORMAL("PlainTextHeader", "plain-text", false, false, "标准", 1), 12 | NORMAL_SORT("NormalHeader", "normal", true, false, "标准(可排序)", 2), 13 | NORMAL_FILTER("NormalHeader", "normal", false, false, "标准(可过滤)", 3), 14 | NORMAL_SORT_FILTER("NormalHeader", "normal", true, true, "标准(可过滤,可排序)", 4), 15 | CHECK_BOX("CheckboxHeader", "check-box", false, false, "选择", 5), 16 | COLUMN_FILTER("ColumnFilter", "column-filter", false, false, "过滤", 6), 17 | PLAIN_TEXT("PlainTextHeader", "plain-text", false, false, "操作", 9), 18 | EMPTY("EmptyHeader", "empty", false, false, "空白", 10); 19 | private String componentName; 20 | private String fileName; 21 | private Boolean sortable; 22 | private Boolean filterable; 23 | private String description; 24 | private Integer id; 25 | 26 | HeaderType(String componentName, String fileName, Boolean sortable, Boolean filterable, String description, Integer id) { 27 | this.componentName = componentName; 28 | this.fileName = fileName; 29 | this.description = description; 30 | this.sortable = sortable; 31 | this.filterable = filterable; 32 | this.id = id; 33 | } 34 | 35 | 36 | @Override 37 | public Integer getIdentity() { 38 | return this.id; 39 | } 40 | 41 | public static HeaderType getById(Integer id) { 42 | for (HeaderType headerType : HeaderType.values()) { 43 | if (headerType.getId().equals(id)) { 44 | return headerType; 45 | } 46 | } 47 | return null; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/StringValidator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | import lombok.Data; 4 | 5 | import java.util.Map; 6 | 7 | @Data 8 | public class StringValidator implements Validator, Cloneable { 9 | public static final String NAME="string"; 10 | 11 | public static final StringValidator STRING_VALIDATOR = new StringValidator(); 12 | static { 13 | STRING_VALIDATOR.setEmptyMessage("不允许为空"); 14 | STRING_VALIDATOR.setMinLengthMessage("至少%s个字符"); 15 | STRING_VALIDATOR.setMaxLengthMessage("最多不允许超过%s个字符"); 16 | STRING_VALIDATOR.setAllowEmpty(false); 17 | STRING_VALIDATOR.setI18n(true); 18 | STRING_VALIDATOR.setMinLength(null); 19 | STRING_VALIDATOR.setMaxLength(null); 20 | } 21 | 22 | 23 | 24 | public StringValidator defaultValidator() { 25 | return STRING_VALIDATOR; 26 | } 27 | 28 | protected Boolean i18n; 29 | protected String emptyMessage; 30 | protected Boolean allowEmpty; 31 | protected Integer minLength; 32 | protected Integer maxLength; 33 | protected String minLengthMessage; 34 | protected String maxLengthMessage; 35 | protected Map i18nConfig; 36 | 37 | 38 | @Override 39 | public StringValidator create() { 40 | StringValidator validator =new StringValidator(); 41 | validator.setI18n(STRING_VALIDATOR.getI18n()); 42 | validator.setEmptyMessage(STRING_VALIDATOR.emptyMessage); 43 | validator.setAllowEmpty(STRING_VALIDATOR.allowEmpty); 44 | validator.setMinLength(STRING_VALIDATOR.minLength); 45 | validator.setMaxLength(STRING_VALIDATOR.maxLength); 46 | validator.setMinLengthMessage(STRING_VALIDATOR.minLengthMessage); 47 | validator.setMaxLengthMessage(STRING_VALIDATOR.maxLengthMessage); 48 | validator.setI18nConfig(STRING_VALIDATOR.i18nConfig); 49 | return validator; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/architecture/ReactArchitectureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.architecture; 2 | 3 | import com.sparrowzoo.coder.constant.ArchitectureNames; 4 | import com.sparrowzoo.coder.domain.bo.TableContext; 5 | import com.sparrowzoo.coder.domain.service.AbstractArchitectureGenerator; 6 | import com.sparrowzoo.coder.domain.service.frontend.FrontendGenerator; 7 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 8 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 9 | import com.sparrowzoo.coder.enums.FrontendKey; 10 | 11 | import javax.inject.Named; 12 | import java.io.IOException; 13 | 14 | @Named 15 | public class ReactArchitectureGenerator extends AbstractArchitectureGenerator { 16 | @Override 17 | public void generate(TableConfigRegistry registry, String tableName) throws IOException { 18 | TableContext tableContext = registry.getTableContext(tableName); 19 | FrontendGenerator frontendGenerator = tableContext.getFrontendGenerator(); 20 | frontendGenerator.generate(FrontendKey.PAGE, registry); 21 | frontendGenerator.generate(FrontendKey.API, registry); 22 | frontendGenerator.generate(FrontendKey.ADD, registry); 23 | frontendGenerator.generate(FrontendKey.EDIT, registry); 24 | frontendGenerator.generate(FrontendKey.SEARCH, registry); 25 | frontendGenerator.generate(FrontendKey.OPERATION, registry); 26 | frontendGenerator.generate(FrontendKey.SCHEMA, registry); 27 | frontendGenerator.generate(FrontendKey.COLUMNS, registry); 28 | frontendGenerator.generate(FrontendKey.MESSAGE, registry); 29 | frontendGenerator.generate(FrontendKey.MESSAGE_FILE_LIST, registry); 30 | } 31 | 32 | @Override 33 | public ArchitectureCategory getCategory() { 34 | return ArchitectureCategory.FRONTEND; 35 | } 36 | 37 | @Override 38 | public String getName() { 39 | return ArchitectureNames.REACT; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/labmda/Test.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring.labmda; 2 | 3 | import com.sparrow.cg.PropertyNamer; 4 | import com.sparrow.protocol.SFunction; 5 | import com.sparrow.utility.ClassUtility; 6 | import com.sparrowzoo.coder.po.ProjectConfig; 7 | 8 | import java.lang.invoke.SerializedLambda; 9 | import java.lang.reflect.Method; 10 | 11 | public class Test { 12 | public static void main(String[] args) { 13 | // LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); 14 | // wrapper.eq(ProjectConfig::getStatus, 1); 15 | // wrapper.eq(ProjectConfig::getChineseName, "中文名称"); 16 | //project_config.status = 1 and project_config.chinese_name = '中文名称' 17 | System.out.println(getPropertyNameAndClassName(ProjectConfig::getStatus).entityDotProperty()); 18 | //System.out.println(getPropertyNameAndClassName(ProjectConfig::getChineseName).entityDotProperty()); 19 | } 20 | 21 | public static ClassUtility.PropertyWithBeanName getPropertyNameAndClassName(SFunction function) { 22 | try { 23 | // 反射获取 writeReplace 方法 24 | Method method = function.getClass().getDeclaredMethod("writeReplace"); 25 | method.setAccessible(true); 26 | // 调用该方法获取 SerializedLambda 对象 27 | SerializedLambda serializedLambda = (SerializedLambda) method.invoke(function); 28 | // 解析方法名 29 | String methodName = serializedLambda.getImplMethodName(); 30 | String clazz = serializedLambda.getImplClass();//PO 31 | return new ClassUtility.PropertyWithBeanName(PropertyNamer.methodToProperty(methodName), clazz); 32 | 33 | //ShadowLambdaMeta lambdaMeta = new ShadowLambdaMeta(serializedLambda); 34 | //return new ClassUtility.PropertyWithEntityName(PropertyNamer.methodToProperty(methodName), lambdaMeta.getInstantiatedClass()); 35 | } catch (Exception e) { 36 | throw new RuntimeException("无法解析方法名", e); 37 | } 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/labmda/Test.java: -------------------------------------------------------------------------------- 1 | package com.sparrow.spring.labmda; 2 | 3 | import com.sparrow.cg.PropertyNamer; 4 | import com.sparrow.protocol.SFunction; 5 | import com.sparrow.utility.ClassUtility; 6 | import com.sparrowzoo.coder.po.ProjectConfig; 7 | 8 | import java.lang.invoke.SerializedLambda; 9 | import java.lang.reflect.Method; 10 | 11 | public class Test { 12 | public static void main(String[] args) { 13 | // LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); 14 | // wrapper.eq(ProjectConfig::getStatus, 1); 15 | // wrapper.eq(ProjectConfig::getChineseName, "中文名称"); 16 | //project_config.status = 1 and project_config.chinese_name = '中文名称' 17 | System.out.println(getPropertyNameAndClassName(ProjectConfig::getStatus).entityDotProperty()); 18 | //System.out.println(getPropertyNameAndClassName(ProjectConfig::getChineseName).entityDotProperty()); 19 | } 20 | 21 | public static ClassUtility.PropertyWithBeanName getPropertyNameAndClassName(SFunction function) { 22 | try { 23 | // 反射获取 writeReplace 方法 24 | Method method = function.getClass().getDeclaredMethod("writeReplace"); 25 | method.setAccessible(true); 26 | // 调用该方法获取 SerializedLambda 对象 27 | SerializedLambda serializedLambda = (SerializedLambda) method.invoke(function); 28 | // 解析方法名 29 | String methodName = serializedLambda.getImplMethodName(); 30 | String clazz = serializedLambda.getImplClass();//PO 31 | return new ClassUtility.PropertyWithBeanName(PropertyNamer.methodToProperty(methodName), clazz); 32 | 33 | //ShadowLambdaMeta lambdaMeta = new ShadowLambdaMeta(serializedLambda); 34 | //return new ClassUtility.PropertyWithEntityName(PropertyNamer.methodToProperty(methodName), lambdaMeta.getInstantiatedClass()); 35 | } catch (Exception e) { 36 | throw new RuntimeException("无法解析方法名", e); 37 | } 38 | } 39 | 40 | 41 | } 42 | -------------------------------------------------------------------------------- /coder-po/src/main/java/com/sparrowzoo/coder/po/ProjectConfig.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.po; 2 | 3 | import com.sparrow.protocol.DisplayTextAccessor; 4 | import com.sparrow.protocol.dao.PO; 5 | import lombok.Data; 6 | 7 | import javax.persistence.*; 8 | 9 | @Table(name = "t_project_config") 10 | @Data 11 | public class ProjectConfig extends PO implements DisplayTextAccessor { 12 | @Id 13 | @GeneratedValue(strategy = GenerationType.IDENTITY) 14 | @Column(name = "id", columnDefinition = "int comment 'ID'") 15 | private Long id; 16 | @Column(name = "name", nullable = false, columnDefinition = "varchar(50) default '' comment '项目名称'") 17 | private String name; 18 | @Column(name = "frontend_name",nullable = false,columnDefinition = "varchar(50) default '' comment '前端项目名称'") 19 | private String frontendName; 20 | @Column(name = "chinese_name",nullable = false, columnDefinition = "varchar(50) default '' comment '项目中文名称'") 21 | private String chineseName; 22 | @Column(name = "i18n", columnDefinition = "tinyint(1) default 0 comment '是否支持国际化'") 23 | private Boolean i18n; 24 | @Column(name = "description", columnDefinition = "text default '' comment '项目描述'") 25 | private String description; 26 | @Column(name = "module_prefix", nullable = false, columnDefinition = "varchar(50) default '' comment '模块前缀'") 27 | private String modulePrefix; 28 | @Column(name = "architectures", columnDefinition = "varchar(50) default '' comment '代码架构'") 29 | private String architectures; 30 | @Column(name = "config", columnDefinition = "varchar(512) default '' comment '脚手架配置'") 31 | private String config; 32 | @Column(name = "wrap_with_parent", columnDefinition = "tinyint(1) default 0 comment '是否使用父module'") 33 | private Boolean wrapWithParent; 34 | @Column(name = "scaffold", columnDefinition = "varchar(50) default '' comment '脚手架'") 35 | private String scaffold; 36 | 37 | @Override 38 | public String getDisplayText() { 39 | return String.format("%s【%s】", chineseName, name); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/placeholder/extension/PathPlaceholderExtension.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend.placeholder.extension; 2 | 3 | import com.sparrowzoo.coder.domain.bo.TableContext; 4 | import com.sparrowzoo.coder.domain.service.AbstractPlaceholderExtension; 5 | import com.sparrowzoo.coder.domain.service.frontend.FrontendPlaceholderGenerator; 6 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 7 | import com.sparrowzoo.coder.enums.FrontendKey; 8 | import com.sparrowzoo.coder.enums.PlaceholderKey; 9 | 10 | import javax.inject.Named; 11 | import java.util.Map; 12 | 13 | @Named 14 | public class PathPlaceholderExtension extends AbstractPlaceholderExtension { 15 | @Override 16 | public void extend(TableContext tableContext, TableConfigRegistry registry) { 17 | FrontendPlaceholderGenerator frontendPlaceholderGenerator = tableContext.getFrontendPlaceholderGenerator(); 18 | Map placeholder = tableContext.getPlaceHolder(); 19 | placeholder.put(PlaceholderKey.$frontend_path_page.name(), frontendPlaceholderGenerator.getPath(FrontendKey.PAGE)); 20 | placeholder.put(PlaceholderKey.$frontend_path_api.name(), frontendPlaceholderGenerator.getPath(FrontendKey.API)); 21 | placeholder.put(PlaceholderKey.$frontend_path_add.name(), frontendPlaceholderGenerator.getPath(FrontendKey.ADD)); 22 | placeholder.put(PlaceholderKey.$frontend_path_edit.name(), frontendPlaceholderGenerator.getPath(FrontendKey.EDIT)); 23 | placeholder.put(PlaceholderKey.$frontend_path_search.name(), frontendPlaceholderGenerator.getPath(FrontendKey.SEARCH)); 24 | placeholder.put(PlaceholderKey.$frontend_path_columns.name(), frontendPlaceholderGenerator.getPath(FrontendKey.COLUMNS)); 25 | placeholder.put(PlaceholderKey.$frontend_path_schema.name(), frontendPlaceholderGenerator.getPath(FrontendKey.SCHEMA)); 26 | placeholder.put(PlaceholderKey.$frontend_path_operation.name(), frontendPlaceholderGenerator.getPath(FrontendKey.OPERATION)); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /coder-main-spring-boot/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | coder-bom 7 | 1.0.0-SNAPSHOT 8 | com.sparrowzoo.coder 9 | 10 | 11 | 4.0.0 12 | coder-main-spring-boot 13 | 14 | 15 | 16 | com.sparrowzoo.coder 17 | coder-spring-starter 18 | 19 | 20 | com.sparrowzoo.passport 21 | passport-starter 22 | 23 | 24 | 25 | 26 | src/main/configs/${env}.properties 27 | 28 | 29 | 30 | src/main/resources 31 | 32 | **/** 33 | *.xml 34 | **/*.html 35 | *.properties 36 | 37 | true 38 | ${project.build.directory}/classes/ 39 | 40 | 41 | 42 | 43 | org.springframework.boot 44 | spring-boot-maven-plugin 45 | 46 | com.sparrowzoo.coder.boot.Application 47 | 48 | 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/ControlType.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import com.sparrow.protocol.EnumIdentityAccessor; 4 | import com.sparrow.protocol.EnumUniqueName; 5 | import com.sparrowzoo.coder.constant.EnumNames; 6 | import lombok.Getter; 7 | 8 | @Getter 9 | @EnumUniqueName(name = EnumNames.CONTROL_TYPE) 10 | public enum ControlType implements EnumIdentityAccessor { 11 | INPUT_TEXT("ValidatableInput","validatable-input", "text", 1), 12 | LABEL("ValidatableInput","validatable-input", "label", 2), 13 | // LINK("lnk", "link", 3), 14 | INPUT_HIDDEN("ValidatableInput","validatable-input", "hidden", 4), 15 | INPUT_PASSWORD("ValidatableInput","validatable-input", "password", 5), 16 | TEXT_AREA("ValidatableTextarea","validatable-textarea", "textarea", 6), 17 | SELECT("ValidatableSelect","validatable-select", "select", 7), 18 | // CODE("validatable-editor", "code", 10), 19 | // EDITOR("validatable-editor", "editor", 11), 20 | DATE("ValidatableDate","validatable-date", "date", 12), 21 | DATE_HHMMSS("ValidatableTime","validatable-time", "time", 13), 22 | CHECK_BOX("ValidatableInput","validatable-input", "checkbox", 14), 23 | // FILE("validatable-upload", "file", 16), 24 | // IMAGE("validatable-upload", "image", 19) 25 | ; 26 | 27 | 28 | private final String component; 29 | private final String fileName; 30 | private final String inputType; 31 | private Integer id; 32 | 33 | 34 | ControlType(String component,String fileName, String inputType, Integer id) { 35 | this.fileName= fileName; 36 | this.component = component; 37 | this.inputType = inputType; 38 | this.id = id; 39 | } 40 | 41 | @Override 42 | public Integer getIdentity() { 43 | return id; 44 | } 45 | 46 | public static ControlType getControlType(Integer inputType) { 47 | for (ControlType controlType : ControlType.values()) { 48 | if (controlType.id.equals(inputType)) { 49 | return controlType; 50 | } 51 | } 52 | return null; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/frontend/DefaultFrontendPlaceholder.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.frontend; 2 | 3 | import com.sparrow.core.spi.JsonFactory; 4 | import com.sparrow.io.file.FileNameBuilder; 5 | import com.sparrow.io.file.FileNameProperty; 6 | import com.sparrow.json.Json; 7 | import com.sparrow.utility.FileUtility; 8 | import com.sparrow.utility.StringUtility; 9 | import com.sparrowzoo.coder.domain.bo.ColumnDef; 10 | import com.sparrowzoo.coder.domain.bo.ProjectBO; 11 | import com.sparrowzoo.coder.domain.bo.TableContext; 12 | import com.sparrowzoo.coder.enums.FrontendKey; 13 | import com.sparrowzoo.coder.enums.PlaceholderKey; 14 | 15 | import java.io.File; 16 | import java.util.List; 17 | 18 | public class DefaultFrontendPlaceholder implements FrontendPlaceholderGenerator { 19 | protected final ProjectBO project; 20 | protected final TableContext tableContext; 21 | protected List columnDefs; 22 | protected Json json = JsonFactory.getProvider(); 23 | 24 | public DefaultFrontendPlaceholder(ProjectBO project, TableContext tableContext) { 25 | this.project = project; 26 | this.tableContext = tableContext; 27 | this.columnDefs = tableContext.getColumns(); 28 | } 29 | 30 | @Override 31 | public String getPath(FrontendKey key) { 32 | String originPath = this.project.getScaffoldConfig().getProperty(key.name().toLowerCase()); 33 | String persistenceClassName = tableContext.getEntityManager().getSimpleClassName(); 34 | String persistenceObjectByDot = StringUtility.humpToLower(persistenceClassName, '-'); 35 | originPath = originPath.replace(PlaceholderKey.$persistence_object_by_horizontal.name(), persistenceObjectByDot); 36 | originPath = originPath.replace(PlaceholderKey.$persistence_class_name.name(), persistenceClassName); 37 | FileNameProperty fileNameProperty = FileUtility.getInstance().getFileNameProperty(originPath); 38 | return new FileNameBuilder(fileNameProperty.getName().replace(".", File.separator)).extension(fileNameProperty.getExtension()).build(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/bo/validate/DigitalValidator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.bo.validate; 2 | 3 | import com.sparrowzoo.coder.enums.DigitalCategory; 4 | import lombok.Data; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | @Data 10 | public class DigitalValidator implements Validator, Cloneable { 11 | public static DigitalValidator DIGITAL_VALIDATOR = new DigitalValidator(); 12 | 13 | public static final String NAME = "digital"; 14 | 15 | static { 16 | DIGITAL_VALIDATOR.setAllowEmpty(false); 17 | DIGITAL_VALIDATOR.setCategory(DigitalCategory.INTEGER); 18 | DIGITAL_VALIDATOR.setEmptyMessage("不允许为空"); 19 | DIGITAL_VALIDATOR.setMinValueMessage("不允许小于%s"); 20 | DIGITAL_VALIDATOR.setMaxValueMessage("不允许大于%s"); 21 | DIGITAL_VALIDATOR.setDigitalMessage("请输入正确的数字"); 22 | } 23 | 24 | private Boolean i18n; 25 | private String emptyMessage; 26 | private Boolean allowEmpty; 27 | private String digitalMessage; 28 | private Integer minValue; 29 | private String minValueMessage; 30 | private Integer maxValue; 31 | private String maxValueMessage; 32 | //INT FLOAT 科学计数法 33 | private DigitalCategory category; 34 | private Map i18nConfig = new HashMap<>(); 35 | 36 | public DigitalValidator create() { 37 | DigitalValidator validator = new DigitalValidator(); 38 | validator.setI18n(DIGITAL_VALIDATOR.i18n); 39 | validator.setEmptyMessage(DIGITAL_VALIDATOR.emptyMessage); 40 | validator.setAllowEmpty(DIGITAL_VALIDATOR.allowEmpty); 41 | validator.setDigitalMessage(DIGITAL_VALIDATOR.digitalMessage); 42 | validator.setMinValue(DIGITAL_VALIDATOR.minValue); 43 | validator.setMinValueMessage(DIGITAL_VALIDATOR.minValueMessage); 44 | validator.setMaxValue(DIGITAL_VALIDATOR.maxValue); 45 | validator.setMaxValueMessage(DIGITAL_VALIDATOR.maxValueMessage); 46 | validator.setCategory(DIGITAL_VALIDATOR.category); 47 | validator.setI18nConfig(DIGITAL_VALIDATOR.i18nConfig); 48 | return validator; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/backend/architecture/MySqlArchitectureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.backend.architecture; 2 | 3 | import com.sparrow.io.file.FileNameBuilder; 4 | import com.sparrow.orm.EntityManager; 5 | import com.sparrow.utility.FileUtility; 6 | import com.sparrowzoo.coder.constant.ArchitectureNames; 7 | import com.sparrowzoo.coder.domain.bo.ProjectConfigBO; 8 | import com.sparrowzoo.coder.domain.service.AbstractArchitectureGenerator; 9 | import com.sparrowzoo.coder.domain.service.EnvConfig; 10 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 11 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 12 | 13 | import javax.inject.Named; 14 | import java.io.IOException; 15 | 16 | @Named 17 | public class MySqlArchitectureGenerator extends AbstractArchitectureGenerator { 18 | @Override 19 | public void generate(TableConfigRegistry registry, String tableName) throws IOException { 20 | EntityManager entityManager = registry.getTableContext(tableName).getEntityManager(); 21 | EnvConfig envConfig = registry.getProject().getEnvConfig(); 22 | ProjectConfigBO projectConfig = registry.getProject().getProjectConfig(); 23 | String home = envConfig.getHome(projectConfig.getCreateUserId()); 24 | String fullPath = new FileNameBuilder(envConfig.getWorkspace()) 25 | .joint(envConfig.getProjectRoot()) 26 | .joint(home) 27 | .joint(projectConfig.getName()) 28 | .joint("ddl") 29 | .fileName(tableName) 30 | .extension("sql") 31 | .build(); 32 | String sql = entityManager.getCreateDDL(); 33 | System.err.println(sql); 34 | FileUtility.getInstance().writeFile(fullPath, sql); 35 | System.err.printf("table create ddl write to %s\n", fullPath); 36 | } 37 | 38 | @Override 39 | public ArchitectureCategory getCategory() { 40 | return ArchitectureCategory.DATABASE; 41 | } 42 | 43 | @Override 44 | public String getName() { 45 | return ArchitectureNames.MYSQL; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/enums/JavaTypeController.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.enums; 2 | 3 | import lombok.Getter; 4 | 5 | import java.time.LocalDate; 6 | 7 | @Getter 8 | public enum JavaTypeController { 9 | STRING(new ControlType[]{ 10 | ControlType.INPUT_TEXT, 11 | ControlType.INPUT_PASSWORD, 12 | ControlType.DATE_HHMMSS, 13 | // ControlType.EDITOR, 14 | ControlType.TEXT_AREA, 15 | ControlType.SELECT, 16 | // ControlType.CODE, 17 | // ControlType.FILE, 18 | // ControlType.IMAGE, 19 | ControlType.INPUT_HIDDEN}), 20 | NUMBER(new ControlType[]{ 21 | ControlType.INPUT_TEXT, 22 | ControlType.INPUT_HIDDEN, 23 | ControlType.SELECT}), 24 | BOOLEAN(new ControlType[]{ 25 | ControlType.CHECK_BOX}), 26 | DATE(new ControlType[]{ 27 | ControlType.DATE}); 28 | 29 | private ControlType[] controlTypes; 30 | 31 | JavaTypeController(ControlType[] controlTypes) { 32 | this.controlTypes = controlTypes; 33 | } 34 | 35 | public static JavaTypeController getByJavaType(String className) { 36 | Class javaType = null; 37 | try { 38 | javaType = Class.forName(className); 39 | } catch (ClassNotFoundException e) { 40 | throw new RuntimeException(e); 41 | } 42 | if (javaType == String.class) { 43 | return STRING; 44 | } 45 | if (javaType == Byte.class || 46 | javaType == Short.class || 47 | javaType == Integer.class || 48 | javaType == Long.class || 49 | javaType == Double.class || 50 | javaType == Float.class) { 51 | return NUMBER; 52 | } 53 | 54 | if (javaType == Boolean.class) { 55 | return BOOLEAN; 56 | } 57 | 58 | if (javaType == java.util.Date.class || 59 | javaType == java.sql.Date.class || 60 | javaType == LocalDate.class) { 61 | return DATE; 62 | } 63 | return STRING; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/template/DefaultTemplateEngineer.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.template; 2 | 3 | import com.sparrow.utility.StringUtility; 4 | import com.sparrowzoo.coder.domain.bo.TableContext; 5 | import com.sparrowzoo.coder.domain.service.TemplateEngineer; 6 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 7 | import org.thymeleaf.TemplateEngine; 8 | import org.thymeleaf.context.Context; 9 | import org.thymeleaf.spring5.SpringTemplateEngine; 10 | import org.thymeleaf.spring5.dialect.SpringStandardDialect; 11 | import org.thymeleaf.templatemode.TemplateMode; 12 | import org.thymeleaf.templateresolver.StringTemplateResolver; 13 | 14 | import java.util.Map; 15 | 16 | public class DefaultTemplateEngineer implements TemplateEngineer { 17 | private final TemplateEngine templateEngine; 18 | 19 | public DefaultTemplateEngineer() { 20 | SpringTemplateEngine springTemplateEngine = new SpringTemplateEngine(); 21 | StringTemplateResolver templateResolver=new StringTemplateResolver(); 22 | templateResolver.setTemplateMode(TemplateMode.TEXT); 23 | springTemplateEngine.setTemplateResolver(templateResolver); 24 | springTemplateEngine.setDialect(new SpringStandardDialect()); 25 | springTemplateEngine.setEnableSpringELCompiler(true); 26 | this.templateEngine = springTemplateEngine; 27 | } 28 | 29 | @Override 30 | public String generate(String template, TableContext context, TableConfigRegistry registry) { 31 | String content = StringUtility.replace(template, context.getPlaceHolder()); 32 | Context ctx = new Context(); 33 | ctx.setVariable("ctx", content); 34 | ctx.setVariable("registry", registry); 35 | Map map = context.getPlaceHolder(); 36 | for (String key : map.keySet()) { 37 | ctx.setVariable(key.substring(1), map.get(key)); 38 | } 39 | Map data = context.getVariables(); 40 | for (String key : data.keySet()) { 41 | ctx.setVariable(key, data.get(key)); 42 | } 43 | return templateEngine.process(content, ctx); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /coder-dao-mybatis/src/main/resources/mybatis-config.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/registry/TableConfigRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.registry; 2 | 3 | import com.sparrow.utility.ClassUtility; 4 | import com.sparrow.utility.StringUtility; 5 | import com.sparrowzoo.coder.domain.bo.ProjectBO; 6 | import com.sparrowzoo.coder.domain.bo.TableConfigBO; 7 | import com.sparrowzoo.coder.domain.bo.TableContext; 8 | import lombok.Data; 9 | import lombok.extern.slf4j.Slf4j; 10 | 11 | import java.util.ArrayList; 12 | import java.util.HashMap; 13 | import java.util.List; 14 | import java.util.Map; 15 | 16 | /** 17 | * 考虑上线后多用户访问 18 | * 为防止内存溢出,这里使用临时变量,每次用户请求量初始化,使用后释放 19 | */ 20 | @Slf4j 21 | @Data 22 | public class TableConfigRegistry { 23 | public TableConfigRegistry(ProjectBO project) { 24 | this.project=project; 25 | this.registry=new HashMap<>(); 26 | } 27 | 28 | 29 | 30 | private Map registry; 31 | //封装project 维度变量,避免table context 引用registry循环依赖 32 | private ProjectBO project; 33 | 34 | private PlaceholderExtensionRegistry placeholderExtensionRegistry=PlaceholderExtensionRegistry.getInstance(); 35 | 36 | public void register(TableContext tableContext) { 37 | registry.put(tableContext.getTableConfig().getTableName(), tableContext); 38 | tableContext.getProject().addI18n(tableContext.getEntityManager().getSimpleClassName()); 39 | this.placeholderExtensionRegistry.extension(tableContext,this); 40 | } 41 | 42 | public void dependency(TableContext tableContext){ 43 | this.placeholderExtensionRegistry.dependencyExtension(tableContext,this); 44 | } 45 | public TableContext getTableContext(String tableName) { 46 | return registry.get(tableName); 47 | } 48 | 49 | public TableContext getFirstTableContext() { 50 | return registry.values().iterator().next(); 51 | } 52 | 53 | public List getAllTableConfig() { 54 | List tableConfigList = new ArrayList<>(); 55 | for (String tableName : this.registry.keySet()) { 56 | tableConfigList.add(this.registry.get(tableName).getTableConfig()); 57 | } 58 | return tableConfigList; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /coder-po/src/main/java/com/sparrowzoo/coder/po/UserExample.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.po; 2 | 3 | import com.sparrow.protocol.dao.ListDatasource; 4 | import com.sparrow.protocol.dao.PO; 5 | import com.sparrow.protocol.dao.enums.ListDatasourceType; 6 | import lombok.Data; 7 | 8 | import javax.persistence.*; 9 | import java.time.LocalDate; 10 | 11 | @Data 12 | @Table(name = "t_user_example") 13 | public class UserExample extends PO { 14 | @Id 15 | @GeneratedValue(strategy = GenerationType.IDENTITY) 16 | @Column(name = "id", columnDefinition = "int COMMENT 'ID'") 17 | private Long id; 18 | @Column(name = "user_name", nullable = false, columnDefinition = "varchar(32) COMMENT '用户名'") 19 | private String userName; 20 | 21 | @Column(name = "chinese_name", nullable = false, columnDefinition = "varchar(32) default '' comment '中文名'") 22 | private String chineseName; 23 | @Column(name = "birthday", nullable = false, columnDefinition = "date null comment '出生日期'") 24 | private LocalDate birthday; 25 | @Column(name = "email", nullable = false, unique = true, columnDefinition = "varchar(128) default '' comment 'Email'") 26 | private String email; 27 | 28 | @Column(name = "mobile", nullable = false, unique = true, columnDefinition = "varchar(128) default '' comment '手机号'") 29 | private String mobile; 30 | 31 | @Column(name = "tel", nullable = false, unique = true, columnDefinition = "varchar(128) default '' comment '电话号码'") 32 | private String tel; 33 | 34 | @Column(name = "id_card", nullable = false, unique = true, columnDefinition = "varchar(128) default '' comment '身份证'") 35 | private String idCard; 36 | 37 | @Column(name = "gender", nullable = false, unique = true, columnDefinition = "int not null default 999 comment '性别'") 38 | @ListDatasource(type = ListDatasourceType.ENUM, params = "gender") 39 | private Integer gender; 40 | 41 | @Column(name = "age", nullable = false, unique = true, columnDefinition = "int not null default 0 comment '年龄'") 42 | private Integer age; 43 | 44 | @Column(name = "project_id", nullable = false, columnDefinition = "int comment '项目'") 45 | @ListDatasource(type = ListDatasourceType.TABLE, params = "t_project_config") 46 | private Long projectId; 47 | } 48 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/clear/assemble.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | package $package_assemble; 3 | 4 | import com.sparrow.protocol.ListRecordTotalBO; 5 | import com.sparrow.protocol.KeyValue; 6 | import com.sparrow.protocol.pager.PagerResult; 7 | import com.sparrow.protocol.pager.SimplePager; 8 | import $package_dto.$persistence_class_nameDTO; 9 | import $package_bo.$persistence_class_nameBO; 10 | import com.sparrow.utility.CollectionsUtility; 11 | import java.util.*; 12 | import javax.inject.*; 13 | import com.sparrow.protocol.BeanCopier; 14 | 15 | 16 | @Named 17 | public class $persistence_class_nameAssemble{ 18 | 19 | @Inject 20 | private BeanCopier beanCopier; 21 | 22 | public $persistence_class_nameDTO boAssembleDTO($persistence_class_nameBO bo) { 23 | $persistence_class_nameDTO $persistence_object_name = new $persistence_class_nameDTO(); 24 | beanCopier.copyProperties(bo, $persistence_object_name); 25 | $persistence_object_name.setStatus(bo.getStatus().getIdentity()); 26 | return $persistence_object_name; 27 | } 28 | 29 | public List<$persistence_class_nameDTO> boListAssembleDTOList(List<$persistence_class_nameBO> list) { 30 | if (CollectionsUtility.isNullOrEmpty(list)) { 31 | return Collections.emptyList(); 32 | } 33 | List<$persistence_class_nameDTO> $persistence_object_nameDTOList = new ArrayList<>(list.size()); 34 | for ($persistence_class_nameBO $persistence_object_nameBo : list) { 35 | $persistence_object_nameDTOList.add(this.boAssembleDTO($persistence_object_nameBo)); 36 | } 37 | return $persistence_object_nameDTOList; 38 | } 39 | 40 | public PagerResult<$persistence_class_nameDTO> assemblePager(ListRecordTotalBO<$persistence_class_nameBO> $persistence_object_nameListTotalRecord, 41 | SimplePager $persistence_object_nameQuery) { 42 | List<$persistence_class_nameDTO> $persistence_object_nameDTOList = this.boListAssembleDTOList($persistence_object_nameListTotalRecord.getList()); 43 | PagerResult<$persistence_class_nameDTO> pagerResult = new PagerResult<>($persistence_object_nameQuery); 44 | pagerResult.setList($persistence_object_nameDTOList); 45 | pagerResult.setRecordTotal($persistence_object_nameListTotalRecord.getTotal()); 46 | return pagerResult; 47 | } 48 | 49 | } 50 | -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/moke/beans/MockProjectConfigRepository.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.moke.beans; 2 | 3 | import com.sparrowzoo.coder.domain.bo.ProjectConfigBO; 4 | import com.sparrowzoo.coder.protocol.param.ProjectConfigParam; 5 | import com.sparrowzoo.coder.protocol.query.ProjectConfigQuery; 6 | import com.sparrowzoo.coder.repository.ProjectConfigRepository; 7 | 8 | import javax.inject.Named; 9 | import java.util.List; 10 | import java.util.Set; 11 | 12 | @Named 13 | public class MockProjectConfigRepository implements ProjectConfigRepository { 14 | @Override 15 | public Long save(ProjectConfigParam projectConfigParam) { 16 | return null; 17 | } 18 | 19 | @Override 20 | public Integer delete(Set projectConfigIds) { 21 | return null; 22 | } 23 | 24 | @Override 25 | public Integer disable(Set projectConfigIds) { 26 | return null; 27 | } 28 | 29 | @Override 30 | public Integer enable(Set projectConfigIds) { 31 | return null; 32 | } 33 | 34 | @Override 35 | public ProjectConfigBO getProjectConfig(Long projectConfigId) { 36 | ProjectConfigBO projectConfig = new ProjectConfigBO(); 37 | projectConfig.setWrapWithParent(false); 38 | projectConfig.setFrontendName("react-next-admin"); 39 | projectConfig.setChineseName("代码生成器模拟"); 40 | projectConfig.setModulePrefix("coder"); 41 | projectConfig.setDescription("代码生成器模拟"); 42 | projectConfig.setI18n(true); 43 | projectConfig.setId(1L); 44 | projectConfig.setName("sparrow-coder"); 45 | projectConfig.setArchitectures("{\"FRONTEND\":\"react\",\"DATABASE\":\"mysql\",\"BACKEND\":\"clear\"}"); 46 | 47 | projectConfig.setConfig(""); 48 | projectConfig.setCreateUserId(1L); 49 | projectConfig.setModifiedUserId(1L); 50 | projectConfig.setGmtCreate(0L); 51 | projectConfig.setGmtModified(0L); 52 | projectConfig.setCreateUserName("harry"); 53 | projectConfig.setModifiedUserName("harry"); 54 | return projectConfig; 55 | } 56 | 57 | @Override 58 | public List queryProjectConfigs(ProjectConfigQuery projectConfigQuery) { 59 | return null; 60 | } 61 | 62 | @Override 63 | public Long getProjectConfigCount(ProjectConfigQuery projectConfigQuery) { 64 | return null; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/template/TemplateEngineerProvider.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.domain.service.template; 19 | 20 | import com.sparrowzoo.coder.domain.service.TemplateEngineer; 21 | 22 | import java.util.Iterator; 23 | import java.util.ServiceLoader; 24 | 25 | public class TemplateEngineerProvider { 26 | private static final String DEFAULT_PROVIDER = "com.sparrowzoo.coder.domain.service.template.DefaultTemplateEngineer"; 27 | private volatile static TemplateEngineer engineer; 28 | 29 | public static TemplateEngineer getEngineer() { 30 | if (engineer != null) { 31 | return engineer; 32 | } 33 | synchronized (TemplateEngineer.class) { 34 | if (engineer != null) { 35 | return engineer; 36 | } 37 | 38 | ServiceLoader loader = ServiceLoader.load(TemplateEngineer.class); 39 | Iterator it = loader.iterator(); 40 | if (it.hasNext()) { 41 | engineer = it.next(); 42 | return engineer; 43 | } 44 | 45 | try { 46 | Class jsonClazz = Class.forName(DEFAULT_PROVIDER); 47 | engineer = (TemplateEngineer) jsonClazz.newInstance(); 48 | return engineer; 49 | } catch (Exception x) { 50 | throw new RuntimeException( 51 | "Provider " + DEFAULT_PROVIDER + " could not be instantiated: " + x, 52 | x); 53 | } 54 | } 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/registry/ValidatorRegistry.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.registry; 2 | 3 | import com.sparrow.protocol.KeyValue; 4 | import com.sparrow.utility.ClassUtility; 5 | import com.sparrowzoo.coder.domain.service.ValidatorMessageGenerator; 6 | 7 | import java.util.ArrayList; 8 | import java.util.HashMap; 9 | import java.util.List; 10 | import java.util.Map; 11 | 12 | public class ValidatorRegistry { 13 | 14 | /** 15 | * key: namespace 16 | * value: Map 17 | */ 18 | private Map> registry; 19 | 20 | private ValidatorRegistry() { 21 | registry = new HashMap<>(); 22 | } 23 | 24 | static class Inner { 25 | private static ValidatorRegistry validatorRegistry = new ValidatorRegistry(); 26 | } 27 | 28 | 29 | public void registry(ValidatorMessageGenerator validatorMessageGenerator) { 30 | String packageName = validatorMessageGenerator.getClass().getPackage().getName(); 31 | String namespace = packageName.substring(packageName.lastIndexOf(".") + 1); 32 | String validatorName = ClassUtility.getBeanNameByClass(validatorMessageGenerator.getClass(), ValidatorMessageGenerator.class); 33 | if (!this.registry.containsKey(namespace)) { 34 | this.registry.putIfAbsent(namespace, new HashMap<>()); 35 | } 36 | this.registry.get(namespace).put(validatorName, validatorMessageGenerator); 37 | } 38 | 39 | public ValidatorMessageGenerator getValidatorMessageGenerator(String namespace, 40 | String validatorName) { 41 | return this.registry.get(namespace).get(validatorName); 42 | } 43 | 44 | public Map> getRegistry() { 45 | return registry; 46 | } 47 | 48 | public static ValidatorRegistry getInstance() { 49 | return Inner.validatorRegistry; 50 | } 51 | 52 | public List> getValidatorNames(String namespace) { 53 | Map validators = this.registry.get(namespace); 54 | List> list = new ArrayList<>(); 55 | for (String validatorName : validators.keySet()) { 56 | list.add(new KeyValue<>(validatorName, validatorName)); 57 | } 58 | return list; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/test/java/com/sparrow/spring/labmda/StringPool.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by FernFlower decompiler) 4 | // 5 | 6 | package com.sparrow.spring.labmda; 7 | 8 | public interface StringPool { 9 | String AMPERSAND = "&"; 10 | String AND = "and"; 11 | String AT = "@"; 12 | String ASTERISK = "*"; 13 | String STAR = "*"; 14 | String BACK_SLASH = "\\"; 15 | String COLON = ":"; 16 | String COMMA = ","; 17 | String DASH = "-"; 18 | String DOLLAR = "$"; 19 | String DOT = "."; 20 | String DOTDOT = ".."; 21 | String DOT_CLASS = ".class"; 22 | String DOT_JAVA = ".java"; 23 | String DOT_XML = ".xml"; 24 | String EMPTY = ""; 25 | String EQUALS = "="; 26 | String FALSE = "false"; 27 | String SLASH = "/"; 28 | String HASH = "#"; 29 | String HAT = "^"; 30 | String LEFT_BRACE = "{"; 31 | String LEFT_BRACKET = "("; 32 | String LEFT_CHEV = "<"; 33 | String DOT_NEWLINE = ",\n"; 34 | String NEWLINE = "\n"; 35 | String N = "n"; 36 | String NO = "no"; 37 | String NULL = "null"; 38 | String NUM = "NUM"; 39 | String OFF = "off"; 40 | String ON = "on"; 41 | String PERCENT = "%"; 42 | String PIPE = "|"; 43 | String PLUS = "+"; 44 | String QUESTION_MARK = "?"; 45 | String EXCLAMATION_MARK = "!"; 46 | String QUOTE = "\""; 47 | String RETURN = "\r"; 48 | String TAB = "\t"; 49 | String RIGHT_BRACE = "}"; 50 | String RIGHT_BRACKET = ")"; 51 | String RIGHT_CHEV = ">"; 52 | String SEMICOLON = ";"; 53 | String SINGLE_QUOTE = "'"; 54 | String BACKTICK = "`"; 55 | String SPACE = " "; 56 | String SQL = "sql"; 57 | String TILDA = "~"; 58 | String LEFT_SQ_BRACKET = "["; 59 | String RIGHT_SQ_BRACKET = "]"; 60 | String TRUE = "true"; 61 | String UNDERSCORE = "_"; 62 | String UTF_8 = "UTF-8"; 63 | String US_ASCII = "US-ASCII"; 64 | String ISO_8859_1 = "ISO-8859-1"; 65 | String Y = "y"; 66 | String YES = "yes"; 67 | String ONE = "1"; 68 | String ZERO = "0"; 69 | String DOLLAR_LEFT_BRACE = "${"; 70 | String HASH_LEFT_BRACE = "#{"; 71 | String CRLF = "\r\n"; 72 | String HTML_NBSP = " "; 73 | String HTML_AMP = "&"; 74 | String HTML_QUOTE = """; 75 | String HTML_LT = "<"; 76 | String HTML_GT = ">"; 77 | String[] EMPTY_ARRAY = new String[0]; 78 | byte[] BYTES_NEW_LINE = "\n".getBytes(); 79 | } 80 | -------------------------------------------------------------------------------- /coder-spring-starter/src/test/java/com/sparrow/spring/labmda/StringPool.java: -------------------------------------------------------------------------------- 1 | // 2 | // Source code recreated from a .class file by IntelliJ IDEA 3 | // (powered by FernFlower decompiler) 4 | // 5 | 6 | package com.sparrow.spring.labmda; 7 | 8 | public interface StringPool { 9 | String AMPERSAND = "&"; 10 | String AND = "and"; 11 | String AT = "@"; 12 | String ASTERISK = "*"; 13 | String STAR = "*"; 14 | String BACK_SLASH = "\\"; 15 | String COLON = ":"; 16 | String COMMA = ","; 17 | String DASH = "-"; 18 | String DOLLAR = "$"; 19 | String DOT = "."; 20 | String DOTDOT = ".."; 21 | String DOT_CLASS = ".class"; 22 | String DOT_JAVA = ".java"; 23 | String DOT_XML = ".xml"; 24 | String EMPTY = ""; 25 | String EQUALS = "="; 26 | String FALSE = "false"; 27 | String SLASH = "/"; 28 | String HASH = "#"; 29 | String HAT = "^"; 30 | String LEFT_BRACE = "{"; 31 | String LEFT_BRACKET = "("; 32 | String LEFT_CHEV = "<"; 33 | String DOT_NEWLINE = ",\n"; 34 | String NEWLINE = "\n"; 35 | String N = "n"; 36 | String NO = "no"; 37 | String NULL = "null"; 38 | String NUM = "NUM"; 39 | String OFF = "off"; 40 | String ON = "on"; 41 | String PERCENT = "%"; 42 | String PIPE = "|"; 43 | String PLUS = "+"; 44 | String QUESTION_MARK = "?"; 45 | String EXCLAMATION_MARK = "!"; 46 | String QUOTE = "\""; 47 | String RETURN = "\r"; 48 | String TAB = "\t"; 49 | String RIGHT_BRACE = "}"; 50 | String RIGHT_BRACKET = ")"; 51 | String RIGHT_CHEV = ">"; 52 | String SEMICOLON = ";"; 53 | String SINGLE_QUOTE = "'"; 54 | String BACKTICK = "`"; 55 | String SPACE = " "; 56 | String SQL = "sql"; 57 | String TILDA = "~"; 58 | String LEFT_SQ_BRACKET = "["; 59 | String RIGHT_SQ_BRACKET = "]"; 60 | String TRUE = "true"; 61 | String UNDERSCORE = "_"; 62 | String UTF_8 = "UTF-8"; 63 | String US_ASCII = "US-ASCII"; 64 | String ISO_8859_1 = "ISO-8859-1"; 65 | String Y = "y"; 66 | String YES = "yes"; 67 | String ONE = "1"; 68 | String ZERO = "0"; 69 | String DOLLAR_LEFT_BRACE = "${"; 70 | String HASH_LEFT_BRACE = "#{"; 71 | String CRLF = "\r\n"; 72 | String HTML_NBSP = " "; 73 | String HTML_AMP = "&"; 74 | String HTML_QUOTE = """; 75 | String HTML_LT = "<"; 76 | String HTML_GT = ">"; 77 | String[] EMPTY_ARRAY = new String[0]; 78 | byte[] BYTES_NEW_LINE = "\n".getBytes(); 79 | } 80 | -------------------------------------------------------------------------------- /coder-domain/src/main/java/com/sparrowzoo/coder/domain/service/backend/architecture/ClearArchitectureGenerator.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.domain.service.backend.architecture; 2 | 3 | import com.sparrowzoo.coder.constant.ArchitectureNames; 4 | import com.sparrowzoo.coder.domain.bo.TableConfigBO; 5 | import com.sparrowzoo.coder.domain.bo.TableContext; 6 | import com.sparrowzoo.coder.domain.service.AbstractArchitectureGenerator; 7 | import com.sparrowzoo.coder.domain.service.backend.ClassGenerator; 8 | import com.sparrowzoo.coder.domain.service.registry.TableConfigRegistry; 9 | import com.sparrowzoo.coder.enums.ArchitectureCategory; 10 | import com.sparrowzoo.coder.enums.ClassKey; 11 | import com.sparrowzoo.coder.enums.CodeSource; 12 | 13 | import javax.inject.Named; 14 | import java.io.IOException; 15 | 16 | @Named 17 | public class ClearArchitectureGenerator extends AbstractArchitectureGenerator { 18 | 19 | @Override 20 | public void generate(TableConfigRegistry registry, String tableName) throws IOException { 21 | TableContext context = registry.getTableContext(tableName); 22 | ClassGenerator classGenerator =context.getClassGenerator(); 23 | TableConfigBO tableConfig = context.getTableConfig(); 24 | if (CodeSource.SOURCE_CODE.getIdentity().equals(tableConfig.getSource())) { 25 | classGenerator.generate(ClassKey.PO,registry); 26 | } 27 | classGenerator.generate(ClassKey.BO,registry); 28 | classGenerator.generate(ClassKey.QUERY,registry); 29 | classGenerator.generate(ClassKey.PARAM,registry); 30 | classGenerator.generate(ClassKey.DTO,registry); 31 | classGenerator.generate(ClassKey.DAO,registry); 32 | classGenerator.generate(ClassKey.DAO_IMPL,registry); 33 | classGenerator.generate(ClassKey.DAO_MYBATIS,registry); 34 | classGenerator.generate(ClassKey.DATA_CONVERTER,registry); 35 | classGenerator.generate(ClassKey.SERVICE,registry); 36 | classGenerator.generate(ClassKey.REPOSITORY,registry); 37 | classGenerator.generate(ClassKey.REPOSITORY_IMPL,registry); 38 | classGenerator.generate(ClassKey.ASSEMBLE,registry); 39 | classGenerator.generate(ClassKey.CONTROLLER,registry); 40 | classGenerator.generate(ClassKey.PAGER_QUERY,registry); 41 | } 42 | 43 | @Override 44 | public ArchitectureCategory getCategory() { 45 | return ArchitectureCategory.BACKEND; 46 | } 47 | 48 | @Override 49 | public String getName() { 50 | return ArchitectureNames.CLEAR; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /coder-spring-starter/src/main/java/com/sparrowzoo/coder/boot/config/CoderKnife4jConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.boot.config; 19 | 20 | import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; 21 | import org.springframework.context.annotation.Bean; 22 | import org.springframework.context.annotation.Configuration; 23 | import springfox.documentation.builders.ApiInfoBuilder; 24 | import springfox.documentation.builders.PathSelectors; 25 | import springfox.documentation.builders.RequestHandlerSelectors; 26 | import springfox.documentation.service.ApiInfo; 27 | import springfox.documentation.service.Contact; 28 | import springfox.documentation.spi.DocumentationType; 29 | import springfox.documentation.spring.web.plugins.Docket; 30 | import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; 31 | 32 | @Configuration 33 | //@ConditionalOnProperty(prefix = "sparrow", name = "profile", havingValue = "dev") 34 | @EnableSwagger2WebMvc 35 | public class CoderKnife4jConfiguration { 36 | @Bean 37 | @ConditionalOnMissingBean(ApiInfo.class) 38 | public ApiInfo apiInfo() { 39 | return new ApiInfoBuilder().title("Sparrow Community").description("Sparrow Community").termsOfServiceUrl("www.sparrowzoo.com").contact(new Contact("harry", "http://www.sparrowzoo.com", "zh_harry@163.com")).version("1.0").build(); 40 | } 41 | 42 | @Bean 43 | public Docket coderDocket(ApiInfo apiInfo) { 44 | return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo).groupName("代码生成器").select().apis( 45 | RequestHandlerSelectors.basePackage("com.sparrowzoo.coder.adapter.controller") 46 | ).paths(PathSelectors.any()).build(); 47 | } 48 | } -------------------------------------------------------------------------------- /coder-domain/src/main/resources/react/search.txt: -------------------------------------------------------------------------------- 1 | overwrite 2 | import * as React from "react"; 3 | import {useState} from "react"; 4 | import {$persistence_class_name} from "@/components/$persistence_object_by_horizontal/columns"; 5 | import {MyTableMeta,SimplePager, TableOperationProps} from "@/common/lib/table/DataTableProperty"; 6 | import {Button} from "@/components/ui/button"; 7 | import $persistence_class_nameApi from "@/api/auto/$persistence_object_by_horizontal"; 8 | import {useTranslations} from "next-intl"; 9 | import SearchInput from "@/common/components/forms/search-input"; 10 | import SearchSelect from "@/common/components/forms/search-select"; 11 | import {PaginationState} from "@tanstack/table-core/src/features/RowPagination"; 12 | import useNavigating from "@/common/hook/NavigatingHook"; 13 | 14 | 15 | interface $persistence_class_nameQuery extends SimplePager{ 16 | $frontend_query_fields 17 | } 18 | 19 | export default function Search({table}: TableOperationProps<$persistence_class_name>) { 20 | const meta = table.options.meta as MyTableMeta<$persistence_class_name>; 21 | const errorTranslate = useTranslations("$persistence_class_name.ErrorMessage") 22 | const pageTranslate = useTranslations("$persistence_class_name") 23 | const globalTranslate = useTranslations("GlobalForm"); 24 | const setDataState = meta.setData; 25 | const [$persistence_object_nameQuery, set$persistence_class_nameQuery] = useState<$persistence_class_nameQuery>({} as $persistence_class_nameQuery) 26 | const Navigations=useNavigating(); 27 | 28 | if (setDataState == null) { 29 | return <>setDataState is not defined 30 | } 31 | 32 | const searchHandler = (page?: PaginationState) => { 33 | if (!page) { 34 | page = {pageIndex: 0, pageSize: table.getState().pagination.pageSize} 35 | table.setPagination(page); 36 | } 37 | $persistence_object_nameQuery.pageNo = page?.pageIndex; 38 | $persistence_object_nameQuery.pageSize = page?.pageSize; 39 | $persistence_class_nameApi.search($persistence_object_nameQuery, errorTranslate,Navigations.redirectToLogin).then( 40 | (res) => { 41 | setDataState(res) 42 | } 43 | ).catch(() => { 44 | }); 45 | }; 46 | meta.searchHandler=searchHandler; 47 | 48 | 49 | return (

50 | $frontend_search_items 51 | 52 |
53 | ); 54 | } 55 | -------------------------------------------------------------------------------- /coder-domain/src/test/resources/application.properties: -------------------------------------------------------------------------------- 1 | #mac 2 | #workspace=/Users/zhanglizhi/workspace 3 | #project_root=sparrow 4 | #frontend_project_root=sparrow.sparrow-js 5 | 6 | 7 | #windows 8 | project_root= 9 | frontend_project_root=sparrow-js 10 | workspace=D:\\workspace\\sparrow\\sparrowzoo\\ 11 | 12 | multi_user=false 13 | sparrow.captcha.service=redis 14 | sparrow.cors.allow=true 15 | sparrow.cors.allowed-origins=http://www.sparrowzoo.com,http://passport.sparrowzoo.com,http://localhost:3000,http://localhost:3001,http://192.168.1.14:3000,http://192.168.1.14:3001 16 | sparrow.authenticator.mock-login-user=true 17 | sparrow.authenticator.encrypt-key=123456 18 | sparrow.authenticator.validate-device-id=false 19 | sparrow.authenticator.validate-status=false 20 | sparrow.authenticator.exclude-patterns=/doc.html,/webjars/*,/swagger-resources,/v2/api-docs,/chat/v2/get-visitor-token.json,/chat/v2/login.json,/chat/v2/long-login.json,/chat/v2/parse-token.json,/password/send-find-password-email.json,/password/reset-password-by-token.json,/password/token-verify,/register/email/shortcut.json,/qun/plaza.json,/shortcut-login.json,/login,/register,/login-dialog,/captcha,/error 21 | sparrow.authenticator.platform=2 22 | sparrow.authenticator.login-token-available-days=0.001 23 | sparrow.authenticator.remember-me-days=15 24 | 25 | sparrow.mvc.ajax-pattens=*.json,/api/* 26 | sparrow.mvc.support-template-engine=true 27 | sparrow.mvc.auto-mapping-view-names=/login,/register,/login-dialog,/password/find,/error 28 | sparrow.mvc.root-path=http://localhost:8888 29 | sparrow.mvc.passport=http://localhost:3000 30 | sparrow.mvc.resource=http://r.sparrowzoo.net 31 | sparrow.mvc.physical_resource=/Users/zhanglizhi/workspace/sparrow/sparrow-js/source 32 | sparrow.mvc.resource-version=1.0.5 33 | sparrow.mvc.internationalization=zh_cn,en 34 | sparrow.mvc.language=zh_cn 35 | sparrow.mvc.upload=http://u.sparrowzoo.net 36 | sparrow.mvc.physical_upload=/Users/zhanglizhi/upload 37 | sparrow.email.enabled=true 38 | sparrow.email.host=smtp.exmail.qq.com 39 | sparrow.email.from=server@sparrowzoo.com 40 | sparrow.email.username=server@sparrowzoo.com 41 | sparrow.email.local_address=127.0.0.1 42 | sparrow.email.debug-password=true 43 | 44 | sparrow.data-source.default-schema=sparrow 45 | sparrow.data-source.password-key=mysql_sparrow_password 46 | sparrow.data-source.debug-datasource-password=true 47 | 48 | sparrow.enums.coder=com.sparrowzoo.coder.enums.CellType\ 49 | ,com.sparrowzoo.coder.enums.HeaderType\ 50 | ,com.sparrowzoo.coder.enums.DatasourceType\ 51 | ,com.sparrowzoo.coder.enums.ColumnType\ 52 | ,com.sparrowzoo.coder.enums.SearchType 53 | sparrow.enums.business=com.sparrowzoo.coder.enums.CellType 54 | 55 | -------------------------------------------------------------------------------- /coder-domain/src/main/resources/config.properties: -------------------------------------------------------------------------------- 1 | module.persistence=$module_prefix-po 2 | module.parent.admin=admin 3 | module.admin.adapter=$module_prefix-admin-adapter 4 | module.admin.dao.api=$module_prefix-admin-dao-api 5 | module.admin.domain=$module_prefix-admin-domain 6 | module.admin.infrastructure=$module_prefix-admin-infrastructure 7 | module.admin.main.boot=$module_prefix-admin-main-spring-boot 8 | module.admin.protocol=$module_prefix-admin-protocol 9 | module.admin.dao.sparrow=$module_prefix-admin-dao-sparrow 10 | module.admin.dao.mybatis=$module_prefix-admin-dao-mybatis 11 | 12 | 13 | 14 | package.po=po 15 | package.bo=admin.domain.bo 16 | package.query=admin.protocol.query 17 | package.param=admin.protocol.param 18 | package.dto=admin.protocol.dto 19 | package.dao=admin.dao 20 | package.service=admin.domain.service 21 | package.dao_impl=admin.dao.sparrow 22 | package.dao_mybatis=admin.dao.mybatis 23 | package.repository_impl=admin.infrastructure.persistence 24 | package.repository=admin.repository 25 | package.controller=admin.adapter.controller 26 | package.assemble=admin.adapter.assemble 27 | package.data_converter=admin.infrastructure.persistence.data.converter 28 | package.pager_query=admin.dao.query 29 | package.batch_operate_param=admin.protocol.param.batch 30 | 31 | 32 | class.po=$persistence_class_name 33 | class.assemble=$persistence_class_nameAssemble 34 | class.query=$persistence_class_nameQuery 35 | class.bo=$persistence_class_nameBO 36 | class.param=$persistence_class_nameParam 37 | class.dto=$persistence_class_nameDTO 38 | class.dao=$persistence_class_nameDAO 39 | class.repository=$persistence_class_nameRepository 40 | class.repository_impl=$persistence_class_nameRepositoryImpl 41 | class.service=$persistence_class_nameService 42 | class.dao_impl=$persistence_class_nameDaoImpl 43 | class.dao_mybatis=$persistence_class_nameMapper 44 | class.controller=$persistence_class_nameController 45 | class.data_converter=$persistence_class_nameConverter 46 | class.pager_query=$persistence_class_nameDBPagerQuery 47 | class.batch_operate_param=$persistence_class_nameBatchOperateParam 48 | 49 | page=src.app.(i18n).[locale].$persistence_object_by_horizontal.page.tsx 50 | api=src.api.auto.$persistence_object_by_horizontal.ts 51 | add=src.components.$persistence_object_by_horizontal.add.tsx 52 | edit=src.components.$persistence_object_by_horizontal.edit.tsx 53 | search=src.components.$persistence_object_by_horizontal.search.tsx 54 | operation=src.components.$persistence_object_by_horizontal.operation.tsx 55 | columns=src.components.$persistence_object_by_horizontal.columns.tsx 56 | schema=src.schema.$persistence_object_by_horizontal.ts 57 | message=messages.$persistence_class_name.zh.json 58 | message_file_list=messages.list.json 59 | 60 | 61 | -------------------------------------------------------------------------------- /coder-domain/src/test/java/com/sparrowzoo/coder/spel/CodeGenerator.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * 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 | 18 | package com.sparrowzoo.coder.spel; 19 | 20 | import org.thymeleaf.TemplateEngine; 21 | import org.thymeleaf.context.Context; 22 | import org.thymeleaf.spring5.SpringTemplateEngine; 23 | import org.thymeleaf.spring5.dialect.SpringStandardDialect; 24 | import org.thymeleaf.templatemode.TemplateMode; 25 | import org.thymeleaf.templateresolver.StringTemplateResolver; 26 | 27 | public class CodeGenerator { 28 | public static void main(String[] args) { 29 | CodeGenerator generator = new CodeGenerator(); 30 | System.out.println(generator.generateEntity(String.class)); 31 | } 32 | 33 | private final TemplateEngine templateEngine; 34 | 35 | public CodeGenerator() { 36 | SpringTemplateEngine springTemplateEngine = new SpringTemplateEngine(); 37 | StringTemplateResolver templateResolver= new StringTemplateResolver(); 38 | templateResolver.setTemplateMode(TemplateMode.RAW); 39 | springTemplateEngine.setTemplateResolver(templateResolver); 40 | springTemplateEngine.setDialect(new SpringStandardDialect()); 41 | springTemplateEngine.setEnableSpringELCompiler(true); 42 | this.templateEngine = springTemplateEngine; 43 | } 44 | 45 | public String generateEntity(Class clazz) { 46 | Context ctx = new Context(); 47 | ctx.setVariable("className", clazz.getSimpleName()); 48 | ctx.setVariable("fields", clazz.getDeclaredFields()); 49 | return templateEngine.process("\n" + 50 | "<>public [[${className}]] {\n" + 51 | "
\n" + 52 | " private \n" + 53 | " ;
}\n" 54 | , ctx); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /coder-domain/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | coder-bom 8 | 1.0.0-SNAPSHOT 9 | com.sparrowzoo.coder 10 | 11 | 12 | jar 13 | coder-domain 14 | 1.0.0-SNAPSHOT 15 | 16 | 17 | com.sparrowzoo 18 | sparrow 19 | 20 | 21 | com.sparrowzoo.coder 22 | coder-protocol 23 | 24 | 25 | com.sparrowzoo 26 | sparrow-orm 27 | 28 | 29 | com.sparrowzoo 30 | sparrow-json 31 | test 32 | 33 | 34 | com.sparrowzoo 35 | sparrow-starter 36 | 37 | 38 | org.springframework.boot 39 | spring-boot-starter-thymeleaf 40 | 41 | 42 | com.sparrowzoo.coder 43 | coder-po 44 | test 45 | 46 | 47 | com.sparrowzoo 48 | sparrow-container 49 | test 50 | 51 | 52 | org.springframework.boot 53 | spring-boot-starter-web 54 | 55 | 56 | com.sparrowzoo 57 | authenticator-monolithic-starter 58 | 59 | 60 | org.springframework.boot 61 | spring-boot-starter-test 62 | test 63 | 64 | 65 | javax.validation 66 | validation-api 67 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /coder-main-spring-boot/src/main/java/com/sparrowzoo/coder/boot/Application.java: -------------------------------------------------------------------------------- 1 | package com.sparrowzoo.coder.boot; 2 | 3 | import com.sparrow.container.Container; 4 | import com.sparrow.container.ContainerBuilder; 5 | import com.sparrow.core.spi.ApplicationContext; 6 | import com.sparrow.passport.config.EnablePassport; 7 | import com.sparrowzoo.coder.boot.config.EnableCoderApp; 8 | import lombok.extern.slf4j.Slf4j; 9 | import org.springframework.boot.SpringApplication; 10 | import org.springframework.boot.autoconfigure.SpringBootApplication; 11 | import org.springframework.boot.context.event.ApplicationStartingEvent; 12 | import org.springframework.context.ApplicationListener; 13 | import org.springframework.context.event.ContextClosedEvent; 14 | import org.springframework.context.event.ContextRefreshedEvent; 15 | 16 | @SpringBootApplication(scanBasePackages = {"com.sparrowzoo.coder"}) 17 | @EnablePassport 18 | @EnableCoderApp 19 | @Slf4j 20 | //@MapperScan(basePackages = "com.sparrow.coder.dao") 21 | public class Application { 22 | public static void main(String[] args) { 23 | SpringApplication springApplication = new SpringApplication(Application.class); 24 | /** 25 | * 在spring 容器启动前 通过sparrow容器提供proxy 代理类反射加速 26 | * 27 | * 因为orm template 初始化时需要method accessor 提速 28 | */ 29 | springApplication.addListeners(new ApplicationListener() { 30 | @Override 31 | public void onApplicationEvent(ApplicationStartingEvent event) { 32 | Container container = ApplicationContext.getContainer(); 33 | //只提供proxy 代码类加速反射 34 | ContainerBuilder builder = new ContainerBuilder() 35 | //只扫描com.sparrow下的类 36 | .scanBasePackage("com.sparrowzoo.coder") 37 | .initController(false) 38 | .initSingletonBean(false) 39 | .initProxyBean(true) 40 | .initInterceptor(false); 41 | container.init(builder); 42 | } 43 | }); 44 | 45 | springApplication.addListeners(new ApplicationListener() { 46 | @Override 47 | public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) { 48 | log.info("application startup at {}", contextRefreshedEvent.getTimestamp()); 49 | } 50 | }); 51 | springApplication.addListeners(new ApplicationListener() { 52 | @Override 53 | public void onApplicationEvent(ContextClosedEvent contextClosedEvent) { 54 | log.info("application closed at at {}", contextClosedEvent.getTimestamp()); 55 | } 56 | }); 57 | springApplication.run(args); 58 | } 59 | } 60 | --------------------------------------------------------------------------------