Commit f5badba2bb9f40695ab5d1e362a3f63298989a4d
1 parent
9ea0041f
添加{}使代码更容易理解
Showing
2 changed files
with
16 additions
and
8 deletions
ruoyi/src/main/java/com/ruoyi/common/utils/VerifyCodeUtils.java
| @@ -139,10 +139,12 @@ public class VerifyCodeUtils | @@ -139,10 +139,12 @@ public class VerifyCodeUtils | ||
| 139 | 139 | ||
| 140 | private static Color getRandColor(int fc, int bc) | 140 | private static Color getRandColor(int fc, int bc) |
| 141 | { | 141 | { |
| 142 | - if (fc > 255) | 142 | + if (fc > 255) { |
| 143 | fc = 255; | 143 | fc = 255; |
| 144 | - if (bc > 255) | 144 | + } |
| 145 | + if (bc > 255) { | ||
| 145 | bc = 255; | 146 | bc = 255; |
| 147 | + } | ||
| 146 | int r = fc + random.nextInt(bc - fc); | 148 | int r = fc + random.nextInt(bc - fc); |
| 147 | int g = fc + random.nextInt(bc - fc); | 149 | int g = fc + random.nextInt(bc - fc); |
| 148 | int b = fc + random.nextInt(bc - fc); | 150 | int b = fc + random.nextInt(bc - fc); |
ruoyi/src/main/java/com/ruoyi/common/utils/ip/IpUtils.java
| @@ -110,8 +110,9 @@ public class IpUtils | @@ -110,8 +110,9 @@ public class IpUtils | ||
| 110 | { | 110 | { |
| 111 | case 1: | 111 | case 1: |
| 112 | l = Long.parseLong(elements[0]); | 112 | l = Long.parseLong(elements[0]); |
| 113 | - if ((l < 0L) || (l > 4294967295L)) | 113 | + if ((l < 0L) || (l > 4294967295L)) { |
| 114 | return null; | 114 | return null; |
| 115 | + } | ||
| 115 | bytes[0] = (byte) (int) (l >> 24 & 0xFF); | 116 | bytes[0] = (byte) (int) (l >> 24 & 0xFF); |
| 116 | bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); | 117 | bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); |
| 117 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); | 118 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); |
| @@ -119,12 +120,14 @@ public class IpUtils | @@ -119,12 +120,14 @@ public class IpUtils | ||
| 119 | break; | 120 | break; |
| 120 | case 2: | 121 | case 2: |
| 121 | l = Integer.parseInt(elements[0]); | 122 | l = Integer.parseInt(elements[0]); |
| 122 | - if ((l < 0L) || (l > 255L)) | 123 | + if ((l < 0L) || (l > 255L)) { |
| 123 | return null; | 124 | return null; |
| 125 | + } | ||
| 124 | bytes[0] = (byte) (int) (l & 0xFF); | 126 | bytes[0] = (byte) (int) (l & 0xFF); |
| 125 | l = Integer.parseInt(elements[1]); | 127 | l = Integer.parseInt(elements[1]); |
| 126 | - if ((l < 0L) || (l > 16777215L)) | 128 | + if ((l < 0L) || (l > 16777215L)) { |
| 127 | return null; | 129 | return null; |
| 130 | + } | ||
| 128 | bytes[1] = (byte) (int) (l >> 16 & 0xFF); | 131 | bytes[1] = (byte) (int) (l >> 16 & 0xFF); |
| 129 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); | 132 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); |
| 130 | bytes[3] = (byte) (int) (l & 0xFF); | 133 | bytes[3] = (byte) (int) (l & 0xFF); |
| @@ -133,13 +136,15 @@ public class IpUtils | @@ -133,13 +136,15 @@ public class IpUtils | ||
| 133 | for (i = 0; i < 2; ++i) | 136 | for (i = 0; i < 2; ++i) |
| 134 | { | 137 | { |
| 135 | l = Integer.parseInt(elements[i]); | 138 | l = Integer.parseInt(elements[i]); |
| 136 | - if ((l < 0L) || (l > 255L)) | 139 | + if ((l < 0L) || (l > 255L)) { |
| 137 | return null; | 140 | return null; |
| 141 | + } | ||
| 138 | bytes[i] = (byte) (int) (l & 0xFF); | 142 | bytes[i] = (byte) (int) (l & 0xFF); |
| 139 | } | 143 | } |
| 140 | l = Integer.parseInt(elements[2]); | 144 | l = Integer.parseInt(elements[2]); |
| 141 | - if ((l < 0L) || (l > 65535L)) | 145 | + if ((l < 0L) || (l > 65535L)) { |
| 142 | return null; | 146 | return null; |
| 147 | + } | ||
| 143 | bytes[2] = (byte) (int) (l >> 8 & 0xFF); | 148 | bytes[2] = (byte) (int) (l >> 8 & 0xFF); |
| 144 | bytes[3] = (byte) (int) (l & 0xFF); | 149 | bytes[3] = (byte) (int) (l & 0xFF); |
| 145 | break; | 150 | break; |
| @@ -147,8 +152,9 @@ public class IpUtils | @@ -147,8 +152,9 @@ public class IpUtils | ||
| 147 | for (i = 0; i < 4; ++i) | 152 | for (i = 0; i < 4; ++i) |
| 148 | { | 153 | { |
| 149 | l = Integer.parseInt(elements[i]); | 154 | l = Integer.parseInt(elements[i]); |
| 150 | - if ((l < 0L) || (l > 255L)) | 155 | + if ((l < 0L) || (l > 255L)) { |
| 151 | return null; | 156 | return null; |
| 157 | + } | ||
| 152 | bytes[i] = (byte) (int) (l & 0xFF); | 158 | bytes[i] = (byte) (int) (l & 0xFF); |
| 153 | } | 159 | } |
| 154 | break; | 160 | break; |