diff --git a/pom.xml b/pom.xml index 57f052180..72fc30301 100644 --- a/pom.xml +++ b/pom.xml @@ -42,6 +42,7 @@ 29.0-jre 2.2.7.RELEASE 2.7 + 3.12.5 @@ -69,7 +70,6 @@ wings-slardar ${wings.version} - org.apache.shardingsphere @@ -87,6 +87,12 @@ spring-security-oauth2-autoconfigure ${spring-boot.version} + + + org.redisson + redisson-spring-data-22 + ${redisson.version} + com.google.guava diff --git a/readme.md b/readme.md index 4db4bfd64..1520cf22d 100644 --- a/readme.md +++ b/readme.md @@ -37,17 +37,39 @@ Wings是springboot的一个脚手架,没有魔法和定制,主要有以下 * [Apache ShardingSphere](https://shardingsphere.apache.org/index_zh.html) * [Jooq - 强类型 sql-mapping](https://www.jooq.org/) -## 0.2.命名风格 +## 0.2.编码风格 -使用`idea`作为开发`IDE`,可使用`code style`和`live templates`。 +使用`IntelliJIdea`作为开发`IDE`,可使用`code style`和`live templates`。 `wings-idea-style.xml`在`Setting/Editor/Code Style`导入。 -`wings-idea-live.xml`需要手动放到`$config/templates/`。 -参考 https://www.jetbrains.com/help/idea/sharing-live-templates.html +`wings-idea-live.xml`需要手动放到`$config/templates/`,没有则新建 * WIN `%HOMEPATH%\.IntelliJIdea2019.2\config` * LIN `~/.IntelliJIdea2019.2/config` * MAC `~/Library/Preferences/IntelliJIdea2019.2` + * MAC `~/Library/ApplicationSupport/JetBrains/IntelliJIdea2020.1` + +参考资料 + * [sharing-live-templates](https://www.jetbrains.com/help/idea/sharing-live-templates.html) + * [2020.1 and above versions](https://www.jetbrains.com/help/idea/tuning-the-ide.html#default-dirs) + * [2019.3.x and below versions](https://www.jetbrains.com/help/idea/2019.3/tuning-the-ide.html#default-dirs) + + +安装以下插件 + * .ignore - 和版本管理中ignore有关的。 + * CheckStyle - 代码质量 + * GeneateAllSetter - alt-enter 生成全部 po.setXxx("") + * Git Flow Integration - 集成了git-flow + * GitToolBox - 自动 fetch + * Grep Console - 控制台的日志分颜色显示和过滤 + * kotlin - 默认安装了 + * lombok - IntelliJ Lombok plugin + * Maven Helper - 帮助管理maven + * Quick File Preview - 单击快速浏览文件 + * Rainbow Brackets - 彩虹括号 + * Request mapper - 快速查找 mapping + * Statistic - 统计一下自己的代码 + * String Manipulation - 对字符串的各种操作和转换。 ### 0.2.1.Java风格,遵循标准的java规范,但**可读性优先**。 @@ -67,7 +89,7 @@ Wings是springboot的一个脚手架,没有魔法和定制,主要有以下 系统内有2种时间`系统时间`和`本地时间`,数据库和 java 映射上, - * `日期时间`,以`DATETIME`和`LocalDateTime`存储。 + * `日期时间`,以`DATETIME(3)`和`LocalDateTime`存储。 * `日期`,以`DATE`和`LocalDate`存储。 * `时间`,以`TIME`和`LocalTime`存储。 @@ -121,6 +143,16 @@ public interface TradeService { } ``` +### 0.2.8.枚举类和code/const值 + +在service层,要求强类型,所以code/const都以enum传递。 +通过自动java模板生成enum,通过*EnumUtil,转换。 + +在db层,以基本类型(int,varchar)读取和写入。 + +在用户层,以多国语形式显示枚举内容 + + ## 0.3.技术选型 技术选型,遵循Unix哲学,主要回答,`为什么`和`为什么不?` @@ -202,4 +234,26 @@ hostname cat /etc/hosts # 在localhost后面,填上 trydofors-Hackintosh.local 127.0.0.1 localhost trydofors-Hackintosh.local +``` + +### 002.工程中哪些参数是必须打开的 + +``` bash +# 找到所以开关文件 +find . -name 'wings-conditional-manager.properties' \ +| egrep -v -E 'target/|example/' + +./wings-slardar/src/main/resources/wings-conf/wings-conditional-manager.properties +./wings-faceless/src/main/resources/wings-conf/wings-conditional-manager.properties +./wings-silencer/src/main/resources/wings-conf/wings-conditional-manager.properties + +# 找到所false的开关 +find . -name 'wings-conditional-manager.properties' \ +| egrep -v -E 'target/|example/' \ +| xargs grep 'false' + +# 以下2个需要在flywave和enum时开启 +spring.wings.flywave.enabled=false +spring.wings.enumi18n.enabled=false + ``` \ No newline at end of file diff --git a/wings-example/pom.xml b/wings-example/pom.xml index fc95b030e..e1f50f2cd 100644 --- a/wings-example/pom.xml +++ b/wings-example/pom.xml @@ -22,6 +22,7 @@ true 2.2.7-SNAPSHOT + 2.9.2 1.8 UTF-8 UTF-8 @@ -52,6 +53,10 @@ pro.fessional wings-slardar + + org.apache.commons + commons-lang3 + commons-io commons-io @@ -62,32 +67,26 @@ org.springframework.boot - spring-boot-starter-thymeleaf + spring-boot-starter-cache - + + + + + + + + - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework.security - spring-security-messaging - - - org.springframework.boot - spring-boot-starter-cache - + + + + + + + + @@ -104,7 +103,23 @@ jooq-codegen true + + + io.springfox + springfox-swagger2 + ${swagger2.version} + + + io.springfox + springfox-swagger-ui + ${swagger2.version} + + + org.springframework.boot + spring-boot-starter-thymeleaf + test + org.springframework.boot spring-boot-starter-test diff --git a/wings-example/readme.md b/wings-example/readme.md index dd51750c4..36664c9b2 100644 --- a/wings-example/readme.md +++ b/wings-example/readme.md @@ -11,7 +11,6 @@ * 了解 `maven`,缺什么,补什么。 * 了解 `spring*`,`看官方文档,不要百度` x 3! * 了解 `mysql*`数据库,mysql,mariadb,percona - * 了解 `redis`缓存 ## 4.2.演示内容 diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/ErrorController.java b/wings-example/src/main/java/pro/fessional/wings/example/controller/ErrorController.java new file mode 100644 index 000000000..c49d0124c --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/controller/ErrorController.java @@ -0,0 +1,35 @@ +package pro.fessional.wings.example.controller; + +import lombok.extern.slf4j.Slf4j; +import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; +import org.springframework.web.bind.annotation.ControllerAdvice; +import org.springframework.web.bind.annotation.ExceptionHandler; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler; +import pro.fessional.mirana.data.DataResult; +import pro.fessional.mirana.data.R; + +/** + * @author trydofor + * @since 2020-06-21 + */ +@ControllerAdvice +@Slf4j +public class ErrorController extends ResponseEntityExceptionHandler { + + @ExceptionHandler(OAuth2Exception.class) + @ResponseBody + public DataResult handleOAuth2Exception(OAuth2Exception ex) { + String err = ex.toString(); + log.info("wings handle exception, oauth2 {}", err); + return R.ng(err); + } + + @ExceptionHandler(Exception.class) + @ResponseBody + public DataResult handleAnyException(Exception ex) { + String c = ex.getClass().getSimpleName(); + log.info("wings handle exception, " + c, ex); + return R.ng("unknown exception, " + c + ":" + ex.getMessage()); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/LoginController.java b/wings-example/src/main/java/pro/fessional/wings/example/controller/LoginController.java new file mode 100644 index 000000000..d6f9160aa --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/controller/LoginController.java @@ -0,0 +1,64 @@ +package pro.fessional.wings.example.controller; + +import lombok.Setter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.client.RestTemplate; +import pro.fessional.wings.slardar.security.WingsOAuth2xHelper; +import pro.fessional.wings.slardar.security.WingsTokenStore; +import pro.fessional.wings.slardar.servlet.TypedRequestUtil; + +import javax.servlet.http.HttpServletRequest; + +/** + * @author trydofor + * @since 2019-11-13 + */ +@Controller +public class LoginController { + + @Setter(onMethod = @__({@Autowired})) + private WingsOAuth2xHelper wingsOAuth2XHelper; + + @Setter(onMethod = @__({@Autowired})) + private WingsTokenStore wingsTokenStore; + + @Setter(onMethod = @__({@Autowired})) + private RestTemplate restTemplate; + + @Setter(onMethod = @__({@Value("${wings.oauth.token.url}")})) + private String oauthTokenUrl; + + @Setter(onMethod = @__({@Value("${wings.slardar.oauth2x.client.staff.client-id}")})) + private String oauthClientId; + + @PostMapping(value = {"/login.json"}) + @ResponseBody + public OAuth2AccessToken login(@RequestParam("username") String username, @RequestParam("password") String password) { + WingsOAuth2xHelper.Login info = new WingsOAuth2xHelper.Login(); + info.setLoginUrl(oauthTokenUrl); + info.setClientId(oauthClientId); // 必须配置中有,否则失败 + info.setUsername(username); + info.setPassword(password); + info.setOauthPasswordAlias("name_pass"); + info.setClientIdAlias("web_admin"); + info.setGrantTypeAlias("admin"); + //info.setAccessToken3rd("bac0c873-e1cc-4740-8b9b-a903dcaaedfe"); + + return wingsOAuth2XHelper.login(restTemplate, info); + } + + @RequestMapping(value = {"/logout.json"}) + @ResponseBody + public String logout(HttpServletRequest request) { + String accessToken = TypedRequestUtil.getAccessToken(request); + wingsOAuth2XHelper.logout(wingsTokenStore, accessToken); + return "logout " + accessToken; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestFlywaveController.java b/wings-example/src/main/java/pro/fessional/wings/example/controller/TestFlywaveController.java deleted file mode 100644 index 21f9b3a6b..000000000 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestFlywaveController.java +++ /dev/null @@ -1,82 +0,0 @@ -package pro.fessional.wings.example.controller; - -import lombok.Setter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.ResponseBody; -import pro.fessional.wings.faceless.flywave.SchemaJournalManager; -import pro.fessional.wings.faceless.flywave.SchemaRevisionManager; -import pro.fessional.wings.faceless.flywave.SchemaShardingManager; -import pro.fessional.wings.faceless.util.FlywaveRevisionScanner; - -import java.util.SortedMap; -/** - * @author trydofor - * @since 2019-06-30 - */ - -@Controller -public class TestFlywaveController { - - @Setter(onMethod = @__({@Autowired})) - private SchemaShardingManager schemaShardingManager; - @Setter(onMethod = @__({@Autowired})) - private SchemaRevisionManager schemaRevisionManager; - @Setter(onMethod = @__({@Autowired})) - private SchemaJournalManager schemaJournalManager; - - @RequestMapping("/flywave-revi.json") - @ResponseBody - public String flywaveRevi(@RequestParam("revi") long revi) { - StringBuilder sb = new StringBuilder(); - if (revi <= 20190512_01) { - sb.append("\n开始初始化"); - SortedMap sqls = FlywaveRevisionScanner.scanMaster(); - schemaRevisionManager.checkAndInitSql(sqls, 0, false); - sb.append("\n结束初始化"); - } - sb.append("\n开始执行版本=").append(revi); - schemaRevisionManager.publishRevision(revi, 0); - sb.append("\n开始执行版本=").append(revi); - return sb.toString(); - } - - @RequestMapping("/flywave-shard.json") - @ResponseBody - public String flywaveShard(@RequestParam("table") String table) { - StringBuilder sb = new StringBuilder(); - sb.append("\n开始分表=").append(table).append(",数量=2"); - schemaShardingManager.publishShard(table, 2); - sb.append("\n结束分表=").append(table).append(",数量=2"); - - sb.append("\n开始迁移数据=").append(table).append(",数量=2"); - schemaShardingManager.shardingData(table, true); - sb.append("\n结束迁移数据=").append(table).append(",数量=2"); - - return sb.toString(); - } - - @RequestMapping("/flywave-journal.json") - @ResponseBody - public String flywaveJournal(@RequestParam("table") String table, @RequestParam("enable") boolean enable) { - StringBuilder sb = new StringBuilder(); - - sb.append("\n开始初始化跟踪配置=").append(table); - - schemaJournalManager.checkAndInitDdl(table, 0); - sb.append("\n结束初始化跟踪配置=").append(table); - - // 开启关闭 - sb.append("\n开始更新追踪=").append(table); - schemaJournalManager.publishUpdate(table, enable, 0); - sb.append("\n结束更新追踪=").append(table); - - sb.append("\n开始删除追踪=").append(table); - schemaJournalManager.publishDelete(table, enable, 0); - sb.append("\n结束删除追踪=").append(table); - - return sb.toString(); - } -} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestOauth2Controller.java b/wings-example/src/main/java/pro/fessional/wings/example/controller/TestOauth2Controller.java deleted file mode 100644 index a9db2de51..000000000 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestOauth2Controller.java +++ /dev/null @@ -1,57 +0,0 @@ -package pro.fessional.wings.example.controller; - -import lombok.Setter; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.http.ResponseEntity; -import org.springframework.security.oauth2.common.OAuth2AccessToken; -import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; -import org.springframework.security.oauth2.provider.error.DefaultWebResponseExceptionTranslator; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.ExceptionHandler; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.client.RestTemplate; -import pro.fessional.wings.slardar.security.WingsOAuth2xLogin; - -import javax.servlet.http.HttpServletRequest; - -/** - * @author trydofor - * @since 2019-06-30 - */ - -@Controller -public class TestOauth2Controller { - - @Setter(onMethod = @__({@Autowired})) - private WingsOAuth2xLogin wingsOAuth2xLogin; - - - @RequestMapping("/oauth2.html") - @ResponseBody - public String oauth2() { - return "oauth2 ok"; - } - - @RequestMapping(value = {"/oauth2-login.html"}) - @ResponseBody - public OAuth2AccessToken restLogin() { - WingsOAuth2xLogin.Login info = new WingsOAuth2xLogin.Login(); - info.setLoginUrl("http://localhost:8081/oauth/token"); - info.setClientId("wings-slardar-id"); - info.setUsername("wings-slardar-user2"); - info.setPassword("wings-slardar-pass"); - info.setOauthPasswordAlias("passwordx"); - info.setClientIdAlias("cid"); - info.setGrantTypeAlias("gtp"); - info.setAccessToken3rd("bac0c873-e1cc-4740-8b9b-a903dcaaedfe"); - - OAuth2AccessToken login = wingsOAuth2xLogin.login(new RestTemplate(), info); - return login; - } - - @ExceptionHandler(Exception.class) - public ResponseEntity handleException(Exception e) throws Exception { - return new DefaultWebResponseExceptionTranslator().translate(e); - } -} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/UserController.java b/wings-example/src/main/java/pro/fessional/wings/example/controller/UserController.java new file mode 100644 index 000000000..2510b171e --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/controller/UserController.java @@ -0,0 +1,26 @@ +package pro.fessional.wings.example.controller; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; + +/** + * @author trydofor + * @since 2019-11-13 + */ +@Controller +public class UserController { + + + @RequestMapping("/index.json") + @ResponseBody + public String index() { + return "{'page':'/index.json'}"; + } + + @RequestMapping("/user/create.json") + @ResponseBody + public String userCreate() { + return "{'page':'/user/create.json'}"; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultCatalog.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultCatalog.java new file mode 100644 index 000000000..c3fb221f8 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultCatalog.java @@ -0,0 +1,39 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen; + + +import javax.annotation.Generated; + +import org.jooq.impl.CatalogImpl; + + +/** + * The catalog . + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4" + }, + date = "2020-06-16T04:24:41.100Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DefaultCatalog extends CatalogImpl { + + private static final long serialVersionUID = 662935846; + + /** + * The reference instance of + */ + public static final DefaultCatalog DEFAULT_CATALOG = new DefaultCatalog(); + + /** + * No further instances allowed + */ + private DefaultCatalog() { + super(""); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultSchema.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultSchema.java new file mode 100644 index 000000000..604ae8e2b --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/DefaultSchema.java @@ -0,0 +1,85 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen; + + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Catalog; +import org.jooq.Table; +import org.jooq.impl.SchemaImpl; + +import pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable; +import pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable; +import pro.fessional.wings.example.database.autogen.tables.WinUserTable; + + +/** + * The schema wings_0. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-17T04:49:52.095Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class DefaultSchema extends SchemaImpl { + + private static final long serialVersionUID = 355582991; + + /** + * The reference instance of + */ + public static final DefaultSchema DEFAULT_SCHEMA = new DefaultSchema(); + + /** + * The table win_auth_role. + */ + public final WinAuthRoleTable WinAuthRole = pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable.WinAuthRole; + + /** + * The table win_user. + */ + public final WinUserTable WinUser = pro.fessional.wings.example.database.autogen.tables.WinUserTable.WinUser; + + /** + * The table win_user_login. + */ + public final WinUserLoginTable WinUserLogin = pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable.WinUserLogin; + + /** + * No further instances allowed + */ + private DefaultSchema() { + super("", null); + } + + + @Override + public Catalog getCatalog() { + return DefaultCatalog.DEFAULT_CATALOG; + } + + @Override + public final List> getTables() { + List result = new ArrayList(); + result.addAll(getTables0()); + return result; + } + + private final List> getTables0() { + return Arrays.>asList( + WinAuthRoleTable.WinAuthRole, + WinUserTable.WinUser, + WinUserLoginTable.WinUserLogin); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/Tables.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/Tables.java new file mode 100644 index 000000000..7f4891f3f --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/Tables.java @@ -0,0 +1,43 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen; + + +import javax.annotation.Generated; + +import pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable; +import pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable; +import pro.fessional.wings.example.database.autogen.tables.WinUserTable; + + +/** + * Convenience access to all tables in + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-17T04:49:52.095Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class Tables { + + /** + * The table win_auth_role. + */ + public static final WinAuthRoleTable WinAuthRole = WinAuthRoleTable.WinAuthRole; + + /** + * The table win_user. + */ + public static final WinUserTable WinUser = WinUserTable.WinUser; + + /** + * The table win_user_login. + */ + public static final WinUserLoginTable WinUserLogin = WinUserLoginTable.WinUserLogin; +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinAuthRoleTable.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinAuthRoleTable.java new file mode 100644 index 000000000..10e4b7612 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinAuthRoleTable.java @@ -0,0 +1,193 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables; + + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.Row9; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; +import org.jooq.impl.TableImpl; + +import pro.fessional.wings.example.database.autogen.DefaultSchema; +import pro.fessional.wings.example.database.autogen.tables.records.WinAuthRoleRecord; +import pro.fessional.wings.faceless.convention.EmptyValue; +import pro.fessional.wings.faceless.service.lightid.LightIdAware; + + +/** + * The table wings_0.win_auth_role. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-17T11:00:12.242Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class WinAuthRoleTable extends TableImpl implements LightIdAware { + + private static final long serialVersionUID = 451215313; + + /** + * The reference instance of win_auth_role + */ + public static final WinAuthRoleTable WinAuthRole = new WinAuthRoleTable(); + public static final WinAuthRoleTable asS1 = WinAuthRole.as("s1"); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return WinAuthRoleRecord.class; + } + + /** + * The column win_auth_role.id. + */ + public final TableField Id = createField(DSL.name("id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "主键"); + + /** + * The column win_auth_role.create_dt. + */ + public final TableField CreateDt = createField(DSL.name("create_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP(3)", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "创建日时(系统)"); + + /** + * The column win_auth_role.modify_dt. + */ + public final TableField ModifyDt = createField(DSL.name("modify_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "修改日时(系统)"); + + /** + * The column win_auth_role.delete_dt. + */ + public final TableField DeleteDt = createField(DSL.name("delete_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "标记删除"); + + /** + * The column win_auth_role.commit_id. + */ + public final TableField CommitId = createField(DSL.name("commit_id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "提交id"); + + /** + * The column win_auth_role.role_type. + */ + public final TableField RoleType = createField(DSL.name("role_type"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "类型/40201##:financial|operation"); + + /** + * The column win_auth_role.role_name. + */ + public final TableField RoleName = createField(DSL.name("role_name"), org.jooq.impl.SQLDataType.VARCHAR(100).nullable(false), this, "名字"); + + /** + * The column win_auth_role.desc. + */ + public final TableField Desc = createField(DSL.name("desc"), org.jooq.impl.SQLDataType.VARCHAR(200).nullable(false).defaultValue(org.jooq.impl.DSL.inline("", org.jooq.impl.SQLDataType.VARCHAR)), this, "描述"); + + /** + * The column win_auth_role.auth_set. + */ + public final TableField AuthSet = createField(DSL.name("auth_set"), org.jooq.impl.SQLDataType.VARCHAR(3000).nullable(false), this, "权限集:authority#401####,逗号分割"); + + /** + * Create a win_auth_role table reference + */ + public WinAuthRoleTable() { + this(DSL.name("win_auth_role"), null); + } + + /** + * Create an aliased win_auth_role table reference + */ + public WinAuthRoleTable(String alias) { + this(DSL.name(alias), WinAuthRole); + } + + /** + * Create an aliased win_auth_role table reference + */ + public WinAuthRoleTable(Name alias) { + this(alias, WinAuthRole); + } + + private WinAuthRoleTable(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private WinAuthRoleTable(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("402/权限组(角色)")); + } + + @Override + public Schema getSchema() { + return DefaultSchema.DEFAULT_SCHEMA; + } + + @Override + public UniqueKey getPrimaryKey() { + return Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable.WinAuthRole, "KEY_win_auth_role_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable.WinAuthRole.Id); + } + + @Override + public List> getKeys() { + return Arrays.>asList( + Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable.WinAuthRole, "KEY_win_auth_role_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable.WinAuthRole.Id) + ); + } + + @Override + public WinAuthRoleTable as(String alias) { + return new WinAuthRoleTable(DSL.name(alias), this); + } + + @Override + public WinAuthRoleTable as(Name alias) { + return new WinAuthRoleTable(alias, this); + } + + /** + * Rename this table + */ + @Override + public WinAuthRoleTable rename(String name) { + return new WinAuthRoleTable(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public WinAuthRoleTable rename(Name name) { + return new WinAuthRoleTable(name, null); + } + + // ------------------------------------------------------------------------- + // Row9 type methods + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } + + /** + * The column delete_dt condition + */ + public final Condition onlyDiedData = DeleteDt.gt(EmptyValue.DATE_TIME); + public final Condition onlyLiveData = DeleteDt.eq(EmptyValue.DATE_TIME); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserLoginTable.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserLoginTable.java new file mode 100644 index 000000000..c6c3ba283 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserLoginTable.java @@ -0,0 +1,218 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables; + + +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.Row14; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; +import org.jooq.impl.TableImpl; + +import pro.fessional.wings.example.database.autogen.DefaultSchema; +import pro.fessional.wings.example.database.autogen.tables.records.WinUserLoginRecord; +import pro.fessional.wings.faceless.convention.EmptyValue; +import pro.fessional.wings.faceless.service.lightid.LightIdAware; + + +/** + * The table wings_0.win_user_login. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class WinUserLoginTable extends TableImpl implements LightIdAware { + + private static final long serialVersionUID = -1565425007; + + /** + * The reference instance of win_user_login + */ + public static final WinUserLoginTable WinUserLogin = new WinUserLoginTable(); + public static final WinUserLoginTable asA2 = WinUserLogin.as("a2"); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return WinUserLoginRecord.class; + } + + /** + * The column win_user_login.id. + */ + public final TableField Id = createField(DSL.name("id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "主键"); + + /** + * The column win_user_login.create_dt. + */ + public final TableField CreateDt = createField(DSL.name("create_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP(3)", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "创建日时(系统)"); + + /** + * The column win_user_login.modify_dt. + */ + public final TableField ModifyDt = createField(DSL.name("modify_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "修改日时(系统)"); + + /** + * The column win_user_login.delete_dt. + */ + public final TableField DeleteDt = createField(DSL.name("delete_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "标记删除"); + + /** + * The column win_user_login.commit_id. + */ + public final TableField CommitId = createField(DSL.name("commit_id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "提交id"); + + /** + * The column win_user_login.user_id. + */ + public final TableField UserId = createField(DSL.name("user_id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "客户id:win_user.id"); + + /** + * The column win_user_login.login_type. + */ + public final TableField LoginType = createField(DSL.name("login_type"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "登录类别/41201##:邮件|手机|微信|facebook"); + + /** + * The column win_user_login.login_name. + */ + public final TableField LoginName = createField(DSL.name("login_name"), org.jooq.impl.SQLDataType.VARCHAR(200).nullable(false), this, "登录名称"); + + /** + * The column win_user_login.login_pass. + */ + public final TableField LoginPass = createField(DSL.name("login_pass"), org.jooq.impl.SQLDataType.VARCHAR(200).nullable(false), this, "登录密码及算法,参考SpringSecurity格式"); + + /** + * The column win_user_login.login_salt. + */ + public final TableField LoginSalt = createField(DSL.name("login_salt"), org.jooq.impl.SQLDataType.VARCHAR(100).nullable(false).defaultValue(org.jooq.impl.DSL.inline("", org.jooq.impl.SQLDataType.VARCHAR)), this, "密码加盐"); + + /** + * The column win_user_login.login_para. + */ + public final TableField LoginPara = createField(DSL.name("login_para"), org.jooq.impl.SQLDataType.VARCHAR(2000).nullable(false), this, "登录参数:json格式的第三方参数"); + + /** + * The column win_user_login.auth_code. + */ + public final TableField AuthCode = createField(DSL.name("auth_code"), org.jooq.impl.SQLDataType.VARCHAR(50).nullable(false).defaultValue(org.jooq.impl.DSL.inline("", org.jooq.impl.SQLDataType.VARCHAR)), this, "长期的识别码"); + + /** + * The column win_user_login.bad_count. + */ + public final TableField BadCount = createField(DSL.name("bad_count"), org.jooq.impl.SQLDataType.INTEGER.nullable(false).defaultValue(org.jooq.impl.DSL.inline("0", org.jooq.impl.SQLDataType.INTEGER)), this, "错误次数"); + + /** + * The column win_user_login.status. + */ + public final TableField Status = createField(DSL.name("status"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "鉴权状态/41101##:同用户状态"); + + /** + * Create a win_user_login table reference + */ + public WinUserLoginTable() { + this(DSL.name("win_user_login"), null); + } + + /** + * Create an aliased win_user_login table reference + */ + public WinUserLoginTable(String alias) { + this(DSL.name(alias), WinUserLogin); + } + + /** + * Create an aliased win_user_login table reference + */ + public WinUserLoginTable(Name alias) { + this(alias, WinUserLogin); + } + + private WinUserLoginTable(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private WinUserLoginTable(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("412/用户登录")); + } + + @Override + public Schema getSchema() { + return DefaultSchema.DEFAULT_SCHEMA; + } + + @Override + public UniqueKey getPrimaryKey() { + return Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable.WinUserLogin, "KEY_win_user_login_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable.WinUserLogin.Id); + } + + @Override + public List> getKeys() { + return Arrays.>asList( + Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable.WinUserLogin, "KEY_win_user_login_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable.WinUserLogin.Id) + ); + } + + @Override + public WinUserLoginTable as(String alias) { + return new WinUserLoginTable(DSL.name(alias), this); + } + + @Override + public WinUserLoginTable as(Name alias) { + return new WinUserLoginTable(alias, this); + } + + /** + * Rename this table + */ + @Override + public WinUserLoginTable rename(String name) { + return new WinUserLoginTable(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public WinUserLoginTable rename(Name name) { + return new WinUserLoginTable(name, null); + } + + // ------------------------------------------------------------------------- + // Row14 type methods + // ------------------------------------------------------------------------- + + @Override + public Row14 fieldsRow() { + return (Row14) super.fieldsRow(); + } + + /** + * The column delete_dt condition + */ + public final Condition onlyDiedData = DeleteDt.gt(EmptyValue.DATE_TIME); + public final Condition onlyLiveData = DeleteDt.eq(EmptyValue.DATE_TIME); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserTable.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserTable.java new file mode 100644 index 000000000..bbeffe882 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/WinUserTable.java @@ -0,0 +1,224 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables; + + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.Arrays; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Condition; +import org.jooq.Field; +import org.jooq.Name; +import org.jooq.Row15; +import org.jooq.Schema; +import org.jooq.Table; +import org.jooq.TableField; +import org.jooq.UniqueKey; +import org.jooq.impl.DSL; +import org.jooq.impl.Internal; +import org.jooq.impl.TableImpl; + +import pro.fessional.wings.example.database.autogen.DefaultSchema; +import pro.fessional.wings.example.database.autogen.tables.records.WinUserRecord; +import pro.fessional.wings.faceless.convention.EmptyValue; +import pro.fessional.wings.faceless.service.lightid.LightIdAware; + + +/** + * The table wings_0.win_user. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-17T11:00:12.242Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +public class WinUserTable extends TableImpl implements LightIdAware { + + private static final long serialVersionUID = 1131736677; + + /** + * The reference instance of win_user + */ + public static final WinUserTable WinUser = new WinUserTable(); + public static final WinUserTable asZ7 = WinUser.as("z7"); + + /** + * The class holding records for this type + */ + @Override + public Class getRecordType() { + return WinUserRecord.class; + } + + /** + * The column win_user.id. + */ + public final TableField Id = createField(DSL.name("id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "主键"); + + /** + * The column win_user.create_dt. + */ + public final TableField CreateDt = createField(DSL.name("create_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.field("CURRENT_TIMESTAMP(3)", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "创建日时(系统)"); + + /** + * The column win_user.modify_dt. + */ + public final TableField ModifyDt = createField(DSL.name("modify_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "修改日时(系统)"); + + /** + * The column win_user.delete_dt. + */ + public final TableField DeleteDt = createField(DSL.name("delete_dt"), org.jooq.impl.SQLDataType.LOCALDATETIME.nullable(false).defaultValue(org.jooq.impl.DSL.inline("1000-01-01 00:00:00.000", org.jooq.impl.SQLDataType.LOCALDATETIME)), this, "标记删除"); + + /** + * The column win_user.commit_id. + */ + public final TableField CommitId = createField(DSL.name("commit_id"), org.jooq.impl.SQLDataType.BIGINT.nullable(false), this, "提交id"); + + /** + * The column win_user.name. + */ + public final TableField Name = createField(DSL.name("name"), org.jooq.impl.SQLDataType.VARCHAR(50).nullable(false), this, "名字"); + + /** + * The column win_user.gender. + */ + public final TableField Gender = createField(DSL.name("gender"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "性别/20101##"); + + /** + * The column win_user.birth. + */ + public final TableField Birth = createField(DSL.name("birth"), org.jooq.impl.SQLDataType.LOCALDATE.nullable(false), this, "生日"); + + /** + * The column win_user.avatar. + */ + public final TableField Avatar = createField(DSL.name("avatar"), org.jooq.impl.SQLDataType.VARCHAR(200).nullable(false), this, "头像"); + + /** + * The column win_user.country. + */ + public final TableField Country = createField(DSL.name("country"), org.jooq.impl.SQLDataType.CHAR(2).nullable(false), this, "国家/地区"); + + /** + * The column win_user.language. + */ + public final TableField Language = createField(DSL.name("language"), org.jooq.impl.SQLDataType.CHAR(5).nullable(false), this, "使用语言"); + + /** + * The column win_user.timezone. + */ + public final TableField Timezone = createField(DSL.name("timezone"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "所在时区"); + + /** + * The column win_user.auth_set. + */ + public final TableField AuthSet = createField(DSL.name("auth_set"), org.jooq.impl.SQLDataType.VARCHAR(2000).nullable(false).defaultValue(org.jooq.impl.DSL.inline("", org.jooq.impl.SQLDataType.VARCHAR)), this, "权限集:authority#401####,逗号分割"); + + /** + * The column win_user.role_set. + */ + public final TableField RoleSet = createField(DSL.name("role_set"), org.jooq.impl.SQLDataType.VARCHAR(1000).nullable(false).defaultValue(org.jooq.impl.DSL.inline("", org.jooq.impl.SQLDataType.VARCHAR)), this, "角色集:win_auth_role.id,逗号分割"); + + /** + * The column win_user.status. + */ + public final TableField Status = createField(DSL.name("status"), org.jooq.impl.SQLDataType.INTEGER.nullable(false), this, "用户状态/41101##"); + + /** + * Create a win_user table reference + */ + public WinUserTable() { + this(DSL.name("win_user"), null); + } + + /** + * Create an aliased win_user table reference + */ + public WinUserTable(String alias) { + this(DSL.name(alias), WinUser); + } + + /** + * Create an aliased win_user table reference + */ + public WinUserTable(Name alias) { + this(alias, WinUser); + } + + private WinUserTable(Name alias, Table aliased) { + this(alias, aliased, null); + } + + private WinUserTable(Name alias, Table aliased, Field[] parameters) { + super(alias, null, aliased, parameters, DSL.comment("411/用户")); + } + + @Override + public Schema getSchema() { + return DefaultSchema.DEFAULT_SCHEMA; + } + + @Override + public UniqueKey getPrimaryKey() { + return Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinUserTable.WinUser, "KEY_win_user_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinUserTable.WinUser.Id); + } + + @Override + public List> getKeys() { + return Arrays.>asList( + Internal.createUniqueKey(pro.fessional.wings.example.database.autogen.tables.WinUserTable.WinUser, "KEY_win_user_PRIMARY", pro.fessional.wings.example.database.autogen.tables.WinUserTable.WinUser.Id) + ); + } + + @Override + public WinUserTable as(String alias) { + return new WinUserTable(DSL.name(alias), this); + } + + @Override + public WinUserTable as(Name alias) { + return new WinUserTable(alias, this); + } + + /** + * Rename this table + */ + @Override + public WinUserTable rename(String name) { + return new WinUserTable(DSL.name(name), null); + } + + /** + * Rename this table + */ + @Override + public WinUserTable rename(Name name) { + return new WinUserTable(name, null); + } + + // ------------------------------------------------------------------------- + // Row15 type methods + // ------------------------------------------------------------------------- + + @Override + public Row15 fieldsRow() { + return (Row15) super.fieldsRow(); + } + + /** + * The column delete_dt condition + */ + public final Condition onlyDiedData = DeleteDt.gt(EmptyValue.DATE_TIME); + public final Condition onlyLiveData = DeleteDt.eq(EmptyValue.DATE_TIME); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinAuthRoleDao.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinAuthRoleDao.java new file mode 100644 index 000000000..fa6b4d706 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinAuthRoleDao.java @@ -0,0 +1,125 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.daos; + + +import org.jooq.Configuration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; +import pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinAuthRole; +import pro.fessional.wings.example.database.autogen.tables.records.WinAuthRoleRecord; +import pro.fessional.wings.faceless.database.common.WingsJooqDaoImpl; + +import javax.annotation.Generated; +import java.time.LocalDateTime; +import java.util.List; + + +/** + * The table wings_0.win_auth_role. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Repository +public class WinAuthRoleDao extends WingsJooqDaoImpl { + + /** + * Create a new WinAuthRoleDao without any configuration + */ + public WinAuthRoleDao() { + super(WinAuthRoleTable.WinAuthRole, WinAuthRoleTable.asS1, WinAuthRole.class); + } + + /** + * Create a new WinAuthRoleDao with an attached configuration + */ + @Autowired + public WinAuthRoleDao(Configuration configuration) { + super(WinAuthRoleTable.WinAuthRole, WinAuthRoleTable.asS1, WinAuthRole.class, configuration); + } + + @Override + public Long getId(WinAuthRole object) { + return object.getId(); + } + + /** + * Fetch records that have id IN (values) + */ + public List fetchById(Long... values) { + return fetch(WinAuthRoleTable.asS1.Id, values); + } + + /** + * Fetch a unique record that has id = value + */ + public WinAuthRole fetchOneById(Long value) { + return fetchOne(WinAuthRoleTable.asS1.Id, value); + } + + /** + * Fetch records that have create_dt IN (values) + */ + public List fetchByCreateDt(LocalDateTime... values) { + return fetch(WinAuthRoleTable.asS1.CreateDt, values); + } + + /** + * Fetch records that have modify_dt IN (values) + */ + public List fetchByModifyDt(LocalDateTime... values) { + return fetch(WinAuthRoleTable.asS1.ModifyDt, values); + } + + /** + * Fetch records that have delete_dt IN (values) + */ + public List fetchByDeleteDt(LocalDateTime... values) { + return fetch(WinAuthRoleTable.asS1.DeleteDt, values); + } + + /** + * Fetch records that have commit_id IN (values) + */ + public List fetchByCommitId(Long... values) { + return fetch(WinAuthRoleTable.asS1.CommitId, values); + } + + /** + * Fetch records that have role_type IN (values) + */ + public List fetchByRoleType(Integer... values) { + return fetch(WinAuthRoleTable.asS1.RoleType, values); + } + + /** + * Fetch records that have role_name IN (values) + */ + public List fetchByRoleName(String... values) { + return fetch(WinAuthRoleTable.asS1.RoleName, values); + } + + /** + * Fetch records that have desc IN (values) + */ + public List fetchByDesc(String... values) { + return fetch(WinAuthRoleTable.asS1.Desc, values); + } + + /** + * Fetch records that have auth_set IN (values) + */ + public List fetchByAuthSet(String... values) { + return fetch(WinAuthRoleTable.asS1.AuthSet, values); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserDao.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserDao.java new file mode 100644 index 000000000..f7ab69cec --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserDao.java @@ -0,0 +1,170 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.daos; + + +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Configuration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import pro.fessional.wings.example.database.autogen.tables.WinUserTable; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinUser; +import pro.fessional.wings.example.database.autogen.tables.records.WinUserRecord; +import pro.fessional.wings.faceless.database.common.WingsJooqDaoImpl; + + +/** + * The table wings_0.win_user. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Repository +public class WinUserDao extends WingsJooqDaoImpl { + + /** + * Create a new WinUserDao without any configuration + */ + public WinUserDao() { + super(WinUserTable.WinUser, WinUserTable.asZ7, WinUser.class); + } + + /** + * Create a new WinUserDao with an attached configuration + */ + @Autowired + public WinUserDao(Configuration configuration) { + super(WinUserTable.WinUser, WinUserTable.asZ7, WinUser.class, configuration); + } + + @Override + public Long getId(WinUser object) { + return object.getId(); + } + + /** + * Fetch records that have id IN (values) + */ + public List fetchById(Long... values) { + return fetch(WinUserTable.asZ7.Id, values); + } + + /** + * Fetch a unique record that has id = value + */ + public WinUser fetchOneById(Long value) { + return fetchOne(WinUserTable.asZ7.Id, value); + } + + /** + * Fetch records that have create_dt IN (values) + */ + public List fetchByCreateDt(LocalDateTime... values) { + return fetch(WinUserTable.asZ7.CreateDt, values); + } + + /** + * Fetch records that have modify_dt IN (values) + */ + public List fetchByModifyDt(LocalDateTime... values) { + return fetch(WinUserTable.asZ7.ModifyDt, values); + } + + /** + * Fetch records that have delete_dt IN (values) + */ + public List fetchByDeleteDt(LocalDateTime... values) { + return fetch(WinUserTable.asZ7.DeleteDt, values); + } + + /** + * Fetch records that have commit_id IN (values) + */ + public List fetchByCommitId(Long... values) { + return fetch(WinUserTable.asZ7.CommitId, values); + } + + /** + * Fetch records that have name IN (values) + */ + public List fetchByName(String... values) { + return fetch(WinUserTable.asZ7.Name, values); + } + + /** + * Fetch records that have gender IN (values) + */ + public List fetchByGender(Integer... values) { + return fetch(WinUserTable.asZ7.Gender, values); + } + + /** + * Fetch records that have birth IN (values) + */ + public List fetchByBirth(LocalDate... values) { + return fetch(WinUserTable.asZ7.Birth, values); + } + + /** + * Fetch records that have avatar IN (values) + */ + public List fetchByAvatar(String... values) { + return fetch(WinUserTable.asZ7.Avatar, values); + } + + /** + * Fetch records that have country IN (values) + */ + public List fetchByCountry(String... values) { + return fetch(WinUserTable.asZ7.Country, values); + } + + /** + * Fetch records that have language IN (values) + */ + public List fetchByLanguage(String... values) { + return fetch(WinUserTable.asZ7.Language, values); + } + + /** + * Fetch records that have timezone IN (values) + */ + public List fetchByTimezone(Integer... values) { + return fetch(WinUserTable.asZ7.Timezone, values); + } + + /** + * Fetch records that have auth_set IN (values) + */ + public List fetchByAuthSet(String... values) { + return fetch(WinUserTable.asZ7.AuthSet, values); + } + + /** + * Fetch records that have role_set IN (values) + */ + public List fetchByRoleSet(String... values) { + return fetch(WinUserTable.asZ7.RoleSet, values); + } + + /** + * Fetch records that have status IN (values) + */ + public List fetchByStatus(Integer... values) { + return fetch(WinUserTable.asZ7.Status, values); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserLoginDao.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserLoginDao.java new file mode 100644 index 000000000..9b1067863 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/daos/WinUserLoginDao.java @@ -0,0 +1,162 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.daos; + + +import java.time.LocalDateTime; +import java.util.List; + +import javax.annotation.Generated; + +import org.jooq.Configuration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Repository; + +import pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinUserLogin; +import pro.fessional.wings.example.database.autogen.tables.records.WinUserLoginRecord; +import pro.fessional.wings.faceless.database.common.WingsJooqDaoImpl; + + +/** + * The table wings_0.win_user_login. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Repository +public class WinUserLoginDao extends WingsJooqDaoImpl { + + /** + * Create a new WinUserLoginDao without any configuration + */ + public WinUserLoginDao() { + super(WinUserLoginTable.WinUserLogin, WinUserLoginTable.asA2, WinUserLogin.class); + } + + /** + * Create a new WinUserLoginDao with an attached configuration + */ + @Autowired + public WinUserLoginDao(Configuration configuration) { + super(WinUserLoginTable.WinUserLogin, WinUserLoginTable.asA2, WinUserLogin.class, configuration); + } + + @Override + public Long getId(WinUserLogin object) { + return object.getId(); + } + + /** + * Fetch records that have id IN (values) + */ + public List fetchById(Long... values) { + return fetch(WinUserLoginTable.asA2.Id, values); + } + + /** + * Fetch a unique record that has id = value + */ + public WinUserLogin fetchOneById(Long value) { + return fetchOne(WinUserLoginTable.asA2.Id, value); + } + + /** + * Fetch records that have create_dt IN (values) + */ + public List fetchByCreateDt(LocalDateTime... values) { + return fetch(WinUserLoginTable.asA2.CreateDt, values); + } + + /** + * Fetch records that have modify_dt IN (values) + */ + public List fetchByModifyDt(LocalDateTime... values) { + return fetch(WinUserLoginTable.asA2.ModifyDt, values); + } + + /** + * Fetch records that have delete_dt IN (values) + */ + public List fetchByDeleteDt(LocalDateTime... values) { + return fetch(WinUserLoginTable.asA2.DeleteDt, values); + } + + /** + * Fetch records that have commit_id IN (values) + */ + public List fetchByCommitId(Long... values) { + return fetch(WinUserLoginTable.asA2.CommitId, values); + } + + /** + * Fetch records that have user_id IN (values) + */ + public List fetchByUserId(Long... values) { + return fetch(WinUserLoginTable.asA2.UserId, values); + } + + /** + * Fetch records that have login_type IN (values) + */ + public List fetchByLoginType(Integer... values) { + return fetch(WinUserLoginTable.asA2.LoginType, values); + } + + /** + * Fetch records that have login_name IN (values) + */ + public List fetchByLoginName(String... values) { + return fetch(WinUserLoginTable.asA2.LoginName, values); + } + + /** + * Fetch records that have login_pass IN (values) + */ + public List fetchByLoginPass(String... values) { + return fetch(WinUserLoginTable.asA2.LoginPass, values); + } + + /** + * Fetch records that have login_salt IN (values) + */ + public List fetchByLoginSalt(String... values) { + return fetch(WinUserLoginTable.asA2.LoginSalt, values); + } + + /** + * Fetch records that have login_para IN (values) + */ + public List fetchByLoginPara(String... values) { + return fetch(WinUserLoginTable.asA2.LoginPara, values); + } + + /** + * Fetch records that have auth_code IN (values) + */ + public List fetchByAuthCode(String... values) { + return fetch(WinUserLoginTable.asA2.AuthCode, values); + } + + /** + * Fetch records that have bad_count IN (values) + */ + public List fetchByBadCount(Integer... values) { + return fetch(WinUserLoginTable.asA2.BadCount, values); + } + + /** + * Fetch records that have status IN (values) + */ + public List fetchByStatus(Integer... values) { + return fetch(WinUserLoginTable.asA2.Status, values); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinAuthRole.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinAuthRole.java new file mode 100644 index 000000000..c01c28866 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinAuthRole.java @@ -0,0 +1,162 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.interfaces; + + +import java.io.Serializable; +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import pro.fessional.wings.faceless.service.journal.JournalAware; + + +/** + * The table wings_0.win_auth_role. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_auth_role", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_auth_role_PRIMARY", columnNames = {"id"}) +}) +public interface IWinAuthRole extends JournalAware, Serializable { + + /** + * Setter for win_auth_role.id. + */ + public void setId(Long value); + + /** + * Getter for win_auth_role.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + public Long getId(); + + /** + * Setter for win_auth_role.create_dt. + */ + public void setCreateDt(LocalDateTime value); + + /** + * Getter for win_auth_role.create_dt. + */ + @Column(name = "create_dt", nullable = false) + public LocalDateTime getCreateDt(); + + /** + * Setter for win_auth_role.modify_dt. + */ + public void setModifyDt(LocalDateTime value); + + /** + * Getter for win_auth_role.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + public LocalDateTime getModifyDt(); + + /** + * Setter for win_auth_role.delete_dt. + */ + public void setDeleteDt(LocalDateTime value); + + /** + * Getter for win_auth_role.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + public LocalDateTime getDeleteDt(); + + /** + * Setter for win_auth_role.commit_id. + */ + public void setCommitId(Long value); + + /** + * Getter for win_auth_role.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + public Long getCommitId(); + + /** + * Setter for win_auth_role.role_type. + */ + public void setRoleType(Integer value); + + /** + * Getter for win_auth_role.role_type. + */ + @Column(name = "role_type", nullable = false, precision = 10) + @NotNull + public Integer getRoleType(); + + /** + * Setter for win_auth_role.role_name. + */ + public void setRoleName(String value); + + /** + * Getter for win_auth_role.role_name. + */ + @Column(name = "role_name", nullable = false, length = 100) + @NotNull + @Size(max = 100) + public String getRoleName(); + + /** + * Setter for win_auth_role.desc. + */ + public void setDesc(String value); + + /** + * Getter for win_auth_role.desc. + */ + @Column(name = "desc", nullable = false, length = 200) + @Size(max = 200) + public String getDesc(); + + /** + * Setter for win_auth_role.auth_set. + */ + public void setAuthSet(String value); + + /** + * Getter for win_auth_role.auth_set. + */ + @Column(name = "auth_set", nullable = false, length = 3000) + @NotNull + @Size(max = 3000) + public String getAuthSet(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IWinAuthRole + */ + public void from(pro.fessional.wings.example.database.autogen.tables.interfaces.IWinAuthRole from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IWinAuthRole + */ + public E into(E into); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUser.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUser.java new file mode 100644 index 000000000..79b87668f --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUser.java @@ -0,0 +1,236 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.interfaces; + + +import pro.fessional.wings.faceless.service.journal.JournalAware; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + + +/** + * The table wings_0.win_user. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_PRIMARY", columnNames = {"id"}) +}) +public interface IWinUser extends JournalAware, Serializable { + + /** + * Setter for win_user.id. + */ + public void setId(Long value); + + /** + * Getter for win_user.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + public Long getId(); + + /** + * Setter for win_user.create_dt. + */ + public void setCreateDt(LocalDateTime value); + + /** + * Getter for win_user.create_dt. + */ + @Column(name = "create_dt", nullable = false) + public LocalDateTime getCreateDt(); + + /** + * Setter for win_user.modify_dt. + */ + public void setModifyDt(LocalDateTime value); + + /** + * Getter for win_user.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + public LocalDateTime getModifyDt(); + + /** + * Setter for win_user.delete_dt. + */ + public void setDeleteDt(LocalDateTime value); + + /** + * Getter for win_user.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + public LocalDateTime getDeleteDt(); + + /** + * Setter for win_user.commit_id. + */ + public void setCommitId(Long value); + + /** + * Getter for win_user.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + public Long getCommitId(); + + /** + * Setter for win_user.name. + */ + public void setName(String value); + + /** + * Getter for win_user.name. + */ + @Column(name = "name", nullable = false, length = 50) + @NotNull + @Size(max = 50) + public String getName(); + + /** + * Setter for win_user.gender. + */ + public void setGender(Integer value); + + /** + * Getter for win_user.gender. + */ + @Column(name = "gender", nullable = false, precision = 10) + @NotNull + public Integer getGender(); + + /** + * Setter for win_user.birth. + */ + public void setBirth(LocalDate value); + + /** + * Getter for win_user.birth. + */ + @Column(name = "birth", nullable = false) + @NotNull + public LocalDate getBirth(); + + /** + * Setter for win_user.avatar. + */ + public void setAvatar(String value); + + /** + * Getter for win_user.avatar. + */ + @Column(name = "avatar", nullable = false, length = 200) + @NotNull + @Size(max = 200) + public String getAvatar(); + + /** + * Setter for win_user.country. + */ + public void setCountry(String value); + + /** + * Getter for win_user.country. + */ + @Column(name = "country", nullable = false, length = 2) + @NotNull + @Size(max = 2) + public String getCountry(); + + /** + * Setter for win_user.language. + */ + public void setLanguage(String value); + + /** + * Getter for win_user.language. + */ + @Column(name = "language", nullable = false, length = 5) + @NotNull + @Size(max = 5) + public String getLanguage(); + + /** + * Setter for win_user.timezone. + */ + public void setTimezone(Integer value); + + /** + * Getter for win_user.timezone. + */ + @Column(name = "timezone", nullable = false, precision = 10) + @NotNull + public Integer getTimezone(); + + /** + * Setter for win_user.auth_set. + */ + public void setAuthSet(String value); + + /** + * Getter for win_user.auth_set. + */ + @Column(name = "auth_set", nullable = false, length = 2000) + @Size(max = 2000) + public String getAuthSet(); + + /** + * Setter for win_user.role_set. + */ + public void setRoleSet(String value); + + /** + * Getter for win_user.role_set. + */ + @Column(name = "role_set", nullable = false, length = 1000) + @Size(max = 1000) + public String getRoleSet(); + + /** + * Setter for win_user.status. + */ + public void setStatus(Integer value); + + /** + * Getter for win_user.status. + */ + @Column(name = "status", nullable = false, precision = 10) + @NotNull + public Integer getStatus(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IWinUser + */ + public void from(pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUser from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IWinUser + */ + public E into(E into); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUserLogin.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUserLogin.java new file mode 100644 index 000000000..7ae3592ca --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/interfaces/IWinUserLogin.java @@ -0,0 +1,222 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.interfaces; + + +import java.io.Serializable; +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import pro.fessional.wings.faceless.service.journal.JournalAware; + + +/** + * The table wings_0.win_user_login. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user_login", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_login_PRIMARY", columnNames = {"id"}) +}) +public interface IWinUserLogin extends JournalAware, Serializable { + + /** + * Setter for win_user_login.id. + */ + public void setId(Long value); + + /** + * Getter for win_user_login.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + public Long getId(); + + /** + * Setter for win_user_login.create_dt. + */ + public void setCreateDt(LocalDateTime value); + + /** + * Getter for win_user_login.create_dt. + */ + @Column(name = "create_dt", nullable = false) + public LocalDateTime getCreateDt(); + + /** + * Setter for win_user_login.modify_dt. + */ + public void setModifyDt(LocalDateTime value); + + /** + * Getter for win_user_login.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + public LocalDateTime getModifyDt(); + + /** + * Setter for win_user_login.delete_dt. + */ + public void setDeleteDt(LocalDateTime value); + + /** + * Getter for win_user_login.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + public LocalDateTime getDeleteDt(); + + /** + * Setter for win_user_login.commit_id. + */ + public void setCommitId(Long value); + + /** + * Getter for win_user_login.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + public Long getCommitId(); + + /** + * Setter for win_user_login.user_id. + */ + public void setUserId(Long value); + + /** + * Getter for win_user_login.user_id. + */ + @Column(name = "user_id", nullable = false, precision = 19) + @NotNull + public Long getUserId(); + + /** + * Setter for win_user_login.login_type. + */ + public void setLoginType(Integer value); + + /** + * Getter for win_user_login.login_type. + */ + @Column(name = "login_type", nullable = false, precision = 10) + @NotNull + public Integer getLoginType(); + + /** + * Setter for win_user_login.login_name. + */ + public void setLoginName(String value); + + /** + * Getter for win_user_login.login_name. + */ + @Column(name = "login_name", nullable = false, length = 200) + @NotNull + @Size(max = 200) + public String getLoginName(); + + /** + * Setter for win_user_login.login_pass. + */ + public void setLoginPass(String value); + + /** + * Getter for win_user_login.login_pass. + */ + @Column(name = "login_pass", nullable = false, length = 200) + @NotNull + @Size(max = 200) + public String getLoginPass(); + + /** + * Setter for win_user_login.login_salt. + */ + public void setLoginSalt(String value); + + /** + * Getter for win_user_login.login_salt. + */ + @Column(name = "login_salt", nullable = false, length = 100) + @Size(max = 100) + public String getLoginSalt(); + + /** + * Setter for win_user_login.login_para. + */ + public void setLoginPara(String value); + + /** + * Getter for win_user_login.login_para. + */ + @Column(name = "login_para", nullable = false, length = 2000) + @NotNull + @Size(max = 2000) + public String getLoginPara(); + + /** + * Setter for win_user_login.auth_code. + */ + public void setAuthCode(String value); + + /** + * Getter for win_user_login.auth_code. + */ + @Column(name = "auth_code", nullable = false, length = 50) + @Size(max = 50) + public String getAuthCode(); + + /** + * Setter for win_user_login.bad_count. + */ + public void setBadCount(Integer value); + + /** + * Getter for win_user_login.bad_count. + */ + @Column(name = "bad_count", nullable = false, precision = 10) + public Integer getBadCount(); + + /** + * Setter for win_user_login.status. + */ + public void setStatus(Integer value); + + /** + * Getter for win_user_login.status. + */ + @Column(name = "status", nullable = false, precision = 10) + @NotNull + public Integer getStatus(); + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + /** + * Load data from another generated Record/POJO implementing the common interface IWinUserLogin + */ + public void from(pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUserLogin from); + + /** + * Copy data into another generated Record/POJO implementing the common interface IWinUserLogin + */ + public E into(E into); +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinAuthRole.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinAuthRole.java new file mode 100644 index 000000000..11cc17111 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinAuthRole.java @@ -0,0 +1,318 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.pojos; + + +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinAuthRole; + + +/** + * The table wings_0.win_auth_role. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_auth_role", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_auth_role_PRIMARY", columnNames = {"id"}) +}) +public class WinAuthRole implements IWinAuthRole { + + private static final long serialVersionUID = 957602074; + + private Long id; + private LocalDateTime createDt; + private LocalDateTime modifyDt; + private LocalDateTime deleteDt; + private Long commitId; + private Integer roleType; + private String roleName; + private String desc; + private String authSet; + + public WinAuthRole() {} + + public WinAuthRole(IWinAuthRole value) { + this.id = value.getId(); + this.createDt = value.getCreateDt(); + this.modifyDt = value.getModifyDt(); + this.deleteDt = value.getDeleteDt(); + this.commitId = value.getCommitId(); + this.roleType = value.getRoleType(); + this.roleName = value.getRoleName(); + this.desc = value.getDesc(); + this.authSet = value.getAuthSet(); + } + + public WinAuthRole( + Long id, + LocalDateTime createDt, + LocalDateTime modifyDt, + LocalDateTime deleteDt, + Long commitId, + Integer roleType, + String roleName, + String desc, + String authSet + ) { + this.id = id; + this.createDt = createDt; + this.modifyDt = modifyDt; + this.deleteDt = deleteDt; + this.commitId = commitId; + this.roleType = roleType; + this.roleName = roleName; + this.desc = desc; + this.authSet = authSet; + } + + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return this.id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return this.createDt; + } + + @Override + public void setCreateDt(LocalDateTime createDt) { + this.createDt = createDt; + } + + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return this.modifyDt; + } + + @Override + public void setModifyDt(LocalDateTime modifyDt) { + this.modifyDt = modifyDt; + } + + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return this.deleteDt; + } + + @Override + public void setDeleteDt(LocalDateTime deleteDt) { + this.deleteDt = deleteDt; + } + + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return this.commitId; + } + + @Override + public void setCommitId(Long commitId) { + this.commitId = commitId; + } + + @Column(name = "role_type", nullable = false, precision = 10) + @NotNull + @Override + public Integer getRoleType() { + return this.roleType; + } + + @Override + public void setRoleType(Integer roleType) { + this.roleType = roleType; + } + + @Column(name = "role_name", nullable = false, length = 100) + @NotNull + @Size(max = 100) + @Override + public String getRoleName() { + return this.roleName; + } + + @Override + public void setRoleName(String roleName) { + this.roleName = roleName; + } + + @Column(name = "desc", nullable = false, length = 200) + @Size(max = 200) + @Override + public String getDesc() { + return this.desc; + } + + @Override + public void setDesc(String desc) { + this.desc = desc; + } + + @Column(name = "auth_set", nullable = false, length = 3000) + @NotNull + @Size(max = 3000) + @Override + public String getAuthSet() { + return this.authSet; + } + + @Override + public void setAuthSet(String authSet) { + this.authSet = authSet; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final WinAuthRole other = (WinAuthRole) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (createDt == null) { + if (other.createDt != null) + return false; + } + else if (!createDt.equals(other.createDt)) + return false; + if (modifyDt == null) { + if (other.modifyDt != null) + return false; + } + else if (!modifyDt.equals(other.modifyDt)) + return false; + if (deleteDt == null) { + if (other.deleteDt != null) + return false; + } + else if (!deleteDt.equals(other.deleteDt)) + return false; + if (commitId == null) { + if (other.commitId != null) + return false; + } + else if (!commitId.equals(other.commitId)) + return false; + if (roleType == null) { + if (other.roleType != null) + return false; + } + else if (!roleType.equals(other.roleType)) + return false; + if (roleName == null) { + if (other.roleName != null) + return false; + } + else if (!roleName.equals(other.roleName)) + return false; + if (desc == null) { + if (other.desc != null) + return false; + } + else if (!desc.equals(other.desc)) + return false; + if (authSet == null) { + if (other.authSet != null) + return false; + } + else if (!authSet.equals(other.authSet)) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); + result = prime * result + ((this.createDt == null) ? 0 : this.createDt.hashCode()); + result = prime * result + ((this.modifyDt == null) ? 0 : this.modifyDt.hashCode()); + result = prime * result + ((this.deleteDt == null) ? 0 : this.deleteDt.hashCode()); + result = prime * result + ((this.commitId == null) ? 0 : this.commitId.hashCode()); + result = prime * result + ((this.roleType == null) ? 0 : this.roleType.hashCode()); + result = prime * result + ((this.roleName == null) ? 0 : this.roleName.hashCode()); + result = prime * result + ((this.desc == null) ? 0 : this.desc.hashCode()); + result = prime * result + ((this.authSet == null) ? 0 : this.authSet.hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("WinAuthRole ("); + + sb.append(id); + sb.append(", ").append(createDt); + sb.append(", ").append(modifyDt); + sb.append(", ").append(deleteDt); + sb.append(", ").append(commitId); + sb.append(", ").append(roleType); + sb.append(", ").append(roleName); + sb.append(", ").append(desc); + sb.append(", ").append(authSet); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinAuthRole from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setRoleType(from.getRoleType()); + setRoleName(from.getRoleName()); + setDesc(from.getDesc()); + setAuthSet(from.getAuthSet()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUser.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUser.java new file mode 100644 index 000000000..ae56d220b --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUser.java @@ -0,0 +1,471 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.pojos; + + +import java.time.LocalDate; +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUser; + + +/** + * The table wings_0.win_user. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_PRIMARY", columnNames = {"id"}) +}) +public class WinUser implements IWinUser { + + private static final long serialVersionUID = 278994491; + + private Long id; + private LocalDateTime createDt; + private LocalDateTime modifyDt; + private LocalDateTime deleteDt; + private Long commitId; + private String name; + private Integer gender; + private LocalDate birth; + private String avatar; + private String country; + private String language; + private Integer timezone; + private String authSet; + private String roleSet; + private Integer status; + + public WinUser() {} + + public WinUser(IWinUser value) { + this.id = value.getId(); + this.createDt = value.getCreateDt(); + this.modifyDt = value.getModifyDt(); + this.deleteDt = value.getDeleteDt(); + this.commitId = value.getCommitId(); + this.name = value.getName(); + this.gender = value.getGender(); + this.birth = value.getBirth(); + this.avatar = value.getAvatar(); + this.country = value.getCountry(); + this.language = value.getLanguage(); + this.timezone = value.getTimezone(); + this.authSet = value.getAuthSet(); + this.roleSet = value.getRoleSet(); + this.status = value.getStatus(); + } + + public WinUser( + Long id, + LocalDateTime createDt, + LocalDateTime modifyDt, + LocalDateTime deleteDt, + Long commitId, + String name, + Integer gender, + LocalDate birth, + String avatar, + String country, + String language, + Integer timezone, + String authSet, + String roleSet, + Integer status + ) { + this.id = id; + this.createDt = createDt; + this.modifyDt = modifyDt; + this.deleteDt = deleteDt; + this.commitId = commitId; + this.name = name; + this.gender = gender; + this.birth = birth; + this.avatar = avatar; + this.country = country; + this.language = language; + this.timezone = timezone; + this.authSet = authSet; + this.roleSet = roleSet; + this.status = status; + } + + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return this.id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return this.createDt; + } + + @Override + public void setCreateDt(LocalDateTime createDt) { + this.createDt = createDt; + } + + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return this.modifyDt; + } + + @Override + public void setModifyDt(LocalDateTime modifyDt) { + this.modifyDt = modifyDt; + } + + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return this.deleteDt; + } + + @Override + public void setDeleteDt(LocalDateTime deleteDt) { + this.deleteDt = deleteDt; + } + + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return this.commitId; + } + + @Override + public void setCommitId(Long commitId) { + this.commitId = commitId; + } + + @Column(name = "name", nullable = false, length = 50) + @NotNull + @Size(max = 50) + @Override + public String getName() { + return this.name; + } + + @Override + public void setName(String name) { + this.name = name; + } + + @Column(name = "gender", nullable = false, precision = 10) + @NotNull + @Override + public Integer getGender() { + return this.gender; + } + + @Override + public void setGender(Integer gender) { + this.gender = gender; + } + + @Column(name = "birth", nullable = false) + @NotNull + @Override + public LocalDate getBirth() { + return this.birth; + } + + @Override + public void setBirth(LocalDate birth) { + this.birth = birth; + } + + @Column(name = "avatar", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getAvatar() { + return this.avatar; + } + + @Override + public void setAvatar(String avatar) { + this.avatar = avatar; + } + + @Column(name = "country", nullable = false, length = 2) + @NotNull + @Size(max = 2) + @Override + public String getCountry() { + return this.country; + } + + @Override + public void setCountry(String country) { + this.country = country; + } + + @Column(name = "language", nullable = false, length = 5) + @NotNull + @Size(max = 5) + @Override + public String getLanguage() { + return this.language; + } + + @Override + public void setLanguage(String language) { + this.language = language; + } + + @Column(name = "timezone", nullable = false, precision = 10) + @NotNull + @Override + public Integer getTimezone() { + return this.timezone; + } + + @Override + public void setTimezone(Integer timezone) { + this.timezone = timezone; + } + + @Column(name = "auth_set", nullable = false, length = 2000) + @Size(max = 2000) + @Override + public String getAuthSet() { + return this.authSet; + } + + @Override + public void setAuthSet(String authSet) { + this.authSet = authSet; + } + + @Column(name = "role_set", nullable = false, length = 1000) + @Size(max = 1000) + @Override + public String getRoleSet() { + return this.roleSet; + } + + @Override + public void setRoleSet(String roleSet) { + this.roleSet = roleSet; + } + + @Column(name = "status", nullable = false, precision = 10) + @NotNull + @Override + public Integer getStatus() { + return this.status; + } + + @Override + public void setStatus(Integer status) { + this.status = status; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final WinUser other = (WinUser) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (createDt == null) { + if (other.createDt != null) + return false; + } + else if (!createDt.equals(other.createDt)) + return false; + if (modifyDt == null) { + if (other.modifyDt != null) + return false; + } + else if (!modifyDt.equals(other.modifyDt)) + return false; + if (deleteDt == null) { + if (other.deleteDt != null) + return false; + } + else if (!deleteDt.equals(other.deleteDt)) + return false; + if (commitId == null) { + if (other.commitId != null) + return false; + } + else if (!commitId.equals(other.commitId)) + return false; + if (name == null) { + if (other.name != null) + return false; + } + else if (!name.equals(other.name)) + return false; + if (gender == null) { + if (other.gender != null) + return false; + } + else if (!gender.equals(other.gender)) + return false; + if (birth == null) { + if (other.birth != null) + return false; + } + else if (!birth.equals(other.birth)) + return false; + if (avatar == null) { + if (other.avatar != null) + return false; + } + else if (!avatar.equals(other.avatar)) + return false; + if (country == null) { + if (other.country != null) + return false; + } + else if (!country.equals(other.country)) + return false; + if (language == null) { + if (other.language != null) + return false; + } + else if (!language.equals(other.language)) + return false; + if (timezone == null) { + if (other.timezone != null) + return false; + } + else if (!timezone.equals(other.timezone)) + return false; + if (authSet == null) { + if (other.authSet != null) + return false; + } + else if (!authSet.equals(other.authSet)) + return false; + if (roleSet == null) { + if (other.roleSet != null) + return false; + } + else if (!roleSet.equals(other.roleSet)) + return false; + if (status == null) { + if (other.status != null) + return false; + } + else if (!status.equals(other.status)) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); + result = prime * result + ((this.createDt == null) ? 0 : this.createDt.hashCode()); + result = prime * result + ((this.modifyDt == null) ? 0 : this.modifyDt.hashCode()); + result = prime * result + ((this.deleteDt == null) ? 0 : this.deleteDt.hashCode()); + result = prime * result + ((this.commitId == null) ? 0 : this.commitId.hashCode()); + result = prime * result + ((this.name == null) ? 0 : this.name.hashCode()); + result = prime * result + ((this.gender == null) ? 0 : this.gender.hashCode()); + result = prime * result + ((this.birth == null) ? 0 : this.birth.hashCode()); + result = prime * result + ((this.avatar == null) ? 0 : this.avatar.hashCode()); + result = prime * result + ((this.country == null) ? 0 : this.country.hashCode()); + result = prime * result + ((this.language == null) ? 0 : this.language.hashCode()); + result = prime * result + ((this.timezone == null) ? 0 : this.timezone.hashCode()); + result = prime * result + ((this.authSet == null) ? 0 : this.authSet.hashCode()); + result = prime * result + ((this.roleSet == null) ? 0 : this.roleSet.hashCode()); + result = prime * result + ((this.status == null) ? 0 : this.status.hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("WinUser ("); + + sb.append(id); + sb.append(", ").append(createDt); + sb.append(", ").append(modifyDt); + sb.append(", ").append(deleteDt); + sb.append(", ").append(commitId); + sb.append(", ").append(name); + sb.append(", ").append(gender); + sb.append(", ").append(birth); + sb.append(", ").append(avatar); + sb.append(", ").append(country); + sb.append(", ").append(language); + sb.append(", ").append(timezone); + sb.append(", ").append(authSet); + sb.append(", ").append(roleSet); + sb.append(", ").append(status); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinUser from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setName(from.getName()); + setGender(from.getGender()); + setBirth(from.getBirth()); + setAvatar(from.getAvatar()); + setCountry(from.getCountry()); + setLanguage(from.getLanguage()); + setTimezone(from.getTimezone()); + setAuthSet(from.getAuthSet()); + setRoleSet(from.getRoleSet()); + setStatus(from.getStatus()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUserLogin.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUserLogin.java new file mode 100644 index 000000000..7e7916e08 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/pojos/WinUserLogin.java @@ -0,0 +1,442 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.pojos; + + +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUserLogin; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; +import java.time.LocalDateTime; + + +/** + * The table wings_0.win_user_login. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user_login", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_login_PRIMARY", columnNames = {"id"}) +}) +public class WinUserLogin implements IWinUserLogin { + + private static final long serialVersionUID = 1712656304; + + private Long id; + private LocalDateTime createDt; + private LocalDateTime modifyDt; + private LocalDateTime deleteDt; + private Long commitId; + private Long userId; + private Integer loginType; + private String loginName; + private String loginPass; + private String loginSalt; + private String loginPara; + private String authCode; + private Integer badCount; + private Integer status; + + public WinUserLogin() {} + + public WinUserLogin(IWinUserLogin value) { + this.id = value.getId(); + this.createDt = value.getCreateDt(); + this.modifyDt = value.getModifyDt(); + this.deleteDt = value.getDeleteDt(); + this.commitId = value.getCommitId(); + this.userId = value.getUserId(); + this.loginType = value.getLoginType(); + this.loginName = value.getLoginName(); + this.loginPass = value.getLoginPass(); + this.loginSalt = value.getLoginSalt(); + this.loginPara = value.getLoginPara(); + this.authCode = value.getAuthCode(); + this.badCount = value.getBadCount(); + this.status = value.getStatus(); + } + + public WinUserLogin( + Long id, + LocalDateTime createDt, + LocalDateTime modifyDt, + LocalDateTime deleteDt, + Long commitId, + Long userId, + Integer loginType, + String loginName, + String loginPass, + String loginSalt, + String loginPara, + String authCode, + Integer badCount, + Integer status + ) { + this.id = id; + this.createDt = createDt; + this.modifyDt = modifyDt; + this.deleteDt = deleteDt; + this.commitId = commitId; + this.userId = userId; + this.loginType = loginType; + this.loginName = loginName; + this.loginPass = loginPass; + this.loginSalt = loginSalt; + this.loginPara = loginPara; + this.authCode = authCode; + this.badCount = badCount; + this.status = status; + } + + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return this.id; + } + + @Override + public void setId(Long id) { + this.id = id; + } + + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return this.createDt; + } + + @Override + public void setCreateDt(LocalDateTime createDt) { + this.createDt = createDt; + } + + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return this.modifyDt; + } + + @Override + public void setModifyDt(LocalDateTime modifyDt) { + this.modifyDt = modifyDt; + } + + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return this.deleteDt; + } + + @Override + public void setDeleteDt(LocalDateTime deleteDt) { + this.deleteDt = deleteDt; + } + + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return this.commitId; + } + + @Override + public void setCommitId(Long commitId) { + this.commitId = commitId; + } + + @Column(name = "user_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getUserId() { + return this.userId; + } + + @Override + public void setUserId(Long userId) { + this.userId = userId; + } + + @Column(name = "login_type", nullable = false, precision = 10) + @NotNull + @Override + public Integer getLoginType() { + return this.loginType; + } + + @Override + public void setLoginType(Integer loginType) { + this.loginType = loginType; + } + + @Column(name = "login_name", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getLoginName() { + return this.loginName; + } + + @Override + public void setLoginName(String loginName) { + this.loginName = loginName; + } + + @Column(name = "login_pass", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getLoginPass() { + return this.loginPass; + } + + @Override + public void setLoginPass(String loginPass) { + this.loginPass = loginPass; + } + + @Column(name = "login_salt", nullable = false, length = 100) + @Size(max = 100) + @Override + public String getLoginSalt() { + return this.loginSalt; + } + + @Override + public void setLoginSalt(String loginSalt) { + this.loginSalt = loginSalt; + } + + @Column(name = "login_para", nullable = false, length = 2000) + @NotNull + @Size(max = 2000) + @Override + public String getLoginPara() { + return this.loginPara; + } + + @Override + public void setLoginPara(String loginPara) { + this.loginPara = loginPara; + } + + @Column(name = "auth_code", nullable = false, length = 50) + @Size(max = 50) + @Override + public String getAuthCode() { + return this.authCode; + } + + @Override + public void setAuthCode(String authCode) { + this.authCode = authCode; + } + + @Column(name = "bad_count", nullable = false, precision = 10) + @Override + public Integer getBadCount() { + return this.badCount; + } + + @Override + public void setBadCount(Integer badCount) { + this.badCount = badCount; + } + + @Column(name = "status", nullable = false, precision = 10) + @NotNull + @Override + public Integer getStatus() { + return this.status; + } + + @Override + public void setStatus(Integer status) { + this.status = status; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + final WinUserLogin other = (WinUserLogin) obj; + if (id == null) { + if (other.id != null) + return false; + } + else if (!id.equals(other.id)) + return false; + if (createDt == null) { + if (other.createDt != null) + return false; + } + else if (!createDt.equals(other.createDt)) + return false; + if (modifyDt == null) { + if (other.modifyDt != null) + return false; + } + else if (!modifyDt.equals(other.modifyDt)) + return false; + if (deleteDt == null) { + if (other.deleteDt != null) + return false; + } + else if (!deleteDt.equals(other.deleteDt)) + return false; + if (commitId == null) { + if (other.commitId != null) + return false; + } + else if (!commitId.equals(other.commitId)) + return false; + if (userId == null) { + if (other.userId != null) + return false; + } + else if (!userId.equals(other.userId)) + return false; + if (loginType == null) { + if (other.loginType != null) + return false; + } + else if (!loginType.equals(other.loginType)) + return false; + if (loginName == null) { + if (other.loginName != null) + return false; + } + else if (!loginName.equals(other.loginName)) + return false; + if (loginPass == null) { + if (other.loginPass != null) + return false; + } + else if (!loginPass.equals(other.loginPass)) + return false; + if (loginSalt == null) { + if (other.loginSalt != null) + return false; + } + else if (!loginSalt.equals(other.loginSalt)) + return false; + if (loginPara == null) { + if (other.loginPara != null) + return false; + } + else if (!loginPara.equals(other.loginPara)) + return false; + if (authCode == null) { + if (other.authCode != null) + return false; + } + else if (!authCode.equals(other.authCode)) + return false; + if (badCount == null) { + if (other.badCount != null) + return false; + } + else if (!badCount.equals(other.badCount)) + return false; + if (status == null) { + if (other.status != null) + return false; + } + else if (!status.equals(other.status)) + return false; + return true; + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((this.id == null) ? 0 : this.id.hashCode()); + result = prime * result + ((this.createDt == null) ? 0 : this.createDt.hashCode()); + result = prime * result + ((this.modifyDt == null) ? 0 : this.modifyDt.hashCode()); + result = prime * result + ((this.deleteDt == null) ? 0 : this.deleteDt.hashCode()); + result = prime * result + ((this.commitId == null) ? 0 : this.commitId.hashCode()); + result = prime * result + ((this.userId == null) ? 0 : this.userId.hashCode()); + result = prime * result + ((this.loginType == null) ? 0 : this.loginType.hashCode()); + result = prime * result + ((this.loginName == null) ? 0 : this.loginName.hashCode()); + result = prime * result + ((this.loginPass == null) ? 0 : this.loginPass.hashCode()); + result = prime * result + ((this.loginSalt == null) ? 0 : this.loginSalt.hashCode()); + result = prime * result + ((this.loginPara == null) ? 0 : this.loginPara.hashCode()); + result = prime * result + ((this.authCode == null) ? 0 : this.authCode.hashCode()); + result = prime * result + ((this.badCount == null) ? 0 : this.badCount.hashCode()); + result = prime * result + ((this.status == null) ? 0 : this.status.hashCode()); + return result; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("WinUserLogin ("); + + sb.append(id); + sb.append(", ").append(createDt); + sb.append(", ").append(modifyDt); + sb.append(", ").append(deleteDt); + sb.append(", ").append(commitId); + sb.append(", ").append(userId); + sb.append(", ").append(loginType); + sb.append(", ").append(loginName); + sb.append(", ").append(loginPass); + sb.append(", ").append(loginSalt); + sb.append(", ").append(loginPara); + sb.append(", ").append(authCode); + sb.append(", ").append(badCount); + sb.append(", ").append(status); + + sb.append(")"); + return sb.toString(); + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinUserLogin from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setUserId(from.getUserId()); + setLoginType(from.getLoginType()); + setLoginName(from.getLoginName()); + setLoginPass(from.getLoginPass()); + setLoginSalt(from.getLoginSalt()); + setLoginPara(from.getLoginPara()); + setAuthCode(from.getAuthCode()); + setBadCount(from.getBadCount()); + setStatus(from.getStatus()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinAuthRoleRecord.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinAuthRoleRecord.java new file mode 100644 index 000000000..a8d3f8abb --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinAuthRoleRecord.java @@ -0,0 +1,487 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.records; + + +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record9; +import org.jooq.Row9; +import org.jooq.impl.UpdatableRecordImpl; + +import pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable; +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinAuthRole; + + +/** + * The table wings_0.win_auth_role. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_auth_role", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_auth_role_PRIMARY", columnNames = {"id"}) +}) +public class WinAuthRoleRecord extends UpdatableRecordImpl implements Record9, IWinAuthRole { + + private static final long serialVersionUID = -2111176306; + + /** + * Setter for win_auth_role.id. + */ + @Override + public void setId(Long value) { + set(0, value); + } + + /** + * Getter for win_auth_role.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return (Long) get(0); + } + + /** + * Setter for win_auth_role.create_dt. + */ + @Override + public void setCreateDt(LocalDateTime value) { + set(1, value); + } + + /** + * Getter for win_auth_role.create_dt. + */ + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return (LocalDateTime) get(1); + } + + /** + * Setter for win_auth_role.modify_dt. + */ + @Override + public void setModifyDt(LocalDateTime value) { + set(2, value); + } + + /** + * Getter for win_auth_role.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return (LocalDateTime) get(2); + } + + /** + * Setter for win_auth_role.delete_dt. + */ + @Override + public void setDeleteDt(LocalDateTime value) { + set(3, value); + } + + /** + * Getter for win_auth_role.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return (LocalDateTime) get(3); + } + + /** + * Setter for win_auth_role.commit_id. + */ + @Override + public void setCommitId(Long value) { + set(4, value); + } + + /** + * Getter for win_auth_role.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return (Long) get(4); + } + + /** + * Setter for win_auth_role.role_type. + */ + @Override + public void setRoleType(Integer value) { + set(5, value); + } + + /** + * Getter for win_auth_role.role_type. + */ + @Column(name = "role_type", nullable = false, precision = 10) + @NotNull + @Override + public Integer getRoleType() { + return (Integer) get(5); + } + + /** + * Setter for win_auth_role.role_name. + */ + @Override + public void setRoleName(String value) { + set(6, value); + } + + /** + * Getter for win_auth_role.role_name. + */ + @Column(name = "role_name", nullable = false, length = 100) + @NotNull + @Size(max = 100) + @Override + public String getRoleName() { + return (String) get(6); + } + + /** + * Setter for win_auth_role.desc. + */ + @Override + public void setDesc(String value) { + set(7, value); + } + + /** + * Getter for win_auth_role.desc. + */ + @Column(name = "desc", nullable = false, length = 200) + @Size(max = 200) + @Override + public String getDesc() { + return (String) get(7); + } + + /** + * Setter for win_auth_role.auth_set. + */ + @Override + public void setAuthSet(String value) { + set(8, value); + } + + /** + * Getter for win_auth_role.auth_set. + */ + @Column(name = "auth_set", nullable = false, length = 3000) + @NotNull + @Size(max = 3000) + @Override + public String getAuthSet() { + return (String) get(8); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record9 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row9 fieldsRow() { + return (Row9) super.fieldsRow(); + } + + @Override + public Row9 valuesRow() { + return (Row9) super.valuesRow(); + } + + @Override + public Field field1() { + return WinAuthRoleTable.WinAuthRole.Id; + } + + @Override + public Field field2() { + return WinAuthRoleTable.WinAuthRole.CreateDt; + } + + @Override + public Field field3() { + return WinAuthRoleTable.WinAuthRole.ModifyDt; + } + + @Override + public Field field4() { + return WinAuthRoleTable.WinAuthRole.DeleteDt; + } + + @Override + public Field field5() { + return WinAuthRoleTable.WinAuthRole.CommitId; + } + + @Override + public Field field6() { + return WinAuthRoleTable.WinAuthRole.RoleType; + } + + @Override + public Field field7() { + return WinAuthRoleTable.WinAuthRole.RoleName; + } + + @Override + public Field field8() { + return WinAuthRoleTable.WinAuthRole.Desc; + } + + @Override + public Field field9() { + return WinAuthRoleTable.WinAuthRole.AuthSet; + } + + @Override + public Long component1() { + return getId(); + } + + @Override + public LocalDateTime component2() { + return getCreateDt(); + } + + @Override + public LocalDateTime component3() { + return getModifyDt(); + } + + @Override + public LocalDateTime component4() { + return getDeleteDt(); + } + + @Override + public Long component5() { + return getCommitId(); + } + + @Override + public Integer component6() { + return getRoleType(); + } + + @Override + public String component7() { + return getRoleName(); + } + + @Override + public String component8() { + return getDesc(); + } + + @Override + public String component9() { + return getAuthSet(); + } + + @Override + public Long value1() { + return getId(); + } + + @Override + public LocalDateTime value2() { + return getCreateDt(); + } + + @Override + public LocalDateTime value3() { + return getModifyDt(); + } + + @Override + public LocalDateTime value4() { + return getDeleteDt(); + } + + @Override + public Long value5() { + return getCommitId(); + } + + @Override + public Integer value6() { + return getRoleType(); + } + + @Override + public String value7() { + return getRoleName(); + } + + @Override + public String value8() { + return getDesc(); + } + + @Override + public String value9() { + return getAuthSet(); + } + + @Override + public WinAuthRoleRecord value1(Long value) { + setId(value); + return this; + } + + @Override + public WinAuthRoleRecord value2(LocalDateTime value) { + setCreateDt(value); + return this; + } + + @Override + public WinAuthRoleRecord value3(LocalDateTime value) { + setModifyDt(value); + return this; + } + + @Override + public WinAuthRoleRecord value4(LocalDateTime value) { + setDeleteDt(value); + return this; + } + + @Override + public WinAuthRoleRecord value5(Long value) { + setCommitId(value); + return this; + } + + @Override + public WinAuthRoleRecord value6(Integer value) { + setRoleType(value); + return this; + } + + @Override + public WinAuthRoleRecord value7(String value) { + setRoleName(value); + return this; + } + + @Override + public WinAuthRoleRecord value8(String value) { + setDesc(value); + return this; + } + + @Override + public WinAuthRoleRecord value9(String value) { + setAuthSet(value); + return this; + } + + @Override + public WinAuthRoleRecord values(Long value1, LocalDateTime value2, LocalDateTime value3, LocalDateTime value4, Long value5, Integer value6, String value7, String value8, String value9) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinAuthRole from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setRoleType(from.getRoleType()); + setRoleName(from.getRoleName()); + setDesc(from.getDesc()); + setAuthSet(from.getAuthSet()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached WinAuthRoleRecord + */ + public WinAuthRoleRecord() { + super(WinAuthRoleTable.WinAuthRole); + } + + /** + * Create a detached, initialised WinAuthRoleRecord + */ + public WinAuthRoleRecord(Long id, LocalDateTime createDt, LocalDateTime modifyDt, LocalDateTime deleteDt, Long commitId, Integer roleType, String roleName, String desc, String authSet) { + super(WinAuthRoleTable.WinAuthRole); + + set(0, id); + set(1, createDt); + set(2, modifyDt); + set(3, deleteDt); + set(4, commitId); + set(5, roleType); + set(6, roleName); + set(7, desc); + set(8, authSet); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserLoginRecord.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserLoginRecord.java new file mode 100644 index 000000000..94a1e9088 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserLoginRecord.java @@ -0,0 +1,697 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.records; + + +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record14; +import org.jooq.Row14; +import org.jooq.impl.UpdatableRecordImpl; + +import pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable; +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUserLogin; + + +/** + * The table wings_0.win_user_login. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user_login", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_login_PRIMARY", columnNames = {"id"}) +}) +public class WinUserLoginRecord extends UpdatableRecordImpl implements Record14, IWinUserLogin { + + private static final long serialVersionUID = -1547839635; + + /** + * Setter for win_user_login.id. + */ + @Override + public void setId(Long value) { + set(0, value); + } + + /** + * Getter for win_user_login.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return (Long) get(0); + } + + /** + * Setter for win_user_login.create_dt. + */ + @Override + public void setCreateDt(LocalDateTime value) { + set(1, value); + } + + /** + * Getter for win_user_login.create_dt. + */ + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return (LocalDateTime) get(1); + } + + /** + * Setter for win_user_login.modify_dt. + */ + @Override + public void setModifyDt(LocalDateTime value) { + set(2, value); + } + + /** + * Getter for win_user_login.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return (LocalDateTime) get(2); + } + + /** + * Setter for win_user_login.delete_dt. + */ + @Override + public void setDeleteDt(LocalDateTime value) { + set(3, value); + } + + /** + * Getter for win_user_login.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return (LocalDateTime) get(3); + } + + /** + * Setter for win_user_login.commit_id. + */ + @Override + public void setCommitId(Long value) { + set(4, value); + } + + /** + * Getter for win_user_login.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return (Long) get(4); + } + + /** + * Setter for win_user_login.user_id. + */ + @Override + public void setUserId(Long value) { + set(5, value); + } + + /** + * Getter for win_user_login.user_id. + */ + @Column(name = "user_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getUserId() { + return (Long) get(5); + } + + /** + * Setter for win_user_login.login_type. + */ + @Override + public void setLoginType(Integer value) { + set(6, value); + } + + /** + * Getter for win_user_login.login_type. + */ + @Column(name = "login_type", nullable = false, precision = 10) + @NotNull + @Override + public Integer getLoginType() { + return (Integer) get(6); + } + + /** + * Setter for win_user_login.login_name. + */ + @Override + public void setLoginName(String value) { + set(7, value); + } + + /** + * Getter for win_user_login.login_name. + */ + @Column(name = "login_name", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getLoginName() { + return (String) get(7); + } + + /** + * Setter for win_user_login.login_pass. + */ + @Override + public void setLoginPass(String value) { + set(8, value); + } + + /** + * Getter for win_user_login.login_pass. + */ + @Column(name = "login_pass", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getLoginPass() { + return (String) get(8); + } + + /** + * Setter for win_user_login.login_salt. + */ + @Override + public void setLoginSalt(String value) { + set(9, value); + } + + /** + * Getter for win_user_login.login_salt. + */ + @Column(name = "login_salt", nullable = false, length = 100) + @Size(max = 100) + @Override + public String getLoginSalt() { + return (String) get(9); + } + + /** + * Setter for win_user_login.login_para. + */ + @Override + public void setLoginPara(String value) { + set(10, value); + } + + /** + * Getter for win_user_login.login_para. + */ + @Column(name = "login_para", nullable = false, length = 2000) + @NotNull + @Size(max = 2000) + @Override + public String getLoginPara() { + return (String) get(10); + } + + /** + * Setter for win_user_login.auth_code. + */ + @Override + public void setAuthCode(String value) { + set(11, value); + } + + /** + * Getter for win_user_login.auth_code. + */ + @Column(name = "auth_code", nullable = false, length = 50) + @Size(max = 50) + @Override + public String getAuthCode() { + return (String) get(11); + } + + /** + * Setter for win_user_login.bad_count. + */ + @Override + public void setBadCount(Integer value) { + set(12, value); + } + + /** + * Getter for win_user_login.bad_count. + */ + @Column(name = "bad_count", nullable = false, precision = 10) + @Override + public Integer getBadCount() { + return (Integer) get(12); + } + + /** + * Setter for win_user_login.status. + */ + @Override + public void setStatus(Integer value) { + set(13, value); + } + + /** + * Getter for win_user_login.status. + */ + @Column(name = "status", nullable = false, precision = 10) + @NotNull + @Override + public Integer getStatus() { + return (Integer) get(13); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record14 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row14 fieldsRow() { + return (Row14) super.fieldsRow(); + } + + @Override + public Row14 valuesRow() { + return (Row14) super.valuesRow(); + } + + @Override + public Field field1() { + return WinUserLoginTable.WinUserLogin.Id; + } + + @Override + public Field field2() { + return WinUserLoginTable.WinUserLogin.CreateDt; + } + + @Override + public Field field3() { + return WinUserLoginTable.WinUserLogin.ModifyDt; + } + + @Override + public Field field4() { + return WinUserLoginTable.WinUserLogin.DeleteDt; + } + + @Override + public Field field5() { + return WinUserLoginTable.WinUserLogin.CommitId; + } + + @Override + public Field field6() { + return WinUserLoginTable.WinUserLogin.UserId; + } + + @Override + public Field field7() { + return WinUserLoginTable.WinUserLogin.LoginType; + } + + @Override + public Field field8() { + return WinUserLoginTable.WinUserLogin.LoginName; + } + + @Override + public Field field9() { + return WinUserLoginTable.WinUserLogin.LoginPass; + } + + @Override + public Field field10() { + return WinUserLoginTable.WinUserLogin.LoginSalt; + } + + @Override + public Field field11() { + return WinUserLoginTable.WinUserLogin.LoginPara; + } + + @Override + public Field field12() { + return WinUserLoginTable.WinUserLogin.AuthCode; + } + + @Override + public Field field13() { + return WinUserLoginTable.WinUserLogin.BadCount; + } + + @Override + public Field field14() { + return WinUserLoginTable.WinUserLogin.Status; + } + + @Override + public Long component1() { + return getId(); + } + + @Override + public LocalDateTime component2() { + return getCreateDt(); + } + + @Override + public LocalDateTime component3() { + return getModifyDt(); + } + + @Override + public LocalDateTime component4() { + return getDeleteDt(); + } + + @Override + public Long component5() { + return getCommitId(); + } + + @Override + public Long component6() { + return getUserId(); + } + + @Override + public Integer component7() { + return getLoginType(); + } + + @Override + public String component8() { + return getLoginName(); + } + + @Override + public String component9() { + return getLoginPass(); + } + + @Override + public String component10() { + return getLoginSalt(); + } + + @Override + public String component11() { + return getLoginPara(); + } + + @Override + public String component12() { + return getAuthCode(); + } + + @Override + public Integer component13() { + return getBadCount(); + } + + @Override + public Integer component14() { + return getStatus(); + } + + @Override + public Long value1() { + return getId(); + } + + @Override + public LocalDateTime value2() { + return getCreateDt(); + } + + @Override + public LocalDateTime value3() { + return getModifyDt(); + } + + @Override + public LocalDateTime value4() { + return getDeleteDt(); + } + + @Override + public Long value5() { + return getCommitId(); + } + + @Override + public Long value6() { + return getUserId(); + } + + @Override + public Integer value7() { + return getLoginType(); + } + + @Override + public String value8() { + return getLoginName(); + } + + @Override + public String value9() { + return getLoginPass(); + } + + @Override + public String value10() { + return getLoginSalt(); + } + + @Override + public String value11() { + return getLoginPara(); + } + + @Override + public String value12() { + return getAuthCode(); + } + + @Override + public Integer value13() { + return getBadCount(); + } + + @Override + public Integer value14() { + return getStatus(); + } + + @Override + public WinUserLoginRecord value1(Long value) { + setId(value); + return this; + } + + @Override + public WinUserLoginRecord value2(LocalDateTime value) { + setCreateDt(value); + return this; + } + + @Override + public WinUserLoginRecord value3(LocalDateTime value) { + setModifyDt(value); + return this; + } + + @Override + public WinUserLoginRecord value4(LocalDateTime value) { + setDeleteDt(value); + return this; + } + + @Override + public WinUserLoginRecord value5(Long value) { + setCommitId(value); + return this; + } + + @Override + public WinUserLoginRecord value6(Long value) { + setUserId(value); + return this; + } + + @Override + public WinUserLoginRecord value7(Integer value) { + setLoginType(value); + return this; + } + + @Override + public WinUserLoginRecord value8(String value) { + setLoginName(value); + return this; + } + + @Override + public WinUserLoginRecord value9(String value) { + setLoginPass(value); + return this; + } + + @Override + public WinUserLoginRecord value10(String value) { + setLoginSalt(value); + return this; + } + + @Override + public WinUserLoginRecord value11(String value) { + setLoginPara(value); + return this; + } + + @Override + public WinUserLoginRecord value12(String value) { + setAuthCode(value); + return this; + } + + @Override + public WinUserLoginRecord value13(Integer value) { + setBadCount(value); + return this; + } + + @Override + public WinUserLoginRecord value14(Integer value) { + setStatus(value); + return this; + } + + @Override + public WinUserLoginRecord values(Long value1, LocalDateTime value2, LocalDateTime value3, LocalDateTime value4, Long value5, Long value6, Integer value7, String value8, String value9, String value10, String value11, String value12, Integer value13, Integer value14) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + value10(value10); + value11(value11); + value12(value12); + value13(value13); + value14(value14); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinUserLogin from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setUserId(from.getUserId()); + setLoginType(from.getLoginType()); + setLoginName(from.getLoginName()); + setLoginPass(from.getLoginPass()); + setLoginSalt(from.getLoginSalt()); + setLoginPara(from.getLoginPara()); + setAuthCode(from.getAuthCode()); + setBadCount(from.getBadCount()); + setStatus(from.getStatus()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached WinUserLoginRecord + */ + public WinUserLoginRecord() { + super(WinUserLoginTable.WinUserLogin); + } + + /** + * Create a detached, initialised WinUserLoginRecord + */ + public WinUserLoginRecord(Long id, LocalDateTime createDt, LocalDateTime modifyDt, LocalDateTime deleteDt, Long commitId, Long userId, Integer loginType, String loginName, String loginPass, String loginSalt, String loginPara, String authCode, Integer badCount, Integer status) { + super(WinUserLoginTable.WinUserLogin); + + set(0, id); + set(1, createDt); + set(2, modifyDt); + set(3, deleteDt); + set(4, commitId); + set(5, userId); + set(6, loginType); + set(7, loginName); + set(8, loginPass); + set(9, loginSalt); + set(10, loginPara); + set(11, authCode); + set(12, badCount); + set(13, status); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserRecord.java b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserRecord.java new file mode 100644 index 000000000..964f920f5 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/database/autogen/tables/records/WinUserRecord.java @@ -0,0 +1,742 @@ +/* + * This file is generated by jOOQ. + */ +package pro.fessional.wings.example.database.autogen.tables.records; + + +import java.time.LocalDate; +import java.time.LocalDateTime; + +import javax.annotation.Generated; +import javax.persistence.Column; +import javax.persistence.Entity; +import javax.persistence.Id; +import javax.persistence.Table; +import javax.persistence.UniqueConstraint; +import javax.validation.constraints.NotNull; +import javax.validation.constraints.Size; + +import org.jooq.Field; +import org.jooq.Record1; +import org.jooq.Record15; +import org.jooq.Row15; +import org.jooq.impl.UpdatableRecordImpl; + +import pro.fessional.wings.example.database.autogen.tables.WinUserTable; +import pro.fessional.wings.example.database.autogen.tables.interfaces.IWinUser; + + +/** + * The table wings_0.win_user. + */ +@Generated( + value = { + "http://www.jooq.org", + "jOOQ version:3.12.4", + "schema version:2019070403" + }, + date = "2020-06-16T08:45:49.702Z", + comments = "This class is generated by jOOQ" +) +@SuppressWarnings({ "all", "unchecked", "rawtypes" }) +@Entity +@Table(name = "win_user", uniqueConstraints = { + @UniqueConstraint(name = "KEY_win_user_PRIMARY", columnNames = {"id"}) +}) +public class WinUserRecord extends UpdatableRecordImpl implements Record15, IWinUser { + + private static final long serialVersionUID = -501197732; + + /** + * Setter for win_user.id. + */ + @Override + public void setId(Long value) { + set(0, value); + } + + /** + * Getter for win_user.id. + */ + @Id + @Column(name = "id", nullable = false, precision = 19) + @NotNull + @Override + public Long getId() { + return (Long) get(0); + } + + /** + * Setter for win_user.create_dt. + */ + @Override + public void setCreateDt(LocalDateTime value) { + set(1, value); + } + + /** + * Getter for win_user.create_dt. + */ + @Column(name = "create_dt", nullable = false) + @Override + public LocalDateTime getCreateDt() { + return (LocalDateTime) get(1); + } + + /** + * Setter for win_user.modify_dt. + */ + @Override + public void setModifyDt(LocalDateTime value) { + set(2, value); + } + + /** + * Getter for win_user.modify_dt. + */ + @Column(name = "modify_dt", nullable = false) + @Override + public LocalDateTime getModifyDt() { + return (LocalDateTime) get(2); + } + + /** + * Setter for win_user.delete_dt. + */ + @Override + public void setDeleteDt(LocalDateTime value) { + set(3, value); + } + + /** + * Getter for win_user.delete_dt. + */ + @Column(name = "delete_dt", nullable = false) + @Override + public LocalDateTime getDeleteDt() { + return (LocalDateTime) get(3); + } + + /** + * Setter for win_user.commit_id. + */ + @Override + public void setCommitId(Long value) { + set(4, value); + } + + /** + * Getter for win_user.commit_id. + */ + @Column(name = "commit_id", nullable = false, precision = 19) + @NotNull + @Override + public Long getCommitId() { + return (Long) get(4); + } + + /** + * Setter for win_user.name. + */ + @Override + public void setName(String value) { + set(5, value); + } + + /** + * Getter for win_user.name. + */ + @Column(name = "name", nullable = false, length = 50) + @NotNull + @Size(max = 50) + @Override + public String getName() { + return (String) get(5); + } + + /** + * Setter for win_user.gender. + */ + @Override + public void setGender(Integer value) { + set(6, value); + } + + /** + * Getter for win_user.gender. + */ + @Column(name = "gender", nullable = false, precision = 10) + @NotNull + @Override + public Integer getGender() { + return (Integer) get(6); + } + + /** + * Setter for win_user.birth. + */ + @Override + public void setBirth(LocalDate value) { + set(7, value); + } + + /** + * Getter for win_user.birth. + */ + @Column(name = "birth", nullable = false) + @NotNull + @Override + public LocalDate getBirth() { + return (LocalDate) get(7); + } + + /** + * Setter for win_user.avatar. + */ + @Override + public void setAvatar(String value) { + set(8, value); + } + + /** + * Getter for win_user.avatar. + */ + @Column(name = "avatar", nullable = false, length = 200) + @NotNull + @Size(max = 200) + @Override + public String getAvatar() { + return (String) get(8); + } + + /** + * Setter for win_user.country. + */ + @Override + public void setCountry(String value) { + set(9, value); + } + + /** + * Getter for win_user.country. + */ + @Column(name = "country", nullable = false, length = 2) + @NotNull + @Size(max = 2) + @Override + public String getCountry() { + return (String) get(9); + } + + /** + * Setter for win_user.language. + */ + @Override + public void setLanguage(String value) { + set(10, value); + } + + /** + * Getter for win_user.language. + */ + @Column(name = "language", nullable = false, length = 5) + @NotNull + @Size(max = 5) + @Override + public String getLanguage() { + return (String) get(10); + } + + /** + * Setter for win_user.timezone. + */ + @Override + public void setTimezone(Integer value) { + set(11, value); + } + + /** + * Getter for win_user.timezone. + */ + @Column(name = "timezone", nullable = false, precision = 10) + @NotNull + @Override + public Integer getTimezone() { + return (Integer) get(11); + } + + /** + * Setter for win_user.auth_set. + */ + @Override + public void setAuthSet(String value) { + set(12, value); + } + + /** + * Getter for win_user.auth_set. + */ + @Column(name = "auth_set", nullable = false, length = 2000) + @Size(max = 2000) + @Override + public String getAuthSet() { + return (String) get(12); + } + + /** + * Setter for win_user.role_set. + */ + @Override + public void setRoleSet(String value) { + set(13, value); + } + + /** + * Getter for win_user.role_set. + */ + @Column(name = "role_set", nullable = false, length = 1000) + @Size(max = 1000) + @Override + public String getRoleSet() { + return (String) get(13); + } + + /** + * Setter for win_user.status. + */ + @Override + public void setStatus(Integer value) { + set(14, value); + } + + /** + * Getter for win_user.status. + */ + @Column(name = "status", nullable = false, precision = 10) + @NotNull + @Override + public Integer getStatus() { + return (Integer) get(14); + } + + // ------------------------------------------------------------------------- + // Primary key information + // ------------------------------------------------------------------------- + + @Override + public Record1 key() { + return (Record1) super.key(); + } + + // ------------------------------------------------------------------------- + // Record15 type implementation + // ------------------------------------------------------------------------- + + @Override + public Row15 fieldsRow() { + return (Row15) super.fieldsRow(); + } + + @Override + public Row15 valuesRow() { + return (Row15) super.valuesRow(); + } + + @Override + public Field field1() { + return WinUserTable.WinUser.Id; + } + + @Override + public Field field2() { + return WinUserTable.WinUser.CreateDt; + } + + @Override + public Field field3() { + return WinUserTable.WinUser.ModifyDt; + } + + @Override + public Field field4() { + return WinUserTable.WinUser.DeleteDt; + } + + @Override + public Field field5() { + return WinUserTable.WinUser.CommitId; + } + + @Override + public Field field6() { + return WinUserTable.WinUser.Name; + } + + @Override + public Field field7() { + return WinUserTable.WinUser.Gender; + } + + @Override + public Field field8() { + return WinUserTable.WinUser.Birth; + } + + @Override + public Field field9() { + return WinUserTable.WinUser.Avatar; + } + + @Override + public Field field10() { + return WinUserTable.WinUser.Country; + } + + @Override + public Field field11() { + return WinUserTable.WinUser.Language; + } + + @Override + public Field field12() { + return WinUserTable.WinUser.Timezone; + } + + @Override + public Field field13() { + return WinUserTable.WinUser.AuthSet; + } + + @Override + public Field field14() { + return WinUserTable.WinUser.RoleSet; + } + + @Override + public Field field15() { + return WinUserTable.WinUser.Status; + } + + @Override + public Long component1() { + return getId(); + } + + @Override + public LocalDateTime component2() { + return getCreateDt(); + } + + @Override + public LocalDateTime component3() { + return getModifyDt(); + } + + @Override + public LocalDateTime component4() { + return getDeleteDt(); + } + + @Override + public Long component5() { + return getCommitId(); + } + + @Override + public String component6() { + return getName(); + } + + @Override + public Integer component7() { + return getGender(); + } + + @Override + public LocalDate component8() { + return getBirth(); + } + + @Override + public String component9() { + return getAvatar(); + } + + @Override + public String component10() { + return getCountry(); + } + + @Override + public String component11() { + return getLanguage(); + } + + @Override + public Integer component12() { + return getTimezone(); + } + + @Override + public String component13() { + return getAuthSet(); + } + + @Override + public String component14() { + return getRoleSet(); + } + + @Override + public Integer component15() { + return getStatus(); + } + + @Override + public Long value1() { + return getId(); + } + + @Override + public LocalDateTime value2() { + return getCreateDt(); + } + + @Override + public LocalDateTime value3() { + return getModifyDt(); + } + + @Override + public LocalDateTime value4() { + return getDeleteDt(); + } + + @Override + public Long value5() { + return getCommitId(); + } + + @Override + public String value6() { + return getName(); + } + + @Override + public Integer value7() { + return getGender(); + } + + @Override + public LocalDate value8() { + return getBirth(); + } + + @Override + public String value9() { + return getAvatar(); + } + + @Override + public String value10() { + return getCountry(); + } + + @Override + public String value11() { + return getLanguage(); + } + + @Override + public Integer value12() { + return getTimezone(); + } + + @Override + public String value13() { + return getAuthSet(); + } + + @Override + public String value14() { + return getRoleSet(); + } + + @Override + public Integer value15() { + return getStatus(); + } + + @Override + public WinUserRecord value1(Long value) { + setId(value); + return this; + } + + @Override + public WinUserRecord value2(LocalDateTime value) { + setCreateDt(value); + return this; + } + + @Override + public WinUserRecord value3(LocalDateTime value) { + setModifyDt(value); + return this; + } + + @Override + public WinUserRecord value4(LocalDateTime value) { + setDeleteDt(value); + return this; + } + + @Override + public WinUserRecord value5(Long value) { + setCommitId(value); + return this; + } + + @Override + public WinUserRecord value6(String value) { + setName(value); + return this; + } + + @Override + public WinUserRecord value7(Integer value) { + setGender(value); + return this; + } + + @Override + public WinUserRecord value8(LocalDate value) { + setBirth(value); + return this; + } + + @Override + public WinUserRecord value9(String value) { + setAvatar(value); + return this; + } + + @Override + public WinUserRecord value10(String value) { + setCountry(value); + return this; + } + + @Override + public WinUserRecord value11(String value) { + setLanguage(value); + return this; + } + + @Override + public WinUserRecord value12(Integer value) { + setTimezone(value); + return this; + } + + @Override + public WinUserRecord value13(String value) { + setAuthSet(value); + return this; + } + + @Override + public WinUserRecord value14(String value) { + setRoleSet(value); + return this; + } + + @Override + public WinUserRecord value15(Integer value) { + setStatus(value); + return this; + } + + @Override + public WinUserRecord values(Long value1, LocalDateTime value2, LocalDateTime value3, LocalDateTime value4, Long value5, String value6, Integer value7, LocalDate value8, String value9, String value10, String value11, Integer value12, String value13, String value14, Integer value15) { + value1(value1); + value2(value2); + value3(value3); + value4(value4); + value5(value5); + value6(value6); + value7(value7); + value8(value8); + value9(value9); + value10(value10); + value11(value11); + value12(value12); + value13(value13); + value14(value14); + value15(value15); + return this; + } + + // ------------------------------------------------------------------------- + // FROM and INTO + // ------------------------------------------------------------------------- + + @Override + public void from(IWinUser from) { + setId(from.getId()); + setCreateDt(from.getCreateDt()); + setModifyDt(from.getModifyDt()); + setDeleteDt(from.getDeleteDt()); + setCommitId(from.getCommitId()); + setName(from.getName()); + setGender(from.getGender()); + setBirth(from.getBirth()); + setAvatar(from.getAvatar()); + setCountry(from.getCountry()); + setLanguage(from.getLanguage()); + setTimezone(from.getTimezone()); + setAuthSet(from.getAuthSet()); + setRoleSet(from.getRoleSet()); + setStatus(from.getStatus()); + } + + @Override + public E into(E into) { + into.from(this); + return into; + } + + // ------------------------------------------------------------------------- + // Constructors + // ------------------------------------------------------------------------- + + /** + * Create a detached WinUserRecord + */ + public WinUserRecord() { + super(WinUserTable.WinUser); + } + + /** + * Create a detached, initialised WinUserRecord + */ + public WinUserRecord(Long id, LocalDateTime createDt, LocalDateTime modifyDt, LocalDateTime deleteDt, Long commitId, String name, Integer gender, LocalDate birth, String avatar, String country, String language, Integer timezone, String authSet, String roleSet, Integer status) { + super(WinUserTable.WinUser); + + set(0, id); + set(1, createDt); + set(2, modifyDt); + set(3, deleteDt); + set(4, commitId); + set(5, name); + set(6, gender); + set(7, birth); + set(8, avatar); + set(9, country); + set(10, language); + set(11, timezone); + set(12, authSet); + set(13, roleSet); + set(14, status); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/Authority.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/Authority.java new file mode 100644 index 000000000..3f4451dd2 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/Authority.java @@ -0,0 +1,95 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum Authority implements ConstantEnum, StandardI18nEnum { + SUPER(4010100, "authority", "权限定义", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + CREATE_USER(4010101, "CREATE_USER", "创建用户", "用户:"), + DELETE_USER(4010102, "DELETE_USER", "删除用户", "用户:"), + CREATE_ROLE(4010203, "CREATE_ROLE", "删除角色", "角色:"), + DELETE_ROLE(4010204, "DELETE_ROLE", "删除角色", "角色:"), + ; + public static final String $SUPER = "authority"; + public static final String $CREATE_USER = "CREATE_USER"; + public static final String $DELETE_USER = "DELETE_USER"; + public static final String $CREATE_ROLE = "CREATE_ROLE"; + public static final String $DELETE_ROLE = "DELETE_ROLE"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + Authority(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "authority"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/CommonGender.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/CommonGender.java new file mode 100644 index 000000000..8243c7328 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/CommonGender.java @@ -0,0 +1,93 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum CommonGender implements ConstantEnum, StandardI18nEnum { + SUPER(2010100, "common_gender", "性别", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + MALE(2010101, "male", "男", "通常"), + FEMALE(2010102, "female", "女", "通常"), + UNKNOWN(2010103, "unknown", "未知", "通常"), + ; + public static final String $SUPER = "common_gender"; + public static final String $MALE = "male"; + public static final String $FEMALE = "female"; + public static final String $UNKNOWN = "unknown"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + CommonGender(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "common_gender"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/LoginType.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/LoginType.java new file mode 100644 index 000000000..97baa1314 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/LoginType.java @@ -0,0 +1,95 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum LoginType implements ConstantEnum, StandardI18nEnum { + SUPER(4120100, "login_type", "用户登录类型", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + EMAIL_PASS(4120101, "email_pass", "邮件", "邮件登录"), + NAME_PASS(4120102, "name_pass", "用户名", "用户名密码"), + MOBILE_SMS(4120103, "mobile_sms", "手机号", "手机号"), + WEIXIN_OAUTH(4120104, "weixin_oauth", "微信登录", "微信登录"), + ; + public static final String $SUPER = "login_type"; + public static final String $EMAIL_PASS = "email_pass"; + public static final String $NAME_PASS = "name_pass"; + public static final String $MOBILE_SMS = "mobile_sms"; + public static final String $WEIXIN_OAUTH = "weixin_oauth"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + LoginType(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "login_type"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/RoleType.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/RoleType.java new file mode 100644 index 000000000..01923d30c --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/RoleType.java @@ -0,0 +1,91 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum RoleType implements ConstantEnum, StandardI18nEnum { + SUPER(4020100, "role_type", "角色类别", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + FINANCIAL(4020101, "financial", "财务", "财务总部"), + OPERATION(4020102, "operation", "运营", "财务总部"), + ; + public static final String $SUPER = "role_type"; + public static final String $FINANCIAL = "financial"; + public static final String $OPERATION = "operation"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + RoleType(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "role_type"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/TerminalType.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/TerminalType.java new file mode 100644 index 000000000..ff1eb9430 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/TerminalType.java @@ -0,0 +1,93 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum TerminalType implements ConstantEnum, StandardI18nEnum { + SUPER(2030100, "terminal_type", "用户类别", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + WEB_ADMIN(2030101, "web_admin", "WEB管理端", ""), + APP_ANDROID(2030102, "app_android", "安卓app", ""), + EXE_PC(2030103, "exe_pc", "pc端exe", ""), + ; + public static final String $SUPER = "terminal_type"; + public static final String $WEB_ADMIN = "web_admin"; + public static final String $APP_ANDROID = "app_android"; + public static final String $EXE_PC = "exe_pc"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + TerminalType(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "terminal_type"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserStatus.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserStatus.java new file mode 100644 index 000000000..e4dcc187a --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserStatus.java @@ -0,0 +1,97 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum UserStatus implements ConstantEnum, StandardI18nEnum { + SUPER(4110100, "user_status", "用户状态", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + UNINIT(4110101, "uninit", "新建", "建立未登陆"), + ACTIVE(4110102, "active", "正常", "正常活动"), + UNSAFE(4110103, "unsafe", "异动", "异动账户"), + DANGER(4110104, "danger", "危险", "危险账户"), + FROZEN(4110105, "frozen", "冻结", "冻结账户"), + ; + public static final String $SUPER = "user_status"; + public static final String $UNINIT = "uninit"; + public static final String $ACTIVE = "active"; + public static final String $UNSAFE = "unsafe"; + public static final String $DANGER = "danger"; + public static final String $FROZEN = "frozen"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + UserStatus(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "user_status"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserType.java b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserType.java new file mode 100644 index 000000000..9b29cd6e1 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/enums/auto/UserType.java @@ -0,0 +1,93 @@ +package pro.fessional.wings.example.enums.auto; + + +import org.jetbrains.annotations.NotNull; +import pro.fessional.wings.faceless.enums.ConstantEnum; +import pro.fessional.wings.faceless.enums.StandardI18nEnum; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public enum UserType implements ConstantEnum, StandardI18nEnum { + SUPER(2020100, "user_type", "用户类别", "classpath:/wings-tmpl/ConstantEnumTemplate.java"), + ADMIN(2020101, "admin", "管理", ""), + STAFF(2020102, "staff", "员工", ""), + GUEST(2020103, "guest", "客户", ""), + ; + public static final String $SUPER = "user_type"; + public static final String $ADMIN = "admin"; + public static final String $STAFF = "staff"; + public static final String $GUEST = "guest"; + + + public static final boolean useIdAsKey = false; + private final int id; + private final String code; + private final String desc; + private final String info; + + private final String ukey; + private final String rkey; + + UserType(int id, String code, String desc, String info) { + this.id = id; + this.code = code; + this.desc = desc; + this.info = info; + this.ukey = useIdAsKey ? "id" + id : code; + this.rkey = "sys_constant_enum.desc." + ukey; + } + + @Override + public int getId() { + return id; + } + + @Override + public @NotNull String getType() { + return "constant_enum_template"; + } + + @Override + public @NotNull String getInfo() { + return info; + } + + public String getDesc() { + return desc; + } + + // + @Override + public @NotNull String getBase() { + return "user_type"; + } + + @Override + public @NotNull String getKind() { + return "desc"; + } + + @Override + public @NotNull String getUkey() { + return ukey; + } + + + // + @Override + public @NotNull String getCode() { + return code; + } + + @Override + public @NotNull String getHint() { + return desc; + } + + @Override + public @NotNull String getI18nCode() { + return rkey; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/TestI18nUserDetail.java b/wings-example/src/main/java/pro/fessional/wings/example/service/TestI18nUserDetail.java deleted file mode 100644 index 9685b72f3..000000000 --- a/wings-example/src/main/java/pro/fessional/wings/example/service/TestI18nUserDetail.java +++ /dev/null @@ -1,82 +0,0 @@ -package pro.fessional.wings.example.service; - -import org.springframework.security.core.GrantedAuthority; -import org.springframework.security.core.authority.SimpleGrantedAuthority; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; - -import java.util.Arrays; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.TimeZone; - -/** - * @author trydofor - * @since 2019-11-20 - */ -public class TestI18nUserDetail implements UserDetails { - - private final List auths = Arrays.asList( - new SimpleGrantedAuthority("ROLE_USER"), - new SimpleGrantedAuthority("ROLE_ADMIN"), - new SimpleGrantedAuthority("ROLE_CLURK"), - new SimpleGrantedAuthority("MENU_READ") - ); - - private final String pass = "{bcrypt}" + new BCryptPasswordEncoder().encode("wings-slardar-pass"); - - private TimeZone timezone = TimeZone.getDefault(); - private Locale locale = Locale.CHINA; - - public TimeZone getTimezone() { - return timezone; - } - - public void setTimezone(TimeZone timezone) { - this.timezone = timezone; - } - - public Locale getLocale() { - return locale; - } - - public void setLocale(Locale locale) { - this.locale = locale; - } - - @Override - public Collection getAuthorities() { - return auths; - } - - @Override - public String getPassword() { - return pass; - } - - @Override - public String getUsername() { - return "wings-slardar-user"; - } - - @Override - public boolean isAccountNonExpired() { - return true; - } - - @Override - public boolean isAccountNonLocked() { - return true; - } - - @Override - public boolean isCredentialsNonExpired() { - return true; - } - - @Override - public boolean isEnabled() { - return true; - } -} \ No newline at end of file diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/TestUserDetailsService.java b/wings-example/src/main/java/pro/fessional/wings/example/service/TestUserDetailsService.java deleted file mode 100644 index e2e42e6b1..000000000 --- a/wings-example/src/main/java/pro/fessional/wings/example/service/TestUserDetailsService.java +++ /dev/null @@ -1,24 +0,0 @@ -package pro.fessional.wings.example.service; - -import org.springframework.security.core.Authentication; -import org.springframework.security.core.context.SecurityContextHolder; -import org.springframework.security.core.userdetails.UserDetails; -import org.springframework.security.core.userdetails.UserDetailsService; -import org.springframework.stereotype.Service; -import pro.fessional.wings.slardar.security.WingsOAuth2xContext; - -/** - * @author trydofor - * @since 2019-11-14 - */ -@Service -public class TestUserDetailsService implements UserDetailsService { - - @Override - public UserDetails loadUserByUsername(String username) { - System.out.println(username); - WingsOAuth2xContext.Context woc = WingsOAuth2xContext.get(); - Authentication aut = SecurityContextHolder.getContext().getAuthentication(); - return new TestI18nUserDetail(); - } -} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthEnumUtil.java b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthEnumUtil.java new file mode 100644 index 000000000..22d451b6b --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthEnumUtil.java @@ -0,0 +1,54 @@ +package pro.fessional.wings.example.service.authrole; + +import pro.fessional.mirana.math.AnyIntegerUtil; +import pro.fessional.wings.example.enums.auto.Authority; +import pro.fessional.wings.faceless.enums.ConstantEnumUtil; + +import java.util.HashSet; +import java.util.Map; +import java.util.Set; + +/** + * @author trydofor + * @since 2020-06-21 + */ +public class AuthEnumUtil { + + /** + * 变成 id和code的map,支持负数标记删除 + * + * @param map map + * @param ids auth id + */ + public static void fillAuth(Map map, String... ids) { + if (ids == null || ids.length == 0) return; + for (String id : ids) { + int i = AnyIntegerUtil.val32(id); + Authority a; + if (i < 0) { + a = ConstantEnumUtil.idOrNull(-i, Authority.values()); + } else { + a = ConstantEnumUtil.idOrNull(i, Authority.values()); + } + if (a != null) { + map.put(i, a.getCode()); + } + } + } + + /** + * 按负数删除,整理 map + * + * @param map map + */ + public static void trimAuth(Map map) { + if (map == null || map.isEmpty()) return; + + Set remove = new HashSet<>(); + for (Integer i : map.keySet()) { + if(i < 0) remove.add(-i); + } + + map.entrySet().removeIf(e -> e.getKey() < 0 || remove.contains(e.getKey())); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleCache.java b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleCache.java new file mode 100644 index 000000000..f17cc7edf --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleCache.java @@ -0,0 +1,71 @@ +package pro.fessional.wings.example.service.authrole; + +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import org.jetbrains.annotations.NotNull; +import org.jooq.Record1; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; +import pro.fessional.wings.example.database.autogen.tables.WinAuthRoleTable; +import pro.fessional.wings.example.database.autogen.tables.daos.WinAuthRoleDao; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinAuthRole; +import pro.fessional.wings.faceless.service.journal.JournalService; +import pro.fessional.wings.faceless.service.lightid.LightIdService; + +import java.util.Collections; +import java.util.HashMap; +import java.util.Map; + +import static pro.fessional.wings.slardar.spring.bean.WingsCacheConfiguration.LEVEL_GENERAL; +import static pro.fessional.wings.slardar.spring.bean.WingsCacheConfiguration.MANAGER_CAFFEINE; + +@Service +@Setter(onMethod = @__({@Autowired})) +public class AuthRoleCache { + + private LightIdService lightIdService; + private WinAuthRoleDao winAuthRoleDao; + + @Cacheable(key = "#roleId", + value = LEVEL_GENERAL + "AuthorityName", + cacheManager = MANAGER_CAFFEINE) + @NotNull + public Map loadAuth(long roleId) { + WinAuthRoleTable t = winAuthRoleDao.getAliasForReader(); + Record1 r1 = winAuthRoleDao + .dslContext() + .select(t.AuthSet) + .from(t) + .where(t.Id.eq(roleId)) + .fetchOne(); + + if (r1 == null) { + return Collections.emptyMap(); + } else { + String[] aids = StringUtils.split(r1.value1(), ","); + Map result = new HashMap<>(); + AuthEnumUtil.fillAuth(result, aids); + return result; + } + } + + @CacheEvict(key = "#result", + value = LEVEL_GENERAL + "AuthorityName", + cacheManager = MANAGER_CAFFEINE) + public long save(WinAuthRole authRole, JournalService.Journal journal) { + long id; + if (authRole.getId() == null) { + id = lightIdService.getId(WinAuthRoleTable.class); + authRole.setId(id); + journal.commit(authRole); + winAuthRoleDao.insert(authRole); + } else { + id = authRole.getId(); + journal.commit(authRole); + winAuthRoleDao.update(authRole, true); + } + return id; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleService.java b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleService.java new file mode 100644 index 000000000..3759859b8 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/authrole/AuthRoleService.java @@ -0,0 +1,46 @@ +package pro.fessional.wings.example.service.authrole; + +import lombok.Setter; +import org.apache.commons.lang3.StringUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.authority.SimpleGrantedAuthority; +import org.springframework.stereotype.Service; +import pro.fessional.mirana.math.AnyIntegerUtil; + +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +/** + * @author trydofor + * @since 2019-12-01 + */ +@Service +@Setter(onMethod = @__({@Autowired})) +public class AuthRoleService { + + private AuthRoleCache authRoleCache; + + public Set loadRoleAuth(String roleSet, String authSet) { + Map auths = new HashMap<>(); + fillByRole(auths, StringUtils.split(roleSet, ",")); + String[] aid = StringUtils.split(authSet, ","); + AuthEnumUtil.fillAuth(auths, aid); + AuthEnumUtil.trimAuth(auths); + return auths.values() + .stream() + .map(SimpleGrantedAuthority::new) + .collect(Collectors.toSet()); + } + + + public void fillByRole(Map map, String... ids) { + if (ids == null || ids.length == 0) return; + for (String id : ids) { + Map authCode = authRoleCache.loadAuth(AnyIntegerUtil.val64(id)); + map.putAll(authCode); + } + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/journal/JournalServiceSpringSecurity.java b/wings-example/src/main/java/pro/fessional/wings/example/service/journal/JournalServiceSpringSecurity.java deleted file mode 100644 index f4503ac30..000000000 --- a/wings-example/src/main/java/pro/fessional/wings/example/service/journal/JournalServiceSpringSecurity.java +++ /dev/null @@ -1,42 +0,0 @@ -package pro.fessional.wings.example.service.journal; - -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; -import pro.fessional.wings.faceless.service.journal.JournalService; - -/** - * @author trydofor - * @since 2019-08-15 - */ -public class JournalServiceSpringSecurity implements JournalService { - - @NotNull - @Override - public Journal commit(@NotNull String eventName, @Nullable String loginInfo, @Nullable String targetKey, @Nullable String otherInfo) { - return null; - } - - @NotNull - @Override - public Journal commit(@NotNull Class eventClass, @Nullable String loginInfo, @Nullable Object targetKey, @Nullable Object otherInfo) { - return null; - } - - @NotNull - @Override - public Journal commit(@NotNull Class eventClass, @Nullable Object targetKey, @Nullable Object otherInfo) { - return null; - } - - @NotNull - @Override - public Journal commit(@NotNull Class eventClass, @Nullable Object targetKey) { - return null; - } - - @NotNull - @Override - public Journal commit(@NotNull Class eventClass) { - return null; - } -} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/security/SecurityJournalService.java b/wings-example/src/main/java/pro/fessional/wings/example/service/security/SecurityJournalService.java new file mode 100644 index 000000000..345f24976 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/security/SecurityJournalService.java @@ -0,0 +1,38 @@ +package pro.fessional.wings.example.service.security; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; +import pro.fessional.wings.faceless.database.manual.single.modify.commitjournal.CommitJournalModify; +import pro.fessional.wings.faceless.service.journal.impl.DefaultJournalService; +import pro.fessional.wings.faceless.service.lightid.BlockIdProvider; +import pro.fessional.wings.faceless.service.lightid.LightIdService; + +/** + * @author trydofor + * @since 2019-08-15 + */ +@Service +public class SecurityJournalService extends DefaultJournalService { + + public SecurityJournalService(LightIdService lightIdService, + BlockIdProvider blockIdProvider, + CommitJournalModify journalModify) { + super(lightIdService, blockIdProvider, journalModify); + } + + @NotNull + @Transactional(propagation = Propagation.REQUIRES_NEW) + public Journal commit(@NotNull String eventName, + @Nullable String targetKey, + @Nullable String otherInfo) { + +// SecurityContextUtil.getDetails() + + String loginInfo = ""; + return super.commit(eventName, loginInfo, targetKey, otherInfo); + } + +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetail.java b/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetail.java new file mode 100644 index 000000000..1921d18e7 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetail.java @@ -0,0 +1,122 @@ +package pro.fessional.wings.example.service.security; + +import lombok.Getter; +import lombok.Setter; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.springframework.security.core.GrantedAuthority; +import pro.fessional.wings.slardar.security.TypeIdI18nUserDetail; + +import java.time.LocalDate; +import java.time.ZoneId; +import java.util.Collection; +import java.util.Collections; +import java.util.Locale; + +/** + * @author trydofor + * @since 2019-11-30 + */ +@Setter +@Getter +public class WingsUserDetail implements TypeIdI18nUserDetail { + + private String username; + private String password; + private Collection authorities = Collections.emptyList(); + + private long userId; + private int userType; + private int loginType; // LoginTypeEnum + + private String name; + private int gender; + private LocalDate birth; + private String avatar; + private String country; + + private Locale locale; + private ZoneId zoneId; + + private boolean accountNonExpired; + private boolean accountNonLocked; + private boolean credentialsNonExpired; + private boolean enabled; + + @Override + public long getUserId() { + return userId; + } + + @Override + public int getUserType() { + return userType; + } + + @Override + public Locale getLocale() { + return locale; + } + + @Override + public ZoneId getZoneId() { + return zoneId; + } + + @Override + public Collection getAuthorities() { + return authorities; + } + + @Override + public String getPassword() { + return password; + } + + @Override + public String getUsername() { + return username; + } + + @Override + public boolean isAccountNonExpired() { + return accountNonExpired; + } + + @Override + public boolean isAccountNonLocked() { + return accountNonLocked; + } + + @Override + public boolean isCredentialsNonExpired() { + return credentialsNonExpired; + } + + @Override + public boolean isEnabled() { + return enabled; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + WingsUserDetail that = (WingsUserDetail) o; + + return new EqualsBuilder() + .append(userId, that.userId) + .append(userType, that.userType) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(userId) + .append(userType) + .toHashCode(); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetailService.java b/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetailService.java new file mode 100644 index 000000000..f839d8296 --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/service/security/WingsUserDetailService.java @@ -0,0 +1,106 @@ +package pro.fessional.wings.example.service.security; + +import lombok.Setter; +import org.jooq.Condition; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.security.core.GrantedAuthority; +import org.springframework.security.core.userdetails.UserDetailsService; +import org.springframework.security.core.userdetails.UsernameNotFoundException; +import org.springframework.stereotype.Service; +import org.springframework.util.Assert; +import pro.fessional.mirana.i18n.LocaleResolver; +import pro.fessional.wings.example.database.autogen.tables.WinUserLoginTable; +import pro.fessional.wings.example.database.autogen.tables.daos.WinUserDao; +import pro.fessional.wings.example.database.autogen.tables.daos.WinUserLoginDao; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinUser; +import pro.fessional.wings.example.database.autogen.tables.pojos.WinUserLogin; +import pro.fessional.wings.example.enums.auto.LoginType; +import pro.fessional.wings.example.enums.auto.UserStatus; +import pro.fessional.wings.example.enums.auto.UserType; +import pro.fessional.wings.example.service.authrole.AuthRoleService; +import pro.fessional.wings.faceless.enums.ConstantEnumUtil; +import pro.fessional.wings.faceless.enums.TimezoneEnumUtil; +import pro.fessional.wings.faceless.enums.auto.StandardTimezone; +import pro.fessional.wings.slardar.security.SecurityContextUtil; +import pro.fessional.wings.slardar.security.WingsOAuth2xContext; + +import java.util.List; +import java.util.Set; + +/** + * @author trydofor + * @since 2019-11-30 + */ +@Service +@Setter(onMethod = @__({@Autowired})) +public class WingsUserDetailService implements UserDetailsService { + + private WinUserLoginDao winUserLoginDao; + private WinUserDao winUserDao; + private AuthRoleService authRoleService; + + // 支持的登录类型 + private static final LoginType[] loginTypes = { + LoginType.EMAIL_PASS, + LoginType.NAME_PASS + }; + + private static final UserStatus[] enables = { + UserStatus.UNINIT, + UserStatus.ACTIVE + }; + + + @Override + public WingsUserDetail loadUserByUsername(String username) { + WingsOAuth2xContext.Context ctx = SecurityContextUtil.getOauth2xContext(); + Assert.notNull(ctx, "oauth2x context is null"); + // 使用alias来判断类型 + String alias = ctx.getOauthPasswordAlias(); + LoginType loginType = ConstantEnumUtil.codeOrNull(alias, loginTypes); + if (loginType == null) { + throw new UsernameNotFoundException("bad login type, username=" + username); + } +// String password = passwordEncoder.encode("moilioncircle"); + + WinUserLoginTable t = winUserLoginDao.getAliasForReader(); + Condition cond = t.LoginName.eq(username) + .and(t.LoginType.eq(loginType.getId())); + List logins = winUserLoginDao.fetch(cond); + + if (logins.size() != 1) { + throw new UsernameNotFoundException("find " + logins.size() + " users. username=" + username); + } + + WinUserLogin login = logins.get(0); + WinUser user = winUserDao.fetchOneById(login.getUserId()); + if (user == null) { + throw new UsernameNotFoundException("can not find users. id=" + login.getUserId()); + } + + Set auths = authRoleService.loadRoleAuth(user.getRoleSet(), user.getAuthSet()); + + WingsUserDetail detail = new WingsUserDetail(); + detail.setUsername(username); + detail.setPassword(login.getLoginPass()); + detail.setAuthorities(null); + detail.setUserId(user.getId()); + detail.setUserType(UserType.GUEST.getId()); + detail.setLoginType(loginType.getId()); + detail.setName(user.getName()); + detail.setGender(user.getGender()); + detail.setBirth(user.getBirth()); + detail.setAvatar(user.getAvatar()); + detail.setCountry(user.getCountry()); + detail.setLocale(LocaleResolver.locale(user.getLanguage())); + detail.setZoneId(TimezoneEnumUtil.idOrThrow(user.getTimezone(), StandardTimezone.values()).toZoneId()); + + detail.setAccountNonExpired(true); + detail.setAccountNonLocked(true); + detail.setCredentialsNonExpired(true); + detail.setEnabled(ConstantEnumUtil.idIn(user.getStatus(), enables)); + detail.setAuthorities(auths); + + return detail; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/AuthorizationServerConfiguration.java b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/AuthorizationServerConfiguration.java new file mode 100644 index 000000000..71c22402d --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/AuthorizationServerConfiguration.java @@ -0,0 +1,39 @@ +package pro.fessional.wings.example.spring.bean; + +import lombok.Setter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.oauth2.config.annotation.configurers.ClientDetailsServiceConfigurer; +import org.springframework.security.oauth2.config.annotation.web.configuration.AuthorizationServerConfigurerAdapter; +import org.springframework.security.oauth2.config.annotation.web.configuration.EnableAuthorizationServer; +import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerEndpointsConfigurer; +import org.springframework.security.oauth2.config.annotation.web.configurers.AuthorizationServerSecurityConfigurer; +import pro.fessional.wings.slardar.spring.bean.WingsOAuth2xConfiguration; + +/** + * @author trydofor + * @since 2019-12-01 + */ +@Configuration +@EnableAuthorizationServer +public class AuthorizationServerConfiguration extends AuthorizationServerConfigurerAdapter { + + @Setter(onMethod = @__({@Autowired})) + private WingsOAuth2xConfiguration.Helper helper; + + @Override + public void configure(ClientDetailsServiceConfigurer clients) throws Exception { + helper.configure(clients); + } + + @Override + public void configure(AuthorizationServerEndpointsConfigurer endpoints) throws Exception { + helper.configure(endpoints); + + } + + @Override + public void configure(AuthorizationServerSecurityConfigurer security) throws Exception { + helper.configure(security); + } +} \ No newline at end of file diff --git a/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfigurer.java b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfiguration.java similarity index 51% rename from wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfigurer.java rename to wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfiguration.java index 3d9c2c767..1f581c07a 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfigurer.java +++ b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/ResourceServerConfiguration.java @@ -2,13 +2,12 @@ import lombok.Setter; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.security.config.annotation.web.builders.HttpSecurity; import org.springframework.security.oauth2.config.annotation.web.configuration.EnableResourceServer; import org.springframework.security.oauth2.config.annotation.web.configuration.ResourceServerConfigurerAdapter; import org.springframework.security.oauth2.config.annotation.web.configurers.ResourceServerSecurityConfigurer; -import org.springframework.security.oauth2.provider.token.RemoteTokenServices; +import pro.fessional.wings.example.enums.auto.Authority; import pro.fessional.wings.slardar.spring.bean.WingsOAuth2xConfiguration; /** @@ -17,7 +16,7 @@ */ @Configuration @EnableResourceServer -public class ResourceServerConfigurer extends ResourceServerConfigurerAdapter { +public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter { @Setter(onMethod = @__({@Autowired})) private WingsOAuth2xConfiguration.Helper helper; @@ -30,25 +29,12 @@ public void configure(ResourceServerSecurityConfigurer resources) throws Excepti @Override public void configure(HttpSecurity http) throws Exception { helper.permitAll(http) - .antMatchers("/test/").permitAll() - .antMatchers("/flywave-*.json").permitAll() - .antMatchers("/index.html","/").permitAll() - .antMatchers("/string.json", "/journal.json").permitAll() - .antMatchers("/test.json").permitAll() - .antMatchers("/sleep.html").permitAll() - .antMatchers("/speed.html").permitAll() - .antMatchers("/oauth2-login.html").permitAll() - .antMatchers("/oauth2.html").hasAuthority("ROLE_ADMIN") + .antMatchers("/login.json", "/logout.json").permitAll() + .antMatchers("/index.html", "/").permitAll() + .antMatchers("/test/**/*").permitAll() + .antMatchers("/user/create.json") + .hasAnyAuthority(Authority.$CREATE_ROLE, Authority.$CREATE_USER) .anyRequest().authenticated() ; } - - @Bean - public RemoteTokenServices tokenService() { - RemoteTokenServices tokenService = new RemoteTokenServices(); - tokenService.setCheckTokenEndpointUrl("http://localhost:8081/oauth/check_token"); - tokenService.setClientId("wings-slardar-id"); - tokenService.setClientSecret("wings-slardar-secret"); - return tokenService; - } } \ No newline at end of file diff --git a/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WebSecurityConfiguration.java b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WebSecurityConfiguration.java new file mode 100644 index 000000000..09f4378ff --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WebSecurityConfiguration.java @@ -0,0 +1,51 @@ +package pro.fessional.wings.example.spring.bean; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.security.authentication.AuthenticationManager; +import org.springframework.security.config.BeanIds; +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +/** + * @author trydofor + * @since 2019-12-01 + */ +@Configuration +@EnableWebSecurity +public class WebSecurityConfiguration extends WebSecurityConfigurerAdapter { + + /** + * The URL paths provided by the framework are + * /oauth/authorize (the authorization endpoint), + * /oauth/token (the token endpoint), + * /oauth/confirm_access (user posts approval for grants here), + * /oauth/error (used to render errors in the authorization server), + * /oauth/check_token (used by Resource Servers to decode access tokens), and + * /oauth/token_key (exposes public key for token verification if using JWT tokens). + *

+ * Note: if your Authorization Server is also a Resource Server then + * there is another security filter chain with lower priority controlling the API resources. + * Fo those requests to be protected by access tokens you need their paths + * not to be matched by the ones in the main user-facing filter chain, + * so be sure to include a request matcher that picks out + * only non-API resources in the WebSecurityConfigurer above. + */ + @Override + public void configure(HttpSecurity http) throws Exception { + http.httpBasic() + .and() + .csrf() + .disable() + ; + } + + // need AuthenticationManager Bean + // password grants are switched on by injecting an AuthenticationManager + @Bean(BeanIds.AUTHENTICATION_MANAGER) + @Override + public AuthenticationManager authenticationManagerBean() throws Exception { + return super.authenticationManagerBean(); + } +} \ No newline at end of file diff --git a/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WingsSwaggerConfiguration.java b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WingsSwaggerConfiguration.java new file mode 100644 index 000000000..cced7402d --- /dev/null +++ b/wings-example/src/main/java/pro/fessional/wings/example/spring/bean/WingsSwaggerConfiguration.java @@ -0,0 +1,41 @@ +package pro.fessional.wings.example.spring.bean; + +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Profile; +import springfox.documentation.builders.ApiInfoBuilder; +import springfox.documentation.builders.PathSelectors; +import springfox.documentation.builders.RequestHandlerSelectors; +import springfox.documentation.service.ApiInfo; +import springfox.documentation.spi.DocumentationType; +import springfox.documentation.spring.web.plugins.Docket; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + +/** + * @author jeff + * @since 2019-10-30 + */ +@Configuration +@EnableSwagger2 +@Profile({"dev", "init"}) +public class WingsSwaggerConfiguration { + + @Bean + public Docket createRestApi() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors + .basePackage("pro.fessional.wings.example.controller")) + .paths(PathSelectors.regex("/.*")) + .build().apiInfo(apiSiteInfo()); + } + + private ApiInfo apiSiteInfo() { + return new ApiInfoBuilder() + .title("专业大翅【wings】") + .description("wings exmaple") + .version("2.2.7-SNAPSHOT") + .build(); + } +} + diff --git a/wings-example/src/main/resources/application.properties b/wings-example/src/main/resources/application.properties index 907b8d105..d377c0c21 100644 --- a/wings-example/src/main/resources/application.properties +++ b/wings-example/src/main/resources/application.properties @@ -1,3 +1,3 @@ -server.error.whitelabel.enabled=false server.port=8080 -spring.application.name=wings-example \ No newline at end of file +spring.application.name=wings-example +spring.profiles.active=dev \ No newline at end of file diff --git a/wings-example/src/main/resources/templates/index.html b/wings-example/src/main/resources/templates/index.html deleted file mode 100644 index e7828a79d..000000000 --- a/wings-example/src/main/resources/templates/index.html +++ /dev/null @@ -1,62 +0,0 @@ - - - - wings example - - -

Sleep(当前窗口)

-/sleep.html?ms=30000 -

I18n(当前窗口)

- -
    -
  • user.hello=
  • -
  • userLocale=
  • -
  • userZoneId=
  • -
  • userDatetime=
  • -
  • systemZoneId=
  • -
  • systemDatetime=
  • -
-
- -

Json(新窗口)

- - -

flywave(新窗口)

-
    -
  • 建议不要通过网页来进行数据库版本管理,因为不安全,日志不全。
  • -
  • 推荐在开发环境下,以WingsFlywaveShardJournalSample的形式执行
  • -
- - -

journal(新窗口)

- - -

Oauth2-resource(新窗口)

- - - - diff --git a/wings-example/src/main/resources/wings-conf/shardingsphere-datasource-09.properties b/wings-example/src/main/resources/wings-conf/shardingsphere-datasource-09.properties index 6ed6ed2b0..d2ae6dc10 100644 --- a/wings-example/src/main/resources/wings-conf/shardingsphere-datasource-09.properties +++ b/wings-example/src/main/resources/wings-conf/shardingsphere-datasource-09.properties @@ -1,5 +1,6 @@ #数据源名称,多数据源以逗号分隔 -spring.shardingsphere.datasource.names=writer,reader +spring.shardingsphere.datasource.names=writer +#spring.shardingsphere.datasource.names=writer,reader # spring.shardingsphere.datasource.writer.type=com.zaxxer.hikari.HikariDataSource spring.shardingsphere.datasource.writer.driver-class-name=com.mysql.cj.jdbc.Driver diff --git a/wings-example/src/main/resources/wings-conf/wings-conditional-manager.properties b/wings-example/src/main/resources/wings-conf/wings-conditional-manager.properties index ee0fb87f3..a240e5edf 100644 --- a/wings-example/src/main/resources/wings-conf/wings-conditional-manager.properties +++ b/wings-example/src/main/resources/wings-conf/wings-conditional-manager.properties @@ -1,3 +1,7 @@ #spring.main.allow-bean-definition-overriding=true -spring.wings.flywave.enabled=true +# 支持flywave +#spring.wings.flywave.enabled=true + +# 支持 enum i18n表和自动生成代码 +#spring.wings.enumi18n.enabled=true diff --git a/wings-example/src/main/resources/wings-conf/wings-error-handling.properties b/wings-example/src/main/resources/wings-conf/wings-error-handling.properties new file mode 100644 index 000000000..886cbf5eb --- /dev/null +++ b/wings-example/src/main/resources/wings-conf/wings-error-handling.properties @@ -0,0 +1 @@ +server.error.whitelabel.enabled=true diff --git a/wings-example/src/main/resources/wings-conf/wings-filter-oauth2x-09.properties b/wings-example/src/main/resources/wings-conf/wings-filter-oauth2x-09.properties new file mode 100644 index 000000000..2d6bb0cab --- /dev/null +++ b/wings-example/src/main/resources/wings-conf/wings-filter-oauth2x-09.properties @@ -0,0 +1,29 @@ +# 别名用来轻度的隐藏oauth特征 +# `client-id`和`grant-type`是oauth的key +# `password`是oauth的value +# 区分TerminalType +wings.slardar.oauth2x.client-id-alias=web_admin,app_android,app_ios,wx_mapp,wx_mp,exe_pc +# +wings.slardar.oauth2x.client-secret-alias= +# 区分UserType +wings.slardar.oauth2x.grant-type-alias=admin,staff,guest +# 区分鉴权类型LoginType +wings.slardar.oauth2x.oauth-password-alias=email_pass,name_pass,mobile_sms,weixin_oauth + +# 可为不同模块的登录设置不同的client +# 单个client的设置,其中`scope`和`grant-type`逗号分割数组 +wings.slardar.oauth2x.client.admin.client-name=wings-example-admin +wings.slardar.oauth2x.client.admin.client-id=wings-example-admin +wings.slardar.oauth2x.client.admin.client-secret=9vCpV36dU6RQvVZJ5WbWcCQ7 +wings.slardar.oauth2x.client.admin.grant-type=authorization_code, client_credentials, password, refresh_token +wings.slardar.oauth2x.client.admin.redirect-uri=http://www.moilioncircle.com +wings.slardar.oauth2x.client.admin.scope=any +wings.slardar.oauth2x.client.admin.auto-approve=true + +wings.slardar.oauth2x.client.staff.client-name=wings-example-staff +wings.slardar.oauth2x.client.staff.client-id=wings-example-staff +wings.slardar.oauth2x.client.staff.client-secret=ditag4dvvFVuJ54dee8MnuvJ +wings.slardar.oauth2x.client.staff.grant-type=authorization_code, client_credentials, password, refresh_token +wings.slardar.oauth2x.client.staff.redirect-uri=http://www.moilioncircle.com +wings.slardar.oauth2x.client.staff.scope=any +wings.slardar.oauth2x.client.staff.auto-approve=true diff --git a/wings-example/src/main/resources/wings-conf/wings-oauth.properties b/wings-example/src/main/resources/wings-conf/wings-oauth.properties new file mode 100644 index 000000000..3d6d5f33f --- /dev/null +++ b/wings-example/src/main/resources/wings-conf/wings-oauth.properties @@ -0,0 +1 @@ +wings.oauth.token.url=http://127.0.0.1:8080/oauth/token \ No newline at end of file diff --git a/wings-example/src/main/resources/wings-flywave/master/2019-07-04u01-schema.sql b/wings-example/src/main/resources/wings-flywave/master/2019-07-04u01-schema.sql new file mode 100644 index 000000000..01bcbcdab --- /dev/null +++ b/wings-example/src/main/resources/wings-flywave/master/2019-07-04u01-schema.sql @@ -0,0 +1,3 @@ +DROP TABLE IF EXISTS `win_auth_role`; +DROP TABLE IF EXISTS `win_user`; +DROP TABLE IF EXISTS `win_user_login`; diff --git a/wings-example/src/main/resources/wings-flywave/master/2019-07-04u02-index.sql b/wings-example/src/main/resources/wings-flywave/master/2019-07-04u02-index.sql new file mode 100644 index 000000000..3b3802de0 --- /dev/null +++ b/wings-example/src/main/resources/wings-flywave/master/2019-07-04u02-index.sql @@ -0,0 +1,13 @@ +-- @plain apply@win_auth_role[_0-9]* error@skip +ALTER TABLE `win_auth_role` + DROP INDEX `ft_auth_set`; + +-- @plain apply@win_user[_0-9]* error@skip +ALTER TABLE `win_user` + DROP INDEX `ft_auth_set`, + DROP INDEX `ft_role_set`; + +-- @plain apply@win_user_login[_0-9]* error@skip +ALTER TABLE `win_user_login` + DROP INDEX `ix_user_id`, + DROP INDEX `uq_login_type_name`; \ No newline at end of file diff --git a/wings-example/src/main/resources/wings-flywave/master/2019-07-04v01-schema.sql b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v01-schema.sql new file mode 100644 index 000000000..60dc4e378 --- /dev/null +++ b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v01-schema.sql @@ -0,0 +1,52 @@ +CREATE TABLE `win_auth_role` ( + `id` BIGINT(20) NOT NULL COMMENT '主键', + `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', + `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', + `delete_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' COMMENT '标记删除', + `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', + `role_type` INT(11) NOT NULL COMMENT '类型/40201##:financial|operation', + `role_name` VARCHAR(100) NOT NULL COMMENT '名字', + `desc` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '描述', + `auth_set` VARCHAR(3000) NOT NULL COMMENT '权限集:authority#401####,逗号分割', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='402/权限组(角色)'; + +CREATE TABLE `win_user` ( + `id` BIGINT(20) NOT NULL COMMENT '主键', + `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', + `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', + `delete_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' COMMENT '标记删除', + `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', + `name` VARCHAR(50) NOT NULL COMMENT '名字', + `gender` INT(11) NOT NULL COMMENT '性别/20101##', + `birth` DATE NOT NULL COMMENT '生日', + `avatar` VARCHAR(200) NOT NULL COMMENT '头像', + `country` CHAR(2) NOT NULL COMMENT '国家/地区', + `language` CHAR(5) NOT NULL COMMENT '使用语言', + `timezone` INT(11) NOT NULL COMMENT '所在时区', + `auth_set` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '权限集:authority#401####,逗号分割,临时增减,负数表减', + `role_set` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '角色集:win_auth_role.id,逗号分割', + `status` INT(11) NOT NULL COMMENT '用户状态/41101##', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='411/用户'; + +CREATE TABLE `win_user_login` ( + `id` BIGINT(20) NOT NULL COMMENT '主键', + `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', + `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', + `delete_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' COMMENT '标记删除', + `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', + `user_id` BIGINT(20) NOT NULL COMMENT '客户id:win_user.id', + `login_type` INT(11) NOT NULL COMMENT '登录类别/41201##:邮件|手机|微信|facebook', + `login_name` VARCHAR(200) NOT NULL COMMENT '登录名称', + `login_pass` VARCHAR(200) NOT NULL COMMENT '登录密码及算法,参考SpringSecurity格式', + `login_salt` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '密码加盐', + `login_para` VARCHAR(2000) NOT NULL COMMENT '登录参数:json格式的第三方参数', + `auth_code` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '长期的识别码', + `bad_count` INT(11) NOT NULL DEFAULT 0 COMMENT '错误次数', + `status` INT(11) NOT NULL COMMENT '鉴权状态/41101##:同用户状态', + PRIMARY KEY (`id`) +) ENGINE = InnoDB + DEFAULT CHARSET = utf8mb4 COMMENT ='412/用户登录'; diff --git a/wings-example/src/main/resources/wings-flywave/revision/20190704v02-index.sql b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v02-index.sql similarity index 71% rename from wings-example/src/main/resources/wings-flywave/revision/20190704v02-index.sql rename to wings-example/src/main/resources/wings-flywave/master/2019-07-04v02-index.sql index a0651703a..6bc3242e7 100644 --- a/wings-example/src/main/resources/wings-flywave/revision/20190704v02-index.sql +++ b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v02-index.sql @@ -1,11 +1,11 @@ -ALTER TABLE `tst_auth_role` +ALTER TABLE `win_auth_role` ADD FULLTEXT INDEX `ft_auth_set` (`auth_set`); -ALTER TABLE `tst_user` +ALTER TABLE `win_user` ADD FULLTEXT INDEX `ft_auth_set` (`auth_set`); -ALTER TABLE `tst_user` +ALTER TABLE `win_user` ADD FULLTEXT INDEX `ft_role_set` (`role_set`); -ALTER TABLE `tst_user_login` +ALTER TABLE `win_user_login` ADD INDEX `ix_user_id` (`user_id`), ADD UNIQUE INDEX `uq_login_type_name` (`login_type`, `login_name`); \ No newline at end of file diff --git a/wings-example/src/main/resources/wings-flywave/master/2019-07-04v03-data.sql b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v03-data.sql new file mode 100644 index 000000000..aada5109d --- /dev/null +++ b/wings-example/src/main/resources/wings-flywave/master/2019-07-04v03-data.sql @@ -0,0 +1,59 @@ +INSERT IGNORE INTO `sys_light_sequence` (`seq_name`, `block_id`, `next_val`, `step_val`, `comments`) +VALUES ('win_authority', 0, 100000000, 100, '系统插入9位起,手动8位'), + ('win_auth_role', 0, 100000000, 100, '系统插入9位起,手动8位'), + ('win_user', 0, 1000, 100, '系统插入4位起,手动3位'), + ('win_user_login', 0, 1000, 100, '系统插入4位起,手动3位'); + +-- 从200#### 开始编号 +REPLACE INTO `sys_constant_enum` (`id`, `type`, `code`, `desc`, `info`) +VALUES (2010100, 'common_gender', 'common_gender', '性别', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (2010101, 'common_gender', 'male', '男', '通常'), + (2010102, 'common_gender', 'female', '女', '通常'), + (2010103, 'common_gender', 'unknown', '未知', '通常'), + + (2020100, 'user_type', 'user_type', '用户类别', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (2020101, 'user_type', 'admin', '管理', ''), + (2020102, 'user_type', 'staff', '员工', ''), + (2020103, 'user_type', 'guest', '客户', ''), + + (2030100, 'terminal_type', 'terminal_type', '用户类别', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (2030101, 'terminal_type', 'web_admin', 'WEB管理端', ''), + (2030102, 'terminal_type', 'app_android', '安卓app', ''), + (2030103, 'terminal_type', 'app_ios', '苹果app', ''), + (2030103, 'terminal_type', 'wx_mapp', '微信小程序', ''), + (2030103, 'terminal_type', 'wx_mp', '微信公众号', ''), + (2030103, 'terminal_type', 'exe_pc', 'pc端exe', ''), + + (4010100, 'authority', 'authority', '权限定义', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (4010101, 'authority', 'CREATE_USER', '创建用户', '用户:'), + (4010102, 'authority', 'DELETE_USER', '删除用户', '用户:'), + (4010203, 'authority', 'CREATE_ROLE', '删除角色', '角色:'), + (4010204, 'authority', 'DELETE_ROLE', '删除角色', '角色:'), + + (4020100, 'role_type', 'role_type', '角色类别', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (4020101, 'role_type', 'financial', '财务', '财务总部'), + (4020102, 'role_type', 'operation', '运营', '财务总部'), + + (4110100, 'user_status', 'user_status', '用户状态', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (4110101, 'user_status', 'uninit', '新建', '建立未登陆'), + (4110102, 'user_status', 'active', '正常', '正常活动'), + (4110103, 'user_status', 'unsafe', '异动', '异动账户'), + (4110104, 'user_status', 'danger', '危险', '危险账户'), + (4110105, 'user_status', 'frozen', '冻结', '冻结账户'), + + (4120100, 'login_type', 'login_type', '用户登录类型', 'classpath:/wings-tmpl/ConstantEnumTemplate.java'), + (4120101, 'login_type', 'email_pass', '邮件', '邮件登录'), + (4120102, 'login_type', 'name_pass', '用户名', '用户名密码'), + (4120103, 'login_type', 'mobile_sms', '手机号', '手机号'), + (4120104, 'login_type', 'weixin_oauth', '微信登录', '微信登录'); + +REPLACE INTO `win_auth_role` (`id`, `commit_id`, `role_type`, `role_name`, `desc`, `auth_set`) +VALUES (10010101, 202006061234, 4020101, 'user.manager', '财务用户管理', '4010101,4010102'), + (10010102, 202006061234, 4020102, 'user.manager', '运营用户管理', '4010204'); + +REPLACE INTO `win_user` (`id`, `commit_id`, `name`, `gender`, `birth`, `avatar`, `country`, `language`, `timezone`, `auth_set`, `role_set`, `status`) +VALUES (1001, 202006061234, '臭豆腐', 2010101, '1993-09-03', 'http://www.trydofor.com/images/post/057.jpg', 'CN', 'zh_CN', 1010201, '4010203,-4010204', '10010101,10010102', 4110101); + +-- 密码 moilioncircle +REPLACE INTO `win_user_login` (`id`, `commit_id`, `user_id`, `login_type`, `login_name`, `login_pass`, `login_salt`, `login_para`, `auth_code`, `bad_count`, `status`) +VALUES (1001, 202006061234, 1001, 4120102, 'trydofor', '{bcrypt}$2a$10$aV.rTLLnOdgDc2jRBFf0Ee70tm33vsYWX5RAasTjJ5mxAmGwrQhtm', '', '', '', 0, 4110101); diff --git a/wings-example/src/main/resources/wings-flywave/revision/20190704u01-schema.sql b/wings-example/src/main/resources/wings-flywave/revision/20190704u01-schema.sql deleted file mode 100644 index 096ce36e3..000000000 --- a/wings-example/src/main/resources/wings-flywave/revision/20190704u01-schema.sql +++ /dev/null @@ -1,4 +0,0 @@ -DROP TABLE IF EXISTS `tst_authority`; -DROP TABLE IF EXISTS `tst_auth_role`; -DROP TABLE IF EXISTS `tst_user`; -DROP TABLE IF EXISTS `tst_user_login`; diff --git a/wings-example/src/main/resources/wings-flywave/revision/20190704u02-index.sql b/wings-example/src/main/resources/wings-flywave/revision/20190704u02-index.sql deleted file mode 100644 index 64f9910d3..000000000 --- a/wings-example/src/main/resources/wings-flywave/revision/20190704u02-index.sql +++ /dev/null @@ -1,10 +0,0 @@ -ALTER TABLE `tst_auth_role` - DROP INDEX `ft_auth_set`; - -ALTER TABLE `tst_user` - DROP INDEX `ft_auth_set`, - DROP INDEX `ft_role_set`; - -ALTER TABLE `tst_user_login` - DROP INDEX `ix_user_id`, - DROP INDEX `uq_login_type_name`; \ No newline at end of file diff --git a/wings-example/src/main/resources/wings-flywave/revision/20190704v01-schema.sql b/wings-example/src/main/resources/wings-flywave/revision/20190704v01-schema.sql deleted file mode 100644 index 94463ff4e..000000000 --- a/wings-example/src/main/resources/wings-flywave/revision/20190704v01-schema.sql +++ /dev/null @@ -1,62 +0,0 @@ -CREATE TABLE `tst_authority` ( - `id` BIGINT(20) NOT NULL COMMENT '主键', - `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', - `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', - `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', - `name` VARCHAR(100) NOT NULL COMMENT '名字', - `desc` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '描述', - `para` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '参数', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='权限/481'; - -CREATE TABLE `tst_auth_role` ( - `id` BIGINT(20) NOT NULL COMMENT '主键', - `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', - `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', - `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', - `deleted` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '标记删除', - `role_type` BIGINT(20) NOT NULL COMMENT '类型/48201##:store|center', - `role_name` VARCHAR(100) NOT NULL COMMENT '名字', - `desc` VARCHAR(200) NOT NULL DEFAULT '' COMMENT '描述', - `auth_set` VARCHAR(3000) NOT NULL COMMENT '权限组:tst_authority.id,逗号分割', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='权限组(角色)/482'; - -CREATE TABLE `tst_user` ( - `id` BIGINT(20) NOT NULL COMMENT '主键', - `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', - `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', - `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', - `name` VARCHAR(50) NOT NULL COMMENT '名字', - `gender` BIGINT(20) NOT NULL COMMENT '性别/10101##', - `birth` DATE NOT NULL COMMENT '生日', - `avatar` VARCHAR(200) NOT NULL COMMENT '头像', - `country` CHAR(2) NOT NULL COMMENT '国家/地区', - `language` CHAR(5) NOT NULL COMMENT '使用语言', - `timezone` VARCHAR(50) NOT NULL COMMENT '所在时区', - `auth_set` VARCHAR(2000) NOT NULL DEFAULT '' COMMENT '权限组:tst_authority.id,逗号分割', - `role_set` VARCHAR(1000) NOT NULL DEFAULT '' COMMENT '权限组:tst_auth_role.id,逗号分割', - `status` BIGINT(20) NOT NULL COMMENT '用户状态/45101##', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='客户/451'; - -CREATE TABLE `tst_user_login` ( - `id` BIGINT(20) NOT NULL COMMENT '主键', - `create_dt` DATETIME(3) NOT NULL DEFAULT CURRENT_TIMESTAMP(3) COMMENT '创建日时(系统)', - `modify_dt` DATETIME(3) NOT NULL DEFAULT '1000-01-01' ON UPDATE CURRENT_TIMESTAMP(3) COMMENT '修改日时(系统)', - `commit_id` BIGINT(20) NOT NULL COMMENT '提交id', - `user_id` BIGINT(20) NOT NULL COMMENT '客户id:tst_user.id', - `login_type` BIGINT(20) NOT NULL COMMENT '登录类别/45201##:邮件|手机|微信|facebook', - `login_name` VARCHAR(200) NOT NULL COMMENT '登录名称', - `login_pass` VARCHAR(200) NOT NULL COMMENT '登录密码及算法,参考SpringSecurity格式', - `login_salt` VARCHAR(100) NOT NULL DEFAULT '' COMMENT '密码加盐', - `login_para` VARCHAR(2000) NOT NULL COMMENT '登录参数:json格式的第三方参数', - `auth_code` VARCHAR(50) NOT NULL DEFAULT '' COMMENT '长期的识别码', - `bad_count` INT(11) NOT NULL DEFAULT 0 COMMENT '错误次数', - `status` BIGINT(20) NOT NULL COMMENT '鉴权状态/45202##', - PRIMARY KEY (`id`) -) ENGINE = InnoDB - DEFAULT CHARSET = utf8mb4 COMMENT ='客户登录/452'; diff --git a/wings-example/src/test/http/login.http b/wings-example/src/test/http/login.http new file mode 100644 index 000000000..55d0b4d60 --- /dev/null +++ b/wings-example/src/test/http/login.http @@ -0,0 +1,33 @@ +# For a quick start check out our HTTP Requests collection (Tools|HTTP Client|Open HTTP Requests Collection) or +# paste cURL into the file and request will be converted to HTTP Request format. +# +# Following HTTP Request Live Templates are available: +# * 'gtrp' and 'gtr' create a GET request with or without query parameters; +# * 'ptr' and 'ptrp' create a POST request with a simple or parameter-like body; +# * 'mptr' and 'fptr' create a POST request to submit a form with a text or file field (multipart/form-data); + +### +POST http://localhost:8080/login.json +Content-Type: application/x-www-form-urlencoded + +username=trydofor&password=moilioncircle + + +### 需要权限 +# 如果access_token 不对则 401 (Unauthorized) +# 需要用login得到的access_token +GET http://localhost:8080/user/create.json +Authorization: Bearer WG-W44KXU-Q7P4A-ZTTK5L8NFNTA2H + +### 需要权限 +# 如果access_token 不对则 401 (Unauthorized) +# 需要用login得到的access_token +GET http://localhost:8080/user/create.json?access_token=WG-W44KXU-Q7P4A-ZTTK5L8NFNTA2H + +### +GET http://localhost:8080/logout.json +Authorization: Bearer WG-W44KXU-Q7P4A-ZTTK5L8NFNTA2H + + + + diff --git a/wings-example/src/test/java/pro/fessional/wings/example/TestZoneId.java b/wings-example/src/test/java/pro/fessional/wings/example/TestZoneId.java deleted file mode 100644 index ec0ac9450..000000000 --- a/wings-example/src/test/java/pro/fessional/wings/example/TestZoneId.java +++ /dev/null @@ -1,15 +0,0 @@ -package pro.fessional.wings.example; - -import java.time.ZoneId; - -/** - * @author trydofor - * @since 2019-07-03 - */ -public class TestZoneId { - public static void main(String[] args) { - for (String id : ZoneId.getAvailableZoneIds()) { - System.out.println(id); - } - } -} diff --git a/wings-example/src/test/java/pro/fessional/wings/example/WingsExampleTestApplication.java b/wings-example/src/test/java/pro/fessional/wings/example/WingsExampleTestApplication.java new file mode 100644 index 000000000..8927ac53d --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/WingsExampleTestApplication.java @@ -0,0 +1,28 @@ +package pro.fessional.wings.example; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.AutoConfigureBefore; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.Bean; +import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity; +import org.springframework.security.config.core.GrantedAuthorityDefaults; +import pro.fessional.wings.example.spring.bean.ResourceServerConfiguration; + +/** + * @author trydofor + * @since 2019-06-26 + */ +@SpringBootApplication +@AutoConfigureBefore(ResourceServerConfiguration.class) +@EnableGlobalMethodSecurity(securedEnabled = true) +public class WingsExampleTestApplication { + + @Bean + public GrantedAuthorityDefaults grantedAuthorityDefaults() { + return new GrantedAuthorityDefaults(""); + } + + public static void main(String[] args) { + SpringApplication.run(WingsExampleTestApplication.class, args); + } +} diff --git a/wings-example/src/test/java/pro/fessional/wings/example/auth/SecuredService.java b/wings-example/src/test/java/pro/fessional/wings/example/auth/SecuredService.java new file mode 100644 index 000000000..d2cb5e188 --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/auth/SecuredService.java @@ -0,0 +1,19 @@ +package pro.fessional.wings.example.auth; + +import org.springframework.security.access.annotation.Secured; +import org.springframework.stereotype.Service; +import pro.fessional.wings.example.enums.auto.Authority; + +/** + * 需要设置 SecuredEnabledConfiguration + * @author trydofor + * @since 2020-06-21 + */ +@Service +public class SecuredService { + + @Secured(Authority.$CREATE_USER) + public String secured(){ + return Authority.$CREATE_USER; + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestI18nController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestI18nController.java similarity index 98% rename from wings-example/src/main/java/pro/fessional/wings/example/controller/TestI18nController.java rename to wings-example/src/test/java/pro/fessional/wings/example/controller/TestI18nController.java index 10b85981c..0aeabdcca 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestI18nController.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestI18nController.java @@ -29,7 +29,7 @@ public class TestI18nController { private final MessageSource messageSource; - @RequestMapping({"/", "index.html"}) + @RequestMapping({"/", "/index.html"}) public String index(HttpServletRequest request, Model model) { ZonedDateTime now = ZonedDateTime.now(); ZoneId systemZoneId = ZoneId.systemDefault(); diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestJournalController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestJournalController.java similarity index 92% rename from wings-example/src/main/java/pro/fessional/wings/example/controller/TestJournalController.java rename to wings-example/src/test/java/pro/fessional/wings/example/controller/TestJournalController.java index a0e81c33c..3a1e6166f 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestJournalController.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestJournalController.java @@ -20,14 +20,14 @@ public class TestJournalController { private final JournalService journalService; - @RequestMapping("/string.json") + @RequestMapping("/test/string.json") @ResponseBody public String string() { JournalService.Journal journal = journalService.commit(SysCommitJournalTable.class); return journal.toString(); } - @RequestMapping("/journal.json") + @RequestMapping("/test/journal.json") @ResponseBody public JournalService.Journal journal() { JournalService.Journal journal = journalService.commit(SysCommitJournalTable.class); diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestJsonController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestJsonController.java similarity index 98% rename from wings-example/src/main/java/pro/fessional/wings/example/controller/TestJsonController.java rename to wings-example/src/test/java/pro/fessional/wings/example/controller/TestJsonController.java index cb87687ba..2f4cae630 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestJsonController.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestJsonController.java @@ -72,7 +72,7 @@ public static class JsonIt { private ZoneId userZoneId; } - @RequestMapping("/test.json") + @RequestMapping("/test/test.json") @ResponseBody public R jsonIt(HttpServletRequest request) { JsonIt json = new JsonIt(); diff --git a/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSecuredController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSecuredController.java new file mode 100644 index 000000000..7e229518e --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSecuredController.java @@ -0,0 +1,25 @@ +package pro.fessional.wings.example.controller; + +import lombok.Setter; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import pro.fessional.wings.example.auth.SecuredService; + +/** + * @author trydofor + * @since 2020-06-21 + */ +@Controller +public class TestSecuredController { + + @Setter(onMethod = @__({@Autowired})) + SecuredService securedService; + + @RequestMapping("/test/secured-test.json") + @ResponseBody + public String securedTest() { + return securedService.secured(); + } +} diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestSleepController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSleepController.java similarity index 95% rename from wings-example/src/main/java/pro/fessional/wings/example/controller/TestSleepController.java rename to wings-example/src/test/java/pro/fessional/wings/example/controller/TestSleepController.java index 4a299a858..9ac4f3b7c 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestSleepController.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSleepController.java @@ -20,7 +20,7 @@ public class TestSleepController { private final Random unsafeRandom = new Random(); - @RequestMapping("/sleep.html") + @RequestMapping("/test/sleep.html") public String sleep(@RequestParam("ms") long ms) { long half = ms / 2; long slp = ((long) (unsafeRandom.nextDouble() * half)) + half; diff --git a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestSpeedController.java b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSpeedController.java similarity index 92% rename from wings-example/src/main/java/pro/fessional/wings/example/controller/TestSpeedController.java rename to wings-example/src/test/java/pro/fessional/wings/example/controller/TestSpeedController.java index 313f3b0cf..5c15df254 100644 --- a/wings-example/src/main/java/pro/fessional/wings/example/controller/TestSpeedController.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/controller/TestSpeedController.java @@ -16,7 +16,7 @@ @RequiredArgsConstructor public class TestSpeedController { - @RequestMapping("/speed.html") + @RequestMapping("/test/speed.html") @ResponseBody public String speed() { return "speed"; diff --git a/wings-example/src/test/java/pro/fessional/wings/example/WingsI18nDepTest.java b/wings-example/src/test/java/pro/fessional/wings/example/deps/WingsI18nDepTest.java similarity index 84% rename from wings-example/src/test/java/pro/fessional/wings/example/WingsI18nDepTest.java rename to wings-example/src/test/java/pro/fessional/wings/example/deps/WingsI18nDepTest.java index 8ced17953..418eadde9 100644 --- a/wings-example/src/test/java/pro/fessional/wings/example/WingsI18nDepTest.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/deps/WingsI18nDepTest.java @@ -1,4 +1,4 @@ -package pro.fessional.wings.example; +package pro.fessional.wings.example.deps; import lombok.Setter; import org.junit.Test; @@ -7,6 +7,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.context.MessageSource; import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleTestApplication; import java.util.Locale; @@ -18,7 +19,7 @@ */ @RunWith(SpringRunner.class) -@SpringBootTest(properties = {"debug = true"}) +@SpringBootTest(classes = WingsExampleTestApplication.class, properties = {"debug = true"}) public class WingsI18nDepTest { @Setter(onMethod = @__({@Autowired})) diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/Wings1SchemaGen.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings1SchemaGen.java new file mode 100644 index 000000000..256385615 --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings1SchemaGen.java @@ -0,0 +1,88 @@ +package pro.fessional.wings.example.init; + +import lombok.Setter; +import lombok.val; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleApplication; +import pro.fessional.wings.faceless.flywave.SchemaRevisionManager; +import pro.fessional.wings.faceless.util.FlywaveRevisionScanner; + +import java.util.SortedMap; + +import static pro.fessional.wings.faceless.util.FlywaveRevisionScanner.REVISION_3RD_ENU18N; +import static pro.fessional.wings.faceless.util.FlywaveRevisionScanner.REVISION_PATH_BRANCH_3RD_ENU18N; +import static pro.fessional.wings.faceless.util.FlywaveRevisionScanner.REVISION_PATH_MASTER; + +/** + * ① 使用wings的flywave管理数据库版本 + * + * @author trydofor + * @since 2019-06-22 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WingsExampleApplication.class, properties = + {"debug = true", + "spring.wings.flywave.enabled=true", +// "spring.wings.enumi18n.enabled=true", +// "spring.shardingsphere.datasource.names=master", +// "spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://127.0.0.1:3306/wings?autoReconnect=true&useSSL=false", +// "spring.shardingsphere.datasource.master.username=trydofor", +// "spring.shardingsphere.datasource.master.password=moilioncircle", + }) +@Ignore("手动执行一次,初始化步骤,危险操作") +public class Wings1SchemaGen { + + @Setter(onMethod = @__({@Autowired})) + private SchemaRevisionManager schemaRevisionManager; + + @Test + public void gen() { + long revision = 2019_0704_03L; + long commitId = 2020_0606_1235L; +// String path = "classpath*:/wings-flywave/revision/**/*.sql"; // 全部类路径 +// String path = "classpath:/wings-flywave/revision/**/*.sql"; // 当前类路径 +// String path = "file:src/main/resources/wings-flywave/revision/**/*.sql"; // 具体文件 +// String path = "file:src/main/resources/wings-flywave/dev-revi/**/*.sql"; // DEV文件 + val sqls = FlywaveRevisionScanner.scan(REVISION_PATH_MASTER, REVISION_PATH_BRANCH_3RD_ENU18N); + + // 是否更新前,更新掉数据库中的脚本,以免字段修改无法降级 + mergeThenDown3rdPub(sqls, revision, commitId); + } + + //先降级,否则无法更新已更新的sql + private void down3rdThenMergePub(SortedMap sqls, long revision, long commitId) { + schemaRevisionManager.publishRevision(REVISION_3RD_ENU18N, commitId); + schemaRevisionManager.checkAndInitSql(sqls, commitId, true); + schemaRevisionManager.publishRevision(revision, commitId); + } + //先降级,否则无法更新已更新的sql + private void mergeThenDown3rdPub(SortedMap sqls, long revision, long commitId) { + schemaRevisionManager.checkAndInitSql(sqls, commitId, true); + schemaRevisionManager.publishRevision(REVISION_3RD_ENU18N, commitId); + schemaRevisionManager.publishRevision(revision, commitId); + } + + // 直接升级 + private void mergeThenPub(SortedMap sqls, long revision, long commitId) { + schemaRevisionManager.checkAndInitSql(sqls, commitId, true); + schemaRevisionManager.publishRevision(revision, commitId); + } + + // 重复升级 + private void forceDownThenMergePub(SortedMap sqls, long revision, long commitId) { + schemaRevisionManager.forceApplyBreak(revision, commitId, false, null); + schemaRevisionManager.checkAndInitSql(sqls, commitId, true); + schemaRevisionManager.publishRevision(revision, commitId); + } + + // 强制升级 + private void insertThenForce(SortedMap sqls, long revision, long commitId) { + schemaRevisionManager.checkAndInitSql(sqls, commitId, false); + schemaRevisionManager.forceApplyBreak(revision, commitId, true, null); + } +} \ No newline at end of file diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleJooqCodeGenerator.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings2JooqJavaGen.java similarity index 69% rename from wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleJooqCodeGenerator.java rename to wings-example/src/test/java/pro/fessional/wings/example/init/Wings2JooqJavaGen.java index eca3e05c2..9e616fa1f 100644 --- a/wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleJooqCodeGenerator.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings2JooqJavaGen.java @@ -3,11 +3,15 @@ import pro.fessional.wings.faceless.jooqgen.WingsCodeGenerator; /** + * ②根据数据库schema自动生成jooq代码 + * * @author trydofor * @since 2019-05-31 */ -public class WingsExampleJooqCodeGenerator { +public class Wings2JooqJavaGen { + // WingsFlywaveInitDatabaseSample + // 注意在目标工程中,应该注释掉.springRepository(false),使Dao自动加载 public static void main(String[] args) { String database = "wings_0"; WingsCodeGenerator.builder() @@ -16,13 +20,12 @@ public static void main(String[] args) { .jdbcUser("trydofor") .jdbcPassword("moilioncircle") .databaseSchema(database) -// .databaseIncludes(".*") -// .databaseExcludes(".*\\$log # 日志表\n" -// + "| SPRING.* # Spring\n" -// + "| SYS_SCALE_SEQUENCE # 特殊处理") + .databaseIncludes("win_.*") + .databaseExcludes("sys_.*") // jdbc实现或默认实现了 .databaseVersionProvider("SELECT MAX(revision) FROM sys_schema_version WHERE apply_dt > '1000-01-01'") .targetPackage("pro.fessional.wings.example.database.autogen") .targetDirectory("wings-example/src/main/java/") + .springRepository(true) .buildAndGenerate(); } } diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/Wings3ConstEnumGen.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings3ConstEnumGen.java new file mode 100644 index 000000000..00f954640 --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings3ConstEnumGen.java @@ -0,0 +1,49 @@ +package pro.fessional.wings.example.init; + +import lombok.Setter; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleApplication; +import pro.fessional.wings.faceless.database.autogen.tables.daos.SysConstantEnumDao; +import pro.fessional.wings.faceless.database.autogen.tables.pojos.SysConstantEnum; +import pro.fessional.wings.faceless.util.ConstantEnumGenerator; + +import java.util.List; + +/** + * ③ 根据数据库记录,自动生成enum类 + * + * @author trydofor + * @since 2020-06-10 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WingsExampleApplication.class, properties = + {"debug = true", + "spring.wings.enumi18n.enabled=true", +// "spring.wings.flywave.enabled=true", +// "spring.shardingsphere.datasource.names=master", +// "spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://127.0.0.1:3306/wings?autoReconnect=true&useSSL=false", +// "spring.shardingsphere.datasource.master.username=trydofor", +// "spring.shardingsphere.datasource.master.password=moilioncircle", + }) +@Ignore("手动生成Java类,依赖分支feature/enum-i18n的2019052101") +public class Wings3ConstEnumGen { + + @Setter(onMethod = @__({@Autowired})) + SysConstantEnumDao sysConstantEnumDao; + + @Test + public void gen() throws Exception { + List all = sysConstantEnumDao.findAll(); + ConstantEnumGenerator.builder() + .setJavaSource("./src/main/java/") + .setJavaPackage("pro.fessional.wings.example.enums.auto") + // 如果够用,可以直接用,否则用自己生成的 + .addExcludeType("standard_timezone", "standard_language") + .generate(SysConstantEnum.class, all); + } +} \ No newline at end of file diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/Wings4SchemaDumper.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings4SchemaDumper.java new file mode 100644 index 000000000..6db27db20 --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings4SchemaDumper.java @@ -0,0 +1,81 @@ +package pro.fessional.wings.example.init; + +import kotlin.jvm.functions.Function1; +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleApplication; +import pro.fessional.wings.faceless.flywave.SchemaFulldumpManager; + +import javax.sql.DataSource; +import java.util.List; + +/** + * ④根据配置,把schema导出,方便保存和对比 + * 更牛的数据库操作,参考 godbart项目 + * + * @author trydofor + * @since 2019-12-26 + */ + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WingsExampleApplication.class, properties = + {"debug = true", + "spring.wings.flywave.enabled=true", +// "spring.wings.enumi18n.enabled=true", +// "spring.shardingsphere.datasource.names=master", +// "spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://127.0.0.1:3306/wings?autoReconnect=true&useSSL=false", +// "spring.shardingsphere.datasource.master.username=trydofor", +// "spring.shardingsphere.datasource.master.password=moilioncircle", + }) +@Ignore("手动执行,版本更新时处理") +@Slf4j +public class Wings4SchemaDumper { + + @Setter(onMethod = @__({@Autowired})) + private DataSource dataSource; + + @Setter(onMethod = @__({@Autowired})) + private SchemaFulldumpManager schemaFulldumpManager; + + @Test + public void dump() { + Function1, List> ddl = SchemaFulldumpManager.groupedTable(false, + "-- ==================== Basement-4(B4/10#):基础 =======================", + "sys_schema_version", // 101/表结构版本 + "sys_schema_journal", // 102/数据触发器 + "sys_light_sequence", // 103/序号生成器 + "sys_commit_journal", // 104/数据变更集 + "-- ==================== Basement-3(B3/15#):多语言,多时区,多货币 =======================", + "sys_constant_enum", // 105/常量枚举:自动生成enum类 + "sys_standard_i18n", // 106/标准多国语 + "-- ==================== Floor-1(F4/40#):用户权限 =======================", + "win_auth_role", // 402/权限组(角色) + "win_user", // 411/用户 + "win_user_login", // 412/用户登录 + "-- ==================== Floor-2(F4/45#):商品信息=======================" + ); + Function1, List> rec = SchemaFulldumpManager.includeRegexp( + "sys_light_.*", + "sys_constant_enum", + "sys_standard_i18n", + "win_auth_role", + "win_user", + "win_user_login" + ); + + String type = "local"; + String root = "./src/test/resources/wings-flywave/fulldump/" + type; + log.info("===== dump ddl to " + root); + List ddls = schemaFulldumpManager.dumpDdl(dataSource, ddl); + schemaFulldumpManager.saveFile(root + "/schema.sql", ddls); + log.info("===== dump rec to " + root); + List recs = schemaFulldumpManager.dumpRec(dataSource, rec); + schemaFulldumpManager.saveFile(root + "/record.sql", recs); + } +} diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/Wings5SchemaJournal.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings5SchemaJournal.java new file mode 100644 index 000000000..58783423d --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings5SchemaJournal.java @@ -0,0 +1,60 @@ +package pro.fessional.wings.example.init; + +import lombok.Setter; +import lombok.extern.slf4j.Slf4j; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleApplication; +import pro.fessional.wings.faceless.flywave.SchemaJournalManager; + +import java.util.Arrays; +import java.util.List; + +/** + * ⑤ 使用wings的flywave,生成trigger和跟踪表 + * + * @author trydofor + * @since 2019-12-26 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WingsExampleApplication.class, properties = + {"debug = true", + "spring.wings.flywave.enabled=true", +// "spring.wings.enumi18n.enabled=true", +// "spring.shardingsphere.datasource.names=master", +// "spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://127.0.0.1:3306/wings?autoReconnect=true&useSSL=false", +// "spring.shardingsphere.datasource.master.username=trydofor", +// "spring.shardingsphere.datasource.master.password=moilioncircle", + }) +@Ignore("手动执行,版本更新时处理") +@Slf4j +public class Wings5SchemaJournal { + + @Setter(onMethod = @__({@Autowired})) + private SchemaJournalManager schemaJournalManager; + + @Test + public void journal() { + long commitId = 2020_0606_1423L; + boolean enable = true; + List tables = Arrays.asList( + "win_user", + "win_user_login" + ); + + for (String table : tables) { + log.info("====== init table={}", table); + schemaJournalManager.checkAndInitDdl(table, commitId); + } + + for (String table : tables) { + log.info("====== init delete,update={}", table); + schemaJournalManager.publishDelete(table, enable, commitId); + schemaJournalManager.publishUpdate(table, enable, commitId); + } + } +} diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/Wings6RequestMapper.java b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings6RequestMapper.java new file mode 100644 index 000000000..de50ebbd8 --- /dev/null +++ b/wings-example/src/test/java/pro/fessional/wings/example/init/Wings6RequestMapper.java @@ -0,0 +1,37 @@ +package pro.fessional.wings.example.init; + +import lombok.Setter; +import org.junit.Ignore; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; +import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleApplication; +import pro.fessional.wings.slardar.webmvc.RequestMappingHelper; + +import java.util.List; + +/** + * ⑥ 使用wings的flywave,生成trigger和跟踪表 + * + * @author trydofor + * @since 2019-12-26 + */ +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WingsExampleApplication.class) +@Ignore("手动执行,版本更新时处理") +public class Wings6RequestMapper { + + @Setter(onMethod = @__({@Autowired})) + private ApplicationContext context; + + @Test + public void infoAllMapping() { + List infos = RequestMappingHelper.infoAllMapping(context); + for (RequestMappingHelper.Info info : infos) { + System.out.println(info.toJson()); + } + } +} diff --git a/wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleDataBaseGenerator.java b/wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleDataBaseGenerator.java deleted file mode 100644 index f0d3a6c9c..000000000 --- a/wings-example/src/test/java/pro/fessional/wings/example/init/WingsExampleDataBaseGenerator.java +++ /dev/null @@ -1,52 +0,0 @@ -package pro.fessional.wings.example.init; - -import org.junit.Ignore; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import pro.fessional.wings.faceless.flywave.SchemaRevisionManager; -import pro.fessional.wings.faceless.util.FlywaveRevisionScanner; - -import java.util.SortedMap; - -import static pro.fessional.wings.faceless.util.FlywaveRevisionScanner.REVISION_2ND_IDLOGS; - -/** - * @author trydofor - * @since 2019-06-22 - */ -@RunWith(SpringRunner.class) -@SpringBootTest -public class WingsExampleDataBaseGenerator { - - private SchemaRevisionManager schemaRevisionManager; - - @Autowired - public void setSchemaRevisionManager(SchemaRevisionManager schemaRevisionManager) { - this.schemaRevisionManager = schemaRevisionManager; - } - - @Test - @Ignore("手动执行一次,初始化步骤") - public void initR520() { - // 初始 - SortedMap sqls = FlywaveRevisionScanner.scanMaster(); - schemaRevisionManager.checkAndInitSql(sqls, 0, false); - - // 初始为可用状态 - schemaRevisionManager.publishRevision(REVISION_2ND_IDLOGS, 0); - } - - @Test - @Ignore("手动执行,版本更新时处理") - public void initOther() { -// String path = "classpath*:/wings-flywave/master/**/*.sql"; // 全部类路径 -// String path = "classpath:/wings-flywave/master/**/*.sql"; // 当前类路径 - String path = "file:src/main/resources/wings-flywave/master/**/*.sql"; // 具体文件 - SortedMap sqls = FlywaveRevisionScanner.scan(path); - schemaRevisionManager.checkAndInitSql(sqls, 0, false); - schemaRevisionManager.publishRevision(3L, 0); - } -} \ No newline at end of file diff --git a/wings-example/src/test/java/pro/fessional/wings/example/load/TestJsonControllerTest.java b/wings-example/src/test/java/pro/fessional/wings/example/load/TestJsonControllerTest.java index bcca58614..5c109dffe 100644 --- a/wings-example/src/test/java/pro/fessional/wings/example/load/TestJsonControllerTest.java +++ b/wings-example/src/test/java/pro/fessional/wings/example/load/TestJsonControllerTest.java @@ -8,6 +8,7 @@ import org.springframework.boot.test.web.client.TestRestTemplate; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; +import pro.fessional.wings.example.WingsExampleTestApplication; import java.util.concurrent.CountDownLatch; import java.util.concurrent.atomic.AtomicInteger; @@ -21,7 +22,7 @@ @RunWith(SpringRunner.class) //@SpringBootTest(properties = {"debug = true"}) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) +@SpringBootTest(classes = WingsExampleTestApplication.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) public class TestJsonControllerTest { private TestRestTemplate tmpl; diff --git a/wings-example/src/test/jmeter/load-test.jmx b/wings-example/src/test/jmeter/load-test.jmx index 9db835db4..236959a5e 100644 --- a/wings-example/src/test/jmeter/load-test.jmx +++ b/wings-example/src/test/jmeter/load-test.jmx @@ -66,7 +66,7 @@ - /test.json + /test/test.json GET true false @@ -85,7 +85,7 @@ - /sleep.html?ms=30 + /test/sleep.html?ms=30 GET true false @@ -104,7 +104,7 @@ - /speed.html + /test/speed.html GET true false diff --git a/wings-example/src/test/resources/templates/index.html b/wings-example/src/test/resources/templates/index.html new file mode 100644 index 000000000..0b2b33c23 --- /dev/null +++ b/wings-example/src/test/resources/templates/index.html @@ -0,0 +1,95 @@ + + + + wings example + + +

Sleep(当前窗口)

+/sleep.html?ms=30000 +

I18n(当前窗口)

+ +
    +
  • user.hello=
  • +
  • userLocale=
  • +
  • userZoneId=
  • +
  • userDatetime=
  • +
  • systemZoneId=
  • +
  • systemDatetime=
  • +
+
+ +

Json(新窗口)

+ + +

journal(新窗口)

+ + +

Oauth2(Ajax)

+
+ 用户:
+ 密码:
+
+ + + + +
+ + + + + + diff --git a/wings-faceless/readme.md b/wings-faceless/readme.md index 628604eda..827663a27 100644 --- a/wings-faceless/readme.md +++ b/wings-faceless/readme.md @@ -342,4 +342,27 @@ i18n可以使用CombinableMessageSource动态添加,处理service内消息的 * ConstantEnumGenSample - enum类生成例子 * JooqJavaCodeGenSample - jooq类生成例子 * WingsSchemaDumper - schema和数据dump例子 - * WingsSchemaJournal - track表控制例子 \ No newline at end of file + * WingsSchemaJournal - track表控制例子 + +### 005.本地创建mysql docker + +```bash +sudo tee /Users/trydofor/Docker/mysql/conf/moilioncircle.cnf << EOF +[mysqld] +innodb_file_per_table = 1 +innodb_ft_min_token_size = 1 +ft_min_word_len = 1 +character-set-server = UTF8MB4 +max_allowed_packet = 1024M +skip_ssl +EOF +# 启动docker +docker run -d \ + --name mysql \ + --restart=unless-stopped \ + -e MYSQL_ALLOW_EMPTY_PASSWORD=yes \ + -v /Users/trydofor/Docker/mysql/conf:/etc/mysql/conf.d \ + -v /Users/trydofor/Docker/mysql/data:/var/lib/mysql \ + -p 3306:3306 \ +mysql:5.7 +``` \ No newline at end of file diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/ConstantEnumUtil.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/ConstantEnumUtil.java index f85da4879..041b1741d 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/ConstantEnumUtil.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/ConstantEnumUtil.java @@ -3,6 +3,8 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import pro.fessional.mirana.data.CodeEnum; +import pro.fessional.mirana.data.Nulls; +import pro.fessional.mirana.math.AnyIntegerUtil; import java.util.ArrayList; import java.util.Collections; @@ -232,4 +234,70 @@ public static List groupInfo(Function List codes(T[] es, String... codes) { + if (codes == null || codes.length == 0) return Collections.emptyList(); + List result = new ArrayList<>(codes.length); + for (String s : codes) { + T c = codeOrNull(s, es); + if (c != null) result.add(c); + } + return result; + } + + @NotNull + public static List ids(T[] es, String... ids) { + if (ids == null || ids.length == 0) return Collections.emptyList(); + List result = new ArrayList<>(ids.length); + for (String s : ids) { + T c = idOrNull(AnyIntegerUtil.val32(s), es); + if (c != null) result.add(c); + } + return result; + } + + @NotNull + public static > List names(T[] es, String... names) { + if (names == null || names.length == 0) return Collections.emptyList(); + List result = new ArrayList<>(names.length); + for (String s : names) { + T c = nameOrNull(s, es); + if (c != null) result.add(c); + } + return result; + } + + @NotNull + public static String joinIds(String delimiter, T... es) { + if (es == null || es.length == 0) return Nulls.Str; + StringBuilder sb = new StringBuilder(); + for (T e : es) { + sb.append(delimiter); + sb.append(e.getId()); + } + return sb.substring(delimiter.length()); + } + + @NotNull + public static > String joinNames(String delimiter, T... es) { + if (es == null || es.length == 0) return Nulls.Str; + StringBuilder sb = new StringBuilder(); + for (T e : es) { + sb.append(delimiter); + sb.append(e.name()); + } + return sb.substring(delimiter.length()); + } + + @NotNull + public static String joinCodes(String delimiter, T... es) { + if (es == null || es.length == 0) return Nulls.Str; + StringBuilder sb = new StringBuilder(); + for (T e : es) { + sb.append(delimiter); + sb.append(e.getCode()); + } + return sb.substring(delimiter.length()); + } } diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/TimezoneEnumUtil.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/TimezoneEnumUtil.java index abf328637..a6c0bf7b2 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/TimezoneEnumUtil.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/TimezoneEnumUtil.java @@ -1,8 +1,94 @@ package pro.fessional.wings.faceless.enums; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import pro.fessional.mirana.i18n.ZoneIdResolver; + +import java.time.ZoneId; + /** * @author trydofor * @since 2020-06-11 */ -public class TimezoneEnumUtil { +public class TimezoneEnumUtil extends ConstantEnumUtil { + + @SafeVarargs + @Nullable + public static T zoneIdOrNull(String zoneId, T... es) { + if (zoneId == null || es == null || es.length == 0) return null; + return zoneIdOrNull(ZoneIdResolver.zoneId(zoneId), es); + } + + @SafeVarargs + @Nullable + public static T zoneIdOrNull(ZoneId zoneId, T... es) { + if (zoneId == null || es == null || es.length == 0) return null; + + String zidStr = zoneId.getId(); + for (T e : es) { + if (e.toZoneId().getId().equalsIgnoreCase(zidStr)) { + return e; + } + } + + return null; + } + + @SafeVarargs + @NotNull + public static T zoneIdOrThrow(String zoneId, T... es) { + T t = zoneIdOrNull(zoneId, es); + if (t == null) { + throw new IllegalArgumentException("can not found StandardTimezoneEnum by zoneId=" + zoneId); + } else { + return t; + } + } + + @SafeVarargs + @NotNull + public static T zoneIdOrThrow(ZoneId zoneId, T... es) { + T t = zoneIdOrNull(zoneId, es); + if (t == null) { + throw new IllegalArgumentException("can not found StandardTimezoneEnum by zoneId=" + zoneId); + } else { + return t; + } + } + + @SafeVarargs + @NotNull + public static T zoneIdOrHint(String zoneId, String hint, T... es) { + T t = zoneIdOrNull(zoneId, es); + if (t == null) { + throw new IllegalArgumentException(hint); + } else { + return t; + } + } + + @SafeVarargs + @NotNull + public static T zoneIdOrHint(ZoneId zoneId, String hint, T... es) { + T t = zoneIdOrNull(zoneId, es); + if (t == null) { + throw new IllegalArgumentException(hint); + } else { + return t; + } + } + + @SafeVarargs + @NotNull + public static T zoneIdOrElse(String zoneId, T el, T... es) { + T t = zoneIdOrNull(zoneId, es); + return t == null ? el : t; + } + + @SafeVarargs + @NotNull + public static T zoneIdOrElse(ZoneId zoneId, T el, T... es) { + T t = zoneIdOrNull(zoneId, es); + return t == null ? el : t; + } } diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardLanguage.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardLanguage.java index 43509ea7b..932fdf911 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardLanguage.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardLanguage.java @@ -11,7 +11,7 @@ * * @author trydofor * @see Locale#toString() - * @since 2020-06-13 + * @since 2020-06-21 */ public enum StandardLanguage implements StandardLanguageEnum { SUPER(1020100, "standard_language", "标准语言", "classpath:/wings-tmpl/StandardLanguageTemplate.java"), @@ -28,6 +28,20 @@ public enum StandardLanguage implements StandardLanguageEnum { ZH_CN(1020111, "zh_CN", "简体中文", ""), ZH_HK(1020112, "zh_HK", "繁体中文", ""), ; + public static final String $SUPER = "standard_language"; + public static final String $AR_AE = "ar_AE"; + public static final String $DE_DE = "de_DE"; + public static final String $EN_US = "en_US"; + public static final String $ES_ES = "es_ES"; + public static final String $FR_FR = "fr_FR"; + public static final String $IT_IT = "it_IT"; + public static final String $JA_JP = "ja_JP"; + public static final String $KO_KR = "ko_KR"; + public static final String $RU_RU = "ru_RU"; + public static final String $TH_TH = "th_TH"; + public static final String $ZH_CN = "zh_CN"; + public static final String $ZH_HK = "zh_HK"; + public static final boolean useIdAsKey = false; private final int id; diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardTimezone.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardTimezone.java index 66a9b833f..d2a008fdb 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardTimezone.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/auto/StandardTimezone.java @@ -11,7 +11,7 @@ /** * @author trydofor * @see ZoneId#getAvailableZoneIds() - * @since 2020-06-13 + * @since 2020-06-21 */ public enum StandardTimezone implements StandardTimezoneEnum { SUPER(1010100, "standard_timezone", "标准时区", "classpath:/wings-tmpl/StandardTimezoneTemplate.java"), @@ -37,6 +37,29 @@ public enum StandardTimezone implements StandardTimezoneEnum { CANADA𓃬NEWFOUNDLAND(1010905, "Canada/Newfoundland", "纽芬兰时(NST):圣约翰斯", "加拿大"), CANADA𓃬PACIFIC(1010906, "Canada/Pacific", "太平洋时(PST):温哥华", "加拿大"), ; + public static final String $SUPER = "standard_timezone"; + public static final String $GMT = "GMT"; + public static final String $ASIA𓃬SHANGHAI = "Asia/Shanghai"; + public static final String $AMERICA𓃬CHICAGO = "America/Chicago"; + public static final String $AMERICA𓃬LOS_ANGELES = "America/Los_Angeles"; + public static final String $AMERICA𓃬NEW_YORK = "America/New_York"; + public static final String $AMERICA𓃬PHOENIX = "America/Phoenix"; + public static final String $US𓃬ALASKA = "US/Alaska"; + public static final String $US𓃬HAWAII = "US/Hawaii"; + public static final String $ASIA𓃬JAKARTA = "Asia/Jakarta"; + public static final String $ASIA𓃬JAYAPURA = "Asia/Jayapura"; + public static final String $ASIA𓃬MAKASSAR = "Asia/Makassar"; + public static final String $ASIA𓃬KUALA_LUMPUR = "Asia/Kuala_Lumpur"; + public static final String $ASIA𓃬SEOUL = "Asia/Seoul"; + public static final String $ASIA𓃬SINGAPORE = "Asia/Singapore"; + public static final String $ASIA𓃬TOKYO = "Asia/Tokyo"; + public static final String $CANADA𓃬ATLANTIC = "Canada/Atlantic"; + public static final String $CANADA𓃬CENTRAL = "Canada/Central"; + public static final String $CANADA𓃬EASTERN = "Canada/Eastern"; + public static final String $CANADA𓃬MOUNTAIN = "Canada/Mountain"; + public static final String $CANADA𓃬NEWFOUNDLAND = "Canada/Newfoundland"; + public static final String $CANADA𓃬PACIFIC = "Canada/Pacific"; + public static final boolean useIdAsKey = true; private final int id; diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/ConstantEnumTemplate.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/ConstantEnumTemplate.java index 21cd717c1..f4e320c4e 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/ConstantEnumTemplate.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/ConstantEnumTemplate.java @@ -11,8 +11,7 @@ */ public enum ConstantEnumTemplate implements ConstantEnum, StandardI18nEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardLanguageTemplate.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardLanguageTemplate.java index 14b68a883..0fb16f273 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardLanguageTemplate.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardLanguageTemplate.java @@ -15,8 +15,7 @@ */ public enum StandardLanguageTemplate implements StandardLanguageEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardTimezoneTemplate.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardTimezoneTemplate.java index f6a40ef04..401d99d33 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardTimezoneTemplate.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/enums/tmpl/StandardTimezoneTemplate.java @@ -15,8 +15,7 @@ */ public enum StandardTimezoneTemplate implements StandardTimezoneEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/ConstantEnumGenerator.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/ConstantEnumGenerator.java index d65bb7959..54b4f6bd6 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/ConstantEnumGenerator.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/ConstantEnumGenerator.java @@ -16,6 +16,7 @@ import java.nio.charset.StandardCharsets; import java.time.LocalDate; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Comparator; import java.util.HashMap; @@ -76,6 +77,7 @@ public static Builder builder() { public static class Builder { private File src; private String pkg; + Set exs = new HashSet<>(); public Builder setJavaSource(File src) { this.src = src; @@ -92,30 +94,48 @@ public Builder setJavaPackage(String pkg) { return this; } - public void generate(Class clazz, Collection pojos) throws IOException { - List enums = ConstantEnumGenerator.copyField(clazz, pojos); + public Builder addExcludeType(String typ) { + this.exs.add(typ); + return this; + } + + public Builder addExcludeType(String... typ) { + this.exs.addAll(Arrays.asList(typ)); + return this; + } + + public void generate(Class clazz, Collection pos) throws IOException { + List enums = ConstantEnumGenerator.copyField(clazz, pos); generate(enums); } - public void generate(Collection enums) throws IOException { - ConstantEnumGenerator.generate(src, pkg, enums); + public void generate(Collection pos) throws IOException { + ConstantEnumGenerator.generate(src, pkg, pos, exs); } } /** * first, copy ConstantEnumTemplate.java to /resource/ to avoid compile * - * @param src ./src/main/java/ - * @param pkg pro.fessional.wings.faceless.enums.constant - * @param pojos 对象数据 + * @param src ./src/main/java/ + * @param pkg pro.fessional.wings.faceless.enums.constant + * @param pojos 对象数据 + * @param excludes 排除的type组 * @throws IOException if IO exception * @see ConstantEnumTemplate */ - public static void generate(File src, String pkg, Collection pojos) throws IOException { + public static void generate(File src, String pkg, Collection pojos, Set excludes) throws IOException { // 初始 - Map> enums = pojos.stream().collect(Collectors.groupingBy(ConstantEnum::getType)); + Map> enums = pojos + .stream() + .filter(it -> excludes.isEmpty() || !excludes.contains(it.type)) + .collect(Collectors.groupingBy(ConstantEnum::getType)); + + int count = 1; + for (Map.Entry> e : enums.entrySet()) { + logger.info("load {} enum type = {}, count={}", count++, e.getKey(), e.getValue().size()); + } - logger.info("load enum count = {}", enums.size()); Set nowFiles = new HashSet<>(); File dst = new File(src, pkg.replace('.', '/')); dst.mkdirs(); @@ -167,7 +187,7 @@ private static String parse(ConstantEnum root, String pkg) { Pattern useIdAsKey = Pattern.compile("\\s*useIdAsKey\\s*=\\s*(false|true)"); Pattern className = Pattern.compile("public\\s+enum\\s+(\\S+)\\s+"); - List txt = null; + List txt; try { DefaultResourceLoader loader = new DefaultResourceLoader(); txt = InputStreams.readLine(loader.getResource(root.info).getInputStream()); @@ -221,10 +241,7 @@ private static String parse(ConstantEnum root, String pkg) { private static String merge(String tmpl, ConstantEnum root, String type, List list) { String pascal = javaClass(type); list.sort(Comparator.comparingLong(ConstantEnum::getId)); - String text = list - .stream() - .map(ConstantEnumGenerator::enumFiled) - .collect(Collectors.joining("\n")); + String text = fields(" ", list); tmpl = tmpl.replace(VAR_SUPER, text); tmpl = tmpl.replace(VAR_CLASS, pascal); @@ -240,48 +257,63 @@ private static boolean isSuper(ConstantEnum it) { return it.getId() % 100 == 0; } - private static String enumFiled(ConstantEnum it) { - StringBuilder sb = new StringBuilder(50); - sb.append(" "); - boolean isSuper = isSuper(it); - if (isSuper) { - sb.append("SUPER"); - } else { - String code = it.code; - int len = code.length(); - boolean canDeer = true; - for (int i = 0; i < len; i++) { - char c = code.charAt(i); - if (c == '-') { - sb.append('_'); - } else if (c >= 'a' && c <= 'z') { - sb.append(Character.toUpperCase(c)); - } else if (Character.isJavaIdentifierPart(c)) { - sb.append(c); - } else if (c > 127) { - sb.append(c); - } else { - if (sb.length() > 0 && canDeer) { - canDeer = false; - sb.append(A9); - continue; + private static String fields(String indent, List its) { + StringBuilder enums = new StringBuilder(); + StringBuilder codes = new StringBuilder(); + + for (ConstantEnum it : its) { + enums.append(indent); + codes.append(indent); + int idx = enums.length(); + boolean isSuper = isSuper(it); + if (isSuper) { + enums.append("SUPER"); + } else { + String code = it.code; + int len = code.length(); + boolean canDeer = true; + for (int i = 0; i < len; i++) { + char c = code.charAt(i); + if (c == '-') { + enums.append('_'); + } else if (c >= 'a' && c <= 'z') { + enums.append(Character.toUpperCase(c)); + } else if (Character.isJavaIdentifierPart(c)) { + enums.append(c); + } else if (c > 127) { + enums.append(c); + } else { + if (enums.length() > 0 && canDeer) { + canDeer = false; + enums.append(A9); + continue; + } } + canDeer = true; } - canDeer = true; } + String code = isSuper ? it.type : it.code; + // public static final String $CREATE_USER = "CREATE_USER" + codes.append("public static final String $"); + codes.append(enums, idx, enums.length()); + codes.append(" = \"").append(code).append("\";\n"); + + enums.append("(") + .append(it.id) + .append(", \"") + .append(code) + .append("\", \"") + .append(it.desc) + .append("\", \"") + .append(it.info) + .append("\"),\n"); } - sb.append("(") - .append(it.id) - .append(", \"") - .append(isSuper ? it.type : it.code) - .append("\", \"") - .append(it.desc) - .append("\", \"") - .append(it.info) - .append("\"),"); - - return sb.toString(); + enums.append(indent) + .append(";\n") + .append(codes.toString()) + ; + return enums.toString(); } @NotNull diff --git a/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java b/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java index 5781f3bcf..8f9c90a9a 100644 --- a/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java +++ b/wings-faceless/src/main/java/pro/fessional/wings/faceless/util/FlywaveRevisionScanner.java @@ -1,5 +1,7 @@ package pro.fessional.wings.faceless.util; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.core.io.Resource; import org.springframework.core.io.support.PathMatchingResourcePatternResolver; import org.springframework.util.StreamUtils; @@ -21,10 +23,15 @@ */ public class FlywaveRevisionScanner { + private static final Logger logger = LoggerFactory.getLogger(ConstantEnumGenerator.class); + public static final String REVISION_PATH_MASTER = "classpath*:/wings-flywave/master/**/*.sql"; public static final String REVISION_PATH_BRANCH_HEAD = "classpath*:/wings-flywave/branch/"; public static final String REVISION_PATH_BRANCH_TAIL = "**/*.sql"; public static final String REVISION_PATH_BRANCH_FULL = REVISION_PATH_BRANCH_HEAD + REVISION_PATH_BRANCH_TAIL; + public static final String REVISION_PATH_BRANCH_3RD_ENU18N = branchPath("features/enum-i18n"); + public static final String REVISION_PATH_BRANCH_FIX_V2_2_7 = branchPath("hotfixes/v2.2.7-fix"); + public static final long REVISION_1ST_SCHEMA = 2019_0512_01L; public static final long REVISION_2ND_IDLOGS = 2019_0520_01L; public static final long REVISION_3RD_ENU18N = 2019_0521_01L; @@ -56,7 +63,7 @@ public static String branchPath(String name) { } public static String commentInfo(String... path) { - Pattern tknRegex = Pattern.compile("[/\\\\]wings-flywave[/\\\\]([^:]*[/\\\\])\\d{8,}[uv]\\d{2,}([^/]*\\.sql)$", Pattern.CASE_INSENSITIVE); + Pattern tknRegex = Pattern.compile("[/\\\\]wings-flywave[/\\\\]([^:]*[/\\\\])[-_0-9]{8,}[uv][0-9]{2,}([^/]*\\.sql)$", Pattern.CASE_INSENSITIVE); LinkedHashSet info = new LinkedHashSet<>(); for (String s : path) { @@ -94,9 +101,9 @@ public static SortedMap scanBranch(Stri * String path = "file:src/main/resources/wings-flywave/master/"; // 具体文件 * * @param path 按Spring的格式写,classpath*:,classpath:等,默认[REVISIONSQL_PATH] + * @return 按版本号升序排列的TreeMap * @see PathMatchingResourcePatternResolver */ - public static SortedMap scan(@NotNull String... path) { TreeMap result = new TreeMap<>(); for (String p : path) { @@ -105,22 +112,36 @@ public static SortedMap scan(@NotNull S return result; } + /** + * @param result 排序map + * @param path 扫描路径 + * @see #scan(String...) + */ public static void scan(SortedMap result, String path) { String file = null; try { PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(); Resource[] resources = resolver.getResources(path); - Pattern reviRegex = Pattern.compile("(\\d{8,})([uv])(\\d{2,})[^/]*\\.sql$", Pattern.CASE_INSENSITIVE); + logger.info("[FlywaveRevisionScanner]🐝 scanned " + resources.length + " resources in path=" + path); + Pattern reviRegex = Pattern.compile("([-_0-9]{8,})([uv])([0-9]{2,})[^/]*\\.sql$", Pattern.CASE_INSENSITIVE); Charset utf8 = StandardCharsets.UTF_8; for (Resource res : resources) { file = res.getURL().getPath(); Matcher m = reviRegex.matcher(file); if (!m.find()) { + logger.info("[FlywaveRevisionScanner]🐝 skip unsupported resource=" + file); continue; } boolean undo = m.group(2).equalsIgnoreCase("u"); - long revi = Long.parseLong(m.group(1) + m.group(3)); + StringBuilder sb = new StringBuilder(10); + String g1 = m.group(1); + for (int i = 0; i < g1.length(); i++) { + char c = g1.charAt(i); + if (c >= '0' && c <= '9') sb.append(c); + } + sb.append(m.group(3)); + final long revi = Long.parseLong(sb.toString()); SchemaRevisionManager.RevisionSql d = result.computeIfAbsent(revi, key -> { SchemaRevisionManager.RevisionSql sql = new SchemaRevisionManager.RevisionSql(); @@ -131,9 +152,11 @@ public static void scan(SortedMap resul String text = StreamUtils.copyToString(res.getInputStream(), utf8); if (undo) { + logger.info("[FlywaveRevisionScanner]🐝 scan " + revi + " undo↓ resource=" + file); d.setUndoPath(file); d.setUndoText(text); } else { + logger.info("[FlywaveRevisionScanner]🐝 scan " + revi + " upto↑ resource=" + file); d.setUptoPath(file); d.setUptoText(text); } diff --git a/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/flywave/impl/DefaultRevisionManager.kt b/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/flywave/impl/DefaultRevisionManager.kt index 1f2dbb32d..66d53d01a 100644 --- a/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/flywave/impl/DefaultRevisionManager.kt +++ b/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/flywave/impl/DefaultRevisionManager.kt @@ -106,7 +106,7 @@ class DefaultRevisionManager( } // 检测和处理边界 - if (isUptoSql) { // 版本从低到高 + if (isUptoSql) { // 版本从低到高,重点不一致,或不存在 if (reviText.last.first != revision) { logger.warn("[publishRevision]🐝 skip the different upgrade end point , name={}, db-revi={}, to-revi={}", plainName, plainRevi, revision) continue diff --git a/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.kt b/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.kt index 5f42ee151..56b828b58 100644 --- a/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.kt +++ b/wings-faceless/src/main/kotlin/pro/fessional/wings/faceless/jooqgen/WingsCodeGenerator.kt @@ -70,10 +70,14 @@ object WingsCodeGenerator { } } + // 忽略注释,import排序和serialVersionUID // date = "2019-09-09T01:33:51.762Z", // schema version:2019090903 // serialVersionUID = 319604016; - val ignoreRegex = arrayOf("@Generated[^)]+", "serialVersionUID[^;]+") + val ignoreRegex = arrayOf( + "(import +[^\r\n]+;[\r\n ]+)+", + "@Generated[^)]+", + "serialVersionUID[^;]+") .joinToString("|") .toRegex(RegexOption.MULTILINE) for ((k, f) in from) { diff --git a/wings-faceless/src/main/resources/wings-conf/wings-flywave-79.properties b/wings-faceless/src/main/resources/wings-conf/wings-flywave-79.properties index 489f184ad..cfc3f4a7e 100644 --- a/wings-faceless/src/main/resources/wings-conf/wings-flywave-79.properties +++ b/wings-faceless/src/main/resources/wings-conf/wings-flywave-79.properties @@ -30,7 +30,7 @@ CREATE TABLE `{{TABLE_NAME}}$upd` ( \n\ wings.flywave.ver.trigger-update=\ CREATE TRIGGER `{{TABLE_NAME}}$bu` BEFORE UPDATE ON `{{TABLE_NAME}}` \n\ FOR EACH ROW BEGIN \n\ - INSERT INTO `{{TABLE_NAME}}$upd` SELECT NULL, NOW(), `*` FROM `{{TABLE_NAME}}` \n\ + INSERT INTO `{{TABLE_NAME}}$upd` SELECT NULL, NOW(3), `*` FROM `{{TABLE_NAME}}` \n\ WHERE id= OLD.id ; \n\ END @@ -47,6 +47,6 @@ CREATE TABLE `{{PLAIN_NAME}}$del` ( \n\ wings.flywave.ver.trigger-delete=\ CREATE TRIGGER `{{TABLE_NAME}}$bd` BEFORE DELETE ON `{{TABLE_NAME}}` \n\ FOR EACH ROW BEGIN \n\ - INSERT INTO `{{PLAIN_NAME}}$del` SELECT NULL, NOW(), `*` FROM `{{TABLE_NAME}}` \n\ + INSERT INTO `{{PLAIN_NAME}}$del` SELECT NULL, NOW(3), `*` FROM `{{TABLE_NAME}}` \n\ WHERE id= OLD.id ; \n\ END \ No newline at end of file diff --git a/wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/20190521u01-enum-i18n.sql b/wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/2019-05-21u01-enum-i18n.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/20190521u01-enum-i18n.sql rename to wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/2019-05-21u01-enum-i18n.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/20190521v01-enum-i18n.sql b/wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/2019-05-21v01-enum-i18n.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/20190521v01-enum-i18n.sql rename to wings-faceless/src/main/resources/wings-flywave/branch/features/enum-i18n/2019-05-21v01-enum-i18n.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/20190512u02-version-add-column.sql b/wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/2019-05-12u02-version-add-column.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/20190512u02-version-add-column.sql rename to wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/2019-05-12u02-version-add-column.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/20190512v02-version-add-column.sql b/wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/2019-05-12v02-version-add-column.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/20190512v02-version-add-column.sql rename to wings-faceless/src/main/resources/wings-flywave/branch/hotfixes/v2.2.7-fix/2019-05-12v02-version-add-column.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/master/init/20190512u01-version-journal.sql b/wings-faceless/src/main/resources/wings-flywave/master/init/2019-05-12u01-version-journal.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/master/init/20190512u01-version-journal.sql rename to wings-faceless/src/main/resources/wings-flywave/master/init/2019-05-12u01-version-journal.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/master/init/20190512v01-version-journal.sql b/wings-faceless/src/main/resources/wings-flywave/master/init/2019-05-12v01-version-journal.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/master/init/20190512v01-version-journal.sql rename to wings-faceless/src/main/resources/wings-flywave/master/init/2019-05-12v01-version-journal.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/master/m001/20190520u01-light-commit.sql b/wings-faceless/src/main/resources/wings-flywave/master/m001/2019-05-20u01-light-commit.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/master/m001/20190520u01-light-commit.sql rename to wings-faceless/src/main/resources/wings-flywave/master/m001/2019-05-20u01-light-commit.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/master/m001/20190520v01-light-commit.sql b/wings-faceless/src/main/resources/wings-flywave/master/m001/2019-05-20v01-light-commit.sql similarity index 100% rename from wings-faceless/src/main/resources/wings-flywave/master/m001/20190520v01-light-commit.sql rename to wings-faceless/src/main/resources/wings-flywave/master/m001/2019-05-20v01-light-commit.sql diff --git a/wings-faceless/src/main/resources/wings-flywave/readme.md b/wings-faceless/src/main/resources/wings-flywave/readme.md index 7a823ba21..5664f6727 100644 --- a/wings-faceless/src/main/resources/wings-flywave/readme.md +++ b/wings-faceless/src/main/resources/wings-flywave/readme.md @@ -14,7 +14,8 @@ ## 主版号 -`主版号`(version/major),使用yyMMdd的方式表述,一共6位数字。 +`主版号`(version/major),使用yyyyMMdd的方式表述,一共8位数字。 +数字部分,支持`_`或`-`分隔数字,以增加人眼识别度,如`yyyy-MM-dd`。 版本号要求严格递增,但不要求连续。 diff --git a/wings-faceless/src/main/resources/wings-tmpl/ConstantEnumTemplate.java b/wings-faceless/src/main/resources/wings-tmpl/ConstantEnumTemplate.java index 21cd717c1..f4e320c4e 100644 --- a/wings-faceless/src/main/resources/wings-tmpl/ConstantEnumTemplate.java +++ b/wings-faceless/src/main/resources/wings-tmpl/ConstantEnumTemplate.java @@ -11,8 +11,7 @@ */ public enum ConstantEnumTemplate implements ConstantEnum, StandardI18nEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/main/resources/wings-tmpl/StandardLanguageTemplate.java b/wings-faceless/src/main/resources/wings-tmpl/StandardLanguageTemplate.java index 14b68a883..0fb16f273 100644 --- a/wings-faceless/src/main/resources/wings-tmpl/StandardLanguageTemplate.java +++ b/wings-faceless/src/main/resources/wings-tmpl/StandardLanguageTemplate.java @@ -15,8 +15,7 @@ */ public enum StandardLanguageTemplate implements StandardLanguageEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/main/resources/wings-tmpl/StandardTimezoneTemplate.java b/wings-faceless/src/main/resources/wings-tmpl/StandardTimezoneTemplate.java index f6a40ef04..401d99d33 100644 --- a/wings-faceless/src/main/resources/wings-tmpl/StandardTimezoneTemplate.java +++ b/wings-faceless/src/main/resources/wings-tmpl/StandardTimezoneTemplate.java @@ -15,8 +15,7 @@ */ public enum StandardTimezoneTemplate implements StandardTimezoneEnum { - SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"), - ; + SUPER(1010100, "ConstantEnumTemplate", "性别", "性别"); public static final boolean useIdAsKey = false; diff --git a/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/ConstantEnumGenSample.java b/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/ConstantEnumGenSample.java index 2df87b030..d5c5a80d5 100644 --- a/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/ConstantEnumGenSample.java +++ b/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/ConstantEnumGenSample.java @@ -15,13 +15,21 @@ import java.util.List; /** + * 可以自己设置配置文件 * @author trydofor * @since 2020-06-10 - * @see pro.fessional.wings.faceless.enums.ConstantEnumI18nTest#test1Init */ @RunWith(SpringRunner.class) @ActiveProfiles("init") -@SpringBootTest(properties = {"debug = true", "spring.wings.enumi18n.enabled=true"}) +@SpringBootTest(properties = + {"debug = true", + "spring.wings.enumi18n.enabled=true", +// "spring.wings.flywave.enabled=true", +// "spring.shardingsphere.datasource.names=master", +// "spring.shardingsphere.datasource.master.jdbc-url=jdbc:mysql://127.0.0.1:3306/wings?autoReconnect=true&useSSL=false", +// "spring.shardingsphere.datasource.master.username=trydofor", +// "spring.shardingsphere.datasource.master.password=moilioncircle", + }) @Ignore("手动生成Java类,依赖分支feature/enum-i18n的2019052101, ConstantEnumI18nTest") public class ConstantEnumGenSample { diff --git a/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/JooqJavaCodeGenSample.java b/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/JooqJavaCodeGenSample.java index a347539aa..dc7914048 100644 --- a/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/JooqJavaCodeGenSample.java +++ b/wings-faceless/src/test/java/pro/fessional/wings/faceless/sample/JooqJavaCodeGenSample.java @@ -19,7 +19,7 @@ public static void main(String[] args) { .jdbcPassword("moilioncircle") .databaseSchema(database) .databaseIncludes("sys_commit_journal|sys_constant_enum|sys_standard_i18n") - .databaseExcludes("") + .databaseExcludes("sys_light_sequence|sys_schema_journal|sys_schema_version") // jdbc实现 .databaseVersionProvider("SELECT MAX(revision) FROM sys_schema_version WHERE apply_dt > '1000-01-01'") .targetPackage("pro.fessional.wings.faceless.database.autogen") .targetDirectory("wings-faceless/src/main/java/") diff --git a/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/OkHttpClientHelperTest.java b/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/OkHttpClientHelperTest.java index a42effb7c..01c34b251 100644 --- a/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/OkHttpClientHelperTest.java +++ b/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/OkHttpClientHelperTest.java @@ -23,7 +23,7 @@ @RunWith(SpringRunner.class) public class OkHttpClientHelperTest { - @Value("http://localhost:${local.server.port}") + @Setter(onMethod = @__({@Value("http://localhost:${local.server.port}")})) private String host; @Setter(onMethod = @__({@Autowired})) diff --git a/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/RestTemplateHelperTest.java b/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/RestTemplateHelperTest.java index 7735d732c..6646db038 100644 --- a/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/RestTemplateHelperTest.java +++ b/wings-silencer/src/test/java/pro/fessional/wings/silencer/httprest/RestTemplateHelperTest.java @@ -28,7 +28,7 @@ @RunWith(SpringRunner.class) public class RestTemplateHelperTest { - @Value("http://localhost:${local.server.port}") + @Setter(onMethod = @__({@Value("http://localhost:${local.server.port}")})) private String host; @Setter(onMethod = @__({@Autowired})) diff --git a/wings-slardar/pom.xml b/wings-slardar/pom.xml index 811f31029..289d52b32 100644 --- a/wings-slardar/pom.xml +++ b/wings-slardar/pom.xml @@ -74,11 +74,23 @@ guava
+ + org.springframework.boot + spring-boot-starter-cache + true + + + + org.redisson + redisson-spring-data-22 + true + org.springframework.boot spring-boot-starter-data-redis true + org.springframework.boot spring-boot-configuration-processor diff --git a/wings-slardar/readme.md b/wings-slardar/readme.md index dc2d18427..9104ab613 100644 --- a/wings-slardar/readme.md +++ b/wings-slardar/readme.md @@ -9,11 +9,17 @@ ## 3.1.OAuth2xFilter扩展 +只应在 AuthorizationServer使用,不需要在ResourceServer使用。 OAuth2比用户密码的登录方式更有利于扩展,十分成熟,被广泛使用和支持。 Slardar通过Filter增加`grant_type=password`的别名穿透机制,使 * 使用`password`模式,不暴露`client_secret` * 使获得UserDetail时,可以通过Context获得request参数。 + +别名`alias`的用途,除了因此oauth特征外,还用来识别登录类型,比如 +`oauth-password-alias=sms,em`,的配置,可以区分短信和邮件名登录。 +这样,`client-id`和`grant-type`和`password`别名有无数种组合, +达到在控制层识别,并控制验证行为。 这样在不污染Spring和OAuth2的情况下,可使`/oauth/token` 支持 @@ -23,7 +29,8 @@ Slardar通过Filter增加`grant_type=password`的别名穿透机制,使 方法级的权限控制`@EnableGlobalMethodSecurity(securedEnabled = true)`, 尽量使用`@Secured("IS_AUTHENTICATED_ANONYMOUSLY")`,这样会方便查找, -尽量不要使用表达式`@PreAuthorize("hasAuthority('ROLE_TELLER')")`。 +非复杂条件不用使用SpEL的`@PreAuthorize("hasAuthority('ROLE_TELLER')")`。 +@Secured只作用于`ROLE_*`,在不自定义`RoleVoter`时得用`@PreAuthorize` 一般情况下,不需要方法级的控制,在Security使用filter拦截更适合。 @@ -57,6 +64,10 @@ ResourceServer和`@Bean RemoteTokenServices tokenService()`即可。 public ResponseEntity handleException(Exception e) ``` +关于详细配置项,参考 wings-filter-oauth2x-79.properties 的注释 +`wings.slardar.oauth2x.client.*`是slardar特有的client,属于配置项, +能够被filter使用,会自动填充`client_secret`。 + ## 3.2.CaptchaFilter防扒 通过`WingsCaptchaContext`设置规则,可以实现全局的防扒验证码。 @@ -95,17 +106,87 @@ public ResponseEntity handleException(Exception e) * WingsOAuth2xContext.Context Oauth2有关的 * WingsTerminalContext.Context 登录终端有关的 -## 3.7.常见问题 +## 3.6.缓存Redis和Caffeine -001.修改过的默认配置 +默认提供caffeine和Redis缓存,可以注入 -slardar,使用undertow,并提供了一下默认配置 +* CaffeineCacheManager caffeineCacheManager +* RedisTemplate redisTemplate +* StringRedisTemplate stringRedisTemplate +* RedissonSpringCacheManager redissonCacheManager + +其中,caffeine默认开启,redis和redission需要引入依赖。 -002.不想使用oauth2内容 +三种不同缓存级别前缀,分别定义不同的ttl,idle,size +* `general.` - 标准配置,1天 +* `service.` - 服务级的,1小时 +* `session.` - 会话级的,10分钟 + +``` java +@Cacheable(key = "'all'", +value = LEVEL_GENERAL + "StandardRegion", +cacheManager = MANAGER_CAFFEINE) + +@CacheEvict(key = "'all'", +value = LEVEL_SERVICE + "StandardRegion", +cacheManager = MANAGER_REDISSON) +``` -## 3.9.参考资料 +## 3.7.参考资料 [OAuth 2 Developers Guide](https://projects.spring.io/spring-security-oauth/docs/oauth2.html) [OAuth2 boot](https://docs.spring.io/spring-security-oauth2-boot/docs/current/reference/htmlsingle/) [Spring Security](https://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/) + +## 3.8.常见问题 + +### 001.spring 找不到 RedissonSpringCacheManager + +在maven依赖中,把slardar以下3个optional的依赖引入 + +* spring-boot-starter-data-redis +* redisson-spring-data-22 + +### 002.修改过的默认配置 + +slardar,使用undertow,并提供了一下默认配置 + +### 003.不想使用oauth2内容 + +spring.wings.slardar.oauth2x.enabled=false + +### 004.本地docker redis 5 + +```bash +docker run -d \ + --name wings-redis \ + --restart=unless-stopped \ + -v /Users/trydofor/Docker/redis/data:/data \ + -p 6379:6379 \ +redis:5.0 \ +redis-server --requirepass moilioncircle +``` +### 005.Spring的Oauth2代码在哪里 + +org.springframework.security.oauth2.provider.endpoint + +* TokenEndpoint - `/oauth/token` +* AuthorizationEndpoint - `/oauth/authorize` + +### 006.Oauth登录 "invalid_client" + +需要设置client组的属性(id,secret等),密码一定要复杂。 +`wings.slardar.oauth2x.client.xxxx.client-*` +其中xxxx要保证唯一,可用来标识不同业务模块。 + +### 007.error处理,需要自定义page或handler + +需要根据spring约定和实际需要,自定义一套机制。 +但是不要使用`spring.mvc.throw-exception-if-no-handler-found=true`, +因为,异常之所以叫异常,就不能当做正常,避免用来处理正常事情。 + + * controller层异常用`@ControllerAdvice` 和 `@ExceptionHandler` + * service层异常,自行做业务处理,或AOP日志 + +[error-handling](https://docs.spring.io/spring-boot/docs/2.2.7.RELEASE/reference/htmlsingle/#boot-features-error-handling) diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/TypeIdI18nUserDetail.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/TypeIdI18nUserDetail.java index c893c4649..792bcca5c 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/TypeIdI18nUserDetail.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/TypeIdI18nUserDetail.java @@ -23,7 +23,7 @@ public interface TypeIdI18nUserDetail extends UserDetails { * * @return 类型 */ - long getUserType(); + int getUserType(); /** diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xLogin.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xHelper.java similarity index 92% rename from wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xLogin.java rename to wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xHelper.java index 1deabd097..9ac5209dd 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xLogin.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/security/WingsOAuth2xHelper.java @@ -11,6 +11,7 @@ import org.springframework.security.oauth2.client.http.OAuth2ErrorHandler; import org.springframework.security.oauth2.client.token.grant.password.ResourceOwnerPasswordResourceDetails; import org.springframework.security.oauth2.common.OAuth2AccessToken; +import org.springframework.security.oauth2.common.OAuth2RefreshToken; import org.springframework.security.oauth2.common.exceptions.OAuth2Exception; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; @@ -40,7 +41,7 @@ */ @Setter @Getter -public class WingsOAuth2xLogin { +public class WingsOAuth2xHelper { private String thirdTokenKey; private String renewTokenKey; @@ -116,17 +117,19 @@ public void login(HttpServletRequest request, HttpServletResponse response, Logi /** * 使用 RestTemplate 远程请求登录。 - * @ExceptionHandler(Exception.class) - * public ResponseEntity handleException(Exception e) throws Exception { - * return new DefaultWebResponseExceptionTranslator().translate(e); - * } + *
+     * @ExceptionHandler(OAuth2Exception.class)
+     * public ResponseEntity handleException(OAuth2Exception e) throws Exception {
+     *    return new DefaultWebResponseExceptionTranslator().translate(e);
+     * }
+     * 
* * @param tmpl Rest模板 * @param info 登录信息 * @return 远程返回的token * @throws OAuth2Exception */ - public OAuth2AccessToken login(RestTemplate tmpl, Login info) { + public OAuth2AccessToken login(RestTemplate tmpl, Login info) throws OAuth2Exception { MultiValueMap params = new LinkedMultiValueMap<>(); put(params, info.clientId, info.clientIdAlias == null ? CLIENT_ID : info.clientIdAlias); @@ -144,7 +147,7 @@ public OAuth2AccessToken login(RestTemplate tmpl, Login info) { WingsTerminalContext.Context ctx = SecurityContextUtil.getTerminalContext(); HttpHeaders head = headers; - if (ctx != null && ctx.getRemoteIp() != null) { + if (ctx.getRemoteIp() != null) { head = new HttpHeaders(headers); head.add("X-Real-IP", ctx.getRemoteIp()); head.add("User-Agent", ctx.getAgentInfo()); @@ -201,7 +204,15 @@ public String logout(RestTemplate tmpl, Logout info) { * @param accessToken 信息 */ public void logout(WingsTokenStore store, String accessToken) { - store.removeAccessToken(accessToken); + if (store == null || accessToken == null) return; + + OAuth2AccessToken at = store.readAccessToken(accessToken); + if (at == null) return; + store.removeAccessToken(at); + + OAuth2RefreshToken rt = at.getRefreshToken(); + if (rt == null) return; + store.removeRefreshToken(rt); } @Data diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/TypedRequestUtil.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/TypedRequestUtil.java index 7ce9fc1a9..b4e3c1dce 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/TypedRequestUtil.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/TypedRequestUtil.java @@ -17,8 +17,6 @@ * @since 2019-07-03 */ public class TypedRequestUtil { - private TypedRequestUtil() { - } @Nullable public static T getAttribute(HttpServletRequest request, String name, Class claz) { @@ -137,4 +135,35 @@ public static Map getParameter(Map param) { return rst; } + + /** + * 有些获得 headers中的Bearer然后 Parameter的access_token + * `Bearer`和`access_token` 不区分大小写,如果有多个token,取最后一个 + */ + @Nullable + public static String getAccessToken(HttpServletRequest request) { + String auth = request.getHeader("Authorization"); + String token = null; + if (auth != null) { + String bearer = "bearer"; + int p = auth.toLowerCase().indexOf(bearer); + if (p >= 0) { + token = auth.substring(p + bearer.length()).trim(); + } + } + if (token == null) { + token = request.getParameter("access_token"); + } + + if (token != null) { + int pos = token.indexOf(","); + if (pos > 0) { + String[] tks = token.split(","); + token = tks[tks.length - 1]; + } + token = token.trim(); + } + + return token; + } } diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsCaptchaFilter.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsCaptchaFilter.java index 12927db83..0d6039396 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsCaptchaFilter.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsCaptchaFilter.java @@ -232,7 +232,10 @@ public void pickSession(HttpServletRequest request, Set session) { String value = headers.nextElement(); if ((value.toLowerCase().startsWith(BEARER_LOWER))) { for (String part : value.substring(BEARER_LOWER.length()).trim().split(",")) { - session.add(part.trim()); + String trim = part.trim(); + if (trim.length() > 0) { + session.add(trim); + } } } } diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsOAuth2xFilter.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsOAuth2xFilter.java index b0d3fbb18..6d5dca06c 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsOAuth2xFilter.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/servlet/WingsOAuth2xFilter.java @@ -58,7 +58,7 @@ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) try { HttpServletRequest request = (HttpServletRequest) req; - ServletRequest nrq = wrapIfNeed(request); + HttpServletRequest nrq = wrapIfNeed(request); if (nrq != request) { WingsOAuth2xContext.set(TypedRequestUtil.getParameter(nrq.getParameterMap())); } @@ -118,7 +118,10 @@ private HttpServletRequest wrapIfNeed(HttpServletRequest request) { } if (cid != null && gtp != null && oauthPasswordAlias.contains(gtp)) { - param.put(CLIENT_SECRET, clientSecret.get(cid)); + String[] cst = clientSecret.get(cid); + if(cst != null) { + param.put(CLIENT_SECRET, cst); + } param.put(GRANT_TYPE, OAUTH_PASSWORD); param.put(OAUTH_PASSWORD_ALIAS, new String[]{gtp}); } @@ -138,7 +141,9 @@ public void setOrder(int order) { this.order = order; } - // + /** + * 配置内部client + */ @Data public static class Config { diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsCacheConfiguration.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsCacheConfiguration.java new file mode 100644 index 000000000..35af5044c --- /dev/null +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsCacheConfiguration.java @@ -0,0 +1,108 @@ +package pro.fessional.wings.slardar.spring.bean; + +import com.github.benmanes.caffeine.cache.Cache; +import com.github.benmanes.caffeine.cache.CacheLoader; +import com.github.benmanes.caffeine.cache.Caffeine; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.jetbrains.annotations.NotNull; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.cache.caffeine.CaffeineCacheManager; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.TimeUnit; + +/** + * @author trydofor + * @since 2019-12-03 + */ +@Configuration +@EnableCaching +@Slf4j +@ConditionalOnProperty(name = "spring.wings.slardar.cache.enabled", havingValue = "true") +public class WingsCacheConfiguration { + + public static final String MANAGER_CAFFEINE = "caffeineCacheManager"; + public static final String MANAGER_REDISSON = "redissonCacheManager"; + + public static final String LEVEL_GENERAL = "general."; + public static final String LEVEL_SERVICE = "service."; + public static final String LEVEL_SESSION = "session."; + + // //////////////////// caffeine //////////////////// + @Bean(MANAGER_CAFFEINE) + public CaffeineCacheManager caffeineCacheManager(CacheLevel conf) { + + final Map> caffeines = new HashMap<>(); + for (Map.Entry entry : conf.level.entrySet()) { + Conf c = entry.getValue(); + caffeines.put(entry.getKey(), newCaffeine(c.maxSize, c.ttl, c.maxIdleTime)); + } + + + CacheLoader loader = new CacheLoader() { + @Override + public Object load(@NotNull Object key) { + return null; + } + + @Override + public Object reload(@NotNull Object key, @NotNull Object oldValue) { + return oldValue; + } + }; + + CaffeineCacheManager cacheManager = new CaffeineCacheManager() { + @Override + @NotNull + protected Cache createNativeCaffeineCache(@NotNull String name) { + for (Map.Entry> entry : caffeines.entrySet()) { + if (name.startsWith(entry.getKey())) { + return entry.getValue().build(loader); + } + } + return super.createNativeCaffeineCache(name); + } + }; + + cacheManager.setAllowNullValues(false); + cacheManager.setCacheLoader(loader); + cacheManager.setCaffeine(newCaffeine(conf.maxSize, conf.ttl, conf.maxIdleTime)); + + return cacheManager; + } + + private Caffeine newCaffeine(int max, long ttl, long idle) { + return Caffeine.newBuilder() + .maximumSize(max <= 0 ? Integer.MAX_VALUE : max) + .expireAfterWrite(ttl <= 0 ? Integer.MAX_VALUE : ttl, TimeUnit.SECONDS) + .expireAfterAccess(idle <= 0 ? Integer.MAX_VALUE : idle, TimeUnit.SECONDS); + } + + @Bean + @ConfigurationProperties("wings.slardar.cache") + public CacheLevel cacheLevel() { + return new CacheLevel(); + } + + @Data + public static class CacheLevel { + private long ttl; + private long maxIdleTime; + private int maxSize; + + private Map level = new HashMap<>(); + } + + @Data + public static class Conf { + private long ttl; + private long maxIdleTime; + private int maxSize; + } +} diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsOAuth2xConfiguration.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsOAuth2xConfiguration.java index d0ab4126a..62ecf1338 100644 --- a/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsOAuth2xConfiguration.java +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsOAuth2xConfiguration.java @@ -44,7 +44,7 @@ import org.springframework.web.cors.CorsConfigurationSource; import pro.fessional.mirana.code.LeapCode; import pro.fessional.wings.slardar.security.JdkSerializationStrategy; -import pro.fessional.wings.slardar.security.WingsOAuth2xLogin; +import pro.fessional.wings.slardar.security.WingsOAuth2xHelper; import pro.fessional.wings.slardar.security.WingsTokenEnhancer; import pro.fessional.wings.slardar.security.WingsTokenStore; import pro.fessional.wings.slardar.servlet.WingsFilterOrder; @@ -90,18 +90,18 @@ public PasswordEncoder passwordEncoder(@Value("${wings.slardar.security.password } @Bean - @ConditionalOnMissingBean(WingsOAuth2xLogin.class) - public WingsOAuth2xLogin wingsOAuth2xLogin(Actoken actoken) { + @ConditionalOnMissingBean(WingsOAuth2xHelper.class) + public WingsOAuth2xHelper wingsOAuth2xLogin(Actoken actoken) { HttpHeaders headers = new HttpHeaders(); headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - WingsOAuth2xLogin login = new WingsOAuth2xLogin(); - login.setHeaders(headers); - login.setThirdTokenKey(actoken.thirdTokenKey); - login.setTokenLiveKey(actoken.tokenLiveKey); - login.setRenewTokenKey(actoken.renewTokenKey); + WingsOAuth2xHelper helper = new WingsOAuth2xHelper(); + helper.setHeaders(headers); + helper.setThirdTokenKey(actoken.thirdTokenKey); + helper.setTokenLiveKey(actoken.tokenLiveKey); + helper.setRenewTokenKey(actoken.renewTokenKey); - return login; + return helper; } @Bean @@ -115,10 +115,10 @@ public WingsTokenStore tokenStore(Actoken actoken) { } @Configuration - @ConditionalOnClass(RedisConnectionFactory.class) + @ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory") @ConditionalOnProperty(name = "wings.slardar.actoken.redis-store", havingValue = "true") @Order(Ordered.LOWEST_PRECEDENCE - 100) - public class Redis { + public class RedisTokenStoreAutowire { @Autowired public void tokenStore(TokenStore tokenStore, RedisConnectionFactory factory) { if (tokenStore instanceof WingsTokenStore) { diff --git a/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsResissonConfiguration.java b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsResissonConfiguration.java new file mode 100644 index 000000000..909ce9e30 --- /dev/null +++ b/wings-slardar/src/main/java/pro/fessional/wings/slardar/spring/bean/WingsResissonConfiguration.java @@ -0,0 +1,120 @@ +package pro.fessional.wings.slardar.spring.bean; + +import lombok.extern.slf4j.Slf4j; +import lombok.val; +import org.redisson.Redisson; +import org.redisson.api.RedissonClient; +import org.redisson.config.Config; +import org.redisson.spring.cache.CacheConfig; +import org.redisson.spring.cache.RedissonSpringCacheManager; +import org.redisson.spring.data.connection.RedissonConnectionFactory; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.autoconfigure.data.redis.RedisProperties; +import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.context.annotation.Primary; +import org.springframework.data.redis.connection.RedisConnectionFactory; +import org.springframework.data.redis.core.RedisTemplate; +import org.springframework.data.redis.core.StringRedisTemplate; + +import java.util.Map; + +import static pro.fessional.wings.slardar.spring.bean.WingsCacheConfiguration.MANAGER_REDISSON; + +/** + * @author trydofor + * @since 2019-12-03 + */ +@Configuration +@EnableCaching +@Slf4j +@ConditionalOnProperty(name = "spring.wings.slardar.redis.enabled", havingValue = "true") +@ConditionalOnClass(name = "org.springframework.data.redis.connection.RedisConnectionFactory") +public class WingsResissonConfiguration { + + // //////////////////// spring redis //////////////////// + @Bean + @ConditionalOnBean(RedisConnectionFactory.class) + public RedisTemplate redisTemplate(RedisConnectionFactory factory) { + val template = new RedisTemplate(); + template.setConnectionFactory(factory); + log.info("config redisson RedisTemplate"); + return template; + } + + @Bean + @ConditionalOnBean(RedisConnectionFactory.class) + public StringRedisTemplate stringRedisTemplate(RedisConnectionFactory factory) { + val template = new StringRedisTemplate(); + template.setConnectionFactory(factory); + return template; + } + + // //////////////////// redisson //////////////////// + + @Primary + @Bean(MANAGER_REDISSON) + @ConditionalOnBean(RedissonClient.class) + @ConditionalOnClass(name = "org.redisson.spring.cache.RedissonSpringCacheManager") + public RedissonSpringCacheManager redissonCacheManager(RedissonClient redissonClient, WingsCacheConfiguration.CacheLevel conf) { + + return new RedissonSpringCacheManager(redissonClient) { + private final ThreadLocal cacheName = new ThreadLocal<>(); + + @Override + public org.springframework.cache.Cache getCache(String name) { + cacheName.set(name); + return super.getCache(name); + } + + @Override + protected CacheConfig createDefaultConfig() { + String name = cacheName.get(); + cacheName.remove(); + if (name != null) { + for (Map.Entry entry : conf.getLevel().entrySet()) { + if (name.startsWith(entry.getKey())) { + WingsCacheConfiguration.Conf v = entry.getValue(); + return newRedisson(v.getMaxSize(), v.getTtl(), v.getMaxIdleTime()); + } + } + } + + return newRedisson(conf.getMaxSize(), conf.getTtl(), conf.getMaxIdleTime()); + } + }; + } + + private CacheConfig newRedisson(int max, long ttl, long idle) { + CacheConfig c = new CacheConfig(ttl * 1000, idle * 1000); + c.setMaxSize(max); + return c; + } + + @Bean + @ConditionalOnBean(RedissonClient.class) + @ConditionalOnClass(name = "org.redisson.spring.data.connection.RedissonConnectionFactory") + public RedisConnectionFactory redisConnectionFactory(RedissonClient redissonClient) { + return new RedissonConnectionFactory(redissonClient); + } + + @Bean(destroyMethod = "shutdown") + @ConditionalOnClass(name = "org.redisson.api.RedissonClient") + @ConditionalOnMissingBean(RedissonClient.class) + public RedissonClient redissonClient(RedisProperties redisProperties) { + val config = new Config(); + config.useSingleServer() + .setAddress("redis://" + redisProperties.getHost() + ":" + redisProperties.getPort()) + .setConnectTimeout((int) redisProperties.getTimeout().toMillis()) + .setDatabase(redisProperties.getDatabase()) + .setPassword(redisProperties.getPassword()) + ; + val client = Redisson.create(config); + log.info("config RedissonClient"); + return client; + } +} diff --git a/wings-slardar/src/main/resources/wings-conf/wings-cache-common.properties b/wings-slardar/src/main/resources/wings-conf/wings-cache-common.properties new file mode 100644 index 000000000..00b93a46b --- /dev/null +++ b/wings-slardar/src/main/resources/wings-conf/wings-cache-common.properties @@ -0,0 +1,22 @@ +spring.cache.type=redis +# use redisson + +# 默认值,单位seconds, 0=infinitely +wings.slardar.cache.ttl=3600 +wings.slardar.cache.maxIdleTime=0 +wings.slardar.cache.maxSize=0 + +# +wings.slardar.cache.level.general.ttl=86400 +wings.slardar.cache.level.general.maxIdleTime=0 +wings.slardar.cache.level.general.maxSize=0 + +# +wings.slardar.cache.level.service.ttl=3600 +wings.slardar.cache.level.service.maxIdleTime=0 +wings.slardar.cache.level.service.maxSize=0 + +# +wings.slardar.cache.level.session.ttl=600 +wings.slardar.cache.level.session.maxIdleTime=0 +wings.slardar.cache.level.session.maxSize=0 \ No newline at end of file diff --git a/wings-slardar/src/main/resources/wings-conf/wings-conditional-manager.properties b/wings-slardar/src/main/resources/wings-conf/wings-conditional-manager.properties index d6fddb144..656b02e4c 100644 --- a/wings-slardar/src/main/resources/wings-conf/wings-conditional-manager.properties +++ b/wings-slardar/src/main/resources/wings-conf/wings-conditional-manager.properties @@ -5,6 +5,10 @@ spring.wings.slardar.locale.enabled=true # 是否开启oauth2x配置 spring.wings.slardar.oauth2x.enabled=true # 是否开启captcha配置 -spring.wings.slardar.captcha.enabled=true +spring.wings.slardar.captcha.enabled=false +# 是否开启cache配置 +spring.wings.slardar.cache.enabled=true +# 是否开启redis(redission)配置 +spring.wings.slardar.redis.enabled=true # 是否开启熔断设置 spring.wings.slardar.overload.enabled=false \ No newline at end of file diff --git a/wings-slardar/src/main/resources/wings-conf/wings-filter-oauth2x-79.properties b/wings-slardar/src/main/resources/wings-conf/wings-filter-oauth2x-79.properties index d81c1c9e2..bd752eeb9 100644 --- a/wings-slardar/src/main/resources/wings-conf/wings-filter-oauth2x-79.properties +++ b/wings-slardar/src/main/resources/wings-conf/wings-filter-oauth2x-79.properties @@ -4,8 +4,9 @@ #{scrypt}$e0801$8bWJaSu2IKSn9Z9kM+TPXfOc/9bdYSrN1oD9qfVThWEwdRTnO7re7Ei+fUZRJ68k9lTyuTeUp4of4g24hHnazw==$OAOec05+bXxvuu/1qZ6NUR+xQYvYv7BeL1QxwRpY5Pc= wings.slardar.security.password-encoder=bcrypt -# 是否启用 wings token,是下2项的开关 -wings.slardar.actoken.redis-store=true +# 是否启用支持redis token store,需要有redis +wings.slardar.actoken.redis-store=false +# 是否使用actoken的wings加强,可共享第三方token wings.slardar.actoken.wings-enhance=true # wing下access_token前缀,用以区分 wings.slardar.actoken.wings-prefix="WG-" @@ -16,11 +17,12 @@ wings.slardar.actoken.renew-token-key="access_token_renew" # 定义更短的access-token-live,必须小于默认时长 wings.slardar.actoken.token-live-key="access_token_live" -# 单号分割的URI +# 逗号分割的URI数组 wings.slardar.oauth2x.endpoint-uri=/oauth/token # 别名用来轻度的隐藏oauth特征 # `client-id`和`grant-type`是oauth的key # `password`是oauth的value +# 所以alias都是逗号分隔的数组 wings.slardar.oauth2x.client-id-alias=cid wings.slardar.oauth2x.client-secret-alias=cst wings.slardar.oauth2x.grant-type-alias=gtp @@ -29,6 +31,7 @@ wings.slardar.oauth2x.oauth-password-alias=pdx, passwordx wings.slardar.oauth2x.access-token-live=2592000 wings.slardar.oauth2x.refresh-token-live=8640000 +# 可为不同模块的登录设置不同的client # 单个client的设置,其中`scope`和`grant-type`逗号分割数组 #wings.slardar.oauth2x.client.slardar.client-name=slardar测试 #wings.slardar.oauth2x.client.slardar.client-id=wings-slardar-id diff --git a/wings-slardar/src/main/resources/wings-conf/wings-spring-redis.properties b/wings-slardar/src/main/resources/wings-conf/wings-spring-redis.properties new file mode 100644 index 000000000..238fbc5e6 --- /dev/null +++ b/wings-slardar/src/main/resources/wings-conf/wings-spring-redis.properties @@ -0,0 +1,6 @@ +# spring 的标准配置 +spring.redis.host=localhost +spring.redis.password=moilioncircle +spring.redis.port=6379 +spring.redis.timeout=10000 +spring.redis.database=0 \ No newline at end of file diff --git a/wings-slardar/src/test/java/pro/fessional/wings/slardar/controller/TestOAuth2xController.java b/wings-slardar/src/test/java/pro/fessional/wings/slardar/controller/TestOAuth2xController.java index d7eb3f164..105866d78 100644 --- a/wings-slardar/src/test/java/pro/fessional/wings/slardar/controller/TestOAuth2xController.java +++ b/wings-slardar/src/test/java/pro/fessional/wings/slardar/controller/TestOAuth2xController.java @@ -15,7 +15,7 @@ import org.springframework.web.client.RestTemplate; import pro.fessional.wings.slardar.security.SecurityContextUtil; import pro.fessional.wings.slardar.security.WingsOAuth2xContext; -import pro.fessional.wings.slardar.security.WingsOAuth2xLogin; +import pro.fessional.wings.slardar.security.WingsOAuth2xHelper; import pro.fessional.wings.slardar.security.WingsTerminalContext; import pro.fessional.wings.slardar.security.WingsTokenEnhancer; import pro.fessional.wings.slardar.security.WingsTokenStore; @@ -32,7 +32,7 @@ public class TestOAuth2xController { @Setter(onMethod = @__({@Autowired})) - private WingsOAuth2xLogin wingsOAuth2xLogin; + private WingsOAuth2xHelper wingsOAuth2XHelper; @Setter(onMethod = @__({@Autowired})) private WingsTokenEnhancer wingsTokenEnhancer; @@ -81,7 +81,7 @@ public ResponseEntity handleException(Exception e) throws Excep @RequestMapping(value = {"/test/forward-login.html"}) public void forwardLogin(HttpServletRequest request, HttpServletResponse response) { - WingsOAuth2xLogin.Login info = new WingsOAuth2xLogin.Login(); + WingsOAuth2xHelper.Login info = new WingsOAuth2xHelper.Login(); info.setLoginUrl("/oauth/token"); info.setClientId("wings-slardar-id"); info.setUsername(request.getParameter("username")); @@ -94,13 +94,13 @@ public void forwardLogin(HttpServletRequest request, HttpServletResponse respons testUserDetailsService.setCredentialsNonExpired("1".equals(request.getParameter("CredentialsNonExpired"))); testUserDetailsService.setEnabled("1".equals(request.getParameter("Enabled"))); - wingsOAuth2xLogin.login(request, response, info); + wingsOAuth2XHelper.login(request, response, info); } @RequestMapping(value = {"/test/rest-login.html"}) @ResponseBody public OAuth2AccessToken restLogin(HttpServletRequest request) { - WingsOAuth2xLogin.Login info = new WingsOAuth2xLogin.Login(); + WingsOAuth2xHelper.Login info = new WingsOAuth2xHelper.Login(); info.setLoginUrl("http://localhost:8081/oauth/token"); info.setClientId("wings-slardar-id"); info.setUsername(request.getParameter("username")); @@ -115,14 +115,14 @@ public OAuth2AccessToken restLogin(HttpServletRequest request) { testUserDetailsService.setCredentialsNonExpired("1".equals(request.getParameter("CredentialsNonExpired"))); testUserDetailsService.setEnabled("1".equals(request.getParameter("Enabled"))); - OAuth2AccessToken login = wingsOAuth2xLogin.login(new RestTemplate(), info); + OAuth2AccessToken login = wingsOAuth2XHelper.login(new RestTemplate(), info); return login; } @RequestMapping(value = {"/test/store-logout.html"}) @ResponseBody public String tokenStoreLogout() { - wingsOAuth2xLogin.logout(wingsTokenStore, "bac0c873-e1cc-4740-8b9b-a903dcaaedfe"); + wingsOAuth2XHelper.logout(wingsTokenStore, "bac0c873-e1cc-4740-8b9b-a903dcaaedfe"); return "logout bac0c873-e1cc-4740-8b9b-a903dcaaedfe"; } } diff --git a/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestI18nUserDetail.java b/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestI18nUserDetail.java index 15e611503..30262924d 100644 --- a/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestI18nUserDetail.java +++ b/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestI18nUserDetail.java @@ -13,7 +13,7 @@ */ public class TestI18nUserDetail implements TypeIdI18nUserDetail { - private long userType; + private int userType; private long userId; private String username; private String password; @@ -28,7 +28,7 @@ public class TestI18nUserDetail implements TypeIdI18nUserDetail { private Locale locale = Locale.CHINA; - public void setUserType(long userType) { + public void setUserType(int userType) { this.userType = userType; } @@ -70,7 +70,7 @@ public long getUserId() { } @Override - public long getUserType() { + public int getUserType() { return userType; } diff --git a/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestUserDetailsService.java b/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestUserDetailsService.java index a97b8f243..2d0ddfee3 100644 --- a/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestUserDetailsService.java +++ b/wings-slardar/src/test/java/pro/fessional/wings/slardar/service/TestUserDetailsService.java @@ -55,7 +55,7 @@ public UserDetails loadUserByUsername(String username) { Authentication aut = SecurityContextHolder.getContext().getAuthentication(); System.out.println("WingsOAuth2xContext=" + ocx); TestI18nUserDetail detail = new TestI18nUserDetail(); - long idType = username.endsWith("2") ? 2L : 1L; + int idType = username.endsWith("2") ? 2 : 1; detail.setUserId(idType); detail.setUserType(idType); detail.setPassword(password); diff --git a/wings-slardar/src/test/resources/application.properties b/wings-slardar/src/test/resources/application.properties index 06efcbd99..bafddced8 100644 --- a/wings-slardar/src/test/resources/application.properties +++ b/wings-slardar/src/test/resources/application.properties @@ -1,2 +1 @@ -server.error.whitelabel.enabled=false server.port=8081 \ No newline at end of file