Skip to content

Commit

Permalink
🎨 refactor(1.1.1): improve code style
Browse files Browse the repository at this point in the history
1) StringUtils#isInclude
2) module cprouter
  • Loading branch information
ruan4261 committed Mar 8, 2021
1 parent 7116cd7 commit f2b3b7c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
7 changes: 5 additions & 2 deletions src/main/java/weaver/micro/devkit/util/StringUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@ public static String makeStackTraceInfo(Throwable t) {
* The minus sign cannot be used as separators.
*/
public static boolean isInclude(String s1, int val) {
Assert.notEmpty(s1);
int offset = 0;
Assert.notNull(s1);
int len = s1.length();
if (len == 0)
return false;

String s2 = Integer.toString(val);
int wid = s2.length();
int lastPossible = len - wid;

int offset = 0;
while (offset <= lastPossible) {
offset = s1.indexOf(s2, offset);
if (offset == -1)
Expand Down
17 changes: 4 additions & 13 deletions web/WEB-INF/micro/devkit/cprouter/router.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,12 @@
while (rs.next()) {
// 是否生效
boolean active = false;
int model = rs.getInt("model");
String nodeGroup = rs.getString("nodeid");
if (model == 0) {
active = true;
} else {
String nodeGroup = rs.getString("nodeid");
boolean modelMatch = StringUtils.isInclude(nodeGroup, nodeid);
if ((model == 1 && modelMatch) || (model == 2 && !modelMatch))
active = true;
}
if (active) {
if (model == 0
|| (model == 1 && StringUtils.isInclude(nodeGroup, nodeid))
|| (model == 2 && !StringUtils.isInclude(nodeGroup, nodeid))) {
String path = rs.getString("custompage");
int fileType = rs.getInt("file_type");
switch (fileType) {
Expand Down

0 comments on commit f2b3b7c

Please # to comment.