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 | 139 | |
| 140 | 140 | private static Color getRandColor(int fc, int bc) |
| 141 | 141 | { |
| 142 | - if (fc > 255) | |
| 142 | + if (fc > 255) { | |
| 143 | 143 | fc = 255; |
| 144 | - if (bc > 255) | |
| 144 | + } | |
| 145 | + if (bc > 255) { | |
| 145 | 146 | bc = 255; |
| 147 | + } | |
| 146 | 148 | int r = fc + random.nextInt(bc - fc); |
| 147 | 149 | int g = fc + random.nextInt(bc - fc); |
| 148 | 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 | 110 | { |
| 111 | 111 | case 1: |
| 112 | 112 | l = Long.parseLong(elements[0]); |
| 113 | - if ((l < 0L) || (l > 4294967295L)) | |
| 113 | + if ((l < 0L) || (l > 4294967295L)) { | |
| 114 | 114 | return null; |
| 115 | + } | |
| 115 | 116 | bytes[0] = (byte) (int) (l >> 24 & 0xFF); |
| 116 | 117 | bytes[1] = (byte) (int) ((l & 0xFFFFFF) >> 16 & 0xFF); |
| 117 | 118 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); |
| ... | ... | @@ -119,12 +120,14 @@ public class IpUtils |
| 119 | 120 | break; |
| 120 | 121 | case 2: |
| 121 | 122 | l = Integer.parseInt(elements[0]); |
| 122 | - if ((l < 0L) || (l > 255L)) | |
| 123 | + if ((l < 0L) || (l > 255L)) { | |
| 123 | 124 | return null; |
| 125 | + } | |
| 124 | 126 | bytes[0] = (byte) (int) (l & 0xFF); |
| 125 | 127 | l = Integer.parseInt(elements[1]); |
| 126 | - if ((l < 0L) || (l > 16777215L)) | |
| 128 | + if ((l < 0L) || (l > 16777215L)) { | |
| 127 | 129 | return null; |
| 130 | + } | |
| 128 | 131 | bytes[1] = (byte) (int) (l >> 16 & 0xFF); |
| 129 | 132 | bytes[2] = (byte) (int) ((l & 0xFFFF) >> 8 & 0xFF); |
| 130 | 133 | bytes[3] = (byte) (int) (l & 0xFF); |
| ... | ... | @@ -133,13 +136,15 @@ public class IpUtils |
| 133 | 136 | for (i = 0; i < 2; ++i) |
| 134 | 137 | { |
| 135 | 138 | l = Integer.parseInt(elements[i]); |
| 136 | - if ((l < 0L) || (l > 255L)) | |
| 139 | + if ((l < 0L) || (l > 255L)) { | |
| 137 | 140 | return null; |
| 141 | + } | |
| 138 | 142 | bytes[i] = (byte) (int) (l & 0xFF); |
| 139 | 143 | } |
| 140 | 144 | l = Integer.parseInt(elements[2]); |
| 141 | - if ((l < 0L) || (l > 65535L)) | |
| 145 | + if ((l < 0L) || (l > 65535L)) { | |
| 142 | 146 | return null; |
| 147 | + } | |
| 143 | 148 | bytes[2] = (byte) (int) (l >> 8 & 0xFF); |
| 144 | 149 | bytes[3] = (byte) (int) (l & 0xFF); |
| 145 | 150 | break; |
| ... | ... | @@ -147,8 +152,9 @@ public class IpUtils |
| 147 | 152 | for (i = 0; i < 4; ++i) |
| 148 | 153 | { |
| 149 | 154 | l = Integer.parseInt(elements[i]); |
| 150 | - if ((l < 0L) || (l > 255L)) | |
| 155 | + if ((l < 0L) || (l > 255L)) { | |
| 151 | 156 | return null; |
| 157 | + } | |
| 152 | 158 | bytes[i] = (byte) (int) (l & 0xFF); |
| 153 | 159 | } |
| 154 | 160 | break; | ... | ... |